All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 17/21] pmic: Add support for Qualcomm PM8916 PMIC
Date: Thu, 31 Mar 2016 23:12:30 +0200	[thread overview]
Message-ID: <1459458754-29559-18-git-send-email-mateusz.kulikowski@gmail.com> (raw)
In-Reply-To: <1459458754-29559-1-git-send-email-mateusz.kulikowski@gmail.com>

This PMIC is connected on SPMI bus so needs SPMI support enabled.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2:
- Add reviewed-by
- Reordered Kconfig & Makefile (to keep alphabetical ordering)
- Added link to dt binding @ help

Changes in v1:
- Added dt bindings
- Reoder includes
- Replaced extract_* macros with ordinary shift/mask
- Added error checking and whitespaces in probe

 doc/device-tree-bindings/pmic/pm8916.txt | 18 ++++++
 drivers/power/pmic/Kconfig               | 16 ++++++
 drivers/power/pmic/Makefile              |  1 +
 drivers/power/pmic/pm8916.c              | 96 ++++++++++++++++++++++++++++++++
 4 files changed, 131 insertions(+)
 create mode 100644 doc/device-tree-bindings/pmic/pm8916.txt
 create mode 100644 drivers/power/pmic/pm8916.c

diff --git a/doc/device-tree-bindings/pmic/pm8916.txt b/doc/device-tree-bindings/pmic/pm8916.txt
new file mode 100644
index 0000000..15c598b
--- /dev/null
+++ b/doc/device-tree-bindings/pmic/pm8916.txt
@@ -0,0 +1,18 @@
+Qualcomm pm8916 PMIC
+
+This PMIC is connected using SPMI bus so should be child of SPMI bus controller.
+
+Required properties:
+- compatible: "qcom,spmi-pmic";
+- reg: SPMI Slave ID, size (ignored)
+- #address-cells: 0x1 (peripheral ID)
+- #size-cells: 0x1 (size of peripheral register space)
+
+Example:
+
+pm8916 at 0 {
+	compatible = "qcom,spmi-pmic";
+	reg = <0x0 0x1>;
+	#address-cells = <0x1>;
+	#size-cells = <0x1>;
+};
diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
index 7f69ae1..69f8d51 100644
--- a/drivers/power/pmic/Kconfig
+++ b/drivers/power/pmic/Kconfig
@@ -54,6 +54,22 @@ config DM_PMIC_MAX77686
 	This config enables implementation of driver-model pmic uclass features
 	for PMIC MAX77686. The driver implements read/write operations.
 
+config PMIC_PM8916
+	bool "Enable Driver Model for Qualcomm PM8916 PMIC"
+	depends on DM_PMIC
+	---help---
+	The PM8916 is a PMIC connected to one (or several) processors
+	with SPMI bus. It has 2 slaves with several peripherals:
+	- 18x LDO
+	- 4x GPIO
+	- Power and Reset buttons
+	- Watchdog
+	- RTC
+	- Vibrator drivers
+	- Others
+
+	Driver binding info: doc/device-tree-bindings/pmic/pm8916.txt
+
 config PMIC_RK808
 	bool "Enable support for Rockchip PMIC RK808"
 	depends on DM_PMIC
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index c6e8d0c..52b4f71 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_DM_PMIC_PFUZE100) += pfuze100.o
 obj-$(CONFIG_PMIC_S2MPS11) += s2mps11.o
 obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o
 obj-$(CONFIG_PMIC_ACT8846) += act8846.o
+obj-$(CONFIG_PMIC_PM8916) += pm8916.o
 obj-$(CONFIG_PMIC_RK808) += rk808.o
 obj-$(CONFIG_PMIC_TPS65090) += tps65090.o
 obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o
