diff options
author | Tom Rini <trini@konsulko.com> | 2023-04-30 21:29:50 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-04-30 21:29:50 -0400 |
commit | 27dc8826441f0c5dd6aa6617a32909d9049f1202 (patch) | |
tree | 18a2dcc2249614fe95b52983a5abe5e992d74840 /drivers/power/regulator | |
parent | fe3a77cb157a6210d8036845f5f80ea67c183563 (diff) | |
parent | 25bc7bfc30532098d9207783ff2ca45cdc5a0161 (diff) | |
download | u-boot-WIP/30Apr2023.zip u-boot-WIP/30Apr2023.tar.gz u-boot-WIP/30Apr2023.tar.bz2 |
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxiWIP/30Apr2023
Please pull the second part of the sunxi pull request for this cycle.
Another bunch of patches that replace old-school U-Boot hacks with
proper DM based code, this time for the raw NAND flash driver, and the
USB PHY VBUS detection code. Plus two smaller patches that were sitting
in my inbox for a while.
Gitlab CI passed. In lack of some supported board with NAND flash I
couldn't really test this part, but apparently this was tested by the
reviewer. I briefly ran the branch on some boards with USB-OTG, and
this still worked.
Diffstat (limited to 'drivers/power/regulator')
-rw-r--r-- | drivers/power/regulator/Kconfig | 7 | ||||
-rw-r--r-- | drivers/power/regulator/Makefile | 1 | ||||
-rw-r--r-- | drivers/power/regulator/axp_usb_power.c | 49 |
3 files changed, 57 insertions, 0 deletions
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index c346d03..eb5aa38 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -57,6 +57,13 @@ config SPL_REGULATOR_AXP Enable support in SPL for the regulators (DCDCs, LDOs) in the X-Powers AXP152, AXP2xx, and AXP8xx PMICs. +config REGULATOR_AXP_USB_POWER + bool "Enable driver for X-Powers AXP PMIC USB power supply" + depends on DM_REGULATOR && PMIC_AXP + help + Enable support for reading the USB power supply status from + X-Powers AXP2xx and AXP8xx PMICs. + config DM_REGULATOR_BD71837 bool "Enable Driver Model for ROHM BD71837/BD71847 regulators" depends on DM_REGULATOR && DM_PMIC_BD71837 diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile index 2d97e10..d9e0cd5 100644 --- a/drivers/power/regulator/Makefile +++ b/drivers/power/regulator/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR) += regulator-uclass.o obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o obj-$(CONFIG_$(SPL_)REGULATOR_AXP) += axp_regulator.o +obj-$(CONFIG_$(SPL_)REGULATOR_AXP_USB_POWER) += axp_usb_power.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o obj-$(CONFIG_DM_REGULATOR_NPCM8XX) += npcm8xx_regulator.o diff --git a/drivers/power/regulator/axp_usb_power.c b/drivers/power/regulator/axp_usb_power.c new file mode 100644 index 0000000..f32fb6a --- /dev/null +++ b/drivers/power/regulator/axp_usb_power.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <dm/device.h> +#include <errno.h> +#include <power/pmic.h> +#include <power/regulator.h> + +#define AXP_POWER_STATUS 0x00 +#define AXP_POWER_STATUS_VBUS_PRESENT BIT(5) + +static int axp_usb_power_get_enable(struct udevice *dev) +{ + int ret; + + ret = pmic_reg_read(dev->parent, AXP_POWER_STATUS); + if (ret < 0) + return ret; + + return !!(ret & AXP_POWER_STATUS_VBUS_PRESENT); +} + +static const struct dm_regulator_ops axp_usb_power_ops = { + .get_enable = axp_usb_power_get_enable, +}; + +static int axp_usb_power_probe(struct udevice *dev) +{ + struct dm_regulator_uclass_plat *uc_plat = dev_get_uclass_plat(dev); + + uc_plat->type = REGULATOR_TYPE_FIXED; + + return 0; +} + +static const struct udevice_id axp_usb_power_ids[] = { + { .compatible = "x-powers,axp202-usb-power-supply" }, + { .compatible = "x-powers,axp221-usb-power-supply" }, + { .compatible = "x-powers,axp223-usb-power-supply" }, + { .compatible = "x-powers,axp813-usb-power-supply" }, + { } +}; + +U_BOOT_DRIVER(axp_usb_power) = { + .name = "axp_usb_power", + .id = UCLASS_REGULATOR, + .of_match = axp_usb_power_ids, + .probe = axp_usb_power_probe, + .ops = &axp_usb_power_ops, +}; |