drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c

Source file repositories/reference/linux-study-clean/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c

File Facts

System
Linux kernel
Corpus path
drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
Extension
.c
Size
103327 bytes
Lines
2891
Domain
Driver Families
Bucket
drivers/pinctrl
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (node) {
			map = syscon_node_to_regmap(node);
			of_node_put(node);
			if (IS_ERR(map))
				return map;
		} else
			return ERR_PTR(-ENODEV);

		ctx->maps[ASPEED_IP_GFX] = map;
		dev_dbg(ctx->dev, "Acquired GFX regmap");
		return map;
	}

	if (ip == ASPEED_IP_LPC) {
		struct device_node *np;
		struct regmap *map;

		np = of_parse_phandle(ctx->dev->of_node,
					"aspeed,external-nodes", 1);
		if (np) {
			if (!of_device_is_compatible(np->parent, "aspeed,ast2500-lpc-v2"))
				return ERR_PTR(-ENODEV);

			map = syscon_node_to_regmap(np->parent);
			of_node_put(np);
			if (IS_ERR(map))
				return map;
		} else
			return ERR_PTR(-ENODEV);

		ctx->maps[ASPEED_IP_LPC] = map;
		dev_dbg(ctx->dev, "Acquired LPC regmap");
		return map;
	}

	return ERR_PTR(-EINVAL);
}

static int aspeed_g5_sig_expr_eval(struct aspeed_pinmux_data *ctx,
				   const struct aspeed_sig_expr *expr,
				   bool enabled)
{
	int ret;
	int i;

	for (i = 0; i < expr->ndescs; i++) {
		const struct aspeed_sig_desc *desc = &expr->descs[i];
		struct regmap *map;

		map = aspeed_g5_acquire_regmap(ctx, desc->ip);
		if (IS_ERR(map)) {
			dev_err(ctx->dev,
				"Failed to acquire regmap for IP block %d\n",
				desc->ip);
			return PTR_ERR(map);
		}

		ret = aspeed_sig_desc_eval(desc, enabled, ctx->maps[desc->ip]);
		if (ret <= 0)
			return ret;
	}

	return 1;
}

/**
 * aspeed_g5_sig_expr_set() - Configure a pin's signal by applying an
 * expression's descriptor state for all descriptors in the expression.
 *
 * @ctx: The pinmux context
 * @expr: The expression associated with the function whose signal is to be
 *        configured
 * @enable: true to enable an function's signal through a pin's signal
 *          expression, false to disable the function's signal
 *
 * Return: 0 if the expression is configured as requested and a negative error
 * code otherwise
 */
static int aspeed_g5_sig_expr_set(struct aspeed_pinmux_data *ctx,
				  const struct aspeed_sig_expr *expr,
				  bool enable)
{
	int ret;
	int i;

	for (i = 0; i < expr->ndescs; i++) {
		const struct aspeed_sig_desc *desc = &expr->descs[i];
		u32 pattern = enable ? desc->enable : desc->disable;
		u32 val = (pattern << __ffs(desc->mask));
		struct regmap *map;

Annotation

Implementation Notes