mx31ads.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /*
  2. * Copyright (C) 2000 Deep Blue Solutions Ltd
  3. * Copyright (C) 2002 Shane Nay (shane@minirl.com)
  4. * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/types.h>
  21. #include <linux/init.h>
  22. #include <linux/clk.h>
  23. #include <linux/serial_8250.h>
  24. #include <linux/gpio.h>
  25. #include <linux/i2c.h>
  26. #include <linux/irq.h>
  27. #include <mach/hardware.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/time.h>
  31. #include <asm/memory.h>
  32. #include <asm/mach/map.h>
  33. #include <mach/common.h>
  34. #include <mach/board-mx31ads.h>
  35. #include <mach/imx-uart.h>
  36. #include <mach/iomux-mx3.h>
  37. #ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
  38. #include <linux/mfd/wm8350/audio.h>
  39. #include <linux/mfd/wm8350/core.h>
  40. #include <linux/mfd/wm8350/pmic.h>
  41. #endif
  42. #include "devices.h"
  43. /*!
  44. * @file mx31ads.c
  45. *
  46. * @brief This file contains the board-specific initialization routines.
  47. *
  48. * @ingroup System
  49. */
  50. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
  51. /*!
  52. * The serial port definition structure.
  53. */
  54. static struct plat_serial8250_port serial_platform_data[] = {
  55. {
  56. .membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTA),
  57. .mapbase = (unsigned long)(CS4_BASE_ADDR + PBC_SC16C652_UARTA),
  58. .irq = EXPIO_INT_XUART_INTA,
  59. .uartclk = 14745600,
  60. .regshift = 0,
  61. .iotype = UPIO_MEM,
  62. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ,
  63. }, {
  64. .membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTB),
  65. .mapbase = (unsigned long)(CS4_BASE_ADDR + PBC_SC16C652_UARTB),
  66. .irq = EXPIO_INT_XUART_INTB,
  67. .uartclk = 14745600,
  68. .regshift = 0,
  69. .iotype = UPIO_MEM,
  70. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ,
  71. },
  72. {},
  73. };
  74. static struct platform_device serial_device = {
  75. .name = "serial8250",
  76. .id = 0,
  77. .dev = {
  78. .platform_data = serial_platform_data,
  79. },
  80. };
  81. static int __init mxc_init_extuart(void)
  82. {
  83. return platform_device_register(&serial_device);
  84. }
  85. #else
  86. static inline int mxc_init_extuart(void)
  87. {
  88. return 0;
  89. }
  90. #endif
  91. #if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
  92. static struct imxuart_platform_data uart_pdata = {
  93. .flags = IMXUART_HAVE_RTSCTS,
  94. };
  95. static unsigned int uart_pins[] = {
  96. MX31_PIN_CTS1__CTS1,
  97. MX31_PIN_RTS1__RTS1,
  98. MX31_PIN_TXD1__TXD1,
  99. MX31_PIN_RXD1__RXD1
  100. };
  101. static inline void mxc_init_imx_uart(void)
  102. {
  103. mxc_iomux_setup_multiple_pins(uart_pins, ARRAY_SIZE(uart_pins), "uart-0");
  104. mxc_register_device(&mxc_uart_device0, &uart_pdata);
  105. }
  106. #else /* !SERIAL_IMX */
  107. static inline void mxc_init_imx_uart(void)
  108. {
  109. }
  110. #endif /* !SERIAL_IMX */
  111. static void mx31ads_expio_irq_handler(u32 irq, struct irq_desc *desc)
  112. {
  113. u32 imr_val;
  114. u32 int_valid;
  115. u32 expio_irq;
  116. imr_val = __raw_readw(PBC_INTMASK_SET_REG);
  117. int_valid = __raw_readw(PBC_INTSTATUS_REG) & imr_val;
  118. expio_irq = MXC_EXP_IO_BASE;
  119. for (; int_valid != 0; int_valid >>= 1, expio_irq++) {
  120. if ((int_valid & 1) == 0)
  121. continue;
  122. generic_handle_irq(expio_irq);
  123. }
  124. }
  125. /*
  126. * Disable an expio pin's interrupt by setting the bit in the imr.
  127. * @param irq an expio virtual irq number
  128. */
  129. static void expio_mask_irq(u32 irq)
  130. {
  131. u32 expio = MXC_IRQ_TO_EXPIO(irq);
  132. /* mask the interrupt */
  133. __raw_writew(1 << expio, PBC_INTMASK_CLEAR_REG);
  134. __raw_readw(PBC_INTMASK_CLEAR_REG);
  135. }
  136. /*
  137. * Acknowledge an expanded io pin's interrupt by clearing the bit in the isr.
  138. * @param irq an expanded io virtual irq number
  139. */
  140. static void expio_ack_irq(u32 irq)
  141. {
  142. u32 expio = MXC_IRQ_TO_EXPIO(irq);
  143. /* clear the interrupt status */
  144. __raw_writew(1 << expio, PBC_INTSTATUS_REG);
  145. }
  146. /*
  147. * Enable a expio pin's interrupt by clearing the bit in the imr.
  148. * @param irq a expio virtual irq number
  149. */
  150. static void expio_unmask_irq(u32 irq)
  151. {
  152. u32 expio = MXC_IRQ_TO_EXPIO(irq);
  153. /* unmask the interrupt */
  154. __raw_writew(1 << expio, PBC_INTMASK_SET_REG);
  155. }
  156. static struct irq_chip expio_irq_chip = {
  157. .ack = expio_ack_irq,
  158. .mask = expio_mask_irq,
  159. .unmask = expio_unmask_irq,
  160. };
  161. static void __init mx31ads_init_expio(void)
  162. {
  163. int i;
  164. printk(KERN_INFO "MX31ADS EXPIO(CPLD) hardware\n");
  165. /*
  166. * Configure INT line as GPIO input
  167. */
  168. mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_GPIO1_4, IOMUX_CONFIG_GPIO), "expio");
  169. /* disable the interrupt and clear the status */
  170. __raw_writew(0xFFFF, PBC_INTMASK_CLEAR_REG);
  171. __raw_writew(0xFFFF, PBC_INTSTATUS_REG);
  172. for (i = MXC_EXP_IO_BASE; i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES);
  173. i++) {
  174. set_irq_chip(i, &expio_irq_chip);
  175. set_irq_handler(i, handle_level_irq);
  176. set_irq_flags(i, IRQF_VALID);
  177. }
  178. set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_HIGH);
  179. set_irq_chained_handler(EXPIO_PARENT_INT, mx31ads_expio_irq_handler);
  180. }
  181. #ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
  182. /* This section defines setup for the Wolfson Microelectronics
  183. * 1133-EV1 PMU/audio board. When other PMU boards are supported the
  184. * regulator definitions may be shared with them, but for now they can
  185. * only be used with this board so would generate warnings about
  186. * unused statics and some of the configuration is specific to this
  187. * module.
  188. */
  189. /* CPU */
  190. static struct regulator_consumer_supply sw1a_consumers[] = {
  191. {
  192. .supply = "cpu_vcc",
  193. }
  194. };
  195. static struct regulator_init_data sw1a_data = {
  196. .constraints = {
  197. .name = "SW1A",
  198. .min_uV = 1275000,
  199. .max_uV = 1600000,
  200. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  201. REGULATOR_CHANGE_MODE,
  202. .valid_modes_mask = REGULATOR_MODE_NORMAL |
  203. REGULATOR_MODE_FAST,
  204. .state_mem = {
  205. .uV = 1400000,
  206. .mode = REGULATOR_MODE_NORMAL,
  207. .enabled = 1,
  208. },
  209. .initial_state = PM_SUSPEND_MEM,
  210. .always_on = 1,
  211. .boot_on = 1,
  212. },
  213. .num_consumer_supplies = ARRAY_SIZE(sw1a_consumers),
  214. .consumer_supplies = sw1a_consumers,
  215. };
  216. /* System IO - High */
  217. static struct regulator_init_data viohi_data = {
  218. .constraints = {
  219. .name = "VIOHO",
  220. .min_uV = 2800000,
  221. .max_uV = 2800000,
  222. .state_mem = {
  223. .uV = 2800000,
  224. .mode = REGULATOR_MODE_NORMAL,
  225. .enabled = 1,
  226. },
  227. .initial_state = PM_SUSPEND_MEM,
  228. .always_on = 1,
  229. .boot_on = 1,
  230. },
  231. };
  232. /* System IO - Low */
  233. static struct regulator_init_data violo_data = {
  234. .constraints = {
  235. .name = "VIOLO",
  236. .min_uV = 1800000,
  237. .max_uV = 1800000,
  238. .state_mem = {
  239. .uV = 1800000,
  240. .mode = REGULATOR_MODE_NORMAL,
  241. .enabled = 1,
  242. },
  243. .initial_state = PM_SUSPEND_MEM,
  244. .always_on = 1,
  245. .boot_on = 1,
  246. },
  247. };
  248. /* DDR RAM */
  249. static struct regulator_init_data sw2a_data = {
  250. .constraints = {
  251. .name = "SW2A",
  252. .min_uV = 1800000,
  253. .max_uV = 1800000,
  254. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  255. .state_mem = {
  256. .uV = 1800000,
  257. .mode = REGULATOR_MODE_NORMAL,
  258. .enabled = 1,
  259. },
  260. .state_disk = {
  261. .mode = REGULATOR_MODE_NORMAL,
  262. .enabled = 0,
  263. },
  264. .always_on = 1,
  265. .boot_on = 1,
  266. .initial_state = PM_SUSPEND_MEM,
  267. },
  268. };
  269. static struct regulator_init_data ldo1_data = {
  270. .constraints = {
  271. .name = "VCAM/VMMC1/VMMC2",
  272. .min_uV = 2800000,
  273. .max_uV = 2800000,
  274. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  275. .apply_uV = 1,
  276. },
  277. };
  278. static struct regulator_consumer_supply ldo2_consumers[] = {
  279. {
  280. .supply = "AVDD",
  281. },
  282. {
  283. .supply = "HPVDD",
  284. },
  285. };
  286. /* CODEC and SIM */
  287. static struct regulator_init_data ldo2_data = {
  288. .constraints = {
  289. .name = "VESIM/VSIM/AVDD",
  290. .min_uV = 3300000,
  291. .max_uV = 3300000,
  292. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  293. .apply_uV = 1,
  294. },
  295. .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
  296. .consumer_supplies = ldo2_consumers,
  297. };
  298. /* General */
  299. static struct regulator_init_data vdig_data = {
  300. .constraints = {
  301. .name = "VDIG",
  302. .min_uV = 1500000,
  303. .max_uV = 1500000,
  304. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  305. .apply_uV = 1,
  306. .always_on = 1,
  307. .boot_on = 1,
  308. },
  309. };
  310. /* Tranceivers */
  311. static struct regulator_init_data ldo4_data = {
  312. .constraints = {
  313. .name = "VRF1/CVDD_2.775",
  314. .min_uV = 2500000,
  315. .max_uV = 2500000,
  316. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  317. .apply_uV = 1,
  318. .always_on = 1,
  319. .boot_on = 1,
  320. },
  321. };
  322. static struct wm8350_led_platform_data wm8350_led_data = {
  323. .name = "wm8350:white",
  324. .default_trigger = "heartbeat",
  325. .max_uA = 27899,
  326. };
  327. static struct wm8350_audio_platform_data imx32ads_wm8350_setup = {
  328. .vmid_discharge_msecs = 1000,
  329. .drain_msecs = 30,
  330. .cap_discharge_msecs = 700,
  331. .vmid_charge_msecs = 700,
  332. .vmid_s_curve = WM8350_S_CURVE_SLOW,
  333. .dis_out4 = WM8350_DISCHARGE_SLOW,
  334. .dis_out3 = WM8350_DISCHARGE_SLOW,
  335. .dis_out2 = WM8350_DISCHARGE_SLOW,
  336. .dis_out1 = WM8350_DISCHARGE_SLOW,
  337. .vroi_out4 = WM8350_TIE_OFF_500R,
  338. .vroi_out3 = WM8350_TIE_OFF_500R,
  339. .vroi_out2 = WM8350_TIE_OFF_500R,
  340. .vroi_out1 = WM8350_TIE_OFF_500R,
  341. .vroi_enable = 0,
  342. .codec_current_on = WM8350_CODEC_ISEL_1_0,
  343. .codec_current_standby = WM8350_CODEC_ISEL_0_5,
  344. .codec_current_charge = WM8350_CODEC_ISEL_1_5,
  345. };
  346. static int mx31_wm8350_init(struct wm8350 *wm8350)
  347. {
  348. int i;
  349. wm8350_gpio_config(wm8350, 0, WM8350_GPIO_DIR_IN,
  350. WM8350_GPIO0_PWR_ON_IN, WM8350_GPIO_ACTIVE_LOW,
  351. WM8350_GPIO_PULL_UP, WM8350_GPIO_INVERT_OFF,
  352. WM8350_GPIO_DEBOUNCE_ON);
  353. wm8350_gpio_config(wm8350, 3, WM8350_GPIO_DIR_IN,
  354. WM8350_GPIO3_PWR_OFF_IN, WM8350_GPIO_ACTIVE_HIGH,
  355. WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,
  356. WM8350_GPIO_DEBOUNCE_ON);
  357. wm8350_gpio_config(wm8350, 4, WM8350_GPIO_DIR_IN,
  358. WM8350_GPIO4_MR_IN, WM8350_GPIO_ACTIVE_HIGH,
  359. WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,
  360. WM8350_GPIO_DEBOUNCE_OFF);
  361. wm8350_gpio_config(wm8350, 7, WM8350_GPIO_DIR_IN,
  362. WM8350_GPIO7_HIBERNATE_IN, WM8350_GPIO_ACTIVE_HIGH,
  363. WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,
  364. WM8350_GPIO_DEBOUNCE_OFF);
  365. wm8350_gpio_config(wm8350, 6, WM8350_GPIO_DIR_OUT,
  366. WM8350_GPIO6_SDOUT_OUT, WM8350_GPIO_ACTIVE_HIGH,
  367. WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
  368. WM8350_GPIO_DEBOUNCE_OFF);
  369. wm8350_gpio_config(wm8350, 8, WM8350_GPIO_DIR_OUT,
  370. WM8350_GPIO8_VCC_FAULT_OUT, WM8350_GPIO_ACTIVE_LOW,
  371. WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
  372. WM8350_GPIO_DEBOUNCE_OFF);
  373. wm8350_gpio_config(wm8350, 9, WM8350_GPIO_DIR_OUT,
  374. WM8350_GPIO9_BATT_FAULT_OUT, WM8350_GPIO_ACTIVE_LOW,
  375. WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
  376. WM8350_GPIO_DEBOUNCE_OFF);
  377. /* Fix up for our own supplies. */
  378. for (i = 0; i < ARRAY_SIZE(ldo2_consumers); i++)
  379. ldo2_consumers[i].dev = wm8350->dev;
  380. wm8350_register_regulator(wm8350, WM8350_DCDC_1, &sw1a_data);
  381. wm8350_register_regulator(wm8350, WM8350_DCDC_3, &viohi_data);
  382. wm8350_register_regulator(wm8350, WM8350_DCDC_4, &violo_data);
  383. wm8350_register_regulator(wm8350, WM8350_DCDC_6, &sw2a_data);
  384. wm8350_register_regulator(wm8350, WM8350_LDO_1, &ldo1_data);
  385. wm8350_register_regulator(wm8350, WM8350_LDO_2, &ldo2_data);
  386. wm8350_register_regulator(wm8350, WM8350_LDO_3, &vdig_data);
  387. wm8350_register_regulator(wm8350, WM8350_LDO_4, &ldo4_data);
  388. /* LEDs */
  389. wm8350_dcdc_set_slot(wm8350, WM8350_DCDC_5, 1, 1,
  390. WM8350_DC5_ERRACT_SHUTDOWN_CONV);
  391. wm8350_isink_set_flash(wm8350, WM8350_ISINK_A,
  392. WM8350_ISINK_FLASH_DISABLE,
  393. WM8350_ISINK_FLASH_TRIG_BIT,
  394. WM8350_ISINK_FLASH_DUR_32MS,
  395. WM8350_ISINK_FLASH_ON_INSTANT,
  396. WM8350_ISINK_FLASH_OFF_INSTANT,
  397. WM8350_ISINK_FLASH_MODE_EN);
  398. wm8350_dcdc25_set_mode(wm8350, WM8350_DCDC_5,
  399. WM8350_ISINK_MODE_BOOST,
  400. WM8350_ISINK_ILIM_NORMAL,
  401. WM8350_DC5_RMP_20V,
  402. WM8350_DC5_FBSRC_ISINKA);
  403. wm8350_register_led(wm8350, 0, WM8350_DCDC_5, WM8350_ISINK_A,
  404. &wm8350_led_data);
  405. wm8350->codec.platform_data = &imx32ads_wm8350_setup;
  406. regulator_has_full_constraints();
  407. return 0;
  408. }
  409. static struct wm8350_platform_data __initdata mx31_wm8350_pdata = {
  410. .init = mx31_wm8350_init,
  411. };
  412. #endif
  413. #if defined(CONFIG_I2C_IMX) || defined(CONFIG_I2C_IMX_MODULE)
  414. static struct i2c_board_info __initdata mx31ads_i2c1_devices[] = {
  415. #ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
  416. {
  417. I2C_BOARD_INFO("wm8350", 0x1a),
  418. .platform_data = &mx31_wm8350_pdata,
  419. .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),
  420. },
  421. #endif
  422. };
  423. static void mxc_init_i2c(void)
  424. {
  425. i2c_register_board_info(1, mx31ads_i2c1_devices,
  426. ARRAY_SIZE(mx31ads_i2c1_devices));
  427. mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MOSI, IOMUX_CONFIG_ALT1));
  428. mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MISO, IOMUX_CONFIG_ALT1));
  429. mxc_register_device(&mxc_i2c_device1, NULL);
  430. }
  431. #else
  432. static void mxc_init_i2c(void)
  433. {
  434. }
  435. #endif
  436. /*!
  437. * This structure defines static mappings for the i.MX31ADS board.
  438. */
  439. static struct map_desc mx31ads_io_desc[] __initdata = {
  440. {
  441. .virtual = SPBA0_BASE_ADDR_VIRT,
  442. .pfn = __phys_to_pfn(SPBA0_BASE_ADDR),
  443. .length = SPBA0_SIZE,
  444. .type = MT_DEVICE_NONSHARED
  445. }, {
  446. .virtual = CS4_BASE_ADDR_VIRT,
  447. .pfn = __phys_to_pfn(CS4_BASE_ADDR),
  448. .length = CS4_SIZE / 2,
  449. .type = MT_DEVICE
  450. },
  451. };
  452. /*!
  453. * Set up static virtual mappings.
  454. */
  455. static void __init mx31ads_map_io(void)
  456. {
  457. mx31_map_io();
  458. iotable_init(mx31ads_io_desc, ARRAY_SIZE(mx31ads_io_desc));
  459. }
  460. static void __init mx31ads_init_irq(void)
  461. {
  462. mx31_init_irq();
  463. mx31ads_init_expio();
  464. }
  465. /*!
  466. * Board specific initialization.
  467. */
  468. static void __init mxc_board_init(void)
  469. {
  470. mxc_init_extuart();
  471. mxc_init_imx_uart();
  472. mxc_init_i2c();
  473. }
  474. static void __init mx31ads_timer_init(void)
  475. {
  476. mx31_clocks_init(26000000);
  477. }
  478. static struct sys_timer mx31ads_timer = {
  479. .init = mx31ads_timer_init,
  480. };
  481. /*
  482. * The following uses standard kernel macros defined in arch.h in order to
  483. * initialize __mach_desc_MX31ADS data structure.
  484. */
  485. MACHINE_START(MX31ADS, "Freescale MX31ADS")
  486. /* Maintainer: Freescale Semiconductor, Inc. */
  487. .phys_io = AIPS1_BASE_ADDR,
  488. .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
  489. .boot_params = PHYS_OFFSET + 0x100,
  490. .map_io = mx31ads_map_io,
  491. .init_irq = mx31ads_init_irq,
  492. .init_machine = mxc_board_init,
  493. .timer = &mx31ads_timer,
  494. MACHINE_END