OMAP3: PM: Ensure MUSB block can idle when driver not loaded
[linux-ginger.git] / arch / arm / mach-pxa / imote2.c
blob2121309b2474dc545e379cac27697c8d374b0bad
1 /*
2 * linux/arch/arm/mach-pxa/imote2.c
4 * Author: Ed C. Epp
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>
32 #include <mach/i2c.h>
33 #include <mach/udc.h>
34 #include <mach/mmc.h>
35 #include <mach/pxa2xx_spi.h>
36 #include <mach/pxa27x-udc.h>
38 #include "devices.h"
39 #include "generic.h"
41 static unsigned long imote2_pin_config[] __initdata = {
43 /* Device Identification for wakeup*/
44 GPIO102_GPIO,
46 /* Button */
47 GPIO91_GPIO,
49 /* DA9030 */
50 GPIO1_GPIO,
52 /* MMC */
53 GPIO32_MMC_CLK,
54 GPIO112_MMC_CMD,
55 GPIO92_MMC_DAT_0,
56 GPIO109_MMC_DAT_1,
57 GPIO110_MMC_DAT_2,
58 GPIO111_MMC_DAT_3,
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 */
69 /* I2C */
70 GPIO117_I2C_SCL,
71 GPIO118_I2C_SDA,
73 /* SSP 3 - 802.15.4 radio */
74 GPIO39_GPIO, /* Chip Select */
75 GPIO34_SSP3_SCLK,
76 GPIO35_SSP3_TXD,
77 GPIO41_SSP3_RXD,
79 /* SSP 2 - to daughter boards */
80 GPIO37_GPIO, /* Chip Select */
81 GPIO36_SSP2_SCLK,
82 GPIO38_SSP2_TXD,
83 GPIO11_SSP2_RXD,
85 /* SSP 1 - to daughter boards */
86 GPIO24_GPIO, /* Chip Select */
87 GPIO23_SSP1_SCLK,
88 GPIO25_SSP1_TXD,
89 GPIO26_SSP1_RXD,
91 /* BTUART Basic Connector*/
92 GPIO42_BTUART_RXD,
93 GPIO43_BTUART_TXD,
94 GPIO44_BTUART_CTS,
95 GPIO45_BTUART_RTS,
97 /* STUART Serial console via debug board*/
98 GPIO46_STUART_RXD,
99 GPIO47_STUART_TXD,
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 */
109 /* LEDS */
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",
118 .gpio = 103,
119 .active_low = 1,
120 }, {
121 .name = "imote2:green",
122 .gpio = 104,
123 .active_low = 1,
124 }, {
125 .name = "imote2:blue",
126 .gpio = 105,
127 .active_low = 1,
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 = {
137 .name = "leds-gpio",
138 .id = -1,
139 .dev = {
140 .platform_data = &imote2_led_data,
144 /* Reverse engineered partly from Platformx drivers */
145 enum imote2_ldos{
146 vcc_vref,
147 vcc_cc2420,
148 vcc_mica,
149 vcc_bt,
150 /* The two voltages available to sensor boards */
151 vcc_sensor_1_8,
152 vcc_sensor_3,
154 vcc_sram_ext, /* directly connected to the pxa271 */
155 vcc_pxa_pll,
156 vcc_pxa_usim, /* Reference voltage for certain gpios */
157 vcc_pxa_mem,
158 vcc_pxa_flash,
159 vcc_pxa_core, /*Dc-Dc buck not yet supported */
160 vcc_lcd,
161 vcc_bb,
162 vcc_bbio,
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[] = {
175 [vcc_bbio] = {
176 .constraints = { /* board default 1.8V */
177 .name = "vcc_bbio",
178 .min_uV = 1800000,
179 .max_uV = 1800000,
182 [vcc_bb] = {
183 .constraints = { /* board default 2.8V */
184 .name = "vcc_bb",
185 .min_uV = 2700000,
186 .max_uV = 3000000,
189 [vcc_pxa_flash] = {
190 .constraints = {/* default is 1.8V */
191 .name = "vcc_pxa_flash",
192 .min_uV = 1800000,
193 .max_uV = 1800000,
196 [vcc_cc2420] = { /* also vcc_io */
197 .constraints = {
198 /* board default is 2.8V */
199 .name = "vcc_cc2420",
200 .min_uV = 2700000,
201 .max_uV = 3300000,
204 [vcc_vref] = { /* Reference for what? */
205 .constraints = { /* default 1.8V */
206 .name = "vcc_vref",
207 .min_uV = 1800000,
208 .max_uV = 1800000,
211 [vcc_sram_ext] = {
212 .constraints = { /* default 2.8V */
213 .name = "vcc_sram_ext",
214 .min_uV = 2800000,
215 .max_uV = 2800000,
218 [vcc_mica] = {
219 .constraints = { /* default 2.8V */
220 .name = "vcc_mica",
221 .min_uV = 2800000,
222 .max_uV = 2800000,
225 [vcc_bt] = {
226 .constraints = { /* default 2.8V */
227 .name = "vcc_bt",
228 .min_uV = 2800000,
229 .max_uV = 2800000,
232 [vcc_lcd] = {
233 .constraints = { /* default 2.8V */
234 .name = "vcc_lcd",
235 .min_uV = 2700000,
236 .max_uV = 3300000,
239 [vcc_io] = { /* Same or higher than everything
240 * bar vccbat and vccusb */
241 .constraints = { /* default 2.8V */
242 .name = "vcc_io",
243 .min_uV = 2692000,
244 .max_uV = 3300000,
247 [vcc_sensor_1_8] = {
248 .constraints = { /* default 1.8V */
249 .name = "vcc_sensor_1_8",
250 .min_uV = 1800000,
251 .max_uV = 1800000,
254 [vcc_sensor_3] = { /* curiously default 2.8V */
255 .constraints = {
256 .name = "vcc_sensor_3",
257 .min_uV = 2800000,
258 .max_uV = 3000000,
261 [vcc_pxa_pll] = { /* 1.17V - 1.43V, default 1.3V*/
262 .constraints = {
263 .name = "vcc_pxa_pll",
264 .min_uV = 1170000,
265 .max_uV = 1430000,
268 [vcc_pxa_usim] = {
269 .constraints = { /* default 1.8V */
270 .name = "vcc_pxa_usim",
271 .min_uV = 1710000,
272 .max_uV = 2160000,
275 [vcc_pxa_mem] = {
276 .constraints = { /* default 1.8V */
277 .name = "vcc_pxa_mem",
278 .min_uV = 1800000,
279 .max_uV = 1800000,
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],
289 }, {
290 .name = "da903x-regulator",
291 .id = DA9030_ID_LDO3,
292 .platform_data = &imote2_ldo_init_data[vcc_bb],
293 }, {
294 .name = "da903x-regulator",
295 .id = DA9030_ID_LDO4,
296 .platform_data = &imote2_ldo_init_data[vcc_pxa_flash],
297 }, {
298 .name = "da903x-regulator",
299 .id = DA9030_ID_LDO5,
300 .platform_data = &imote2_ldo_init_data[vcc_cc2420],
301 }, {
302 .name = "da903x-regulator",
303 .id = DA9030_ID_LDO6,
304 .platform_data = &imote2_ldo_init_data[vcc_vref],
305 }, {
306 .name = "da903x-regulator",
307 .id = DA9030_ID_LDO7,
308 .platform_data = &imote2_ldo_init_data[vcc_sram_ext],
309 }, {
310 .name = "da903x-regulator",
311 .id = DA9030_ID_LDO8,
312 .platform_data = &imote2_ldo_init_data[vcc_mica],
313 }, {
314 .name = "da903x-regulator",
315 .id = DA9030_ID_LDO9,
316 .platform_data = &imote2_ldo_init_data[vcc_bt],
317 }, {
318 .name = "da903x-regulator",
319 .id = DA9030_ID_LDO10,
320 .platform_data = &imote2_ldo_init_data[vcc_sensor_1_8],
321 }, {
322 .name = "da903x-regulator",
323 .id = DA9030_ID_LDO11,
324 .platform_data = &imote2_ldo_init_data[vcc_sensor_3],
325 }, {
326 .name = "da903x-regulator",
327 .id = DA9030_ID_LDO12,
328 .platform_data = &imote2_ldo_init_data[vcc_lcd],
329 }, {
330 .name = "da903x-regulator",
331 .id = DA9030_ID_LDO15,
332 .platform_data = &imote2_ldo_init_data[vcc_pxa_pll],
333 }, {
334 .name = "da903x-regulator",
335 .id = DA9030_ID_LDO17,
336 .platform_data = &imote2_ldo_init_data[vcc_pxa_usim],
337 }, {
338 .name = "da903x-regulator",
339 .id = DA9030_ID_LDO18,
340 .platform_data = &imote2_ldo_init_data[vcc_io],
341 }, {
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)
358 return 0;
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",
370 .size = 0x00040000,
371 .offset = 0,
372 .mask_flags = MTD_WRITEABLE,
373 }, {
374 .name = "Kernel",
375 .size = 0x00200000,
376 .offset = 0x00040000,
377 .mask_flags = 0,
378 }, {
379 .name = "Filesystem",
380 .size = 0x01DC0000,
381 .offset = 0x00240000,
382 .mask_flags = 0,
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",
397 .width = 2,
400 static struct platform_device imote2_flash_device = {
401 .name = "pxa2xx-flash",
402 .id = 0,
403 .dev = {
404 .platform_data = &imote2_flash_data,
406 .resource = &flash_resources,
407 .num_resources = 1,
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 */
415 .type = "max1238",
416 .addr = 0x35,
417 }, { /* ITS400 Sensor board only */
418 .type = "max1363",
419 .addr = 0x34,
420 /* Through a nand gate - Also beware, on V2 sensor board the
421 * pull up resistors are missing.
423 .irq = IRQ_GPIO(99),
424 }, { /* ITS400 Sensor board only */
425 .type = "tsl2561",
426 .addr = 0x49,
427 /* Through a nand gate - Also beware, on V2 sensor board the
428 * pull up resistors are missing.
430 .irq = IRQ_GPIO(99),
431 }, { /* ITS400 Sensor board only */
432 .type = "tmp175",
433 .addr = 0x4A,
434 .irq = IRQ_GPIO(96),
438 static struct i2c_board_info __initdata imote2_pwr_i2c_board_info[] = {
440 .type = "da9030",
441 .addr = 0x49,
442 .platform_data = &imote2_da9030_pdata,
443 .irq = gpio_to_irq(1),
447 static struct pxa2xx_spi_master pxa_ssp_master_0_info = {
448 .num_chipselect = 1,
451 static struct pxa2xx_spi_master pxa_ssp_master_1_info = {
452 .num_chipselect = 1,
455 static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
456 .num_chipselect = 1,
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 = {
473 .tx_threshold = 8,
474 .rx_threshold = 8,
475 .dma_burst_size = 8,
476 .timeout = 235,
477 .cs_control = spi1control,
480 static struct pxa2xx_spi_chip cc2420_info = {
481 .tx_threshold = 8,
482 .rx_threshold = 8,
483 .dma_burst_size = 8,
484 .timeout = 235,
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 */
492 .bus_num = 1,
493 .chip_select = 0,
494 .controller_data = &staccel_chip_info,
495 .irq = IRQ_GPIO(96),
496 }, { /* Driver out of kernel as it needs considerable rewriting */
497 .modalias = "cc2420",
498 .max_speed_hz = 6500000,
499 .bus_num = 3,
500 .chip_select = 0,
501 .controller_data = &cc2420_info,
505 static void im2_udc_command(int cmd)
507 switch (cmd) {
508 case PXA2XX_UDC_CMD_CONNECT:
509 UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
510 break;
511 case PXA2XX_UDC_CMD_DISCONNECT:
512 UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
513 break;
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,
523 &imote2_leds,
526 static struct i2c_pxa_platform_data i2c_pwr_pdata = {
527 .fast_mode = 1,
530 static struct i2c_pxa_platform_data i2c_pdata = {
531 .fast_mode = 1,
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,
569 .timer = &pxa_timer,
570 .init_machine = imote2_init,
571 .boot_params = 0xA0000100,
572 MACHINE_END