imote2.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /*
  2. * linux/arch/arm/mach-pxa/imote2.c
  3. *
  4. * Author: Ed C. Epp
  5. * Created: Nov 05, 2002
  6. * Copyright: Intel Corp.
  7. *
  8. * Modified 2008: Jonathan Cameron
  9. *
  10. * The Imote2 is a wireless sensor node platform sold
  11. * by Crossbow (www.xbow.com).
  12. */
  13. #include <linux/init.h>
  14. #include <linux/device.h>
  15. #include <linux/mtd/mtd.h>
  16. #include <linux/mtd/partitions.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/regulator/machine.h>
  19. #include <linux/gpio.h>
  20. #include <linux/leds.h>
  21. #include <linux/spi/spi.h>
  22. #include <linux/i2c.h>
  23. #include <linux/mfd/da903x.h>
  24. #include <linux/sht15.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <asm/mach/flash.h>
  29. #include <mach/pxa27x.h>
  30. #include <plat/i2c.h>
  31. #include <mach/udc.h>
  32. #include <mach/mmc.h>
  33. #include <mach/pxa2xx_spi.h>
  34. #include <mach/pxa27x-udc.h>
  35. #include "devices.h"
  36. #include "generic.h"
  37. static unsigned long imote2_pin_config[] __initdata = {
  38. /* Device Identification for wakeup*/
  39. GPIO102_GPIO,
  40. /* Button */
  41. GPIO91_GPIO,
  42. /* DA9030 */
  43. GPIO1_GPIO,
  44. /* MMC */
  45. GPIO32_MMC_CLK,
  46. GPIO112_MMC_CMD,
  47. GPIO92_MMC_DAT_0,
  48. GPIO109_MMC_DAT_1,
  49. GPIO110_MMC_DAT_2,
  50. GPIO111_MMC_DAT_3,
  51. /* 802.15.4 radio - driver out of mainline */
  52. GPIO22_GPIO, /* CC_RSTN */
  53. GPIO114_GPIO, /* CC_FIFO */
  54. GPIO116_GPIO, /* CC_CCA */
  55. GPIO0_GPIO, /* CC_FIFOP */
  56. GPIO16_GPIO, /* CCSFD */
  57. GPIO39_GPIO, /* CSn */
  58. GPIO115_GPIO, /* Power enable */
  59. /* I2C */
  60. GPIO117_I2C_SCL,
  61. GPIO118_I2C_SDA,
  62. /* SSP 3 - 802.15.4 radio */
  63. GPIO39_GPIO, /* Chip Select */
  64. GPIO34_SSP3_SCLK,
  65. GPIO35_SSP3_TXD,
  66. GPIO41_SSP3_RXD,
  67. /* SSP 2 - to daughter boards */
  68. GPIO37_GPIO, /* Chip Select */
  69. GPIO36_SSP2_SCLK,
  70. GPIO38_SSP2_TXD,
  71. GPIO11_SSP2_RXD,
  72. /* SSP 1 - to daughter boards */
  73. GPIO24_GPIO, /* Chip Select */
  74. GPIO23_SSP1_SCLK,
  75. GPIO25_SSP1_TXD,
  76. GPIO26_SSP1_RXD,
  77. /* BTUART Basic Connector*/
  78. GPIO42_BTUART_RXD,
  79. GPIO43_BTUART_TXD,
  80. GPIO44_BTUART_CTS,
  81. GPIO45_BTUART_RTS,
  82. /* STUART Serial console via debug board*/
  83. GPIO46_STUART_RXD,
  84. GPIO47_STUART_TXD,
  85. /* Basic sensor board */
  86. GPIO96_GPIO, /* accelerometer interrupt */
  87. GPIO99_GPIO, /* ADC interrupt */
  88. /* SHT15 */
  89. GPIO100_GPIO,
  90. GPIO98_GPIO,
  91. /* Connector pins specified as gpios */
  92. GPIO94_GPIO, /* large basic connector pin 14 */
  93. GPIO10_GPIO, /* large basic connector pin 23 */
  94. /* LEDS */
  95. GPIO103_GPIO, /* red led */
  96. GPIO104_GPIO, /* green led */
  97. GPIO105_GPIO, /* blue led */
  98. };
  99. static struct sht15_platform_data platform_data_sht15 = {
  100. .gpio_data = 100,
  101. .gpio_sck = 98,
  102. };
  103. static struct platform_device sht15 = {
  104. .name = "sht15",
  105. .id = -1,
  106. .dev = {
  107. .platform_data = &platform_data_sht15,
  108. },
  109. };
  110. static struct regulator_consumer_supply imote2_sensor_3_con[] = {
  111. {
  112. .dev = &sht15.dev,
  113. .supply = "vcc",
  114. },
  115. };
  116. static struct gpio_led imote2_led_pins[] = {
  117. {
  118. .name = "imote2:red",
  119. .gpio = 103,
  120. .active_low = 1,
  121. }, {
  122. .name = "imote2:green",
  123. .gpio = 104,
  124. .active_low = 1,
  125. }, {
  126. .name = "imote2:blue",
  127. .gpio = 105,
  128. .active_low = 1,
  129. },
  130. };
  131. static struct gpio_led_platform_data imote2_led_data = {
  132. .num_leds = ARRAY_SIZE(imote2_led_pins),
  133. .leds = imote2_led_pins,
  134. };
  135. static struct platform_device imote2_leds = {
  136. .name = "leds-gpio",
  137. .id = -1,
  138. .dev = {
  139. .platform_data = &imote2_led_data,
  140. },
  141. };
  142. /* Reverse engineered partly from Platformx drivers */
  143. enum imote2_ldos{
  144. vcc_vref,
  145. vcc_cc2420,
  146. vcc_mica,
  147. vcc_bt,
  148. /* The two voltages available to sensor boards */
  149. vcc_sensor_1_8,
  150. vcc_sensor_3,
  151. vcc_sram_ext, /* directly connected to the pxa271 */
  152. vcc_pxa_pll,
  153. vcc_pxa_usim, /* Reference voltage for certain gpios */
  154. vcc_pxa_mem,
  155. vcc_pxa_flash,
  156. vcc_pxa_core, /*Dc-Dc buck not yet supported */
  157. vcc_lcd,
  158. vcc_bb,
  159. vcc_bbio,
  160. vcc_io, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
  161. };
  162. /* The values of the various regulator constraints are obviously dependent
  163. * on exactly what is wired to each ldo. Unfortunately this information is
  164. * not generally available. More information has been requested from Xbow
  165. * but as of yet they haven't been forthcoming.
  166. *
  167. * Some of these are clearly Stargate 2 related (no way of plugging
  168. * in an lcd on the IM2 for example!).
  169. */
  170. static struct regulator_init_data imote2_ldo_init_data[] = {
  171. [vcc_bbio] = {
  172. .constraints = { /* board default 1.8V */
  173. .name = "vcc_bbio",
  174. .min_uV = 1800000,
  175. .max_uV = 1800000,
  176. },
  177. },
  178. [vcc_bb] = {
  179. .constraints = { /* board default 2.8V */
  180. .name = "vcc_bb",
  181. .min_uV = 2700000,
  182. .max_uV = 3000000,
  183. },
  184. },
  185. [vcc_pxa_flash] = {
  186. .constraints = {/* default is 1.8V */
  187. .name = "vcc_pxa_flash",
  188. .min_uV = 1800000,
  189. .max_uV = 1800000,
  190. },
  191. },
  192. [vcc_cc2420] = { /* also vcc_io */
  193. .constraints = {
  194. /* board default is 2.8V */
  195. .name = "vcc_cc2420",
  196. .min_uV = 2700000,
  197. .max_uV = 3300000,
  198. },
  199. },
  200. [vcc_vref] = { /* Reference for what? */
  201. .constraints = { /* default 1.8V */
  202. .name = "vcc_vref",
  203. .min_uV = 1800000,
  204. .max_uV = 1800000,
  205. },
  206. },
  207. [vcc_sram_ext] = {
  208. .constraints = { /* default 2.8V */
  209. .name = "vcc_sram_ext",
  210. .min_uV = 2800000,
  211. .max_uV = 2800000,
  212. },
  213. },
  214. [vcc_mica] = {
  215. .constraints = { /* default 2.8V */
  216. .name = "vcc_mica",
  217. .min_uV = 2800000,
  218. .max_uV = 2800000,
  219. },
  220. },
  221. [vcc_bt] = {
  222. .constraints = { /* default 2.8V */
  223. .name = "vcc_bt",
  224. .min_uV = 2800000,
  225. .max_uV = 2800000,
  226. },
  227. },
  228. [vcc_lcd] = {
  229. .constraints = { /* default 2.8V */
  230. .name = "vcc_lcd",
  231. .min_uV = 2700000,
  232. .max_uV = 3300000,
  233. },
  234. },
  235. [vcc_io] = { /* Same or higher than everything
  236. * bar vccbat and vccusb */
  237. .constraints = { /* default 2.8V */
  238. .name = "vcc_io",
  239. .min_uV = 2692000,
  240. .max_uV = 3300000,
  241. },
  242. },
  243. [vcc_sensor_1_8] = {
  244. .constraints = { /* default 1.8V */
  245. .name = "vcc_sensor_1_8",
  246. .min_uV = 1800000,
  247. .max_uV = 1800000,
  248. },
  249. },
  250. [vcc_sensor_3] = { /* curiously default 2.8V */
  251. .constraints = {
  252. .name = "vcc_sensor_3",
  253. .min_uV = 2800000,
  254. .max_uV = 3000000,
  255. },
  256. .num_consumer_supplies = ARRAY_SIZE(imote2_sensor_3_con),
  257. .consumer_supplies = imote2_sensor_3_con,
  258. },
  259. [vcc_pxa_pll] = { /* 1.17V - 1.43V, default 1.3V*/
  260. .constraints = {
  261. .name = "vcc_pxa_pll",
  262. .min_uV = 1170000,
  263. .max_uV = 1430000,
  264. },
  265. },
  266. [vcc_pxa_usim] = {
  267. .constraints = { /* default 1.8V */
  268. .name = "vcc_pxa_usim",
  269. .min_uV = 1710000,
  270. .max_uV = 2160000,
  271. },
  272. },
  273. [vcc_pxa_mem] = {
  274. .constraints = { /* default 1.8V */
  275. .name = "vcc_pxa_mem",
  276. .min_uV = 1800000,
  277. .max_uV = 1800000,
  278. },
  279. },
  280. };
  281. static struct da903x_subdev_info imote2_da9030_subdevs[] = {
  282. {
  283. .name = "da903x-regulator",
  284. .id = DA9030_ID_LDO2,
  285. .platform_data = &imote2_ldo_init_data[vcc_bbio],
  286. }, {
  287. .name = "da903x-regulator",
  288. .id = DA9030_ID_LDO3,
  289. .platform_data = &imote2_ldo_init_data[vcc_bb],
  290. }, {
  291. .name = "da903x-regulator",
  292. .id = DA9030_ID_LDO4,
  293. .platform_data = &imote2_ldo_init_data[vcc_pxa_flash],
  294. }, {
  295. .name = "da903x-regulator",
  296. .id = DA9030_ID_LDO5,
  297. .platform_data = &imote2_ldo_init_data[vcc_cc2420],
  298. }, {
  299. .name = "da903x-regulator",
  300. .id = DA9030_ID_LDO6,
  301. .platform_data = &imote2_ldo_init_data[vcc_vref],
  302. }, {
  303. .name = "da903x-regulator",
  304. .id = DA9030_ID_LDO7,
  305. .platform_data = &imote2_ldo_init_data[vcc_sram_ext],
  306. }, {
  307. .name = "da903x-regulator",
  308. .id = DA9030_ID_LDO8,
  309. .platform_data = &imote2_ldo_init_data[vcc_mica],
  310. }, {
  311. .name = "da903x-regulator",
  312. .id = DA9030_ID_LDO9,
  313. .platform_data = &imote2_ldo_init_data[vcc_bt],
  314. }, {
  315. .name = "da903x-regulator",
  316. .id = DA9030_ID_LDO10,
  317. .platform_data = &imote2_ldo_init_data[vcc_sensor_1_8],
  318. }, {
  319. .name = "da903x-regulator",
  320. .id = DA9030_ID_LDO11,
  321. .platform_data = &imote2_ldo_init_data[vcc_sensor_3],
  322. }, {
  323. .name = "da903x-regulator",
  324. .id = DA9030_ID_LDO12,
  325. .platform_data = &imote2_ldo_init_data[vcc_lcd],
  326. }, {
  327. .name = "da903x-regulator",
  328. .id = DA9030_ID_LDO15,
  329. .platform_data = &imote2_ldo_init_data[vcc_pxa_pll],
  330. }, {
  331. .name = "da903x-regulator",
  332. .id = DA9030_ID_LDO17,
  333. .platform_data = &imote2_ldo_init_data[vcc_pxa_usim],
  334. }, {
  335. .name = "da903x-regulator",
  336. .id = DA9030_ID_LDO18,
  337. .platform_data = &imote2_ldo_init_data[vcc_io],
  338. }, {
  339. .name = "da903x-regulator",
  340. .id = DA9030_ID_LDO19,
  341. .platform_data = &imote2_ldo_init_data[vcc_pxa_mem],
  342. },
  343. };
  344. static struct da903x_platform_data imote2_da9030_pdata = {
  345. .num_subdevs = ARRAY_SIZE(imote2_da9030_subdevs),
  346. .subdevs = imote2_da9030_subdevs,
  347. };
  348. /* As the the imote2 doesn't currently have a conventional SD slot
  349. * there is no option to hotplug cards, making all this rather simple
  350. */
  351. static int imote2_mci_get_ro(struct device *dev)
  352. {
  353. return 0;
  354. }
  355. /* Rather simple case as hotplugging not possible */
  356. static struct pxamci_platform_data imote2_mci_platform_data = {
  357. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* default anyway */
  358. .get_ro = imote2_mci_get_ro,
  359. .gpio_card_detect = -1,
  360. .gpio_card_ro = -1,
  361. .gpio_power = -1,
  362. };
  363. static struct mtd_partition imote2flash_partitions[] = {
  364. {
  365. .name = "Bootloader",
  366. .size = 0x00040000,
  367. .offset = 0,
  368. .mask_flags = MTD_WRITEABLE,
  369. }, {
  370. .name = "Kernel",
  371. .size = 0x00200000,
  372. .offset = 0x00040000,
  373. .mask_flags = 0,
  374. }, {
  375. .name = "Filesystem",
  376. .size = 0x01DC0000,
  377. .offset = 0x00240000,
  378. .mask_flags = 0,
  379. },
  380. };
  381. static struct resource flash_resources = {
  382. .start = PXA_CS0_PHYS,
  383. .end = PXA_CS0_PHYS + SZ_32M - 1,
  384. .flags = IORESOURCE_MEM,
  385. };
  386. static struct flash_platform_data imote2_flash_data = {
  387. .map_name = "cfi_probe",
  388. .parts = imote2flash_partitions,
  389. .nr_parts = ARRAY_SIZE(imote2flash_partitions),
  390. .name = "PXA27xOnChipROM",
  391. .width = 2,
  392. };
  393. static struct platform_device imote2_flash_device = {
  394. .name = "pxa2xx-flash",
  395. .id = 0,
  396. .dev = {
  397. .platform_data = &imote2_flash_data,
  398. },
  399. .resource = &flash_resources,
  400. .num_resources = 1,
  401. };
  402. /* Some of the drivers here are out of kernel at the moment (parts of IIO)
  403. * and it may be a while before they are in the mainline.
  404. */
  405. static struct i2c_board_info __initdata imote2_i2c_board_info[] = {
  406. { /* UCAM sensor board */
  407. .type = "max1239",
  408. .addr = 0x35,
  409. }, { /* ITS400 Sensor board only */
  410. .type = "max1363",
  411. .addr = 0x34,
  412. /* Through a nand gate - Also beware, on V2 sensor board the
  413. * pull up resistors are missing.
  414. */
  415. .irq = IRQ_GPIO(99),
  416. }, { /* ITS400 Sensor board only */
  417. .type = "tsl2561",
  418. .addr = 0x49,
  419. /* Through a nand gate - Also beware, on V2 sensor board the
  420. * pull up resistors are missing.
  421. */
  422. .irq = IRQ_GPIO(99),
  423. }, { /* ITS400 Sensor board only */
  424. .type = "tmp175",
  425. .addr = 0x4A,
  426. .irq = IRQ_GPIO(96),
  427. }, { /* IMB400 Multimedia board */
  428. .type = "wm8940",
  429. .addr = 0x1A,
  430. },
  431. };
  432. static struct i2c_board_info __initdata imote2_pwr_i2c_board_info[] = {
  433. {
  434. .type = "da9030",
  435. .addr = 0x49,
  436. .platform_data = &imote2_da9030_pdata,
  437. .irq = gpio_to_irq(1),
  438. },
  439. };
  440. static struct pxa2xx_spi_master pxa_ssp_master_0_info = {
  441. .num_chipselect = 1,
  442. };
  443. static struct pxa2xx_spi_master pxa_ssp_master_1_info = {
  444. .num_chipselect = 1,
  445. };
  446. static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
  447. .num_chipselect = 1,
  448. };
  449. static struct pxa2xx_spi_chip staccel_chip_info = {
  450. .tx_threshold = 8,
  451. .rx_threshold = 8,
  452. .dma_burst_size = 8,
  453. .timeout = 235,
  454. .gpio_cs = 24,
  455. };
  456. static struct pxa2xx_spi_chip cc2420_info = {
  457. .tx_threshold = 8,
  458. .rx_threshold = 8,
  459. .dma_burst_size = 8,
  460. .timeout = 235,
  461. .gpio_cs = 39,
  462. };
  463. static struct spi_board_info spi_board_info[] __initdata = {
  464. { /* Driver in IIO */
  465. .modalias = "lis3l02dq",
  466. .max_speed_hz = 8000000,/* 8MHz max spi frequency at 3V */
  467. .bus_num = 1,
  468. .chip_select = 0,
  469. .controller_data = &staccel_chip_info,
  470. .irq = IRQ_GPIO(96),
  471. }, { /* Driver out of kernel as it needs considerable rewriting */
  472. .modalias = "cc2420",
  473. .max_speed_hz = 6500000,
  474. .bus_num = 3,
  475. .chip_select = 0,
  476. .controller_data = &cc2420_info,
  477. },
  478. };
  479. static void im2_udc_command(int cmd)
  480. {
  481. switch (cmd) {
  482. case PXA2XX_UDC_CMD_CONNECT:
  483. UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
  484. break;
  485. case PXA2XX_UDC_CMD_DISCONNECT:
  486. UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
  487. break;
  488. }
  489. }
  490. static struct pxa2xx_udc_mach_info imote2_udc_info __initdata = {
  491. .udc_command = im2_udc_command,
  492. };
  493. static struct platform_device *imote2_devices[] = {
  494. &imote2_flash_device,
  495. &imote2_leds,
  496. &sht15,
  497. };
  498. static struct i2c_pxa_platform_data i2c_pwr_pdata = {
  499. .fast_mode = 1,
  500. };
  501. static struct i2c_pxa_platform_data i2c_pdata = {
  502. .fast_mode = 1,
  503. };
  504. static void __init imote2_init(void)
  505. {
  506. pxa2xx_mfp_config(ARRAY_AND_SIZE(imote2_pin_config));
  507. /* SPI chip select directions - all other directions should
  508. * be handled by drivers.*/
  509. gpio_direction_output(37, 0);
  510. platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));
  511. pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
  512. pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info);
  513. pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info);
  514. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  515. i2c_register_board_info(0, imote2_i2c_board_info,
  516. ARRAY_SIZE(imote2_i2c_board_info));
  517. i2c_register_board_info(1, imote2_pwr_i2c_board_info,
  518. ARRAY_SIZE(imote2_pwr_i2c_board_info));
  519. pxa27x_set_i2c_power_info(&i2c_pwr_pdata);
  520. pxa_set_i2c_info(&i2c_pdata);
  521. pxa_set_mci_info(&imote2_mci_platform_data);
  522. pxa_set_udc_info(&imote2_udc_info);
  523. }
  524. MACHINE_START(INTELMOTE2, "IMOTE 2")
  525. .phys_io = 0x40000000,
  526. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  527. .map_io = pxa_map_io,
  528. .init_irq = pxa27x_init_irq,
  529. .timer = &pxa_timer,
  530. .init_machine = imote2_init,
  531. .boot_params = 0xA0000100,
  532. MACHINE_END