Commit | Line | Data |
---|---|---|
0dd28f1d RP |
1 | /* |
2 | * Support for Sharp SL-Cxx00 Series of PDAs | |
3 | * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi) | |
4 | * | |
5 | * Copyright (c) 2005 Richard Purdie | |
6 | * | |
7 | * Based on Sharp's 2.4 kernel patches/lubbock.c | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | * | |
13 | */ | |
14 | ||
15 | #include <linux/kernel.h> | |
16 | #include <linux/init.h> | |
d052d1be | 17 | #include <linux/platform_device.h> |
0dd28f1d RP |
18 | #include <linux/delay.h> |
19 | #include <linux/major.h> | |
20 | #include <linux/fs.h> | |
21 | #include <linux/interrupt.h> | |
22 | #include <linux/mmc/host.h> | |
74617fb6 | 23 | #include <linux/pm.h> |
c3f8f650 | 24 | #include <linux/backlight.h> |
0dd28f1d RP |
25 | |
26 | #include <asm/setup.h> | |
27 | #include <asm/memory.h> | |
28 | #include <asm/mach-types.h> | |
29 | #include <asm/hardware.h> | |
30 | #include <asm/irq.h> | |
31 | #include <asm/io.h> | |
74617fb6 | 32 | #include <asm/system.h> |
0dd28f1d RP |
33 | |
34 | #include <asm/mach/arch.h> | |
35 | #include <asm/mach/map.h> | |
36 | #include <asm/mach/irq.h> | |
37 | ||
38 | #include <asm/arch/pxa-regs.h> | |
bb548dd4 | 39 | #include <asm/arch/pxa2xx-regs.h> |
a683b14d | 40 | #include <asm/arch/pxa2xx-gpio.h> |
dc07845d | 41 | #include <asm/arch/irda.h> |
0dd28f1d | 42 | #include <asm/arch/mmc.h> |
3125c68d | 43 | #include <asm/arch/ohci.h> |
0dd28f1d | 44 | #include <asm/arch/udc.h> |
0dd28f1d RP |
45 | #include <asm/arch/pxafb.h> |
46 | #include <asm/arch/akita.h> | |
47 | #include <asm/arch/spitz.h> | |
48 | #include <asm/arch/sharpsl.h> | |
49 | ||
50 | #include <asm/mach/sharpsl_param.h> | |
51 | #include <asm/hardware/scoop.h> | |
52 | ||
53 | #include "generic.h" | |
46c41e62 | 54 | #include "devices.h" |
0dd28f1d RP |
55 | #include "sharpsl.h" |
56 | ||
57 | /* | |
58 | * Spitz SCOOP Device #1 | |
59 | */ | |
60 | static struct resource spitz_scoop_resources[] = { | |
61 | [0] = { | |
62 | .start = 0x10800000, | |
63 | .end = 0x10800fff, | |
64 | .flags = IORESOURCE_MEM, | |
65 | }, | |
66 | }; | |
67 | ||
68 | static struct scoop_config spitz_scoop_setup = { | |
69 | .io_dir = SPITZ_SCP_IO_DIR, | |
70 | .io_out = SPITZ_SCP_IO_OUT, | |
71 | .suspend_clr = SPITZ_SCP_SUS_CLR, | |
72 | .suspend_set = SPITZ_SCP_SUS_SET, | |
73 | }; | |
74 | ||
75 | struct platform_device spitzscoop_device = { | |
76 | .name = "sharp-scoop", | |
77 | .id = 0, | |
78 | .dev = { | |
79 | .platform_data = &spitz_scoop_setup, | |
80 | }, | |
81 | .num_resources = ARRAY_SIZE(spitz_scoop_resources), | |
82 | .resource = spitz_scoop_resources, | |
83 | }; | |
84 | ||
85 | /* | |
86 | * Spitz SCOOP Device #2 | |
87 | */ | |
88 | static struct resource spitz_scoop2_resources[] = { | |
89 | [0] = { | |
90 | .start = 0x08800040, | |
91 | .end = 0x08800fff, | |
92 | .flags = IORESOURCE_MEM, | |
93 | }, | |
94 | }; | |
95 | ||
96 | static struct scoop_config spitz_scoop2_setup = { | |
97 | .io_dir = SPITZ_SCP2_IO_DIR, | |
98 | .io_out = SPITZ_SCP2_IO_OUT, | |
99 | .suspend_clr = SPITZ_SCP2_SUS_CLR, | |
100 | .suspend_set = SPITZ_SCP2_SUS_SET, | |
101 | }; | |
102 | ||
103 | struct platform_device spitzscoop2_device = { | |
104 | .name = "sharp-scoop", | |
105 | .id = 1, | |
106 | .dev = { | |
107 | .platform_data = &spitz_scoop2_setup, | |
108 | }, | |
109 | .num_resources = ARRAY_SIZE(spitz_scoop2_resources), | |
110 | .resource = spitz_scoop2_resources, | |
111 | }; | |
112 | ||
a63ae442 RP |
113 | #define SPITZ_PWR_SD 0x01 |
114 | #define SPITZ_PWR_CF 0x02 | |
115 | ||
116 | /* Power control is shared with between one of the CF slots and SD */ | |
117 | static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr) | |
118 | { | |
119 | unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR); | |
120 | ||
121 | if (new_cpr & 0x0007) { | |
122 | set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); | |
123 | if (!(cpr & 0x0002) && !(cpr & 0x0004)) | |
124 | mdelay(5); | |
125 | if (device == SPITZ_PWR_CF) | |
126 | cpr |= 0x0002; | |
127 | if (device == SPITZ_PWR_SD) | |
128 | cpr |= 0x0004; | |
129 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); | |
130 | } else { | |
131 | if (device == SPITZ_PWR_CF) | |
132 | cpr &= ~0x0002; | |
133 | if (device == SPITZ_PWR_SD) | |
134 | cpr &= ~0x0004; | |
a63ae442 | 135 | if (!(cpr & 0x0002) && !(cpr & 0x0004)) { |
945b9579 | 136 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000); |
a63ae442 RP |
137 | mdelay(1); |
138 | reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); | |
945b9579 RP |
139 | } else { |
140 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); | |
a63ae442 RP |
141 | } |
142 | } | |
143 | } | |
144 | ||
145 | static void spitz_pcmcia_init(void) | |
146 | { | |
147 | /* Setup default state of GPIO outputs | |
148 | before we enable them as outputs. */ | |
149 | GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) | | |
150 | GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) | | |
151 | GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO54_nPCE_2); | |
152 | GPSR(GPIO85_nPCE_1) = GPIO_bit(GPIO85_nPCE_1); | |
153 | ||
154 | pxa_gpio_mode(GPIO48_nPOE_MD); | |
155 | pxa_gpio_mode(GPIO49_nPWE_MD); | |
156 | pxa_gpio_mode(GPIO50_nPIOR_MD); | |
157 | pxa_gpio_mode(GPIO51_nPIOW_MD); | |
158 | pxa_gpio_mode(GPIO55_nPREG_MD); | |
159 | pxa_gpio_mode(GPIO56_nPWAIT_MD); | |
160 | pxa_gpio_mode(GPIO57_nIOIS16_MD); | |
161 | pxa_gpio_mode(GPIO85_nPCE_1_MD); | |
162 | pxa_gpio_mode(GPIO54_nPCE_2_MD); | |
163 | pxa_gpio_mode(GPIO104_pSKTSEL_MD); | |
164 | } | |
165 | ||
166 | static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr) | |
167 | { | |
168 | /* Only need to override behaviour for slot 0 */ | |
169 | if (nr == 0) | |
170 | spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr); | |
171 | else | |
172 | write_scoop_reg(scoop, SCOOP_CPR, cpr); | |
173 | } | |
174 | ||
0dd28f1d RP |
175 | static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = { |
176 | { | |
177 | .dev = &spitzscoop_device.dev, | |
178 | .irq = SPITZ_IRQ_GPIO_CF_IRQ, | |
179 | .cd_irq = SPITZ_IRQ_GPIO_CF_CD, | |
180 | .cd_irq_str = "PCMCIA0 CD", | |
181 | },{ | |
182 | .dev = &spitzscoop2_device.dev, | |
183 | .irq = SPITZ_IRQ_GPIO_CF2_IRQ, | |
184 | .cd_irq = -1, | |
185 | }, | |
186 | }; | |
187 | ||
a63ae442 RP |
188 | static struct scoop_pcmcia_config spitz_pcmcia_config = { |
189 | .devs = &spitz_pcmcia_scoop[0], | |
190 | .num_devs = 2, | |
191 | .pcmcia_init = spitz_pcmcia_init, | |
192 | .power_ctrl = spitz_pcmcia_pwr, | |
193 | }; | |
194 | ||
195 | EXPORT_SYMBOL(spitzscoop_device); | |
196 | EXPORT_SYMBOL(spitzscoop2_device); | |
197 | ||
0dd28f1d RP |
198 | |
199 | /* | |
200 | * Spitz SSP Device | |
201 | * | |
202 | * Set the parent as the scoop device because a lot of SSP devices | |
203 | * also use scoop functions and this makes the power up/down order | |
204 | * work correctly. | |
205 | */ | |
206 | struct platform_device spitzssp_device = { | |
207 | .name = "corgi-ssp", | |
208 | .dev = { | |
209 | .parent = &spitzscoop_device.dev, | |
210 | }, | |
211 | .id = -1, | |
212 | }; | |
213 | ||
214 | struct corgissp_machinfo spitz_ssp_machinfo = { | |
215 | .port = 2, | |
216 | .cs_lcdcon = SPITZ_GPIO_LCDCON_CS, | |
217 | .cs_ads7846 = SPITZ_GPIO_ADS7846_CS, | |
218 | .cs_max1111 = SPITZ_GPIO_MAX1111_CS, | |
219 | .clk_lcdcon = 520, | |
220 | .clk_ads7846 = 14, | |
221 | .clk_max1111 = 56, | |
222 | }; | |
223 | ||
224 | ||
225 | /* | |
226 | * Spitz Backlight Device | |
227 | */ | |
c3f8f650 RP |
228 | static void spitz_bl_kick_battery(void) |
229 | { | |
230 | void (*kick_batt)(void); | |
231 | ||
232 | kick_batt = symbol_get(sharpsl_battery_kick); | |
233 | if (kick_batt) { | |
234 | kick_batt(); | |
235 | symbol_put(sharpsl_battery_kick); | |
236 | } | |
237 | } | |
238 | ||
239 | static struct generic_bl_info spitz_bl_machinfo = { | |
240 | .name = "corgi-bl", | |
2c0f5fb0 RP |
241 | .default_intensity = 0x1f, |
242 | .limit_mask = 0x0b, | |
0dd28f1d | 243 | .max_intensity = 0x2f, |
c3f8f650 | 244 | .kick_battery = spitz_bl_kick_battery, |
0dd28f1d RP |
245 | }; |
246 | ||
247 | static struct platform_device spitzbl_device = { | |
c3f8f650 | 248 | .name = "generic-bl", |
0dd28f1d RP |
249 | .dev = { |
250 | .platform_data = &spitz_bl_machinfo, | |
251 | }, | |
252 | .id = -1, | |
253 | }; | |
254 | ||
255 | ||
256 | /* | |
257 | * Spitz Keyboard Device | |
258 | */ | |
259 | static struct platform_device spitzkbd_device = { | |
260 | .name = "spitz-keyboard", | |
261 | .id = -1, | |
262 | }; | |
263 | ||
264 | ||
3179108d RP |
265 | /* |
266 | * Spitz LEDs | |
267 | */ | |
268 | static struct platform_device spitzled_device = { | |
269 | .name = "spitz-led", | |
270 | .id = -1, | |
271 | }; | |
272 | ||
0dd28f1d RP |
273 | /* |
274 | * Spitz Touch Screen Device | |
275 | */ | |
ca4d6cfc RP |
276 | |
277 | static unsigned long (*get_hsync_invperiod)(struct device *dev); | |
278 | ||
279 | static void inline sharpsl_wait_sync(int gpio) | |
280 | { | |
281 | while((GPLR(gpio) & GPIO_bit(gpio)) == 0); | |
282 | while((GPLR(gpio) & GPIO_bit(gpio)) != 0); | |
283 | } | |
284 | ||
285 | static struct device *spitz_pxafb_dev; | |
286 | ||
287 | static int is_pxafb_device(struct device * dev, void * data) | |
288 | { | |
289 | struct platform_device *pdev = container_of(dev, struct platform_device, dev); | |
290 | ||
291 | return (strncmp(pdev->name, "pxa2xx-fb", 9) == 0); | |
292 | } | |
293 | ||
294 | static unsigned long spitz_get_hsync_invperiod(void) | |
295 | { | |
296 | #ifdef CONFIG_FB_PXA | |
297 | if (!spitz_pxafb_dev) { | |
298 | spitz_pxafb_dev = bus_find_device(&platform_bus_type, NULL, NULL, is_pxafb_device); | |
299 | if (!spitz_pxafb_dev) | |
300 | return 0; | |
301 | } | |
302 | if (!get_hsync_invperiod) | |
303 | get_hsync_invperiod = symbol_get(pxafb_get_hsync_time); | |
304 | if (!get_hsync_invperiod) | |
305 | #endif | |
306 | return 0; | |
307 | ||
308 | return get_hsync_invperiod(spitz_pxafb_dev); | |
309 | } | |
310 | ||
311 | static void spitz_put_hsync(void) | |
312 | { | |
313 | put_device(spitz_pxafb_dev); | |
314 | if (get_hsync_invperiod) | |
315 | symbol_put(pxafb_get_hsync_time); | |
316 | spitz_pxafb_dev = NULL; | |
317 | get_hsync_invperiod = NULL; | |
318 | } | |
319 | ||
320 | static void spitz_wait_hsync(void) | |
321 | { | |
322 | sharpsl_wait_sync(SPITZ_GPIO_HSYNC); | |
323 | } | |
324 | ||
0dd28f1d RP |
325 | static struct resource spitzts_resources[] = { |
326 | [0] = { | |
327 | .start = SPITZ_IRQ_GPIO_TP_INT, | |
328 | .end = SPITZ_IRQ_GPIO_TP_INT, | |
329 | .flags = IORESOURCE_IRQ, | |
330 | }, | |
331 | }; | |
332 | ||
333 | static struct corgits_machinfo spitz_ts_machinfo = { | |
ca4d6cfc RP |
334 | .get_hsync_invperiod = spitz_get_hsync_invperiod, |
335 | .put_hsync = spitz_put_hsync, | |
336 | .wait_hsync = spitz_wait_hsync, | |
0dd28f1d RP |
337 | }; |
338 | ||
339 | static struct platform_device spitzts_device = { | |
340 | .name = "corgi-ts", | |
341 | .dev = { | |
342 | .parent = &spitzssp_device.dev, | |
343 | .platform_data = &spitz_ts_machinfo, | |
344 | }, | |
345 | .id = -1, | |
346 | .num_resources = ARRAY_SIZE(spitzts_resources), | |
347 | .resource = spitzts_resources, | |
348 | }; | |
349 | ||
350 | ||
351 | /* | |
352 | * MMC/SD Device | |
353 | * | |
354 | * The card detect interrupt isn't debounced so we delay it by 250ms | |
355 | * to give the card a chance to fully insert/eject. | |
356 | */ | |
357 | ||
358 | static struct pxamci_platform_data spitz_mci_platform_data; | |
359 | ||
40220c1a | 360 | static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data) |
0dd28f1d RP |
361 | { |
362 | int err; | |
363 | ||
364 | /* setup GPIO for PXA27x MMC controller */ | |
365 | pxa_gpio_mode(GPIO32_MMCCLK_MD); | |
366 | pxa_gpio_mode(GPIO112_MMCCMD_MD); | |
367 | pxa_gpio_mode(GPIO92_MMCDAT0_MD); | |
368 | pxa_gpio_mode(GPIO109_MMCDAT1_MD); | |
369 | pxa_gpio_mode(GPIO110_MMCDAT2_MD); | |
370 | pxa_gpio_mode(GPIO111_MMCDAT3_MD); | |
371 | pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN); | |
372 | pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN); | |
373 | ||
374 | spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250); | |
375 | ||
9ded96f2 | 376 | err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, |
52e405ea | 377 | IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
9ded96f2 | 378 | "MMC card detect", data); |
2687bd38 | 379 | if (err) |
0dd28f1d | 380 | printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); |
0dd28f1d | 381 | |
2687bd38 | 382 | return err; |
0dd28f1d RP |
383 | } |
384 | ||
0dd28f1d RP |
385 | static void spitz_mci_setpower(struct device *dev, unsigned int vdd) |
386 | { | |
387 | struct pxamci_platform_data* p_d = dev->platform_data; | |
388 | ||
a63ae442 RP |
389 | if (( 1 << vdd) & p_d->ocr_mask) |
390 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004); | |
391 | else | |
392 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000); | |
0dd28f1d RP |
393 | } |
394 | ||
395 | static int spitz_mci_get_ro(struct device *dev) | |
396 | { | |
397 | return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP); | |
398 | } | |
399 | ||
400 | static void spitz_mci_exit(struct device *dev, void *data) | |
401 | { | |
402 | free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data); | |
403 | } | |
404 | ||
405 | static struct pxamci_platform_data spitz_mci_platform_data = { | |
406 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, | |
407 | .init = spitz_mci_init, | |
408 | .get_ro = spitz_mci_get_ro, | |
409 | .setpower = spitz_mci_setpower, | |
410 | .exit = spitz_mci_exit, | |
411 | }; | |
412 | ||
413 | ||
3125c68d RP |
414 | /* |
415 | * USB Host (OHCI) | |
416 | */ | |
417 | static int spitz_ohci_init(struct device *dev) | |
418 | { | |
419 | /* Only Port 2 is connected */ | |
420 | pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN); | |
421 | pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT); | |
422 | pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN); | |
423 | ||
424 | /* Setup USB Port 2 Output Control Register */ | |
425 | UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; | |
426 | ||
427 | GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST); | |
428 | ||
429 | UHCHR = (UHCHR) & | |
430 | ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); | |
431 | ||
432 | UHCRHDA |= UHCRHDA_NOCP; | |
433 | ||
434 | return 0; | |
435 | } | |
436 | ||
437 | static struct pxaohci_platform_data spitz_ohci_platform_data = { | |
438 | .port_mode = PMM_NPS_MODE, | |
439 | .init = spitz_ohci_init, | |
0c27c5d5 | 440 | .power_budget = 150, |
3125c68d RP |
441 | }; |
442 | ||
443 | ||
dc07845d RP |
444 | /* |
445 | * Irda | |
446 | */ | |
447 | static void spitz_irda_transceiver_mode(struct device *dev, int mode) | |
448 | { | |
449 | if (mode & IR_OFF) | |
450 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON); | |
451 | else | |
452 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON); | |
453 | } | |
454 | ||
94cabd00 RP |
455 | #ifdef CONFIG_MACH_AKITA |
456 | static void akita_irda_transceiver_mode(struct device *dev, int mode) | |
457 | { | |
458 | if (mode & IR_OFF) | |
459 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON); | |
460 | else | |
461 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON); | |
462 | } | |
463 | #endif | |
464 | ||
dc07845d RP |
465 | static struct pxaficp_platform_data spitz_ficp_platform_data = { |
466 | .transceiver_cap = IR_SIRMODE | IR_OFF, | |
467 | .transceiver_mode = spitz_irda_transceiver_mode, | |
468 | }; | |
469 | ||
470 | ||
0dd28f1d RP |
471 | /* |
472 | * Spitz PXA Framebuffer | |
473 | */ | |
d14b272b | 474 | |
ca4d6cfc RP |
475 | static void spitz_lcd_power(int on, struct fb_var_screeninfo *var) |
476 | { | |
477 | if (on) | |
478 | corgi_lcdtg_hw_init(var->xres); | |
479 | else | |
480 | corgi_lcdtg_suspend(); | |
481 | } | |
482 | ||
d14b272b RP |
483 | static struct pxafb_mode_info spitz_pxafb_modes[] = { |
484 | { | |
485 | .pixclock = 19231, | |
486 | .xres = 480, | |
487 | .yres = 640, | |
488 | .bpp = 16, | |
489 | .hsync_len = 40, | |
490 | .left_margin = 46, | |
491 | .right_margin = 125, | |
492 | .vsync_len = 3, | |
493 | .upper_margin = 1, | |
494 | .lower_margin = 0, | |
495 | .sync = 0, | |
496 | },{ | |
497 | .pixclock = 134617, | |
498 | .xres = 240, | |
499 | .yres = 320, | |
500 | .bpp = 16, | |
501 | .hsync_len = 20, | |
502 | .left_margin = 20, | |
503 | .right_margin = 46, | |
504 | .vsync_len = 2, | |
505 | .upper_margin = 1, | |
506 | .lower_margin = 0, | |
507 | .sync = 0, | |
508 | }, | |
509 | }; | |
510 | ||
511 | static struct pxafb_mach_info spitz_pxafb_info = { | |
512 | .modes = &spitz_pxafb_modes[0], | |
513 | .num_modes = 2, | |
514 | .fixed_modes = 1, | |
515 | .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM, | |
516 | .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH, | |
517 | .pxafb_lcd_power = spitz_lcd_power, | |
0dd28f1d RP |
518 | }; |
519 | ||
520 | ||
521 | static struct platform_device *devices[] __initdata = { | |
522 | &spitzscoop_device, | |
523 | &spitzssp_device, | |
524 | &spitzkbd_device, | |
525 | &spitzts_device, | |
526 | &spitzbl_device, | |
3179108d | 527 | &spitzled_device, |
0dd28f1d RP |
528 | }; |
529 | ||
74617fb6 RP |
530 | static void spitz_poweroff(void) |
531 | { | |
532 | RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR; | |
533 | ||
534 | pxa_gpio_mode(SPITZ_GPIO_ON_RESET | GPIO_OUT); | |
535 | GPSR(SPITZ_GPIO_ON_RESET) = GPIO_bit(SPITZ_GPIO_ON_RESET); | |
536 | ||
537 | mdelay(1000); | |
538 | arm_machine_restart('h'); | |
539 | } | |
540 | ||
541 | static void spitz_restart(char mode) | |
542 | { | |
543 | /* Bootloader magic for a reboot */ | |
544 | if((MSC0 & 0xffff0000) == 0x7ff00000) | |
545 | MSC0 = (MSC0 & 0xffff) | 0x7ee00000; | |
546 | ||
547 | spitz_poweroff(); | |
548 | } | |
549 | ||
0dd28f1d RP |
550 | static void __init common_init(void) |
551 | { | |
74617fb6 RP |
552 | pm_power_off = spitz_poweroff; |
553 | arm_pm_restart = spitz_restart; | |
554 | ||
0dd28f1d RP |
555 | PMCR = 0x00; |
556 | ||
557 | /* setup sleep mode values */ | |
558 | PWER = 0x00000002; | |
559 | PFER = 0x00000000; | |
560 | PRER = 0x00000002; | |
561 | PGSR0 = 0x0158C000; | |
562 | PGSR1 = 0x00FF0080; | |
563 | PGSR2 = 0x0001C004; | |
564 | ||
565 | /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ | |
566 | PCFR |= PCFR_OPDE; | |
567 | ||
568 | corgi_ssp_set_machinfo(&spitz_ssp_machinfo); | |
569 | ||
570 | pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN); | |
571 | ||
572 | platform_add_devices(devices, ARRAY_SIZE(devices)); | |
573 | pxa_set_mci_info(&spitz_mci_platform_data); | |
3125c68d | 574 | pxa_set_ohci_info(&spitz_ohci_platform_data); |
dc07845d | 575 | pxa_set_ficp_info(&spitz_ficp_platform_data); |
cb38c569 | 576 | set_pxa_fb_parent(&spitzssp_device.dev); |
0dd28f1d RP |
577 | set_pxa_fb_info(&spitz_pxafb_info); |
578 | } | |
579 | ||
ca4d6cfc RP |
580 | #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI) |
581 | static void spitz_bl_set_intensity(int intensity) | |
582 | { | |
583 | if (intensity > 0x10) | |
584 | intensity += 0x10; | |
585 | ||
586 | /* Bits 0-4 are accessed via the SSP interface */ | |
587 | corgi_ssp_blduty_set(intensity & 0x1f); | |
588 | ||
589 | /* Bit 5 is via SCOOP */ | |
590 | if (intensity & 0x0020) | |
591 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); | |
592 | else | |
593 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); | |
594 | ||
595 | if (intensity) | |
596 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); | |
597 | else | |
598 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); | |
599 | } | |
600 | ||
0dd28f1d RP |
601 | static void __init spitz_init(void) |
602 | { | |
a63ae442 RP |
603 | platform_scoop_config = &spitz_pcmcia_config; |
604 | ||
0dd28f1d RP |
605 | spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity; |
606 | ||
607 | common_init(); | |
608 | ||
609 | platform_device_register(&spitzscoop2_device); | |
610 | } | |
ca4d6cfc | 611 | #endif |
0dd28f1d | 612 | |
94cabd00 RP |
613 | #ifdef CONFIG_MACH_AKITA |
614 | /* | |
615 | * Akita IO Expander | |
616 | */ | |
617 | struct platform_device akitaioexp_device = { | |
618 | .name = "akita-ioexp", | |
619 | .id = -1, | |
620 | }; | |
621 | ||
bd8f103e RP |
622 | EXPORT_SYMBOL_GPL(akitaioexp_device); |
623 | ||
ca4d6cfc RP |
624 | static void akita_bl_set_intensity(int intensity) |
625 | { | |
626 | if (intensity > 0x10) | |
627 | intensity += 0x10; | |
628 | ||
629 | /* Bits 0-4 are accessed via the SSP interface */ | |
630 | corgi_ssp_blduty_set(intensity & 0x1f); | |
631 | ||
632 | /* Bit 5 is via IO-Expander */ | |
633 | if (intensity & 0x0020) | |
634 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); | |
635 | else | |
636 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); | |
637 | ||
638 | if (intensity) | |
639 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); | |
640 | else | |
641 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); | |
642 | } | |
643 | ||
94cabd00 RP |
644 | static void __init akita_init(void) |
645 | { | |
646 | spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode; | |
647 | ||
648 | /* We just pretend the second element of the array doesn't exist */ | |
649 | spitz_pcmcia_config.num_devs = 1; | |
650 | platform_scoop_config = &spitz_pcmcia_config; | |
651 | spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity; | |
652 | ||
653 | platform_device_register(&akitaioexp_device); | |
654 | ||
655 | spitzscoop_device.dev.parent = &akitaioexp_device.dev; | |
656 | common_init(); | |
657 | } | |
658 | #endif | |
659 | ||
0dd28f1d RP |
660 | static void __init fixup_spitz(struct machine_desc *desc, |
661 | struct tag *tags, char **cmdline, struct meminfo *mi) | |
662 | { | |
663 | sharpsl_save_param(); | |
664 | mi->nr_banks = 1; | |
665 | mi->bank[0].start = 0xa0000000; | |
666 | mi->bank[0].node = 0; | |
667 | mi->bank[0].size = (64*1024*1024); | |
668 | } | |
669 | ||
670 | #ifdef CONFIG_MACH_SPITZ | |
671 | MACHINE_START(SPITZ, "SHARP Spitz") | |
0dd28f1d RP |
672 | .phys_io = 0x40000000, |
673 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
674 | .fixup = fixup_spitz, | |
675 | .map_io = pxa_map_io, | |
cd49104d | 676 | .init_irq = pxa27x_init_irq, |
0dd28f1d RP |
677 | .init_machine = spitz_init, |
678 | .timer = &pxa_timer, | |
679 | MACHINE_END | |
680 | #endif | |
681 | ||
682 | #ifdef CONFIG_MACH_BORZOI | |
683 | MACHINE_START(BORZOI, "SHARP Borzoi") | |
0dd28f1d RP |
684 | .phys_io = 0x40000000, |
685 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
686 | .fixup = fixup_spitz, | |
687 | .map_io = pxa_map_io, | |
cd49104d | 688 | .init_irq = pxa27x_init_irq, |
0dd28f1d RP |
689 | .init_machine = spitz_init, |
690 | .timer = &pxa_timer, | |
691 | MACHINE_END | |
692 | #endif | |
94cabd00 RP |
693 | |
694 | #ifdef CONFIG_MACH_AKITA | |
695 | MACHINE_START(AKITA, "SHARP Akita") | |
94cabd00 RP |
696 | .phys_io = 0x40000000, |
697 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
698 | .fixup = fixup_spitz, | |
699 | .map_io = pxa_map_io, | |
cd49104d | 700 | .init_irq = pxa27x_init_irq, |
94cabd00 RP |
701 | .init_machine = akita_init, |
702 | .timer = &pxa_timer, | |
703 | MACHINE_END | |
704 | #endif |