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/platnand.h>
36 #include <irq-mapping.h>
39 static u64 uart_dmamask
= DMA_BIT_MASK(32);
41 static struct resource pnx833x_uart_resources
[] = {
43 .start
= PNX833X_UART0_PORTS_START
,
44 .end
= PNX833X_UART0_PORTS_END
,
45 .flags
= IORESOURCE_MEM
,
48 .start
= PNX833X_PIC_UART0_INT
,
49 .end
= PNX833X_PIC_UART0_INT
,
50 .flags
= IORESOURCE_IRQ
,
53 .start
= PNX833X_UART1_PORTS_START
,
54 .end
= PNX833X_UART1_PORTS_END
,
55 .flags
= IORESOURCE_MEM
,
58 .start
= PNX833X_PIC_UART1_INT
,
59 .end
= PNX833X_PIC_UART1_INT
,
60 .flags
= IORESOURCE_IRQ
,
64 struct pnx8xxx_port pnx8xxx_ports
[] = {
69 .membase
= (void __iomem
*)PNX833X_UART0_PORTS_START
,
70 .mapbase
= PNX833X_UART0_PORTS_START
,
71 .irq
= PNX833X_PIC_UART0_INT
,
74 .flags
= UPF_BOOT_AUTOCONF
,
82 .membase
= (void __iomem
*)PNX833X_UART1_PORTS_START
,
83 .mapbase
= PNX833X_UART1_PORTS_START
,
84 .irq
= PNX833X_PIC_UART1_INT
,
87 .flags
= UPF_BOOT_AUTOCONF
,
93 static struct platform_device pnx833x_uart_device
= {
94 .name
= "pnx8xxx-uart",
97 .dma_mask
= &uart_dmamask
,
98 .coherent_dma_mask
= DMA_BIT_MASK(32),
99 .platform_data
= pnx8xxx_ports
,
101 .num_resources
= ARRAY_SIZE(pnx833x_uart_resources
),
102 .resource
= pnx833x_uart_resources
,
105 static u64 ehci_dmamask
= DMA_BIT_MASK(32);
107 static struct resource pnx833x_usb_ehci_resources
[] = {
109 .start
= PNX833X_USB_PORTS_START
,
110 .end
= PNX833X_USB_PORTS_END
,
111 .flags
= IORESOURCE_MEM
,
114 .start
= PNX833X_PIC_USB_INT
,
115 .end
= PNX833X_PIC_USB_INT
,
116 .flags
= IORESOURCE_IRQ
,
120 static struct platform_device pnx833x_usb_ehci_device
= {
121 .name
= "pnx833x-ehci",
124 .dma_mask
= &ehci_dmamask
,
125 .coherent_dma_mask
= DMA_BIT_MASK(32),
127 .num_resources
= ARRAY_SIZE(pnx833x_usb_ehci_resources
),
128 .resource
= pnx833x_usb_ehci_resources
,
131 static u64 ethernet_dmamask
= DMA_BIT_MASK(32);
133 static struct resource pnx833x_ethernet_resources
[] = {
135 .start
= PNX8335_IP3902_PORTS_START
,
136 .end
= PNX8335_IP3902_PORTS_END
,
137 .flags
= IORESOURCE_MEM
,
139 #ifdef CONFIG_SOC_PNX8335
141 .start
= PNX8335_PIC_ETHERNET_INT
,
142 .end
= PNX8335_PIC_ETHERNET_INT
,
143 .flags
= IORESOURCE_IRQ
,
148 static struct platform_device pnx833x_ethernet_device
= {
149 .name
= "ip3902-eth",
152 .dma_mask
= ðernet_dmamask
,
153 .coherent_dma_mask
= DMA_BIT_MASK(32),
155 .num_resources
= ARRAY_SIZE(pnx833x_ethernet_resources
),
156 .resource
= pnx833x_ethernet_resources
,
159 static struct resource pnx833x_sata_resources
[] = {
161 .start
= PNX8335_SATA_PORTS_START
,
162 .end
= PNX8335_SATA_PORTS_END
,
163 .flags
= IORESOURCE_MEM
,
166 .start
= PNX8335_PIC_SATA_INT
,
167 .end
= PNX8335_PIC_SATA_INT
,
168 .flags
= IORESOURCE_IRQ
,
172 static struct platform_device pnx833x_sata_device
= {
173 .name
= "pnx833x-sata",
175 .num_resources
= ARRAY_SIZE(pnx833x_sata_resources
),
176 .resource
= pnx833x_sata_resources
,
180 pnx833x_flash_nand_cmd_ctrl(struct nand_chip
*this, int cmd
, unsigned int ctrl
)
182 unsigned long nandaddr
= (unsigned long)this->legacy
.IO_ADDR_W
;
184 if (cmd
== NAND_CMD_NONE
)
188 writeb(cmd
, (void __iomem
*)(nandaddr
+ PNX8335_NAND_CLE_MASK
));
190 writeb(cmd
, (void __iomem
*)(nandaddr
+ PNX8335_NAND_ALE_MASK
));
193 static struct platform_nand_data pnx833x_flash_nand_data
= {
199 .cmd_ctrl
= pnx833x_flash_nand_cmd_ctrl
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.
207 static struct resource pnx833x_flash_nand_resource
= {
208 .start
= PNX8335_NAND_BASE
,
209 .end
= PNX8335_NAND_BASE
+ 12,
210 .flags
= IORESOURCE_MEM
,
213 static struct platform_device pnx833x_flash_nand
= {
217 .resource
= &pnx833x_flash_nand_resource
,
219 .platform_data
= &pnx833x_flash_nand_data
,
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
,
231 static int __init
pnx833x_platform_init(void)
233 return platform_add_devices(pnx833x_platform_devices
,
234 ARRAY_SIZE(pnx833x_platform_devices
));
237 arch_initcall(pnx833x_platform_init
);