[RAMEN9610-19688][Common] s2mpu09: use ldo scp interrupts
authorJieun Yi <jieun.yi@samsung.com>
Mon, 13 May 2019 02:01:18 +0000 (02:01 +0000)
committerKim Gunho <gunho.kim@samsung.com>
Mon, 9 Sep 2019 11:13:02 +0000 (20:13 +0900)
Change-Id: Ica4639a4826ddbb05dbb29a15553768cf62ae7f6
Signed-off-by: Jieun Yi <jieun.yi@samsung.com>
drivers/regulator/s2mpu09-regulator.c
include/linux/mfd/samsung/s2mpu09-regulator.h

index 73dd0de1875da55481da9e801620ef09c93b7d44..931d0d8bec5a54a0dafd0d64bc135c9fe9863d56 100644 (file)
 #include <linux/mutex.h>
 #include <linux/debug-snapshot.h>
 #include <linux/debugfs.h>
+#include <linux/interrupt.h>
 
 static struct s2mpu09_info *static_info;
 static struct regulator_desc regulators[S2MPU09_REGULATOR_MAX];
+static char sc_ldo_irq_name [S2MPU09_NUM_SC_LDO_IRQ][20] =
+       {"SC_LDO2_IRQ", "SC_LDO18_IRQ", "SC_LDO19_IRQ", "SC_LDO33_IRQ", "SC_LDO34_IRQ", "SC_LDO35_IRQ"};
 
 #ifdef CONFIG_DEBUG_FS
 static u8 i2caddr = 0;
@@ -49,6 +52,7 @@ struct s2mpu09_info {
        struct s2mpu09_dev *iodev;
        struct mutex lock;
        struct i2c_client *i2c;
+       int sc_ldo_irq[S2MPU09_NUM_SC_LDO_IRQ];
 };
 
 static unsigned int s2mpu09_of_map_mode(unsigned int val) {
@@ -284,6 +288,24 @@ static int s2m_set_voltage_time_sel(struct regulator_dev *rdev,
        return 0;
 }
 
+static irqreturn_t s2mpu09_sc_ldo_irq(int irq, void *data)
+{
+       int i;
+
+       for (i = 0; i <S2MPU09_NUM_SC_LDO_IRQ; i++) {
+               if(irq == static_info->sc_ldo_irq[i])
+                       break;
+       }
+
+       if (i == S2MPU09_NUM_SC_LDO_IRQ) {
+               pr_err("%s : wrong irq num\n", __func__);
+               return IRQ_HANDLED;
+       }
+
+       pr_info("%s : %s\n", __func__, sc_ldo_irq_name[i]);
+       return IRQ_HANDLED;
+}
+
 static struct regulator_ops s2mpu09_ldo_ops = {
        .list_voltage           = regulator_list_voltage_linear,
        .map_voltage            = regulator_map_voltage_linear,
@@ -622,6 +644,7 @@ static int s2mpu09_pmic_probe(struct platform_device *pdev)
        struct s2mpu09_info *s2mpu09;
        int i, ret;
        u8 val;
+       int irq_base;
 
        pr_info("%s s2mpu09 pmic driver Loading start\n", __func__);
 
@@ -641,6 +664,12 @@ static int s2mpu09_pmic_probe(struct platform_device *pdev)
        if (!s2mpu09)
                return -ENOMEM;
 
+       irq_base = pdata->irq_base;
+       if (!irq_base) {
+               dev_err(&pdev->dev, "Failed to get irq base %d\n", irq_base);
+               return -ENODEV;
+       }
+
        s2mpu09->iodev = iodev;
        s2mpu09->i2c = iodev->pmic;
 
@@ -693,6 +722,17 @@ static int s2mpu09_pmic_probe(struct platform_device *pdev)
        s2mpu09_read_reg(s2mpu09->i2c, S2MPU09_PMIC_REG_OFFSRC, &val);
        pr_info("OFFSRC 0x%x\n", __func__, val);
 
+       for (i = 0; i < S2MPU09_NUM_SC_LDO_IRQ; i++) {
+               s2mpu09->sc_ldo_irq[i] = irq_base + S2MPU09_PMIC_IRQ_SCLDO2_INT5 + i;
+
+               ret = devm_request_threaded_irq(&pdev->dev, s2mpu09->sc_ldo_irq[i], NULL,
+                       s2mpu09_sc_ldo_irq, 0, sc_ldo_irq_name[i], s2mpu09);
+               if (ret < 0) {
+                       dev_err(&pdev->dev, "Failed to request SC LDO IRQ: %d: %d\n",
+                               s2mpu09->sc_ldo_irq[i], ret);
+               }
+       }
+
        pr_info("%s s2mpu09 pmic driver Loading end\n", __func__);
        s2mpu09_update_reg(s2mpu09->i2c, S2MPU09_PMIC_REG_RTCBUF, 0x4, 0x4);
 
index da0fd9e83864e89702f07507f36360689a88e49e..01fc44790fb1e7a6b57159125bb10f7d85041cf0 100644 (file)
@@ -273,6 +273,7 @@ enum s2mpu09_irq_source {
 };
 
 #define S2MPU09_NUM_IRQ_PMIC_REGS      5
+#define S2MPU09_NUM_SC_LDO_IRQ         6
 
 enum s2mpu09_irq {
        /* PMIC */