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>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/flash.h>
32 #include <mach/pxa-regs.h>
33 #include <mach/pxa2xx-regs.h>
34 #include <mach/mfp-pxa27x.h>
35 #include <mach/regs-ssp.h>
38 #include <mach/pxa2xx_spi.h>
39 #include <mach/pxa27x-udc.h>
44 static unsigned long imote2_pin_config
[] __initdata
= {
46 /* Device Identification for wakeup*/
63 /* 802.15.4 radio - driver out of mainline */
64 GPIO22_GPIO
, /* CC_RSTN */
65 GPIO114_GPIO
, /* CC_FIFO */
66 GPIO116_GPIO
, /* CC_CCA */
67 GPIO0_GPIO
, /* CC_FIFOP */
68 GPIO16_GPIO
, /* CCSFD */
69 GPIO39_GPIO
, /* CSn */
70 GPIO115_GPIO
, /* Power enable */
76 /* SSP 3 - 802.15.4 radio */
77 GPIO39_GPIO
, /* Chip Select */
82 /* SSP 2 - to daughter boards */
83 GPIO37_GPIO
, /* Chip Select */
88 /* SSP 1 - to daughter boards */
89 GPIO24_GPIO
, /* Chip Select */
94 /* BTUART Basic Connector*/
100 /* STUART Serial console via debug board*/
104 /* Basic sensor board */
105 GPIO96_GPIO
, /* accelerometer interrupt */
106 GPIO99_GPIO
, /* ADC interrupt */
108 /* Connector pins specified as gpios */
109 GPIO94_GPIO
, /* large basic connector pin 14 */
110 GPIO10_GPIO
, /* large basic connector pin 23 */
113 GPIO103_GPIO
, /* red led */
114 GPIO104_GPIO
, /* green led */
115 GPIO105_GPIO
, /* blue led */
118 static struct gpio_led imote2_led_pins
[] = {
120 .name
= "imote2:red",
124 .name
= "imote2:green",
128 .name
= "imote2:blue",
134 static struct gpio_led_platform_data imote2_led_data
= {
135 .num_leds
= ARRAY_SIZE(imote2_led_pins
),
136 .leds
= imote2_led_pins
,
139 static struct platform_device imote2_leds
= {
143 .platform_data
= &imote2_led_data
,
147 /* Reverse engineered partly from Platformx drivers */
153 /* The two voltages available to sensor boards */
157 vcc_sram_ext
, /* directly connected to the pxa271 */
159 vcc_pxa_usim
, /* Reference voltage for certain gpios */
162 vcc_pxa_core
, /*Dc-Dc buck not yet supported */
166 vcc_io
, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
169 /* The values of the various regulator constraints are obviously dependent
170 * on exactly what is wired to each ldo. Unfortunately this information is
171 * not generally available. More information has been requested from Xbow
172 * but as of yet they haven't been forthcoming.
174 * Some of these are clearly Stargate 2 related (no way of plugging
175 * in an lcd on the IM2 for example!).
177 static struct regulator_init_data imote2_ldo_init_data
[] = {
179 .constraints
= { /* board default 1.8V */
186 .constraints
= { /* board default 2.8V */
193 .constraints
= {/* default is 1.8V */
194 .name
= "vcc_pxa_flash",
199 [vcc_cc2420
] = { /* also vcc_io */
201 /* board default is 2.8V */
202 .name
= "vcc_cc2420",
207 [vcc_vref
] = { /* Reference for what? */
208 .constraints
= { /* default 1.8V */
215 .constraints
= { /* default 2.8V */
216 .name
= "vcc_sram_ext",
222 .constraints
= { /* default 2.8V */
229 .constraints
= { /* default 2.8V */
236 .constraints
= { /* default 2.8V */
242 [vcc_io
] = { /* Same or higher than everything
243 * bar vccbat and vccusb */
244 .constraints
= { /* default 2.8V */
251 .constraints
= { /* default 1.8V */
252 .name
= "vcc_sensor_1_8",
257 [vcc_sensor_3
] = { /* curiously default 2.8V */
259 .name
= "vcc_sensor_3",
264 [vcc_pxa_pll
] = { /* 1.17V - 1.43V, default 1.3V*/
266 .name
= "vcc_pxa_pll",
272 .constraints
= { /* default 1.8V */
273 .name
= "vcc_pxa_usim",
279 .constraints
= { /* default 1.8V */
280 .name
= "vcc_pxa_mem",
287 static struct da903x_subdev_info imote2_da9030_subdevs
[] = {
289 .name
= "da903x-regulator",
290 .id
= DA9030_ID_LDO2
,
291 .platform_data
= &imote2_ldo_init_data
[vcc_bbio
],
293 .name
= "da903x-regulator",
294 .id
= DA9030_ID_LDO3
,
295 .platform_data
= &imote2_ldo_init_data
[vcc_bb
],
297 .name
= "da903x-regulator",
298 .id
= DA9030_ID_LDO4
,
299 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_flash
],
301 .name
= "da903x-regulator",
302 .id
= DA9030_ID_LDO5
,
303 .platform_data
= &imote2_ldo_init_data
[vcc_cc2420
],
305 .name
= "da903x-regulator",
306 .id
= DA9030_ID_LDO6
,
307 .platform_data
= &imote2_ldo_init_data
[vcc_vref
],
309 .name
= "da903x-regulator",
310 .id
= DA9030_ID_LDO7
,
311 .platform_data
= &imote2_ldo_init_data
[vcc_sram_ext
],
313 .name
= "da903x-regulator",
314 .id
= DA9030_ID_LDO8
,
315 .platform_data
= &imote2_ldo_init_data
[vcc_mica
],
317 .name
= "da903x-regulator",
318 .id
= DA9030_ID_LDO9
,
319 .platform_data
= &imote2_ldo_init_data
[vcc_bt
],
321 .name
= "da903x-regulator",
322 .id
= DA9030_ID_LDO10
,
323 .platform_data
= &imote2_ldo_init_data
[vcc_sensor_1_8
],
325 .name
= "da903x-regulator",
326 .id
= DA9030_ID_LDO11
,
327 .platform_data
= &imote2_ldo_init_data
[vcc_sensor_3
],
329 .name
= "da903x-regulator",
330 .id
= DA9030_ID_LDO12
,
331 .platform_data
= &imote2_ldo_init_data
[vcc_lcd
],
333 .name
= "da903x-regulator",
334 .id
= DA9030_ID_LDO15
,
335 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_pll
],
337 .name
= "da903x-regulator",
338 .id
= DA9030_ID_LDO17
,
339 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_usim
],
341 .name
= "da903x-regulator",
342 .id
= DA9030_ID_LDO18
,
343 .platform_data
= &imote2_ldo_init_data
[vcc_io
],
345 .name
= "da903x-regulator",
346 .id
= DA9030_ID_LDO19
,
347 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_mem
],
351 static struct da903x_platform_data imote2_da9030_pdata
= {
352 .num_subdevs
= ARRAY_SIZE(imote2_da9030_subdevs
),
353 .subdevs
= imote2_da9030_subdevs
,
356 /* As the the imote2 doesn't currently have a conventional SD slot
357 * there is no option to hotplug cards, making all this rather simple
359 static int imote2_mci_get_ro(struct device
*dev
)
364 /* Rather simple case as hotplugging not possible */
365 static struct pxamci_platform_data imote2_mci_platform_data
= {
366 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
, /* default anyway */
367 .get_ro
= imote2_mci_get_ro
,
370 static struct mtd_partition imote2flash_partitions
[] = {
372 .name
= "Bootloader",
375 .mask_flags
= MTD_WRITEABLE
,
379 .offset
= 0x00040000,
382 .name
= "Filesystem",
384 .offset
= 0x00240000,
389 static struct resource flash_resources
= {
390 .start
= PXA_CS0_PHYS
,
391 .end
= PXA_CS0_PHYS
+ SZ_32M
- 1,
392 .flags
= IORESOURCE_MEM
,
395 static struct flash_platform_data imote2_flash_data
= {
396 .map_name
= "cfi_probe",
397 .parts
= imote2flash_partitions
,
398 .nr_parts
= ARRAY_SIZE(imote2flash_partitions
),
399 .name
= "PXA27xOnChipROM",
403 static struct platform_device imote2_flash_device
= {
404 .name
= "pxa2xx-flash",
407 .platform_data
= &imote2_flash_data
,
409 .resource
= &flash_resources
,
413 /* Some of the drivers here are out of kernel at the moment (parts of IIO)
414 * and it may be a while before they are in the mainline.
416 static struct i2c_board_info __initdata imote2_i2c_board_info
[] = {
417 { /* UCAM sensor board */
420 }, { /* ITS400 Sensor board only */
423 /* Through a nand gate - Also beware, on V2 sensor board the
424 * pull up resistors are missing.
427 }, { /* ITS400 Sensor board only */
430 /* Through a nand gate - Also beware, on V2 sensor board the
431 * pull up resistors are missing.
434 }, { /* ITS400 Sensor board only */
441 static struct i2c_board_info __initdata imote2_pwr_i2c_board_info
[] = {
445 .platform_data
= &imote2_da9030_pdata
,
446 .irq
= gpio_to_irq(1),
450 static struct pxa2xx_spi_master pxa_ssp_master_0_info
= {
454 static struct pxa2xx_spi_master pxa_ssp_master_1_info
= {
458 static struct pxa2xx_spi_master pxa_ssp_master_2_info
= {
462 /* Patch posted by Eric Miao <eric.miao@marvell.com> will remove
463 * the need for these functions.
465 static void spi1control(u32 command
)
467 gpio_set_value(24, command
& PXA2XX_CS_ASSERT
? 0 : 1);
470 static void spi3control(u32 command
)
472 gpio_set_value(39, command
& PXA2XX_CS_ASSERT
? 0 : 1);
475 static struct pxa2xx_spi_chip staccel_chip_info
= {
480 .cs_control
= spi1control
,
483 static struct pxa2xx_spi_chip cc2420_info
= {
488 .cs_control
= spi3control
,
491 static struct spi_board_info spi_board_info
[] __initdata
= {
492 { /* Driver in IIO */
493 .modalias
= "lis3l02dq",
494 .max_speed_hz
= 8000000,/* 8MHz max spi frequency at 3V */
497 .controller_data
= &staccel_chip_info
,
499 }, { /* Driver out of kernel as it needs considerable rewriting */
500 .modalias
= "cc2420",
501 .max_speed_hz
= 6500000,
504 .controller_data
= &cc2420_info
,
508 static void im2_udc_command(int cmd
)
511 case PXA2XX_UDC_CMD_CONNECT
:
512 UP2OCR
|= UP2OCR_HXOE
| UP2OCR_DPPUE
| UP2OCR_DPPUBE
;
514 case PXA2XX_UDC_CMD_DISCONNECT
:
515 UP2OCR
&= ~(UP2OCR_HXOE
| UP2OCR_DPPUE
| UP2OCR_DPPUBE
);
520 static struct pxa2xx_udc_mach_info imote2_udc_info __initdata
= {
521 .udc_command
= im2_udc_command
,
524 static struct platform_device
*imote2_devices
[] = {
525 &imote2_flash_device
,
529 static struct i2c_pxa_platform_data i2c_pwr_pdata
= {
533 static struct i2c_pxa_platform_data i2c_pdata
= {
537 static void __init
imote2_init(void)
540 pxa2xx_mfp_config(ARRAY_AND_SIZE(imote2_pin_config
));
541 /* SPI chip select directions - all other directions should
542 * be handled by drivers.*/
543 gpio_direction_output(37, 0);
544 gpio_direction_output(24, 0);
545 gpio_direction_output(39, 0);
547 platform_add_devices(imote2_devices
, ARRAY_SIZE(imote2_devices
));
549 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info
);
550 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info
);
551 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info
);
553 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
555 i2c_register_board_info(0, imote2_i2c_board_info
,
556 ARRAY_SIZE(imote2_i2c_board_info
));
557 i2c_register_board_info(1, imote2_pwr_i2c_board_info
,
558 ARRAY_SIZE(imote2_pwr_i2c_board_info
));
560 pxa27x_set_i2c_power_info(&i2c_pwr_pdata
);
561 pxa_set_i2c_info(&i2c_pdata
);
563 pxa_set_mci_info(&imote2_mci_platform_data
);
564 pxa_set_udc_info(&imote2_udc_info
);
567 MACHINE_START(INTELMOTE2
, "IMOTE 2")
568 .phys_io
= 0x40000000,
569 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
570 .map_io
= pxa_map_io
,
571 .init_irq
= pxa27x_init_irq
,
573 .init_machine
= imote2_init
,
574 .boot_params
= 0xA0000100,