2 * platform.c: platform support for PNX833X.
4 * Copyright 2008 NXP Semiconductors
5 * Chris Steel <chris.steel@nxp.com>
6 * Daniel Laird <daniel.j.laird@nxp.com>
8 * Based on software written by:
9 * Nikita Youshchenko <yoush@debian.org>, based on PNX8550 code.
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.
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.
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.
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/nand.h>
34 #include <linux/mtd/partitions.h>
37 #include <irq-mapping.h>
40 static u64 uart_dmamask
= DMA_BIT_MASK(32);
42 static struct resource pnx833x_uart_resources
[] = {
44 .start
= PNX833X_UART0_PORTS_START
,
45 .end
= PNX833X_UART0_PORTS_END
,
46 .flags
= IORESOURCE_MEM
,
49 .start
= PNX833X_PIC_UART0_INT
,
50 .end
= PNX833X_PIC_UART0_INT
,
51 .flags
= IORESOURCE_IRQ
,
54 .start
= PNX833X_UART1_PORTS_START
,
55 .end
= PNX833X_UART1_PORTS_END
,
56 .flags
= IORESOURCE_MEM
,
59 .start
= PNX833X_PIC_UART1_INT
,
60 .end
= PNX833X_PIC_UART1_INT
,
61 .flags
= IORESOURCE_IRQ
,
65 struct pnx8xxx_port pnx8xxx_ports
[] = {
70 .membase
= (void __iomem
*)PNX833X_UART0_PORTS_START
,
71 .mapbase
= PNX833X_UART0_PORTS_START
,
72 .irq
= PNX833X_PIC_UART0_INT
,
75 .flags
= UPF_BOOT_AUTOCONF
,
83 .membase
= (void __iomem
*)PNX833X_UART1_PORTS_START
,
84 .mapbase
= PNX833X_UART1_PORTS_START
,
85 .irq
= PNX833X_PIC_UART1_INT
,
88 .flags
= UPF_BOOT_AUTOCONF
,
94 static struct platform_device pnx833x_uart_device
= {
95 .name
= "pnx8xxx-uart",
98 .dma_mask
= &uart_dmamask
,
99 .coherent_dma_mask
= DMA_BIT_MASK(32),
100 .platform_data
= pnx8xxx_ports
,
102 .num_resources
= ARRAY_SIZE(pnx833x_uart_resources
),
103 .resource
= pnx833x_uart_resources
,
106 static u64 ehci_dmamask
= DMA_BIT_MASK(32);
108 static struct resource pnx833x_usb_ehci_resources
[] = {
110 .start
= PNX833X_USB_PORTS_START
,
111 .end
= PNX833X_USB_PORTS_END
,
112 .flags
= IORESOURCE_MEM
,
115 .start
= PNX833X_PIC_USB_INT
,
116 .end
= PNX833X_PIC_USB_INT
,
117 .flags
= IORESOURCE_IRQ
,
121 static struct platform_device pnx833x_usb_ehci_device
= {
122 .name
= "pnx833x-ehci",
125 .dma_mask
= &ehci_dmamask
,
126 .coherent_dma_mask
= DMA_BIT_MASK(32),
128 .num_resources
= ARRAY_SIZE(pnx833x_usb_ehci_resources
),
129 .resource
= pnx833x_usb_ehci_resources
,
132 static u64 ethernet_dmamask
= DMA_BIT_MASK(32);
134 static struct resource pnx833x_ethernet_resources
[] = {
136 .start
= PNX8335_IP3902_PORTS_START
,
137 .end
= PNX8335_IP3902_PORTS_END
,
138 .flags
= IORESOURCE_MEM
,
140 #ifdef CONFIG_SOC_PNX8335
142 .start
= PNX8335_PIC_ETHERNET_INT
,
143 .end
= PNX8335_PIC_ETHERNET_INT
,
144 .flags
= IORESOURCE_IRQ
,
149 static struct platform_device pnx833x_ethernet_device
= {
150 .name
= "ip3902-eth",
153 .dma_mask
= ðernet_dmamask
,
154 .coherent_dma_mask
= DMA_BIT_MASK(32),
156 .num_resources
= ARRAY_SIZE(pnx833x_ethernet_resources
),
157 .resource
= pnx833x_ethernet_resources
,
160 static struct resource pnx833x_sata_resources
[] = {
162 .start
= PNX8335_SATA_PORTS_START
,
163 .end
= PNX8335_SATA_PORTS_END
,
164 .flags
= IORESOURCE_MEM
,
167 .start
= PNX8335_PIC_SATA_INT
,
168 .end
= PNX8335_PIC_SATA_INT
,
169 .flags
= IORESOURCE_IRQ
,
173 static struct platform_device pnx833x_sata_device
= {
174 .name
= "pnx833x-sata",
176 .num_resources
= ARRAY_SIZE(pnx833x_sata_resources
),
177 .resource
= pnx833x_sata_resources
,
181 pnx833x_flash_nand_cmd_ctrl(struct mtd_info
*mtd
, int cmd
, unsigned int ctrl
)
183 struct nand_chip
*this = mtd_to_nand(mtd
);
184 unsigned long nandaddr
= (unsigned long)this->IO_ADDR_W
;
186 if (cmd
== NAND_CMD_NONE
)
190 writeb(cmd
, (void __iomem
*)(nandaddr
+ PNX8335_NAND_CLE_MASK
));
192 writeb(cmd
, (void __iomem
*)(nandaddr
+ PNX8335_NAND_ALE_MASK
));
195 static struct platform_nand_data pnx833x_flash_nand_data
= {
201 .cmd_ctrl
= pnx833x_flash_nand_cmd_ctrl
206 * Set start to be the correct address (PNX8335_NAND_BASE with no 0xb!!),
207 * 12 bytes more seems to be the standard that allows for NAND access.
209 static struct resource pnx833x_flash_nand_resource
= {
210 .start
= PNX8335_NAND_BASE
,
211 .end
= PNX8335_NAND_BASE
+ 12,
212 .flags
= IORESOURCE_MEM
,
215 static struct platform_device pnx833x_flash_nand
= {
219 .resource
= &pnx833x_flash_nand_resource
,
221 .platform_data
= &pnx833x_flash_nand_data
,
225 static struct platform_device
*pnx833x_platform_devices
[] __initdata
= {
226 &pnx833x_uart_device
,
227 &pnx833x_usb_ehci_device
,
228 &pnx833x_ethernet_device
,
229 &pnx833x_sata_device
,
233 static int __init
pnx833x_platform_init(void)
237 res
= platform_add_devices(pnx833x_platform_devices
,
238 ARRAY_SIZE(pnx833x_platform_devices
));
243 arch_initcall(pnx833x_platform_init
);