dt-bindings: reset: imx7: Fix the spelling of 'indices'
[sfrench/cifs-2.6.git] / arch / mips / pnx833x / common / platform.c
1 /*
2  *  platform.c: platform support for PNX833X.
3  *
4  *  Copyright 2008 NXP Semiconductors
5  *        Chris Steel <chris.steel@nxp.com>
6  *    Daniel Laird <daniel.j.laird@nxp.com>
7  *
8  *  Based on software written by:
9  *      Nikita Youshchenko <yoush@debian.org>, based on PNX8550 code.
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 #include <linux/device.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/platform_device.h>
28 #include <linux/kernel.h>
29 #include <linux/init.h>
30 #include <linux/resource.h>
31 #include <linux/serial.h>
32 #include <linux/serial_pnx8xxx.h>
33 #include <linux/mtd/platnand.h>
34
35 #include <irq.h>
36 #include <irq-mapping.h>
37 #include <pnx833x.h>
38
39 static u64 uart_dmamask     = DMA_BIT_MASK(32);
40
41 static struct resource pnx833x_uart_resources[] = {
42         [0] = {
43                 .start          = PNX833X_UART0_PORTS_START,
44                 .end            = PNX833X_UART0_PORTS_END,
45                 .flags          = IORESOURCE_MEM,
46         },
47         [1] = {
48                 .start          = PNX833X_PIC_UART0_INT,
49                 .end            = PNX833X_PIC_UART0_INT,
50                 .flags          = IORESOURCE_IRQ,
51         },
52         [2] = {
53                 .start          = PNX833X_UART1_PORTS_START,
54                 .end            = PNX833X_UART1_PORTS_END,
55                 .flags          = IORESOURCE_MEM,
56         },
57         [3] = {
58                 .start          = PNX833X_PIC_UART1_INT,
59                 .end            = PNX833X_PIC_UART1_INT,
60                 .flags          = IORESOURCE_IRQ,
61         },
62 };
63
64 struct pnx8xxx_port pnx8xxx_ports[] = {
65         [0] = {
66                 .port   = {
67                         .type           = PORT_PNX8XXX,
68                         .iotype         = UPIO_MEM,
69                         .membase        = (void __iomem *)PNX833X_UART0_PORTS_START,
70                         .mapbase        = PNX833X_UART0_PORTS_START,
71                         .irq            = PNX833X_PIC_UART0_INT,
72                         .uartclk        = 3692300,
73                         .fifosize       = 16,
74                         .flags          = UPF_BOOT_AUTOCONF,
75                         .line           = 0,
76                 },
77         },
78         [1] = {
79                 .port   = {
80                         .type           = PORT_PNX8XXX,
81                         .iotype         = UPIO_MEM,
82                         .membase        = (void __iomem *)PNX833X_UART1_PORTS_START,
83                         .mapbase        = PNX833X_UART1_PORTS_START,
84                         .irq            = PNX833X_PIC_UART1_INT,
85                         .uartclk        = 3692300,
86                         .fifosize       = 16,
87                         .flags          = UPF_BOOT_AUTOCONF,
88                         .line           = 1,
89                 },
90         },
91 };
92
93 static struct platform_device pnx833x_uart_device = {
94         .name           = "pnx8xxx-uart",
95         .id             = -1,
96         .dev = {
97                 .dma_mask               = &uart_dmamask,
98                 .coherent_dma_mask      = DMA_BIT_MASK(32),
99                 .platform_data          = pnx8xxx_ports,
100         },
101         .num_resources  = ARRAY_SIZE(pnx833x_uart_resources),
102         .resource       = pnx833x_uart_resources,
103 };
104
105 static u64 ehci_dmamask     = DMA_BIT_MASK(32);
106
107 static struct resource pnx833x_usb_ehci_resources[] = {
108         [0] = {
109                 .start          = PNX833X_USB_PORTS_START,
110                 .end            = PNX833X_USB_PORTS_END,
111                 .flags          = IORESOURCE_MEM,
112         },
113         [1] = {
114                 .start          = PNX833X_PIC_USB_INT,
115                 .end            = PNX833X_PIC_USB_INT,
116                 .flags          = IORESOURCE_IRQ,
117         },
118 };
119
120 static struct platform_device pnx833x_usb_ehci_device = {
121         .name           = "pnx833x-ehci",
122         .id             = -1,
123         .dev = {
124                 .dma_mask               = &ehci_dmamask,
125                 .coherent_dma_mask      = DMA_BIT_MASK(32),
126         },
127         .num_resources  = ARRAY_SIZE(pnx833x_usb_ehci_resources),
128         .resource       = pnx833x_usb_ehci_resources,
129 };
130
131 static u64 ethernet_dmamask = DMA_BIT_MASK(32);
132
133 static struct resource pnx833x_ethernet_resources[] = {
134         [0] = {
135                 .start = PNX8335_IP3902_PORTS_START,
136                 .end   = PNX8335_IP3902_PORTS_END,
137                 .flags = IORESOURCE_MEM,
138         },
139 #ifdef CONFIG_SOC_PNX8335
140         [1] = {
141                 .start = PNX8335_PIC_ETHERNET_INT,
142                 .end   = PNX8335_PIC_ETHERNET_INT,
143                 .flags = IORESOURCE_IRQ,
144         },
145 #endif
146 };
147
148 static struct platform_device pnx833x_ethernet_device = {
149         .name = "ip3902-eth",
150         .id   = -1,
151         .dev  = {
152                 .dma_mask          = &ethernet_dmamask,
153                 .coherent_dma_mask = DMA_BIT_MASK(32),
154         },
155         .num_resources = ARRAY_SIZE(pnx833x_ethernet_resources),
156         .resource      = pnx833x_ethernet_resources,
157 };
158
159 static struct resource pnx833x_sata_resources[] = {
160         [0] = {
161                 .start = PNX8335_SATA_PORTS_START,
162                 .end   = PNX8335_SATA_PORTS_END,
163                 .flags = IORESOURCE_MEM,
164         },
165         [1] = {
166                 .start = PNX8335_PIC_SATA_INT,
167                 .end   = PNX8335_PIC_SATA_INT,
168                 .flags = IORESOURCE_IRQ,
169         },
170 };
171
172 static struct platform_device pnx833x_sata_device = {
173         .name          = "pnx833x-sata",
174         .id            = -1,
175         .num_resources = ARRAY_SIZE(pnx833x_sata_resources),
176         .resource      = pnx833x_sata_resources,
177 };
178
179 static void
180 pnx833x_flash_nand_cmd_ctrl(struct nand_chip *this, int cmd, unsigned int ctrl)
181 {
182         unsigned long nandaddr = (unsigned long)this->legacy.IO_ADDR_W;
183
184         if (cmd == NAND_CMD_NONE)
185                 return;
186
187         if (ctrl & NAND_CLE)
188                 writeb(cmd, (void __iomem *)(nandaddr + PNX8335_NAND_CLE_MASK));
189         else
190                 writeb(cmd, (void __iomem *)(nandaddr + PNX8335_NAND_ALE_MASK));
191 }
192
193 static struct platform_nand_data pnx833x_flash_nand_data = {
194         .chip = {
195                 .nr_chips               = 1,
196                 .chip_delay             = 25,
197         },
198         .ctrl = {
199                 .cmd_ctrl               = pnx833x_flash_nand_cmd_ctrl
200         }
201 };
202
203 /*
204  * Set start to be the correct address (PNX8335_NAND_BASE with no 0xb!!),
205  * 12 bytes more seems to be the standard that allows for NAND access.
206  */
207 static struct resource pnx833x_flash_nand_resource = {
208         .start  = PNX8335_NAND_BASE,
209         .end    = PNX8335_NAND_BASE + 12,
210         .flags  = IORESOURCE_MEM,
211 };
212
213 static struct platform_device pnx833x_flash_nand = {
214         .name           = "gen_nand",
215         .id                     = -1,
216         .num_resources  = 1,
217         .resource           = &pnx833x_flash_nand_resource,
218         .dev            = {
219                 .platform_data = &pnx833x_flash_nand_data,
220         },
221 };
222
223 static struct platform_device *pnx833x_platform_devices[] __initdata = {
224         &pnx833x_uart_device,
225         &pnx833x_usb_ehci_device,
226         &pnx833x_ethernet_device,
227         &pnx833x_sata_device,
228         &pnx833x_flash_nand,
229 };
230
231 static int __init pnx833x_platform_init(void)
232 {
233         return platform_add_devices(pnx833x_platform_devices,
234                                     ARRAY_SIZE(pnx833x_platform_devices));
235 }
236
237 arch_initcall(pnx833x_platform_init);