tegra.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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/clk.h>
  19. #include <linux/clk/tegra.h>
  20. #include <linux/dma-mapping.h>
  21. #include <linux/init.h>
  22. #include <linux/io.h>
  23. #include <linux/irqchip.h>
  24. #include <linux/irqdomain.h>
  25. #include <linux/kernel.h>
  26. #include <linux/of_address.h>
  27. #include <linux/of_fdt.h>
  28. #include <linux/of.h>
  29. #include <linux/of_platform.h>
  30. #include <linux/pda_power.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/serial_8250.h>
  33. #include <linux/slab.h>
  34. #include <linux/sys_soc.h>
  35. #include <linux/usb/tegra_usb_phy.h>
  36. #include <soc/tegra/fuse.h>
  37. #include <soc/tegra/pmc.h>
  38. #include <asm/hardware/cache-l2x0.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/mach/time.h>
  41. #include <asm/mach-types.h>
  42. #include <asm/setup.h>
  43. #include <asm/trusted_foundations.h>
  44. #include "board.h"
  45. #include "common.h"
  46. #include "cpuidle.h"
  47. #include "flowctrl.h"
  48. #include "iomap.h"
  49. #include "irq.h"
  50. #include "pm.h"
  51. #include "reset.h"
  52. #include "sleep.h"
  53. /*
  54. * Storage for debug-macro.S's state.
  55. *
  56. * This must be in .data not .bss so that it gets initialized each time the
  57. * kernel is loaded. The data is declared here rather than debug-macro.S so
  58. * that multiple inclusions of debug-macro.S point at the same data.
  59. */
  60. u32 tegra_uart_config[3] = {
  61. /* Debug UART initialization required */
  62. 1,
  63. /* Debug UART physical address */
  64. 0,
  65. /* Debug UART virtual address */
  66. 0,
  67. };
  68. static void __init tegra_init_early(void)
  69. {
  70. of_register_trusted_foundations();
  71. tegra_cpu_reset_handler_init();
  72. tegra_flowctrl_init();
  73. }
  74. static void __init tegra_dt_init_irq(void)
  75. {
  76. tegra_init_irq();
  77. irqchip_init();
  78. tegra_legacy_irq_syscore_init();
  79. }
  80. static void __init tegra_dt_init(void)
  81. {
  82. struct soc_device_attribute *soc_dev_attr;
  83. struct soc_device *soc_dev;
  84. struct device *parent = NULL;
  85. tegra_clocks_apply_init_table();
  86. soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
  87. if (!soc_dev_attr)
  88. goto out;
  89. soc_dev_attr->family = kasprintf(GFP_KERNEL, "Tegra");
  90. soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d",
  91. tegra_sku_info.revision);
  92. soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%u", tegra_get_chip_id());
  93. soc_dev = soc_device_register(soc_dev_attr);
  94. if (IS_ERR(soc_dev)) {
  95. kfree(soc_dev_attr->family);
  96. kfree(soc_dev_attr->revision);
  97. kfree(soc_dev_attr->soc_id);
  98. kfree(soc_dev_attr);
  99. goto out;
  100. }
  101. parent = soc_device_to_device(soc_dev);
  102. /*
  103. * Finished with the static registrations now; fill in the missing
  104. * devices
  105. */
  106. out:
  107. of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
  108. }
  109. static void __init paz00_init(void)
  110. {
  111. if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
  112. tegra_paz00_wifikill_init();
  113. }
  114. static struct {
  115. char *machine;
  116. void (*init)(void);
  117. } board_init_funcs[] = {
  118. { "compal,paz00", paz00_init },
  119. };
  120. static void __init tegra_dt_init_late(void)
  121. {
  122. int i;
  123. tegra_init_suspend();
  124. tegra_cpuidle_init();
  125. for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
  126. if (of_machine_is_compatible(board_init_funcs[i].machine)) {
  127. board_init_funcs[i].init();
  128. break;
  129. }
  130. }
  131. }
  132. static const char * const tegra_dt_board_compat[] = {
  133. "nvidia,tegra124",
  134. "nvidia,tegra114",
  135. "nvidia,tegra30",
  136. "nvidia,tegra20",
  137. NULL
  138. };
  139. DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
  140. .l2c_aux_val = 0x3c400001,
  141. .l2c_aux_mask = 0xc20fc3fe,
  142. .smp = smp_ops(tegra_smp_ops),
  143. .map_io = tegra_map_common_io,
  144. .init_early = tegra_init_early,
  145. .init_irq = tegra_dt_init_irq,
  146. .init_machine = tegra_dt_init,
  147. .init_late = tegra_dt_init_late,
  148. .restart = tegra_pmc_restart,
  149. .dt_compat = tegra_dt_board_compat,
  150. MACHINE_END