2 * linux/arch/arm/mach-pxa/stargate2.c
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>
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>
33 #include <asm/types.h>
34 #include <asm/setup.h>
35 #include <asm/memory.h>
36 #include <asm/mach-types.h>
39 #include <asm/mach/arch.h>
40 #include <asm/mach/map.h>
41 #include <asm/mach/irq.h>
42 #include <asm/mach/flash.h>
44 #include <mach/pxa27x.h>
48 #include <mach/pxa2xx_spi.h>
49 #include <mach/pxa27x-udc.h>
51 #include <linux/spi/spi.h>
52 #include <linux/mfd/da903x.h>
53 #include <linux/sht15.h>
59 #define SG2_BT_RESET 81
62 #define SG2_GPIO_nSD_DETECT 90
63 #define SG2_SD_POWER_ENABLE 89
65 static unsigned long stargate2_pin_config
[] __initdata
= {
67 GPIO15_nCS_1
, /* SRAM */
70 GPIO40_GPIO
, /*cable detect?*/
71 /* Device Identification for wakeup*/
75 GPIO91_GPIO
| WAKEUP_ON_LEVEL_HIGH
,
91 GPIO120_GPIO
, /* Buff ctrl */
92 GPIO108_GPIO
, /* Power ctrl */
93 GPIO82_GPIO
, /* Reset */
94 GPIO53_GPIO
, /* SG2_S0_GPIO_DETECT */
103 GPIO90_GPIO
, /* nSD detect */
104 GPIO89_GPIO
, /* SD_POWER_ENABLE */
107 GPIO81_GPIO
, /* reset */
109 /* cc2420 802.15.4 radio */
110 GPIO22_GPIO
, /* CC_RSTN (out)*/
111 GPIO114_GPIO
, /* CC_FIFO (in) */
112 GPIO116_GPIO
, /* CC_CCA (in) */
113 GPIO0_GPIO
, /* CC_FIFOP (in) */
114 GPIO16_GPIO
, /* CCSFD (in) */
115 GPIO39_GPIO
, /* CSn (out) */
121 /* SSP 3 - 802.15.4 radio */
122 GPIO39_GPIO
, /* chip select */
131 GPIO37_GPIO
, /* chip select */
137 GPIO24_GPIO
, /* chip select */
149 /* Basic sensor board */
150 GPIO96_GPIO
, /* accelerometer interrupt */
151 GPIO99_GPIO
, /* ADC interrupt */
153 /* Connector pins specified as gpios */
154 GPIO94_GPIO
, /* large basic connector pin 14 */
155 GPIO10_GPIO
, /* large basic connector pin 23 */
163 * stargate2_reset_bluetooth() reset the bluecore to ensure consistent state
165 static int stargate2_reset_bluetooth(void)
168 err
= gpio_request(SG2_BT_RESET
, "SG2_BT_RESET");
170 printk(KERN_ERR
"Could not get gpio for bluetooth reset \n");
173 gpio_direction_output(SG2_BT_RESET
, 1);
175 /* now reset it - 5 msec minimum */
176 gpio_set_value(SG2_BT_RESET
, 0);
178 gpio_set_value(SG2_BT_RESET
, 1);
179 gpio_free(SG2_BT_RESET
);
183 static struct led_info stargate2_leds
[] = {
186 .flags
= DA9030_LED_RATE_ON
,
189 .flags
= DA9030_LED_RATE_ON
,
192 .flags
= DA9030_LED_RATE_ON
,
196 static struct sht15_platform_data platform_data_sht15
= {
201 static struct platform_device sht15
= {
205 .platform_data
= &platform_data_sht15
,
209 static struct regulator_consumer_supply stargate2_sensor_3_con
[] = {
219 /* a mote connector? */
221 /* the CSR bluecore chip */
223 /* The two voltages available to sensor boards */
226 /* directly connected to the pxa27x */
229 vcc_pxa_usim
, /* Reference voltage for certain gpios */
232 vcc_pxa_core
, /*Dc-Dc buck not yet supported */
235 vcc_bbio
, /*not sure!*/
236 vcc_io
, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
239 /* The values of the various regulator constraints are obviously dependent
240 * on exactly what is wired to each ldo. Unfortunately this information is
241 * not generally available. More information has been requested from Xbow.
243 static struct regulator_init_data stargate2_ldo_init_data
[] = {
245 .constraints
= { /* board default 1.8V */
252 .constraints
= { /* board default 2.8V */
259 .constraints
= {/* default is 1.8V */
260 .name
= "vcc_pxa_flash",
265 [vcc_cc2420
] = { /* also vcc_io */
267 /* board default is 2.8V */
268 .name
= "vcc_cc2420",
273 [vcc_vref
] = { /* Reference for what? */
274 .constraints
= { /* default 1.8V */
281 .constraints
= { /* default 2.8V */
282 .name
= "vcc_sram_ext",
288 .constraints
= { /* default 2.8V */
295 .constraints
= { /* default 2.8V */
302 .constraints
= { /* default 2.8V */
308 [vcc_io
] = { /* Same or higher than everything
309 * bar vccbat and vccusb */
310 .constraints
= { /* default 2.8V */
317 .constraints
= { /* default 1.8V */
318 .name
= "vcc_sensor_1_8",
323 [vcc_sensor_3
] = { /* curiously default 2.8V */
325 .name
= "vcc_sensor_3",
329 .num_consumer_supplies
= ARRAY_SIZE(stargate2_sensor_3_con
),
330 .consumer_supplies
= stargate2_sensor_3_con
,
332 [vcc_pxa_pll
] = { /* 1.17V - 1.43V, default 1.3V*/
334 .name
= "vcc_pxa_pll",
340 .constraints
= { /* default 1.8V */
341 .name
= "vcc_pxa_usim",
347 .constraints
= { /* default 1.8V */
348 .name
= "vcc_pxa_mem",
355 static struct da903x_subdev_info stargate2_da9030_subdevs
[] = {
357 .name
= "da903x-led",
358 .id
= DA9030_ID_LED_2
,
359 .platform_data
= &stargate2_leds
[0],
361 .name
= "da903x-led",
362 .id
= DA9030_ID_LED_3
,
363 .platform_data
= &stargate2_leds
[2],
365 .name
= "da903x-led",
366 .id
= DA9030_ID_LED_4
,
367 .platform_data
= &stargate2_leds
[1],
369 .name
= "da903x-regulator",
370 .id
= DA9030_ID_LDO2
,
371 .platform_data
= &stargate2_ldo_init_data
[vcc_bbio
],
373 .name
= "da903x-regulator",
374 .id
= DA9030_ID_LDO3
,
375 .platform_data
= &stargate2_ldo_init_data
[vcc_bb
],
377 .name
= "da903x-regulator",
378 .id
= DA9030_ID_LDO4
,
379 .platform_data
= &stargate2_ldo_init_data
[vcc_pxa_flash
],
381 .name
= "da903x-regulator",
382 .id
= DA9030_ID_LDO5
,
383 .platform_data
= &stargate2_ldo_init_data
[vcc_cc2420
],
385 .name
= "da903x-regulator",
386 .id
= DA9030_ID_LDO6
,
387 .platform_data
= &stargate2_ldo_init_data
[vcc_vref
],
389 .name
= "da903x-regulator",
390 .id
= DA9030_ID_LDO7
,
391 .platform_data
= &stargate2_ldo_init_data
[vcc_sram_ext
],
393 .name
= "da903x-regulator",
394 .id
= DA9030_ID_LDO8
,
395 .platform_data
= &stargate2_ldo_init_data
[vcc_mica
],
397 .name
= "da903x-regulator",
398 .id
= DA9030_ID_LDO9
,
399 .platform_data
= &stargate2_ldo_init_data
[vcc_bt
],
401 .name
= "da903x-regulator",
402 .id
= DA9030_ID_LDO10
,
403 .platform_data
= &stargate2_ldo_init_data
[vcc_sensor_1_8
],
405 .name
= "da903x-regulator",
406 .id
= DA9030_ID_LDO11
,
407 .platform_data
= &stargate2_ldo_init_data
[vcc_sensor_3
],
409 .name
= "da903x-regulator",
410 .id
= DA9030_ID_LDO12
,
411 .platform_data
= &stargate2_ldo_init_data
[vcc_lcd
],
413 .name
= "da903x-regulator",
414 .id
= DA9030_ID_LDO15
,
415 .platform_data
= &stargate2_ldo_init_data
[vcc_pxa_pll
],
417 .name
= "da903x-regulator",
418 .id
= DA9030_ID_LDO17
,
419 .platform_data
= &stargate2_ldo_init_data
[vcc_pxa_usim
],
421 .name
= "da903x-regulator", /*pxa vcc i/o and cc2420 vcc i/o */
422 .id
= DA9030_ID_LDO18
,
423 .platform_data
= &stargate2_ldo_init_data
[vcc_io
],
425 .name
= "da903x-regulator",
426 .id
= DA9030_ID_LDO19
,
427 .platform_data
= &stargate2_ldo_init_data
[vcc_pxa_mem
],
431 static struct da903x_platform_data stargate2_da9030_pdata
= {
432 .num_subdevs
= ARRAY_SIZE(stargate2_da9030_subdevs
),
433 .subdevs
= stargate2_da9030_subdevs
,
436 static struct resource smc91x_resources
[] = {
438 .name
= "smc91x-regs",
439 .start
= (PXA_CS4_PHYS
+ 0x300),
440 .end
= (PXA_CS4_PHYS
+ 0xfffff),
441 .flags
= IORESOURCE_MEM
,
444 .start
= IRQ_GPIO(40),
446 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
450 static struct smc91x_platdata stargate2_smc91x_info
= {
451 .flags
= SMC91X_USE_8BIT
| SMC91X_USE_16BIT
| SMC91X_USE_32BIT
452 | SMC91X_NOWAIT
| SMC91X_USE_DMA
,
455 static struct platform_device smc91x_device
= {
458 .num_resources
= ARRAY_SIZE(smc91x_resources
),
459 .resource
= smc91x_resources
,
461 .platform_data
= &stargate2_smc91x_info
,
468 * The card detect interrupt isn't debounced so we delay it by 250ms
469 * to give the card a chance to fully insert / eject.
471 static int stargate2_mci_init(struct device
*dev
,
472 irq_handler_t stargate2_detect_int
,
477 err
= gpio_request(SG2_SD_POWER_ENABLE
, "SG2_sd_power_enable");
479 printk(KERN_ERR
"Can't get the gpio for SD power control");
482 gpio_direction_output(SG2_SD_POWER_ENABLE
, 0);
484 err
= gpio_request(SG2_GPIO_nSD_DETECT
, "SG2_sd_detect");
486 printk(KERN_ERR
"Can't get the sd detect gpio");
489 gpio_direction_input(SG2_GPIO_nSD_DETECT
);
491 err
= request_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT
),
492 stargate2_detect_int
,
497 printk(KERN_ERR
"can't request MMC card detect IRQ\n");
498 goto free_nsd_detect
;
503 gpio_free(SG2_GPIO_nSD_DETECT
);
505 gpio_free(SG2_SD_POWER_ENABLE
);
511 * stargate2_mci_setpower() - set state of mmc power supply
513 * Very simple control. Either it is on or off and is controlled by
515 static void stargate2_mci_setpower(struct device
*dev
, unsigned int vdd
)
517 gpio_set_value(SG2_SD_POWER_ENABLE
, !!vdd
);
520 static void stargate2_mci_exit(struct device
*dev
, void *data
)
522 free_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT
), data
);
523 gpio_free(SG2_SD_POWER_ENABLE
);
524 gpio_free(SG2_GPIO_nSD_DETECT
);
527 static struct pxamci_platform_data stargate2_mci_platform_data
= {
528 .detect_delay_ms
= 250,
529 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
530 .init
= stargate2_mci_init
,
531 .setpower
= stargate2_mci_setpower
,
532 .exit
= stargate2_mci_exit
,
535 static struct mtd_partition stargate2flash_partitions
[] = {
537 .name
= "Bootloader",
544 .offset
= 0x00040000,
547 .name
= "Filesystem",
549 .offset
= 0x00240000,
554 static struct resource flash_resources
= {
555 .start
= PXA_CS0_PHYS
,
556 .end
= PXA_CS0_PHYS
+ SZ_32M
- 1,
557 .flags
= IORESOURCE_MEM
,
560 static struct flash_platform_data stargate2_flash_data
= {
561 .map_name
= "cfi_probe",
562 .parts
= stargate2flash_partitions
,
563 .nr_parts
= ARRAY_SIZE(stargate2flash_partitions
),
564 .name
= "PXA27xOnChipROM",
568 static struct platform_device stargate2_flash_device
= {
569 .name
= "pxa2xx-flash",
572 .platform_data
= &stargate2_flash_data
,
574 .resource
= &flash_resources
,
579 * SRAM - The Stargate 2 has 32MB of SRAM.
581 * Here it is made available as an MTD. This will then
582 * typically have a cifs filesystem created on it to provide
583 * fast temporary storage.
585 static struct resource sram_resources
= {
586 .start
= PXA_CS1_PHYS
,
587 .end
= PXA_CS1_PHYS
+ SZ_32M
-1,
588 .flags
= IORESOURCE_MEM
,
591 static struct platdata_mtd_ram stargate2_sram_pdata
= {
592 .mapname
= "Stargate2 SRAM",
596 static struct platform_device stargate2_sram
= {
599 .resource
= &sram_resources
,
602 .platform_data
= &stargate2_sram_pdata
,
606 static struct pcf857x_platform_data platform_data_pcf857x
= {
614 static struct at24_platform_data pca9500_eeprom_pdata
= {
620 static struct i2c_board_info __initdata stargate2_i2c_board_info
[] = {
621 /* Techically this a pca9500 - but it's compatible with the 8574
622 * for gpio expansion and the 24c02 for eeprom access.
627 .platform_data
= &platform_data_pcf857x
,
631 .platform_data
= &pca9500_eeprom_pdata
,
635 }, { /* ITS400 Sensor board only */
638 /* Through a nand gate - Also beware, on V2 sensor board the
639 * pull up resistors are missing.
642 }, { /* ITS400 Sensor board only */
645 /* Through a nand gate - Also beware, on V2 sensor board the
646 * pull up resistors are missing.
649 }, { /* ITS400 Sensor board only */
656 static struct i2c_board_info __initdata stargate2_pwr_i2c_board_info
[] = {
660 .platform_data
= &stargate2_da9030_pdata
,
661 .irq
= gpio_to_irq(1),
665 static struct pxa2xx_spi_master pxa_ssp_master_0_info
= {
669 static struct pxa2xx_spi_master pxa_ssp_master_1_info
= {
673 static struct pxa2xx_spi_master pxa_ssp_master_2_info
= {
677 /* An upcoming kernel change will scrap SFRM usage so these
678 * drivers have been moved to use gpio's via cs_control */
679 static struct pxa2xx_spi_chip staccel_chip_info
= {
687 static struct pxa2xx_spi_chip cc2420_info
= {
695 static struct spi_board_info spi_board_info
[] __initdata
= {
697 .modalias
= "lis3l02dq",
698 .max_speed_hz
= 8000000,/* 8MHz max spi frequency at 3V */
701 .controller_data
= &staccel_chip_info
,
704 .modalias
= "cc2420",
705 .max_speed_hz
= 6500000,
708 .controller_data
= &cc2420_info
,
712 static void sg2_udc_command(int cmd
)
715 case PXA2XX_UDC_CMD_CONNECT
:
716 UP2OCR
|= UP2OCR_HXOE
| UP2OCR_DPPUE
| UP2OCR_DPPUBE
;
718 case PXA2XX_UDC_CMD_DISCONNECT
:
719 UP2OCR
&= ~(UP2OCR_HXOE
| UP2OCR_DPPUE
| UP2OCR_DPPUBE
);
724 /* Board doesn't support cable detection - so always lie and say
725 * something is there.
727 static int sg2_udc_detect(void)
732 static struct pxa2xx_udc_mach_info stargate2_udc_info __initdata
= {
733 .udc_is_connected
= sg2_udc_detect
,
734 .udc_command
= sg2_udc_command
,
737 static struct platform_device
*stargate2_devices
[] = {
738 &stargate2_flash_device
,
744 static struct i2c_pxa_platform_data i2c_pwr_pdata
= {
748 static struct i2c_pxa_platform_data i2c_pdata
= {
752 static void __init
stargate2_init(void)
754 /* This is probably a board specific hack as this must be set
755 prior to connecting the MFP stuff up. */
758 pxa2xx_mfp_config(ARRAY_AND_SIZE(stargate2_pin_config
));
760 pxa_set_ffuart_info(NULL
);
761 pxa_set_btuart_info(NULL
);
762 pxa_set_stuart_info(NULL
);
764 platform_add_devices(ARRAY_AND_SIZE(stargate2_devices
));
766 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info
);
767 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info
);
768 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info
);
769 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
771 i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info
));
772 i2c_register_board_info(1,
773 ARRAY_AND_SIZE(stargate2_pwr_i2c_board_info
));
774 pxa27x_set_i2c_power_info(&i2c_pwr_pdata
);
775 pxa_set_i2c_info(&i2c_pdata
);
777 pxa_set_mci_info(&stargate2_mci_platform_data
);
779 pxa_set_udc_info(&stargate2_udc_info
);
781 stargate2_reset_bluetooth();
784 MACHINE_START(STARGATE2
, "Stargate 2")
785 .phys_io
= 0x40000000,
786 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
787 .map_io
= pxa_map_io
,
788 .init_irq
= pxa27x_init_irq
,
790 .init_machine
= stargate2_init
,
791 .boot_params
= 0xA0000100,