Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / arm / mach-pxa / zylonite.c
blobe1b5e4c14579663de80bd684818c7017111763d7
1 /*
2 * linux/arch/arm/mach-pxa/zylonite.c
4 * Support for the PXA3xx Development Platform (aka Zylonite)
6 * Copyright (C) 2006 Marvell International Ltd.
8 * 2007-09-04: eric miao <eric.miao@marvell.com>
9 * rewrite to align with latest kernel
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/interrupt.h>
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
24 #include <asm/hardware.h>
25 #include <asm/arch/gpio.h>
26 #include <asm/arch/pxafb.h>
27 #include <asm/arch/zylonite.h>
28 #include <asm/arch/mmc.h>
30 #include "generic.h"
32 #define MAX_SLOTS 3
33 struct platform_mmc_slot zylonite_mmc_slot[MAX_SLOTS];
35 int gpio_backlight;
36 int gpio_eth_irq;
38 int lcd_id;
39 int lcd_orientation;
41 static struct resource smc91x_resources[] = {
42 [0] = {
43 .start = ZYLONITE_ETH_PHYS + 0x300,
44 .end = ZYLONITE_ETH_PHYS + 0xfffff,
45 .flags = IORESOURCE_MEM,
47 [1] = {
48 .start = -1, /* for run-time assignment */
49 .end = -1,
50 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
54 static struct platform_device smc91x_device = {
55 .name = "smc91x",
56 .id = 0,
57 .num_resources = ARRAY_SIZE(smc91x_resources),
58 .resource = smc91x_resources,
61 <<<<<<< HEAD:arch/arm/mach-pxa/zylonite.c
62 #if defined(CONFIG_FB_PXA) || (CONFIG_FB_PXA_MODULES)
63 =======
64 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
65 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-pxa/zylonite.c
66 static void zylonite_backlight_power(int on)
68 gpio_set_value(gpio_backlight, on);
71 static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
72 .pixclock = 110000,
73 .xres = 240,
74 .yres = 320,
75 .bpp = 16,
76 .hsync_len = 4,
77 .left_margin = 6,
78 .right_margin = 4,
79 .vsync_len = 2,
80 .upper_margin = 2,
81 .lower_margin = 3,
82 .sync = FB_SYNC_VERT_HIGH_ACT,
85 static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
86 .pixclock = 50000,
87 .xres = 640,
88 .yres = 480,
89 .bpp = 16,
90 .hsync_len = 1,
91 .left_margin = 0x9f,
92 .right_margin = 1,
93 .vsync_len = 44,
94 .upper_margin = 0,
95 .lower_margin = 0,
96 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
99 static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
100 .num_modes = 1,
101 .lccr0 = LCCR0_Act,
102 .lccr3 = LCCR3_PCP,
103 .pxafb_backlight_power = zylonite_backlight_power,
106 static struct pxafb_mode_info sharp_ls037_modes[] = {
107 [0] = {
108 .pixclock = 158000,
109 .xres = 240,
110 .yres = 320,
111 .bpp = 16,
112 .hsync_len = 4,
113 .left_margin = 39,
114 .right_margin = 39,
115 .vsync_len = 1,
116 .upper_margin = 2,
117 .lower_margin = 3,
118 .sync = 0,
120 [1] = {
121 .pixclock = 39700,
122 .xres = 480,
123 .yres = 640,
124 .bpp = 16,
125 .hsync_len = 8,
126 .left_margin = 81,
127 .right_margin = 81,
128 .vsync_len = 1,
129 .upper_margin = 2,
130 .lower_margin = 7,
131 .sync = 0,
135 static struct pxafb_mach_info zylonite_sharp_lcd_info = {
136 .modes = sharp_ls037_modes,
137 .num_modes = 2,
138 .lccr0 = LCCR0_Act,
139 .lccr3 = LCCR3_PCP | LCCR3_HSP | LCCR3_VSP,
140 .pxafb_backlight_power = zylonite_backlight_power,
143 static void __init zylonite_init_lcd(void)
145 /* backlight GPIO: output, default on */
146 gpio_direction_output(gpio_backlight, 1);
148 if (lcd_id & 0x20) {
149 set_pxa_fb_info(&zylonite_sharp_lcd_info);
150 return;
153 /* legacy LCD panels, it would be handy here if LCD panel type can
154 * be decided at run-time
156 if (1)
157 zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
158 else
159 zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
161 set_pxa_fb_info(&zylonite_toshiba_lcd_info);
163 #else
164 static inline void zylonite_init_lcd(void) {}
165 #endif
167 #if defined(CONFIG_MMC)
168 static int zylonite_mci_ro(struct device *dev)
170 struct platform_device *pdev = to_platform_device(dev);
172 return gpio_get_value(zylonite_mmc_slot[pdev->id].gpio_wp);
175 static int zylonite_mci_init(struct device *dev,
176 irq_handler_t zylonite_detect_int,
177 void *data)
179 struct platform_device *pdev = to_platform_device(dev);
180 int err, cd_irq, gpio_cd, gpio_wp;
182 cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
183 gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
184 gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
187 * setup GPIO for Zylonite MMC controller
189 err = gpio_request(gpio_cd, "mmc card detect");
190 if (err)
191 goto err_request_cd;
192 gpio_direction_input(gpio_cd);
194 err = gpio_request(gpio_wp, "mmc write protect");
195 if (err)
196 goto err_request_wp;
197 gpio_direction_input(gpio_wp);
199 err = request_irq(cd_irq, zylonite_detect_int,
200 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
201 "MMC card detect", data);
202 if (err) {
203 printk(KERN_ERR "%s: MMC/SD/SDIO: "
204 "can't request card detect IRQ\n", __func__);
205 goto err_request_irq;
208 return 0;
210 err_request_irq:
211 gpio_free(gpio_wp);
212 err_request_wp:
213 gpio_free(gpio_cd);
214 err_request_cd:
215 return err;
218 static void zylonite_mci_exit(struct device *dev, void *data)
220 struct platform_device *pdev = to_platform_device(dev);
221 int cd_irq, gpio_cd, gpio_wp;
223 cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
224 gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
225 gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
227 free_irq(cd_irq, data);
228 gpio_free(gpio_cd);
229 gpio_free(gpio_wp);
232 static struct pxamci_platform_data zylonite_mci_platform_data = {
233 .detect_delay = 20,
234 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
235 .init = zylonite_mci_init,
236 .exit = zylonite_mci_exit,
237 .get_ro = zylonite_mci_ro,
240 static struct pxamci_platform_data zylonite_mci2_platform_data = {
241 .detect_delay = 20,
242 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
245 static void __init zylonite_init_mmc(void)
247 pxa_set_mci_info(&zylonite_mci_platform_data);
248 pxa3xx_set_mci2_info(&zylonite_mci2_platform_data);
249 if (cpu_is_pxa310())
250 pxa3xx_set_mci3_info(&zylonite_mci_platform_data);
252 #else
253 static inline void zylonite_init_mmc(void) {}
254 #endif
256 static void __init zylonite_init(void)
258 /* board-processor specific initialization */
259 zylonite_pxa300_init();
260 zylonite_pxa320_init();
263 * Note: We depend that the bootloader set
264 * the correct value to MSC register for SMC91x.
266 smc91x_resources[1].start = gpio_to_irq(gpio_eth_irq);
267 smc91x_resources[1].end = gpio_to_irq(gpio_eth_irq);
268 platform_device_register(&smc91x_device);
270 zylonite_init_lcd();
271 zylonite_init_mmc();
274 MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
275 .phys_io = 0x40000000,
276 .boot_params = 0xa0000100,
277 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
278 .map_io = pxa_map_io,
279 .init_irq = pxa3xx_init_irq,
280 .timer = &pxa_timer,
281 .init_machine = zylonite_init,
282 MACHINE_END