1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * platform.c: platform support for PNX833X.
5 * Copyright 2008 NXP Semiconductors
6 * Chris Steel <chris.steel@nxp.com>
7 * Daniel Laird <daniel.j.laird@nxp.com>
9 * Based on software written by:
10 * Nikita Youshchenko <yoush@debian.org>, based on PNX8550 code.
12 #include <linux/device.h>
13 #include <linux/dma-mapping.h>
14 #include <linux/platform_device.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/resource.h>
18 #include <linux/serial.h>
19 #include <linux/serial_pnx8xxx.h>
20 #include <linux/mtd/platnand.h>
23 #include <irq-mapping.h>
26 static u64 uart_dmamask
= DMA_BIT_MASK(32);
28 static struct resource pnx833x_uart_resources
[] = {
30 .start
= PNX833X_UART0_PORTS_START
,
31 .end
= PNX833X_UART0_PORTS_END
,
32 .flags
= IORESOURCE_MEM
,
35 .start
= PNX833X_PIC_UART0_INT
,
36 .end
= PNX833X_PIC_UART0_INT
,
37 .flags
= IORESOURCE_IRQ
,
40 .start
= PNX833X_UART1_PORTS_START
,
41 .end
= PNX833X_UART1_PORTS_END
,
42 .flags
= IORESOURCE_MEM
,
45 .start
= PNX833X_PIC_UART1_INT
,
46 .end
= PNX833X_PIC_UART1_INT
,
47 .flags
= IORESOURCE_IRQ
,
51 struct pnx8xxx_port pnx8xxx_ports
[] = {
56 .membase
= (void __iomem
*)PNX833X_UART0_PORTS_START
,
57 .mapbase
= PNX833X_UART0_PORTS_START
,
58 .irq
= PNX833X_PIC_UART0_INT
,
61 .flags
= UPF_BOOT_AUTOCONF
,
69 .membase
= (void __iomem
*)PNX833X_UART1_PORTS_START
,
70 .mapbase
= PNX833X_UART1_PORTS_START
,
71 .irq
= PNX833X_PIC_UART1_INT
,
74 .flags
= UPF_BOOT_AUTOCONF
,
80 static struct platform_device pnx833x_uart_device
= {
81 .name
= "pnx8xxx-uart",
84 .dma_mask
= &uart_dmamask
,
85 .coherent_dma_mask
= DMA_BIT_MASK(32),
86 .platform_data
= pnx8xxx_ports
,
88 .num_resources
= ARRAY_SIZE(pnx833x_uart_resources
),
89 .resource
= pnx833x_uart_resources
,
92 static u64 ehci_dmamask
= DMA_BIT_MASK(32);
94 static struct resource pnx833x_usb_ehci_resources
[] = {
96 .start
= PNX833X_USB_PORTS_START
,
97 .end
= PNX833X_USB_PORTS_END
,
98 .flags
= IORESOURCE_MEM
,
101 .start
= PNX833X_PIC_USB_INT
,
102 .end
= PNX833X_PIC_USB_INT
,
103 .flags
= IORESOURCE_IRQ
,
107 static struct platform_device pnx833x_usb_ehci_device
= {
108 .name
= "pnx833x-ehci",
111 .dma_mask
= &ehci_dmamask
,
112 .coherent_dma_mask
= DMA_BIT_MASK(32),
114 .num_resources
= ARRAY_SIZE(pnx833x_usb_ehci_resources
),
115 .resource
= pnx833x_usb_ehci_resources
,
118 static u64 ethernet_dmamask
= DMA_BIT_MASK(32);
120 static struct resource pnx833x_ethernet_resources
[] = {
122 .start
= PNX8335_IP3902_PORTS_START
,
123 .end
= PNX8335_IP3902_PORTS_END
,
124 .flags
= IORESOURCE_MEM
,
126 #ifdef CONFIG_SOC_PNX8335
128 .start
= PNX8335_PIC_ETHERNET_INT
,
129 .end
= PNX8335_PIC_ETHERNET_INT
,
130 .flags
= IORESOURCE_IRQ
,
135 static struct platform_device pnx833x_ethernet_device
= {
136 .name
= "ip3902-eth",
139 .dma_mask
= ðernet_dmamask
,
140 .coherent_dma_mask
= DMA_BIT_MASK(32),
142 .num_resources
= ARRAY_SIZE(pnx833x_ethernet_resources
),
143 .resource
= pnx833x_ethernet_resources
,
146 static struct resource pnx833x_sata_resources
[] = {
148 .start
= PNX8335_SATA_PORTS_START
,
149 .end
= PNX8335_SATA_PORTS_END
,
150 .flags
= IORESOURCE_MEM
,
153 .start
= PNX8335_PIC_SATA_INT
,
154 .end
= PNX8335_PIC_SATA_INT
,
155 .flags
= IORESOURCE_IRQ
,
159 static struct platform_device pnx833x_sata_device
= {
160 .name
= "pnx833x-sata",
162 .num_resources
= ARRAY_SIZE(pnx833x_sata_resources
),
163 .resource
= pnx833x_sata_resources
,
167 pnx833x_flash_nand_cmd_ctrl(struct nand_chip
*this, int cmd
, unsigned int ctrl
)
169 unsigned long nandaddr
= (unsigned long)this->legacy
.IO_ADDR_W
;
171 if (cmd
== NAND_CMD_NONE
)
175 writeb(cmd
, (void __iomem
*)(nandaddr
+ PNX8335_NAND_CLE_MASK
));
177 writeb(cmd
, (void __iomem
*)(nandaddr
+ PNX8335_NAND_ALE_MASK
));
180 static struct platform_nand_data pnx833x_flash_nand_data
= {
186 .cmd_ctrl
= pnx833x_flash_nand_cmd_ctrl
191 * Set start to be the correct address (PNX8335_NAND_BASE with no 0xb!!),
192 * 12 bytes more seems to be the standard that allows for NAND access.
194 static struct resource pnx833x_flash_nand_resource
= {
195 .start
= PNX8335_NAND_BASE
,
196 .end
= PNX8335_NAND_BASE
+ 12,
197 .flags
= IORESOURCE_MEM
,
200 static struct platform_device pnx833x_flash_nand
= {
204 .resource
= &pnx833x_flash_nand_resource
,
206 .platform_data
= &pnx833x_flash_nand_data
,
210 static struct platform_device
*pnx833x_platform_devices
[] __initdata
= {
211 &pnx833x_uart_device
,
212 &pnx833x_usb_ehci_device
,
213 &pnx833x_ethernet_device
,
214 &pnx833x_sata_device
,
218 static int __init
pnx833x_platform_init(void)
220 return platform_add_devices(pnx833x_platform_devices
,
221 ARRAY_SIZE(pnx833x_platform_devices
));
224 arch_initcall(pnx833x_platform_init
);