aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/spitz.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/spitz.c')
-rw-r--r--arch/arm/mach-pxa/spitz.c533
1 files changed, 278 insertions, 255 deletions
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 7e181afcca39..9b4f24c7c055 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -19,10 +19,17 @@
19#include <linux/major.h> 19#include <linux/major.h>
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/gpio.h>
23#include <linux/leds.h>
22#include <linux/mmc/host.h> 24#include <linux/mmc/host.h>
23#include <linux/pm.h> 25#include <linux/pm.h>
24#include <linux/backlight.h> 26#include <linux/backlight.h>
25#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/i2c.h>
29#include <linux/i2c/pca953x.h>
30#include <linux/spi/spi.h>
31#include <linux/spi/ads7846.h>
32#include <linux/spi/corgi_lcd.h>
26 33
27#include <asm/setup.h> 34#include <asm/setup.h>
28#include <asm/memory.h> 35#include <asm/memory.h>
@@ -37,7 +44,7 @@
37 44
38#include <mach/pxa-regs.h> 45#include <mach/pxa-regs.h>
39#include <mach/pxa2xx-regs.h> 46#include <mach/pxa2xx-regs.h>
40#include <mach/pxa2xx-gpio.h> 47#include <mach/mfp-pxa27x.h>
41#include <mach/pxa27x-udc.h> 48#include <mach/pxa27x-udc.h>
42#include <mach/reset.h> 49#include <mach/reset.h>
43#include <mach/i2c.h> 50#include <mach/i2c.h>
@@ -46,7 +53,7 @@
46#include <mach/ohci.h> 53#include <mach/ohci.h>
47#include <mach/udc.h> 54#include <mach/udc.h>
48#include <mach/pxafb.h> 55#include <mach/pxafb.h>
49#include <mach/akita.h> 56#include <mach/pxa2xx_spi.h>
50#include <mach/spitz.h> 57#include <mach/spitz.h>
51#include <mach/sharpsl.h> 58#include <mach/sharpsl.h>
52 59
@@ -57,6 +64,66 @@
57#include "devices.h" 64#include "devices.h"
58#include "sharpsl.h" 65#include "sharpsl.h"
59 66
67static unsigned long spitz_pin_config[] __initdata = {
68 /* Chip Selects */
69 GPIO78_nCS_2, /* SCOOP #2 */
70 GPIO80_nCS_4, /* SCOOP #1 */
71
72 /* LCD - 16bpp Active TFT */
73 GPIO58_LCD_LDD_0,
74 GPIO59_LCD_LDD_1,
75 GPIO60_LCD_LDD_2,
76 GPIO61_LCD_LDD_3,
77 GPIO62_LCD_LDD_4,
78 GPIO63_LCD_LDD_5,
79 GPIO64_LCD_LDD_6,
80 GPIO65_LCD_LDD_7,
81 GPIO66_LCD_LDD_8,
82 GPIO67_LCD_LDD_9,
83 GPIO68_LCD_LDD_10,
84 GPIO69_LCD_LDD_11,
85 GPIO70_LCD_LDD_12,
86 GPIO71_LCD_LDD_13,
87 GPIO72_LCD_LDD_14,
88 GPIO73_LCD_LDD_15,
89 GPIO74_LCD_FCLK,
90 GPIO75_LCD_LCLK,
91 GPIO76_LCD_PCLK,
92
93 /* PC Card */
94 GPIO48_nPOE,
95 GPIO49_nPWE,
96 GPIO50_nPIOR,
97 GPIO51_nPIOW,
98 GPIO85_nPCE_1,
99 GPIO54_nPCE_2,
100 GPIO79_PSKTSEL,
101 GPIO55_nPREG,
102 GPIO56_nPWAIT,
103 GPIO57_nIOIS16,
104
105 /* MMC */
106 GPIO32_MMC_CLK,
107 GPIO112_MMC_CMD,
108 GPIO92_MMC_DAT_0,
109 GPIO109_MMC_DAT_1,
110 GPIO110_MMC_DAT_2,
111 GPIO111_MMC_DAT_3,
112
113 /* GPIOs */
114 GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
115 GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
116 GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
117 GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
118 GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
119 GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
120 GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
121 GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
122 GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
123
124 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
125};
126
60/* 127/*
61 * Spitz SCOOP Device #1 128 * Spitz SCOOP Device #1
62 */ 129 */
@@ -69,10 +136,11 @@ static struct resource spitz_scoop_resources[] = {
69}; 136};
70 137
71static struct scoop_config spitz_scoop_setup = { 138static struct scoop_config spitz_scoop_setup = {
72 .io_dir = SPITZ_SCP_IO_DIR, 139 .io_dir = SPITZ_SCP_IO_DIR,
73 .io_out = SPITZ_SCP_IO_OUT, 140 .io_out = SPITZ_SCP_IO_OUT,
74 .suspend_clr = SPITZ_SCP_SUS_CLR, 141 .suspend_clr = SPITZ_SCP_SUS_CLR,
75 .suspend_set = SPITZ_SCP_SUS_SET, 142 .suspend_set = SPITZ_SCP_SUS_SET,
143 .gpio_base = SPITZ_SCP_GPIO_BASE,
76}; 144};
77 145
78struct platform_device spitzscoop_device = { 146struct platform_device spitzscoop_device = {
@@ -97,10 +165,11 @@ static struct resource spitz_scoop2_resources[] = {
97}; 165};
98 166
99static struct scoop_config spitz_scoop2_setup = { 167static struct scoop_config spitz_scoop2_setup = {
100 .io_dir = SPITZ_SCP2_IO_DIR, 168 .io_dir = SPITZ_SCP2_IO_DIR,
101 .io_out = SPITZ_SCP2_IO_OUT, 169 .io_out = SPITZ_SCP2_IO_OUT,
102 .suspend_clr = SPITZ_SCP2_SUS_CLR, 170 .suspend_clr = SPITZ_SCP2_SUS_CLR,
103 .suspend_set = SPITZ_SCP2_SUS_SET, 171 .suspend_set = SPITZ_SCP2_SUS_SET,
172 .gpio_base = SPITZ_SCP2_GPIO_BASE,
104}; 173};
105 174
106struct platform_device spitzscoop2_device = { 175struct platform_device spitzscoop2_device = {
@@ -122,7 +191,7 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
122 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR); 191 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
123 192
124 if (new_cpr & 0x0007) { 193 if (new_cpr & 0x0007) {
125 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); 194 gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
126 if (!(cpr & 0x0002) && !(cpr & 0x0004)) 195 if (!(cpr & 0x0002) && !(cpr & 0x0004))
127 mdelay(5); 196 mdelay(5);
128 if (device == SPITZ_PWR_CF) 197 if (device == SPITZ_PWR_CF)
@@ -138,34 +207,13 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
138 if (!(cpr & 0x0002) && !(cpr & 0x0004)) { 207 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
139 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000); 208 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
140 mdelay(1); 209 mdelay(1);
141 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); 210 gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
142 } else { 211 } else {
143 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); 212 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
144 } 213 }
145 } 214 }
146} 215}
147 216
148static void spitz_pcmcia_init(void)
149{
150 /* Setup default state of GPIO outputs
151 before we enable them as outputs. */
152 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
153 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
154 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO54_nPCE_2);
155 GPSR(GPIO85_nPCE_1) = GPIO_bit(GPIO85_nPCE_1);
156
157 pxa_gpio_mode(GPIO48_nPOE_MD);
158 pxa_gpio_mode(GPIO49_nPWE_MD);
159 pxa_gpio_mode(GPIO50_nPIOR_MD);
160 pxa_gpio_mode(GPIO51_nPIOW_MD);
161 pxa_gpio_mode(GPIO55_nPREG_MD);
162 pxa_gpio_mode(GPIO56_nPWAIT_MD);
163 pxa_gpio_mode(GPIO57_nIOIS16_MD);
164 pxa_gpio_mode(GPIO85_nPCE_1_MD);
165 pxa_gpio_mode(GPIO54_nPCE_2_MD);
166 pxa_gpio_mode(GPIO104_pSKTSEL_MD);
167}
168
169static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr) 217static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
170{ 218{
171 /* Only need to override behaviour for slot 0 */ 219 /* Only need to override behaviour for slot 0 */
@@ -191,165 +239,169 @@ static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
191static struct scoop_pcmcia_config spitz_pcmcia_config = { 239static struct scoop_pcmcia_config spitz_pcmcia_config = {
192 .devs = &spitz_pcmcia_scoop[0], 240 .devs = &spitz_pcmcia_scoop[0],
193 .num_devs = 2, 241 .num_devs = 2,
194 .pcmcia_init = spitz_pcmcia_init,
195 .power_ctrl = spitz_pcmcia_pwr, 242 .power_ctrl = spitz_pcmcia_pwr,
196}; 243};
197 244
198EXPORT_SYMBOL(spitzscoop_device); 245EXPORT_SYMBOL(spitzscoop_device);
199EXPORT_SYMBOL(spitzscoop2_device); 246EXPORT_SYMBOL(spitzscoop2_device);
200 247
201
202/* 248/*
203 * Spitz SSP Device 249 * Spitz Keyboard Device
204 *
205 * Set the parent as the scoop device because a lot of SSP devices
206 * also use scoop functions and this makes the power up/down order
207 * work correctly.
208 */ 250 */
209struct platform_device spitzssp_device = { 251static struct platform_device spitzkbd_device = {
210 .name = "corgi-ssp", 252 .name = "spitz-keyboard",
211 .dev = {
212 .parent = &spitzscoop_device.dev,
213 },
214 .id = -1, 253 .id = -1,
215}; 254};
216 255
217struct corgissp_machinfo spitz_ssp_machinfo = {
218 .port = 2,
219 .cs_lcdcon = SPITZ_GPIO_LCDCON_CS,
220 .cs_ads7846 = SPITZ_GPIO_ADS7846_CS,
221 .cs_max1111 = SPITZ_GPIO_MAX1111_CS,
222 .clk_lcdcon = 520,
223 .clk_ads7846 = 14,
224 .clk_max1111 = 56,
225};
226
227 256
228/* 257/*
229 * Spitz Backlight Device 258 * Spitz LEDs
230 */ 259 */
231static void spitz_bl_kick_battery(void) 260static struct gpio_led spitz_gpio_leds[] = {
232{ 261 {
233 void (*kick_batt)(void); 262 .name = "spitz:amber:charge",
234 263 .default_trigger = "sharpsl-charge",
235 kick_batt = symbol_get(sharpsl_battery_kick); 264 .gpio = SPITZ_GPIO_LED_ORANGE,
236 if (kick_batt) { 265 },
237 kick_batt(); 266 {
238 symbol_put(sharpsl_battery_kick); 267 .name = "spitz:green:hddactivity",
239 } 268 .default_trigger = "ide-disk",
240} 269 .gpio = SPITZ_GPIO_LED_GREEN,
241
242static struct generic_bl_info spitz_bl_machinfo = {
243 .name = "corgi-bl",
244 .default_intensity = 0x1f,
245 .limit_mask = 0x0b,
246 .max_intensity = 0x2f,
247 .kick_battery = spitz_bl_kick_battery,
248};
249
250static struct platform_device spitzbl_device = {
251 .name = "generic-bl",
252 .dev = {
253 .platform_data = &spitz_bl_machinfo,
254 }, 270 },
255 .id = -1,
256}; 271};
257 272
258 273static struct gpio_led_platform_data spitz_gpio_leds_info = {
259/* 274 .leds = spitz_gpio_leds,
260 * Spitz Keyboard Device 275 .num_leds = ARRAY_SIZE(spitz_gpio_leds),
261 */
262static struct platform_device spitzkbd_device = {
263 .name = "spitz-keyboard",
264 .id = -1,
265}; 276};
266 277
267
268/*
269 * Spitz LEDs
270 */
271static struct platform_device spitzled_device = { 278static struct platform_device spitzled_device = {
272 .name = "spitz-led", 279 .name = "leds-gpio",
273 .id = -1, 280 .id = -1,
281 .dev = {
282 .platform_data = &spitz_gpio_leds_info,
283 },
274}; 284};
275 285
276/* 286#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
277 * Spitz Touch Screen Device 287static struct pxa2xx_spi_master spitz_spi_info = {
278 */ 288 .num_chipselect = 3,
289};
279 290
280static unsigned long (*get_hsync_invperiod)(struct device *dev); 291static struct ads7846_platform_data spitz_ads7846_info = {
292 .model = 7846,
293 .vref_delay_usecs = 100,
294 .x_plate_ohms = 419,
295 .y_plate_ohms = 486,
296 .gpio_pendown = SPITZ_GPIO_TP_INT,
297};
281 298
282static void inline sharpsl_wait_sync(int gpio) 299static void spitz_ads7846_cs(u32 command)
283{ 300{
284 while((GPLR(gpio) & GPIO_bit(gpio)) == 0); 301 gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
285 while((GPLR(gpio) & GPIO_bit(gpio)) != 0);
286} 302}
287 303
288static struct device *spitz_pxafb_dev; 304static struct pxa2xx_spi_chip spitz_ads7846_chip = {
305 .cs_control = spitz_ads7846_cs,
306};
289 307
290static int is_pxafb_device(struct device * dev, void * data) 308static void spitz_bl_kick_battery(void)
291{ 309{
292 struct platform_device *pdev = container_of(dev, struct platform_device, dev); 310 void (*kick_batt)(void);
293
294 return (strncmp(pdev->name, "pxa2xx-fb", 9) == 0);
295}
296 311
297static unsigned long spitz_get_hsync_invperiod(void) 312 kick_batt = symbol_get(sharpsl_battery_kick);
298{ 313 if (kick_batt) {
299#ifdef CONFIG_FB_PXA 314 kick_batt();
300 if (!spitz_pxafb_dev) { 315 symbol_put(sharpsl_battery_kick);
301 spitz_pxafb_dev = bus_find_device(&platform_bus_type, NULL, NULL, is_pxafb_device);
302 if (!spitz_pxafb_dev)
303 return 0;
304 } 316 }
305 if (!get_hsync_invperiod)
306 get_hsync_invperiod = symbol_get(pxafb_get_hsync_time);
307 if (!get_hsync_invperiod)
308#endif
309 return 0;
310
311 return get_hsync_invperiod(spitz_pxafb_dev);
312} 317}
313 318
314static void spitz_put_hsync(void) 319static struct corgi_lcd_platform_data spitz_lcdcon_info = {
315{ 320 .init_mode = CORGI_LCD_MODE_VGA,
316 put_device(spitz_pxafb_dev); 321 .max_intensity = 0x2f,
317 if (get_hsync_invperiod) 322 .default_intensity = 0x1f,
318 symbol_put(pxafb_get_hsync_time); 323 .limit_mask = 0x0b,
319 spitz_pxafb_dev = NULL; 324 .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
320 get_hsync_invperiod = NULL; 325 .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
321} 326 .kick_battery = spitz_bl_kick_battery,
327};
322 328
323static void spitz_wait_hsync(void) 329static void spitz_lcdcon_cs(u32 command)
324{ 330{
325 sharpsl_wait_sync(SPITZ_GPIO_HSYNC); 331 gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
326} 332}
327 333
328static struct resource spitzts_resources[] = { 334static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
329 [0] = { 335 .cs_control = spitz_lcdcon_cs,
330 .start = SPITZ_IRQ_GPIO_TP_INT,
331 .end = SPITZ_IRQ_GPIO_TP_INT,
332 .flags = IORESOURCE_IRQ,
333 },
334}; 336};
335 337
336static struct corgits_machinfo spitz_ts_machinfo = { 338static void spitz_max1111_cs(u32 command)
337 .get_hsync_invperiod = spitz_get_hsync_invperiod, 339{
338 .put_hsync = spitz_put_hsync, 340 gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
339 .wait_hsync = spitz_wait_hsync, 341}
342
343static struct pxa2xx_spi_chip spitz_max1111_chip = {
344 .cs_control = spitz_max1111_cs,
340}; 345};
341 346
342static struct platform_device spitzts_device = { 347static struct spi_board_info spitz_spi_devices[] = {
343 .name = "corgi-ts", 348 {
344 .dev = { 349 .modalias = "ads7846",
345 .parent = &spitzssp_device.dev, 350 .max_speed_hz = 1200000,
346 .platform_data = &spitz_ts_machinfo, 351 .bus_num = 2,
352 .chip_select = 0,
353 .platform_data = &spitz_ads7846_info,
354 .controller_data= &spitz_ads7846_chip,
355 .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
356 }, {
357 .modalias = "corgi-lcd",
358 .max_speed_hz = 50000,
359 .bus_num = 2,
360 .chip_select = 1,
361 .platform_data = &spitz_lcdcon_info,
362 .controller_data= &spitz_lcdcon_chip,
363 }, {
364 .modalias = "max1111",
365 .max_speed_hz = 450000,
366 .bus_num = 2,
367 .chip_select = 2,
368 .controller_data= &spitz_max1111_chip,
347 }, 369 },
348 .id = -1,
349 .num_resources = ARRAY_SIZE(spitzts_resources),
350 .resource = spitzts_resources,
351}; 370};
352 371
372static void __init spitz_init_spi(void)
373{
374 int err;
375
376 err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS");
377 if (err)
378 return;
379
380 err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS");
381 if (err)
382 goto err_free_1;
383
384 err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS");
385 if (err)
386 goto err_free_2;
387
388 if (machine_is_akita()) {
389 spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
390 spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
391 }
392
393 pxa2xx_set_spi_info(2, &spitz_spi_info);
394 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
395 return;
396
397err_free_2:
398 gpio_free(SPITZ_GPIO_LCDCON_CS);
399err_free_1:
400 gpio_free(SPITZ_GPIO_ADS7846_CS);
401}
402#else
403static inline void spitz_init_spi(void) {}
404#endif
353 405
354/* 406/*
355 * MMC/SD Device 407 * MMC/SD Device
@@ -364,24 +416,35 @@ static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, vo
364{ 416{
365 int err; 417 int err;
366 418
367 /* setup GPIO for PXA27x MMC controller */ 419 err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT");
368 pxa_gpio_mode(GPIO32_MMCCLK_MD); 420 if (err)
369 pxa_gpio_mode(GPIO112_MMCCMD_MD); 421 goto err_out;
370 pxa_gpio_mode(GPIO92_MMCDAT0_MD); 422
371 pxa_gpio_mode(GPIO109_MMCDAT1_MD); 423 err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP");
372 pxa_gpio_mode(GPIO110_MMCDAT2_MD); 424 if (err)
373 pxa_gpio_mode(GPIO111_MMCDAT3_MD); 425 goto err_free_1;
374 pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN); 426
375 pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN); 427 gpio_direction_input(SPITZ_GPIO_nSD_DETECT);
428 gpio_direction_input(SPITZ_GPIO_nSD_WP);
376 429
377 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250); 430 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
378 431
379 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, 432 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
380 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 433 IRQF_DISABLED | IRQF_TRIGGER_RISING |
434 IRQF_TRIGGER_FALLING,
381 "MMC card detect", data); 435 "MMC card detect", data);
382 if (err) 436 if (err) {
383 printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n"); 437 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
438 __func__);
439 goto err_free_2;
440 }
441 return 0;
384 442
443err_free_2:
444 gpio_free(SPITZ_GPIO_nSD_WP);
445err_free_1:
446 gpio_free(SPITZ_GPIO_nSD_DETECT);
447err_out:
385 return err; 448 return err;
386} 449}
387 450
@@ -397,12 +460,14 @@ static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
397 460
398static int spitz_mci_get_ro(struct device *dev) 461static int spitz_mci_get_ro(struct device *dev)
399{ 462{
400 return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP); 463 return gpio_get_value(SPITZ_GPIO_nSD_WP);
401} 464}
402 465
403static void spitz_mci_exit(struct device *dev, void *data) 466static void spitz_mci_exit(struct device *dev, void *data)
404{ 467{
405 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data); 468 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
469 gpio_free(SPITZ_GPIO_nSD_WP);
470 gpio_free(SPITZ_GPIO_nSD_DETECT);
406} 471}
407 472
408static struct pxamci_platform_data spitz_mci_platform_data = { 473static struct pxamci_platform_data spitz_mci_platform_data = {
@@ -419,27 +484,24 @@ static struct pxamci_platform_data spitz_mci_platform_data = {
419 */ 484 */
420static int spitz_ohci_init(struct device *dev) 485static int spitz_ohci_init(struct device *dev)
421{ 486{
422 /* Only Port 2 is connected */ 487 int err;
423 pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN);
424 pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT);
425 pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN);
426
427 /* Setup USB Port 2 Output Control Register */
428 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
429
430 GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST);
431 488
432 UHCHR = (UHCHR) & 489 err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
433 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); 490 if (err)
491 return err;
434 492
435 UHCRHDA |= UHCRHDA_NOCP; 493 /* Only Port 2 is connected
494 * Setup USB Port 2 Output Control Register
495 */
496 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
436 497
437 return 0; 498 return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
438} 499}
439 500
440static struct pxaohci_platform_data spitz_ohci_platform_data = { 501static struct pxaohci_platform_data spitz_ohci_platform_data = {
441 .port_mode = PMM_NPS_MODE, 502 .port_mode = PMM_NPS_MODE,
442 .init = spitz_ohci_init, 503 .init = spitz_ohci_init,
504 .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
443 .power_budget = 150, 505 .power_budget = 150,
444}; 506};
445 507
@@ -447,29 +509,50 @@ static struct pxaohci_platform_data spitz_ohci_platform_data = {
447/* 509/*
448 * Irda 510 * Irda
449 */ 511 */
512static int spitz_irda_startup(struct device *dev)
513{
514 int rc;
515
516 rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
517 if (rc)
518 goto err;
519
520 rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
521 if (rc)
522 goto err_dir;
523
524 return 0;
525
526err_dir:
527 gpio_free(SPITZ_GPIO_IR_ON);
528err:
529 return rc;
530}
531
532static void spitz_irda_shutdown(struct device *dev)
533{
534 gpio_free(SPITZ_GPIO_IR_ON);
535}
536
450static void spitz_irda_transceiver_mode(struct device *dev, int mode) 537static void spitz_irda_transceiver_mode(struct device *dev, int mode)
451{ 538{
452 if (mode & IR_OFF) 539 gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
453 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
454 else
455 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
456 pxa2xx_transceiver_mode(dev, mode); 540 pxa2xx_transceiver_mode(dev, mode);
457} 541}
458 542
459#ifdef CONFIG_MACH_AKITA 543#ifdef CONFIG_MACH_AKITA
460static void akita_irda_transceiver_mode(struct device *dev, int mode) 544static void akita_irda_transceiver_mode(struct device *dev, int mode)
461{ 545{
462 if (mode & IR_OFF) 546 gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
463 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
464 else
465 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
466 pxa2xx_transceiver_mode(dev, mode); 547 pxa2xx_transceiver_mode(dev, mode);
467} 548}
468#endif 549#endif
469 550
470static struct pxaficp_platform_data spitz_ficp_platform_data = { 551static struct pxaficp_platform_data spitz_ficp_platform_data = {
471 .transceiver_cap = IR_SIRMODE | IR_OFF, 552 .transceiver_cap = IR_SIRMODE | IR_OFF,
472 .transceiver_mode = spitz_irda_transceiver_mode, 553 .transceiver_mode = spitz_irda_transceiver_mode,
554 .startup = spitz_irda_startup,
555 .shutdown = spitz_irda_shutdown,
473}; 556};
474 557
475 558
@@ -477,14 +560,6 @@ static struct pxaficp_platform_data spitz_ficp_platform_data = {
477 * Spitz PXA Framebuffer 560 * Spitz PXA Framebuffer
478 */ 561 */
479 562
480static void spitz_lcd_power(int on, struct fb_var_screeninfo *var)
481{
482 if (on)
483 corgi_lcdtg_hw_init(var->xres);
484 else
485 corgi_lcdtg_suspend();
486}
487
488static struct pxafb_mode_info spitz_pxafb_modes[] = { 563static struct pxafb_mode_info spitz_pxafb_modes[] = {
489{ 564{
490 .pixclock = 19231, 565 .pixclock = 19231,
@@ -517,18 +592,13 @@ static struct pxafb_mach_info spitz_pxafb_info = {
517 .modes = &spitz_pxafb_modes[0], 592 .modes = &spitz_pxafb_modes[0],
518 .num_modes = 2, 593 .num_modes = 2,
519 .fixed_modes = 1, 594 .fixed_modes = 1,
520 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM, 595 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
521 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
522 .pxafb_lcd_power = spitz_lcd_power,
523}; 596};
524 597
525 598
526static struct platform_device *devices[] __initdata = { 599static struct platform_device *devices[] __initdata = {
527 &spitzscoop_device, 600 &spitzscoop_device,
528 &spitzssp_device,
529 &spitzkbd_device, 601 &spitzkbd_device,
530 &spitzts_device,
531 &spitzbl_device,
532 &spitzled_device, 602 &spitzled_device,
533}; 603};
534 604
@@ -554,57 +624,26 @@ static void __init common_init(void)
554 624
555 PMCR = 0x00; 625 PMCR = 0x00;
556 626
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 */ 627 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
566 PCFR |= PCFR_OPDE; 628 PCFR |= PCFR_OPDE;
567 629
568 corgi_ssp_set_machinfo(&spitz_ssp_machinfo); 630 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
569 631
570 pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN); 632 spitz_init_spi();
571 633
572 platform_add_devices(devices, ARRAY_SIZE(devices)); 634 platform_add_devices(devices, ARRAY_SIZE(devices));
573 pxa_set_mci_info(&spitz_mci_platform_data); 635 pxa_set_mci_info(&spitz_mci_platform_data);
574 pxa_set_ohci_info(&spitz_ohci_platform_data); 636 pxa_set_ohci_info(&spitz_ohci_platform_data);
575 pxa_set_ficp_info(&spitz_ficp_platform_data); 637 pxa_set_ficp_info(&spitz_ficp_platform_data);
576 set_pxa_fb_parent(&spitzssp_device.dev);
577 set_pxa_fb_info(&spitz_pxafb_info); 638 set_pxa_fb_info(&spitz_pxafb_info);
578 pxa_set_i2c_info(NULL); 639 pxa_set_i2c_info(NULL);
579} 640}
580 641
581#if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI) 642#if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
582static void spitz_bl_set_intensity(int intensity)
583{
584 if (intensity > 0x10)
585 intensity += 0x10;
586
587 /* Bits 0-4 are accessed via the SSP interface */
588 corgi_ssp_blduty_set(intensity & 0x1f);
589
590 /* Bit 5 is via SCOOP */
591 if (intensity & 0x0020)
592 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
593 else
594 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT);
595
596 if (intensity)
597 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
598 else
599 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON);
600}
601
602static void __init spitz_init(void) 643static void __init spitz_init(void)
603{ 644{
604 platform_scoop_config = &spitz_pcmcia_config; 645 platform_scoop_config = &spitz_pcmcia_config;
605 646
606 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
607
608 common_init(); 647 common_init();
609 648
610 platform_device_register(&spitzscoop2_device); 649 platform_device_register(&spitzscoop2_device);
@@ -615,32 +654,17 @@ static void __init spitz_init(void)
615/* 654/*
616 * Akita IO Expander 655 * Akita IO Expander
617 */ 656 */
618struct platform_device akitaioexp_device = { 657static struct pca953x_platform_data akita_ioexp = {
619 .name = "akita-ioexp", 658 .gpio_base = AKITA_IOEXP_GPIO_BASE,
620 .id = -1,
621}; 659};
622 660
623EXPORT_SYMBOL_GPL(akitaioexp_device); 661static struct i2c_board_info akita_i2c_board_info[] = {
624 662 {
625static void akita_bl_set_intensity(int intensity) 663 .type = "max7310",
626{ 664 .addr = 0x18,
627 if (intensity > 0x10) 665 .platform_data = &akita_ioexp,
628 intensity += 0x10; 666 },
629 667};
630 /* Bits 0-4 are accessed via the SSP interface */
631 corgi_ssp_blduty_set(intensity & 0x1f);
632
633 /* Bit 5 is via IO-Expander */
634 if (intensity & 0x0020)
635 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
636 else
637 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
638
639 if (intensity)
640 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
641 else
642 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
643}
644 668
645static void __init akita_init(void) 669static void __init akita_init(void)
646{ 670{
@@ -649,11 +673,10 @@ static void __init akita_init(void)
649 /* We just pretend the second element of the array doesn't exist */ 673 /* We just pretend the second element of the array doesn't exist */
650 spitz_pcmcia_config.num_devs = 1; 674 spitz_pcmcia_config.num_devs = 1;
651 platform_scoop_config = &spitz_pcmcia_config; 675 platform_scoop_config = &spitz_pcmcia_config;
652 spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity;
653 676
654 platform_device_register(&akitaioexp_device); 677 pxa_set_i2c_info(NULL);
678 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
655 679
656 spitzscoop_device.dev.parent = &akitaioexp_device.dev;
657 common_init(); 680 common_init();
658} 681}
659#endif 682#endif