nyan-big.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * (C) Copyright 2014
  3. * NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.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 *pmic;
  43. int ret;
  44. ret = as3722_get(&pmic);
  45. if (ret)
  46. return -ENOENT;
  47. if (board_id == 0)
  48. as3722_write(pmic, 0x00, 0x3c);
  49. else
  50. as3722_write(pmic, 0x00, 0x50);
  51. as3722_write(pmic, 0x12, 0x10);
  52. as3722_write(pmic, 0x0c, 0x07);
  53. as3722_write(pmic, 0x20, 0x10);
  54. return 0;
  55. }
  56. /* Setup required information for Linux kernel */
  57. static void setup_kernel_info(void)
  58. {
  59. struct mc_ctlr *mc = (void *)NV_PA_MC_BASE;
  60. /* The kernel graphics driver needs this region locked down */
  61. writel(0, &mc->mc_video_protect_bom);
  62. writel(0, &mc->mc_video_protect_size_mb);
  63. writel(1, &mc->mc_video_protect_reg_ctrl);
  64. }
  65. /*
  66. * We need to take ALL audio devices conntected to AHUB (AUDIO, APBIF,
  67. * I2S, DAM, AMX, ADX, SPDIF, AFC) out of reset and enable the clocks.
  68. * Otherwise reading AHUB devices will hang when the kernel boots.
  69. */
  70. static void enable_required_clocks(void)
  71. {
  72. static enum periph_id ids[] = {
  73. PERIPH_ID_I2S0,
  74. PERIPH_ID_I2S1,
  75. PERIPH_ID_I2S2,
  76. PERIPH_ID_I2S3,
  77. PERIPH_ID_I2S4,
  78. PERIPH_ID_AUDIO,
  79. PERIPH_ID_APBIF,
  80. PERIPH_ID_DAM0,
  81. PERIPH_ID_DAM1,
  82. PERIPH_ID_DAM2,
  83. PERIPH_ID_AMX0,
  84. PERIPH_ID_AMX1,
  85. PERIPH_ID_ADX0,
  86. PERIPH_ID_ADX1,
  87. PERIPH_ID_SPDIF,
  88. PERIPH_ID_AFC0,
  89. PERIPH_ID_AFC1,
  90. PERIPH_ID_AFC2,
  91. PERIPH_ID_AFC3,
  92. PERIPH_ID_AFC4,
  93. PERIPH_ID_AFC5,
  94. PERIPH_ID_EXTPERIPH1
  95. };
  96. int i;
  97. for (i = 0; i < ARRAY_SIZE(ids); i++)
  98. clock_enable(ids[i]);
  99. udelay(2);
  100. for (i = 0; i < ARRAY_SIZE(ids); i++)
  101. reset_set_enable(ids[i], 0);
  102. }
  103. int nvidia_board_init(void)
  104. {
  105. clock_start_periph_pll(PERIPH_ID_EXTPERIPH1, CLOCK_ID_OSC, 12000000);
  106. clock_start_periph_pll(PERIPH_ID_I2S1, CLOCK_ID_OSC, 1500000);
  107. /* For external MAX98090 audio codec */
  108. clock_external_output(1);
  109. setup_kernel_info();
  110. enable_required_clocks();
  111. return 0;
  112. }