mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
Merge branch 'ib-gpio-dir-imx' of https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl into gpio/for-next
Pull pinctrl updates required to allow tracking of direction of GPIOs on chips without dedicated direction registers that GPIO drivers can access. This allows GPIO drivers to get that information from the associated pin controller.
This commit is contained in:
commit
9fbdc9ab1c
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <linux/pinctrl/machine.h>
|
||||
#include <linux/pinctrl/pinconf.h>
|
||||
#include <linux/pinctrl/pinconf-generic.h>
|
||||
#include <linux/pinctrl/pinctrl.h>
|
||||
#include <linux/pinctrl/pinmux.h>
|
||||
|
||||
|
|
@ -291,8 +292,8 @@ struct pinmux_ops imx_pmx_ops = {
|
|||
.set_mux = imx_pmx_set,
|
||||
};
|
||||
|
||||
static int imx_pinconf_get_mmio(struct pinctrl_dev *pctldev, unsigned pin_id,
|
||||
unsigned long *config)
|
||||
static int imx_pinconf_get_raw_mmio(struct pinctrl_dev *pctldev,
|
||||
unsigned int pin_id, unsigned long *config)
|
||||
{
|
||||
struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
|
||||
const struct imx_pinctrl_soc_info *info = ipctl->info;
|
||||
|
|
@ -312,16 +313,61 @@ static int imx_pinconf_get_mmio(struct pinctrl_dev *pctldev, unsigned pin_id,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int imx_pinconf_get_mmio(struct pinctrl_dev *pctldev,
|
||||
unsigned int pin_id, unsigned long *config)
|
||||
{
|
||||
struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
|
||||
const struct imx_pinctrl_soc_info *info = ipctl->info;
|
||||
const struct imx_pin_reg *pin_reg = &ipctl->pin_regs[pin_id];
|
||||
enum pin_config_param param = pinconf_to_config_param(*config);
|
||||
unsigned int mask;
|
||||
u32 raw;
|
||||
|
||||
switch (param) {
|
||||
case PIN_CONFIG_OUTPUT_ENABLE:
|
||||
mask = info->obe_mask;
|
||||
break;
|
||||
case PIN_CONFIG_INPUT_ENABLE:
|
||||
mask = info->ibe_mask;
|
||||
break;
|
||||
default:
|
||||
mask = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mask)
|
||||
return -ENOTSUPP;
|
||||
if (pin_reg->conf_reg == -1)
|
||||
return -EINVAL;
|
||||
|
||||
raw = readl(ipctl->base + pin_reg->conf_reg);
|
||||
*config = pinconf_to_config_packed(param, !!(raw & mask));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int imx_pinconf_get(struct pinctrl_dev *pctldev,
|
||||
unsigned pin_id, unsigned long *config)
|
||||
{
|
||||
struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
|
||||
const struct imx_pinctrl_soc_info *info = ipctl->info;
|
||||
|
||||
if (info->flags & IMX_USE_SCU)
|
||||
return -ENOTSUPP;
|
||||
|
||||
return imx_pinconf_get_mmio(pctldev, pin_id, config);
|
||||
}
|
||||
|
||||
static int imx_pinconf_get_raw(struct pinctrl_dev *pctldev,
|
||||
unsigned int pin_id, unsigned long *config)
|
||||
{
|
||||
struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
|
||||
const struct imx_pinctrl_soc_info *info = ipctl->info;
|
||||
|
||||
if (info->flags & IMX_USE_SCU)
|
||||
return info->imx_pinconf_get(pctldev, pin_id, config);
|
||||
else
|
||||
return imx_pinconf_get_mmio(pctldev, pin_id, config);
|
||||
return imx_pinconf_get_raw_mmio(pctldev, pin_id, config);
|
||||
}
|
||||
|
||||
static int imx_pinconf_set_mmio(struct pinctrl_dev *pctldev,
|
||||
|
|
@ -426,7 +472,7 @@ static void imx_pinconf_group_dbg_show(struct pinctrl_dev *pctldev,
|
|||
struct imx_pin *pin = &((struct imx_pin *)(grp->data))[i];
|
||||
|
||||
name = pin_get_name(pctldev, pin->pin);
|
||||
ret = imx_pinconf_get(pctldev, pin->pin, &config);
|
||||
ret = imx_pinconf_get_raw(pctldev, pin->pin, &config);
|
||||
if (ret)
|
||||
return;
|
||||
seq_printf(s, " %s: 0x%lx\n", name, config);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,10 @@ struct imx_pinctrl_soc_info {
|
|||
unsigned int mux_mask;
|
||||
u8 mux_shift;
|
||||
|
||||
/* OBE/IBE bits in the conf register, 0 if the pad does not have them */
|
||||
unsigned int obe_mask;
|
||||
unsigned int ibe_mask;
|
||||
|
||||
int (*gpio_set_direction)(struct pinctrl_dev *pctldev,
|
||||
struct pinctrl_gpio_range *range,
|
||||
unsigned offset,
|
||||
|
|
|
|||
|
|
@ -319,6 +319,8 @@ static const struct imx_pinctrl_soc_info vf610_pinctrl_info = {
|
|||
.gpio_set_direction = vf610_pmx_gpio_set_direction,
|
||||
.mux_mask = 0x700000,
|
||||
.mux_shift = 20,
|
||||
.obe_mask = 0x2,
|
||||
.ibe_mask = 0x1,
|
||||
};
|
||||
|
||||
static const struct of_device_id vf610_pinctrl_of_match[] = {
|
||||
|
|
|
|||
|
|
@ -107,14 +107,14 @@ static inline int
|
|||
pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset,
|
||||
unsigned long *config)
|
||||
{
|
||||
return 0;
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
static inline int
|
||||
pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
|
||||
unsigned long config)
|
||||
{
|
||||
return 0;
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
static inline struct pinctrl * __must_check pinctrl_get(struct device *dev)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user