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 pxa_pinctrl_group *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 pxa_pinctrl_group *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 pxa_pinctrl_function *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 pxa_pinctrl_function *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 pxa_pinctrl_group *group = pctl->groups + tgroup; in pxa2xx_pmx_set_mux()
150 df = pxa_desc_by_func_group(pctl, group->name, in pxa2xx_pmx_set_mux()
151 (pctl->functions + function)->name); in pxa2xx_pmx_set_mux()
156 gafr = pctl->base_gafr[pin / 16]; in pxa2xx_pmx_set_mux()
157 gpdr = pctl->base_gpdr[pin / 32]; in pxa2xx_pmx_set_mux()
159 dev_dbg(pctl->dev, "set_mux(pin=%d): af=%d dir=%d\n", in pxa2xx_pmx_set_mux()
162 spin_lock_irqsave(&pctl->lock, flags); in pxa2xx_pmx_set_mux()
172 spin_unlock_irqrestore(&pctl->lock, flags); in pxa2xx_pmx_set_mux()
188 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pconf_group_get() local
189 struct pxa_pinctrl_group *g = pctl->groups + group; in pxa2xx_pconf_group_get()
192 void __iomem *pgsr = pctl->base_pgsr[pin / 32]; in pxa2xx_pconf_group_get()
195 spin_lock_irqsave(&pctl->lock, flags); in pxa2xx_pconf_group_get()
198 spin_unlock_irqrestore(&pctl->lock, flags); in pxa2xx_pconf_group_get()
200 dev_dbg(pctl->dev, "get sleep gpio state(pin=%d) %d\n", in pxa2xx_pconf_group_get()
210 struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in pxa2xx_pconf_group_set() local
211 struct pxa_pinctrl_group *g = pctl->groups + group; in pxa2xx_pconf_group_set()
214 void __iomem *pgsr = pctl->base_pgsr[pin / 32]; in pxa2xx_pconf_group_set()
228 dev_dbg(pctl->dev, "set sleep gpio state(pin=%d) %d\n", in pxa2xx_pconf_group_set()
231 spin_lock_irqsave(&pctl->lock, flags); in pxa2xx_pconf_group_set()
235 spin_unlock_irqrestore(&pctl->lock, flags); in pxa2xx_pconf_group_set()
253 pxa2xx_find_function(struct pxa_pinctrl *pctl, const char *fname, in pxa2xx_find_function() argument
265 static int pxa2xx_build_functions(struct pxa_pinctrl *pctl) in pxa2xx_build_functions() argument
277 functions = devm_kcalloc(pctl->dev, pctl->npins * 6, in pxa2xx_build_functions()
282 for (i = 0; i < pctl->npins; i++) in pxa2xx_build_functions()
283 for (df = pctl->ppins[i].functions; df->name; df++) in pxa2xx_build_functions()
284 if (!pxa2xx_find_function(pctl, df->name, functions)) in pxa2xx_build_functions()
285 (functions + pctl->nfuncs++)->name = df->name; in pxa2xx_build_functions()
286 pctl->functions = devm_kmemdup(pctl->dev, functions, in pxa2xx_build_functions()
287 pctl->nfuncs * sizeof(*functions), in pxa2xx_build_functions()
289 if (!pctl->functions) in pxa2xx_build_functions()
292 devm_kfree(pctl->dev, functions); in pxa2xx_build_functions()
296 static int pxa2xx_build_groups(struct pxa_pinctrl *pctl) in pxa2xx_build_groups() argument
303 gtmp = devm_kmalloc_array(pctl->dev, pctl->npins, sizeof(*gtmp), in pxa2xx_build_groups()
308 for (i = 0; i < pctl->nfuncs; i++) { in pxa2xx_build_groups()
310 for (j = 0; j < pctl->npins; j++) in pxa2xx_build_groups()
311 for (df = pctl->ppins[j].functions; df->name; in pxa2xx_build_groups()
313 if (!strcmp(pctl->functions[i].name, in pxa2xx_build_groups()
316 pctl->ppins[j].pin.name; in pxa2xx_build_groups()
317 func = pctl->functions + i; in pxa2xx_build_groups()
320 devm_kmalloc_array(pctl->dev, ngroups, in pxa2xx_build_groups()
328 devm_kfree(pctl->dev, gtmp); in pxa2xx_build_groups()
332 static int pxa2xx_build_state(struct pxa_pinctrl *pctl, in pxa2xx_build_state() argument
339 pctl->npins = npins; in pxa2xx_build_state()
340 pctl->ppins = ppins; in pxa2xx_build_state()
341 pctl->ngroups = npins; in pxa2xx_build_state()
343 pctl->desc.npins = npins; in pxa2xx_build_state()
344 pins = devm_kcalloc(pctl->dev, npins, sizeof(*pins), GFP_KERNEL); in pxa2xx_build_state()
348 pctl->desc.pins = pins; in pxa2xx_build_state()
352 pctl->groups = devm_kmalloc_array(pctl->dev, pctl->ngroups, in pxa2xx_build_state()
353 sizeof(*pctl->groups), GFP_KERNEL); in pxa2xx_build_state()
354 if (!pctl->groups) in pxa2xx_build_state()
358 group = pctl->groups + i; in pxa2xx_build_state()
363 ret = pxa2xx_build_functions(pctl); in pxa2xx_build_state()
367 ret = pxa2xx_build_groups(pctl); in pxa2xx_build_state()
379 struct pxa_pinctrl *pctl; in pxa2xx_pinctrl_init() local
385 pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL); in pxa2xx_pinctrl_init()
386 if (!pctl) in pxa2xx_pinctrl_init()
388 pctl->base_gafr = devm_kcalloc(&pdev->dev, roundup(maxpin, 16), in pxa2xx_pinctrl_init()
389 sizeof(*pctl->base_gafr), GFP_KERNEL); in pxa2xx_pinctrl_init()
390 pctl->base_gpdr = devm_kcalloc(&pdev->dev, roundup(maxpin, 32), in pxa2xx_pinctrl_init()
391 sizeof(*pctl->base_gpdr), GFP_KERNEL); in pxa2xx_pinctrl_init()
392 pctl->base_pgsr = devm_kcalloc(&pdev->dev, roundup(maxpin, 32), in pxa2xx_pinctrl_init()
393 sizeof(*pctl->base_pgsr), GFP_KERNEL); in pxa2xx_pinctrl_init()
394 if (!pctl->base_gafr || !pctl->base_gpdr || !pctl->base_pgsr) in pxa2xx_pinctrl_init()
397 platform_set_drvdata(pdev, pctl); in pxa2xx_pinctrl_init()
398 spin_lock_init(&pctl->lock); in pxa2xx_pinctrl_init()
400 pctl->dev = &pdev->dev; in pxa2xx_pinctrl_init()
401 pctl->desc = pxa2xx_pinctrl_desc; in pxa2xx_pinctrl_init()
402 pctl->desc.name = dev_name(&pdev->dev); in pxa2xx_pinctrl_init()
403 pctl->desc.owner = THIS_MODULE; in pxa2xx_pinctrl_init()
406 pctl->base_gafr[i / 16] = base_gafr[i / 16]; in pxa2xx_pinctrl_init()
408 pctl->base_gpdr[i / 32] = base_gpdr[i / 32]; in pxa2xx_pinctrl_init()
409 pctl->base_pgsr[i / 32] = base_pgsr[i / 32]; in pxa2xx_pinctrl_init()
412 ret = pxa2xx_build_state(pctl, ppins, npins); in pxa2xx_pinctrl_init()
416 pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, &pctl->desc, pctl); in pxa2xx_pinctrl_init()
417 if (IS_ERR(pctl->pctl_dev)) { in pxa2xx_pinctrl_init()
419 return PTR_ERR(pctl->pctl_dev); in pxa2xx_pinctrl_init()