[RAMEN9610-20799][ERD][NEUS7920-623] [NEUS7920-263][9610] nfc: control nfc pvdd for...
authorJia Lee <jia0515.lee@samsung.com>
Wed, 30 Oct 2019 09:01:32 +0000 (18:01 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:23:38 +0000 (20:23 +0300)
nfc pvdd should be low during phone off and USB charging mode.

Change-Id: I31aed59395e06d031895ad7cc2a4b82eccc75bd3
Signed-off-by: Jia Lee <jia0515.lee@samsung.com>
drivers/nfc/samsung/Kconfig
drivers/nfc/samsung/sec_nfc.c
drivers/nfc/samsung/sec_nfc.h

index d9e0b54078f35292ef1eefc02e9b5f4826f26ea3..7ea4c020283ddc4782dbd546143e630c023330bf 100644 (file)
@@ -55,4 +55,7 @@ config SEC_NFC_CLK_REQ
 config SEC_NFC_LDO_EN
         bool "SEC NFC LDO"
         default y
+config SEC_NFC_PMIC_LDO
+        bool "SEC NFC PMIC LDO"
+        default n
 endmenu
index 3096a042cfde1d1e5144b0859067b0d5226b49bd..f8a3830b4ad08524ccf0b792a0e4f347de3b2002 100644 (file)
@@ -645,6 +645,10 @@ static int sec_nfc_parse_dt(struct device *dev,
 #ifdef CONFIG_SEC_NFC_LDO_EN
     pdata->pvdd_en = of_get_named_gpio(np, "sec-nfc,ldo_en",0);
 #endif
+#ifdef CONFIG_SEC_NFC_PMIC_LDO
+    if (of_property_read_string(np, "sec-nfc,pmic-ldo", &pdata->pvdd_regulator_name))
+        pr_err("%s: Failed to get %s regulator.\n", __func__, pdata->pvdd_regulator_name);
+#endif
 
 #ifdef CONFIG_SEC_NFC_CLK_REQ
     pdata->clk_req = of_get_named_gpio(np, "sec-nfc,clk_req-gpio", 0);
@@ -716,17 +720,28 @@ static int __sec_nfc_probe(struct device *dev)
             pr_err("failed to request about pvdd_en pin\n");
             goto err_dev_reg;
         }
-        //if (!lpcharge)
+        if (!is_charging_mode)
             gpio_direction_output(pdata->pvdd_en, NFC_I2C_LDO_ON);
         pr_info("pvdd en: %d\n", gpio_get_value(pdata->pvdd_en));
     }
 #endif
+#ifdef CONFIG_SEC_NFC_PMIC_LDO
+    if (!is_charging_mode) {
+        pdata->pvdd_regulator = regulator_get(NULL, pdata->pvdd_regulator_name);
+        if (IS_ERR(pdata->pvdd_regulator))
+            pr_err("%s: Failed to get %s pmic regulator.\n", __func__, pdata->pvdd_regulator);
+        ret = regulator_enable(pdata->pvdd_regulator);
+        pr_err("%s: Failed to enable pmic regulator: %d\n", __func__, ret);
+    }
+#endif
+
     ret = gpio_request(pdata->ven, "nfc_ven");
     if (ret) {
         dev_err(dev, "failed to get gpio ven\n");
         goto err_gpio_ven;
     }
-    gpio_direction_output(pdata->ven, SEC_NFC_PW_OFF);
+    if (!is_charging_mode)
+        gpio_direction_output(pdata->ven, SEC_NFC_PW_OFF);
 
     if (pdata->firm) {
         ret = gpio_request(pdata->firm, "nfc_firm");
@@ -863,6 +878,16 @@ static struct i2c_driver sec_nfc_driver = {
     },
 };
 
+static int __init is_poweroff_charging_mode(char *str)
+{
+    if (strncmp("charger", str, 7) == 0)
+        is_charging_mode = true;
+    else {
+        is_charging_mode = false;
+    }
+    return 0;
+} early_param("androidboot.mode", is_poweroff_charging_mode);
+
 static int __init sec_nfc_init(void)
 {
     return SEC_NFC_INIT(&sec_nfc_driver);
index 37fb80d0ca5e41a2c5b8037c42689579fc1f4897..750463030a3d1b36f9600779064a957b6e58a63c 100644 (file)
 #ifdef CONFIG_SEC_NFC_CLK_REQ
 #include <linux/clk.h>
 #endif
+#ifdef CONFIG_SEC_NFC_PMIC_LDO
+#include <linux/regulator/consumer.h>
+#include <linux/err.h>
+#endif
 
 #ifdef CONFIG_SEC_NFC_I2C /* support old driver configuration */
 
@@ -74,6 +78,10 @@ struct sec_nfc_platform_data {
        u32 firm_gpio_flags;
        u32 irq_gpio_flags;
        const char *nfc_pvdd;
+#ifdef CONFIG_SEC_NFC_PMIC_LDO
+    const char *pvdd_regulator_name;
+    struct regulator *pvdd_regulator;
+#endif
 };
 
 enum sec_nfc_mode {
@@ -105,7 +113,7 @@ enum sec_nfc_wake {
        SEC_NFC_WAKE_UP,
 };
 
-extern unsigned int lpcharge;
+bool is_charging_mode;
 
 #define NFC_I2C_LDO_ON  1
 #define NFC_I2C_LDO_OFF 0