Commit 07ae3f07 authored by Anson Huang's avatar Anson Huang Committed by Linus Walleij

pinctrl: imx: Use function callbacks for SCU related functions

Use function callbacks for SCU related functions in pinctrl-imx.c
in order to support the scenario of PINCTRL_IMX is built in while
PINCTRL_IMX_SCU is built as module, all drivers using SCU pinctrl
driver need to initialize the SCU related function callback, and
no need to check CONFIG_PINCTRL_IMX_SCU anymore, hence stub functions
also can be removed.
Signed-off-by: default avatarAnson Huang <Anson.Huang@nxp.com>
Reviewed-by: default avatarDong Aisheng <aisheng.dong@nxp.com>
Link: https://lore.kernel.org/r/1599552721-24872-1-git-send-email-Anson.Huang@nxp.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 82d70627
...@@ -373,7 +373,7 @@ static int imx_pinconf_get(struct pinctrl_dev *pctldev, ...@@ -373,7 +373,7 @@ static int imx_pinconf_get(struct pinctrl_dev *pctldev,
const struct imx_pinctrl_soc_info *info = ipctl->info; const struct imx_pinctrl_soc_info *info = ipctl->info;
if (info->flags & IMX_USE_SCU) if (info->flags & IMX_USE_SCU)
return imx_pinconf_get_scu(pctldev, pin_id, config); return info->imx_pinconf_get(pctldev, pin_id, config);
else else
return imx_pinconf_get_mmio(pctldev, pin_id, config); return imx_pinconf_get_mmio(pctldev, pin_id, config);
} }
...@@ -423,7 +423,7 @@ static int imx_pinconf_set(struct pinctrl_dev *pctldev, ...@@ -423,7 +423,7 @@ static int imx_pinconf_set(struct pinctrl_dev *pctldev,
const struct imx_pinctrl_soc_info *info = ipctl->info; const struct imx_pinctrl_soc_info *info = ipctl->info;
if (info->flags & IMX_USE_SCU) if (info->flags & IMX_USE_SCU)
return imx_pinconf_set_scu(pctldev, pin_id, return info->imx_pinconf_set(pctldev, pin_id,
configs, num_configs); configs, num_configs);
else else
return imx_pinconf_set_mmio(pctldev, pin_id, return imx_pinconf_set_mmio(pctldev, pin_id,
...@@ -440,7 +440,7 @@ static void imx_pinconf_dbg_show(struct pinctrl_dev *pctldev, ...@@ -440,7 +440,7 @@ static void imx_pinconf_dbg_show(struct pinctrl_dev *pctldev,
int ret; int ret;
if (info->flags & IMX_USE_SCU) { if (info->flags & IMX_USE_SCU) {
ret = imx_pinconf_get_scu(pctldev, pin_id, &config); ret = info->imx_pinconf_get(pctldev, pin_id, &config);
if (ret) { if (ret) {
dev_err(ipctl->dev, "failed to get %s pinconf\n", dev_err(ipctl->dev, "failed to get %s pinconf\n",
pin_get_name(pctldev, pin_id)); pin_get_name(pctldev, pin_id));
...@@ -629,7 +629,7 @@ static int imx_pinctrl_parse_groups(struct device_node *np, ...@@ -629,7 +629,7 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
for (i = 0; i < grp->num_pins; i++) { for (i = 0; i < grp->num_pins; i++) {
pin = &((struct imx_pin *)(grp->data))[i]; pin = &((struct imx_pin *)(grp->data))[i];
if (info->flags & IMX_USE_SCU) if (info->flags & IMX_USE_SCU)
imx_pinctrl_parse_pin_scu(ipctl, &grp->pins[i], info->imx_pinctrl_parse_pin(ipctl, &grp->pins[i],
pin, &list); pin, &list);
else else
imx_pinctrl_parse_pin_mmio(ipctl, &grp->pins[i], imx_pinctrl_parse_pin_mmio(ipctl, &grp->pins[i],
......
...@@ -75,6 +75,21 @@ struct imx_cfg_params_decode { ...@@ -75,6 +75,21 @@ struct imx_cfg_params_decode {
bool invert; bool invert;
}; };
/**
* @dev: a pointer back to containing device
* @base: the offset to the controller in virtual memory
*/
struct imx_pinctrl {
struct device *dev;
struct pinctrl_dev *pctl;
void __iomem *base;
void __iomem *input_sel_base;
const struct imx_pinctrl_soc_info *info;
struct imx_pin_reg *pin_regs;
unsigned int group_index;
struct mutex mutex;
};
struct imx_pinctrl_soc_info { struct imx_pinctrl_soc_info {
const struct pinctrl_pin_desc *pins; const struct pinctrl_pin_desc *pins;
unsigned int npins; unsigned int npins;
...@@ -98,21 +113,13 @@ struct imx_pinctrl_soc_info { ...@@ -98,21 +113,13 @@ struct imx_pinctrl_soc_info {
struct pinctrl_gpio_range *range, struct pinctrl_gpio_range *range,
unsigned offset, unsigned offset,
bool input); bool input);
}; int (*imx_pinconf_get)(struct pinctrl_dev *pctldev, unsigned int pin_id,
unsigned long *config);
/** int (*imx_pinconf_set)(struct pinctrl_dev *pctldev, unsigned int pin_id,
* @dev: a pointer back to containing device unsigned long *configs, unsigned int num_configs);
* @base: the offset to the controller in virtual memory void (*imx_pinctrl_parse_pin)(struct imx_pinctrl *ipctl,
*/ unsigned int *pin_id, struct imx_pin *pin,
struct imx_pinctrl { const __be32 **list_p);
struct device *dev;
struct pinctrl_dev *pctl;
void __iomem *base;
void __iomem *input_sel_base;
const struct imx_pinctrl_soc_info *info;
struct imx_pin_reg *pin_regs;
unsigned int group_index;
struct mutex mutex;
}; };
#define IMX_CFG_PARAMS_DECODE(p, m, o) \ #define IMX_CFG_PARAMS_DECODE(p, m, o) \
...@@ -137,7 +144,6 @@ struct imx_pinctrl { ...@@ -137,7 +144,6 @@ struct imx_pinctrl {
int imx_pinctrl_probe(struct platform_device *pdev, int imx_pinctrl_probe(struct platform_device *pdev,
const struct imx_pinctrl_soc_info *info); const struct imx_pinctrl_soc_info *info);
#ifdef CONFIG_PINCTRL_IMX_SCU
#define BM_PAD_CTL_GP_ENABLE BIT(30) #define BM_PAD_CTL_GP_ENABLE BIT(30)
#define BM_PAD_CTL_IFMUX_ENABLE BIT(31) #define BM_PAD_CTL_IFMUX_ENABLE BIT(31)
#define BP_PAD_CTL_IFMUX 27 #define BP_PAD_CTL_IFMUX 27
...@@ -150,23 +156,4 @@ int imx_pinconf_set_scu(struct pinctrl_dev *pctldev, unsigned pin_id, ...@@ -150,23 +156,4 @@ int imx_pinconf_set_scu(struct pinctrl_dev *pctldev, unsigned pin_id,
void imx_pinctrl_parse_pin_scu(struct imx_pinctrl *ipctl, void imx_pinctrl_parse_pin_scu(struct imx_pinctrl *ipctl,
unsigned int *pin_id, struct imx_pin *pin, unsigned int *pin_id, struct imx_pin *pin,
const __be32 **list_p); const __be32 **list_p);
#else
static inline int imx_pinconf_get_scu(struct pinctrl_dev *pctldev,
unsigned pin_id, unsigned long *config)
{
return -EINVAL;
}
static inline int imx_pinconf_set_scu(struct pinctrl_dev *pctldev,
unsigned pin_id, unsigned long *configs,
unsigned num_configs)
{
return -EINVAL;
}
static inline void imx_pinctrl_parse_pin_scu(struct imx_pinctrl *ipctl,
unsigned int *pin_id,
struct imx_pin *pin,
const __be32 **list_p)
{
}
#endif
#endif /* __DRIVERS_PINCTRL_IMX_H */ #endif /* __DRIVERS_PINCTRL_IMX_H */
...@@ -159,6 +159,9 @@ static struct imx_pinctrl_soc_info imx8dxl_pinctrl_info = { ...@@ -159,6 +159,9 @@ static struct imx_pinctrl_soc_info imx8dxl_pinctrl_info = {
.pins = imx8dxl_pinctrl_pads, .pins = imx8dxl_pinctrl_pads,
.npins = ARRAY_SIZE(imx8dxl_pinctrl_pads), .npins = ARRAY_SIZE(imx8dxl_pinctrl_pads),
.flags = IMX_USE_SCU, .flags = IMX_USE_SCU,
.imx_pinconf_get = imx_pinconf_get_scu,
.imx_pinconf_set = imx_pinconf_set_scu,
.imx_pinctrl_parse_pin = imx_pinctrl_parse_pin_scu,
}; };
static const struct of_device_id imx8dxl_pinctrl_of_match[] = { static const struct of_device_id imx8dxl_pinctrl_of_match[] = {
......
...@@ -292,6 +292,9 @@ static const struct imx_pinctrl_soc_info imx8qm_pinctrl_info = { ...@@ -292,6 +292,9 @@ static const struct imx_pinctrl_soc_info imx8qm_pinctrl_info = {
.pins = imx8qm_pinctrl_pads, .pins = imx8qm_pinctrl_pads,
.npins = ARRAY_SIZE(imx8qm_pinctrl_pads), .npins = ARRAY_SIZE(imx8qm_pinctrl_pads),
.flags = IMX_USE_SCU, .flags = IMX_USE_SCU,
.imx_pinconf_get = imx_pinconf_get_scu,
.imx_pinconf_set = imx_pinconf_set_scu,
.imx_pinctrl_parse_pin = imx_pinctrl_parse_pin_scu,
}; };
static const struct of_device_id imx8qm_pinctrl_of_match[] = { static const struct of_device_id imx8qm_pinctrl_of_match[] = {
......
...@@ -198,6 +198,9 @@ static struct imx_pinctrl_soc_info imx8qxp_pinctrl_info = { ...@@ -198,6 +198,9 @@ static struct imx_pinctrl_soc_info imx8qxp_pinctrl_info = {
.pins = imx8qxp_pinctrl_pads, .pins = imx8qxp_pinctrl_pads,
.npins = ARRAY_SIZE(imx8qxp_pinctrl_pads), .npins = ARRAY_SIZE(imx8qxp_pinctrl_pads),
.flags = IMX_USE_SCU, .flags = IMX_USE_SCU,
.imx_pinconf_get = imx_pinconf_get_scu,
.imx_pinconf_set = imx_pinconf_set_scu,
.imx_pinctrl_parse_pin = imx_pinctrl_parse_pin_scu,
}; };
static const struct of_device_id imx8qxp_pinctrl_of_match[] = { static const struct of_device_id imx8qxp_pinctrl_of_match[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment