locks: fix setlease methods to free passed-in lock
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-pxa / stargate2.c
blob738adc1773fdf643cfc4a81c662fd10da0b2bc8e
1 /*
2 * linux/arch/arm/mach-pxa/stargate2.c
4 * Author: Ed C. Epp
5 * Created: Nov 05, 2002
6 * Copyright: Intel Corp.
8 * Modified 2009: Jonathan Cameron <jic23@cam.ac.uk>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/init.h>
16 #include <linux/device.h>
17 #include <linux/interrupt.h>
18 #include <linux/sched.h>
19 #include <linux/bitops.h>
20 #include <linux/fb.h>
21 #include <linux/delay.h>
22 #include <linux/platform_device.h>
23 #include <linux/regulator/machine.h>
24 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/plat-ram.h>
26 #include <linux/mtd/partitions.h>
28 #include <linux/i2c/pcf857x.h>
29 #include <linux/i2c/at24.h>
30 #include <linux/smc91x.h>
31 #include <linux/gpio.h>
32 #include <linux/leds.h>
34 #include <asm/types.h>
35 #include <asm/setup.h>
36 #include <asm/memory.h>
37 #include <asm/mach-types.h>
38 #include <asm/irq.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/map.h>
42 #include <asm/mach/irq.h>
43 #include <asm/mach/flash.h>
45 #include <mach/pxa27x.h>
46 #include <plat/i2c.h>
47 #include <mach/mmc.h>
48 #include <mach/udc.h>
49 #include <mach/pxa2xx_spi.h>
50 #include <mach/pxa27x-udc.h>
52 #include <linux/spi/spi.h>
53 #include <linux/mfd/da903x.h>
54 #include <linux/sht15.h>
56 #include "devices.h"
57 #include "generic.h"
59 #define STARGATE_NR_IRQS (IRQ_BOARD_START + 8)
61 /* Bluetooth */
62 #define SG2_BT_RESET 81
64 /* SD */
65 #define SG2_GPIO_nSD_DETECT 90
66 #define SG2_SD_POWER_ENABLE 89
68 static unsigned long sg2_im2_unified_pin_config[] __initdata = {
69 /* Device Identification for wakeup*/
70 GPIO102_GPIO,
71 /* DA9030 */
72 GPIO1_GPIO,
74 /* MMC */
75 GPIO32_MMC_CLK,
76 GPIO112_MMC_CMD,
77 GPIO92_MMC_DAT_0,
78 GPIO109_MMC_DAT_1,
79 GPIO110_MMC_DAT_2,
80 GPIO111_MMC_DAT_3,
82 /* 802.15.4 radio - driver out of mainline */
83 GPIO22_GPIO, /* CC_RSTN */
84 GPIO114_GPIO, /* CC_FIFO */
85 GPIO116_GPIO, /* CC_CCA */
86 GPIO0_GPIO, /* CC_FIFOP */
87 GPIO16_GPIO, /* CCSFD */
88 GPIO115_GPIO, /* Power enable */
90 /* I2C */
91 GPIO117_I2C_SCL,
92 GPIO118_I2C_SDA,
94 /* SSP 3 - 802.15.4 radio */
95 GPIO39_GPIO, /* Chip Select */
96 GPIO34_SSP3_SCLK,
97 GPIO35_SSP3_TXD,
98 GPIO41_SSP3_RXD,
100 /* SSP 2 to daughter boards */
101 GPIO11_SSP2_RXD,
102 GPIO38_SSP2_TXD,
103 GPIO36_SSP2_SCLK,
104 GPIO37_GPIO, /* chip select */
106 /* SSP 1 - to daughter boards */
107 GPIO24_GPIO, /* Chip Select */
108 GPIO23_SSP1_SCLK,
109 GPIO25_SSP1_TXD,
110 GPIO26_SSP1_RXD,
112 /* BTUART Basic Connector*/
113 GPIO42_BTUART_RXD,
114 GPIO43_BTUART_TXD,
115 GPIO44_BTUART_CTS,
116 GPIO45_BTUART_RTS,
118 /* STUART - IM2 via debug board not sure on SG2*/
119 GPIO46_STUART_RXD,
120 GPIO47_STUART_TXD,
122 /* Basic sensor board */
123 GPIO96_GPIO, /* accelerometer interrupt */
124 GPIO99_GPIO, /* ADC interrupt */
126 /* SHT15 */
127 GPIO100_GPIO,
128 GPIO98_GPIO,
130 /* Basic sensor board */
131 GPIO96_GPIO, /* accelerometer interrupt */
132 GPIO99_GPIO, /* ADC interrupt */
134 /* Connector pins specified as gpios */
135 GPIO94_GPIO, /* large basic connector pin 14 */
136 GPIO10_GPIO, /* large basic connector pin 23 */
139 static struct sht15_platform_data platform_data_sht15 = {
140 .gpio_data = 100,
141 .gpio_sck = 98,
144 static struct platform_device sht15 = {
145 .name = "sht15",
146 .id = -1,
147 .dev = {
148 .platform_data = &platform_data_sht15,
152 static struct regulator_consumer_supply stargate2_sensor_3_con[] = {
154 .dev = &sht15.dev,
155 .supply = "vcc",
159 enum stargate2_ldos{
160 vcc_vref,
161 vcc_cc2420,
162 /* a mote connector? */
163 vcc_mica,
164 /* the CSR bluecore chip */
165 vcc_bt,
166 /* The two voltages available to sensor boards */
167 vcc_sensor_1_8,
168 vcc_sensor_3,
169 /* directly connected to the pxa27x */
170 vcc_sram_ext,
171 vcc_pxa_pll,
172 vcc_pxa_usim, /* Reference voltage for certain gpios */
173 vcc_pxa_mem,
174 vcc_pxa_flash,
175 vcc_pxa_core, /*Dc-Dc buck not yet supported */
176 vcc_lcd,
177 vcc_bb,
178 vcc_bbio, /*not sure!*/
179 vcc_io, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
182 /* The values of the various regulator constraints are obviously dependent
183 * on exactly what is wired to each ldo. Unfortunately this information is
184 * not generally available. More information has been requested from Xbow.
186 static struct regulator_init_data stargate2_ldo_init_data[] = {
187 [vcc_bbio] = {
188 .constraints = { /* board default 1.8V */
189 .name = "vcc_bbio",
190 .min_uV = 1800000,
191 .max_uV = 1800000,
194 [vcc_bb] = {
195 .constraints = { /* board default 2.8V */
196 .name = "vcc_bb",
197 .min_uV = 2700000,
198 .max_uV = 3000000,
201 [vcc_pxa_flash] = {
202 .constraints = {/* default is 1.8V */
203 .name = "vcc_pxa_flash",
204 .min_uV = 1800000,
205 .max_uV = 1800000,
208 [vcc_cc2420] = { /* also vcc_io */
209 .constraints = {
210 /* board default is 2.8V */
211 .name = "vcc_cc2420",
212 .min_uV = 2700000,
213 .max_uV = 3300000,
216 [vcc_vref] = { /* Reference for what? */
217 .constraints = { /* default 1.8V */
218 .name = "vcc_vref",
219 .min_uV = 1800000,
220 .max_uV = 1800000,
223 [vcc_sram_ext] = {
224 .constraints = { /* default 2.8V */
225 .name = "vcc_sram_ext",
226 .min_uV = 2800000,
227 .max_uV = 2800000,
230 [vcc_mica] = {
231 .constraints = { /* default 2.8V */
232 .name = "vcc_mica",
233 .min_uV = 2800000,
234 .max_uV = 2800000,
237 [vcc_bt] = {
238 .constraints = { /* default 2.8V */
239 .name = "vcc_bt",
240 .min_uV = 2800000,
241 .max_uV = 2800000,
244 [vcc_lcd] = {
245 .constraints = { /* default 2.8V */
246 .name = "vcc_lcd",
247 .min_uV = 2700000,
248 .max_uV = 3300000,
251 [vcc_io] = { /* Same or higher than everything
252 * bar vccbat and vccusb */
253 .constraints = { /* default 2.8V */
254 .name = "vcc_io",
255 .min_uV = 2692000,
256 .max_uV = 3300000,
259 [vcc_sensor_1_8] = {
260 .constraints = { /* default 1.8V */
261 .name = "vcc_sensor_1_8",
262 .min_uV = 1800000,
263 .max_uV = 1800000,
266 [vcc_sensor_3] = { /* curiously default 2.8V */
267 .constraints = {
268 .name = "vcc_sensor_3",
269 .min_uV = 2800000,
270 .max_uV = 3000000,
272 .num_consumer_supplies = ARRAY_SIZE(stargate2_sensor_3_con),
273 .consumer_supplies = stargate2_sensor_3_con,
275 [vcc_pxa_pll] = { /* 1.17V - 1.43V, default 1.3V*/
276 .constraints = {
277 .name = "vcc_pxa_pll",
278 .min_uV = 1170000,
279 .max_uV = 1430000,
282 [vcc_pxa_usim] = {
283 .constraints = { /* default 1.8V */
284 .name = "vcc_pxa_usim",
285 .min_uV = 1710000,
286 .max_uV = 2160000,
289 [vcc_pxa_mem] = {
290 .constraints = { /* default 1.8V */
291 .name = "vcc_pxa_mem",
292 .min_uV = 1800000,
293 .max_uV = 1800000,
298 static struct mtd_partition stargate2flash_partitions[] = {
300 .name = "Bootloader",
301 .size = 0x00040000,
302 .offset = 0,
303 .mask_flags = 0,
304 }, {
305 .name = "Kernel",
306 .size = 0x00200000,
307 .offset = 0x00040000,
308 .mask_flags = 0
309 }, {
310 .name = "Filesystem",
311 .size = 0x01DC0000,
312 .offset = 0x00240000,
313 .mask_flags = 0
317 static struct resource flash_resources = {
318 .start = PXA_CS0_PHYS,
319 .end = PXA_CS0_PHYS + SZ_32M - 1,
320 .flags = IORESOURCE_MEM,
323 static struct flash_platform_data stargate2_flash_data = {
324 .map_name = "cfi_probe",
325 .parts = stargate2flash_partitions,
326 .nr_parts = ARRAY_SIZE(stargate2flash_partitions),
327 .name = "PXA27xOnChipROM",
328 .width = 2,
331 static struct platform_device stargate2_flash_device = {
332 .name = "pxa2xx-flash",
333 .id = 0,
334 .dev = {
335 .platform_data = &stargate2_flash_data,
337 .resource = &flash_resources,
338 .num_resources = 1,
341 static struct pxa2xx_spi_master pxa_ssp_master_0_info = {
342 .num_chipselect = 1,
345 static struct pxa2xx_spi_master pxa_ssp_master_1_info = {
346 .num_chipselect = 1,
349 static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
350 .num_chipselect = 1,
353 /* An upcoming kernel change will scrap SFRM usage so these
354 * drivers have been moved to use gpio's via cs_control */
355 static struct pxa2xx_spi_chip staccel_chip_info = {
356 .tx_threshold = 8,
357 .rx_threshold = 8,
358 .dma_burst_size = 8,
359 .timeout = 235,
360 .gpio_cs = 24,
363 static struct pxa2xx_spi_chip cc2420_info = {
364 .tx_threshold = 8,
365 .rx_threshold = 8,
366 .dma_burst_size = 8,
367 .timeout = 235,
368 .gpio_cs = 39,
371 static struct spi_board_info spi_board_info[] __initdata = {
373 .modalias = "lis3l02dq",
374 .max_speed_hz = 8000000,/* 8MHz max spi frequency at 3V */
375 .bus_num = 1,
376 .chip_select = 0,
377 .controller_data = &staccel_chip_info,
378 .irq = IRQ_GPIO(96),
379 }, {
380 .modalias = "cc2420",
381 .max_speed_hz = 6500000,
382 .bus_num = 3,
383 .chip_select = 0,
384 .controller_data = &cc2420_info,
388 static void sg2_udc_command(int cmd)
390 switch (cmd) {
391 case PXA2XX_UDC_CMD_CONNECT:
392 UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
393 break;
394 case PXA2XX_UDC_CMD_DISCONNECT:
395 UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
396 break;
400 static struct i2c_pxa_platform_data i2c_pwr_pdata = {
401 .fast_mode = 1,
404 static struct i2c_pxa_platform_data i2c_pdata = {
405 .fast_mode = 1,
408 static void __init imote2_stargate2_init(void)
411 pxa2xx_mfp_config(ARRAY_AND_SIZE(sg2_im2_unified_pin_config));
413 pxa_set_ffuart_info(NULL);
414 pxa_set_btuart_info(NULL);
415 pxa_set_stuart_info(NULL);
417 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
418 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info);
419 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info);
420 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
423 pxa27x_set_i2c_power_info(&i2c_pwr_pdata);
424 pxa_set_i2c_info(&i2c_pdata);
427 #ifdef CONFIG_MACH_INTELMOTE2
428 /* As the the imote2 doesn't currently have a conventional SD slot
429 * there is no option to hotplug cards, making all this rather simple
431 static int imote2_mci_get_ro(struct device *dev)
433 return 0;
436 /* Rather simple case as hotplugging not possible */
437 static struct pxamci_platform_data imote2_mci_platform_data = {
438 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* default anyway */
439 .get_ro = imote2_mci_get_ro,
440 .gpio_card_detect = -1,
441 .gpio_card_ro = -1,
442 .gpio_power = -1,
445 static struct gpio_led imote2_led_pins[] = {
447 .name = "imote2:red",
448 .gpio = 103,
449 .active_low = 1,
450 }, {
451 .name = "imote2:green",
452 .gpio = 104,
453 .active_low = 1,
454 }, {
455 .name = "imote2:blue",
456 .gpio = 105,
457 .active_low = 1,
461 static struct gpio_led_platform_data imote2_led_data = {
462 .num_leds = ARRAY_SIZE(imote2_led_pins),
463 .leds = imote2_led_pins,
466 static struct platform_device imote2_leds = {
467 .name = "leds-gpio",
468 .id = -1,
469 .dev = {
470 .platform_data = &imote2_led_data,
474 static struct da903x_subdev_info imote2_da9030_subdevs[] = {
476 .name = "da903x-regulator",
477 .id = DA9030_ID_LDO2,
478 .platform_data = &stargate2_ldo_init_data[vcc_bbio],
479 }, {
480 .name = "da903x-regulator",
481 .id = DA9030_ID_LDO3,
482 .platform_data = &stargate2_ldo_init_data[vcc_bb],
483 }, {
484 .name = "da903x-regulator",
485 .id = DA9030_ID_LDO4,
486 .platform_data = &stargate2_ldo_init_data[vcc_pxa_flash],
487 }, {
488 .name = "da903x-regulator",
489 .id = DA9030_ID_LDO5,
490 .platform_data = &stargate2_ldo_init_data[vcc_cc2420],
491 }, {
492 .name = "da903x-regulator",
493 .id = DA9030_ID_LDO6,
494 .platform_data = &stargate2_ldo_init_data[vcc_vref],
495 }, {
496 .name = "da903x-regulator",
497 .id = DA9030_ID_LDO7,
498 .platform_data = &stargate2_ldo_init_data[vcc_sram_ext],
499 }, {
500 .name = "da903x-regulator",
501 .id = DA9030_ID_LDO8,
502 .platform_data = &stargate2_ldo_init_data[vcc_mica],
503 }, {
504 .name = "da903x-regulator",
505 .id = DA9030_ID_LDO9,
506 .platform_data = &stargate2_ldo_init_data[vcc_bt],
507 }, {
508 .name = "da903x-regulator",
509 .id = DA9030_ID_LDO10,
510 .platform_data = &stargate2_ldo_init_data[vcc_sensor_1_8],
511 }, {
512 .name = "da903x-regulator",
513 .id = DA9030_ID_LDO11,
514 .platform_data = &stargate2_ldo_init_data[vcc_sensor_3],
515 }, {
516 .name = "da903x-regulator",
517 .id = DA9030_ID_LDO12,
518 .platform_data = &stargate2_ldo_init_data[vcc_lcd],
519 }, {
520 .name = "da903x-regulator",
521 .id = DA9030_ID_LDO15,
522 .platform_data = &stargate2_ldo_init_data[vcc_pxa_pll],
523 }, {
524 .name = "da903x-regulator",
525 .id = DA9030_ID_LDO17,
526 .platform_data = &stargate2_ldo_init_data[vcc_pxa_usim],
527 }, {
528 .name = "da903x-regulator", /*pxa vcc i/o and cc2420 vcc i/o */
529 .id = DA9030_ID_LDO18,
530 .platform_data = &stargate2_ldo_init_data[vcc_io],
531 }, {
532 .name = "da903x-regulator",
533 .id = DA9030_ID_LDO19,
534 .platform_data = &stargate2_ldo_init_data[vcc_pxa_mem],
538 static struct da903x_platform_data imote2_da9030_pdata = {
539 .num_subdevs = ARRAY_SIZE(imote2_da9030_subdevs),
540 .subdevs = imote2_da9030_subdevs,
543 static struct i2c_board_info __initdata imote2_pwr_i2c_board_info[] = {
545 .type = "da9030",
546 .addr = 0x49,
547 .platform_data = &imote2_da9030_pdata,
548 .irq = gpio_to_irq(1),
552 static struct i2c_board_info __initdata imote2_i2c_board_info[] = {
553 { /* UCAM sensor board */
554 .type = "max1239",
555 .addr = 0x35,
556 }, { /* ITS400 Sensor board only */
557 .type = "max1363",
558 .addr = 0x34,
559 /* Through a nand gate - Also beware, on V2 sensor board the
560 * pull up resistors are missing.
562 .irq = IRQ_GPIO(99),
563 }, { /* ITS400 Sensor board only */
564 .type = "tsl2561",
565 .addr = 0x49,
566 /* Through a nand gate - Also beware, on V2 sensor board the
567 * pull up resistors are missing.
569 .irq = IRQ_GPIO(99),
570 }, { /* ITS400 Sensor board only */
571 .type = "tmp175",
572 .addr = 0x4A,
573 .irq = IRQ_GPIO(96),
574 }, { /* IMB400 Multimedia board */
575 .type = "wm8940",
576 .addr = 0x1A,
580 static unsigned long imote2_pin_config[] __initdata = {
582 /* Button */
583 GPIO91_GPIO,
585 /* LEDS */
586 GPIO103_GPIO, /* red led */
587 GPIO104_GPIO, /* green led */
588 GPIO105_GPIO, /* blue led */
591 static struct pxa2xx_udc_mach_info imote2_udc_info __initdata = {
592 .udc_command = sg2_udc_command,
595 static struct platform_device *imote2_devices[] = {
596 &stargate2_flash_device,
597 &imote2_leds,
598 &sht15,
601 static void __init imote2_init(void)
603 pxa2xx_mfp_config(ARRAY_AND_SIZE(imote2_pin_config));
605 imote2_stargate2_init();
607 platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));
609 i2c_register_board_info(0, imote2_i2c_board_info,
610 ARRAY_SIZE(imote2_i2c_board_info));
611 i2c_register_board_info(1, imote2_pwr_i2c_board_info,
612 ARRAY_SIZE(imote2_pwr_i2c_board_info));
614 pxa_set_mci_info(&imote2_mci_platform_data);
615 pxa_set_udc_info(&imote2_udc_info);
617 #endif
619 #ifdef CONFIG_MACH_STARGATE2
621 static unsigned long stargate2_pin_config[] __initdata = {
623 GPIO15_nCS_1, /* SRAM */
624 /* SMC91x */
625 GPIO80_nCS_4,
626 GPIO40_GPIO, /*cable detect?*/
628 /* Button */
629 GPIO91_GPIO | WAKEUP_ON_LEVEL_HIGH,
631 /* Compact Flash */
632 GPIO79_PSKTSEL,
633 GPIO48_nPOE,
634 GPIO49_nPWE,
635 GPIO50_nPIOR,
636 GPIO51_nPIOW,
637 GPIO85_nPCE_1,
638 GPIO54_nPCE_2,
639 GPIO55_nPREG,
640 GPIO56_nPWAIT,
641 GPIO57_nIOIS16,
642 GPIO120_GPIO, /* Buff ctrl */
643 GPIO108_GPIO, /* Power ctrl */
644 GPIO82_GPIO, /* Reset */
645 GPIO53_GPIO, /* SG2_S0_GPIO_DETECT */
647 /* MMC not shared with imote2 */
648 GPIO90_GPIO, /* nSD detect */
649 GPIO89_GPIO, /* SD_POWER_ENABLE */
651 /* Bluetooth */
652 GPIO81_GPIO, /* reset */
655 static struct resource smc91x_resources[] = {
656 [0] = {
657 .name = "smc91x-regs",
658 .start = (PXA_CS4_PHYS + 0x300),
659 .end = (PXA_CS4_PHYS + 0xfffff),
660 .flags = IORESOURCE_MEM,
662 [1] = {
663 .start = IRQ_GPIO(40),
664 .end = IRQ_GPIO(40),
665 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
669 static struct smc91x_platdata stargate2_smc91x_info = {
670 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT
671 | SMC91X_NOWAIT | SMC91X_USE_DMA,
674 static struct platform_device smc91x_device = {
675 .name = "smc91x",
676 .id = -1,
677 .num_resources = ARRAY_SIZE(smc91x_resources),
678 .resource = smc91x_resources,
679 .dev = {
680 .platform_data = &stargate2_smc91x_info,
686 * The card detect interrupt isn't debounced so we delay it by 250ms
687 * to give the card a chance to fully insert / eject.
689 static int stargate2_mci_init(struct device *dev,
690 irq_handler_t stargate2_detect_int,
691 void *data)
693 int err;
695 err = gpio_request(SG2_SD_POWER_ENABLE, "SG2_sd_power_enable");
696 if (err) {
697 printk(KERN_ERR "Can't get the gpio for SD power control");
698 goto return_err;
700 gpio_direction_output(SG2_SD_POWER_ENABLE, 0);
702 err = gpio_request(SG2_GPIO_nSD_DETECT, "SG2_sd_detect");
703 if (err) {
704 printk(KERN_ERR "Can't get the sd detect gpio");
705 goto free_power_en;
707 gpio_direction_input(SG2_GPIO_nSD_DETECT);
709 err = request_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT),
710 stargate2_detect_int,
711 IRQ_TYPE_EDGE_BOTH,
712 "MMC card detect",
713 data);
714 if (err) {
715 printk(KERN_ERR "can't request MMC card detect IRQ\n");
716 goto free_nsd_detect;
718 return 0;
720 free_nsd_detect:
721 gpio_free(SG2_GPIO_nSD_DETECT);
722 free_power_en:
723 gpio_free(SG2_SD_POWER_ENABLE);
724 return_err:
725 return err;
729 * stargate2_mci_setpower() - set state of mmc power supply
731 * Very simple control. Either it is on or off and is controlled by
732 * a gpio pin */
733 static void stargate2_mci_setpower(struct device *dev, unsigned int vdd)
735 gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd);
738 static void stargate2_mci_exit(struct device *dev, void *data)
740 free_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT), data);
741 gpio_free(SG2_SD_POWER_ENABLE);
742 gpio_free(SG2_GPIO_nSD_DETECT);
745 static struct pxamci_platform_data stargate2_mci_platform_data = {
746 .detect_delay_ms = 250,
747 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
748 .init = stargate2_mci_init,
749 .setpower = stargate2_mci_setpower,
750 .exit = stargate2_mci_exit,
755 * SRAM - The Stargate 2 has 32MB of SRAM.
757 * Here it is made available as an MTD. This will then
758 * typically have a cifs filesystem created on it to provide
759 * fast temporary storage.
761 static struct resource sram_resources = {
762 .start = PXA_CS1_PHYS,
763 .end = PXA_CS1_PHYS + SZ_32M-1,
764 .flags = IORESOURCE_MEM,
767 static struct platdata_mtd_ram stargate2_sram_pdata = {
768 .mapname = "Stargate2 SRAM",
769 .bankwidth = 2,
772 static struct platform_device stargate2_sram = {
773 .name = "mtd-ram",
774 .id = 0,
775 .resource = &sram_resources,
776 .num_resources = 1,
777 .dev = {
778 .platform_data = &stargate2_sram_pdata,
782 static struct pcf857x_platform_data platform_data_pcf857x = {
783 .gpio_base = 128,
784 .n_latch = 0,
785 .setup = NULL,
786 .teardown = NULL,
787 .context = NULL,
790 static struct at24_platform_data pca9500_eeprom_pdata = {
791 .byte_len = 256,
792 .page_size = 4,
796 * stargate2_reset_bluetooth() reset the bluecore to ensure consistent state
798 static int stargate2_reset_bluetooth(void)
800 int err;
801 err = gpio_request(SG2_BT_RESET, "SG2_BT_RESET");
802 if (err) {
803 printk(KERN_ERR "Could not get gpio for bluetooth reset\n");
804 return err;
806 gpio_direction_output(SG2_BT_RESET, 1);
807 mdelay(5);
808 /* now reset it - 5 msec minimum */
809 gpio_set_value(SG2_BT_RESET, 0);
810 mdelay(10);
811 gpio_set_value(SG2_BT_RESET, 1);
812 gpio_free(SG2_BT_RESET);
813 return 0;
816 static struct led_info stargate2_leds[] = {
818 .name = "sg2:red",
819 .flags = DA9030_LED_RATE_ON,
820 }, {
821 .name = "sg2:blue",
822 .flags = DA9030_LED_RATE_ON,
823 }, {
824 .name = "sg2:green",
825 .flags = DA9030_LED_RATE_ON,
829 static struct da903x_subdev_info stargate2_da9030_subdevs[] = {
831 .name = "da903x-led",
832 .id = DA9030_ID_LED_2,
833 .platform_data = &stargate2_leds[0],
834 }, {
835 .name = "da903x-led",
836 .id = DA9030_ID_LED_3,
837 .platform_data = &stargate2_leds[2],
838 }, {
839 .name = "da903x-led",
840 .id = DA9030_ID_LED_4,
841 .platform_data = &stargate2_leds[1],
842 }, {
843 .name = "da903x-regulator",
844 .id = DA9030_ID_LDO2,
845 .platform_data = &stargate2_ldo_init_data[vcc_bbio],
846 }, {
847 .name = "da903x-regulator",
848 .id = DA9030_ID_LDO3,
849 .platform_data = &stargate2_ldo_init_data[vcc_bb],
850 }, {
851 .name = "da903x-regulator",
852 .id = DA9030_ID_LDO4,
853 .platform_data = &stargate2_ldo_init_data[vcc_pxa_flash],
854 }, {
855 .name = "da903x-regulator",
856 .id = DA9030_ID_LDO5,
857 .platform_data = &stargate2_ldo_init_data[vcc_cc2420],
858 }, {
859 .name = "da903x-regulator",
860 .id = DA9030_ID_LDO6,
861 .platform_data = &stargate2_ldo_init_data[vcc_vref],
862 }, {
863 .name = "da903x-regulator",
864 .id = DA9030_ID_LDO7,
865 .platform_data = &stargate2_ldo_init_data[vcc_sram_ext],
866 }, {
867 .name = "da903x-regulator",
868 .id = DA9030_ID_LDO8,
869 .platform_data = &stargate2_ldo_init_data[vcc_mica],
870 }, {
871 .name = "da903x-regulator",
872 .id = DA9030_ID_LDO9,
873 .platform_data = &stargate2_ldo_init_data[vcc_bt],
874 }, {
875 .name = "da903x-regulator",
876 .id = DA9030_ID_LDO10,
877 .platform_data = &stargate2_ldo_init_data[vcc_sensor_1_8],
878 }, {
879 .name = "da903x-regulator",
880 .id = DA9030_ID_LDO11,
881 .platform_data = &stargate2_ldo_init_data[vcc_sensor_3],
882 }, {
883 .name = "da903x-regulator",
884 .id = DA9030_ID_LDO12,
885 .platform_data = &stargate2_ldo_init_data[vcc_lcd],
886 }, {
887 .name = "da903x-regulator",
888 .id = DA9030_ID_LDO15,
889 .platform_data = &stargate2_ldo_init_data[vcc_pxa_pll],
890 }, {
891 .name = "da903x-regulator",
892 .id = DA9030_ID_LDO17,
893 .platform_data = &stargate2_ldo_init_data[vcc_pxa_usim],
894 }, {
895 .name = "da903x-regulator", /*pxa vcc i/o and cc2420 vcc i/o */
896 .id = DA9030_ID_LDO18,
897 .platform_data = &stargate2_ldo_init_data[vcc_io],
898 }, {
899 .name = "da903x-regulator",
900 .id = DA9030_ID_LDO19,
901 .platform_data = &stargate2_ldo_init_data[vcc_pxa_mem],
905 static struct da903x_platform_data stargate2_da9030_pdata = {
906 .num_subdevs = ARRAY_SIZE(stargate2_da9030_subdevs),
907 .subdevs = stargate2_da9030_subdevs,
910 static struct i2c_board_info __initdata stargate2_pwr_i2c_board_info[] = {
912 .type = "da9030",
913 .addr = 0x49,
914 .platform_data = &stargate2_da9030_pdata,
915 .irq = gpio_to_irq(1),
919 static struct i2c_board_info __initdata stargate2_i2c_board_info[] = {
920 /* Techically this a pca9500 - but it's compatible with the 8574
921 * for gpio expansion and the 24c02 for eeprom access.
924 .type = "pcf8574",
925 .addr = 0x27,
926 .platform_data = &platform_data_pcf857x,
927 }, {
928 .type = "24c02",
929 .addr = 0x57,
930 .platform_data = &pca9500_eeprom_pdata,
931 }, {
932 .type = "max1238",
933 .addr = 0x35,
934 }, { /* ITS400 Sensor board only */
935 .type = "max1363",
936 .addr = 0x34,
937 /* Through a nand gate - Also beware, on V2 sensor board the
938 * pull up resistors are missing.
940 .irq = IRQ_GPIO(99),
941 }, { /* ITS400 Sensor board only */
942 .type = "tsl2561",
943 .addr = 0x49,
944 /* Through a nand gate - Also beware, on V2 sensor board the
945 * pull up resistors are missing.
947 .irq = IRQ_GPIO(99),
948 }, { /* ITS400 Sensor board only */
949 .type = "tmp175",
950 .addr = 0x4A,
951 .irq = IRQ_GPIO(96),
955 /* Board doesn't support cable detection - so always lie and say
956 * something is there.
958 static int sg2_udc_detect(void)
960 return 1;
963 static struct pxa2xx_udc_mach_info stargate2_udc_info __initdata = {
964 .udc_is_connected = sg2_udc_detect,
965 .udc_command = sg2_udc_command,
968 static struct platform_device *stargate2_devices[] = {
969 &stargate2_flash_device,
970 &stargate2_sram,
971 &smc91x_device,
972 &sht15,
975 static void __init stargate2_init(void)
977 /* This is probably a board specific hack as this must be set
978 prior to connecting the MFP stuff up. */
979 MECR &= ~MECR_NOS;
981 pxa2xx_mfp_config(ARRAY_AND_SIZE(stargate2_pin_config));
983 imote2_stargate2_init();
985 platform_add_devices(ARRAY_AND_SIZE(stargate2_devices));
987 i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info));
988 i2c_register_board_info(1, stargate2_pwr_i2c_board_info,
989 ARRAY_SIZE(stargate2_pwr_i2c_board_info));
991 pxa_set_mci_info(&stargate2_mci_platform_data);
993 pxa_set_udc_info(&stargate2_udc_info);
995 stargate2_reset_bluetooth();
997 #endif
999 #ifdef CONFIG_MACH_INTELMOTE2
1000 MACHINE_START(INTELMOTE2, "IMOTE 2")
1001 .map_io = pxa_map_io,
1002 .init_irq = pxa27x_init_irq,
1003 .timer = &pxa_timer,
1004 .init_machine = imote2_init,
1005 .boot_params = 0xA0000100,
1006 MACHINE_END
1007 #endif
1009 #ifdef CONFIG_MACH_STARGATE2
1010 MACHINE_START(STARGATE2, "Stargate 2")
1011 .map_io = pxa_map_io,
1012 .nr_irqs = STARGATE_NR_IRQS,
1013 .init_irq = pxa27x_init_irq,
1014 .timer = &pxa_timer,
1015 .init_machine = stargate2_init,
1016 .boot_params = 0xA0000100,
1017 MACHINE_END
1018 #endif