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>
This commit is contained in:
parent
a4925311a5
commit
5e0b7e7cd2
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue