stargate2.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. /*
  2. * linux/arch/arm/mach-pxa/stargate2.c
  3. *
  4. * Author: Ed C. Epp
  5. * Created: Nov 05, 2002
  6. * Copyright: Intel Corp.
  7. *
  8. * Modified 2009: Jonathan Cameron <jic23@cam.ac.uk>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/device.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/sched.h>
  18. #include <linux/bitops.h>
  19. #include <linux/fb.h>
  20. #include <linux/delay.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/regulator/machine.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/plat-ram.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/i2c/pxa-i2c.h>
  27. #include <linux/i2c/pcf857x.h>
  28. #include <linux/platform_data/at24.h>
  29. #include <linux/smc91x.h>
  30. #include <linux/gpio.h>
  31. #include <linux/leds.h>
  32. #include <asm/types.h>
  33. #include <asm/setup.h>
  34. #include <asm/memory.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/irq.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/mach/map.h>
  39. #include <asm/mach/irq.h>
  40. #include <asm/mach/flash.h>
  41. #include "pxa27x.h"
  42. #include <linux/platform_data/mmc-pxamci.h>
  43. #include "udc.h"
  44. #include "pxa27x-udc.h"
  45. #include <mach/smemc.h>
  46. #include <linux/spi/spi.h>
  47. #include <linux/spi/pxa2xx_spi.h>
  48. #include <linux/mfd/da903x.h>
  49. #include <linux/platform_data/sht15.h>
  50. #include "devices.h"
  51. #include "generic.h"
  52. #define STARGATE_NR_IRQS (IRQ_BOARD_START + 8)
  53. /* Bluetooth */
  54. #define SG2_BT_RESET 81
  55. /* SD */
  56. #define SG2_GPIO_nSD_DETECT 90
  57. #define SG2_SD_POWER_ENABLE 89
  58. static unsigned long sg2_im2_unified_pin_config[] __initdata = {
  59. /* Device Identification for wakeup*/
  60. GPIO102_GPIO,
  61. /* DA9030 */
  62. GPIO1_GPIO,
  63. /* MMC */
  64. GPIO32_MMC_CLK,
  65. GPIO112_MMC_CMD,
  66. GPIO92_MMC_DAT_0,
  67. GPIO109_MMC_DAT_1,
  68. GPIO110_MMC_DAT_2,
  69. GPIO111_MMC_DAT_3,
  70. /* 802.15.4 radio - driver out of mainline */
  71. GPIO22_GPIO, /* CC_RSTN */
  72. GPIO114_GPIO, /* CC_FIFO */
  73. GPIO116_GPIO, /* CC_CCA */
  74. GPIO0_GPIO, /* CC_FIFOP */
  75. GPIO16_GPIO, /* CCSFD */
  76. GPIO115_GPIO, /* Power enable */
  77. /* I2C */
  78. GPIO117_I2C_SCL,
  79. GPIO118_I2C_SDA,
  80. /* SSP 3 - 802.15.4 radio */
  81. GPIO39_GPIO, /* Chip Select */
  82. GPIO34_SSP3_SCLK,
  83. GPIO35_SSP3_TXD,
  84. GPIO41_SSP3_RXD,
  85. /* SSP 2 to daughter boards */
  86. GPIO11_SSP2_RXD,
  87. GPIO38_SSP2_TXD,
  88. GPIO36_SSP2_SCLK,
  89. GPIO37_GPIO, /* chip select */
  90. /* SSP 1 - to daughter boards */
  91. GPIO24_GPIO, /* Chip Select */
  92. GPIO23_SSP1_SCLK,
  93. GPIO25_SSP1_TXD,
  94. GPIO26_SSP1_RXD,
  95. /* BTUART Basic Connector*/
  96. GPIO42_BTUART_RXD,
  97. GPIO43_BTUART_TXD,
  98. GPIO44_BTUART_CTS,
  99. GPIO45_BTUART_RTS,
  100. /* STUART - IM2 via debug board not sure on SG2*/
  101. GPIO46_STUART_RXD,
  102. GPIO47_STUART_TXD,
  103. /* Basic sensor board */
  104. GPIO96_GPIO, /* accelerometer interrupt */
  105. GPIO99_GPIO, /* ADC interrupt */
  106. /* SHT15 */
  107. GPIO100_GPIO,
  108. GPIO98_GPIO,
  109. /* Basic sensor board */
  110. GPIO96_GPIO, /* accelerometer interrupt */
  111. GPIO99_GPIO, /* ADC interrupt */
  112. /* Connector pins specified as gpios */
  113. GPIO94_GPIO, /* large basic connector pin 14 */
  114. GPIO10_GPIO, /* large basic connector pin 23 */
  115. };
  116. static struct sht15_platform_data platform_data_sht15 = {
  117. .gpio_data = 100,
  118. .gpio_sck = 98,
  119. };
  120. static struct platform_device sht15 = {
  121. .name = "sht15",
  122. .id = -1,
  123. .dev = {
  124. .platform_data = &platform_data_sht15,
  125. },
  126. };
  127. static struct regulator_consumer_supply stargate2_sensor_3_con[] = {
  128. REGULATOR_SUPPLY("vcc", "sht15"),
  129. };
  130. enum stargate2_ldos{
  131. vcc_vref,
  132. vcc_cc2420,
  133. /* a mote connector? */
  134. vcc_mica,
  135. /* the CSR bluecore chip */
  136. vcc_bt,
  137. /* The two voltages available to sensor boards */
  138. vcc_sensor_1_8,
  139. vcc_sensor_3,
  140. /* directly connected to the pxa27x */
  141. vcc_sram_ext,
  142. vcc_pxa_pll,
  143. vcc_pxa_usim, /* Reference voltage for certain gpios */
  144. vcc_pxa_mem,
  145. vcc_pxa_flash,
  146. vcc_pxa_core, /*Dc-Dc buck not yet supported */
  147. vcc_lcd,
  148. vcc_bb,
  149. vcc_bbio, /*not sure!*/
  150. vcc_io, /* cc2420 802.15.4 radio and pxa vcc_io ?*/
  151. };
  152. /* The values of the various regulator constraints are obviously dependent
  153. * on exactly what is wired to each ldo. Unfortunately this information is
  154. * not generally available. More information has been requested from Xbow.
  155. */
  156. static struct regulator_init_data stargate2_ldo_init_data[] = {
  157. [vcc_bbio] = {
  158. .constraints = { /* board default 1.8V */
  159. .name = "vcc_bbio",
  160. .min_uV = 1800000,
  161. .max_uV = 1800000,
  162. },
  163. },
  164. [vcc_bb] = {
  165. .constraints = { /* board default 2.8V */
  166. .name = "vcc_bb",
  167. .min_uV = 2700000,
  168. .max_uV = 3000000,
  169. },
  170. },
  171. [vcc_pxa_flash] = {
  172. .constraints = {/* default is 1.8V */
  173. .name = "vcc_pxa_flash",
  174. .min_uV = 1800000,
  175. .max_uV = 1800000,
  176. },
  177. },
  178. [vcc_cc2420] = { /* also vcc_io */
  179. .constraints = {
  180. /* board default is 2.8V */
  181. .name = "vcc_cc2420",
  182. .min_uV = 2700000,
  183. .max_uV = 3300000,
  184. },
  185. },
  186. [vcc_vref] = { /* Reference for what? */
  187. .constraints = { /* default 1.8V */
  188. .name = "vcc_vref",
  189. .min_uV = 1800000,
  190. .max_uV = 1800000,
  191. },
  192. },
  193. [vcc_sram_ext] = {
  194. .constraints = { /* default 2.8V */
  195. .name = "vcc_sram_ext",
  196. .min_uV = 2800000,
  197. .max_uV = 2800000,
  198. },
  199. },
  200. [vcc_mica] = {
  201. .constraints = { /* default 2.8V */
  202. .name = "vcc_mica",
  203. .min_uV = 2800000,
  204. .max_uV = 2800000,
  205. },
  206. },
  207. [vcc_bt] = {
  208. .constraints = { /* default 2.8V */
  209. .name = "vcc_bt",
  210. .min_uV = 2800000,
  211. .max_uV = 2800000,
  212. },
  213. },
  214. [vcc_lcd] = {
  215. .constraints = { /* default 2.8V */
  216. .name = "vcc_lcd",
  217. .min_uV = 2700000,
  218. .max_uV = 3300000,
  219. },
  220. },
  221. [vcc_io] = { /* Same or higher than everything
  222. * bar vccbat and vccusb */
  223. .constraints = { /* default 2.8V */
  224. .name = "vcc_io",
  225. .min_uV = 2692000,
  226. .max_uV = 3300000,
  227. },
  228. },
  229. [vcc_sensor_1_8] = {
  230. .constraints = { /* default 1.8V */
  231. .name = "vcc_sensor_1_8",
  232. .min_uV = 1800000,
  233. .max_uV = 1800000,
  234. },
  235. },
  236. [vcc_sensor_3] = { /* curiously default 2.8V */
  237. .constraints = {
  238. .name = "vcc_sensor_3",
  239. .min_uV = 2800000,
  240. .max_uV = 3000000,
  241. },
  242. .num_consumer_supplies = ARRAY_SIZE(stargate2_sensor_3_con),
  243. .consumer_supplies = stargate2_sensor_3_con,
  244. },
  245. [vcc_pxa_pll] = { /* 1.17V - 1.43V, default 1.3V*/
  246. .constraints = {
  247. .name = "vcc_pxa_pll",
  248. .min_uV = 1170000,
  249. .max_uV = 1430000,
  250. },
  251. },
  252. [vcc_pxa_usim] = {
  253. .constraints = { /* default 1.8V */
  254. .name = "vcc_pxa_usim",
  255. .min_uV = 1710000,
  256. .max_uV = 2160000,
  257. },
  258. },
  259. [vcc_pxa_mem] = {
  260. .constraints = { /* default 1.8V */
  261. .name = "vcc_pxa_mem",
  262. .min_uV = 1800000,
  263. .max_uV = 1800000,
  264. },
  265. },
  266. };
  267. static struct mtd_partition stargate2flash_partitions[] = {
  268. {
  269. .name = "Bootloader",
  270. .size = 0x00040000,
  271. .offset = 0,
  272. .mask_flags = 0,
  273. }, {
  274. .name = "Kernel",
  275. .size = 0x00200000,
  276. .offset = 0x00040000,
  277. .mask_flags = 0
  278. }, {
  279. .name = "Filesystem",
  280. .size = 0x01DC0000,
  281. .offset = 0x00240000,
  282. .mask_flags = 0
  283. },
  284. };
  285. static struct resource flash_resources = {
  286. .start = PXA_CS0_PHYS,
  287. .end = PXA_CS0_PHYS + SZ_32M - 1,
  288. .flags = IORESOURCE_MEM,
  289. };
  290. static struct flash_platform_data stargate2_flash_data = {
  291. .map_name = "cfi_probe",
  292. .parts = stargate2flash_partitions,
  293. .nr_parts = ARRAY_SIZE(stargate2flash_partitions),
  294. .name = "PXA27xOnChipROM",
  295. .width = 2,
  296. };
  297. static struct platform_device stargate2_flash_device = {
  298. .name = "pxa2xx-flash",
  299. .id = 0,
  300. .dev = {
  301. .platform_data = &stargate2_flash_data,
  302. },
  303. .resource = &flash_resources,
  304. .num_resources = 1,
  305. };
  306. static struct pxa2xx_spi_master pxa_ssp_master_0_info = {
  307. .num_chipselect = 1,
  308. };
  309. static struct pxa2xx_spi_master pxa_ssp_master_1_info = {
  310. .num_chipselect = 1,
  311. };
  312. static struct pxa2xx_spi_master pxa_ssp_master_2_info = {
  313. .num_chipselect = 1,
  314. };
  315. /* An upcoming kernel change will scrap SFRM usage so these
  316. * drivers have been moved to use gpio's via cs_control */
  317. static struct pxa2xx_spi_chip staccel_chip_info = {
  318. .tx_threshold = 8,
  319. .rx_threshold = 8,
  320. .dma_burst_size = 8,
  321. .timeout = 235,
  322. .gpio_cs = 24,
  323. };
  324. static struct pxa2xx_spi_chip cc2420_info = {
  325. .tx_threshold = 8,
  326. .rx_threshold = 8,
  327. .dma_burst_size = 8,
  328. .timeout = 235,
  329. .gpio_cs = 39,
  330. };
  331. static struct spi_board_info spi_board_info[] __initdata = {
  332. {
  333. .modalias = "lis3l02dq",
  334. .max_speed_hz = 8000000,/* 8MHz max spi frequency at 3V */
  335. .bus_num = 1,
  336. .chip_select = 0,
  337. .controller_data = &staccel_chip_info,
  338. .irq = PXA_GPIO_TO_IRQ(96),
  339. }, {
  340. .modalias = "cc2420",
  341. .max_speed_hz = 6500000,
  342. .bus_num = 3,
  343. .chip_select = 0,
  344. .controller_data = &cc2420_info,
  345. },
  346. };
  347. static void sg2_udc_command(int cmd)
  348. {
  349. switch (cmd) {
  350. case PXA2XX_UDC_CMD_CONNECT:
  351. UP2OCR |= UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE;
  352. break;
  353. case PXA2XX_UDC_CMD_DISCONNECT:
  354. UP2OCR &= ~(UP2OCR_HXOE | UP2OCR_DPPUE | UP2OCR_DPPUBE);
  355. break;
  356. }
  357. }
  358. static struct i2c_pxa_platform_data i2c_pwr_pdata = {
  359. .fast_mode = 1,
  360. };
  361. static struct i2c_pxa_platform_data i2c_pdata = {
  362. .fast_mode = 1,
  363. };
  364. static void __init imote2_stargate2_init(void)
  365. {
  366. pxa2xx_mfp_config(ARRAY_AND_SIZE(sg2_im2_unified_pin_config));
  367. pxa_set_ffuart_info(NULL);
  368. pxa_set_btuart_info(NULL);
  369. pxa_set_stuart_info(NULL);
  370. pxa2xx_set_spi_info(1, &pxa_ssp_master_0_info);
  371. pxa2xx_set_spi_info(2, &pxa_ssp_master_1_info);
  372. pxa2xx_set_spi_info(3, &pxa_ssp_master_2_info);
  373. spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
  374. pxa27x_set_i2c_power_info(&i2c_pwr_pdata);
  375. pxa_set_i2c_info(&i2c_pdata);
  376. }
  377. #ifdef CONFIG_MACH_INTELMOTE2
  378. /* As the the imote2 doesn't currently have a conventional SD slot
  379. * there is no option to hotplug cards, making all this rather simple
  380. */
  381. static int imote2_mci_get_ro(struct device *dev)
  382. {
  383. return 0;
  384. }
  385. /* Rather simple case as hotplugging not possible */
  386. static struct pxamci_platform_data imote2_mci_platform_data = {
  387. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* default anyway */
  388. .get_ro = imote2_mci_get_ro,
  389. .gpio_card_detect = -1,
  390. .gpio_card_ro = -1,
  391. .gpio_power = -1,
  392. };
  393. static struct gpio_led imote2_led_pins[] = {
  394. {
  395. .name = "imote2:red",
  396. .gpio = 103,
  397. .active_low = 1,
  398. }, {
  399. .name = "imote2:green",
  400. .gpio = 104,
  401. .active_low = 1,
  402. }, {
  403. .name = "imote2:blue",
  404. .gpio = 105,
  405. .active_low = 1,
  406. },
  407. };
  408. static struct gpio_led_platform_data imote2_led_data = {
  409. .num_leds = ARRAY_SIZE(imote2_led_pins),
  410. .leds = imote2_led_pins,
  411. };
  412. static struct platform_device imote2_leds = {
  413. .name = "leds-gpio",
  414. .id = -1,
  415. .dev = {
  416. .platform_data = &imote2_led_data,
  417. },
  418. };
  419. static struct da903x_subdev_info imote2_da9030_subdevs[] = {
  420. {
  421. .name = "da903x-regulator",
  422. .id = DA9030_ID_LDO2,
  423. .platform_data = &stargate2_ldo_init_data[vcc_bbio],
  424. }, {
  425. .name = "da903x-regulator",
  426. .id = DA9030_ID_LDO3,
  427. .platform_data = &stargate2_ldo_init_data[vcc_bb],
  428. }, {
  429. .name = "da903x-regulator",
  430. .id = DA9030_ID_LDO4,
  431. .platform_data = &stargate2_ldo_init_data[vcc_pxa_flash],
  432. }, {
  433. .name = "da903x-regulator",
  434. .id = DA9030_ID_LDO5,
  435. .platform_data = &stargate2_ldo_init_data[vcc_cc2420],
  436. }, {
  437. .name = "da903x-regulator",
  438. .id = DA9030_ID_LDO6,
  439. .platform_data = &stargate2_ldo_init_data[vcc_vref],
  440. }, {
  441. .name = "da903x-regulator",
  442. .id = DA9030_ID_LDO7,
  443. .platform_data = &stargate2_ldo_init_data[vcc_sram_ext],
  444. }, {
  445. .name = "da903x-regulator",
  446. .id = DA9030_ID_LDO8,
  447. .platform_data = &stargate2_ldo_init_data[vcc_mica],
  448. }, {
  449. .name = "da903x-regulator",
  450. .id = DA9030_ID_LDO9,
  451. .platform_data = &stargate2_ldo_init_data[vcc_bt],
  452. }, {
  453. .name = "da903x-regulator",
  454. .id = DA9030_ID_LDO10,
  455. .platform_data = &stargate2_ldo_init_data[vcc_sensor_1_8],
  456. }, {
  457. .name = "da903x-regulator",
  458. .id = DA9030_ID_LDO11,
  459. .platform_data = &stargate2_ldo_init_data[vcc_sensor_3],
  460. }, {
  461. .name = "da903x-regulator",
  462. .id = DA9030_ID_LDO12,
  463. .platform_data = &stargate2_ldo_init_data[vcc_lcd],
  464. }, {
  465. .name = "da903x-regulator",
  466. .id = DA9030_ID_LDO15,
  467. .platform_data = &stargate2_ldo_init_data[vcc_pxa_pll],
  468. }, {
  469. .name = "da903x-regulator",
  470. .id = DA9030_ID_LDO17,
  471. .platform_data = &stargate2_ldo_init_data[vcc_pxa_usim],
  472. }, {
  473. .name = "da903x-regulator", /*pxa vcc i/o and cc2420 vcc i/o */
  474. .id = DA9030_ID_LDO18,
  475. .platform_data = &stargate2_ldo_init_data[vcc_io],
  476. }, {
  477. .name = "da903x-regulator",
  478. .id = DA9030_ID_LDO19,
  479. .platform_data = &stargate2_ldo_init_data[vcc_pxa_mem],
  480. },
  481. };
  482. static struct da903x_platform_data imote2_da9030_pdata = {
  483. .num_subdevs = ARRAY_SIZE(imote2_da9030_subdevs),
  484. .subdevs = imote2_da9030_subdevs,
  485. };
  486. static struct i2c_board_info __initdata imote2_pwr_i2c_board_info[] = {
  487. {
  488. .type = "da9030",
  489. .addr = 0x49,
  490. .platform_data = &imote2_da9030_pdata,
  491. .irq = PXA_GPIO_TO_IRQ(1),
  492. },
  493. };
  494. static struct i2c_board_info __initdata imote2_i2c_board_info[] = {
  495. { /* UCAM sensor board */
  496. .type = "max1239",
  497. .addr = 0x35,
  498. }, { /* ITS400 Sensor board only */
  499. .type = "max1363",
  500. .addr = 0x34,
  501. /* Through a nand gate - Also beware, on V2 sensor board the
  502. * pull up resistors are missing.
  503. */
  504. .irq = PXA_GPIO_TO_IRQ(99),
  505. }, { /* ITS400 Sensor board only */
  506. .type = "tsl2561",
  507. .addr = 0x49,
  508. /* Through a nand gate - Also beware, on V2 sensor board the
  509. * pull up resistors are missing.
  510. */
  511. .irq = PXA_GPIO_TO_IRQ(99),
  512. }, { /* ITS400 Sensor board only */
  513. .type = "tmp175",
  514. .addr = 0x4A,
  515. .irq = PXA_GPIO_TO_IRQ(96),
  516. }, { /* IMB400 Multimedia board */
  517. .type = "wm8940",
  518. .addr = 0x1A,
  519. },
  520. };
  521. static unsigned long imote2_pin_config[] __initdata = {
  522. /* Button */
  523. GPIO91_GPIO,
  524. /* LEDS */
  525. GPIO103_GPIO, /* red led */
  526. GPIO104_GPIO, /* green led */
  527. GPIO105_GPIO, /* blue led */
  528. };
  529. static struct pxa2xx_udc_mach_info imote2_udc_info __initdata = {
  530. .udc_command = sg2_udc_command,
  531. };
  532. static struct platform_device imote2_audio_device = {
  533. .name = "imote2-audio",
  534. .id = -1,
  535. };
  536. static struct platform_device *imote2_devices[] = {
  537. &stargate2_flash_device,
  538. &imote2_leds,
  539. &sht15,
  540. &imote2_audio_device,
  541. };
  542. static void __init imote2_init(void)
  543. {
  544. pxa2xx_mfp_config(ARRAY_AND_SIZE(imote2_pin_config));
  545. imote2_stargate2_init();
  546. platform_add_devices(imote2_devices, ARRAY_SIZE(imote2_devices));
  547. i2c_register_board_info(0, imote2_i2c_board_info,
  548. ARRAY_SIZE(imote2_i2c_board_info));
  549. i2c_register_board_info(1, imote2_pwr_i2c_board_info,
  550. ARRAY_SIZE(imote2_pwr_i2c_board_info));
  551. pxa_set_mci_info(&imote2_mci_platform_data);
  552. pxa_set_udc_info(&imote2_udc_info);
  553. }
  554. #endif
  555. #ifdef CONFIG_MACH_STARGATE2
  556. static unsigned long stargate2_pin_config[] __initdata = {
  557. GPIO15_nCS_1, /* SRAM */
  558. /* SMC91x */
  559. GPIO80_nCS_4,
  560. GPIO40_GPIO, /*cable detect?*/
  561. /* Button */
  562. GPIO91_GPIO | WAKEUP_ON_LEVEL_HIGH,
  563. /* Compact Flash */
  564. GPIO79_PSKTSEL,
  565. GPIO48_nPOE,
  566. GPIO49_nPWE,
  567. GPIO50_nPIOR,
  568. GPIO51_nPIOW,
  569. GPIO85_nPCE_1,
  570. GPIO54_nPCE_2,
  571. GPIO55_nPREG,
  572. GPIO56_nPWAIT,
  573. GPIO57_nIOIS16,
  574. GPIO120_GPIO, /* Buff ctrl */
  575. GPIO108_GPIO, /* Power ctrl */
  576. GPIO82_GPIO, /* Reset */
  577. GPIO53_GPIO, /* SG2_S0_GPIO_DETECT */
  578. /* MMC not shared with imote2 */
  579. GPIO90_GPIO, /* nSD detect */
  580. GPIO89_GPIO, /* SD_POWER_ENABLE */
  581. /* Bluetooth */
  582. GPIO81_GPIO, /* reset */
  583. };
  584. static struct resource smc91x_resources[] = {
  585. [0] = {
  586. .name = "smc91x-regs",
  587. .start = (PXA_CS4_PHYS + 0x300),
  588. .end = (PXA_CS4_PHYS + 0xfffff),
  589. .flags = IORESOURCE_MEM,
  590. },
  591. [1] = {
  592. .start = PXA_GPIO_TO_IRQ(40),
  593. .end = PXA_GPIO_TO_IRQ(40),
  594. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  595. }
  596. };
  597. static struct smc91x_platdata stargate2_smc91x_info = {
  598. .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT
  599. | SMC91X_NOWAIT | SMC91X_USE_DMA,
  600. };
  601. static struct platform_device smc91x_device = {
  602. .name = "smc91x",
  603. .id = -1,
  604. .num_resources = ARRAY_SIZE(smc91x_resources),
  605. .resource = smc91x_resources,
  606. .dev = {
  607. .platform_data = &stargate2_smc91x_info,
  608. },
  609. };
  610. /*
  611. * The card detect interrupt isn't debounced so we delay it by 250ms
  612. * to give the card a chance to fully insert / eject.
  613. */
  614. static int stargate2_mci_init(struct device *dev,
  615. irq_handler_t stargate2_detect_int,
  616. void *data)
  617. {
  618. int err;
  619. err = gpio_request(SG2_SD_POWER_ENABLE, "SG2_sd_power_enable");
  620. if (err) {
  621. printk(KERN_ERR "Can't get the gpio for SD power control");
  622. goto return_err;
  623. }
  624. gpio_direction_output(SG2_SD_POWER_ENABLE, 0);
  625. err = gpio_request(SG2_GPIO_nSD_DETECT, "SG2_sd_detect");
  626. if (err) {
  627. printk(KERN_ERR "Can't get the sd detect gpio");
  628. goto free_power_en;
  629. }
  630. gpio_direction_input(SG2_GPIO_nSD_DETECT);
  631. err = request_irq(PXA_GPIO_TO_IRQ(SG2_GPIO_nSD_DETECT),
  632. stargate2_detect_int,
  633. IRQ_TYPE_EDGE_BOTH,
  634. "MMC card detect",
  635. data);
  636. if (err) {
  637. printk(KERN_ERR "can't request MMC card detect IRQ\n");
  638. goto free_nsd_detect;
  639. }
  640. return 0;
  641. free_nsd_detect:
  642. gpio_free(SG2_GPIO_nSD_DETECT);
  643. free_power_en:
  644. gpio_free(SG2_SD_POWER_ENABLE);
  645. return_err:
  646. return err;
  647. }
  648. /**
  649. * stargate2_mci_setpower() - set state of mmc power supply
  650. *
  651. * Very simple control. Either it is on or off and is controlled by
  652. * a gpio pin */
  653. static int stargate2_mci_setpower(struct device *dev, unsigned int vdd)
  654. {
  655. gpio_set_value(SG2_SD_POWER_ENABLE, !!vdd);
  656. return 0;
  657. }
  658. static void stargate2_mci_exit(struct device *dev, void *data)
  659. {
  660. free_irq(PXA_GPIO_TO_IRQ(SG2_GPIO_nSD_DETECT), data);
  661. gpio_free(SG2_SD_POWER_ENABLE);
  662. gpio_free(SG2_GPIO_nSD_DETECT);
  663. }
  664. static struct pxamci_platform_data stargate2_mci_platform_data = {
  665. .detect_delay_ms = 250,
  666. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  667. .init = stargate2_mci_init,
  668. .setpower = stargate2_mci_setpower,
  669. .exit = stargate2_mci_exit,
  670. };
  671. /*
  672. * SRAM - The Stargate 2 has 32MB of SRAM.
  673. *
  674. * Here it is made available as an MTD. This will then
  675. * typically have a cifs filesystem created on it to provide
  676. * fast temporary storage.
  677. */
  678. static struct resource sram_resources = {
  679. .start = PXA_CS1_PHYS,
  680. .end = PXA_CS1_PHYS + SZ_32M-1,
  681. .flags = IORESOURCE_MEM,
  682. };
  683. static struct platdata_mtd_ram stargate2_sram_pdata = {
  684. .mapname = "Stargate2 SRAM",
  685. .bankwidth = 2,
  686. };
  687. static struct platform_device stargate2_sram = {
  688. .name = "mtd-ram",
  689. .id = 0,
  690. .resource = &sram_resources,
  691. .num_resources = 1,
  692. .dev = {
  693. .platform_data = &stargate2_sram_pdata,
  694. },
  695. };
  696. static struct pcf857x_platform_data platform_data_pcf857x = {
  697. .gpio_base = 128,
  698. .n_latch = 0,
  699. .setup = NULL,
  700. .teardown = NULL,
  701. .context = NULL,
  702. };
  703. static struct at24_platform_data pca9500_eeprom_pdata = {
  704. .byte_len = 256,
  705. .page_size = 4,
  706. };
  707. /**
  708. * stargate2_reset_bluetooth() reset the bluecore to ensure consistent state
  709. **/
  710. static int stargate2_reset_bluetooth(void)
  711. {
  712. int err;
  713. err = gpio_request(SG2_BT_RESET, "SG2_BT_RESET");
  714. if (err) {
  715. printk(KERN_ERR "Could not get gpio for bluetooth reset\n");
  716. return err;
  717. }
  718. gpio_direction_output(SG2_BT_RESET, 1);
  719. mdelay(5);
  720. /* now reset it - 5 msec minimum */
  721. gpio_set_value(SG2_BT_RESET, 0);
  722. mdelay(10);
  723. gpio_set_value(SG2_BT_RESET, 1);
  724. gpio_free(SG2_BT_RESET);
  725. return 0;
  726. }
  727. static struct led_info stargate2_leds[] = {
  728. {
  729. .name = "sg2:red",
  730. .flags = DA9030_LED_RATE_ON,
  731. }, {
  732. .name = "sg2:blue",
  733. .flags = DA9030_LED_RATE_ON,
  734. }, {
  735. .name = "sg2:green",
  736. .flags = DA9030_LED_RATE_ON,
  737. },
  738. };
  739. static struct da903x_subdev_info stargate2_da9030_subdevs[] = {
  740. {
  741. .name = "da903x-led",
  742. .id = DA9030_ID_LED_2,
  743. .platform_data = &stargate2_leds[0],
  744. }, {
  745. .name = "da903x-led",
  746. .id = DA9030_ID_LED_3,
  747. .platform_data = &stargate2_leds[2],
  748. }, {
  749. .name = "da903x-led",
  750. .id = DA9030_ID_LED_4,
  751. .platform_data = &stargate2_leds[1],
  752. }, {
  753. .name = "da903x-regulator",
  754. .id = DA9030_ID_LDO2,
  755. .platform_data = &stargate2_ldo_init_data[vcc_bbio],
  756. }, {
  757. .name = "da903x-regulator",
  758. .id = DA9030_ID_LDO3,
  759. .platform_data = &stargate2_ldo_init_data[vcc_bb],
  760. }, {
  761. .name = "da903x-regulator",
  762. .id = DA9030_ID_LDO4,
  763. .platform_data = &stargate2_ldo_init_data[vcc_pxa_flash],
  764. }, {
  765. .name = "da903x-regulator",
  766. .id = DA9030_ID_LDO5,
  767. .platform_data = &stargate2_ldo_init_data[vcc_cc2420],
  768. }, {
  769. .name = "da903x-regulator",
  770. .id = DA9030_ID_LDO6,
  771. .platform_data = &stargate2_ldo_init_data[vcc_vref],
  772. }, {
  773. .name = "da903x-regulator",
  774. .id = DA9030_ID_LDO7,
  775. .platform_data = &stargate2_ldo_init_data[vcc_sram_ext],
  776. }, {
  777. .name = "da903x-regulator",
  778. .id = DA9030_ID_LDO8,
  779. .platform_data = &stargate2_ldo_init_data[vcc_mica],
  780. }, {
  781. .name = "da903x-regulator",
  782. .id = DA9030_ID_LDO9,
  783. .platform_data = &stargate2_ldo_init_data[vcc_bt],
  784. }, {
  785. .name = "da903x-regulator",
  786. .id = DA9030_ID_LDO10,
  787. .platform_data = &stargate2_ldo_init_data[vcc_sensor_1_8],
  788. }, {
  789. .name = "da903x-regulator",
  790. .id = DA9030_ID_LDO11,
  791. .platform_data = &stargate2_ldo_init_data[vcc_sensor_3],
  792. }, {
  793. .name = "da903x-regulator",
  794. .id = DA9030_ID_LDO12,
  795. .platform_data = &stargate2_ldo_init_data[vcc_lcd],
  796. }, {
  797. .name = "da903x-regulator",
  798. .id = DA9030_ID_LDO15,
  799. .platform_data = &stargate2_ldo_init_data[vcc_pxa_pll],
  800. }, {
  801. .name = "da903x-regulator",
  802. .id = DA9030_ID_LDO17,
  803. .platform_data = &stargate2_ldo_init_data[vcc_pxa_usim],
  804. }, {
  805. .name = "da903x-regulator", /*pxa vcc i/o and cc2420 vcc i/o */
  806. .id = DA9030_ID_LDO18,
  807. .platform_data = &stargate2_ldo_init_data[vcc_io],
  808. }, {
  809. .name = "da903x-regulator",
  810. .id = DA9030_ID_LDO19,
  811. .platform_data = &stargate2_ldo_init_data[vcc_pxa_mem],
  812. },
  813. };
  814. static struct da903x_platform_data stargate2_da9030_pdata = {
  815. .num_subdevs = ARRAY_SIZE(stargate2_da9030_subdevs),
  816. .subdevs = stargate2_da9030_subdevs,
  817. };
  818. static struct i2c_board_info __initdata stargate2_pwr_i2c_board_info[] = {
  819. {
  820. .type = "da9030",
  821. .addr = 0x49,
  822. .platform_data = &stargate2_da9030_pdata,
  823. .irq = PXA_GPIO_TO_IRQ(1),
  824. },
  825. };
  826. static struct i2c_board_info __initdata stargate2_i2c_board_info[] = {
  827. /* Techically this a pca9500 - but it's compatible with the 8574
  828. * for gpio expansion and the 24c02 for eeprom access.
  829. */
  830. {
  831. .type = "pcf8574",
  832. .addr = 0x27,
  833. .platform_data = &platform_data_pcf857x,
  834. }, {
  835. .type = "24c02",
  836. .addr = 0x57,
  837. .platform_data = &pca9500_eeprom_pdata,
  838. }, {
  839. .type = "max1238",
  840. .addr = 0x35,
  841. }, { /* ITS400 Sensor board only */
  842. .type = "max1363",
  843. .addr = 0x34,
  844. /* Through a nand gate - Also beware, on V2 sensor board the
  845. * pull up resistors are missing.
  846. */
  847. .irq = PXA_GPIO_TO_IRQ(99),
  848. }, { /* ITS400 Sensor board only */
  849. .type = "tsl2561",
  850. .addr = 0x49,
  851. /* Through a nand gate - Also beware, on V2 sensor board the
  852. * pull up resistors are missing.
  853. */
  854. .irq = PXA_GPIO_TO_IRQ(99),
  855. }, { /* ITS400 Sensor board only */
  856. .type = "tmp175",
  857. .addr = 0x4A,
  858. .irq = PXA_GPIO_TO_IRQ(96),
  859. },
  860. };
  861. /* Board doesn't support cable detection - so always lie and say
  862. * something is there.
  863. */
  864. static int sg2_udc_detect(void)
  865. {
  866. return 1;
  867. }
  868. static struct pxa2xx_udc_mach_info stargate2_udc_info __initdata = {
  869. .udc_is_connected = sg2_udc_detect,
  870. .udc_command = sg2_udc_command,
  871. };
  872. static struct platform_device *stargate2_devices[] = {
  873. &stargate2_flash_device,
  874. &stargate2_sram,
  875. &smc91x_device,
  876. &sht15,
  877. };
  878. static void __init stargate2_init(void)
  879. {
  880. /* This is probably a board specific hack as this must be set
  881. prior to connecting the MFP stuff up. */
  882. __raw_writel(__raw_readl(MECR) & ~MECR_NOS, MECR);
  883. pxa2xx_mfp_config(ARRAY_AND_SIZE(stargate2_pin_config));
  884. imote2_stargate2_init();
  885. platform_add_devices(ARRAY_AND_SIZE(stargate2_devices));
  886. i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info));
  887. i2c_register_board_info(1, stargate2_pwr_i2c_board_info,
  888. ARRAY_SIZE(stargate2_pwr_i2c_board_info));
  889. pxa_set_mci_info(&stargate2_mci_platform_data);
  890. pxa_set_udc_info(&stargate2_udc_info);
  891. stargate2_reset_bluetooth();
  892. }
  893. #endif
  894. #ifdef CONFIG_MACH_INTELMOTE2
  895. MACHINE_START(INTELMOTE2, "IMOTE 2")
  896. .map_io = pxa27x_map_io,
  897. .nr_irqs = PXA_NR_IRQS,
  898. .init_irq = pxa27x_init_irq,
  899. .handle_irq = pxa27x_handle_irq,
  900. .init_time = pxa_timer_init,
  901. .init_machine = imote2_init,
  902. .atag_offset = 0x100,
  903. .restart = pxa_restart,
  904. MACHINE_END
  905. #endif
  906. #ifdef CONFIG_MACH_STARGATE2
  907. MACHINE_START(STARGATE2, "Stargate 2")
  908. .map_io = pxa27x_map_io,
  909. .nr_irqs = STARGATE_NR_IRQS,
  910. .init_irq = pxa27x_init_irq,
  911. .handle_irq = pxa27x_handle_irq,
  912. .init_time = pxa_timer_init,
  913. .init_machine = stargate2_init,
  914. .atag_offset = 0x100,
  915. .restart = pxa_restart,
  916. MACHINE_END
  917. #endif