Lines Matching +full:ast2400 +full:- +full:scu

1 // SPDX-License-Identifier: GPL-2.0-or-later
12 #include "pinctrl-aspeed.h"
18 return pdata->pinmux.ngroups; in aspeed_pinctrl_get_groups_count()
26 return pdata->pinmux.groups[group].name; in aspeed_pinctrl_get_group_name()
35 *pins = &pdata->pinmux.groups[group].pins[0]; in aspeed_pinctrl_get_group_pins()
36 *npins = pdata->pinmux.groups[group].npins; in aspeed_pinctrl_get_group_pins()
44 seq_printf(s, " %s", dev_name(pctldev->dev)); in aspeed_pinctrl_pin_dbg_show()
51 return pdata->pinmux.nfunctions; in aspeed_pinmux_get_fn_count()
59 return pdata->pinmux.functions[function].name; in aspeed_pinmux_get_fn_name()
69 *groups = pdata->pinmux.functions[function].groups; in aspeed_pinmux_get_fn_groups()
70 *num_groups = pdata->pinmux.functions[function].ngroups; in aspeed_pinmux_get_fn_groups()
80 pr_debug("Enabling signal %s for %s\n", expr->signal, in aspeed_sig_expr_enable()
81 expr->function); in aspeed_sig_expr_enable()
98 pr_debug("Disabling signal %s for %s\n", expr->signal, in aspeed_sig_expr_disable()
99 expr->function); in aspeed_sig_expr_disable()
112 * aspeed_disable_sig() - Disable a signal on a pin by disabling all provided
126 return -EINVAL; in aspeed_disable_sig()
137 * aspeed_find_expr_by_name - Search for the signal expression needed to
151 if (strcmp((*exprs)->function, name) == 0) in aspeed_find_expr_by_name()
167 prios = pdesc->prios; in get_defined_attribute()
198 found[len - 2] = '\0'; in get_defined_attribute()
205 return expr->function; in aspeed_sig_expr_function()
215 return expr->signal; in aspeed_sig_expr_signal()
229 const struct aspeed_pin_group *pgroup = &pdata->pinmux.groups[group]; in aspeed_pinmux_set_mux()
231 &pdata->pinmux.functions[function]; in aspeed_pinmux_set_mux()
233 for (i = 0; i < pgroup->npins; i++) { in aspeed_pinmux_set_mux()
234 int pin = pgroup->pins[i]; in aspeed_pinmux_set_mux()
235 const struct aspeed_pin_desc *pdesc = pdata->pins[pin].drv_data; in aspeed_pinmux_set_mux()
241 return -EINVAL; in aspeed_pinmux_set_mux()
243 pr_debug("Muxing pin %s for %s\n", pdesc->name, pfunc->name); in aspeed_pinmux_set_mux()
245 prios = pdesc->prios; in aspeed_pinmux_set_mux()
252 expr = aspeed_find_expr_by_name(funcs, pfunc->name); in aspeed_pinmux_set_mux()
257 ret = aspeed_disable_sig(&pdata->pinmux, funcs); in aspeed_pinmux_set_mux()
269 pfunc->name, pdesc->name, pin, signals, in aspeed_pinmux_set_mux()
274 return -ENXIO; in aspeed_pinmux_set_mux()
277 ret = aspeed_sig_expr_enable(&pdata->pinmux, expr); in aspeed_pinmux_set_mux()
281 pr_debug("Muxed pin %s as %s for %s\n", pdesc->name, expr->signal, in aspeed_pinmux_set_mux()
282 expr->function); in aspeed_pinmux_set_mux()
291 * We need to differentiate between GPIO and non-GPIO signals to in aspeed_expr_is_gpio()
296 * Generally we have the following - A GPIO such as B1 has: in aspeed_expr_is_gpio()
298 * - expr->signal set to "GPIOB1" in aspeed_expr_is_gpio()
299 * - expr->function set to "GPIOB1" in aspeed_expr_is_gpio()
305 * However, some GPIOs are input-only, and the ASPEED datasheets name in aspeed_expr_is_gpio()
306 * them differently. An input-only GPIO such as T0 has: in aspeed_expr_is_gpio()
308 * - expr->signal set to "GPIT0" in aspeed_expr_is_gpio()
309 * - expr->function set to "GPIT0" in aspeed_expr_is_gpio()
315 * Some pins in the ASPEED BMC SoCs have a "pass-through" GPIO in aspeed_expr_is_gpio()
317 * output state of another (as if they were shorted together - a mux in aspeed_expr_is_gpio()
322 * separate, pin-specific GPIO. in aspeed_expr_is_gpio()
324 * Conceptually this pass-through mode is a form of GPIO and is named in aspeed_expr_is_gpio()
326 * trips us up with the simple GPI-prefixed-signal-name scheme in aspeed_expr_is_gpio()
327 * discussed above, as the pass-through configuration is not what we in aspeed_expr_is_gpio()
330 * On e.g. the AST2400, a pass-through function "GPID0" is grouped on in aspeed_expr_is_gpio()
334 * - expr->signal set to "GPID0IN" in aspeed_expr_is_gpio()
335 * - expr->function set to "GPID0" in aspeed_expr_is_gpio()
338 * - expr->signal set to "GPID0OUT" in aspeed_expr_is_gpio()
339 * - expr->function set to "GPID0" in aspeed_expr_is_gpio()
341 * By contrast, the pin-specific GPIO expressions for the same pins are in aspeed_expr_is_gpio()
345 * - expr->signal looks like "GPIOD0" in aspeed_expr_is_gpio()
346 * - expr->function looks like "GPIOD0" in aspeed_expr_is_gpio()
349 * - expr->signal looks like "GPIOD1" in aspeed_expr_is_gpio()
350 * - expr->function looks like "GPIOD1" in aspeed_expr_is_gpio()
353 * differentiate the pass-through GPIO pinmux configuration from the in aspeed_expr_is_gpio()
354 * pin-specific configuration that the GPIO subsystem is after: An in aspeed_expr_is_gpio()
355 * expression is a pin-specific (non-pass-through) GPIO configuration in aspeed_expr_is_gpio()
359 return !strncmp(expr->signal, "GPI", 3) && in aspeed_expr_is_gpio()
360 !strcmp(expr->signal, expr->function); in aspeed_expr_is_gpio()
383 const struct aspeed_pin_desc *pdesc = pdata->pins[offset].drv_data; in aspeed_gpio_request_enable()
387 return -EINVAL; in aspeed_gpio_request_enable()
389 prios = pdesc->prios; in aspeed_gpio_request_enable()
392 return -ENXIO; in aspeed_gpio_request_enable()
394 pr_debug("Muxing pin %s for GPIO\n", pdesc->name); in aspeed_gpio_request_enable()
401 ret = aspeed_disable_sig(&pdata->pinmux, funcs); in aspeed_gpio_request_enable()
412 pdesc->name, offset, signals); in aspeed_gpio_request_enable()
415 return -ENXIO; in aspeed_gpio_request_enable()
421 * Disabling all higher-priority expressions is enough to enable the in aspeed_gpio_request_enable()
422 * lowest-priority signal type. As such it has no associated in aspeed_gpio_request_enable()
426 pr_debug("Muxed pin %s as GPIO\n", pdesc->name); in aspeed_gpio_request_enable()
434 ret = aspeed_sig_expr_enable(&pdata->pinmux, expr); in aspeed_gpio_request_enable()
438 pr_debug("Muxed pin %s as %s\n", pdesc->name, expr->signal); in aspeed_gpio_request_enable()
450 parent = pdev->dev.parent; in aspeed_pinctrl_probe()
452 dev_err(&pdev->dev, "No parent for syscon pincontroller\n"); in aspeed_pinctrl_probe()
453 return -ENODEV; in aspeed_pinctrl_probe()
456 pdata->scu = syscon_node_to_regmap(parent->of_node); in aspeed_pinctrl_probe()
457 if (IS_ERR(pdata->scu)) { in aspeed_pinctrl_probe()
458 dev_err(&pdev->dev, "No regmap for syscon pincontroller parent\n"); in aspeed_pinctrl_probe()
459 return PTR_ERR(pdata->scu); in aspeed_pinctrl_probe()
462 pdata->pinmux.maps[ASPEED_IP_SCU] = pdata->scu; in aspeed_pinctrl_probe()
464 pctl = pinctrl_register(pdesc, &pdev->dev, pdata); in aspeed_pinctrl_probe()
467 dev_err(&pdev->dev, "Failed to register pinctrl\n"); in aspeed_pinctrl_probe()
479 return offset >= config->pins[0] && offset <= config->pins[1]; in pin_in_config_range()
489 for (i = 0; i < pdata->nconfigs; i++) { in find_pinconf_config()
490 if (param == pdata->configs[i].param && in find_pinconf_config()
491 pin_in_config_range(offset, &pdata->configs[i])) in find_pinconf_config()
492 return &pdata->configs[i]; in find_pinconf_config()
508 for (i = 0; i < pdata->nconfmaps; i++) { in find_pinconf_map()
512 elem = &pdata->confmaps[i]; in find_pinconf_map()
516 match = (elem->arg == -1 || elem->arg == value); in find_pinconf_map()
519 match = (elem->val == value); in find_pinconf_map()
523 if (param == elem->param && match) in find_pinconf_map()
544 return -ENOTSUPP; in aspeed_pin_config_get()
546 rc = regmap_read(pdata->scu, pconf->reg, &val); in aspeed_pin_config_get()
551 (val & pconf->mask) >> __ffs(pconf->mask)); in aspeed_pin_config_get()
554 return -EINVAL; in aspeed_pin_config_get()
557 arg = (u32) pmap->arg; in aspeed_pin_config_get()
559 arg = !!pmap->arg; in aspeed_pin_config_get()
564 return -EINVAL; in aspeed_pin_config_get()
592 return -ENOTSUPP; in aspeed_pin_config_set()
597 return -EINVAL; in aspeed_pin_config_set()
599 val = pmap->val << __ffs(pconf->mask); in aspeed_pin_config_set()
601 rc = regmap_update_bits(pdata->scu, pconf->reg, in aspeed_pin_config_set()
602 pconf->mask, val); in aspeed_pin_config_set()
607 pr_debug("%s: Set SCU%02X[0x%08X]=0x%X for param %d(=%d) on pin %d\n", in aspeed_pin_config_set()
608 __func__, pconf->reg, pconf->mask, in aspeed_pin_config_set()
628 return -ENODEV; in aspeed_pin_config_group_get()