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>
31 #include <mach/pxa27x.h>
35 #include <mach/pxa2xx_spi.h>
36 #include <mach/pxa27x-udc.h>
41 static unsigned long imote2_pin_config
[] __initdata
= {
43 /* Device Identification for wakeup*/
60 /* 802.15.4 radio - driver out of mainline */
61 GPIO22_GPIO
, /* CC_RSTN */
62 GPIO114_GPIO
, /* CC_FIFO */
63 GPIO116_GPIO
, /* CC_CCA */
64 GPIO0_GPIO
, /* CC_FIFOP */
65 GPIO16_GPIO
, /* CCSFD */
66 GPIO39_GPIO
, /* CSn */
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 */
105 /* Connector pins specified as gpios */
106 GPIO94_GPIO
, /* large basic connector pin 14 */
107 GPIO10_GPIO
, /* large basic connector pin 23 */
110 GPIO103_GPIO
, /* red led */
111 GPIO104_GPIO
, /* green led */
112 GPIO105_GPIO
, /* blue led */
115 static struct gpio_led imote2_led_pins
[] = {
117 .name
= "imote2:red",
121 .name
= "imote2:green",
125 .name
= "imote2:blue",
131 static struct gpio_led_platform_data imote2_led_data
= {
132 .num_leds
= ARRAY_SIZE(imote2_led_pins
),
133 .leds
= imote2_led_pins
,
136 static struct platform_device imote2_leds
= {
140 .platform_data
= &imote2_led_data
,
144 /* Reverse engineered partly from Platformx drivers */
150 /* The two voltages available to sensor boards */
154 vcc_sram_ext
, /* directly connected to the pxa271 */
156 vcc_pxa_usim
, /* Reference voltage for certain gpios */
159 vcc_pxa_core
, /*Dc-Dc buck not yet supported */
163 vcc_io
, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
166 /* The values of the various regulator constraints are obviously dependent
167 * on exactly what is wired to each ldo. Unfortunately this information is
168 * not generally available. More information has been requested from Xbow
169 * but as of yet they haven't been forthcoming.
171 * Some of these are clearly Stargate 2 related (no way of plugging
172 * in an lcd on the IM2 for example!).
174 static struct regulator_init_data imote2_ldo_init_data
[] = {
176 .constraints
= { /* board default 1.8V */
183 .constraints
= { /* board default 2.8V */
190 .constraints
= {/* default is 1.8V */
191 .name
= "vcc_pxa_flash",
196 [vcc_cc2420
] = { /* also vcc_io */
198 /* board default is 2.8V */
199 .name
= "vcc_cc2420",
204 [vcc_vref
] = { /* Reference for what? */
205 .constraints
= { /* default 1.8V */
212 .constraints
= { /* default 2.8V */
213 .name
= "vcc_sram_ext",
219 .constraints
= { /* default 2.8V */
226 .constraints
= { /* default 2.8V */
233 .constraints
= { /* default 2.8V */
239 [vcc_io
] = { /* Same or higher than everything
240 * bar vccbat and vccusb */
241 .constraints
= { /* default 2.8V */
248 .constraints
= { /* default 1.8V */
249 .name
= "vcc_sensor_1_8",
254 [vcc_sensor_3
] = { /* curiously default 2.8V */
256 .name
= "vcc_sensor_3",
261 [vcc_pxa_pll
] = { /* 1.17V - 1.43V, default 1.3V*/
263 .name
= "vcc_pxa_pll",
269 .constraints
= { /* default 1.8V */
270 .name
= "vcc_pxa_usim",
276 .constraints
= { /* default 1.8V */
277 .name
= "vcc_pxa_mem",
284 static struct da903x_subdev_info imote2_da9030_subdevs
[] = {
286 .name
= "da903x-regulator",
287 .id
= DA9030_ID_LDO2
,
288 .platform_data
= &imote2_ldo_init_data
[vcc_bbio
],
290 .name
= "da903x-regulator",
291 .id
= DA9030_ID_LDO3
,
292 .platform_data
= &imote2_ldo_init_data
[vcc_bb
],
294 .name
= "da903x-regulator",
295 .id
= DA9030_ID_LDO4
,
296 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_flash
],
298 .name
= "da903x-regulator",
299 .id
= DA9030_ID_LDO5
,
300 .platform_data
= &imote2_ldo_init_data
[vcc_cc2420
],
302 .name
= "da903x-regulator",
303 .id
= DA9030_ID_LDO6
,
304 .platform_data
= &imote2_ldo_init_data
[vcc_vref
],
306 .name
= "da903x-regulator",
307 .id
= DA9030_ID_LDO7
,
308 .platform_data
= &imote2_ldo_init_data
[vcc_sram_ext
],
310 .name
= "da903x-regulator",
311 .id
= DA9030_ID_LDO8
,
312 .platform_data
= &imote2_ldo_init_data
[vcc_mica
],
314 .name
= "da903x-regulator",
315 .id
= DA9030_ID_LDO9
,
316 .platform_data
= &imote2_ldo_init_data
[vcc_bt
],
318 .name
= "da903x-regulator",
319 .id
= DA9030_ID_LDO10
,
320 .platform_data
= &imote2_ldo_init_data
[vcc_sensor_1_8
],
322 .name
= "da903x-regulator",
323 .id
= DA9030_ID_LDO11
,
324 .platform_data
= &imote2_ldo_init_data
[vcc_sensor_3
],
326 .name
= "da903x-regulator",
327 .id
= DA9030_ID_LDO12
,
328 .platform_data
= &imote2_ldo_init_data
[vcc_lcd
],
330 .name
= "da903x-regulator",
331 .id
= DA9030_ID_LDO15
,
332 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_pll
],
334 .name
= "da903x-regulator",
335 .id
= DA9030_ID_LDO17
,
336 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_usim
],
338 .name
= "da903x-regulator",
339 .id
= DA9030_ID_LDO18
,
340 .platform_data
= &imote2_ldo_init_data
[vcc_io
],
342 .name
= "da903x-regulator",
343 .id
= DA9030_ID_LDO19
,
344 .platform_data
= &imote2_ldo_init_data
[vcc_pxa_mem
],
348 static struct da903x_platform_data imote2_da9030_pdata
= {
349 .num_subdevs
= ARRAY_SIZE(imote2_da9030_subdevs
),
350 .subdevs
= imote2_da9030_subdevs
,
353 /* As the the imote2 doesn't currently have a conventional SD slot
354 * there is no option to hotplug cards, making all this rather simple
356 static int imote2_mci_get_ro(struct device
*dev
)
361 /* Rather simple case as hotplugging not possible */
362 static struct pxamci_platform_data imote2_mci_platform_data
= {
363 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
, /* default anyway */
364 .get_ro
= imote2_mci_get_ro
,
367 static struct mtd_partition imote2flash_partitions
[] = {
369 .name
= "Bootloader",
372 .mask_flags
= MTD_WRITEABLE
,
376 .offset
= 0x00040000,
379 .name
= "Filesystem",
381 .offset
= 0x00240000,
386 static struct resource flash_resources
= {
387 .start
= PXA_CS0_PHYS
,
388 .end
= PXA_CS0_PHYS
+ SZ_32M
- 1,
389 .flags
= IORESOURCE_MEM
,
392 static struct flash_platform_data imote2_flash_data
= {
393 .map_name
= "cfi_probe",
394 .parts
= imote2flash_partitions
,
395 .nr_parts
= ARRAY_SIZE(imote2flash_partitions
),
396 .name
= "PXA27xOnChipROM",
400 static struct platform_device imote2_flash_device
= {
401 .name
= "pxa2xx-flash",
404 .platform_data
= &imote2_flash_data
,
406 .resource
= &flash_resources
,
410 /* Some of the drivers here are out of kernel at the moment (parts of IIO)
411 * and it may be a while before they are in the mainline.
413 static struct i2c_board_info __initdata imote2_i2c_board_info
[] = {
414 { /* UCAM sensor board */
417 }, { /* ITS400 Sensor board only */
420 /* Through a nand gate - Also beware, on V2 sensor board the
421 * pull up resistors are missing.
424 }, { /* ITS400 Sensor board only */
427 /* Through a nand gate - Also beware, on V2 sensor board the
428 * pull up resistors are missing.
431 }, { /* ITS400 Sensor board only */
438 static struct i2c_board_info __initdata imote2_pwr_i2c_board_info
[] = {
442 .platform_data
= &imote2_da9030_pdata
,
443 .irq
= gpio_to_irq(1),
447 static struct pxa2xx_spi_master pxa_ssp_master_0_info
= {
451 static struct pxa2xx_spi_master pxa_ssp_master_1_info
= {
455 static struct pxa2xx_spi_master pxa_ssp_master_2_info
= {
459 /* Patch posted by Eric Miao <eric.miao@marvell.com> will remove
460 * the need for these functions.
462 static void spi1control(u32 command
)
464 gpio_set_value(24, command
& PXA2XX_CS_ASSERT
? 0 : 1);
467 static void spi3control(u32 command
)
469 gpio_set_value(39, command
& PXA2XX_CS_ASSERT
? 0 : 1);
472 static struct pxa2xx_spi_chip staccel_chip_info
= {
477 .cs_control
= spi1control
,
480 static struct pxa2xx_spi_chip cc2420_info
= {
485 .cs_control
= spi3control
,
488 static struct spi_board_info spi_board_info
[] __initdata
= {
489 { /* Driver in IIO */
490 .modalias
= "lis3l02dq",
491 .max_speed_hz
= 8000000,/* 8MHz max spi frequency at 3V */
494 .controller_data
= &staccel_chip_info
,
496 }, { /* Driver out of kernel as it needs considerable rewriting */
497 .modalias
= "cc2420",
498 .max_speed_hz
= 6500000,
501 .controller_data
= &cc2420_info
,
505 static void im2_udc_command(int cmd
)
508 case PXA2XX_UDC_CMD_CONNECT
:
509 UP2OCR
|= UP2OCR_HXOE
| UP2OCR_DPPUE
| UP2OCR_DPPUBE
;
511 case PXA2XX_UDC_CMD_DISCONNECT
:
512 UP2OCR
&= ~(UP2OCR_HXOE
| UP2OCR_DPPUE
| UP2OCR_DPPUBE
);
517 static struct pxa2xx_udc_mach_info imote2_udc_info __initdata
= {
518 .udc_command
= im2_udc_command
,
521 static struct platform_device
*imote2_devices
[] = {
522 &imote2_flash_device
,
526 static struct i2c_pxa_platform_data i2c_pwr_pdata
= {
530 static struct i2c_pxa_platform_data i2c_pdata
= {
534 static void __init
imote2_init(void)
537 pxa2xx_mfp_config(ARRAY_AND_SIZE(imote2_pin_config
));
538 /* SPI chip select directions - all other directions should
539 * be handled by drivers.*/
540 gpio_direction_output(37, 0);
541 gpio_direction_output(24, 0);
542 gpio_direction_output(39, 0);
544 platform_add_devices(imote2_devices
, ARRAY_SIZE(imote2_devices
));
546 pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info
);
547 pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info
);
548 pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info
);
550 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
552 i2c_register_board_info(0, imote2_i2c_board_info
,
553 ARRAY_SIZE(imote2_i2c_board_info
));
554 i2c_register_board_info(1, imote2_pwr_i2c_board_info
,
555 ARRAY_SIZE(imote2_pwr_i2c_board_info
));
557 pxa27x_set_i2c_power_info(&i2c_pwr_pdata
);
558 pxa_set_i2c_info(&i2c_pdata
);
560 pxa_set_mci_info(&imote2_mci_platform_data
);
561 pxa_set_udc_info(&imote2_udc_info
);
564 MACHINE_START(INTELMOTE2
, "IMOTE 2")
565 .phys_io
= 0x40000000,
566 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
567 .map_io
= pxa_map_io
,
568 .init_irq
= pxa27x_init_irq
,
570 .init_machine
= imote2_init
,
571 .boot_params
= 0xA0000100,