board-seaboard.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 <mach/iomap.h>
  27. #include <mach/irqs.h>
  28. #include <mach/sdhci.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include "board.h"
  32. #include "board-seaboard.h"
  33. #include "clock.h"
  34. #include "devices.h"
  35. #include "gpio-names.h"
  36. static struct plat_serial8250_port debug_uart_platform_data[] = {
  37. {
  38. /* Memory and IRQ filled in before registration */
  39. .flags = UPF_BOOT_AUTOCONF,
  40. .iotype = UPIO_MEM,
  41. .regshift = 2,
  42. .uartclk = 216000000,
  43. }, {
  44. .flags = 0,
  45. }
  46. };
  47. static struct platform_device debug_uart = {
  48. .name = "serial8250",
  49. .id = PLAT8250_DEV_PLATFORM,
  50. .dev = {
  51. .platform_data = debug_uart_platform_data,
  52. },
  53. };
  54. static __initdata struct tegra_clk_init_table seaboard_clk_init_table[] = {
  55. /* name parent rate enabled */
  56. { "uartb", "pll_p", 216000000, true},
  57. { "uartd", "pll_p", 216000000, true},
  58. { NULL, NULL, 0, 0},
  59. };
  60. static struct gpio_keys_button seaboard_gpio_keys_buttons[] = {
  61. {
  62. .code = SW_LID,
  63. .gpio = TEGRA_GPIO_LIDSWITCH,
  64. .active_low = 0,
  65. .desc = "Lid",
  66. .type = EV_SW,
  67. .wakeup = 1,
  68. .debounce_interval = 1,
  69. },
  70. {
  71. .code = KEY_POWER,
  72. .gpio = TEGRA_GPIO_POWERKEY,
  73. .active_low = 1,
  74. .desc = "Power",
  75. .type = EV_KEY,
  76. .wakeup = 1,
  77. },
  78. };
  79. static struct gpio_keys_platform_data seaboard_gpio_keys = {
  80. .buttons = seaboard_gpio_keys_buttons,
  81. .nbuttons = ARRAY_SIZE(seaboard_gpio_keys_buttons),
  82. };
  83. static struct platform_device seaboard_gpio_keys_device = {
  84. .name = "gpio-keys",
  85. .id = -1,
  86. .dev = {
  87. .platform_data = &seaboard_gpio_keys,
  88. }
  89. };
  90. static struct tegra_sdhci_platform_data sdhci_pdata1 = {
  91. .cd_gpio = -1,
  92. .wp_gpio = -1,
  93. .power_gpio = -1,
  94. };
  95. static struct tegra_sdhci_platform_data sdhci_pdata3 = {
  96. .cd_gpio = TEGRA_GPIO_SD2_CD,
  97. .wp_gpio = TEGRA_GPIO_SD2_WP,
  98. .power_gpio = TEGRA_GPIO_SD2_POWER,
  99. };
  100. static struct tegra_sdhci_platform_data sdhci_pdata4 = {
  101. .cd_gpio = -1,
  102. .wp_gpio = -1,
  103. .power_gpio = -1,
  104. .is_8bit = 1,
  105. };
  106. static struct platform_device *seaboard_devices[] __initdata = {
  107. &debug_uart,
  108. &tegra_pmu_device,
  109. &tegra_sdhci_device4,
  110. &tegra_sdhci_device3,
  111. &tegra_sdhci_device1,
  112. &seaboard_gpio_keys_device,
  113. };
  114. static struct i2c_board_info __initdata isl29018_device = {
  115. I2C_BOARD_INFO("isl29018", 0x44),
  116. .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ),
  117. };
  118. static struct i2c_board_info __initdata adt7461_device = {
  119. I2C_BOARD_INFO("adt7461", 0x4c),
  120. };
  121. static void __init seaboard_i2c_init(void)
  122. {
  123. gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
  124. gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
  125. i2c_register_board_info(0, &isl29018_device, 1);
  126. i2c_register_board_info(3, &adt7461_device, 1);
  127. platform_device_register(&tegra_i2c_device1);
  128. platform_device_register(&tegra_i2c_device2);
  129. platform_device_register(&tegra_i2c_device3);
  130. platform_device_register(&tegra_i2c_device4);
  131. }
  132. static void __init seaboard_common_init(void)
  133. {
  134. seaboard_pinmux_init();
  135. tegra_clk_init_from_table(seaboard_clk_init_table);
  136. tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
  137. tegra_sdhci_device3.dev.platform_data = &sdhci_pdata3;
  138. tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
  139. platform_add_devices(seaboard_devices, ARRAY_SIZE(seaboard_devices));
  140. }
  141. static void __init tegra_seaboard_init(void)
  142. {
  143. /* Seaboard uses UARTD for the debug port. */
  144. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTD_BASE);
  145. debug_uart_platform_data[0].mapbase = TEGRA_UARTD_BASE;
  146. debug_uart_platform_data[0].irq = INT_UARTD;
  147. seaboard_common_init();
  148. seaboard_i2c_init();
  149. }
  150. static void __init tegra_kaen_init(void)
  151. {
  152. /* Kaen uses UARTB for the debug port. */
  153. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
  154. debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
  155. debug_uart_platform_data[0].irq = INT_UARTB;
  156. seaboard_common_init();
  157. seaboard_i2c_init();
  158. }
  159. static void __init tegra_wario_init(void)
  160. {
  161. /* Wario uses UARTB for the debug port. */
  162. debug_uart_platform_data[0].membase = IO_ADDRESS(TEGRA_UARTB_BASE);
  163. debug_uart_platform_data[0].mapbase = TEGRA_UARTB_BASE;
  164. debug_uart_platform_data[0].irq = INT_UARTB;
  165. seaboard_common_init();
  166. seaboard_i2c_init();
  167. }
  168. MACHINE_START(SEABOARD, "seaboard")
  169. .boot_params = 0x00000100,
  170. .map_io = tegra_map_common_io,
  171. .init_early = tegra_init_early,
  172. .init_irq = tegra_init_irq,
  173. .timer = &tegra_timer,
  174. .init_machine = tegra_seaboard_init,
  175. MACHINE_END
  176. MACHINE_START(KAEN, "kaen")
  177. .boot_params = 0x00000100,
  178. .map_io = tegra_map_common_io,
  179. .init_early = tegra_init_early,
  180. .init_irq = tegra_init_irq,
  181. .timer = &tegra_timer,
  182. .init_machine = tegra_kaen_init,
  183. MACHINE_END
  184. MACHINE_START(WARIO, "wario")
  185. .boot_params = 0x00000100,
  186. .map_io = tegra_map_common_io,
  187. .init_early = tegra_init_early,
  188. .init_irq = tegra_init_irq,
  189. .timer = &tegra_timer,
  190. .init_machine = tegra_wario_init,
  191. MACHINE_END