MIPS: eBPF: Fix icache flush end address
[linux/fpc-iii.git] / arch / mips / pnx833x / common / platform.c
blobdafbf027fad0185ea6af7df7b477313802a9102e
1 /*
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>
35 #include <irq.h>
36 #include <irq-mapping.h>
37 #include <pnx833x.h>
39 static u64 uart_dmamask = DMA_BIT_MASK(32);
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,
47 [1] = {
48 .start = PNX833X_PIC_UART0_INT,
49 .end = PNX833X_PIC_UART0_INT,
50 .flags = IORESOURCE_IRQ,
52 [2] = {
53 .start = PNX833X_UART1_PORTS_START,
54 .end = PNX833X_UART1_PORTS_END,
55 .flags = IORESOURCE_MEM,
57 [3] = {
58 .start = PNX833X_PIC_UART1_INT,
59 .end = PNX833X_PIC_UART1_INT,
60 .flags = IORESOURCE_IRQ,
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,
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,
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,
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[] = {
108 [0] = {
109 .start = PNX833X_USB_PORTS_START,
110 .end = PNX833X_USB_PORTS_END,
111 .flags = IORESOURCE_MEM,
113 [1] = {
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",
122 .id = -1,
123 .dev = {
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[] = {
134 [0] = {
135 .start = PNX8335_IP3902_PORTS_START,
136 .end = PNX8335_IP3902_PORTS_END,
137 .flags = IORESOURCE_MEM,
139 #ifdef CONFIG_SOC_PNX8335
140 [1] = {
141 .start = PNX8335_PIC_ETHERNET_INT,
142 .end = PNX8335_PIC_ETHERNET_INT,
143 .flags = IORESOURCE_IRQ,
145 #endif
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),
155 .num_resources = ARRAY_SIZE(pnx833x_ethernet_resources),
156 .resource = pnx833x_ethernet_resources,
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,
165 [1] = {
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",
174 .id = -1,
175 .num_resources = ARRAY_SIZE(pnx833x_sata_resources),
176 .resource = pnx833x_sata_resources,
179 static void
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)
185 return;
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));
193 static struct platform_nand_data pnx833x_flash_nand_data = {
194 .chip = {
195 .nr_chips = 1,
196 .chip_delay = 25,
198 .ctrl = {
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 = {
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,
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,
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);