ARM: mmp: fix pxa168_device_usb_phy use on aspenite
[muen/linux.git] / arch / arm / mach-mmp / aspenite.c
1 /*
2  *  linux/arch/arm/mach-mmp/aspenite.c
3  *
4  *  Support for the Marvell PXA168-based Aspenite and Zylonite2
5  *  Development Platform.
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  publishhed by the Free Software Foundation.
10  */
11 #include <linux/gpio.h>
12 #include <linux/gpio-pxa.h>
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/platform_device.h>
16 #include <linux/smc91x.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/mtd/rawnand.h>
20 #include <linux/interrupt.h>
21 #include <linux/platform_data/mv_usb.h>
22
23 #include <asm/mach-types.h>
24 #include <asm/mach/arch.h>
25 #include <video/pxa168fb.h>
26 #include <linux/input.h>
27 #include <linux/platform_data/keypad-pxa27x.h>
28
29 #include "addr-map.h"
30 #include "mfp-pxa168.h"
31 #include "pxa168.h"
32 #include "pxa910.h"
33 #include "irqs.h"
34 #include "common.h"
35
36 static unsigned long common_pin_config[] __initdata = {
37         /* Data Flash Interface */
38         GPIO0_DFI_D15,
39         GPIO1_DFI_D14,
40         GPIO2_DFI_D13,
41         GPIO3_DFI_D12,
42         GPIO4_DFI_D11,
43         GPIO5_DFI_D10,
44         GPIO6_DFI_D9,
45         GPIO7_DFI_D8,
46         GPIO8_DFI_D7,
47         GPIO9_DFI_D6,
48         GPIO10_DFI_D5,
49         GPIO11_DFI_D4,
50         GPIO12_DFI_D3,
51         GPIO13_DFI_D2,
52         GPIO14_DFI_D1,
53         GPIO15_DFI_D0,
54
55         /* Static Memory Controller */
56         GPIO18_SMC_nCS0,
57         GPIO34_SMC_nCS1,
58         GPIO23_SMC_nLUA,
59         GPIO25_SMC_nLLA,
60         GPIO28_SMC_RDY,
61         GPIO29_SMC_SCLK,
62         GPIO35_SMC_BE1,
63         GPIO36_SMC_BE2,
64         GPIO27_GPIO,    /* Ethernet IRQ */
65
66         /* UART1 */
67         GPIO107_UART1_RXD,
68         GPIO108_UART1_TXD,
69
70         /* SSP1 */
71         GPIO113_I2S_MCLK,
72         GPIO114_I2S_FRM,
73         GPIO115_I2S_BCLK,
74         GPIO116_I2S_RXD,
75         GPIO117_I2S_TXD,
76
77         /* LCD */
78         GPIO56_LCD_FCLK_RD,
79         GPIO57_LCD_LCLK_A0,
80         GPIO58_LCD_PCLK_WR,
81         GPIO59_LCD_DENA_BIAS,
82         GPIO60_LCD_DD0,
83         GPIO61_LCD_DD1,
84         GPIO62_LCD_DD2,
85         GPIO63_LCD_DD3,
86         GPIO64_LCD_DD4,
87         GPIO65_LCD_DD5,
88         GPIO66_LCD_DD6,
89         GPIO67_LCD_DD7,
90         GPIO68_LCD_DD8,
91         GPIO69_LCD_DD9,
92         GPIO70_LCD_DD10,
93         GPIO71_LCD_DD11,
94         GPIO72_LCD_DD12,
95         GPIO73_LCD_DD13,
96         GPIO74_LCD_DD14,
97         GPIO75_LCD_DD15,
98         GPIO76_LCD_DD16,
99         GPIO77_LCD_DD17,
100         GPIO78_LCD_DD18,
101         GPIO79_LCD_DD19,
102         GPIO80_LCD_DD20,
103         GPIO81_LCD_DD21,
104         GPIO82_LCD_DD22,
105         GPIO83_LCD_DD23,
106
107         /* Keypad */
108         GPIO109_KP_MKIN1,
109         GPIO110_KP_MKIN0,
110         GPIO111_KP_MKOUT7,
111         GPIO112_KP_MKOUT6,
112         GPIO121_KP_MKIN4,
113 };
114
115 static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
116         .irq_base       = MMP_GPIO_TO_IRQ(0),
117 };
118
119 static struct smc91x_platdata smc91x_info = {
120         .flags  = SMC91X_USE_16BIT | SMC91X_NOWAIT,
121 };
122
123 static struct resource smc91x_resources[] = {
124         [0] = {
125                 .start  = SMC_CS1_PHYS_BASE + 0x300,
126                 .end    = SMC_CS1_PHYS_BASE + 0xfffff,
127                 .flags  = IORESOURCE_MEM,
128         },
129         [1] = {
130                 .start  = MMP_GPIO_TO_IRQ(27),
131                 .end    = MMP_GPIO_TO_IRQ(27),
132                 .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
133         }
134 };
135
136 static struct platform_device smc91x_device = {
137         .name           = "smc91x",
138         .id             = 0,
139         .dev            = {
140                 .platform_data = &smc91x_info,
141         },
142         .num_resources  = ARRAY_SIZE(smc91x_resources),
143         .resource       = smc91x_resources,
144 };
145
146 static struct mtd_partition aspenite_nand_partitions[] = {
147         {
148                 .name           = "bootloader",
149                 .offset         = 0,
150                 .size           = SZ_1M,
151                 .mask_flags     = MTD_WRITEABLE,
152         }, {
153                 .name           = "reserved",
154                 .offset         = MTDPART_OFS_APPEND,
155                 .size           = SZ_128K,
156                 .mask_flags     = MTD_WRITEABLE,
157         }, {
158                 .name           = "reserved",
159                 .offset         = MTDPART_OFS_APPEND,
160                 .size           = SZ_8M,
161                 .mask_flags     = MTD_WRITEABLE,
162         }, {
163                 .name           = "kernel",
164                 .offset         = MTDPART_OFS_APPEND,
165                 .size           = (SZ_2M + SZ_1M),
166                 .mask_flags     = 0,
167         }, {
168                 .name           = "filesystem",
169                 .offset         = MTDPART_OFS_APPEND,
170                 .size           = SZ_32M + SZ_16M,
171                 .mask_flags     = 0,
172         }
173 };
174
175 static struct pxa3xx_nand_platform_data aspenite_nand_info = {
176         .parts          = aspenite_nand_partitions,
177         .nr_parts       = ARRAY_SIZE(aspenite_nand_partitions),
178 };
179
180 static struct i2c_board_info aspenite_i2c_info[] __initdata = {
181         { I2C_BOARD_INFO("wm8753", 0x1b), },
182 };
183
184 static struct fb_videomode video_modes[] = {
185         [0] = {
186                 .pixclock       = 30120,
187                 .refresh        = 60,
188                 .xres           = 800,
189                 .yres           = 480,
190                 .hsync_len      = 1,
191                 .left_margin    = 215,
192                 .right_margin   = 40,
193                 .vsync_len      = 1,
194                 .upper_margin   = 34,
195                 .lower_margin   = 10,
196                 .sync           = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
197         },
198 };
199
200 struct pxa168fb_mach_info aspenite_lcd_info = {
201         .id                     = "Graphic Frame",
202         .modes                  = video_modes,
203         .num_modes              = ARRAY_SIZE(video_modes),
204         .pix_fmt                = PIX_FMT_RGB565,
205         .io_pin_allocation_mode = PIN_MODE_DUMB_24,
206         .dumb_mode              = DUMB_MODE_RGB888,
207         .active                 = 1,
208         .panel_rbswap           = 0,
209         .invert_pixclock        = 0,
210 };
211
212 static const unsigned int aspenite_matrix_key_map[] = {
213         KEY(0, 6, KEY_UP),      /* SW 4 */
214         KEY(0, 7, KEY_DOWN),    /* SW 5 */
215         KEY(1, 6, KEY_LEFT),    /* SW 6 */
216         KEY(1, 7, KEY_RIGHT),   /* SW 7 */
217         KEY(4, 6, KEY_ENTER),   /* SW 8 */
218         KEY(4, 7, KEY_ESC),     /* SW 9 */
219 };
220
221 static struct matrix_keymap_data aspenite_matrix_keymap_data = {
222         .keymap                 = aspenite_matrix_key_map,
223         .keymap_size            = ARRAY_SIZE(aspenite_matrix_key_map),
224 };
225
226 static struct pxa27x_keypad_platform_data aspenite_keypad_info __initdata = {
227         .matrix_key_rows        = 5,
228         .matrix_key_cols        = 8,
229         .matrix_keymap_data     = &aspenite_matrix_keymap_data,
230         .debounce_interval      = 30,
231 };
232
233 #if IS_ENABLED(CONFIG_USB_EHCI_MV)
234 static struct mv_usb_platform_data pxa168_sph_pdata = {
235         .mode           = MV_USB_MODE_HOST,
236         .phy_init       = pxa_usb_phy_init,
237         .phy_deinit     = pxa_usb_phy_deinit,
238         .set_vbus       = NULL,
239 };
240 #endif
241
242 static void __init common_init(void)
243 {
244         mfp_config(ARRAY_AND_SIZE(common_pin_config));
245
246         /* on-chip devices */
247         pxa168_add_uart(1);
248         pxa168_add_twsi(1, NULL, ARRAY_AND_SIZE(aspenite_i2c_info));
249         pxa168_add_ssp(1);
250         pxa168_add_nand(&aspenite_nand_info);
251         pxa168_add_fb(&aspenite_lcd_info);
252         pxa168_add_keypad(&aspenite_keypad_info);
253         platform_device_add_data(&pxa168_device_gpio, &pxa168_gpio_pdata,
254                                  sizeof(struct pxa_gpio_platform_data));
255         platform_device_register(&pxa168_device_gpio);
256
257         /* off-chip devices */
258         platform_device_register(&smc91x_device);
259
260 #if IS_ENABLED(CONFIG_USB_SUPPORT)
261 #if IS_ENABLED(CONFIG_PHY_PXA_USB)
262         platform_device_register(&pxa168_device_usb_phy);
263 #endif
264
265 #if IS_ENABLED(CONFIG_USB_EHCI_MV)
266         pxa168_add_usb_host(&pxa168_sph_pdata);
267 #endif
268 #endif
269 }
270
271 MACHINE_START(ASPENITE, "PXA168-based Aspenite Development Platform")
272         .map_io         = mmp_map_io,
273         .nr_irqs        = MMP_NR_IRQS,
274         .init_irq       = pxa168_init_irq,
275         .init_time      = pxa168_timer_init,
276         .init_machine   = common_init,
277         .restart        = pxa168_restart,
278 MACHINE_END
279
280 MACHINE_START(ZYLONITE2, "PXA168-based Zylonite2 Development Platform")
281         .map_io         = mmp_map_io,
282         .nr_irqs        = MMP_NR_IRQS,
283         .init_irq       = pxa168_init_irq,
284         .init_time      = pxa168_timer_init,
285         .init_machine   = common_init,
286         .restart        = pxa168_restart,
287 MACHINE_END