Commit 477ac771 authored by Haojian Zhuang's avatar Haojian Zhuang Committed by Linus Walleij

pinctrl: single: set function mask as optional

Since Hisilicon's pin controller is divided into two parts. One is the
function mux, and the other is pin configuration. These two parts are
in the different memory regions. So make pinctrl-single,function-mask
as optional property. Then we can define pingroups without valid
function mux that is only used for pin configuration.
Signed-off-by: default avatarHaojian Zhuang <haojian.zhuang@linaro.org>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 9cfd1724
...@@ -350,6 +350,9 @@ static int pcs_enable(struct pinctrl_dev *pctldev, unsigned fselector, ...@@ -350,6 +350,9 @@ static int pcs_enable(struct pinctrl_dev *pctldev, unsigned fselector,
int i; int i;
pcs = pinctrl_dev_get_drvdata(pctldev); pcs = pinctrl_dev_get_drvdata(pctldev);
/* If function mask is null, needn't enable it. */
if (!pcs->fmask)
return 0;
func = radix_tree_lookup(&pcs->ftree, fselector); func = radix_tree_lookup(&pcs->ftree, fselector);
if (!func) if (!func)
return -EINVAL; return -EINVAL;
...@@ -384,6 +387,10 @@ static void pcs_disable(struct pinctrl_dev *pctldev, unsigned fselector, ...@@ -384,6 +387,10 @@ static void pcs_disable(struct pinctrl_dev *pctldev, unsigned fselector,
int i; int i;
pcs = pinctrl_dev_get_drvdata(pctldev); pcs = pinctrl_dev_get_drvdata(pctldev);
/* If function mask is null, needn't disable it. */
if (!pcs->fmask)
return;
func = radix_tree_lookup(&pcs->ftree, fselector); func = radix_tree_lookup(&pcs->ftree, fselector);
if (!func) { if (!func) {
dev_err(pcs->dev, "%s could not find function%i\n", dev_err(pcs->dev, "%s could not find function%i\n",
...@@ -427,6 +434,10 @@ static int pcs_request_gpio(struct pinctrl_dev *pctldev, ...@@ -427,6 +434,10 @@ static int pcs_request_gpio(struct pinctrl_dev *pctldev,
int mux_bytes = 0; int mux_bytes = 0;
unsigned data; unsigned data;
/* If function mask is null, return directly. */
if (!pcs->fmask)
return -ENOTSUPP;
list_for_each_safe(pos, tmp, &pcs->gpiofuncs) { list_for_each_safe(pos, tmp, &pcs->gpiofuncs) {
frange = list_entry(pos, struct pcs_gpiofunc_range, node); frange = list_entry(pos, struct pcs_gpiofunc_range, node);
if (pin >= frange->offset + frange->npins if (pin >= frange->offset + frange->npins
...@@ -969,10 +980,17 @@ static int pcs_probe(struct platform_device *pdev) ...@@ -969,10 +980,17 @@ static int pcs_probe(struct platform_device *pdev)
PCS_GET_PROP_U32("pinctrl-single,register-width", &pcs->width, PCS_GET_PROP_U32("pinctrl-single,register-width", &pcs->width,
"register width not specified\n"); "register width not specified\n");
PCS_GET_PROP_U32("pinctrl-single,function-mask", &pcs->fmask, ret = of_property_read_u32(np, "pinctrl-single,function-mask",
"function register mask not specified\n"); &pcs->fmask);
pcs->fshift = ffs(pcs->fmask) - 1; if (!ret) {
pcs->fmax = pcs->fmask >> pcs->fshift; pcs->fshift = ffs(pcs->fmask) - 1;
pcs->fmax = pcs->fmask >> pcs->fshift;
} else {
/* If mask property doesn't exist, function mux is invalid. */
pcs->fmask = 0;
pcs->fshift = 0;
pcs->fmax = 0;
}
ret = of_property_read_u32(np, "pinctrl-single,function-off", ret = of_property_read_u32(np, "pinctrl-single,function-off",
&pcs->foff); &pcs->foff);
......
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