diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2018-09-22 16:51:15 +0300 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2018-09-25 12:44:41 +0200 |
commit | 5e0b7e7cd27da0dda51d7d840398621b0cffa0a1 (patch) | |
tree | 9689c50ed9f1c731107f0113c40cdf62c012f5b4 /drivers | |
parent | a4925311a5443126ecc90671a1604ea7b0f5b32e (diff) | |
download | linux-5e0b7e7cd27da0dda51d7d840398621b0cffa0a1.tar.bz2 |
pinctrl: intel: merrifield: Introduce mrfld_read_bufcfg()
mrfld_read_bufcfg() helper checks if pin is correct and reads back
the current value of corresponding BUFCFG register.
While it adds lines of code it will be easier to maintain in the future.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pinctrl/intel/pinctrl-merrifield.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/pinctrl/intel/pinctrl-merrifield.c b/drivers/pinctrl/intel/pinctrl-merrifield.c index 4fa69f988c7b..5b7599ec4c47 100644 --- a/drivers/pinctrl/intel/pinctrl-merrifield.c +++ b/drivers/pinctrl/intel/pinctrl-merrifield.c @@ -476,6 +476,19 @@ static void __iomem *mrfld_get_bufcfg(struct mrfld_pinctrl *mp, unsigned int pin return family->regs + BUFCFG_OFFSET + bufno * 4; } +static int mrfld_read_bufcfg(struct mrfld_pinctrl *mp, unsigned int pin, u32 *value) +{ + void __iomem *bufcfg; + + if (!mrfld_buf_available(mp, pin)) + return -EBUSY; + + bufcfg = mrfld_get_bufcfg(mp, pin); + *value = readl(bufcfg); + + return 0; +} + static int mrfld_get_groups_count(struct pinctrl_dev *pctldev) { struct mrfld_pinctrl *mp = pinctrl_dev_get_drvdata(pctldev); @@ -505,17 +518,15 @@ static void mrfld_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned int pin) { struct mrfld_pinctrl *mp = pinctrl_dev_get_drvdata(pctldev); - void __iomem *bufcfg; u32 value, mode; + int ret; - if (!mrfld_buf_available(mp, pin)) { + ret = mrfld_read_bufcfg(mp, pin, &value); + if (ret) { seq_puts(s, "not available"); return; } - bufcfg = mrfld_get_bufcfg(mp, pin); - value = readl(bufcfg); - mode = (value & BUFCFG_PINMODE_MASK) >> BUFCFG_PINMODE_SHIFT; if (!mode) seq_puts(s, "GPIO "); @@ -637,11 +648,12 @@ static int mrfld_config_get(struct pinctrl_dev *pctldev, unsigned int pin, enum pin_config_param param = pinconf_to_config_param(*config); u32 value, term; u16 arg = 0; + int ret; - if (!mrfld_buf_available(mp, pin)) + ret = mrfld_read_bufcfg(mp, pin, &value); + if (ret) return -ENOTSUPP; - value = readl(mrfld_get_bufcfg(mp, pin)); term = (value & BUFCFG_PUPD_VAL_MASK) >> BUFCFG_PUPD_VAL_SHIFT; switch (param) { |