evb-rk3399.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2016 Rockchip Electronics Co., Ltd
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <dm/pinctrl.h>
  8. #include <dm/uclass-internal.h>
  9. #include <asm/arch-rockchip/periph.h>
  10. #include <power/regulator.h>
  11. #include <spl.h>
  12. int board_init(void)
  13. {
  14. struct udevice *pinctrl, *regulator;
  15. int ret;
  16. /*
  17. * The PWM do not have decicated interrupt number in dts and can
  18. * not get periph_id by pinctrl framework, so let's init them here.
  19. * The PWM2 and PWM3 are for pwm regulater.
  20. */
  21. ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
  22. if (ret) {
  23. debug("%s: Cannot find pinctrl device\n", __func__);
  24. goto out;
  25. }
  26. /* Enable pwm0 for panel backlight */
  27. ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM0);
  28. if (ret) {
  29. debug("%s PWM0 pinctrl init fail! (ret=%d)\n", __func__, ret);
  30. goto out;
  31. }
  32. ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM2);
  33. if (ret) {
  34. debug("%s PWM2 pinctrl init fail!\n", __func__);
  35. goto out;
  36. }
  37. ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM3);
  38. if (ret) {
  39. debug("%s PWM3 pinctrl init fail!\n", __func__);
  40. goto out;
  41. }
  42. ret = regulators_enable_boot_on(false);
  43. if (ret)
  44. debug("%s: Cannot enable boot on regulator\n", __func__);
  45. ret = regulator_get_by_platname("vcc5v0_host", &regulator);
  46. if (ret) {
  47. debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret);
  48. goto out;
  49. }
  50. ret = regulator_set_enable(regulator, true);
  51. if (ret) {
  52. debug("%s vcc5v0-host-en set fail!\n", __func__);
  53. goto out;
  54. }
  55. out:
  56. return 0;
  57. }
  58. void spl_board_init(void)
  59. {
  60. struct udevice *pinctrl;
  61. int ret;
  62. ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
  63. if (ret) {
  64. debug("%s: Cannot find pinctrl device\n", __func__);
  65. goto err;
  66. }
  67. /* Enable debug UART */
  68. ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_UART_DBG);
  69. if (ret) {
  70. debug("%s: Failed to set up console UART\n", __func__);
  71. goto err;
  72. }
  73. preloader_console_init();
  74. return;
  75. err:
  76. printf("%s: Error %d\n", __func__, ret);
  77. /* No way to report error here */
  78. hang();
  79. }