board-seaboard.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /*
  2. * Copyright (c) 2010, 2011 NVIDIA Corporation.
  3. * Copyright (C) 2010, 2011 Google, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/serial_8250.h>
  20. #include <linux/i2c.h>
  21. #include <linux/delay.h>
  22. #include <linux/input.h>
  23. #include <linux/io.h>
  24. #include <linux/gpio.h>
  25. #include <linux/gpio_keys.h>
  26. #include <linux/platform_data/tegra_usb.h>
  27. #include <sound/wm8903.h>
  28. #include <mach/iomap.h>
  29. #include <mach/irqs.h>
  30. #include <mach/sdhci.h>
  31. #include <mach/tegra_wm8903_pdata.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/hardware/gic.h>
  35. #include "board.h"
  36. #include "board-seaboard.h"
  37. #include "clock.h"
  38. #include "devices.h"
  39. #include "gpio-names.h"
  40. static struct plat_serial8250_port debug_uart_platform_data[] = {
  41. {
  42. /* Memory and IRQ filled in before registration */
  43. .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
  44. .type = PORT_TEGRA,
  45. .iotype = UPIO_MEM,
  46. .regshift = 2,
  47. .uartclk = 216000000,
  48. }, {
  49. .flags = 0,
  50. }
  51. };
  52. static struct platform_device debug_uart = {
  53. .name = "serial8250",
  54. .id = PLAT8250_DEV_PLATFORM,
  55. .dev = {
  56. .platform_data = debug_uart_platform_data,
  57. },
  58. };
  59. static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
  60. /* name parent rate enabled */
  61. { "uartb", "pll_p", 216000000, true},
  62. { "uartd", "pll_p", 216000000, true},
  63. { "pll_a", "pll_p_out1", 56448000, true },
  64. { "pll_a_out0", "pll_a", 11289600, true },
  65. { "cdev1", NULL, 0, true },
  66. { "i2s1", "pll_a_out0", 11289600, false},
  67. { "usbd", "clk_m", 12000000, true},
  68. { "usb3", "clk_m", 12000000, true},
  69. { NULL, NULL, 0, 0},
  70. };
  71. static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
  72. {
  73. .code = SW_LID,
  74. .gpio = TEGRA_GPIO_LIDSWITCH,
  75. .active_low = 0,
  76. .desc = "Lid",
  77. .type = EV_SW,
  78. .wakeup = 1,
  79. .debounce_interval = 1,
  80. },
  81. {
  82. .code = KEY_POWER,
  83. .gpio = TEGRA_GPIO_POWERKEY,
  84. .active_low = 1,
  85. .desc = "Power",
  86. .type = EV_KEY,
  87. .wakeup = 1,
  88. },
  89. };
  90. static struct gpio_keys_platform_data seaboard_gpio_keys = {
  91. .buttons = seaboard_gpio_keys_buttons,
  92. .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
  93. };
  94. static struct platform_device seaboard_gpio_keys_device = {
  95. .name = "gpio-keys",
  96. .id = -1,
  97. .dev = {
  98. .platform_data = &seaboard_gpio_keys,
  99. }
  100. };
  101. static struct tegra_sdhci_platform_data sdhci_pdata1 = {
  102. .cd_gpio = -1,
  103. .wp_gpio = -1,
  104. .power_gpio = -1,
  105. };
  106. static struct tegra_sdhci_platform_data sdhci_pdata3 = {
  107. .cd_gpio = TEGRA_GPIO_SD2_CD,
  108. .wp_gpio = TEGRA_GPIO_SD2_WP,
  109. .power_gpio = TEGRA_GPIO_SD2_POWER,
  110. };
  111. static struct tegra_sdhci_platform_data sdhci_pdata4 = {
  112. .cd_gpio = -1,
  113. .wp_gpio = -1,
  114. .power_gpio = -1,
  115. .is_8bit = 1,
  116. };
  117. static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
  118. .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
  119. .gpio_hp_det = TEGRA_GPIO_HP_DET,
  120. .gpio_hp_mute = -1,
  121. .gpio_int_mic_en = -1,
  122. .gpio_ext_mic_en = -1,
  123. };
  124. static struct platform_device seaboard_audio_device = {
  125. .name = "tegra-snd-wm8903",
  126. .id = 0,
  127. .dev = {
  128. .platform_data = &seaboard_audio_pdata,
  129. },
  130. };
  131. static struct platform_device *seaboard_devices[] __initdata = {
  132. &debug_uart,
  133. &tegra_pmu_device,
  134. &tegra_sdhci_device4,
  135. &tegra_sdhci_device3,
  136. &tegra_sdhci_device1,
  137. &seaboard_gpio_keys_device,
  138. &tegra_i2s_device1,
  139. &tegra_das_device,
  140. &tegra_pcm_device,
  141. &seaboard_audio_device,
  142. };
  143. static struct i2c_board_info __initdata isl29018_device = {
  144. I2C_BOARD_INFO("isl29018", 0x44),
  145. };
  146. static struct i2c_board_info __initdata adt7461_device = {
  147. I2C_BOARD_INFO("adt7461", 0x4c),
  148. };
  149. static struct wm8903_platform_data wm8903_pdata = {
  150. .irq_active_low = 0,
  151. .micdet_cfg = 0,
  152. .micdet_delay = 100,
  153. .gpio_base = SEABOARD_GPIO_WM8903(0),
  154. .gpio_cfg = {
  155. 0,
  156. 0,
  157. WM8903_GPIO_CONFIG_ZERO,
  158. 0,
  159. 0,
  160. },
  161. };
  162. static struct i2c_board_info __initdata wm8903_device = {
  163. I2C_BOARD_INFO("wm8903", 0x1a),
  164. .platform_data = &wm8903_pdata,
  165. };
  166. static int seaboard_ehci_init(void)
  167. {
  168. struct tegra_ehci_platform_data *pdata;
  169. pdata = tegra_ehci1_device.dev.platform_data;
  170. pdata->vbus_gpio = TEGRA_GPIO_USB1;
  171. platform_device_register(&tegra_ehci1_device);
  172. platform_device_register(&tegra_ehci3_device);
  173. return 0;
  174. }
  175. static void __init seaboard_i2c_init(void)
  176. {
  177. isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
  178. i2c_register_board_info(0, &isl29018_device, 1);
  179. wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
  180. i2c_register_board_info(0, &wm8903_device, 1);
  181. i2c_register_board_info(3, &adt7461_device, 1);
  182. platform_device_register(&tegra_i2c_device1);
  183. platform_device_register(&tegra_i2c_device2);
  184. platform_device_register(&tegra_i2c_device3);
  185. platform_device_register(&tegra_i2c_device4);
  186. }
  187. static void __init seaboard_common_init(void)
  188. {
  189. seaboard_pinmux_init();
  190. tegra_clk_init_from_table(seaboard_clk_init_table);
  191. tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
  192. tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
  193. tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
  194. platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
  195. seaboard_ehci_init();
  196. }
  197. static void __init tegra_seaboard_init(void)
  198. {
  199. /* Seaboard uses UARTD for the debug port. */
  200. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
  201. debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
  202. debug_uart_platform_data[0].irq = INT_UARTD;
  203. seaboard_common_init();
  204. seaboard_i2c_init();
  205. }
  206. static void __init tegra_kaen_init(void)
  207. {
  208. /* Kaen uses UARTB for the debug port. */
  209. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
  210. debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
  211. debug_uart_platform_data[0].irq = INT_UARTB;
  212. seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
  213. tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE);
  214. seaboard_common_init();
  215. seaboard_i2c_init();
  216. }
  217. static void __init tegra_wario_init(void)
  218. {
  219. /* Wario uses UARTB for the debug port. */
  220. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
  221. debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
  222. debug_uart_platform_data[0].irq = INT_UARTB;
  223. seaboard_common_init();
  224. seaboard_i2c_init();
  225. }
  226. MACHINE_START(SEABOARD, "seaboard")
  227. .atag_offset = 0x100,
  228. .map_io = tegra_map_common_io,
  229. .init_early = tegra20_init_early,
  230. .init_irq = tegra_init_irq,
  231. .handle_irq = gic_handle_irq,
  232. .timer = &tegra_timer,
  233. .init_machine = tegra_seaboard_init,
  234. .restart = tegra_assert_system_reset,
  235. MACHINE_END
  236. MACHINE_START(KAEN, "kaen")
  237. .atag_offset = 0x100,
  238. .map_io = tegra_map_common_io,
  239. .init_early = tegra20_init_early,
  240. .init_irq = tegra_init_irq,
  241. .handle_irq = gic_handle_irq,
  242. .timer = &tegra_timer,
  243. .init_machine = tegra_kaen_init,
  244. .restart = tegra_assert_system_reset,
  245. MACHINE_END
  246. MACHINE_START(WARIO, "wario")
  247. .atag_offset = 0x100,
  248. .map_io = tegra_map_common_io,
  249. .init_early = tegra20_init_early,
  250. .init_irq = tegra_init_irq,
  251. .handle_irq = gic_handle_irq,
  252. .timer = &tegra_timer,
  253. .init_machine = tegra_wario_init,
  254. .restart = tegra_assert_system_reset,
  255. MACHINE_END