board-seaboard.c 7.5 KB

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