board-seaboard.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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 <sound/wm8903.h>
  27. #include <mach/iomap.h>
  28. #include <mach/irqs.h>
  29. #include <mach/sdhci.h>
  30. #include <mach/tegra_wm8903_pdata.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/hardware/gic.h>
  34. #include "board.h"
  35. #include "board-seaboard.h"
  36. #include "clock.h"
  37. #include "devices.h"
  38. #include "gpio-names.h"
  39. static struct plat_serial8250_port debug_uart_platform_data[] = {
  40. {
  41. /* Memory and IRQ filled in before registration */
  42. .flags = UPF_BOOT_AUTOCONF | UPF_FIXED_TYPE,
  43. .type = PORT_TEGRA,
  44. .iotype = UPIO_MEM,
  45. .regshift = 2,
  46. .uartclk = 216000000,
  47. }, {
  48. .flags = 0,
  49. }
  50. };
  51. static struct platform_device debug_uart = {
  52. .name = "serial8250",
  53. .id = PLAT8250_DEV_PLATFORM,
  54. .dev = {
  55. .platform_data = debug_uart_platform_data,
  56. },
  57. };
  58. static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
  59. /* name parent rate enabled */
  60. { "uartb", "pll_p", 216000000, true},
  61. { "uartd", "pll_p", 216000000, true},
  62. { "pll_a", "pll_p_out1", 56448000, true },
  63. { "pll_a_out0", "pll_a", 11289600, true },
  64. { "cdev1", NULL, 0, true },
  65. { "i2s1", "pll_a_out0", 11289600, false},
  66. { "usbd", "clk_m", 12000000, true},
  67. { "usb3", "clk_m", 12000000, true},
  68. { NULL, NULL, 0, 0},
  69. };
  70. static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
  71. {
  72. .code = SW_LID,
  73. .gpio = TEGRA_GPIO_LIDSWITCH,
  74. .active_low = 0,
  75. .desc = "Lid",
  76. .type = EV_SW,
  77. .wakeup = 1,
  78. .debounce_interval = 1,
  79. },
  80. {
  81. .code = KEY_POWER,
  82. .gpio = TEGRA_GPIO_POWERKEY,
  83. .active_low = 1,
  84. .desc = "Power",
  85. .type = EV_KEY,
  86. .wakeup = 1,
  87. },
  88. };
  89. static struct gpio_keys_platform_data seaboard_gpio_keys = {
  90. .buttons = seaboard_gpio_keys_buttons,
  91. .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
  92. };
  93. static struct platform_device seaboard_gpio_keys_device = {
  94. .name = "gpio-keys",
  95. .id = -1,
  96. .dev = {
  97. .platform_data = &seaboard_gpio_keys,
  98. }
  99. };
  100. static struct tegra_sdhci_platform_data sdhci_pdata1 = {
  101. .cd_gpio = -1,
  102. .wp_gpio = -1,
  103. .power_gpio = -1,
  104. };
  105. static struct tegra_sdhci_platform_data sdhci_pdata3 = {
  106. .cd_gpio = TEGRA_GPIO_SD2_CD,
  107. .wp_gpio = TEGRA_GPIO_SD2_WP,
  108. .power_gpio = TEGRA_GPIO_SD2_POWER,
  109. };
  110. static struct tegra_sdhci_platform_data sdhci_pdata4 = {
  111. .cd_gpio = -1,
  112. .wp_gpio = -1,
  113. .power_gpio = -1,
  114. .is_8bit = 1,
  115. };
  116. static struct tegra_wm8903_platform_data seaboard_audio_pdata = {
  117. .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
  118. .gpio_hp_det = TEGRA_GPIO_HP_DET,
  119. .gpio_hp_mute = -1,
  120. .gpio_int_mic_en = -1,
  121. .gpio_ext_mic_en = -1,
  122. };
  123. static struct platform_device seaboard_audio_device = {
  124. .name = "tegra-snd-wm8903",
  125. .id = 0,
  126. .dev = {
  127. .platform_data = &seaboard_audio_pdata,
  128. },
  129. };
  130. static struct platform_device *seaboard_devices[] __initdata = {
  131. &debug_uart,
  132. &tegra_pmu_device,
  133. &tegra_sdhci_device4,
  134. &tegra_sdhci_device3,
  135. &tegra_sdhci_device1,
  136. &seaboard_gpio_keys_device,
  137. &tegra_i2s_device1,
  138. &tegra_das_device,
  139. &tegra_pcm_device,
  140. &seaboard_audio_device,
  141. };
  142. static struct i2c_board_info __initdata isl29018_device = {
  143. I2C_BOARD_INFO("isl29018", 0x44),
  144. };
  145. static struct i2c_board_info __initdata adt7461_device = {
  146. I2C_BOARD_INFO("adt7461", 0x4c),
  147. };
  148. static struct wm8903_platform_data wm8903_pdata = {
  149. .irq_active_low = 0,
  150. .micdet_cfg = 0,
  151. .micdet_delay = 100,
  152. .gpio_base = SEABOARD_GPIO_WM8903(0),
  153. .gpio_cfg = {
  154. 0,
  155. 0,
  156. WM8903_GPIO_CONFIG_ZERO,
  157. 0,
  158. 0,
  159. },
  160. };
  161. static struct i2c_board_info __initdata wm8903_device = {
  162. I2C_BOARD_INFO("wm8903", 0x1a),
  163. .platform_data = &wm8903_pdata,
  164. };
  165. static int seaboard_ehci_init(void)
  166. {
  167. int gpio_status;
  168. gpio_status = gpio_request(TEGRA_GPIO_USB1, "VBUS_USB1");
  169. if (gpio_status < 0) {
  170. pr_err("VBUS_USB1 request GPIO FAILED\n");
  171. WARN_ON(1);
  172. }
  173. gpio_status = gpio_direction_output(TEGRA_GPIO_USB1, 1);
  174. if (gpio_status < 0) {
  175. pr_err("VBUS_USB1 request GPIO DIRECTION FAILED\n");
  176. WARN_ON(1);
  177. }
  178. gpio_set_value(TEGRA_GPIO_USB1, 1);
  179. platform_device_register(&tegra_ehci1_device);
  180. platform_device_register(&tegra_ehci3_device);
  181. return 0;
  182. }
  183. static void __init seaboard_i2c_init(void)
  184. {
  185. gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
  186. gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
  187. isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
  188. i2c_register_board_info(0, &isl29018_device, 1);
  189. wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
  190. i2c_register_board_info(0, &wm8903_device, 1);
  191. i2c_register_board_info(3, &adt7461_device, 1);
  192. platform_device_register(&tegra_i2c_device1);
  193. platform_device_register(&tegra_i2c_device2);
  194. platform_device_register(&tegra_i2c_device3);
  195. platform_device_register(&tegra_i2c_device4);
  196. }
  197. static void __init seaboard_common_init(void)
  198. {
  199. seaboard_pinmux_init();
  200. tegra_clk_init_from_table(seaboard_clk_init_table);
  201. tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
  202. tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
  203. tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
  204. platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
  205. seaboard_ehci_init();
  206. }
  207. static void __init tegra_seaboard_init(void)
  208. {
  209. /* Seaboard uses UARTD for the debug port. */
  210. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
  211. debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
  212. debug_uart_platform_data[0].irq = INT_UARTD;
  213. seaboard_common_init();
  214. seaboard_i2c_init();
  215. }
  216. static void __init tegra_kaen_init(void)
  217. {
  218. /* Kaen uses UARTB for the debug port. */
  219. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
  220. debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
  221. debug_uart_platform_data[0].irq = INT_UARTB;
  222. seaboard_audio_pdata.gpio_hp_mute = TEGRA_GPIO_KAEN_HP_MUTE;
  223. tegra_gpio_enable(TEGRA_GPIO_KAEN_HP_MUTE);
  224. seaboard_common_init();
  225. seaboard_i2c_init();
  226. }
  227. static void __init tegra_wario_init(void)
  228. {
  229. /* Wario uses UARTB for the debug port. */
  230. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
  231. debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
  232. debug_uart_platform_data[0].irq = INT_UARTB;
  233. seaboard_common_init();
  234. seaboard_i2c_init();
  235. }
  236. MACHINE_START(SEABOARD, "seaboard")
  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_seaboard_init,
  244. .restart = tegra_assert_system_reset,
  245. MACHINE_END
  246. MACHINE_START(KAEN, "kaen")
  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_kaen_init,
  254. .restart = tegra_assert_system_reset,
  255. MACHINE_END
  256. MACHINE_START(WARIO, "wario")
  257. .atag_offset = 0x100,
  258. .map_io = tegra_map_common_io,
  259. .init_early = tegra20_init_early,
  260. .init_irq = tegra_init_irq,
  261. .handle_irq = gic_handle_irq,
  262. .timer = &tegra_timer,
  263. .init_machine = tegra_wario_init,
  264. .restart = tegra_assert_system_reset,
  265. MACHINE_END