nyan-big.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2014
  4. * NVIDIA Corporation <www.nvidia.com>
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <errno.h>
  9. #include <asm/gpio.h>
  10. #include <asm/io.h>
  11. #include <asm/arch/pinmux.h>
  12. #include <asm/arch/clock.h>
  13. #include <asm/arch/mc.h>
  14. #include <asm/arch-tegra/clk_rst.h>
  15. #include <asm/arch-tegra/pmc.h>
  16. #include <power/as3722.h>
  17. #include <power/pmic.h>
  18. #include "pinmux-config-nyan-big.h"
  19. /*
  20. * Routine: pinmux_init
  21. * Description: Do individual peripheral pinmux configs
  22. */
  23. void pinmux_init(void)
  24. {
  25. gpio_config_table(nyan_big_gpio_inits,
  26. ARRAY_SIZE(nyan_big_gpio_inits));
  27. pinmux_config_pingrp_table(nyan_big_pingrps,
  28. ARRAY_SIZE(nyan_big_pingrps));
  29. pinmux_config_drvgrp_table(nyan_big_drvgrps,
  30. ARRAY_SIZE(nyan_big_drvgrps));
  31. }
  32. int tegra_board_id(void)
  33. {
  34. static const int vector[] = {TEGRA_GPIO(Q, 3), TEGRA_GPIO(T, 1),
  35. TEGRA_GPIO(X, 1), TEGRA_GPIO(X, 4),
  36. -1};
  37. gpio_claim_vector(vector, "board_id%d");
  38. return gpio_get_values_as_int(vector);
  39. }
  40. int tegra_lcd_pmic_init(int board_id)
  41. {
  42. struct udevice *dev;
  43. int ret;
  44. ret = uclass_get_device_by_driver(UCLASS_PMIC,
  45. DM_GET_DRIVER(pmic_as3722), &dev);
  46. if (ret) {
  47. debug("%s: Failed to find PMIC\n", __func__);
  48. return ret;
  49. }
  50. if (board_id == 0)
  51. pmic_reg_write(dev, 0x00, 0x3c);
  52. else
  53. pmic_reg_write(dev, 0x00, 0x50);
  54. pmic_reg_write(dev, 0x12, 0x10);
  55. pmic_reg_write(dev, 0x0c, 0x07);
  56. pmic_reg_write(dev, 0x20, 0x10);
  57. return 0;
  58. }
  59. /* Setup required information for Linux kernel */
  60. static void setup_kernel_info(void)
  61. {
  62. struct mc_ctlr *mc = (void *)NV_PA_MC_BASE;
  63. /* The kernel graphics driver needs this region locked down */
  64. writel(0, &mc->mc_video_protect_bom);
  65. writel(0, &mc->mc_video_protect_size_mb);
  66. writel(1, &mc->mc_video_protect_reg_ctrl);
  67. }
  68. /*
  69. * We need to take ALL audio devices conntected to AHUB (AUDIO, APBIF,
  70. * I2S, DAM, AMX, ADX, SPDIF, AFC) out of reset and enable the clocks.
  71. * Otherwise reading AHUB devices will hang when the kernel boots.
  72. */
  73. static void enable_required_clocks(void)
  74. {
  75. static enum periph_id ids[] = {
  76. PERIPH_ID_I2S0,
  77. PERIPH_ID_I2S1,
  78. PERIPH_ID_I2S2,
  79. PERIPH_ID_I2S3,
  80. PERIPH_ID_I2S4,
  81. PERIPH_ID_AUDIO,
  82. PERIPH_ID_APBIF,
  83. PERIPH_ID_DAM0,
  84. PERIPH_ID_DAM1,
  85. PERIPH_ID_DAM2,
  86. PERIPH_ID_AMX0,
  87. PERIPH_ID_AMX1,
  88. PERIPH_ID_ADX0,
  89. PERIPH_ID_ADX1,
  90. PERIPH_ID_SPDIF,
  91. PERIPH_ID_AFC0,
  92. PERIPH_ID_AFC1,
  93. PERIPH_ID_AFC2,
  94. PERIPH_ID_AFC3,
  95. PERIPH_ID_AFC4,
  96. PERIPH_ID_AFC5,
  97. PERIPH_ID_EXTPERIPH1
  98. };
  99. int i;
  100. for (i = 0; i < ARRAY_SIZE(ids); i++)
  101. clock_enable(ids[i]);
  102. udelay(2);
  103. for (i = 0; i < ARRAY_SIZE(ids); i++)
  104. reset_set_enable(ids[i], 0);
  105. }
  106. int nvidia_board_init(void)
  107. {
  108. clock_start_periph_pll(PERIPH_ID_EXTPERIPH1, CLOCK_ID_OSC, 12000000);
  109. clock_start_periph_pll(PERIPH_ID_I2S1, CLOCK_ID_OSC, 1500000);
  110. /* For external MAX98090 audio codec */
  111. clock_external_output(1);
  112. setup_kernel_info();
  113. enable_required_clocks();
  114. return 0;
  115. }