board-seaboard.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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/i2c-tegra.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 <mach/iomap.h>
  28. #include <mach/irqs.h>
  29. #include <mach/sdhci.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include "board.h"
  33. #include "board-seaboard.h"
  34. #include "clock.h"
  35. #include "devices.h"
  36. #include "gpio-names.h"
  37. static struct plat_serial8250_port debug_uart_platform_data[] = {
  38. {
  39. /* Memory and IRQ filled in before registration */
  40. .flags = UPF_BOOT_AUTOCONF,
  41. .iotype = UPIO_MEM,
  42. .regshift = 2,
  43. .uartclk = 216000000,
  44. }, {
  45. .flags = 0,
  46. }
  47. };
  48. static struct platform_device debug_uart = {
  49. .name = "serial8250",
  50. .id = PLAT8250_DEV_PLATFORM,
  51. .dev = {
  52. .platform_data = debug_uart_platform_data,
  53. },
  54. };
  55. static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
  56. /* name parent rate enabled */
  57. { "uartb", "pll_p", 216000000, true},
  58. { "uartd", "pll_p", 216000000, true},
  59. { NULL, NULL, 0, 0},
  60. };
  61. static struct tegra_i2c_platform_data seaboard_i2c1_platform_data = {
  62. .bus_clk_rate = 400000.
  63. };
  64. static struct tegra_i2c_platform_data seaboard_i2c2_platform_data = {
  65. .bus_clk_rate = 400000,
  66. };
  67. static struct tegra_i2c_platform_data seaboard_i2c3_platform_data = {
  68. .bus_clk_rate = 400000,
  69. };
  70. static struct tegra_i2c_platform_data seaboard_dvc_platform_data = {
  71. .bus_clk_rate = 400000,
  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 platform_device *seaboard_devices[] __initdata = {
  120. &debug_uart,
  121. &tegra_pmu_device,
  122. &tegra_sdhci_device1,
  123. &tegra_sdhci_device3,
  124. &tegra_sdhci_device4,
  125. &seaboard_gpio_keys_device,
  126. };
  127. static struct i2c_board_info __initdata isl29018_device = {
  128. I2C_BOARD_INFO("isl29018", 0x44),
  129. .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ),
  130. };
  131. static struct i2c_board_info __initdata adt7461_device = {
  132. I2C_BOARD_INFO("adt7461", 0x4c),
  133. };
  134. static void __init seaboard_i2c_init(void)
  135. {
  136. gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
  137. gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
  138. i2c_register_board_info(0, &isl29018_device, 1);
  139. i2c_register_board_info(4, &adt7461_device, 1);
  140. tegra_i2c_device1.dev.platform_data = &seaboard_i2c1_platform_data;
  141. tegra_i2c_device2.dev.platform_data = &seaboard_i2c2_platform_data;
  142. tegra_i2c_device3.dev.platform_data = &seaboard_i2c3_platform_data;
  143. tegra_i2c_device4.dev.platform_data = &seaboard_dvc_platform_data;
  144. platform_device_register(&tegra_i2c_device1);
  145. platform_device_register(&tegra_i2c_device2);
  146. platform_device_register(&tegra_i2c_device3);
  147. platform_device_register(&tegra_i2c_device4);
  148. }
  149. static void __init seaboard_common_init(void)
  150. {
  151. seaboard_pinmux_init();
  152. tegra_clk_init_from_table(seaboard_clk_init_table);
  153. tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
  154. tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
  155. tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
  156. platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
  157. }
  158. static void __init tegra_seaboard_init(void)
  159. {
  160. /* Seaboard uses UARTD for the debug port. */
  161. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
  162. debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
  163. debug_uart_platform_data[0].irq = INT_UARTD;
  164. seaboard_common_init();
  165. seaboard_i2c_init();
  166. }
  167. static void __init tegra_kaen_init(void)
  168. {
  169. /* Kaen uses UARTB for the debug port. */
  170. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
  171. debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
  172. debug_uart_platform_data[0].irq = INT_UARTB;
  173. seaboard_common_init();
  174. seaboard_i2c_init();
  175. }
  176. static void __init tegra_wario_init(void)
  177. {
  178. /* Wario uses UARTB for the debug port. */
  179. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
  180. debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
  181. debug_uart_platform_data[0].irq = INT_UARTB;
  182. seaboard_common_init();
  183. seaboard_i2c_init();
  184. }
  185. MACHINE_START(SEABOARD, "seaboard")
  186. .boot_params = 0x00000100,
  187. .map_io = tegra_map_common_io,
  188. .init_early = tegra_init_early,
  189. .init_irq = tegra_init_irq,
  190. .timer = &tegra_timer,
  191. .init_machine = tegra_seaboard_init,
  192. MACHINE_END
  193. MACHINE_START(KAEN, "kaen")
  194. .boot_params = 0x00000100,
  195. .map_io = tegra_map_common_io,
  196. .init_early = tegra_init_early,
  197. .init_irq = tegra_init_irq,
  198. .timer = &tegra_timer,
  199. .init_machine = tegra_kaen_init,
  200. MACHINE_END
  201. MACHINE_START(WARIO, "wario")
  202. .boot_params = 0x00000100,
  203. .map_io = tegra_map_common_io,
  204. .init_early = tegra_init_early,
  205. .init_irq = tegra_init_irq,
  206. .timer = &tegra_timer,
  207. .init_machine = tegra_wario_init,
  208. MACHINE_END