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 GPIO39_GPIO
, /* CSn */
68 GPIO115_GPIO
, /* Power enable */
74 /* SSP 3 - 802.15.4 radio */
75 GPIO39_GPIO
, /* Chip Select */
80 /* SSP 2 - to daughter boards */
81 GPIO37_GPIO
, /* Chip Select */
86 /* SSP 1 - to daughter boards */
87 GPIO24_GPIO
, /* Chip Select */
92 /* BTUART Basic Connector*/
98 /* STUART Serial console via debug board*/
102 /* Basic sensor board */
103 GPIO96_GPIO
, /* accelerometer interrupt */
104 GPIO99_GPIO
, /* ADC interrupt */
110 /* Connector pins specified as gpios */
111 GPIO94_GPIO
, /* large basic connector pin 14 */
112 GPIO10_GPIO
, /* large basic connector pin 23 */
115 GPIO103_GPIO
, /* red led */
116 GPIO104_GPIO
, /* green led */
117 GPIO105_GPIO
, /* blue led */
120 static struct sht15_platform_data platform_data_sht15
= {
125 static struct platform_device sht15
= {
129 .platform_data
= &platform_data_sht15
,
133 static struct regulator_consumer_supply imote2_sensor_3_con
[] = {
140 static struct gpio_led imote2_led_pins
[] = {
142 .name
= "imote2:red",
146 .name
= "imote2:green",
150 .name
= "imote2:blue",
156 static struct gpio_led_platform_data imote2_led_data
= {
157 .num_leds
= ARRAY_SIZE(imote2_led_pins
),
158 .leds
= imote2_led_pins
,
161 static struct platform_device imote2_leds
= {
165 .platform_data
= &imote2_led_data
,
169 /* Reverse engineered partly from Platformx drivers */
175 /* The two voltages available to sensor boards */
179 vcc_sram_ext
, /* directly connected to the pxa271 */
181 vcc_pxa_usim
, /* Reference voltage for certain gpios */
184 vcc_pxa_core
, /*Dc-Dc buck not yet supported */
188 vcc_io
, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
191 /* The values of the various regulator constraints are obviously dependent
192 * on exactly what is wired to each ldo. Unfortunately this information is
193 * not generally available. More information has been requested from Xbow
194 * but as of yet they haven't been forthcoming.
196 * Some of these are clearly Stargate 2 related (no way of plugging
197 * in an lcd on the IM2 for example!).
199 static struct regulator_init_data imote2_ldo_init_data
[] = {
201 .constraints
= { /* board default 1.8V */
208 .constraints
= { /* board default 2.8V */
215 .constraints
= {/* default is 1.8V */
216 .name
= "vcc_pxa_flash",
221 [vcc_cc2420
] = { /* also vcc_io */
223 /* board default is 2.8V */
224 .name
= "vcc_cc2420",
229 [vcc_vref
] = { /* Reference for what? */
230 .constraints
= { /* default 1.8V */
237 .constraints
= { /* default 2.8V */
238 .name
= "vcc_sram_ext",
244 .constraints
= { /* default 2.8V */
251 .constraints
= { /* default 2.8V */
258 .constraints
= { /* default 2.8V */
264 [vcc_io
] = { /* Same or higher than everything
265 * bar vccbat and vccusb */
266 .constraints
= { /* default 2.8V */
273 .constraints
= { /* default 1.8V */
274 .name
= "vcc_sensor_1_8",
279 [vcc_sensor_3
] = { /* curiously default 2.8V */
281 .name
= "vcc_sensor_3",
285 .num_consumer_supplies
= ARRAY_SIZE(imote2_sensor_3_con
),
286 .consumer_supplies
= imote2_sensor_3_con
,
288 [vcc_pxa_pll
] = { /* 1.17V - 1.43V, default 1.3V*/
290 .name
= "vcc_pxa_pll",
296 .constraints
= { /* default 1.8V */
297 .name
= "vcc_pxa_usim",
303 .constraints
= { /* default 1.8V */
304 .name
= "vcc_pxa_mem",
311 static struct da903x_subdev_info imote2_da9030_subdevs
[] = {
313 .name
= "da903x-regulator",
314 .id
= DA9030_ID_LDO2
,
315 .platform_data
= &imote2_ldo_init_data
[vcc_bbio
],
317 .name
= "da903x-regulator",
318 .id
= DA9030_ID_LDO3
,
319 .platform_data
= &imote2_ldo_init_data
[vcc_bb
],
321 .name
= "da903x-regulator",
322 .id
= DA9030_ID_LDO4
,
323 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_flash
],
325 .name
= "da903x-regulator",
326 .id
= DA9030_ID_LDO5
,
327 .platform_data
= &imote2_ldo_init_data
[vcc_cc2420
],
329 .name
= "da903x-regulator",
330 .id
= DA9030_ID_LDO6
,
331 .platform_data
= &imote2_ldo_init_data
[vcc_vref
],
333 .name
= "da903x-regulator",
334 .id
= DA9030_ID_LDO7
,
335 .platform_data
= &imote2_ldo_init_data
[vcc_sram_ext
],
337 .name
= "da903x-regulator",
338 .id
= DA9030_ID_LDO8
,
339 .platform_data
= &imote2_ldo_init_data
[vcc_mica
],
341 .name
= "da903x-regulator",
342 .id
= DA9030_ID_LDO9
,
343 .platform_data
= &imote2_ldo_init_data
[vcc_bt
],
345 .name
= "da903x-regulator",
346 .id
= DA9030_ID_LDO10
,
347 .platform_data
= &imote2_ldo_init_data
[vcc_sensor_1_8
],
349 .name
= "da903x-regulator",
350 .id
= DA9030_ID_LDO11
,
351 .platform_data
= &imote2_ldo_init_data
[vcc_sensor_3
],
353 .name
= "da903x-regulator",
354 .id
= DA9030_ID_LDO12
,
355 .platform_data
= &imote2_ldo_init_data
[vcc_lcd
],
357 .name
= "da903x-regulator",
358 .id
= DA9030_ID_LDO15
,
359 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_pll
],
361 .name
= "da903x-regulator",
362 .id
= DA9030_ID_LDO17
,
363 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_usim
],
365 .name
= "da903x-regulator",
366 .id
= DA9030_ID_LDO18
,
367 .platform_data
= &imote2_ldo_init_data
[vcc_io
],
369 .name
= "da903x-regulator",
370 .id
= DA9030_ID_LDO19
,
371 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_mem
],
375 static struct da903x_platform_data imote2_da9030_pdata
= {
376 .num_subdevs
= ARRAY_SIZE(imote2_da9030_subdevs
),
377 .subdevs
= imote2_da9030_subdevs
,
380 /* As the the imote2 doesn't currently have a conventional SD slot
381 * there is no option to hotplug cards, making all this rather simple
383 static int imote2_mci_get_ro(struct device
*dev
)
388 /* Rather simple case as hotplugging not possible */
389 static struct pxamci_platform_data imote2_mci_platform_data
= {
390 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
, /* default anyway */
391 .get_ro
= imote2_mci_get_ro
,
394 static struct mtd_partition imote2flash_partitions
[] = {
396 .name
= "Bootloader",
399 .mask_flags
= MTD_WRITEABLE
,
403 .offset
= 0x00040000,
406 .name
= "Filesystem",
408 .offset
= 0x00240000,
413 static struct resource flash_resources
= {
414 .start
= PXA_CS0_PHYS
,
415 .end
= PXA_CS0_PHYS
+ SZ_32M
- 1,
416 .flags
= IORESOURCE_MEM
,
419 static struct flash_platform_data imote2_flash_data
= {
420 .map_name
= "cfi_probe",
421 .parts
= imote2flash_partitions
,
422 .nr_parts
= ARRAY_SIZE(imote2flash_partitions
),
423 .name
= "PXA27xOnChipROM",
427 static struct platform_device imote2_flash_device
= {
428 .name
= "pxa2xx-flash",
431 .platform_data
= &imote2_flash_data
,
433 .resource
= &flash_resources
,
437 /* Some of the drivers here are out of kernel at the moment (parts of IIO)
438 * and it may be a while before they are in the mainline.
440 static struct i2c_board_info __initdata imote2_i2c_board_info
[] = {
441 { /* UCAM sensor board */
444 }, { /* ITS400 Sensor board only */
447 /* Through a nand gate - Also beware, on V2 sensor board the
448 * pull up resistors are missing.
451 }, { /* ITS400 Sensor board only */
454 /* Through a nand gate - Also beware, on V2 sensor board the
455 * pull up resistors are missing.
458 }, { /* ITS400 Sensor board only */
462 }, { /* IMB400 Multimedia board */
468 static struct i2c_board_info __initdata imote2_pwr_i2c_board_info
[] = {
472 .platform_data
= &imote2_da9030_pdata
,
473 .irq
= gpio_to_irq(1),
477 static struct pxa2xx_spi_master pxa_ssp_master_0_info
= {
481 static struct pxa2xx_spi_master pxa_ssp_master_1_info
= {
485 static struct pxa2xx_spi_master pxa_ssp_master_2_info
= {
489 static struct pxa2xx_spi_chip staccel_chip_info
= {
497 static struct pxa2xx_spi_chip cc2420_info
= {
505 static struct spi_board_info spi_board_info
[] __initdata
= {
506 { /* Driver in IIO */
507 .modalias
= "lis3l02dq",
508 .max_speed_hz
= 8000000,/* 8MHz max spi frequency at 3V */
511 .controller_data
= &staccel_chip_info
,
513 }, { /* Driver out of kernel as it needs considerable rewriting */
514 .modalias
= "cc2420",
515 .max_speed_hz
= 6500000,
518 .controller_data
= &cc2420_info
,
522 static void im2_udc_command(int cmd
)
525 case PXA2XX_UDC_CMD_CONNECT
:
526 UP2OCR
|= UP2OCR_HXOE
| UP2OCR_DPPUE
| UP2OCR_DPPUBE
;
528 case PXA2XX_UDC_CMD_DISCONNECT
:
529 UP2OCR
&= ~(UP2OCR_HXOE
| UP2OCR_DPPUE
| UP2OCR_DPPUBE
);
534 static struct pxa2xx_udc_mach_info imote2_udc_info __initdata
= {
535 .udc_command
= im2_udc_command
,
538 static struct platform_device
*imote2_devices
[] = {
539 &imote2_flash_device
,
544 static struct i2c_pxa_platform_data i2c_pwr_pdata
= {
548 static struct i2c_pxa_platform_data i2c_pdata
= {
552 static void __init
imote2_init(void)
555 pxa2xx_mfp_config(ARRAY_AND_SIZE(imote2_pin_config
));
556 /* SPI chip select directions - all other directions should
557 * be handled by drivers.*/
558 gpio_direction_output(37, 0);
560 platform_add_devices(imote2_devices
, ARRAY_SIZE(imote2_devices
));
562 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info
);
563 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info
);
564 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info
);
566 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
568 i2c_register_board_info(0, imote2_i2c_board_info
,
569 ARRAY_SIZE(imote2_i2c_board_info
));
570 i2c_register_board_info(1, imote2_pwr_i2c_board_info
,
571 ARRAY_SIZE(imote2_pwr_i2c_board_info
));
573 pxa27x_set_i2c_power_info(&i2c_pwr_pdata
);
574 pxa_set_i2c_info(&i2c_pdata
);
576 pxa_set_mci_info(&imote2_mci_platform_data
);
577 pxa_set_udc_info(&imote2_udc_info
);
580 MACHINE_START(INTELMOTE2
, "IMOTE 2")
581 .phys_io
= 0x40000000,
582 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
583 .map_io
= pxa_map_io
,
584 .init_irq
= pxa27x_init_irq
,
586 .init_machine
= imote2_init
,
587 .boot_params
= 0xA0000100,