imote2.c 13 KB

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