Lines Matching full:pctl

26 	struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);  in pxa2xx_pctrl_get_groups_count()  local
28 return pctl->ngroups; in pxa2xx_pctrl_get_groups_count()
34 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pctrl_get_group_name() local
35 struct pingroup *group = pctl->groups + tgroup; in pxa2xx_pctrl_get_group_name()
45 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pctrl_get_group_pins() local
46 struct pingroup *group = pctl->groups + tgroup; in pxa2xx_pctrl_get_group_pins()
65 pxa_desc_by_func_group(struct pxa_pinctrl *pctl, const char *pin_name, in pxa_desc_by_func_group() argument
71 for (i = 0; i < pctl->npins; i++) { in pxa_desc_by_func_group()
72 const struct pxa_desc_pin *pin = pctl->ppins + i; in pxa_desc_by_func_group()
88 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pmx_gpio_set_direction() local
93 gpdr = pctl->base_gpdr[pin / 32]; in pxa2xx_pmx_gpio_set_direction()
94 dev_dbg(pctl->dev, "set_direction(pin=%d): dir=%d\n", in pxa2xx_pmx_gpio_set_direction()
97 spin_lock_irqsave(&pctl->lock, flags); in pxa2xx_pmx_gpio_set_direction()
103 spin_unlock_irqrestore(&pctl->lock, flags); in pxa2xx_pmx_gpio_set_direction()
111 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pmx_get_func_name() local
112 struct pinfunction *pf = pctl->functions + function; in pxa2xx_pmx_get_func_name()
119 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_get_functions_count() local
121 return pctl->nfuncs; in pxa2xx_get_functions_count()
129 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pmx_get_func_groups() local
130 struct pinfunction *pf = pctl->functions + function; in pxa2xx_pmx_get_func_groups()
141 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pmx_set_mux() local
142 struct pingroup *g = pctl->groups + tgroup; in pxa2xx_pmx_set_mux()
150 df = pxa_desc_by_func_group(pctl, g->name, (pctl->functions + function)->name); in pxa2xx_pmx_set_mux()
154 gafr = pctl->base_gafr[pin / 16]; in pxa2xx_pmx_set_mux()
155 gpdr = pctl->base_gpdr[pin / 32]; in pxa2xx_pmx_set_mux()
157 dev_dbg(pctl->dev, "set_mux(pin=%d): af=%d dir=%d\n", in pxa2xx_pmx_set_mux()
160 spin_lock_irqsave(&pctl->lock, flags); in pxa2xx_pmx_set_mux()
170 spin_unlock_irqrestore(&pctl->lock, flags); in pxa2xx_pmx_set_mux()
186 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pconf_group_get() local
187 struct pingroup *g = pctl->groups + group; in pxa2xx_pconf_group_get()
190 void __iomem *pgsr = pctl->base_pgsr[pin / 32]; in pxa2xx_pconf_group_get()
193 spin_lock_irqsave(&pctl->lock, flags); in pxa2xx_pconf_group_get()
196 spin_unlock_irqrestore(&pctl->lock, flags); in pxa2xx_pconf_group_get()
198 dev_dbg(pctl->dev, "get sleep gpio state(pin=%d) %d\n", in pxa2xx_pconf_group_get()
208 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pconf_group_set() local
209 struct pingroup *g = pctl->groups + group; in pxa2xx_pconf_group_set()
212 void __iomem *pgsr = pctl->base_pgsr[pin / 32]; in pxa2xx_pconf_group_set()
226 dev_dbg(pctl->dev, "set sleep gpio state(pin=%d) %d\n", in pxa2xx_pconf_group_set()
229 spin_lock_irqsave(&pctl->lock, flags); in pxa2xx_pconf_group_set()
233 spin_unlock_irqrestore(&pctl->lock, flags); in pxa2xx_pconf_group_set()
250 static const struct pinfunction *pxa2xx_find_function(struct pxa_pinctrl *pctl, in pxa2xx_find_function() argument
263 static int pxa2xx_build_functions(struct pxa_pinctrl *pctl) in pxa2xx_build_functions() argument
275 functions = devm_kcalloc(pctl->dev, pctl->npins * 6, in pxa2xx_build_functions()
280 for (i = 0; i < pctl->npins; i++) in pxa2xx_build_functions()
281 for (df = pctl->ppins[i].functions; df->name; df++) in pxa2xx_build_functions()
282 if (!pxa2xx_find_function(pctl, df->name, functions)) in pxa2xx_build_functions()
283 (functions + pctl->nfuncs++)->name = df->name; in pxa2xx_build_functions()
284 pctl->functions = devm_kmemdup(pctl->dev, functions, in pxa2xx_build_functions()
285 pctl->nfuncs * sizeof(*functions), in pxa2xx_build_functions()
287 if (!pctl->functions) in pxa2xx_build_functions()
290 devm_kfree(pctl->dev, functions); in pxa2xx_build_functions()
294 static int pxa2xx_build_groups(struct pxa_pinctrl *pctl) in pxa2xx_build_groups() argument
301 gtmp = devm_kmalloc_array(pctl->dev, pctl->npins, sizeof(*gtmp), in pxa2xx_build_groups()
306 for (i = 0; i < pctl->nfuncs; i++) { in pxa2xx_build_groups()
308 for (j = 0; j < pctl->npins; j++) in pxa2xx_build_groups()
309 for (df = pctl->ppins[j].functions; df->name; in pxa2xx_build_groups()
311 if (!strcmp(pctl->functions[i].name, in pxa2xx_build_groups()
314 pctl->ppins[j].pin.name; in pxa2xx_build_groups()
315 func = pctl->functions + i; in pxa2xx_build_groups()
317 func->groups = devm_kmemdup(pctl->dev, gtmp, ngroups * sizeof(*gtmp), GFP_KERNEL); in pxa2xx_build_groups()
322 devm_kfree(pctl->dev, gtmp); in pxa2xx_build_groups()
326 static int pxa2xx_build_state(struct pxa_pinctrl *pctl, in pxa2xx_build_state() argument
333 pctl->npins = npins; in pxa2xx_build_state()
334 pctl->ppins = ppins; in pxa2xx_build_state()
335 pctl->ngroups = npins; in pxa2xx_build_state()
337 pctl->desc.npins = npins; in pxa2xx_build_state()
338 pins = devm_kcalloc(pctl->dev, npins, sizeof(*pins), GFP_KERNEL); in pxa2xx_build_state()
342 pctl->desc.pins = pins; in pxa2xx_build_state()
346 pctl->groups = devm_kmalloc_array(pctl->dev, pctl->ngroups, in pxa2xx_build_state()
347 sizeof(*pctl->groups), GFP_KERNEL); in pxa2xx_build_state()
348 if (!pctl->groups) in pxa2xx_build_state()
352 group = pctl->groups + i; in pxa2xx_build_state()
358 ret = pxa2xx_build_functions(pctl); in pxa2xx_build_state()
362 ret = pxa2xx_build_groups(pctl); in pxa2xx_build_state()
374 struct pxa_pinctrl *pctl; in pxa2xx_pinctrl_init() local
380 pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL); in pxa2xx_pinctrl_init()
381 if (!pctl) in pxa2xx_pinctrl_init()
383 pctl->base_gafr = devm_kcalloc(&pdev->dev, roundup(maxpin, 16), in pxa2xx_pinctrl_init()
384 sizeof(*pctl->base_gafr), GFP_KERNEL); in pxa2xx_pinctrl_init()
385 pctl->base_gpdr = devm_kcalloc(&pdev->dev, roundup(maxpin, 32), in pxa2xx_pinctrl_init()
386 sizeof(*pctl->base_gpdr), GFP_KERNEL); in pxa2xx_pinctrl_init()
387 pctl->base_pgsr = devm_kcalloc(&pdev->dev, roundup(maxpin, 32), in pxa2xx_pinctrl_init()
388 sizeof(*pctl->base_pgsr), GFP_KERNEL); in pxa2xx_pinctrl_init()
389 if (!pctl->base_gafr || !pctl->base_gpdr || !pctl->base_pgsr) in pxa2xx_pinctrl_init()
392 platform_set_drvdata(pdev, pctl); in pxa2xx_pinctrl_init()
393 spin_lock_init(&pctl->lock); in pxa2xx_pinctrl_init()
395 pctl->dev = &pdev->dev; in pxa2xx_pinctrl_init()
396 pctl->desc = pxa2xx_pinctrl_desc; in pxa2xx_pinctrl_init()
397 pctl->desc.name = dev_name(&pdev->dev); in pxa2xx_pinctrl_init()
398 pctl->desc.owner = THIS_MODULE; in pxa2xx_pinctrl_init()
401 pctl->base_gafr[i / 16] = base_gafr[i / 16]; in pxa2xx_pinctrl_init()
403 pctl->base_gpdr[i / 32] = base_gpdr[i / 32]; in pxa2xx_pinctrl_init()
404 pctl->base_pgsr[i / 32] = base_pgsr[i / 32]; in pxa2xx_pinctrl_init()
407 ret = pxa2xx_build_state(pctl, ppins, npins); in pxa2xx_pinctrl_init()
411 pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, &pctl->desc, pctl); in pxa2xx_pinctrl_init()
412 if (IS_ERR(pctl->pctl_dev)) { in pxa2xx_pinctrl_init()
414 return PTR_ERR(pctl->pctl_dev); in pxa2xx_pinctrl_init()