From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 18/26] power: Add a regulator driver for the as3722 PMIC
Date: Sun, 21 May 2017 01:40:21 +0200 [thread overview]
Message-ID: <20170521014021.0215fe9c@jawa> (raw)
In-Reply-To: <20170519143109.21683-19-sjg@chromium.org>
On Fri, 19 May 2017 08:31:01 -0600
Simon Glass <sjg@chromium.org> wrote:
> This pmic includes regulators which should have their own driver. Add
> a driver to support these.
Reviewed-by: Lukasz Majewski <lukma@denx.de>
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> drivers/power/regulator/Kconfig | 9 ++
> drivers/power/regulator/Makefile | 1 +
> drivers/power/regulator/as3722_regulator.c | 149
> +++++++++++++++++++++++++++++
> include/power/as3722.h | 8 ++ 4 files changed,
> 167 insertions(+) create mode 100644
> drivers/power/regulator/as3722_regulator.c
>
> diff --git a/drivers/power/regulator/Kconfig
> b/drivers/power/regulator/Kconfig index ef057e0e2f..2583a19910 100644
> --- a/drivers/power/regulator/Kconfig
> +++ b/drivers/power/regulator/Kconfig
> @@ -34,6 +34,15 @@ config REGULATOR_ACT8846
> by the PMIC device. This driver is controlled by a device
> tree node which includes voltage limits.
>
> +config REGULATOR_AS3722
> + bool "Enable driver for AS7322 regulator"
> + depends on DM_REGULATOR && PMIC_AS3722
> + help
> + Enable support for the regulator functions of the AS3722.
> The
> + driver implements enable/disable for step-down bucks and
> LDOs,
> + but does not yet support change voltages. Currently this
> must be
> + done using direct register writes to the PMIC.
> +
> config DM_REGULATOR_PFUZE100
> bool "Enable Driver Model for REGULATOR PFUZE100"
> depends on DM_REGULATOR && DM_PMIC_PFUZE100
> diff --git a/drivers/power/regulator/Makefile
> b/drivers/power/regulator/Makefile index 3e01021b76..48d3735d6c 100644
> --- a/drivers/power/regulator/Makefile
> +++ b/drivers/power/regulator/Makefile
> @@ -7,6 +7,7 @@
>
> obj-$(CONFIG_$(SPL_)DM_REGULATOR) += regulator-uclass.o
> obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o
> +obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o
> obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o
> obj-$(CONFIG_DM_REGULATOR_PFUZE100) += pfuze100.o
> obj-$(CONFIG_REGULATOR_PWM) += pwm_regulator.o
> diff --git a/drivers/power/regulator/as3722_regulator.c
> b/drivers/power/regulator/as3722_regulator.c new file mode 100644
> index 0000000000..0122e1e389
> --- /dev/null
> +++ b/drivers/power/regulator/as3722_regulator.c
> @@ -0,0 +1,149 @@
> +/*
> + * Copyright (C) 2017 Google, Inc
> + * Written by Simon Glass <sjg@chromium.org>
> + *
> + * Placeholder regulator driver for as3722.
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <errno.h>
> +#include <power/as3722.h>
> +#include <power/pmic.h>
> +#include <power/regulator.h>
> +
> +static int stepdown_get_value(struct udevice *dev)
> +{
> + return -ENOSYS;
> +}
> +
> +static int stepdown_set_value(struct udevice *dev, int uvolt)
> +{
> + return -ENOSYS;
> +}
> +
> +static int stepdown_set_enable(struct udevice *dev, bool enable)
> +{
> + struct udevice *pmic = dev_get_parent(dev);
> + int sd = dev->driver_data;
> + int ret;
> +
> + ret = pmic_clrsetbits(pmic, AS3722_SD_CONTROL, 0, 1 << sd);
> + if (ret < 0) {
> + debug("%s: failed to write SD control register: %d",
> __func__,
> + ret);
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static bool stepdown_get_enable(struct udevice *dev)
> +{
> + struct udevice *pmic = dev_get_parent(dev);
> + int sd = dev->driver_data;
> + int ret;
> +
> + ret = pmic_reg_read(pmic, AS3722_SD_CONTROL);
> + if (ret < 0) {
> + debug("%s: failed to read SD control register: %d",
> __func__,
> + ret);
> + return false;
> + }
> +
> + return ret & (1 << sd) ? true : false;
> +}
> +
> +static int ldo_get_value(struct udevice *dev)
> +{
> + return -ENOSYS;
> +}
> +
> +static int ldo_set_value(struct udevice *dev, int uvolt)
> +{
> + return -ENOSYS;
> +}
> +
> +static int ldo_set_enable(struct udevice *dev, bool enable)
> +{
> + struct udevice *pmic = dev_get_parent(dev);
> + int ldo = dev->driver_data;
> + int ret;
> +
> + ret = pmic_clrsetbits(pmic, AS3722_LDO_CONTROL, 0, 1 << ldo);
> + if (ret < 0) {
> + debug("%s: failed to write LDO control register:
> %d", __func__,
> + ret);
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static bool ldo_get_enable(struct udevice *dev)
> +{
> + struct udevice *pmic = dev_get_parent(dev);
> + int ldo = dev->driver_data;
> + int ret;
> +
> + ret = pmic_reg_read(pmic, AS3722_LDO_CONTROL);
> + if (ret < 0) {
> + debug("%s: failed to read SD control register: %d",
> __func__,
> + ret);
> + return false;
> + }
> +
> + return ret & (1 << ldo) ? true : false;
> +}
> +
> +static int as3722_stepdown_probe(struct udevice *dev)
> +{
> + struct dm_regulator_uclass_platdata *uc_pdata;
> +
> + uc_pdata = dev_get_uclass_platdata(dev);
> +
> + uc_pdata->type = REGULATOR_TYPE_BUCK;
> +
> + return 0;
> +}
> +
> +static int as3722_ldo_probe(struct udevice *dev)
> +{
> + struct dm_regulator_uclass_platdata *uc_pdata;
> +
> + uc_pdata = dev_get_uclass_platdata(dev);
> +
> + uc_pdata->type = REGULATOR_TYPE_LDO;
> +
> + return 0;
> +}
> +
> +static const struct dm_regulator_ops as3722_stepdown_ops = {
> + .get_value = stepdown_get_value,
> + .set_value = stepdown_set_value,
> + .get_enable = stepdown_get_enable,
> + .set_enable = stepdown_set_enable,
> +};
> +
> +static const struct dm_regulator_ops as3722_ldo_ops = {
> + .get_value = ldo_get_value,
> + .set_value = ldo_set_value,
> + .get_enable = ldo_get_enable,
> + .set_enable = ldo_set_enable,
> +};
> +
> +U_BOOT_DRIVER(as3722_stepdown) = {
> + .name = "as3722_stepdown",
> + .id = UCLASS_REGULATOR,
> + .ops = &as3722_stepdown_ops,
> + .probe = as3722_stepdown_probe,
> +};
> +
> +U_BOOT_DRIVER(as3722_ldo) = {
> + .name = "as3722_ldo",
> + .id = UCLASS_REGULATOR,
> + .ops = &as3722_ldo_ops,
> + .probe = as3722_ldo_probe,
> +};
> diff --git a/include/power/as3722.h b/include/power/as3722.h
> index 0f22482ff7..14afa0c81a 100644
> --- a/include/power/as3722.h
> +++ b/include/power/as3722.h
> @@ -12,6 +12,14 @@
> #define AS3722_GPIO_OUTPUT_VDDH (1 << 0)
> #define AS3722_GPIO_INVERT (1 << 1)
>
> +#define AS3722_DEVICE_ID 0x0c
> +#define AS3722_SD_VOLTAGE(n) (0x00 + (n))
> +#define AS3722_LDO_VOLTAGE(n) (0x10 + (n))
> +#define AS3722_SD_CONTROL 0x4d
> +#define AS3722_LDO_CONTROL 0x4e
> +#define AS3722_ASIC_ID1 0x90
> +#define AS3722_ASIC_ID2 0x91
> +
> struct udevice;
>
> int as3722_init(struct udevice **devp);
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
next prev parent reply other threads:[~2017-05-20 23:40 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-19 14:30 [U-Boot] [PATCH 00/26] dm: tegra: Move nyan-big to livetree Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 01/26] dm: video: Sync display on backspace Simon Glass
2017-05-19 14:53 ` Anatolij Gustschin
2017-05-19 14:30 ` [U-Boot] [PATCH 02/26] dm: video: Update pwm_backlight to support livetree Simon Glass
2017-05-19 14:55 ` Anatolij Gustschin
2017-05-19 14:30 ` [U-Boot] [PATCH 03/26] video: simple-panel: Add a little more debugging Simon Glass
2017-05-19 14:56 ` Anatolij Gustschin
2017-05-19 14:30 ` [U-Boot] [PATCH 04/26] tegra: Fix up include file ordering Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 05/26] tegra: spl: Enable debug UART Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 06/26] tegra: nyan: Add a PMC syscon driver Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 07/26] dm: tegra: Convert USB setup to livetree Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 08/26] dm: tegra: Convert clock_decode_periph_id() to support livetree Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 09/26] dm: video: tegra124: Convert to livetree Simon Glass
2017-05-19 15:02 ` Anatolij Gustschin
2017-05-19 14:30 ` [U-Boot] [PATCH 10/26] tegra: dts: Move stdout-path to /chosen Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 11/26] tegra: Don't set up the UART clocks again in U-Boot Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 12/26] dm: tegra: gpio: Convert to support livetree Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 13/26] dm: tegra: usb: Convert to livetree Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 14/26] dm: tegra: spi: " Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 15/26] dm: tegra: i2c: " Simon Glass
2017-05-19 14:30 ` [U-Boot] [PATCH 16/26] dm: tegra: pwm: " Simon Glass
2017-05-19 14:31 ` [U-Boot] [PATCH 17/26] dm: tegra: mmc: " Simon Glass
2017-05-19 14:31 ` [U-Boot] [PATCH 18/26] power: Add a regulator driver for the as3722 PMIC Simon Glass
2017-05-20 23:40 ` Lukasz Majewski [this message]
2017-05-19 14:31 ` [U-Boot] [PATCH 19/26] power: Add a GPIO " Simon Glass
2017-05-20 23:40 ` Lukasz Majewski
2017-05-19 14:31 ` [U-Boot] [PATCH 20/26] dm: power: Convert as3722 to driver model Simon Glass
2017-05-20 23:41 ` Lukasz Majewski
2017-05-19 14:31 ` [U-Boot] [PATCH 21/26] dm: serial: ns16550: Convert to livetree Simon Glass
2017-05-19 14:31 ` [U-Boot] [PATCH 22/26] dm: serial: Separate out the core serial-device finding code Simon Glass
2017-05-19 14:31 ` [U-Boot] [PATCH 23/26] dm: serial: Add livetree support Simon Glass
2017-05-19 14:31 ` [U-Boot] [PATCH 24/26] tegra: Show a debug message if the LCD PMIC fails to start Simon Glass
2017-05-19 14:31 ` [U-Boot] [PATCH 25/26] fdtdec: Drop old compatible values Simon Glass
2017-05-19 14:31 ` [U-Boot] [PATCH 26/26] dm: tegra: nyan-big: Move to livetree Simon Glass
2017-05-29 15:08 ` Marcel Ziswiler
2017-06-01 3:11 ` Simon Glass
2017-05-22 22:15 ` [U-Boot] [PATCH 00/26] dm: tegra: Move nyan-big " Tom Rini
2017-05-24 0:44 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170521014021.0215fe9c@jawa \
--to=lukma@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox