PageRenderTime 49ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/arm/mach-mx3/mach-mx31ads.c

https://github.com/dmitriy103/bravo_kernel-2.6.35
C | 559 lines | 420 code | 62 blank | 77 comment | 8 complexity | 6de4e7c0f89ecd16c505b74e2b52938d MD5 | raw file
  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)(MX31_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)(MX31_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. .name = "EXPIO(CPLD)",
  158. .ack = expio_ack_irq,
  159. .mask = expio_mask_irq,
  160. .unmask = expio_unmask_irq,
  161. };
  162. static void __init mx31ads_init_expio(void)
  163. {
  164. int i;
  165. printk(KERN_INFO "MX31ADS EXPIO(CPLD) hardware\n");
  166. /*
  167. * Configure INT line as GPIO input
  168. */
  169. mxc_iomux_alloc_pin(IOMUX_MODE(MX31_PIN_GPIO1_4, IOMUX_CONFIG_GPIO), "expio");
  170. /* disable the interrupt and clear the status */
  171. __raw_writew(0xFFFF, PBC_INTMASK_CLEAR_REG);
  172. __raw_writew(0xFFFF, PBC_INTSTATUS_REG);
  173. for (i = MXC_EXP_IO_BASE; i < (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES);
  174. i++) {
  175. set_irq_chip(i, &expio_irq_chip);
  176. set_irq_handler(i, handle_level_irq);
  177. set_irq_flags(i, IRQF_VALID);
  178. }
  179. set_irq_type(EXPIO_PARENT_INT, IRQ_TYPE_LEVEL_HIGH);
  180. set_irq_chained_handler(EXPIO_PARENT_INT, mx31ads_expio_irq_handler);
  181. }
  182. #ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
  183. /* This section defines setup for the Wolfson Microelectronics
  184. * 1133-EV1 PMU/audio board. When other PMU boards are supported the
  185. * regulator definitions may be shared with them, but for now they can
  186. * only be used with this board so would generate warnings about
  187. * unused statics and some of the configuration is specific to this
  188. * module.
  189. */
  190. /* CPU */
  191. static struct regulator_consumer_supply sw1a_consumers[] = {
  192. {
  193. .supply = "cpu_vcc",
  194. }
  195. };
  196. static struct regulator_init_data sw1a_data = {
  197. .constraints = {
  198. .name = "SW1A",
  199. .min_uV = 1275000,
  200. .max_uV = 1600000,
  201. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  202. REGULATOR_CHANGE_MODE,
  203. .valid_modes_mask = REGULATOR_MODE_NORMAL |
  204. REGULATOR_MODE_FAST,
  205. .state_mem = {
  206. .uV = 1400000,
  207. .mode = REGULATOR_MODE_NORMAL,
  208. .enabled = 1,
  209. },
  210. .initial_state = PM_SUSPEND_MEM,
  211. .always_on = 1,
  212. .boot_on = 1,
  213. },
  214. .num_consumer_supplies = ARRAY_SIZE(sw1a_consumers),
  215. .consumer_supplies = sw1a_consumers,
  216. };
  217. /* System IO - High */
  218. static struct regulator_init_data viohi_data = {
  219. .constraints = {
  220. .name = "VIOHO",
  221. .min_uV = 2800000,
  222. .max_uV = 2800000,
  223. .state_mem = {
  224. .uV = 2800000,
  225. .mode = REGULATOR_MODE_NORMAL,
  226. .enabled = 1,
  227. },
  228. .initial_state = PM_SUSPEND_MEM,
  229. .always_on = 1,
  230. .boot_on = 1,
  231. },
  232. };
  233. /* System IO - Low */
  234. static struct regulator_init_data violo_data = {
  235. .constraints = {
  236. .name = "VIOLO",
  237. .min_uV = 1800000,
  238. .max_uV = 1800000,
  239. .state_mem = {
  240. .uV = 1800000,
  241. .mode = REGULATOR_MODE_NORMAL,
  242. .enabled = 1,
  243. },
  244. .initial_state = PM_SUSPEND_MEM,
  245. .always_on = 1,
  246. .boot_on = 1,
  247. },
  248. };
  249. /* DDR RAM */
  250. static struct regulator_init_data sw2a_data = {
  251. .constraints = {
  252. .name = "SW2A",
  253. .min_uV = 1800000,
  254. .max_uV = 1800000,
  255. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  256. .state_mem = {
  257. .uV = 1800000,
  258. .mode = REGULATOR_MODE_NORMAL,
  259. .enabled = 1,
  260. },
  261. .state_disk = {
  262. .mode = REGULATOR_MODE_NORMAL,
  263. .enabled = 0,
  264. },
  265. .always_on = 1,
  266. .boot_on = 1,
  267. .initial_state = PM_SUSPEND_MEM,
  268. },
  269. };
  270. static struct regulator_init_data ldo1_data = {
  271. .constraints = {
  272. .name = "VCAM/VMMC1/VMMC2",
  273. .min_uV = 2800000,
  274. .max_uV = 2800000,
  275. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  276. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  277. .apply_uV = 1,
  278. },
  279. };
  280. static struct regulator_consumer_supply ldo2_consumers[] = {
  281. { .supply = "AVDD", .dev_name = "1-001a" },
  282. { .supply = "HPVDD", .dev_name = "1-001a" },
  283. };
  284. /* CODEC and SIM */
  285. static struct regulator_init_data ldo2_data = {
  286. .constraints = {
  287. .name = "VESIM/VSIM/AVDD",
  288. .min_uV = 3300000,
  289. .max_uV = 3300000,
  290. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  291. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  292. .apply_uV = 1,
  293. },
  294. .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
  295. .consumer_supplies = ldo2_consumers,
  296. };
  297. /* General */
  298. static struct regulator_init_data vdig_data = {
  299. .constraints = {
  300. .name = "VDIG",
  301. .min_uV = 1500000,
  302. .max_uV = 1500000,
  303. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  304. .apply_uV = 1,
  305. .always_on = 1,
  306. .boot_on = 1,
  307. },
  308. };
  309. /* Tranceivers */
  310. static struct regulator_init_data ldo4_data = {
  311. .constraints = {
  312. .name = "VRF1/CVDD_2.775",
  313. .min_uV = 2500000,
  314. .max_uV = 2500000,
  315. .valid_modes_mask = REGULATOR_MODE_NORMAL,
  316. .apply_uV = 1,
  317. .always_on = 1,
  318. .boot_on = 1,
  319. },
  320. };
  321. static struct wm8350_led_platform_data wm8350_led_data = {
  322. .name = "wm8350:white",
  323. .default_trigger = "heartbeat",
  324. .max_uA = 27899,
  325. };
  326. static struct wm8350_audio_platform_data imx32ads_wm8350_setup = {
  327. .vmid_discharge_msecs = 1000,
  328. .drain_msecs = 30,
  329. .cap_discharge_msecs = 700,
  330. .vmid_charge_msecs = 700,
  331. .vmid_s_curve = WM8350_S_CURVE_SLOW,
  332. .dis_out4 = WM8350_DISCHARGE_SLOW,
  333. .dis_out3 = WM8350_DISCHARGE_SLOW,
  334. .dis_out2 = WM8350_DISCHARGE_SLOW,
  335. .dis_out1 = WM8350_DISCHARGE_SLOW,
  336. .vroi_out4 = WM8350_TIE_OFF_500R,
  337. .vroi_out3 = WM8350_TIE_OFF_500R,
  338. .vroi_out2 = WM8350_TIE_OFF_500R,
  339. .vroi_out1 = WM8350_TIE_OFF_500R,
  340. .vroi_enable = 0,
  341. .codec_current_on = WM8350_CODEC_ISEL_1_0,
  342. .codec_current_standby = WM8350_CODEC_ISEL_0_5,
  343. .codec_current_charge = WM8350_CODEC_ISEL_1_5,
  344. };
  345. static int mx31_wm8350_init(struct wm8350 *wm8350)
  346. {
  347. wm8350_gpio_config(wm8350, 0, WM8350_GPIO_DIR_IN,
  348. WM8350_GPIO0_PWR_ON_IN, WM8350_GPIO_ACTIVE_LOW,
  349. WM8350_GPIO_PULL_UP, WM8350_GPIO_INVERT_OFF,
  350. WM8350_GPIO_DEBOUNCE_ON);
  351. wm8350_gpio_config(wm8350, 3, WM8350_GPIO_DIR_IN,
  352. WM8350_GPIO3_PWR_OFF_IN, WM8350_GPIO_ACTIVE_HIGH,
  353. WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,
  354. WM8350_GPIO_DEBOUNCE_ON);
  355. wm8350_gpio_config(wm8350, 4, WM8350_GPIO_DIR_IN,
  356. WM8350_GPIO4_MR_IN, WM8350_GPIO_ACTIVE_HIGH,
  357. WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,
  358. WM8350_GPIO_DEBOUNCE_OFF);
  359. wm8350_gpio_config(wm8350, 7, WM8350_GPIO_DIR_IN,
  360. WM8350_GPIO7_HIBERNATE_IN, WM8350_GPIO_ACTIVE_HIGH,
  361. WM8350_GPIO_PULL_DOWN, WM8350_GPIO_INVERT_OFF,
  362. WM8350_GPIO_DEBOUNCE_OFF);
  363. wm8350_gpio_config(wm8350, 6, WM8350_GPIO_DIR_OUT,
  364. WM8350_GPIO6_SDOUT_OUT, WM8350_GPIO_ACTIVE_HIGH,
  365. WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
  366. WM8350_GPIO_DEBOUNCE_OFF);
  367. wm8350_gpio_config(wm8350, 8, WM8350_GPIO_DIR_OUT,
  368. WM8350_GPIO8_VCC_FAULT_OUT, WM8350_GPIO_ACTIVE_LOW,
  369. WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
  370. WM8350_GPIO_DEBOUNCE_OFF);
  371. wm8350_gpio_config(wm8350, 9, WM8350_GPIO_DIR_OUT,
  372. WM8350_GPIO9_BATT_FAULT_OUT, WM8350_GPIO_ACTIVE_LOW,
  373. WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
  374. WM8350_GPIO_DEBOUNCE_OFF);
  375. wm8350_register_regulator(wm8350, WM8350_DCDC_1, &sw1a_data);
  376. wm8350_register_regulator(wm8350, WM8350_DCDC_3, &viohi_data);
  377. wm8350_register_regulator(wm8350, WM8350_DCDC_4, &violo_data);
  378. wm8350_register_regulator(wm8350, WM8350_DCDC_6, &sw2a_data);
  379. wm8350_register_regulator(wm8350, WM8350_LDO_1, &ldo1_data);
  380. wm8350_register_regulator(wm8350, WM8350_LDO_2, &ldo2_data);
  381. wm8350_register_regulator(wm8350, WM8350_LDO_3, &vdig_data);
  382. wm8350_register_regulator(wm8350, WM8350_LDO_4, &ldo4_data);
  383. /* LEDs */
  384. wm8350_dcdc_set_slot(wm8350, WM8350_DCDC_5, 1, 1,
  385. WM8350_DC5_ERRACT_SHUTDOWN_CONV);
  386. wm8350_isink_set_flash(wm8350, WM8350_ISINK_A,
  387. WM8350_ISINK_FLASH_DISABLE,
  388. WM8350_ISINK_FLASH_TRIG_BIT,
  389. WM8350_ISINK_FLASH_DUR_32MS,
  390. WM8350_ISINK_FLASH_ON_INSTANT,
  391. WM8350_ISINK_FLASH_OFF_INSTANT,
  392. WM8350_ISINK_FLASH_MODE_EN);
  393. wm8350_dcdc25_set_mode(wm8350, WM8350_DCDC_5,
  394. WM8350_ISINK_MODE_BOOST,
  395. WM8350_ISINK_ILIM_NORMAL,
  396. WM8350_DC5_RMP_20V,
  397. WM8350_DC5_FBSRC_ISINKA);
  398. wm8350_register_led(wm8350, 0, WM8350_DCDC_5, WM8350_ISINK_A,
  399. &wm8350_led_data);
  400. wm8350->codec.platform_data = &imx32ads_wm8350_setup;
  401. regulator_has_full_constraints();
  402. return 0;
  403. }
  404. static struct wm8350_platform_data __initdata mx31_wm8350_pdata = {
  405. .init = mx31_wm8350_init,
  406. .irq_base = MXC_BOARD_IRQ_START + MXC_MAX_EXP_IO_LINES,
  407. };
  408. #endif
  409. #if defined(CONFIG_I2C_IMX) || defined(CONFIG_I2C_IMX_MODULE)
  410. static struct i2c_board_info __initdata mx31ads_i2c1_devices[] = {
  411. #ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
  412. {
  413. I2C_BOARD_INFO("wm8350", 0x1a),
  414. .platform_data = &mx31_wm8350_pdata,
  415. .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_3),
  416. },
  417. #endif
  418. };
  419. static void mxc_init_i2c(void)
  420. {
  421. i2c_register_board_info(1, mx31ads_i2c1_devices,
  422. ARRAY_SIZE(mx31ads_i2c1_devices));
  423. mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MOSI, IOMUX_CONFIG_ALT1));
  424. mxc_iomux_mode(IOMUX_MODE(MX31_PIN_CSPI2_MISO, IOMUX_CONFIG_ALT1));
  425. mxc_register_device(&mxc_i2c_device1, NULL);
  426. }
  427. #else
  428. static void mxc_init_i2c(void)
  429. {
  430. }
  431. #endif
  432. static unsigned int ssi_pins[] = {
  433. MX31_PIN_SFS5__SFS5,
  434. MX31_PIN_SCK5__SCK5,
  435. MX31_PIN_SRXD5__SRXD5,
  436. MX31_PIN_STXD5__STXD5,
  437. };
  438. static void mxc_init_audio(void)
  439. {
  440. mxc_register_device(&imx_ssi_device0, NULL);
  441. mxc_iomux_setup_multiple_pins(ssi_pins, ARRAY_SIZE(ssi_pins), "ssi");
  442. }
  443. /*!
  444. * This structure defines static mappings for the i.MX31ADS board.
  445. */
  446. static struct map_desc mx31ads_io_desc[] __initdata = {
  447. {
  448. .virtual = MX31_CS4_BASE_ADDR_VIRT,
  449. .pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR),
  450. .length = MX31_CS4_SIZE / 2,
  451. .type = MT_DEVICE
  452. },
  453. };
  454. /*!
  455. * Set up static virtual mappings.
  456. */
  457. static void __init mx31ads_map_io(void)
  458. {
  459. mx31_map_io();
  460. iotable_init(mx31ads_io_desc, ARRAY_SIZE(mx31ads_io_desc));
  461. }
  462. static void __init mx31ads_init_irq(void)
  463. {
  464. mx31_init_irq();
  465. mx31ads_init_expio();
  466. }
  467. /*!
  468. * Board specific initialization.
  469. */
  470. static void __init mxc_board_init(void)
  471. {
  472. mxc_init_extuart();
  473. mxc_init_imx_uart();
  474. mxc_init_i2c();
  475. mxc_init_audio();
  476. }
  477. static void __init mx31ads_timer_init(void)
  478. {
  479. mx31_clocks_init(26000000);
  480. }
  481. static struct sys_timer mx31ads_timer = {
  482. .init = mx31ads_timer_init,
  483. };
  484. /*
  485. * The following uses standard kernel macros defined in arch.h in order to
  486. * initialize __mach_desc_MX31ADS data structure.
  487. */
  488. MACHINE_START(MX31ADS, "Freescale MX31ADS")
  489. /* Maintainer: Freescale Semiconductor, Inc. */
  490. .phys_io = MX31_AIPS1_BASE_ADDR,
  491. .io_pg_offst = (MX31_AIPS1_BASE_ADDR_VIRT >> 18) & 0xfffc,
  492. .boot_params = MX3x_PHYS_OFFSET + 0x100,
  493. .map_io = mx31ads_map_io,
  494. .init_irq = mx31ads_init_irq,
  495. .init_machine = mxc_board_init,
  496. .timer = &mx31ads_timer,
  497. MACHINE_END