diff --git a/drivers/power/pmic/pm8916.c b/drivers/power/pmic/pm8916.c
new file mode 100644
index 0000000..9acf5f5
--- /dev/null
+++ b/drivers/power/pmic/pm8916.c
@@ -0,0 +1,96 @@
+/*
+ * Qualcomm pm8916 pmic driver
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#include <common.h>
+#include <dm.h>
+#include <dm/root.h>
+#include <power/pmic.h>
+#include <spmi/spmi.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define PID_SHIFT 8
+#define PID_MASK (0xFF << PID_SHIFT)
+#define REG_MASK 0xFF
+
+struct pm8916_priv {
+	uint16_t usid; /* Slave ID on SPMI bus */
+};
+
+static int pm8916_reg_count(struct udevice *dev)
+{
+	return 0xFFFF;
+}
+
+static int pm8916_write(struct udevice *dev, uint reg, const uint8_t *buff,
+			int len)
+{
+	struct pm8916_priv *priv = dev_get_priv(dev);
+
+	if (len != 1)
+		return -EINVAL;
+
+	return spmi_reg_write(dev->parent, priv->usid,
+			      (reg & PID_MASK) >> PID_SHIFT, reg & REG_MASK,
+			      *buff);
+}
+
+static int pm8916_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+	struct pm8916_priv *priv = dev_get_priv(dev);
+	int val;
+
+	if (len != 1)
+		return -EINVAL;
+
+	val = spmi_reg_read(dev->parent, priv->usid,
+			    (reg & PID_MASK) >> PID_SHIFT, reg & REG_MASK);
+
+	if (val < 0)
+		return val;
+	*buff = val;
+	return 0;
+}
+
+static struct dm_pmic_ops pm8916_ops = {
+	.reg_count = pm8916_reg_count,
+	.read = pm8916_read,
+	.write = pm8916_write,
+};
+
+static const struct udevice_id pm8916_ids[] = {
+	{ .compatible = "qcom,spmi-pmic" },
+	{ }
+};
+
+static int pm8916_probe(struct udevice *dev)
+{
+	struct pm8916_priv *priv = dev_get_priv(dev);
+
+	priv->usid = dev_get_addr(dev);
+
+	if (priv->usid == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	return 0;
+}
+
+
+static int pm8916_bind(struct udevice *dev)
+{
+	return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
+}
+
+U_BOOT_DRIVER(pmic_pm8916) = {
+	.name = "pmic_pm8916",
+	.id = UCLASS_PMIC,
+	.of_match = pm8916_ids,
+	.bind = pm8916_bind,
+	.probe = pm8916_probe,
+	.ops = &pm8916_ops,
+	.priv_auto_alloc_size = sizeof(struct pm8916_priv),
+};
-- 
2.5.0

  parent reply	other threads:[~2016-03-31 21:12 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-31 21:12 [U-Boot] [PATCH v4 00/21] Add support for 96boards Dragonboard410C board Mateusz Kulikowski
2016-03-31 21:12 ` [U-Boot] [PATCH v4 01/21] serial: Add support for Qualcomm serial port Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 02/21] gpio: Add support for Qualcomm gpio controller Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 03/21] mmc: Add support for Qualcomm SDHCI controller Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 04/21] ehci-hcd: Add init_after_reset Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot,v4,04/21] " Tom Rini
2016-04-03 10:58     ` Bernhard Nortmann
2016-04-03 11:40       ` Mateusz Kulikowski
2016-03-31 21:12 ` [U-Boot] [PATCH v4 05/21] usb: ulpi: Add Kconfig options for ULPI Mateusz Kulikowski
2016-04-02  2:01   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 06/21] Migrate CONFIG_ULPI* to Kconfig Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot,v4,06/21] " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 07/21] usb: ulpi: Fix viewport_addr type Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot,v4,07/21] " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 08/21] usb: ulpi: Fix compile warning in read/write on 64-bit machines Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 09/21] eth: asix88179: Print packet length properly Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 10/21] usb: Rename ehci-fsl.h to ehci-ci.h Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot,v4,10/21] " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 11/21] usb: ehci-ci: Add missing registers Mateusz Kulikowski
2016-04-02  2:02   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 12/21] ehci-ci.h: drop generic USBCMD fields Mateusz Kulikowski
2016-04-02  2:03   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 13/21] ehci: Add support for Qualcomm EHCI Mateusz Kulikowski
2016-04-02  2:03   ` [U-Boot] [U-Boot,v4,13/21] " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 14/21] drivers: Add SPMI bus uclass Mateusz Kulikowski
2016-04-02  2:04   ` [U-Boot] [U-Boot,v4,14/21] " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 15/21] spmi: Add sandbox test driver Mateusz Kulikowski
2016-04-02  2:04   ` [U-Boot] [U-Boot,v4,15/21] " Tom Rini
2016-04-04 15:49     ` Stephen Warren
2016-04-04 16:19       ` Mateusz Kulikowski
2016-04-04 17:09         ` Stephen Warren
2016-04-04 18:02           ` Mateusz Kulikowski
2016-04-04 17:16       ` Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 16/21] drivers: spmi: Add support for Qualcomm SPMI bus driver Mateusz Kulikowski
2016-04-02  2:04   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` Mateusz Kulikowski [this message]
2016-04-02  2:04   ` [U-Boot] [U-Boot, v4, 17/21] pmic: Add support for Qualcomm PM8916 PMIC Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 18/21] gpio: Add support for Qualcomm PM8916 gpios Mateusz Kulikowski
2016-04-02  2:05   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 19/21] arm: Add support for Qualcomm Snapdragon family Mateusz Kulikowski
2016-04-02  2:05   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-03-31 21:12 ` [U-Boot] [PATCH v4 20/21] board: Add Qualcomm Dragonboard 410C support Mateusz Kulikowski
2016-04-02  2:05   ` [U-Boot] [U-Boot, v4, " Tom Rini
2016-04-04 23:13   ` [U-Boot] [PATCH v4 " Andreas Färber
2016-04-04 23:54     ` Daniel Glöckner
2016-04-05  0:15       ` Andreas Färber
2016-03-31 21:12 ` [U-Boot] [PATCH v4 21/21] Add myself as Snapdragon and SPMI maintainer Mateusz Kulikowski
2016-04-02  2:06   ` [U-Boot] [U-Boot, v4, " Tom Rini

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=1459458754-29559-18-git-send-email-mateusz.kulikowski@gmail.com \
    --to=mateusz.kulikowski@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.