regulator_dm.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-09-23 GuEe-GUI first version
  9. */
  10. #include "regulator_dm.h"
  11. #ifdef RT_USING_OFW
  12. rt_err_t regulator_ofw_parse(struct rt_ofw_node *np, struct rt_regulator_param *param)
  13. {
  14. rt_uint32_t pval;
  15. param->name = rt_ofw_prop_read_raw(np, "regulator-name", RT_NULL);
  16. if (!rt_ofw_prop_read_u32(np, "regulator-min-microvolt", &pval))
  17. {
  18. param->min_uvolt = pval;
  19. }
  20. if (!rt_ofw_prop_read_u32(np, "regulator-max-microvolt", &pval))
  21. {
  22. param->max_uvolt = pval;
  23. }
  24. if (!rt_ofw_prop_read_u32(np, "regulator-min-microamp", &pval))
  25. {
  26. param->min_uamp = pval;
  27. }
  28. if (!rt_ofw_prop_read_u32(np, "regulator-max-microamp", &pval))
  29. {
  30. param->max_uamp = pval;
  31. }
  32. if (!rt_ofw_prop_read_u32(np, "regulator-ramp-delay", &pval))
  33. {
  34. param->ramp_delay = pval;
  35. }
  36. else
  37. {
  38. param->ramp_disable = RT_TRUE;
  39. }
  40. if (!rt_ofw_prop_read_u32(np, "regulator-enable-ramp-delay", &pval))
  41. {
  42. param->enable_delay = pval;
  43. }
  44. if (!rt_ofw_prop_read_u32(np, "regulator-settling-time-us", &pval))
  45. {
  46. param->settling_time = pval;
  47. }
  48. if (!rt_ofw_prop_read_u32(np, "regulator-settling-time-up-us", &pval))
  49. {
  50. param->settling_time_up = pval;
  51. }
  52. if (!rt_ofw_prop_read_u32(np, "regulator-settling-time-down-us", &pval))
  53. {
  54. param->settling_time_down = pval;
  55. }
  56. param->enable_active_high = rt_ofw_prop_read_bool(np, "enable-active-high");
  57. param->boot_on = rt_ofw_prop_read_bool(np, "regulator-boot-on");
  58. param->always_on = rt_ofw_prop_read_bool(np, "regulator-always-on");
  59. param->soft_start = rt_ofw_prop_read_bool(np, "regulator-soft-start");
  60. param->pull_down = rt_ofw_prop_read_bool(np, "regulator-pull-down");
  61. param->over_current_protection = rt_ofw_prop_read_bool(np, "regulator-over-current-protection");
  62. return RT_EOK;
  63. }
  64. #endif /* RT_USING_OFW */