14 #define pr_fmt(fmt) "%s: " fmt, __func__
16 #include <linux/kernel.h>
18 #include <linux/slab.h>
20 #include <linux/msm_ssbi.h>
25 #define REG_HWREV 0x002
26 #define REG_HWREV_2 0x0E8
38 return msm_ssbi_read(pmic->
dev->parent, addr, val, 1);
46 return msm_ssbi_write(pmic->
dev->parent, addr, &val, 1);
55 return msm_ssbi_read(pmic->
dev->parent, addr, buf, cnt);
64 return msm_ssbi_write(pmic->
dev->parent, addr, buf, cnt);
67 static int pm8921_read_irq_stat(
const struct device *
dev,
int irq)
76 .pmic_readb = pm8921_readb,
77 .pmic_writeb = pm8921_writeb,
78 .pmic_read_buf = pm8921_read_buf,
79 .pmic_write_buf = pm8921_write_buf,
80 .pmic_read_irq_stat = pm8921_read_irq_stat,
88 int ret = 0, irq_base = 0;
97 if (IS_ERR(irq_chip)) {
98 pr_err(
"Failed to init interrupts ret=%ld\n",
100 return PTR_ERR(irq_chip);
116 pr_err(
"missing platform data\n");
122 pr_err(
"Cannot alloc pm8921 struct\n");
127 rc = msm_ssbi_read(pdev->
dev.parent,
REG_HWREV, &val,
sizeof(val));
132 pr_info(
"PMIC revision 1: %02X\n", val);
136 rc = msm_ssbi_read(pdev->
dev.parent,
REG_HWREV_2, &val,
sizeof(val));
138 pr_err(
"Failed to read hw rev 2 reg %d:rc=%d\n",
142 pr_info(
"PMIC revision 2: %02X\n", val);
147 platform_set_drvdata(pdev, &pm8921_drvdata);
149 rc = pm8921_add_subdevices(pdata, pmic, rev);
151 pr_err(
"Cannot add subdevices rc=%d\n", rc);
162 platform_set_drvdata(pdev,
NULL);
173 drvdata = platform_get_drvdata(pdev);
182 platform_set_drvdata(pdev,
NULL);
189 .probe = pm8921_probe,
192 .name =
"pm8921-core",
197 static int __init pm8921_init(
void)
203 static void __exit pm8921_exit(
void)