On Thu, Nov 17, 2022 at 02:05:11PM +0200, Ilpo Järvinen wrote: > Add support for indirect register access via a regmap interface. > > Indirect register access is a generic way to access registers indirectly. > One use case is accessing registers on Intel FPGA IPs with e.g. PMCI or > HSSI. I can't tell from this changelog what exactly you're trying to implement here... > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Indirect Register Access. > + * > + * Copyright (C) 2020-2022 Intel Corporation, Inc. > + */ > +#include <linux/debugfs.h> Please make the entire comment a C++ one so things look more intentional. > +#include <linux/module.h> > +#include <linux/mutex.h> > +#include <linux/regmap.h> > +#include <linux/seq_file.h> I can't see what seq_file.h is used for, which is probably good TBH since the interfaces it offers don't look like things I'd expect a regmap bus to use. > +static int indirect_bus_reg_read(void *context, unsigned int reg, > + unsigned int *val) > +{ > + struct indirect_ctx *ctx = context; > + unsigned int cmd, ack, tmpval; > + int ret; > + > + cmd = readl(ctx->base + ctx->indirect_cfg->cmd_offset); > + if (cmd != ctx->indirect_cfg->idle_cmd) > + dev_warn(ctx->dev, "residual cmd 0x%x on read entry\n", cmd); > + > + writel(reg, ctx->base + ctx->indirect_cfg->addr_offset); > + writel(ctx->indirect_cfg->read_cmd, ctx->base + ctx->indirect_cfg->cmd_offset); > + > + ret = readl_poll_timeout(ctx->base + ctx->indirect_cfg->ack_offset, ack, > + (ack & ctx->indirect_cfg->ack_mask) == ctx->indirect_cfg->ack_mask, > + ctx->indirect_cfg->sleep_us, ctx->indirect_cfg->timeout_us); This all looks very specific to one particular implementation, requiring a particular set of memory mapped registers and operations - things like the initial read of the command for example. It's not clear to me how much reuse this is likely to see outside of the one driver you're trying to add - if you want to implement something device specific you can just provide the custom operations in the device's regmap configuration rather than having to provide a bus. Why add a bus?
Attachment:
signature.asc
Description: PGP signature