regulator_dm.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. if (!rt_ofw_prop_read_u32(np, "regulator-enable-ramp-delay", &pval))
  37. {
  38. param->enable_delay = pval;
  39. }
  40. param->enable_active_high = rt_ofw_prop_read_bool(np, "enable-active-high");
  41. param->boot_on = rt_ofw_prop_read_bool(np, "regulator-boot-on");
  42. param->always_on = rt_ofw_prop_read_bool(np, "regulator-always-on");
  43. param->soft_start = rt_ofw_prop_read_bool(np, "regulator-soft-start");
  44. param->pull_down = rt_ofw_prop_read_bool(np, "regulator-pull-down");
  45. param->over_current_protection = rt_ofw_prop_read_bool(np, "regulator-over-current-protection");
  46. return RT_EOK;
  47. }
  48. #endif /* RT_USING_OFW */