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,
467 static struct pxamci_platform_data stargate2_mci_platform_data;
470 * The card detect interrupt isn't debounced so we delay it by 250ms
471 * to give the card a chance to fully insert / eject.
473 static int stargate2_mci_init(struct device *dev,
474 irq_handler_t stargate2_detect_int,
479 err = gpio_request(SG2_SD_POWER_ENABLE, "SG2_sd_power_enable");
481 printk(KERN_ERR "Can't get the gpio for SD power control");
484 gpio_direction_output(SG2_SD_POWER_ENABLE, 0);
486 err = gpio_request(SG2_GPIO_nSD_DETECT, "SG2_sd_detect");
488 printk(KERN_ERR "Can't get the sd detect gpio");
491 gpio_direction_input(SG2_GPIO_nSD_DETECT);
492 /* Delay to allow for full insertion */
493 stargate2_mci_platform_data.detect_delay = msecs_to_jiffies(250);
495 err = request_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT),
496 stargate2_detect_int,
501 printk(KERN_ERR "can't request MMC card detect IRQ\n");
502 goto free_nsd_detect;
507 gpio_free(SG2_GPIO_nSD_DETECT);
509 gpio_free(SG2_SD_POWER_ENABLE);
515 * stargate2_mci_setpower() - set state of mmc power supply
517 * Very simple control. Either it is on or off and is controlled by
519 static void stargate2_mci_setpower(struct device *dev, unsigned int vdd)
521 gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd);
524 static void stargate2_mci_exit(struct device *dev, void *data)
526 free_irq(IRQ_GPIO(SG2_GPIO_nSD_DETECT), data);
527 gpio_free(SG2_SD_POWER_ENABLE);
528 gpio_free(SG2_GPIO_nSD_DETECT);
531 static struct pxamci_platform_data stargate2_mci_platform_data = {
532 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
533 .init = stargate2_mci_init,
534 .setpower = stargate2_mci_setpower,
535 .exit = stargate2_mci_exit,
538 static struct mtd_partition stargate2flash_partitions[] = {
540 .name = "Bootloader",
547 .offset = 0x00040000,
550 .name = "Filesystem",
552 .offset = 0x00240000,
557 static struct resource flash_resources = {
558 .start = PXA_CS0_PHYS,
559 .end = PXA_CS0_PHYS + SZ_32M - 1,
560 .flags = IORESOURCE_MEM,
563 static struct flash_platform_data stargate2_flash_data = {
564 .map_name = "cfi_probe",
565 .parts = stargate2flash_partitions,
566 .nr_parts = ARRAY_SIZE(stargate2flash_partitions),
567 .name = "PXA27xOnChipROM",
571 static struct platform_device stargate2_flash_device = {
572 .name = "pxa2xx-flash",
575 .platform_data = &stargate2_flash_data,
577 .resource = &flash_resources,
582 * SRAM - The Stargate 2 has 32MB of SRAM.
584 * Here it is made available as an MTD. This will then
585 * typically have a cifs filesystem created on it to provide
586 * fast temporary storage.
588 static struct resource sram_resources = {
589 .start = PXA_CS1_PHYS,
590 .end = PXA_CS1_PHYS + SZ_32M-1,
591 .flags = IORESOURCE_MEM,
594 static struct platdata_mtd_ram stargate2_sram_pdata = {
595 .mapname = "Stargate2 SRAM",
599 static struct platform_device stargate2_sram = {
602 .resource = &sram_resources,
605 .platform_data = &stargate2_sram_pdata,
609 static struct pcf857x_platform_data platform_data_pcf857x = {
617 static struct at24_platform_data pca9500_eeprom_pdata = {
623 static struct i2c_board_info __initdata stargate2_i2c_board_info[] = {
624 /* Techically this a pca9500 - but it's compatible with the 8574
625 * for gpio expansion and the 24c02 for eeprom access.
630 .platform_data = &platform_data_pcf857x,
634 .platform_data = &pca9500_eeprom_pdata,
638 }, { /* ITS400 Sensor board only */
641 /* Through a nand gate - Also beware, on V2 sensor board the
642 * pull up resistors are missing.
645 }, { /* ITS400 Sensor board only */
648 /* Through a nand gate - Also beware, on V2 sensor board the
649 * pull up resistors are missing.
652 }, { /* ITS400 Sensor board only */
659 static struct i2c_board_info __initdata stargate2_pwr_i2c_board_info[] = {
663 .platform_data = &stargate2_da9030_pdata,
664 .irq = gpio_to_irq(1),
668 static struct pxa2xx_spi_master pxa_ssp_master_0_info = {
672 static struct pxa2xx_spi_master pxa_ssp_master_1_info = {
676 static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
680 /* An upcoming kernel change will scrap SFRM usage so these
681 * drivers have been moved to use gpio's via cs_control */
682 static struct pxa2xx_spi_chip staccel_chip_info = {
690 static struct pxa2xx_spi_chip cc2420_info = {
698 static struct spi_board_info spi_board_info[] __initdata = {
700 .modalias = "lis3l02dq",
701 .max_speed_hz = 8000000,/* 8MHz max spi frequency at 3V */
704 .controller_data = &staccel_chip_info,
707 .modalias = "cc2420",
708 .max_speed_hz = 6500000,
711 .controller_data = &cc2420_info,
715 static void sg2_udc_command(int cmd)
718 case PXA2XX_UDC_CMD_CONNECT:
719 UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
721 case PXA2XX_UDC_CMD_DISCONNECT:
722 UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
727 /* Board doesn't support cable detection - so always lie and say
728 * something is there.
730 static int sg2_udc_detect(void)
735 static struct pxa2xx_udc_mach_info stargate2_udc_info __initdata = {
736 .udc_is_connected = sg2_udc_detect,
737 .udc_command = sg2_udc_command,
740 static struct platform_device *stargate2_devices[] = {
741 &stargate2_flash_device,
747 static struct i2c_pxa_platform_data i2c_pwr_pdata = {
751 static struct i2c_pxa_platform_data i2c_pdata = {
755 static void __init stargate2_init(void)
757 /* This is probably a board specific hack as this must be set
758 prior to connecting the MFP stuff up. */
761 pxa2xx_mfp_config(ARRAY_AND_SIZE(stargate2_pin_config));
763 pxa_set_ffuart_info(NULL);
764 pxa_set_btuart_info(NULL);
765 pxa_set_stuart_info(NULL);
767 /* spi chip selects */
768 gpio_direction_output(37, 0);
769 gpio_direction_output(24, 0);
770 gpio_direction_output(39, 0);
772 platform_add_devices(ARRAY_AND_SIZE(stargate2_devices));
774 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
775 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info);
776 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info);
777 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
779 i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info));
780 i2c_register_board_info(1,
781 ARRAY_AND_SIZE(stargate2_pwr_i2c_board_info));
782 pxa27x_set_i2c_power_info(&i2c_pwr_pdata);
783 pxa_set_i2c_info(&i2c_pdata);
785 pxa_set_mci_info(&stargate2_mci_platform_data);
787 pxa_set_udc_info(&stargate2_udc_info);
789 stargate2_reset_bluetooth();
792 MACHINE_START(STARGATE2, "Stargate 2")
793 .phys_io = 0x40000000,
794 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
795 .map_io = pxa_map_io,
796 .init_irq = pxa27x_init_irq,
798 .init_machine = stargate2_init,
799 .boot_params = 0xA0000100,