pmic: Convert pm8916 driver to a generic Qcom PMIC driver
Since both pm8916.c and pm8916_gpio.c are already supporting multiple
Qcom SoCs, it makes sense to rename these drivers to pmic_qcom.c and
qcom_pmic_gpio.c respectively. Also, these driver can be extended to
support additional functionality if required for other Qcom SoCs.
Along with this import latest DT binding: qcom,spmi-pmic.txt from Linux
kernel and thereby remove pm8916.txt.
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
diff --git a/drivers/power/pmic/Kconfig b/drivers/power/pmic/Kconfig
index 66b16b0..0478f2a 100644
--- a/drivers/power/pmic/Kconfig
+++ b/drivers/power/pmic/Kconfig
@@ -216,10 +216,10 @@
- MUIC
- Others
-config PMIC_PM8916
- bool "Enable Driver Model for Qualcomm PM8916 PMIC"
+config PMIC_QCOM
+ bool "Enable Driver Model for Qualcomm generic PMIC"
---help---
- The PM8916 is a PMIC connected to one (or several) processors
+ The Qcom PMIC is connected to one (or several) processors
with SPMI bus. It has 2 slaves with several peripherals:
- 18x LDO
- 4x GPIO
@@ -229,7 +229,7 @@
- Vibrator drivers
- Others
- Driver binding info: doc/device-tree-bindings/pmic/pm8916.txt
+ Driver binding info: doc/device-tree-bindings/pmic/qcom,spmi-pmic.txt
config PMIC_RK8XX
bool "Enable support for Rockchip PMIC RK8XX"
diff --git a/drivers/power/pmic/Makefile b/drivers/power/pmic/Makefile
index f73b326..e1d3545 100644
--- a/drivers/power/pmic/Makefile
+++ b/drivers/power/pmic/Makefile
@@ -20,7 +20,7 @@
obj-$(CONFIG_PMIC_AS3722) += as3722.o as3722_gpio.o
obj-$(CONFIG_$(SPL_)PMIC_AXP) += axp.o
obj-$(CONFIG_PMIC_MAX8997) += max8997.o
-obj-$(CONFIG_PMIC_PM8916) += pm8916.o
+obj-$(CONFIG_PMIC_QCOM) += pmic_qcom.o
obj-$(CONFIG_$(SPL_TPL_)PMIC_RK8XX) += rk8xx.o
obj-$(CONFIG_PMIC_RN5T567) += rn5t567.o
obj-$(CONFIG_PMIC_TPS65090) += tps65090.o
diff --git a/drivers/power/pmic/pm8916.c b/drivers/power/pmic/pm8916.c
deleted file mode 100644
index 5f4386d..0000000
--- a/drivers/power/pmic/pm8916.c
+++ /dev/null
@@ -1,86 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Qualcomm pm8916 pmic driver
- *
- * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
- */
-#include <common.h>
-#include <dm.h>
-#include <power/pmic.h>
-#include <spmi/spmi.h>
-
-#define PID_SHIFT 8
-#define PID_MASK (0xFF << PID_SHIFT)
-#define REG_MASK 0xFF
-
-struct pm8916_priv {
- uint32_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_read_addr(dev);
-
- if (priv->usid == FDT_ADDR_T_NONE)
- return -EINVAL;
-
- return 0;
-}
-
-U_BOOT_DRIVER(pmic_pm8916) = {
- .name = "pmic_pm8916",
- .id = UCLASS_PMIC,
- .of_match = pm8916_ids,
- .bind = dm_scan_fdt_dev,
- .probe = pm8916_probe,
- .ops = &pm8916_ops,
- .priv_auto = sizeof(struct pm8916_priv),
-};
diff --git a/drivers/power/pmic/pmic_qcom.c b/drivers/power/pmic/pmic_qcom.c
new file mode 100644
index 0000000..ad8daf4
--- /dev/null
+++ b/drivers/power/pmic/pmic_qcom.c
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm generic pmic driver
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
+ */
+#include <common.h>
+#include <dm.h>
+#include <power/pmic.h>
+#include <spmi/spmi.h>
+
+#define PID_SHIFT 8
+#define PID_MASK (0xFF << PID_SHIFT)
+#define REG_MASK 0xFF
+
+struct pmic_qcom_priv {
+ uint32_t usid; /* Slave ID on SPMI bus */
+};
+
+static int pmic_qcom_reg_count(struct udevice *dev)
+{
+ return 0xFFFF;
+}
+
+static int pmic_qcom_write(struct udevice *dev, uint reg, const uint8_t *buff,
+ int len)
+{
+ struct pmic_qcom_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 pmic_qcom_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
+{
+ struct pmic_qcom_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 pmic_qcom_ops = {
+ .reg_count = pmic_qcom_reg_count,
+ .read = pmic_qcom_read,
+ .write = pmic_qcom_write,
+};
+
+static const struct udevice_id pmic_qcom_ids[] = {
+ { .compatible = "qcom,spmi-pmic" },
+ { }
+};
+
+static int pmic_qcom_probe(struct udevice *dev)
+{
+ struct pmic_qcom_priv *priv = dev_get_priv(dev);
+
+ priv->usid = dev_read_addr(dev);
+
+ if (priv->usid == FDT_ADDR_T_NONE)
+ return -EINVAL;
+
+ return 0;
+}
+
+U_BOOT_DRIVER(pmic_qcom) = {
+ .name = "pmic_qcom",
+ .id = UCLASS_PMIC,
+ .of_match = pmic_qcom_ids,
+ .bind = dm_scan_fdt_dev,
+ .probe = pmic_qcom_probe,
+ .ops = &pmic_qcom_ops,
+ .priv_auto = sizeof(struct pmic_qcom_priv),
+};