blob: 6aff30615b306f280a58897bb92fc05038a3e2bd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Support for Sharp SL-C7xx PDAs
3 * Models: SL-C700 (Corgi), SL-C750 (Shepherd), SL-C760 (Husky)
4 *
5 * Copyright (c) 2004-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>
Russell Kingd052d1b2005-10-29 19:07:23 +010017#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/major.h>
19#include <linux/fs.h>
20#include <linux/interrupt.h>
21#include <linux/mmc/host.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010022#include <linux/pm.h>
Eric Miao9d708752008-08-27 09:16:30 +080023#include <linux/gpio.h>
Richard Purdiec3f8f652007-09-03 00:27:00 +010024#include <linux/backlight.h>
Richard Purdieca4d6cf2008-01-02 01:09:54 +010025#include <video/w100fb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27#include <asm/setup.h>
28#include <asm/memory.h>
29#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010030#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <asm/irq.h>
32#include <asm/io.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010033#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37#include <asm/mach/irq.h>
38
Russell Kinga09e64f2008-08-05 16:14:15 +010039#include <mach/pxa-regs.h>
40#include <mach/pxa2xx-regs.h>
41#include <mach/pxa2xx-gpio.h>
Mark Brownf8787fd2008-08-26 13:30:03 +010042#include <mach/i2c.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010043#include <mach/irda.h>
44#include <mach/mmc.h>
45#include <mach/udc.h>
46#include <mach/corgi.h>
47#include <mach/sharpsl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49#include <asm/mach/sharpsl_param.h>
50#include <asm/hardware/scoop.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010053#include "devices.h"
Richard Purdie50a5de42005-09-13 01:25:30 -070054#include "sharpsl.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56
57/*
58 * Corgi SCOOP Device
59 */
60static struct resource corgi_scoop_resources[] = {
61 [0] = {
62 .start = 0x10800000,
63 .end = 0x10800fff,
64 .flags = IORESOURCE_MEM,
65 },
66};
67
68static struct scoop_config corgi_scoop_setup = {
69 .io_dir = CORGI_SCOOP_IO_DIR,
70 .io_out = CORGI_SCOOP_IO_OUT,
71};
72
73struct platform_device corgiscoop_device = {
74 .name = "sharp-scoop",
75 .id = -1,
76 .dev = {
77 .platform_data = &corgi_scoop_setup,
78 },
79 .num_resources = ARRAY_SIZE(corgi_scoop_resources),
80 .resource = corgi_scoop_resources,
81};
82
Richard Purdiea63ae442005-11-08 19:15:43 +000083static void corgi_pcmcia_init(void)
84{
85 /* Setup default state of GPIO outputs
86 before we enable them as outputs. */
87 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
88 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
89 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
90 GPIO_bit(GPIO53_nPCE_2);
91
92 pxa_gpio_mode(GPIO48_nPOE_MD);
93 pxa_gpio_mode(GPIO49_nPWE_MD);
94 pxa_gpio_mode(GPIO50_nPIOR_MD);
95 pxa_gpio_mode(GPIO51_nPIOW_MD);
96 pxa_gpio_mode(GPIO55_nPREG_MD);
97 pxa_gpio_mode(GPIO56_nPWAIT_MD);
98 pxa_gpio_mode(GPIO57_nIOIS16_MD);
99 pxa_gpio_mode(GPIO52_nPCE_1_MD);
100 pxa_gpio_mode(GPIO53_nPCE_2_MD);
101 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
102}
103
104static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
105{
106 .dev = &corgiscoop_device.dev,
107 .irq = CORGI_IRQ_GPIO_CF_IRQ,
108 .cd_irq = CORGI_IRQ_GPIO_CF_CD,
109 .cd_irq_str = "PCMCIA0 CD",
110},
111};
112
113static struct scoop_pcmcia_config corgi_pcmcia_config = {
114 .devs = &corgi_pcmcia_scoop[0],
115 .num_devs = 1,
116 .pcmcia_init = corgi_pcmcia_init,
117};
118
119EXPORT_SYMBOL(corgiscoop_device);
120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
122/*
123 * Corgi SSP Device
124 *
125 * Set the parent as the scoop device because a lot of SSP devices
126 * also use scoop functions and this makes the power up/down order
127 * work correctly.
128 */
Richard Purdie41b1bce2005-09-06 15:19:05 -0700129struct platform_device corgissp_device = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 .name = "corgi-ssp",
131 .dev = {
132 .parent = &corgiscoop_device.dev,
133 },
134 .id = -1,
135};
136
Richard Purdie50a5de42005-09-13 01:25:30 -0700137struct corgissp_machinfo corgi_ssp_machinfo = {
138 .port = 1,
139 .cs_lcdcon = CORGI_GPIO_LCDCON_CS,
140 .cs_ads7846 = CORGI_GPIO_ADS7846_CS,
141 .cs_max1111 = CORGI_GPIO_MAX1111_CS,
142 .clk_lcdcon = 76,
143 .clk_ads7846 = 2,
144 .clk_max1111 = 8,
145};
146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148/*
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100149 * LCD/Framebuffer
150 */
151static void w100_lcdtg_suspend(struct w100fb_par *par)
152{
153 corgi_lcdtg_suspend();
154}
155
156static void w100_lcdtg_init(struct w100fb_par *par)
157{
158 corgi_lcdtg_hw_init(par->xres);
159}
160
161
162static struct w100_tg_info corgi_lcdtg_info = {
163 .change = w100_lcdtg_init,
164 .suspend = w100_lcdtg_suspend,
165 .resume = w100_lcdtg_init,
166};
167
168static struct w100_mem_info corgi_fb_mem = {
169 .ext_cntl = 0x00040003,
170 .sdram_mode_reg = 0x00650021,
171 .ext_timing_cntl = 0x10002a4a,
172 .io_cntl = 0x7ff87012,
173 .size = 0x1fffff,
174};
175
176static struct w100_gen_regs corgi_fb_regs = {
177 .lcd_format = 0x00000003,
178 .lcdd_cntl1 = 0x01CC0000,
179 .lcdd_cntl2 = 0x0003FFFF,
180 .genlcd_cntl1 = 0x00FFFF0D,
181 .genlcd_cntl2 = 0x003F3003,
182 .genlcd_cntl3 = 0x000102aa,
183};
184
185static struct w100_gpio_regs corgi_fb_gpio = {
186 .init_data1 = 0x000000bf,
187 .init_data2 = 0x00000000,
188 .gpio_dir1 = 0x00000000,
189 .gpio_oe1 = 0x03c0feff,
190 .gpio_dir2 = 0x00000000,
191 .gpio_oe2 = 0x00000000,
192};
193
194static struct w100_mode corgi_fb_modes[] = {
195{
196 .xres = 480,
197 .yres = 640,
198 .left_margin = 0x56,
199 .right_margin = 0x55,
200 .upper_margin = 0x03,
201 .lower_margin = 0x00,
202 .crtc_ss = 0x82360056,
203 .crtc_ls = 0xA0280000,
204 .crtc_gs = 0x80280028,
205 .crtc_vpos_gs = 0x02830002,
206 .crtc_rev = 0x00400008,
207 .crtc_dclk = 0xA0000000,
208 .crtc_gclk = 0x8015010F,
209 .crtc_goe = 0x80100110,
210 .crtc_ps1_active = 0x41060010,
211 .pll_freq = 75,
212 .fast_pll_freq = 100,
213 .sysclk_src = CLK_SRC_PLL,
214 .sysclk_divider = 0,
215 .pixclk_src = CLK_SRC_PLL,
216 .pixclk_divider = 2,
217 .pixclk_divider_rotated = 6,
218},{
219 .xres = 240,
220 .yres = 320,
221 .left_margin = 0x27,
222 .right_margin = 0x2e,
223 .upper_margin = 0x01,
224 .lower_margin = 0x00,
225 .crtc_ss = 0x81170027,
226 .crtc_ls = 0xA0140000,
227 .crtc_gs = 0xC0140014,
228 .crtc_vpos_gs = 0x00010141,
229 .crtc_rev = 0x00400008,
230 .crtc_dclk = 0xA0000000,
231 .crtc_gclk = 0x8015010F,
232 .crtc_goe = 0x80100110,
233 .crtc_ps1_active = 0x41060010,
234 .pll_freq = 0,
235 .fast_pll_freq = 0,
236 .sysclk_src = CLK_SRC_XTAL,
237 .sysclk_divider = 0,
238 .pixclk_src = CLK_SRC_XTAL,
239 .pixclk_divider = 1,
240 .pixclk_divider_rotated = 1,
241},
242
243};
244
245static struct w100fb_mach_info corgi_fb_info = {
246 .tg = &corgi_lcdtg_info,
247 .init_mode = INIT_MODE_ROTATED,
248 .mem = &corgi_fb_mem,
249 .regs = &corgi_fb_regs,
250 .modelist = &corgi_fb_modes[0],
251 .num_modes = 2,
252 .gpio = &corgi_fb_gpio,
253 .xtal_freq = 12500000,
254 .xtal_dbl = 0,
255};
256
257static struct resource corgi_fb_resources[] = {
258 [0] = {
259 .start = 0x08000000,
260 .end = 0x08ffffff,
261 .flags = IORESOURCE_MEM,
262 },
263};
264
265static struct platform_device corgifb_device = {
266 .name = "w100fb",
267 .id = -1,
268 .num_resources = ARRAY_SIZE(corgi_fb_resources),
269 .resource = corgi_fb_resources,
270 .dev = {
271 .platform_data = &corgi_fb_info,
272 .parent = &corgissp_device.dev,
273 },
274
275};
276
277
278/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 * Corgi Backlight Device
280 */
Richard Purdiec3f8f652007-09-03 00:27:00 +0100281static void corgi_bl_kick_battery(void)
282{
283 void (*kick_batt)(void);
284
285 kick_batt = symbol_get(sharpsl_battery_kick);
286 if (kick_batt) {
287 kick_batt();
288 symbol_put(sharpsl_battery_kick);
289 }
290}
291
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100292static void corgi_bl_set_intensity(int intensity)
293{
294 if (intensity > 0x10)
295 intensity += 0x10;
296
297 /* Bits 0-4 are accessed via the SSP interface */
298 corgi_ssp_blduty_set(intensity & 0x1f);
299
300 /* Bit 5 is via SCOOP */
301 if (intensity & 0x0020)
302 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
303 else
304 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_BACKLIGHT_CONT);
305}
306
Richard Purdiec3f8f652007-09-03 00:27:00 +0100307static struct generic_bl_info corgi_bl_machinfo = {
308 .name = "corgi-bl",
Richard Purdie1351e6e2005-09-13 01:25:33 -0700309 .max_intensity = 0x2f,
Richard Purdie2c0f5fb2006-03-31 02:31:51 -0800310 .default_intensity = 0x1f,
311 .limit_mask = 0x0b,
Richard Purdie1351e6e2005-09-13 01:25:33 -0700312 .set_bl_intensity = corgi_bl_set_intensity,
Richard Purdiec3f8f652007-09-03 00:27:00 +0100313 .kick_battery = corgi_bl_kick_battery,
Richard Purdie1351e6e2005-09-13 01:25:33 -0700314};
315
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316static struct platform_device corgibl_device = {
Richard Purdiec3f8f652007-09-03 00:27:00 +0100317 .name = "generic-bl",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 .dev = {
319 .parent = &corgifb_device.dev,
Richard Purdie1351e6e2005-09-13 01:25:33 -0700320 .platform_data = &corgi_bl_machinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 },
322 .id = -1,
323};
324
325
326/*
Richard Purdief7ceff32005-09-06 15:19:07 -0700327 * Corgi Keyboard Device
328 */
329static struct platform_device corgikbd_device = {
330 .name = "corgi-keyboard",
331 .id = -1,
332};
333
334
335/*
Richard Purdie31791082006-03-31 02:31:09 -0800336 * Corgi LEDs
337 */
338static struct platform_device corgiled_device = {
339 .name = "corgi-led",
340 .id = -1,
341};
342
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100343
Richard Purdie31791082006-03-31 02:31:09 -0800344/*
Richard Purdief7ceff32005-09-06 15:19:07 -0700345 * Corgi Touch Screen Device
346 */
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100347static unsigned long (*get_hsync_invperiod)(struct device *dev);
348
349static void inline sharpsl_wait_sync(int gpio)
350{
351 while((GPLR(gpio) & GPIO_bit(gpio)) == 0);
352 while((GPLR(gpio) & GPIO_bit(gpio)) != 0);
353}
354
355static unsigned long corgi_get_hsync_invperiod(void)
356{
357 if (!get_hsync_invperiod)
358 get_hsync_invperiod = symbol_get(w100fb_get_hsynclen);
359 if (!get_hsync_invperiod)
360 return 0;
361
362 return get_hsync_invperiod(&corgifb_device.dev);
363}
364
365static void corgi_put_hsync(void)
366{
367 if (get_hsync_invperiod)
368 symbol_put(w100fb_get_hsynclen);
369 get_hsync_invperiod = NULL;
370}
371
372static void corgi_wait_hsync(void)
373{
374 sharpsl_wait_sync(CORGI_GPIO_HSYNC);
375}
376
Richard Purdie513b6e12005-09-13 01:25:33 -0700377static struct resource corgits_resources[] = {
378 [0] = {
379 .start = CORGI_IRQ_GPIO_TP_INT,
380 .end = CORGI_IRQ_GPIO_TP_INT,
381 .flags = IORESOURCE_IRQ,
382 },
383};
384
385static struct corgits_machinfo corgi_ts_machinfo = {
Richard Purdieca4d6cf2008-01-02 01:09:54 +0100386 .get_hsync_invperiod = corgi_get_hsync_invperiod,
387 .put_hsync = corgi_put_hsync,
388 .wait_hsync = corgi_wait_hsync,
Richard Purdie513b6e12005-09-13 01:25:33 -0700389};
390
Richard Purdief7ceff32005-09-06 15:19:07 -0700391static struct platform_device corgits_device = {
392 .name = "corgi-ts",
393 .dev = {
394 .parent = &corgissp_device.dev,
Richard Purdie513b6e12005-09-13 01:25:33 -0700395 .platform_data = &corgi_ts_machinfo,
Richard Purdief7ceff32005-09-06 15:19:07 -0700396 },
397 .id = -1,
Richard Purdie513b6e12005-09-13 01:25:33 -0700398 .num_resources = ARRAY_SIZE(corgits_resources),
399 .resource = corgits_resources,
Richard Purdief7ceff32005-09-06 15:19:07 -0700400};
401
402
403/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 * MMC/SD Device
405 *
Richard Purdieaa6c2e72005-09-09 18:54:03 +0100406 * The card detect interrupt isn't debounced so we delay it by 250ms
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 * to give the card a chance to fully insert/eject.
408 */
Richard Purdieaa6c2e72005-09-09 18:54:03 +0100409static struct pxamci_platform_data corgi_mci_platform_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
David Howells40220c12006-10-09 12:19:47 +0100411static int corgi_mci_init(struct device *dev, irq_handler_t corgi_detect_int, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412{
413 int err;
414
415 /* setup GPIO for PXA25x MMC controller */
416 pxa_gpio_mode(GPIO6_MMCCLK_MD);
417 pxa_gpio_mode(GPIO8_MMCCS0_MD);
Eric Miao9d708752008-08-27 09:16:30 +0800418
419 err = gpio_request(CORGI_GPIO_nSD_DETECT, "nSD_DETECT");
420 if (err)
421 goto err_out;
422
423 err = gpio_request(CORGI_GPIO_nSD_WP, "nSD_WP");
424 if (err)
425 goto err_free_1;
426
427 err = gpio_request(CORGI_GPIO_SD_PWR, "SD_PWR");
428 if (err)
429 goto err_free_2;
430
431 gpio_direction_input(CORGI_GPIO_nSD_DETECT);
432 gpio_direction_input(CORGI_GPIO_nSD_WP);
433 gpio_direction_output(CORGI_GPIO_SD_PWR, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434
Richard Purdieaa6c2e72005-09-09 18:54:03 +0100435 corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436
Russell King9ded96f2006-01-08 01:02:07 -0800437 err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int,
Eric Miao9d708752008-08-27 09:16:30 +0800438 IRQF_DISABLED | IRQF_TRIGGER_RISING |
439 IRQF_TRIGGER_FALLING,
440 "MMC card detect", data);
441 if (err) {
442 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
443 __func__);
444 goto err_free_3;
445 }
446 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447
Eric Miao9d708752008-08-27 09:16:30 +0800448err_free_3:
449 gpio_free(CORGI_GPIO_SD_PWR);
450err_free_2:
451 gpio_free(CORGI_GPIO_nSD_WP);
452err_free_1:
453 gpio_free(CORGI_GPIO_nSD_DETECT);
454err_out:
Russell King2687bd32008-01-23 14:05:58 +0000455 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
458static void corgi_mci_setpower(struct device *dev, unsigned int vdd)
459{
460 struct pxamci_platform_data* p_d = dev->platform_data;
461
Eric Miao9d708752008-08-27 09:16:30 +0800462 gpio_set_value(CORGI_GPIO_SD_PWR, ((1 << vdd) & p_d->ocr_mask));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463}
464
Richard Purdie3870ee82005-09-06 15:19:07 -0700465static int corgi_mci_get_ro(struct device *dev)
466{
Eric Miao9d708752008-08-27 09:16:30 +0800467 return gpio_get_value(CORGI_GPIO_nSD_WP);
Richard Purdie3870ee82005-09-06 15:19:07 -0700468}
469
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470static void corgi_mci_exit(struct device *dev, void *data)
471{
472 free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data);
Eric Miao9d708752008-08-27 09:16:30 +0800473 gpio_free(CORGI_GPIO_SD_PWR);
474 gpio_free(CORGI_GPIO_nSD_WP);
475 gpio_free(CORGI_GPIO_nSD_DETECT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476}
477
478static struct pxamci_platform_data corgi_mci_platform_data = {
479 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
480 .init = corgi_mci_init,
Richard Purdie3870ee82005-09-06 15:19:07 -0700481 .get_ro = corgi_mci_get_ro,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 .setpower = corgi_mci_setpower,
483 .exit = corgi_mci_exit,
484};
485
486
Richard Purdieca1140b2005-10-30 14:38:53 +0000487/*
488 * Irda
489 */
490static void corgi_irda_transceiver_mode(struct device *dev, int mode)
491{
Eric Miao9d708752008-08-27 09:16:30 +0800492 gpio_set_value(CORGI_GPIO_IR_ON, mode & IR_OFF);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100493 pxa2xx_transceiver_mode(dev, mode);
Richard Purdieca1140b2005-10-30 14:38:53 +0000494}
495
Eric Miao9d708752008-08-27 09:16:30 +0800496static int corgi_irda_startup(struct device *dev)
497{
498 int err;
499
500 err = gpio_request(CORGI_GPIO_IR_ON, "IR_ON");
501 if (err)
502 return err;
503
504 gpio_direction_output(CORGI_GPIO_IR_ON, 1);
505 return 0;
506}
507
508static void corgi_irda_shutdown(struct device *dev)
509{
510 gpio_free(CORGI_GPIO_IR_ON);
511}
512
Richard Purdieca1140b2005-10-30 14:38:53 +0000513static struct pxaficp_platform_data corgi_ficp_platform_data = {
Eric Miao9d708752008-08-27 09:16:30 +0800514 .transceiver_cap = IR_SIRMODE | IR_OFF,
515 .transceiver_mode = corgi_irda_transceiver_mode,
516 .startup = corgi_irda_startup,
517 .shutdown = corgi_irda_shutdown,
Richard Purdieca1140b2005-10-30 14:38:53 +0000518};
519
Richard Purdief7ceff32005-09-06 15:19:07 -0700520
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521/*
522 * USB Device Controller
523 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524static struct pxa2xx_udc_mach_info udc_info __initdata = {
525 /* no connect GPIO; corgi can't tell connection status */
David Brownellb2bbb202006-06-29 12:25:39 -0700526 .gpio_pullup = CORGI_GPIO_USB_PULLUP,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527};
528
529
530static struct platform_device *devices[] __initdata = {
531 &corgiscoop_device,
532 &corgissp_device,
533 &corgifb_device,
Richard Purdief7ceff32005-09-06 15:19:07 -0700534 &corgikbd_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 &corgibl_device,
Richard Purdief7ceff32005-09-06 15:19:07 -0700536 &corgits_device,
Richard Purdie31791082006-03-31 02:31:09 -0800537 &corgiled_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538};
539
Richard Purdie74617fb2006-06-19 19:57:12 +0100540static void corgi_poweroff(void)
541{
Richard Purdie74617fb2006-06-19 19:57:12 +0100542 if (!machine_is_corgi())
543 /* Green LED off tells the bootloader to halt */
544 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
545 arm_machine_restart('h');
546}
547
548static void corgi_restart(char mode)
549{
Richard Purdie74617fb2006-06-19 19:57:12 +0100550 if (!machine_is_corgi())
551 /* Green LED on tells the bootloader to reboot */
552 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
553 arm_machine_restart('h');
554}
555
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556static void __init corgi_init(void)
557{
Richard Purdie74617fb2006-06-19 19:57:12 +0100558 pm_power_off = corgi_poweroff;
559 arm_pm_restart = corgi_restart;
560
Richard Purdiefdce05b2005-09-15 14:53:21 +0100561 /* setup sleep mode values */
562 PWER = 0x00000002;
563 PFER = 0x00000000;
564 PRER = 0x00000002;
565 PGSR0 = 0x0158C000;
566 PGSR1 = 0x00FF0080;
567 PGSR2 = 0x0001C004;
568 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
569 PCFR |= PCFR_OPDE;
570
Richard Purdie50a5de42005-09-13 01:25:30 -0700571 corgi_ssp_set_machinfo(&corgi_ssp_machinfo);
572
Richard Purdieca1140b2005-10-30 14:38:53 +0000573 pxa_gpio_mode(CORGI_GPIO_IR_ON | GPIO_OUT);
Richard Purdie513b6e12005-09-13 01:25:33 -0700574 pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
Richard Purdieca1140b2005-10-30 14:38:53 +0000575
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 pxa_set_udc_info(&udc_info);
577 pxa_set_mci_info(&corgi_mci_platform_data);
Richard Purdieca1140b2005-10-30 14:38:53 +0000578 pxa_set_ficp_info(&corgi_ficp_platform_data);
Mark Brownf8787fd2008-08-26 13:30:03 +0100579 pxa_set_i2c_info(NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580
Richard Purdiea63ae442005-11-08 19:15:43 +0000581 platform_scoop_config = &corgi_pcmcia_config;
Richard Purdie0ce76252005-09-05 20:49:54 +0100582
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 platform_add_devices(devices, ARRAY_SIZE(devices));
584}
585
586static void __init fixup_corgi(struct machine_desc *desc,
587 struct tag *tags, char **cmdline, struct meminfo *mi)
588{
589 sharpsl_save_param();
590 mi->nr_banks=1;
591 mi->bank[0].start = 0xa0000000;
592 mi->bank[0].node = 0;
593 if (machine_is_corgi())
594 mi->bank[0].size = (32*1024*1024);
595 else
596 mi->bank[0].size = (64*1024*1024);
597}
598
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599#ifdef CONFIG_MACH_CORGI
600MACHINE_START(CORGI, "SHARP Corgi")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100601 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100602 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100603 .fixup = fixup_corgi,
Richard Purdiefdce05b2005-09-15 14:53:21 +0100604 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100605 .init_irq = pxa25x_init_irq,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100606 .init_machine = corgi_init,
607 .timer = &pxa_timer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608MACHINE_END
609#endif
610
611#ifdef CONFIG_MACH_SHEPHERD
612MACHINE_START(SHEPHERD, "SHARP Shepherd")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100613 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100614 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100615 .fixup = fixup_corgi,
Richard Purdiefdce05b2005-09-15 14:53:21 +0100616 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100617 .init_irq = pxa25x_init_irq,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100618 .init_machine = corgi_init,
619 .timer = &pxa_timer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620MACHINE_END
621#endif
622
623#ifdef CONFIG_MACH_HUSKY
624MACHINE_START(HUSKY, "SHARP Husky")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100625 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100626 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100627 .fixup = fixup_corgi,
Richard Purdiefdce05b2005-09-15 14:53:21 +0100628 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100629 .init_irq = pxa25x_init_irq,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100630 .init_machine = corgi_init,
631 .timer = &pxa_timer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632MACHINE_END
633#endif
634