tegra.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * NVIDIA Tegra SoC device tree board support
  3. *
  4. * Copyright (C) 2011, 2013, NVIDIA Corporation
  5. * Copyright (C) 2010 Secret Lab Technologies, Ltd.
  6. * Copyright (C) 2010 Google, Inc.
  7. *
  8. * This software is licensed under the terms of the GNU General Public
  9. * License version 2, as published by the Free Software Foundation, and
  10. * may be copied, distributed, and modified under those terms.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. */
  18. #include <linux/clocksource.h>
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/serial_8250.h>
  23. #include <linux/clk.h>
  24. #include <linux/dma-mapping.h>
  25. #include <linux/irqdomain.h>
  26. #include <linux/of.h>
  27. #include <linux/of_address.h>
  28. #include <linux/of_fdt.h>
  29. #include <linux/of_platform.h>
  30. #include <linux/pda_power.h>
  31. #include <linux/platform_data/tegra_usb.h>
  32. #include <linux/io.h>
  33. #include <linux/slab.h>
  34. #include <linux/sys_soc.h>
  35. #include <linux/usb/tegra_usb_phy.h>
  36. #include <linux/clk/tegra.h>
  37. #include <asm/mach-types.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/time.h>
  40. #include <asm/setup.h>
  41. #include "board.h"
  42. #include "common.h"
  43. #include "fuse.h"
  44. #include "iomap.h"
  45. static struct tegra_ehci_platform_data tegra_ehci1_pdata = {
  46. .operating_mode = TEGRA_USB_OTG,
  47. .power_down_on_bus_suspend = 1,
  48. .vbus_gpio = -1,
  49. };
  50. static struct tegra_ulpi_config tegra_ehci2_ulpi_phy_config = {
  51. .reset_gpio = -1,
  52. .clk = "cdev2",
  53. };
  54. static struct tegra_ehci_platform_data tegra_ehci2_pdata = {
  55. .phy_config = &tegra_ehci2_ulpi_phy_config,
  56. .operating_mode = TEGRA_USB_HOST,
  57. .power_down_on_bus_suspend = 1,
  58. .vbus_gpio = -1,
  59. };
  60. static struct tegra_ehci_platform_data tegra_ehci3_pdata = {
  61. .operating_mode = TEGRA_USB_HOST,
  62. .power_down_on_bus_suspend = 1,
  63. .vbus_gpio = -1,
  64. };
  65. static struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {
  66. OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5000000, "tegra-ehci.0",
  67. &tegra_ehci1_pdata),
  68. OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5004000, "tegra-ehci.1",
  69. &tegra_ehci2_pdata),
  70. OF_DEV_AUXDATA("nvidia,tegra20-ehci", 0xC5008000, "tegra-ehci.2",
  71. &tegra_ehci3_pdata),
  72. {}
  73. };
  74. static void __init tegra_dt_init(void)
  75. {
  76. struct soc_device_attribute *soc_dev_attr;
  77. struct soc_device *soc_dev;
  78. struct device *parent = NULL;
  79. tegra_clocks_apply_init_table();
  80. soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
  81. if (!soc_dev_attr)
  82. goto out;
  83. soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra");
  84. soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d", tegra_revision);
  85. soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%d", tegra_chip_id);
  86. soc_dev = soc_device_register(soc_dev_attr);
  87. if (IS_ERR(soc_dev)) {
  88. kfree(soc_dev_attr->family);
  89. kfree(soc_dev_attr->revision);
  90. kfree(soc_dev_attr->soc_id);
  91. kfree(soc_dev_attr);
  92. goto out;
  93. }
  94. parent = soc_device_to_device(soc_dev);
  95. /*
  96. * Finished with the static registrations now; fill in the missing
  97. * devices
  98. */
  99. out:
  100. of_platform_populate(NULL, of_default_bus_match_table,
  101. tegra20_auxdata_lookup, parent);
  102. }
  103. static void __init trimslice_init(void)
  104. {
  105. #ifdef CONFIG_TEGRA_PCI
  106. int ret;
  107. ret = tegra_pcie_init(true, true);
  108. if (ret)
  109. pr_err("tegra_pci_init() failed: %d\n", ret);
  110. #endif
  111. }
  112. static void __init harmony_init(void)
  113. {
  114. #ifdef CONFIG_TEGRA_PCI
  115. int ret;
  116. ret = harmony_pcie_init();
  117. if (ret)
  118. pr_err("harmony_pcie_init() failed: %d\n", ret);
  119. #endif
  120. }
  121. static void __init paz00_init(void)
  122. {
  123. if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
  124. tegra_paz00_wifikill_init();
  125. }
  126. static struct {
  127. char *machine;
  128. void (*init)(void);
  129. } board_init_funcs[] = {
  130. { "compulab,trimslice", trimslice_init },
  131. { "nvidia,harmony", harmony_init },
  132. { "compal,paz00", paz00_init },
  133. };
  134. static void __init tegra_dt_init_late(void)
  135. {
  136. int i;
  137. tegra_init_late();
  138. for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
  139. if (of_machine_is_compatible(board_init_funcs[i].machine)) {
  140. board_init_funcs[i].init();
  141. break;
  142. }
  143. }
  144. }
  145. static const char * const tegra_dt_board_compat[] = {
  146. "nvidia,tegra114",
  147. "nvidia,tegra30",
  148. "nvidia,tegra20",
  149. NULL
  150. };
  151. DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
  152. .map_io = tegra_map_common_io,
  153. .smp = smp_ops(tegra_smp_ops),
  154. .init_early = tegra_init_early,
  155. .init_irq = tegra_dt_init_irq,
  156. .init_time = clocksource_of_init,
  157. .init_machine = tegra_dt_init,
  158. .init_late = tegra_dt_init_late,
  159. .restart = tegra_assert_system_reset,
  160. .dt_compat = tegra_dt_board_compat,
  161. MACHINE_END