Commit | Line | Data |
---|---|---|
bdf21b18 | 1 | /* |
a92b0588 | 2 | * Platform device support for NXP PNX8550 SoCs |
bdf21b18 PP |
3 | * |
4 | * Copyright 2005, Embedded Alley Solutions, Inc | |
5 | * | |
6 | * Based on arch/mips/au1000/common/platform.c | |
7 | * Platform device support for Au1x00 SoCs. | |
8 | * | |
9 | * Copyright 2004, Matt Porter <mporter@kernel.crashing.org> | |
10 | * | |
11 | * This file is licensed under the terms of the GNU General Public | |
12 | * License version 2. This program is licensed "as is" without any | |
13 | * warranty of any kind, whether express or implied. | |
14 | */ | |
15 | #include <linux/device.h> | |
4b62220b | 16 | #include <linux/dma-mapping.h> |
bdf21b18 PP |
17 | #include <linux/kernel.h> |
18 | #include <linux/init.h> | |
19 | #include <linux/resource.h> | |
20 | #include <linux/serial.h> | |
7009af8c | 21 | #include <linux/serial_pnx8xxx.h> |
41d4f0e6 | 22 | #include <linux/platform_device.h> |
f2028bdf | 23 | #include <linux/usb/ohci_pdriver.h> |
bdf21b18 PP |
24 | |
25 | #include <int.h> | |
26 | #include <usb.h> | |
27 | #include <uart.h> | |
28 | ||
bdf21b18 PP |
29 | static struct resource pnx8550_usb_ohci_resources[] = { |
30 | [0] = { | |
31 | .start = PNX8550_USB_OHCI_OP_BASE, | |
32 | .end = PNX8550_USB_OHCI_OP_BASE + | |
33 | PNX8550_USB_OHCI_OP_LEN, | |
34 | .flags = IORESOURCE_MEM, | |
35 | }, | |
36 | [1] = { | |
37 | .start = PNX8550_INT_USB, | |
38 | .end = PNX8550_INT_USB, | |
39 | .flags = IORESOURCE_IRQ, | |
40 | }, | |
41 | }; | |
42 | ||
43 | static struct resource pnx8550_uart_resources[] = { | |
44 | [0] = { | |
45 | .start = PNX8550_UART_PORT0, | |
46 | .end = PNX8550_UART_PORT0 + 0xfff, | |
47 | .flags = IORESOURCE_MEM, | |
48 | }, | |
49 | [1] = { | |
50 | .start = PNX8550_UART_INT(0), | |
51 | .end = PNX8550_UART_INT(0), | |
52 | .flags = IORESOURCE_IRQ, | |
53 | }, | |
54 | [2] = { | |
55 | .start = PNX8550_UART_PORT1, | |
56 | .end = PNX8550_UART_PORT1 + 0xfff, | |
57 | .flags = IORESOURCE_MEM, | |
58 | }, | |
59 | [3] = { | |
60 | .start = PNX8550_UART_INT(1), | |
61 | .end = PNX8550_UART_INT(1), | |
62 | .flags = IORESOURCE_IRQ, | |
63 | }, | |
64 | }; | |
65 | ||
7009af8c | 66 | struct pnx8xxx_port pnx8xxx_ports[] = { |
bdf21b18 PP |
67 | [0] = { |
68 | .port = { | |
7009af8c | 69 | .type = PORT_PNX8XXX, |
9b4a1617 | 70 | .iotype = UPIO_MEM, |
bdf21b18 PP |
71 | .membase = (void __iomem *)PNX8550_UART_PORT0, |
72 | .mapbase = PNX8550_UART_PORT0, | |
73 | .irq = PNX8550_UART_INT(0), | |
74 | .uartclk = 3692300, | |
75 | .fifosize = 16, | |
59a675b2 | 76 | .flags = UPF_BOOT_AUTOCONF, |
bdf21b18 PP |
77 | .line = 0, |
78 | }, | |
79 | }, | |
80 | [1] = { | |
81 | .port = { | |
7009af8c | 82 | .type = PORT_PNX8XXX, |
9b4a1617 | 83 | .iotype = UPIO_MEM, |
bdf21b18 PP |
84 | .membase = (void __iomem *)PNX8550_UART_PORT1, |
85 | .mapbase = PNX8550_UART_PORT1, | |
86 | .irq = PNX8550_UART_INT(1), | |
87 | .uartclk = 3692300, | |
88 | .fifosize = 16, | |
59a675b2 | 89 | .flags = UPF_BOOT_AUTOCONF, |
bdf21b18 PP |
90 | .line = 1, |
91 | }, | |
92 | }, | |
93 | }; | |
94 | ||
95 | /* The dmamask must be set for OHCI to work */ | |
284901a9 | 96 | static u64 ohci_dmamask = DMA_BIT_MASK(32); |
bdf21b18 | 97 | |
284901a9 | 98 | static u64 uart_dmamask = DMA_BIT_MASK(32); |
bdf21b18 | 99 | |
f2028bdf FF |
100 | static int pnx8550_usb_ohci_power_on(struct platform_device *pdev) |
101 | { | |
102 | /* | |
103 | * Set register CLK48CTL to enable and 48MHz | |
104 | */ | |
105 | outl(0x00000003, PCI_BASE | 0x0004770c); | |
106 | ||
107 | /* | |
108 | * Set register CLK12CTL to enable and 48MHz | |
109 | */ | |
110 | outl(0x00000003, PCI_BASE | 0x00047710); | |
111 | ||
112 | udelay(100); | |
113 | ||
114 | return 0; | |
115 | } | |
116 | ||
117 | static void pnx8550_usb_ohci_power_off(struct platform_device *pdev) | |
118 | { | |
119 | udelay(10); | |
120 | } | |
121 | ||
122 | static struct usb_ohci_pdata pnx8550_usb_ohci_pdata = { | |
123 | .power_on = pnx8550_usb_ohci_power_on, | |
124 | .power_off = pnx8550_usb_ohci_power_off, | |
125 | }; | |
126 | ||
bdf21b18 | 127 | static struct platform_device pnx8550_usb_ohci_device = { |
f2028bdf | 128 | .name = "ohci-platform", |
bdf21b18 PP |
129 | .id = -1, |
130 | .dev = { | |
131 | .dma_mask = &ohci_dmamask, | |
284901a9 | 132 | .coherent_dma_mask = DMA_BIT_MASK(32), |
f2028bdf | 133 | .platform_data = &pnx8550_usb_ohci_pdata, |
bdf21b18 PP |
134 | }, |
135 | .num_resources = ARRAY_SIZE(pnx8550_usb_ohci_resources), | |
136 | .resource = pnx8550_usb_ohci_resources, | |
137 | }; | |
138 | ||
139 | static struct platform_device pnx8550_uart_device = { | |
7009af8c | 140 | .name = "pnx8xxx-uart", |
bdf21b18 PP |
141 | .id = -1, |
142 | .dev = { | |
143 | .dma_mask = &uart_dmamask, | |
284901a9 | 144 | .coherent_dma_mask = DMA_BIT_MASK(32), |
7009af8c | 145 | .platform_data = pnx8xxx_ports, |
bdf21b18 PP |
146 | }, |
147 | .num_resources = ARRAY_SIZE(pnx8550_uart_resources), | |
148 | .resource = pnx8550_uart_resources, | |
149 | }; | |
150 | ||
151 | static struct platform_device *pnx8550_platform_devices[] __initdata = { | |
152 | &pnx8550_usb_ohci_device, | |
153 | &pnx8550_uart_device, | |
154 | }; | |
155 | ||
f2c4b47f | 156 | static int __init pnx8550_platform_init(void) |
bdf21b18 PP |
157 | { |
158 | return platform_add_devices(pnx8550_platform_devices, | |
159 | ARRAY_SIZE(pnx8550_platform_devices)); | |
160 | } | |
161 | ||
162 | arch_initcall(pnx8550_platform_init); |