board-seaboard.c 7.5 KB

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