public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Przemyslaw Marczak <p.marczak@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 23/55] dm: power: Add support for the S5M8767 PMIC
Date: Fri, 10 Jul 2015 13:52:37 +0200	[thread overview]
Message-ID: <559FB205.5050700@samsung.com> (raw)
In-Reply-To: <1435882592-487-24-git-send-email-sjg@chromium.org>

Hello Simon,

On 07/03/2015 02:16 AM, Simon Glass wrote:
> This PMIC is used with SoCs which need a combination of BUCKs and LDOs. The
> driver supports probing and basic register access. It supports the standard
> device tree binding and supports driver model. A regulator driver can be
> provided also.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   drivers/power/pmic/Kconfig   |  9 +++++
>   drivers/power/pmic/Makefile  |  2 +
>   drivers/power/pmic/s5m8767.c | 95 ++++++++++++++++++++++++++++++++++++++++++++
>   include/power/s5m8767.h      | 85 +++++++++++++++++++++++++++++++++++++++
>   4 files changed, 191 insertions(+)
>   create mode 100644 drivers/power/pmic/s5m8767.c
>   create mode 100644 include/power/s5m8767.h
>
> diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
> index fd8af81..7b98189 100644
> --- a/drivers/power/pmic/Kconfig
> +++ b/drivers/power/pmic/Kconfig
> @@ -42,6 +42,15 @@ config DM_PMIC_SANDBOX
>
>   	Driver binding info: doc/device-tree-bindings/pmic/sandbox.txt
>
> +config PMIC_S5M8767
> +	bool "Enable Driver Model for the Samsung S5M8767 PMIC"
> +	depends on DM_PMIC
> +	---help---
> +	The S5M8767 PMIC provides a large array of LDOs and BUCKs for use
> +	as a SoC power controller. It also provides 32KHz clock outputs. This
> +	driver provides basic register access and sets up the attached
> +	regulators if regulator support is enabled.
> +
>   config PMIC_TPS65090
>   	bool "Enable driver for Texas Instruments TPS65090 PMIC"
>   	depends on DM_PMIC
> diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
> index 2316e3b..ee23c26 100644
> --- a/drivers/power/pmic/Makefile
> +++ b/drivers/power/pmic/Makefile
> @@ -9,6 +9,8 @@ obj-$(CONFIG_DM_PMIC) += pmic-uclass.o
>   obj-$(CONFIG_DM_PMIC_MAX77686) += max77686.o
>   obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o
>   obj-$(CONFIG_PMIC_TPS65090) += tps65090.o
> +obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o
> +
>   obj-$(CONFIG_POWER_LTC3676) += pmic_ltc3676.o
>   obj-$(CONFIG_POWER_MAX8998) += pmic_max8998.o
>   obj-$(CONFIG_POWER_MAX8997) += pmic_max8997.o
> diff --git a/drivers/power/pmic/s5m8767.c b/drivers/power/pmic/s5m8767.c
> new file mode 100644
> index 0000000..075fe7e
> --- /dev/null
> +++ b/drivers/power/pmic/s5m8767.c
> @@ -0,0 +1,95 @@
> +/*
> + * Copyright (C) 2015 Google, Inc
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <fdtdec.h>
> +#include <errno.h>
> +#include <dm.h>
> +#include <i2c.h>
> +#include <power/pmic.h>
> +#include <power/regulator.h>
> +#include <power/s5m8767.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static const struct pmic_child_info pmic_children_info[] = {
> +	{ .prefix = "LDO", .driver = S5M8767_LDO_DRIVER },
> +	{ .prefix = "BUCK", .driver = S5M8767_BUCK_DRIVER },
> +	{ },
> +};
> +
> +static int s5m8767_reg_count(struct udevice *dev)
> +{
> +	return S5M8767_NUM_OF_REGS;
> +}
> +
> +static int s5m8767_write(struct udevice *dev, uint reg, const uint8_t *buff,
> +			  int len)
> +{
> +	if (dm_i2c_write(dev, reg, buff, len)) {
> +		error("write error to device: %p register: %#x!", dev, reg);
> +		return -EIO;
> +	}
> +
> +	return 0;
> +}
> +
> +static int s5m8767_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
> +{
> +	if (dm_i2c_read(dev, reg, buff, len)) {
> +		error("read error from device: %p register: %#x!", dev, reg);
> +		return -EIO;
> +	}
> +
> +	return 0;
> +}
> +
> +int s5m8767_enable_32khz_cp(struct udevice *dev)
> +{
> +	return pmic_clrsetbits(dev, S5M8767_EN32KHZ_CP, 0, 1 << 1);
> +}
> +
> +static int s5m8767_bind(struct udevice *dev)
> +{
> +	int node;
> +	const void *blob = gd->fdt_blob;
> +	int children;
> +
> +	node = fdt_subnode_offset(blob, dev->of_offset, "regulators");
> +	if (node <= 0) {
> +		debug("%s: %s regulators subnode not found!", __func__,
> +		      dev->name);
> +		return -ENXIO;
> +	}
> +
> +	debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
> +
> +	children = pmic_bind_children(dev, node, pmic_children_info);
> +	if (!children)
> +		debug("%s: %s - no child found\n", __func__, dev->name);
> +
> +	/* Always return success for this device */
> +	return 0;
> +}
> +
> +static struct dm_pmic_ops s5m8767_ops = {
> +	.reg_count = s5m8767_reg_count,
> +	.read = s5m8767_read,
> +	.write = s5m8767_write,
> +};
> +
> +static const struct udevice_id s5m8767_ids[] = {
> +	{ .compatible = "samsung,s5m8767-pmic" },
> +	{ }
> +};
> +
> +U_BOOT_DRIVER(pmic_s5m8767) = {
> +	.name = "s5m8767_pmic",
> +	.id = UCLASS_PMIC,
> +	.of_match = s5m8767_ids,
> +	.bind = s5m8767_bind,
> +	.ops = &s5m8767_ops,
> +};
> diff --git a/include/power/s5m8767.h b/include/power/s5m8767.h
> new file mode 100644
> index 0000000..ba88ff7
> --- /dev/null
> +++ b/include/power/s5m8767.h
> @@ -0,0 +1,85 @@
> +/*
> + * Copyright (c) 2015 Google, Inc
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +#ifndef __S5M8767_H_
> +#define __S5M8767_H_
> +
> +enum s5m8767_regnum {
> +	S5M8767_BUCK1 = 0,
> +	S5M8767_BUCK2,
> +	S5M8767_BUCK3,
> +	S5M8767_BUCK4,
> +	S5M8767_BUCK5,
> +	S5M8767_BUCK6,
> +	S5M8767_BUCK7,
> +	S5M8767_BUCK8,
> +	S5M8767_BUCK9,
> +	S5M8767_LDO1,
> +	S5M8767_LDO2,
> +	S5M8767_LDO3,
> +	S5M8767_LDO4,
> +	S5M8767_LDO5,
> +	S5M8767_LDO6,
> +	S5M8767_LDO7,
> +	S5M8767_LDO8,
> +	S5M8767_LDO9,
> +	S5M8767_LDO10,
> +	S5M8767_LDO11,
> +	S5M8767_LDO12,
> +	S5M8767_LDO13,
> +	S5M8767_LDO14,
> +	S5M8767_LDO15,
> +	S5M8767_LDO16,
> +	S5M8767_LDO17,
> +	S5M8767_LDO18,
> +	S5M8767_LDO19,
> +	S5M8767_LDO20,
> +	S5M8767_LDO21,
> +	S5M8767_LDO22,
> +	S5M8767_LDO23,
> +	S5M8767_LDO24,
> +	S5M8767_LDO25,
> +	S5M8767_LDO26,
> +	S5M8767_LDO27,
> +	S5M8767_LDO28,
> +	S5M8767_EN32KHZ_CP,
> +
> +	S5M8767_NUM_OF_REGS,
> +};
> +
> +struct sec_voltage_desc {
> +	int max;
> +	int min;
> +	int step;
> +};
> +
> +/**
> + * struct s5m8767_para - s5m8767 register parameters
> + * @param vol_addr	i2c address of the given buck/ldo register
> + * @param vol_bitpos	bit position to be set or clear within register
> + * @param vol_bitmask	bit mask value
> + * @param reg_enaddr	control register address, which enable the given
> + *			given buck/ldo.
> + * @param reg_enbiton	value to be written to buck/ldo to make it ON
> + * @param vol		Voltage information
> + */
> +struct s5m8767_para {
> +	enum s5m8767_regnum regnum;
> +	u8	vol_addr;
> +	u8	vol_bitpos;
> +	u8	vol_bitmask;
> +	u8	reg_enaddr;
> +	u8	reg_enbiton;
> +	const struct sec_voltage_desc *vol;
> +};
> +
> +/* Drivers name */
> +#define S5M8767_LDO_DRIVER	"s5m8767_ldo"
> +#define S5M8767_BUCK_DRIVER	"s5m8767_buck"
> +
> +int s5m8767_enable_32khz_cp(struct udevice *dev);
> +
> +#endif /* __S5M8767_PMIC_H_ */
>

Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>

