board-harmony.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * arch/arm/mach-tegra/board-harmony.c
  3. *
  4. * Copyright (C) 2010 Google, Inc.
  5. * Copyright (C) 2011 NVIDIA, Inc.
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/serial_8250.h>
  21. #include <linux/clk.h>
  22. #include <linux/dma-mapping.h>
  23. #include <linux/pda_power.h>
  24. #include <linux/io.h>
  25. #include <linux/gpio.h>
  26. #include <linux/i2c.h>
  27. #include <linux/i2c-tegra.h>
  28. #include <sound/wm8903.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/time.h>
  32. #include <asm/setup.h>
  33. #include <mach/tegra_wm8903_pdata.h>
  34. #include <mach/iomap.h>
  35. #include <mach/irqs.h>
  36. #include <mach/sdhci.h>
  37. #include "board.h"
  38. #include "board-harmony.h"
  39. #include "clock.h"
  40. #include "devices.h"
  41. #include "gpio-names.h"
  42. static struct plat_serial8250_port debug_uart_platform_data[] = {
  43. {
  44. .membase = IO_ADDRESS(TEGRA_UARTD_BASE),
  45. .mapbase = TEGRA_UARTD_BASE,
  46. .irq = INT_UARTD,
  47. .flags = UPF_BOOT_AUTOCONF,
  48. .iotype = UPIO_MEM,
  49. .regshift = 2,
  50. .uartclk = 216000000,
  51. }, {
  52. .flags = 0
  53. }
  54. };
  55. static struct platform_device debug_uart = {
  56. .name = "serial8250",
  57. .id = PLAT8250_DEV_PLATFORM,
  58. .dev = {
  59. .platform_data = debug_uart_platform_data,
  60. },
  61. };
  62. static struct tegra_wm8903_platform_data harmony_audio_pdata = {
  63. .gpio_spkr_en = TEGRA_GPIO_SPKR_EN,
  64. .gpio_hp_det = TEGRA_GPIO_HP_DET,
  65. .gpio_hp_mute = -1,
  66. .gpio_int_mic_en = TEGRA_GPIO_INT_MIC_EN,
  67. .gpio_ext_mic_en = TEGRA_GPIO_EXT_MIC_EN,
  68. };
  69. static struct platform_device harmony_audio_device = {
  70. .name = "tegra-snd-wm8903",
  71. .id = 0,
  72. .dev = {
  73. .platform_data = &harmony_audio_pdata,
  74. },
  75. };
  76. static struct tegra_i2c_platform_data harmony_i2c1_platform_data = {
  77. .bus_clk_rate = 400000,
  78. };
  79. static struct tegra_i2c_platform_data harmony_i2c2_platform_data = {
  80. .bus_clk_rate = 400000,
  81. };
  82. static struct tegra_i2c_platform_data harmony_i2c3_platform_data = {
  83. .bus_clk_rate = 400000,
  84. };
  85. static struct tegra_i2c_platform_data harmony_dvc_platform_data = {
  86. .bus_clk_rate = 400000,
  87. };
  88. static struct wm8903_platform_data harmony_wm8903_pdata = {
  89. .irq_active_low = 0,
  90. .micdet_cfg = 0,
  91. .micdet_delay = 100,
  92. .gpio_base = HARMONY_GPIO_WM8903(0),
  93. .gpio_cfg = {
  94. WM8903_GPIO_NO_CONFIG,
  95. WM8903_GPIO_NO_CONFIG,
  96. 0,
  97. WM8903_GPIO_NO_CONFIG,
  98. WM8903_GPIO_NO_CONFIG,
  99. },
  100. };
  101. static struct i2c_board_info __initdata wm8903_board_info = {
  102. I2C_BOARD_INFO("wm8903", 0x1a),
  103. .platform_data = &harmony_wm8903_pdata,
  104. .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
  105. };
  106. static void __init harmony_i2c_init(void)
  107. {
  108. tegra_i2c_device1.dev.platform_data = &harmony_i2c1_platform_data;
  109. tegra_i2c_device2.dev.platform_data = &harmony_i2c2_platform_data;
  110. tegra_i2c_device3.dev.platform_data = &harmony_i2c3_platform_data;
  111. tegra_i2c_device4.dev.platform_data = &harmony_dvc_platform_data;
  112. platform_device_register(&tegra_i2c_device1);
  113. platform_device_register(&tegra_i2c_device2);
  114. platform_device_register(&tegra_i2c_device3);
  115. platform_device_register(&tegra_i2c_device4);
  116. i2c_register_board_info(0, &wm8903_board_info, 1);
  117. }
  118. static struct platform_device *harmony_devices[] __initdata = {
  119. &debug_uart,
  120. &tegra_sdhci_device1,
  121. &tegra_sdhci_device2,
  122. &tegra_sdhci_device4,
  123. &tegra_i2s_device1,
  124. &tegra_das_device,
  125. &tegra_pcm_device,
  126. &harmony_audio_device,
  127. };
  128. static void __init tegra_harmony_fixup(struct machine_desc *desc,
  129. struct tag *tags, char **cmdline, struct meminfo *mi)
  130. {
  131. mi->nr_banks = 2;
  132. mi->bank[0].start = PHYS_OFFSET;
  133. mi->bank[0].size = 448 * SZ_1M;
  134. mi->bank[1].start = SZ_512M;
  135. mi->bank[1].size = SZ_512M;
  136. }
  137. static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = {
  138. /* name parent rate enabled */
  139. { "uartd", "pll_p", 216000000, true },
  140. { "pll_a", "pll_p_out1", 56448000, true },
  141. { "pll_a_out0", "pll_a", 11289600, true },
  142. { "cdev1", NULL, 0, true },
  143. { "i2s1", "pll_a_out0", 11289600, false},
  144. { NULL, NULL, 0, 0},
  145. };
  146. static struct tegra_sdhci_platform_data sdhci_pdata1 = {
  147. .cd_gpio = -1,
  148. .wp_gpio = -1,
  149. .power_gpio = -1,
  150. };
  151. static struct tegra_sdhci_platform_data sdhci_pdata2 = {
  152. .cd_gpio = TEGRA_GPIO_SD2_CD,
  153. .wp_gpio = TEGRA_GPIO_SD2_WP,
  154. .power_gpio = TEGRA_GPIO_SD2_POWER,
  155. };
  156. static struct tegra_sdhci_platform_data sdhci_pdata4 = {
  157. .cd_gpio = TEGRA_GPIO_SD4_CD,
  158. .wp_gpio = TEGRA_GPIO_SD4_WP,
  159. .power_gpio = TEGRA_GPIO_SD4_POWER,
  160. .is_8bit = 1,
  161. };
  162. static void __init tegra_harmony_init(void)
  163. {
  164. tegra_clk_init_from_table(harmony_clk_init_table);
  165. harmony_pinmux_init();
  166. tegra_sdhci_device1.dev.platform_data = &sdhci_pdata1;
  167. tegra_sdhci_device2.dev.platform_data = &sdhci_pdata2;
  168. tegra_sdhci_device4.dev.platform_data = &sdhci_pdata4;
  169. platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices));
  170. harmony_i2c_init();
  171. harmony_regulator_init();
  172. }
  173. MACHINE_START(HARMONY, "harmony")
  174. .boot_params = 0x00000100,
  175. .fixup = tegra_harmony_fixup,
  176. .map_io = tegra_map_common_io,
  177. .init_early = tegra_init_early,
  178. .init_irq = tegra_init_irq,
  179. .timer = &tegra_timer,
  180. .init_machine = tegra_harmony_init,
  181. MACHINE_END