diff --git a/nfc/common.c b/nfc/common.c index 6539cf617d..10bd17f17e 100644 --- a/nfc/common.c +++ b/nfc/common.c @@ -45,6 +45,7 @@ int nfc_parse_dt(struct device *dev, struct platform_configs *nfc_configs, nfc_gpio->irq = -EINVAL; nfc_gpio->dwl_req = -EINVAL; nfc_gpio->ven = -EINVAL; + nfc_gpio->clkreq = -EINVAL; /* irq required for i2c based chips only */ if (interface == PLATFORM_IF_I2C) { @@ -67,16 +68,21 @@ int nfc_parse_dt(struct device *dev, struct platform_configs *nfc_configs, if ((!gpio_is_valid(nfc_gpio->dwl_req))) pr_warn("%s: nfc dwl_req gpio invalid %d\n", __func__, nfc_gpio->dwl_req); - + /* Read clock request gpio configuration if MGPIO configurations are not preasent */ if (of_property_read_string(np, DTS_CLKSRC_GPIO_STR, &nfc_configs->clk_src_name)) { nfc_configs->clk_pin_voting = false; + nfc_gpio->clkreq = of_get_named_gpio(np, DTS_CLKREQ_GPIO_STR, 0); + if (!gpio_is_valid(nfc_gpio->clkreq)) { + dev_err(dev, "clkreq gpio invalid %d\n", nfc_gpio->clkreq); + return -EINVAL; + } } else { nfc_configs->clk_pin_voting = true; } - pr_info("%s: irq %d, ven %d, dwl %d\n", __func__, nfc_gpio->irq, nfc_gpio->ven, - nfc_gpio->dwl_req); + pr_info("%s: irq %d, ven %d, dwl %d, clkreq %d, clk_pin_voting %d \n", __func__, nfc_gpio->irq, nfc_gpio->ven, + nfc_gpio->dwl_req, nfc_gpio->clkreq, nfc_configs->clk_pin_voting); /* optional property */ ret = of_property_read_u32_array(np, NFC_LDO_VOL_DT_NAME, @@ -188,6 +194,9 @@ void gpio_free_all(struct nfc_dev *nfc_dev) { struct platform_gpio *nfc_gpio = &nfc_dev->configs.gpio; + if (gpio_is_valid(nfc_gpio->clkreq)) + gpio_free(nfc_gpio->clkreq); + if (gpio_is_valid(nfc_gpio->dwl_req)) gpio_free(nfc_gpio->dwl_req); @@ -420,6 +429,15 @@ int nfc_post_init(struct nfc_dev *nfc_dev) __func__, nfc_gpio->dwl_req); } + if(!(nfc_configs.clk_pin_voting)){ + ret = configure_gpio(nfc_gpio->clkreq, GPIO_INPUT); + if (ret) { + pr_err("%s: unable to request nfc clkreq gpio [%d]\n", + __func__, nfc_gpio->clkreq); + return ret; + } + } + ret = nfcc_hw_check(nfc_dev); if (ret || nfc_dev->nfc_state == NFC_STATE_UNKNOWN) { pr_err("nfc hw check failed ret %d\n", ret); diff --git a/nfc/common.h b/nfc/common.h index 6e4ed15996..32c923f667 100644 --- a/nfc/common.h +++ b/nfc/common.h @@ -103,6 +103,7 @@ #define DTS_IRQ_GPIO_STR "qcom,sn-irq" #define DTS_VEN_GPIO_STR "qcom,sn-ven" #define DTS_FWDN_GPIO_STR "qcom,sn-firm" +#define DTS_CLKREQ_GPIO_STR "qcom,sn-clkreq" #define DTS_CLKSRC_GPIO_STR "qcom,clk-src" #define NFC_LDO_SUPPLY_DT_NAME "qcom,sn-vdd-1p8" #define NFC_LDO_SUPPLY_NAME "qcom,sn-vdd-1p8-supply" @@ -204,6 +205,7 @@ enum gpio_values { struct platform_gpio { unsigned int irq; unsigned int ven; + unsigned int clkreq; unsigned int dwl_req; };