board-cm-t35.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. /*
  2. * board-cm-t35.c (CompuLab CM-T35 module)
  3. *
  4. * Copyright (C) 2009 CompuLab, Ltd.
  5. * Author: Mike Rapoport <mike@compulab.co.il>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. *
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/input.h>
  26. #include <linux/input/matrix_keypad.h>
  27. #include <linux/delay.h>
  28. #include <linux/gpio.h>
  29. #include <linux/i2c/at24.h>
  30. #include <linux/i2c/twl4030.h>
  31. #include <linux/regulator/machine.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <plat/board.h>
  36. #include <plat/common.h>
  37. #include <plat/mux.h>
  38. #include <plat/nand.h>
  39. #include <plat/gpmc.h>
  40. #include <plat/usb.h>
  41. #include <mach/hardware.h>
  42. #include "mux.h"
  43. #include "sdram-micron-mt46h32m32lf-6.h"
  44. #include "mmc-twl4030.h"
  45. #define CM_T35_GPIO_PENDOWN 57
  46. #define CM_T35_SMSC911X_CS 5
  47. #define CM_T35_SMSC911X_GPIO 163
  48. #define SB_T35_SMSC911X_CS 4
  49. #define SB_T35_SMSC911X_GPIO 65
  50. #define NAND_BLOCK_SIZE SZ_128K
  51. #define GPMC_CS0_BASE 0x60
  52. #define GPMC_CS0_BASE_ADDR (OMAP34XX_GPMC_VIRT + GPMC_CS0_BASE)
  53. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  54. #include <linux/smsc911x.h>
  55. static struct smsc911x_platform_config cm_t35_smsc911x_config = {
  56. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  57. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  58. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  59. .phy_interface = PHY_INTERFACE_MODE_MII,
  60. };
  61. static struct resource cm_t35_smsc911x_resources[] = {
  62. {
  63. .flags = IORESOURCE_MEM,
  64. },
  65. {
  66. .start = OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO),
  67. .end = OMAP_GPIO_IRQ(CM_T35_SMSC911X_GPIO),
  68. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  69. },
  70. };
  71. static struct platform_device cm_t35_smsc911x_device = {
  72. .name = "smsc911x",
  73. .id = 0,
  74. .num_resources = ARRAY_SIZE(cm_t35_smsc911x_resources),
  75. .resource = cm_t35_smsc911x_resources,
  76. .dev = {
  77. .platform_data = &cm_t35_smsc911x_config,
  78. },
  79. };
  80. static struct resource sb_t35_smsc911x_resources[] = {
  81. {
  82. .flags = IORESOURCE_MEM,
  83. },
  84. {
  85. .start = OMAP_GPIO_IRQ(SB_T35_SMSC911X_GPIO),
  86. .end = OMAP_GPIO_IRQ(SB_T35_SMSC911X_GPIO),
  87. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  88. },
  89. };
  90. static struct platform_device sb_t35_smsc911x_device = {
  91. .name = "smsc911x",
  92. .id = 1,
  93. .num_resources = ARRAY_SIZE(sb_t35_smsc911x_resources),
  94. .resource = sb_t35_smsc911x_resources,
  95. .dev = {
  96. .platform_data = &cm_t35_smsc911x_config,
  97. },
  98. };
  99. static void __init cm_t35_init_smsc911x(struct platform_device *dev,
  100. int cs, int irq_gpio)
  101. {
  102. unsigned long cs_mem_base;
  103. if (gpmc_cs_request(cs, SZ_16M, &cs_mem_base) < 0) {
  104. pr_err("CM-T35: Failed request for GPMC mem for smsc911x\n");
  105. return;
  106. }
  107. dev->resource[0].start = cs_mem_base + 0x0;
  108. dev->resource[0].end = cs_mem_base + 0xff;
  109. if ((gpio_request(irq_gpio, "ETH IRQ") == 0) &&
  110. (gpio_direction_input(irq_gpio) == 0)) {
  111. gpio_export(irq_gpio, 0);
  112. } else {
  113. pr_err("CM-T35: could not obtain gpio for SMSC911X IRQ\n");
  114. return;
  115. }
  116. platform_device_register(dev);
  117. }
  118. static void __init cm_t35_init_ethernet(void)
  119. {
  120. cm_t35_init_smsc911x(&cm_t35_smsc911x_device,
  121. CM_T35_SMSC911X_CS, CM_T35_SMSC911X_GPIO);
  122. cm_t35_init_smsc911x(&sb_t35_smsc911x_device,
  123. SB_T35_SMSC911X_CS, SB_T35_SMSC911X_GPIO);
  124. }
  125. #else
  126. static inline void __init cm_t35_init_ethernet(void) { return; }
  127. #endif
  128. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  129. #include <linux/leds.h>
  130. static struct gpio_led cm_t35_leds[] = {
  131. [0] = {
  132. .gpio = 186,
  133. .name = "cm-t35:green",
  134. .default_trigger = "heartbeat",
  135. .active_low = 0,
  136. },
  137. };
  138. static struct gpio_led_platform_data cm_t35_led_pdata = {
  139. .num_leds = ARRAY_SIZE(cm_t35_leds),
  140. .leds = cm_t35_leds,
  141. };
  142. static struct platform_device cm_t35_led_device = {
  143. .name = "leds-gpio",
  144. .id = -1,
  145. .dev = {
  146. .platform_data = &cm_t35_led_pdata,
  147. },
  148. };
  149. static void __init cm_t35_init_led(void)
  150. {
  151. platform_device_register(&cm_t35_led_device);
  152. }
  153. #else
  154. static inline void cm_t35_init_led(void) {}
  155. #endif
  156. #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
  157. #include <linux/mtd/mtd.h>
  158. #include <linux/mtd/nand.h>
  159. #include <linux/mtd/partitions.h>
  160. static struct mtd_partition cm_t35_nand_partitions[] = {
  161. {
  162. .name = "xloader",
  163. .offset = 0, /* Offset = 0x00000 */
  164. .size = 4 * NAND_BLOCK_SIZE,
  165. .mask_flags = MTD_WRITEABLE
  166. },
  167. {
  168. .name = "uboot",
  169. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  170. .size = 15 * NAND_BLOCK_SIZE,
  171. },
  172. {
  173. .name = "uboot environment",
  174. .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
  175. .size = 2 * NAND_BLOCK_SIZE,
  176. },
  177. {
  178. .name = "linux",
  179. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  180. .size = 32 * NAND_BLOCK_SIZE,
  181. },
  182. {
  183. .name = "rootfs",
  184. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  185. .size = MTDPART_SIZ_FULL,
  186. },
  187. };
  188. static struct omap_nand_platform_data cm_t35_nand_data = {
  189. .parts = cm_t35_nand_partitions,
  190. .nr_parts = ARRAY_SIZE(cm_t35_nand_partitions),
  191. .dma_channel = -1, /* disable DMA in OMAP NAND driver */
  192. .cs = 0,
  193. .gpmc_cs_baseaddr = (void __iomem *)GPMC_CS0_BASE_ADDR,
  194. .gpmc_baseaddr = (void __iomem *)OMAP34XX_GPMC_VIRT,
  195. };
  196. static struct resource cm_t35_nand_resource = {
  197. .flags = IORESOURCE_MEM,
  198. };
  199. static struct platform_device cm_t35_nand_device = {
  200. .name = "omap2-nand",
  201. .id = -1,
  202. .num_resources = 1,
  203. .resource = &cm_t35_nand_resource,
  204. .dev = {
  205. .platform_data = &cm_t35_nand_data,
  206. },
  207. };
  208. static void __init cm_t35_init_nand(void)
  209. {
  210. if (platform_device_register(&cm_t35_nand_device) < 0)
  211. pr_err("CM-T35: Unable to register NAND device\n");
  212. }
  213. #else
  214. static inline void cm_t35_init_nand(void) {}
  215. #endif
  216. #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
  217. defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
  218. #include <linux/spi/spi.h>
  219. #include <linux/spi/ads7846.h>
  220. #include <plat/mcspi.h>
  221. static struct omap2_mcspi_device_config ads7846_mcspi_config = {
  222. .turbo_mode = 0,
  223. .single_channel = 1, /* 0: slave, 1: master */
  224. };
  225. static int ads7846_get_pendown_state(void)
  226. {
  227. return !gpio_get_value(CM_T35_GPIO_PENDOWN);
  228. }
  229. static struct ads7846_platform_data ads7846_config = {
  230. .x_max = 0x0fff,
  231. .y_max = 0x0fff,
  232. .x_plate_ohms = 180,
  233. .pressure_max = 255,
  234. .debounce_max = 10,
  235. .debounce_tol = 3,
  236. .debounce_rep = 1,
  237. .get_pendown_state = ads7846_get_pendown_state,
  238. .keep_vref_on = 1,
  239. };
  240. static struct spi_board_info cm_t35_spi_board_info[] __initdata = {
  241. {
  242. .modalias = "ads7846",
  243. .bus_num = 1,
  244. .chip_select = 0,
  245. .max_speed_hz = 1500000,
  246. .controller_data = &ads7846_mcspi_config,
  247. .irq = OMAP_GPIO_IRQ(CM_T35_GPIO_PENDOWN),
  248. .platform_data = &ads7846_config,
  249. },
  250. };
  251. static void __init cm_t35_init_ads7846(void)
  252. {
  253. if ((gpio_request(CM_T35_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
  254. (gpio_direction_input(CM_T35_GPIO_PENDOWN) == 0)) {
  255. gpio_export(CM_T35_GPIO_PENDOWN, 0);
  256. } else {
  257. pr_err("CM-T35: could not obtain gpio for ADS7846_PENDOWN\n");
  258. return;
  259. }
  260. spi_register_board_info(cm_t35_spi_board_info,
  261. ARRAY_SIZE(cm_t35_spi_board_info));
  262. }
  263. #else
  264. static inline void cm_t35_init_ads7846(void) {}
  265. #endif
  266. static struct regulator_consumer_supply cm_t35_vmmc1_supply = {
  267. .supply = "vmmc",
  268. };
  269. static struct regulator_consumer_supply cm_t35_vsim_supply = {
  270. .supply = "vmmc_aux",
  271. };
  272. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  273. static struct regulator_init_data cm_t35_vmmc1 = {
  274. .constraints = {
  275. .min_uV = 1850000,
  276. .max_uV = 3150000,
  277. .valid_modes_mask = REGULATOR_MODE_NORMAL
  278. | REGULATOR_MODE_STANDBY,
  279. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  280. | REGULATOR_CHANGE_MODE
  281. | REGULATOR_CHANGE_STATUS,
  282. },
  283. .num_consumer_supplies = 1,
  284. .consumer_supplies = &cm_t35_vmmc1_supply,
  285. };
  286. /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
  287. static struct regulator_init_data cm_t35_vsim = {
  288. .constraints = {
  289. .min_uV = 1800000,
  290. .max_uV = 3000000,
  291. .valid_modes_mask = REGULATOR_MODE_NORMAL
  292. | REGULATOR_MODE_STANDBY,
  293. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  294. | REGULATOR_CHANGE_MODE
  295. | REGULATOR_CHANGE_STATUS,
  296. },
  297. .num_consumer_supplies = 1,
  298. .consumer_supplies = &cm_t35_vsim_supply,
  299. };
  300. static struct twl4030_usb_data cm_t35_usb_data = {
  301. .usb_mode = T2_USB_MODE_ULPI,
  302. };
  303. static int cm_t35_keymap[] = {
  304. KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_LEFT),
  305. KEY(1, 0, KEY_UP), KEY(1, 1, KEY_ENTER), KEY(1, 2, KEY_DOWN),
  306. KEY(2, 0, KEY_RIGHT), KEY(2, 1, KEY_C), KEY(2, 2, KEY_D),
  307. };
  308. static struct matrix_keymap_data cm_t35_keymap_data = {
  309. .keymap = cm_t35_keymap,
  310. .keymap_size = ARRAY_SIZE(cm_t35_keymap),
  311. };
  312. static struct twl4030_keypad_data cm_t35_kp_data = {
  313. .keymap_data = &cm_t35_keymap_data,
  314. .rows = 3,
  315. .cols = 3,
  316. .rep = 1,
  317. };
  318. static struct twl4030_hsmmc_info mmc[] = {
  319. {
  320. .mmc = 1,
  321. .wires = 4,
  322. .gpio_cd = -EINVAL,
  323. .gpio_wp = -EINVAL,
  324. },
  325. {
  326. .mmc = 2,
  327. .wires = 4,
  328. .transceiver = 1,
  329. .gpio_cd = -EINVAL,
  330. .gpio_wp = -EINVAL,
  331. .ocr_mask = 0x00100000, /* 3.3V */
  332. },
  333. {} /* Terminator */
  334. };
  335. static struct ehci_hcd_omap_platform_data ehci_pdata = {
  336. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  337. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  338. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  339. .phy_reset = true,
  340. .reset_gpio_port[0] = -EINVAL,
  341. .reset_gpio_port[1] = -EINVAL,
  342. .reset_gpio_port[2] = -EINVAL
  343. };
  344. static int cm_t35_twl_gpio_setup(struct device *dev, unsigned gpio,
  345. unsigned ngpio)
  346. {
  347. int wlan_rst = gpio + 2;
  348. if ((gpio_request(wlan_rst, "WLAN RST") == 0) &&
  349. (gpio_direction_output(wlan_rst, 1) == 0)) {
  350. gpio_export(wlan_rst, 0);
  351. udelay(10);
  352. gpio_set_value(wlan_rst, 0);
  353. udelay(10);
  354. gpio_set_value(wlan_rst, 1);
  355. } else {
  356. pr_err("CM-T35: could not obtain gpio for WiFi reset\n");
  357. }
  358. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  359. mmc[0].gpio_cd = gpio + 0;
  360. twl4030_mmc_init(mmc);
  361. /* link regulators to MMC adapters */
  362. cm_t35_vmmc1_supply.dev = mmc[0].dev;
  363. cm_t35_vsim_supply.dev = mmc[0].dev;
  364. /* setup USB with proper PHY reset GPIOs */
  365. ehci_pdata.reset_gpio_port[0] = gpio + 6;
  366. ehci_pdata.reset_gpio_port[1] = gpio + 7;
  367. usb_ehci_init(&ehci_pdata);
  368. return 0;
  369. }
  370. static struct twl4030_gpio_platform_data cm_t35_gpio_data = {
  371. .gpio_base = OMAP_MAX_GPIO_LINES,
  372. .irq_base = TWL4030_GPIO_IRQ_BASE,
  373. .irq_end = TWL4030_GPIO_IRQ_END,
  374. .setup = cm_t35_twl_gpio_setup,
  375. };
  376. static struct twl4030_platform_data cm_t35_twldata = {
  377. .irq_base = TWL4030_IRQ_BASE,
  378. .irq_end = TWL4030_IRQ_END,
  379. /* platform_data for children goes here */
  380. .keypad = &cm_t35_kp_data,
  381. .usb = &cm_t35_usb_data,
  382. .gpio = &cm_t35_gpio_data,
  383. .vmmc1 = &cm_t35_vmmc1,
  384. .vsim = &cm_t35_vsim,
  385. };
  386. static struct i2c_board_info __initdata cm_t35_i2c_boardinfo[] = {
  387. {
  388. I2C_BOARD_INFO("tps65930", 0x48),
  389. .flags = I2C_CLIENT_WAKE,
  390. .irq = INT_34XX_SYS_NIRQ,
  391. .platform_data = &cm_t35_twldata,
  392. },
  393. };
  394. static void __init cm_t35_init_i2c(void)
  395. {
  396. omap_register_i2c_bus(1, 2600, cm_t35_i2c_boardinfo,
  397. ARRAY_SIZE(cm_t35_i2c_boardinfo));
  398. }
  399. static struct omap_board_config_kernel cm_t35_config[] __initdata = {
  400. };
  401. static void __init cm_t35_init_irq(void)
  402. {
  403. omap_board_config = cm_t35_config;
  404. omap_board_config_size = ARRAY_SIZE(cm_t35_config);
  405. omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
  406. mt46h32m32lf6_sdrc_params);
  407. omap_init_irq();
  408. omap_gpio_init();
  409. }
  410. static void __init cm_t35_map_io(void)
  411. {
  412. omap2_set_globals_343x();
  413. omap2_map_common_io();
  414. }
  415. #ifdef CONFIG_OMAP_MUX
  416. static struct omap_board_mux board_mux[] __initdata = {
  417. { .reg_offset = OMAP_MUX_TERMINATOR },
  418. };
  419. #else
  420. #define board_mux NULL
  421. #endif
  422. static void __init cm_t35_init(void)
  423. {
  424. omap3_mux_init(board_mux, OMAP_PACKAGE_CUS);
  425. omap_serial_init();
  426. cm_t35_init_i2c();
  427. cm_t35_init_nand();
  428. cm_t35_init_ads7846();
  429. cm_t35_init_ethernet();
  430. cm_t35_init_led();
  431. usb_musb_init();
  432. omap_mux_init_signal("sys_nirq",
  433. OMAP_WAKEUP_EN | OMAP_PIN_INPUT_PULLUP);
  434. }
  435. MACHINE_START(CM_T35, "Compulab CM-T35")
  436. .phys_io = 0x48000000,
  437. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  438. .boot_params = 0x80000100,
  439. .map_io = cm_t35_map_io,
  440. .init_irq = cm_t35_init_irq,
  441. .init_machine = cm_t35_init,
  442. .timer = &omap_timer,
  443. MACHINE_END