Regards
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

  reply	other threads:[~2015-07-10 11:52 UTC|newest]

Thread overview: 139+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-03  0:15 [U-Boot] [PATCH 00/55] dm: exynos: Driver model improvements leading to spring support Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 01/55] dm: core: Support finding a device by phandle Simon Glass
2015-07-27 23:28   ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 02/55] dm: i2c: Add a message debug function Simon Glass
2015-07-03  6:52   ` Heiko Schocher denx
2015-07-27 23:28     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 03/55] dm: i2c: Correct comment nits in dm_i2c_reg_read/write() Simon Glass
2015-07-03  6:53   ` Heiko Schocher denx
2015-07-27 23:28     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 04/55] dm: i2c: Move definitions to the top of the header file Simon Glass
2015-07-03  6:55   ` Heiko Schocher denx
2015-07-27 23:28     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 05/55] dm: i2c: Add a function to transfer messages Simon Glass
2015-07-03  6:58   ` Heiko Schocher denx
2015-07-27 23:28     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 06/55] dm: i2c: Add support for multiplexed I2C buses Simon Glass
2015-07-05  6:10   ` Heiko Schocher
2015-07-06 16:38     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 07/55] exynos: i2c: Correct bug in pinmux selection Simon Glass
2015-07-05  6:15   ` Heiko Schocher
2015-07-06 15:27     ` Simon Glass
2015-07-07  1:36       ` Minkyu Kang
2015-07-08  2:38         ` Simon Glass
2015-07-10  1:43           ` Minkyu Kang
2015-07-10  1:46             ` Simon Glass
2015-07-10  8:56               ` Przemyslaw Marczak
2015-07-10 12:14               ` Minkyu Kang
2015-07-07  6:51   ` Przemyslaw Marczak
2015-07-03  0:15 ` [U-Boot] [PATCH 08/55] i2c: Add a mux for GPIO-based I2C bus arbitration Simon Glass
2015-07-05  6:43   ` Heiko Schocher
2015-07-06 16:38     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 09/55] exynos: i2c: Fix code style with ReadWriteByte() Simon Glass
2015-07-05  6:45   ` Heiko Schocher
2015-07-27 23:29     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 10/55] exynos: i2c: Tidy up the driver model code Simon Glass
2015-07-06  5:40   ` Heiko Schocher
2015-07-27 23:28     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 11/55] exynos: dts: Sync up I2C ports with the kernel Simon Glass
2015-07-10 11:51   ` Przemyslaw Marczak
2015-07-27 23:29     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 12/55] exynos: dts: Add PMIC and regulator definitions Simon Glass
2015-07-10 11:51   ` Przemyslaw Marczak
2015-07-27 23:29     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 13/55] exynos: dts: Support EC tunnel and main TPS65090 regulator Simon Glass
2015-07-27 23:29   ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 14/55] dm: cros_ec: Convert the I2C tunnel code to use driver model Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 15/55] cros_ec: Support the LDO access method used by spring Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 16/55] exynos: serial: Refactor init code for debug UART Simon Glass
2015-07-27 23:29   ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 17/55] exynos: Add debug UART support for Samsung S5P serial Simon Glass
2015-07-27 23:29   ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 18/55] exynos: Enable the debug UART in SPL Simon Glass
2015-07-27 23:30   ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 19/55] dm: gpio: Add support for setting a GPIO's pull direction Simon Glass
2015-07-05  4:55   ` Masahiro Yamada
2015-07-06 16:39     ` Simon Glass
2015-07-06 17:20       ` Masahiro Yamada
2015-07-06 17:33         ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 20/55] dm: exynos: gpio: Support pull-up/down in GPIOs Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 21/55] dm: power: Add a new driver for the TPS65090 PMIC Simon Glass
2015-07-10 11:52   ` Przemyslaw Marczak
2015-07-27 23:30     ` Simon Glass
2015-07-03  0:15 ` [U-Boot] [PATCH 22/55] dm: power: Add support for TPS65090 FETs Simon Glass
2015-07-10 11:52   ` Przemyslaw Marczak
2015-07-27 23:30     ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 23/55] dm: power: Add support for the S5M8767 PMIC Simon Glass
2015-07-10 11:52   ` Przemyslaw Marczak [this message]
2015-07-27 23:30     ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 24/55] dm: power: Add support for S5M8767 regulators Simon Glass
2015-07-10 11:52   ` Przemyslaw Marczak
2015-07-27 23:30     ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 25/55] dm: pmic: max77686: Correct a few nits Simon Glass
2015-07-10 11:53   ` Przemyslaw Marczak
2015-07-27 23:30     ` Simon Glass
2015-07-28  6:19       ` Przemyslaw Marczak
2015-08-03 14:02         ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 26/55] dm: pmic: Correct the pmic_reg_write() implementation Simon Glass
2015-07-10 11:53   ` Przemyslaw Marczak
2015-07-27 23:30     ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 27/55] dm: power: max77686: Correct BUCK register access Simon Glass
2015-07-10 11:53   ` Przemyslaw Marczak
2015-07-27 23:30     ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 28/55] dm: pmic: max77686: Support all BUCK regulators Simon Glass
2015-07-10 11:53   ` Przemyslaw Marczak
2015-07-30  2:05     ` Simon Glass
2015-07-30  8:22       ` Przemyslaw Marczak
2015-08-03 14:05         ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 29/55] dm: power: Don't return an error when regulators are not autoset Simon Glass
2015-07-10 11:54   ` Przemyslaw Marczak
2015-07-27 23:30     ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 30/55] dm: pmic: Display the regulator limits on error Simon Glass
2015-07-10 11:54   ` Przemyslaw Marczak
2015-07-27 23:30     ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 31/55] dm: video: Add support for video bridges Simon Glass
2015-07-27 23:30   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 32/55] dm: video: Add support for the Parade PS8622/625 bridge Simon Glass
2015-07-27 23:30   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 33/55] dm: video: Add support for the NXP PTN3460 bridge Simon Glass
2015-07-27 23:30   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 34/55] exynos: spi: Convert the timeout to debug() Simon Glass
2015-07-27 23:30   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 35/55] exynos: Correct return value in exynos_mmc_init() Simon Glass
2015-07-27 23:31   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 36/55] exynos: Add support for the DisplayPort hotplug detect Simon Glass
2015-07-27 23:31   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 37/55] exynos: video: Correct debug output Simon Glass
2015-07-27 23:31   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 38/55] exynos: Tidy up CPU frequency display Simon Glass
2015-07-27 23:31   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 39/55] dm: gpio: Check a GPIO is valid before using it Simon Glass
2015-07-27 23:31   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 40/55] dts: exynos: snow: Add memory layout description Simon Glass
2015-07-27 23:31   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 41/55] dts: exynos: pit: Add a new node for the parade video bridge driver Simon Glass
2015-07-27 23:31   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 42/55] dts: exynos: snow: Add a new node for the NXP " Simon Glass
2015-07-27 23:31   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 43/55] exynos: dts: Drop the old TPS65090 I2C node Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 44/55] exynos: Add common board code for exynos5 boards that use device tree Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 45/55] exynos: Enable new features for exynos5 boards Simon Glass
2015-07-10 11:55   ` Przemyslaw Marczak
2015-07-28 16:29     ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 46/55] exynos: Remove unneeded device tree control #ifdefs Simon Glass
2015-07-27 23:31   ` Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 47/55] exynos: config: Move common options to the common headers and tidy up Simon Glass
2015-07-10 11:56   ` Przemyslaw Marczak
2015-07-03  0:16 ` [U-Boot] [PATCH 48/55] exynos: Drop old exynos5420-specific board code Simon Glass
2015-07-10 11:56   ` Przemyslaw Marczak
2015-07-03  0:16 ` [U-Boot] [PATCH 49/55] exynos: Drop old exynos5250-specific " Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 50/55] power: Remove old TPS65090 drivers Simon Glass
2015-07-10 11:56   ` Przemyslaw Marczak
2015-07-03  0:16 ` [U-Boot] [PATCH 51/55] cros_ec: Remove the old tunnel code Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 52/55] video: Remove the old parade driver Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 53/55] dts: Drop unused compatible ID for the NXP video bridge Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 54/55] exynos: video: Remove non-device-tree code Simon Glass
2015-07-03  0:16 ` [U-Boot] [PATCH 55/55] exynos: Add support for spring Simon Glass
2015-07-20 14:19 ` [U-Boot] [PATCH 00/55] dm: exynos: Driver model improvements leading to spring support Simon Glass
2015-07-22  4:52   ` Minkyu Kang
2015-07-23  2:08     ` 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=559FB205.5050700@samsung.com \
    --to=p.marczak@samsung.com \
    --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