2 * linux/arch/arm/mach-pxa/imote2.c
5 * Created: Nov 05, 2002
6 * Copyright: Intel Corp.
8 * Modified 2008: Jonathan Cameron
10 * The Imote2 is a wireless sensor node platform sold
11 * by Crossbow (www.xbow.com).
14 #include <linux/init.h>
15 #include <linux/device.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/platform_device.h>
19 #include <linux/regulator/machine.h>
20 #include <linux/gpio.h>
21 #include <linux/leds.h>
22 #include <linux/spi/spi.h>
23 #include <linux/i2c.h>
24 #include <linux/mfd/da903x.h>
25 #include <linux/sht15.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/flash.h>
32 #include <mach/pxa27x.h>
36 #include <mach/pxa2xx_spi.h>
37 #include <mach/pxa27x-udc.h>
42 static unsigned long imote2_pin_config[] __initdata = {
44 /* Device Identification for wakeup*/
61 /* 802.15.4 radio - driver out of mainline */
62 GPIO22_GPIO, /* CC_RSTN */
63 GPIO114_GPIO, /* CC_FIFO */
64 GPIO116_GPIO, /* CC_CCA */
65 GPIO0_GPIO, /* CC_FIFOP */
66 GPIO16_GPIO, /* CCSFD */
67 GPIO115_GPIO, /* Power enable */
73 /* SSP 3 - 802.15.4 radio */
74 GPIO39_GPIO, /* Chip Select */
79 /* SSP 2 - to daughter boards */
80 GPIO37_GPIO, /* Chip Select */
85 /* SSP 1 - to daughter boards */
86 GPIO24_GPIO, /* Chip Select */
91 /* BTUART Basic Connector*/
97 /* STUART Serial console via debug board*/
101 /* Basic sensor board */
102 GPIO96_GPIO, /* accelerometer interrupt */
103 GPIO99_GPIO, /* ADC interrupt */
109 /* Connector pins specified as gpios */
110 GPIO94_GPIO, /* large basic connector pin 14 */
111 GPIO10_GPIO, /* large basic connector pin 23 */
114 GPIO103_GPIO, /* red led */
115 GPIO104_GPIO, /* green led */
116 GPIO105_GPIO, /* blue led */
119 static struct sht15_platform_data platform_data_sht15 = {
124 static struct platform_device sht15 = {
128 .platform_data = &platform_data_sht15,
132 static struct regulator_consumer_supply imote2_sensor_3_con[] = {
139 static struct gpio_led imote2_led_pins[] = {
141 .name = "imote2:red",
145 .name = "imote2:green",
149 .name = "imote2:blue",
155 static struct gpio_led_platform_data imote2_led_data = {
156 .num_leds = ARRAY_SIZE(imote2_led_pins),
157 .leds = imote2_led_pins,
160 static struct platform_device imote2_leds = {
164 .platform_data = &imote2_led_data,
168 /* Reverse engineered partly from Platformx drivers */
174 /* The two voltages available to sensor boards */
178 vcc_sram_ext, /* directly connected to the pxa271 */
180 vcc_pxa_usim, /* Reference voltage for certain gpios */
183 vcc_pxa_core, /*Dc-Dc buck not yet supported */
187 vcc_io, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
190 /* The values of the various regulator constraints are obviously dependent
191 * on exactly what is wired to each ldo. Unfortunately this information is
192 * not generally available. More information has been requested from Xbow
193 * but as of yet they haven't been forthcoming.
195 * Some of these are clearly Stargate 2 related (no way of plugging
196 * in an lcd on the IM2 for example!).
198 static struct regulator_init_data imote2_ldo_init_data[] = {
200 .constraints = { /* board default 1.8V */
207 .constraints = { /* board default 2.8V */
214 .constraints = {/* default is 1.8V */
215 .name = "vcc_pxa_flash",
220 [vcc_cc2420] = { /* also vcc_io */
222 /* board default is 2.8V */
223 .name = "vcc_cc2420",
228 [vcc_vref] = { /* Reference for what? */
229 .constraints = { /* default 1.8V */
236 .constraints = { /* default 2.8V */
237 .name = "vcc_sram_ext",
243 .constraints = { /* default 2.8V */
250 .constraints = { /* default 2.8V */
257 .constraints = { /* default 2.8V */
263 [vcc_io] = { /* Same or higher than everything
264 * bar vccbat and vccusb */
265 .constraints = { /* default 2.8V */
272 .constraints = { /* default 1.8V */
273 .name = "vcc_sensor_1_8",
278 [vcc_sensor_3] = { /* curiously default 2.8V */
280 .name = "vcc_sensor_3",
284 .num_consumer_supplies = ARRAY_SIZE(imote2_sensor_3_con),
285 .consumer_supplies = imote2_sensor_3_con,
287 [vcc_pxa_pll] = { /* 1.17V - 1.43V, default 1.3V*/
289 .name = "vcc_pxa_pll",
295 .constraints = { /* default 1.8V */
296 .name = "vcc_pxa_usim",
302 .constraints = { /* default 1.8V */
303 .name = "vcc_pxa_mem",
310 static struct da903x_subdev_info imote2_da9030_subdevs[] = {
312 .name = "da903x-regulator",
313 .id = DA9030_ID_LDO2,
314 .platform_data = &imote2_ldo_init_data[vcc_bbio],
316 .name = "da903x-regulator",
317 .id = DA9030_ID_LDO3,
318 .platform_data = &imote2_ldo_init_data[vcc_bb],
320 .name = "da903x-regulator",
321 .id = DA9030_ID_LDO4,
322 .platform_data = &imote2_ldo_init_data[vcc_pxa_flash],
324 .name = "da903x-regulator",
325 .id = DA9030_ID_LDO5,
326 .platform_data = &imote2_ldo_init_data[vcc_cc2420],
328 .name = "da903x-regulator",
329 .id = DA9030_ID_LDO6,
330 .platform_data = &imote2_ldo_init_data[vcc_vref],
332 .name = "da903x-regulator",
333 .id = DA9030_ID_LDO7,
334 .platform_data = &imote2_ldo_init_data[vcc_sram_ext],
336 .name = "da903x-regulator",
337 .id = DA9030_ID_LDO8,
338 .platform_data = &imote2_ldo_init_data[vcc_mica],
340 .name = "da903x-regulator",
341 .id = DA9030_ID_LDO9,
342 .platform_data = &imote2_ldo_init_data[vcc_bt],
344 .name = "da903x-regulator",
345 .id = DA9030_ID_LDO10,
346 .platform_data = &imote2_ldo_init_data[vcc_sensor_1_8],
348 .name = "da903x-regulator",
349 .id = DA9030_ID_LDO11,
350 .platform_data = &imote2_ldo_init_data[vcc_sensor_3],
352 .name = "da903x-regulator",
353 .id = DA9030_ID_LDO12,
354 .platform_data = &imote2_ldo_init_data[vcc_lcd],
356 .name = "da903x-regulator",
357 .id = DA9030_ID_LDO15,
358 .platform_data = &imote2_ldo_init_data[vcc_pxa_pll],
360 .name = "da903x-regulator",
361 .id = DA9030_ID_LDO17,
362 .platform_data = &imote2_ldo_init_data[vcc_pxa_usim],
364 .name = "da903x-regulator",
365 .id = DA9030_ID_LDO18,
366 .platform_data = &imote2_ldo_init_data[vcc_io],
368 .name = "da903x-regulator",
369 .id = DA9030_ID_LDO19,
370 .platform_data = &imote2_ldo_init_data[vcc_pxa_mem],
374 static struct da903x_platform_data imote2_da9030_pdata = {
375 .num_subdevs = ARRAY_SIZE(imote2_da9030_subdevs),
376 .subdevs = imote2_da9030_subdevs,
379 /* As the the imote2 doesn't currently have a conventional SD slot
380 * there is no option to hotplug cards, making all this rather simple
382 static int imote2_mci_get_ro(struct device *dev)
387 /* Rather simple case as hotplugging not possible */
388 static struct pxamci_platform_data imote2_mci_platform_data = {
389 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* default anyway */
390 .get_ro = imote2_mci_get_ro,
391 .gpio_card_detect = -1,
396 static struct mtd_partition imote2flash_partitions[] = {
398 .name = "Bootloader",
401 .mask_flags = MTD_WRITEABLE,
405 .offset = 0x00040000,
408 .name = "Filesystem",
410 .offset = 0x00240000,
415 static struct resource flash_resources = {
416 .start = PXA_CS0_PHYS,
417 .end = PXA_CS0_PHYS + SZ_32M - 1,
418 .flags = IORESOURCE_MEM,
421 static struct flash_platform_data imote2_flash_data = {
422 .map_name = "cfi_probe",
423 .parts = imote2flash_partitions,
424 .nr_parts = ARRAY_SIZE(imote2flash_partitions),
425 .name = "PXA27xOnChipROM",
429 static struct platform_device imote2_flash_device = {
430 .name = "pxa2xx-flash",
433 .platform_data = &imote2_flash_data,
435 .resource = &flash_resources,
439 /* Some of the drivers here are out of kernel at the moment (parts of IIO)
440 * and it may be a while before they are in the mainline.
442 static struct i2c_board_info __initdata imote2_i2c_board_info[] = {
443 { /* UCAM sensor board */
446 }, { /* ITS400 Sensor board only */
449 /* Through a nand gate - Also beware, on V2 sensor board the
450 * pull up resistors are missing.
453 }, { /* ITS400 Sensor board only */
456 /* Through a nand gate - Also beware, on V2 sensor board the
457 * pull up resistors are missing.
460 }, { /* ITS400 Sensor board only */
464 }, { /* IMB400 Multimedia board */
470 static struct i2c_board_info __initdata imote2_pwr_i2c_board_info[] = {
474 .platform_data = &imote2_da9030_pdata,
475 .irq = gpio_to_irq(1),
479 static struct pxa2xx_spi_master pxa_ssp_master_0_info = {
483 static struct pxa2xx_spi_master pxa_ssp_master_1_info = {
487 static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
491 static struct pxa2xx_spi_chip staccel_chip_info = {
499 static struct pxa2xx_spi_chip cc2420_info = {
507 static struct spi_board_info spi_board_info[] __initdata = {
508 { /* Driver in IIO */
509 .modalias = "lis3l02dq",
510 .max_speed_hz = 8000000,/* 8MHz max spi frequency at 3V */
513 .controller_data = &staccel_chip_info,
515 }, { /* Driver out of kernel as it needs considerable rewriting */
516 .modalias = "cc2420",
517 .max_speed_hz = 6500000,
520 .controller_data = &cc2420_info,
524 static void im2_udc_command(int cmd)
527 case PXA2XX_UDC_CMD_CONNECT:
528 UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
530 case PXA2XX_UDC_CMD_DISCONNECT:
531 UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
536 static struct pxa2xx_udc_mach_info imote2_udc_info __initdata = {
537 .udc_command = im2_udc_command,
540 static struct platform_device *imote2_devices[] = {
541 &imote2_flash_device,
546 static struct i2c_pxa_platform_data i2c_pwr_pdata = {
550 static struct i2c_pxa_platform_data i2c_pdata = {
554 static void __init imote2_init(void)
556 pxa2xx_mfp_config(ARRAY_AND_SIZE(imote2_pin_config));
558 pxa_set_ffuart_info(NULL);
559 pxa_set_btuart_info(NULL);
560 pxa_set_stuart_info(NULL);
562 platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));
564 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
565 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info);
566 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info);
568 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
570 i2c_register_board_info(0, imote2_i2c_board_info,
571 ARRAY_SIZE(imote2_i2c_board_info));
572 i2c_register_board_info(1, imote2_pwr_i2c_board_info,
573 ARRAY_SIZE(imote2_pwr_i2c_board_info));
575 pxa27x_set_i2c_power_info(&i2c_pwr_pdata);
576 pxa_set_i2c_info(&i2c_pdata);
578 pxa_set_mci_info(&imote2_mci_platform_data);
579 pxa_set_udc_info(&imote2_udc_info);
582 MACHINE_START(INTELMOTE2, "IMOTE 2")
583 .phys_io = 0x40000000,
584 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
585 .map_io = pxa_map_io,
586 .init_irq = pxa27x_init_irq,
588 .init_machine = imote2_init,
589 .boot_params = 0xA0000100,