stargate2.c 24 KB

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