From: Philipp Zabel <p.zabel@pengutronix.de>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: linux-media@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
Ezequiel Garcia <ezequiel@collabora.com>,
Nicolas Dufresne <nicolas@ndufresne.ca>,
Jonas Karlman <jonas@kwiboo.se>,
devicetree@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH v2 5/9] media: hantro: add support for named register ranges
Date: Wed, 29 May 2019 15:20:52 +0200 [thread overview]
Message-ID: <1559136052.3651.9.camel@pengutronix.de> (raw)
In-Reply-To: <20190529134645.65f8feb4@collabora.com>
Hi Boris,
thank you for the review.
On Wed, 2019-05-29 at 13:46 +0200, Boris Brezillon wrote:
> On Wed, 29 May 2019 11:54:20 +0200
> Philipp Zabel <p.zabel@pengutronix.de> wrote:
>
> > Add support for multiple register ranges with SoC specific names.
> >
> > Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> > ---
> > drivers/staging/media/hantro/hantro.h | 7 ++++++-
> > drivers/staging/media/hantro/hantro_drv.c | 25 +++++++++++++++++------
> > 2 files changed, 25 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/staging/media/hantro/hantro.h b/drivers/staging/media/hantro/hantro.h
> > index 6b90fe48bcdf..b796867808d5 100644
> > --- a/drivers/staging/media/hantro/hantro.h
> > +++ b/drivers/staging/media/hantro/hantro.h
> > @@ -27,6 +27,7 @@
> >
> > #define HANTRO_MAX_CLOCKS 4
> > #define HANTRO_MAX_IRQS 3
> > +#define HANTRO_MAX_REG_RANGES 4
> >
> > #define MPEG2_MB_DIM 16
> > #define MPEG2_MB_WIDTH(w) DIV_ROUND_UP(w, MPEG2_MB_DIM)
> > @@ -63,6 +64,8 @@ struct hantro_codec_ops;
> > * @num_irqs: number of irqs in the arrays
> > * @clk_names: array of clock names
> > * @num_clocks: number of clocks in the array
> > + * @reg_names: array of register range names
> > + * @num_regs: number of register range names in the array
> > */
> > struct hantro_variant {
> > unsigned int enc_offset;
> > @@ -80,6 +83,8 @@ struct hantro_variant {
> > int num_irqs;
> > const char *clk_names[HANTRO_MAX_CLOCKS];
> > int num_clocks;
> > + const char *reg_names[HANTRO_MAX_REG_RANGES];
> > + int num_regs;
Do you suggest
const char * const *reg_names;
...
> > };
> >
> > /**
> > @@ -170,7 +175,7 @@ struct hantro_dev {
> > struct platform_device *pdev;
> > struct device *dev;
> > struct clk_bulk_data clocks[HANTRO_MAX_CLOCKS];
> > - void __iomem *base;
> > + void __iomem *base[HANTRO_MAX_REG_RANGES];
>
> Same comment as for the irq stuff.
... and
void __iomem **base;
to get rid of HANTRO_MAX_REG_RANGES?
Would you like to see the same for clk_names?
> > void __iomem *enc_base;
> > void __iomem *dec_base;
> >
> > diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
> > index f677b40bcd2d..bd02b27258e3 100644
> > --- a/drivers/staging/media/hantro/hantro_drv.c
> > +++ b/drivers/staging/media/hantro/hantro_drv.c
> > @@ -692,12 +692,25 @@ static int hantro_probe(struct platform_device *pdev)
> > if (ret)
> > return ret;
> >
> > - res = platform_get_resource(vpu->pdev, IORESOURCE_MEM, 0);
> > - vpu->base = devm_ioremap_resource(vpu->dev, res);
> > - if (IS_ERR(vpu->base))
> > - return PTR_ERR(vpu->base);
> > - vpu->enc_base = vpu->base + vpu->variant->enc_offset;
> > - vpu->dec_base = vpu->base + vpu->variant->dec_offset;
> > + if (vpu->variant->num_regs) {
> > + for (i = 0; i < vpu->variant->num_regs; i++) {
> > + const char *reg_name = vpu->variant->reg_names[i];
> > +
> > + res = platform_get_resource_byname(vpu->pdev,
> > + IORESOURCE_MEM,
> > + reg_name);
> > + vpu->base[i] = devm_ioremap_resource(vpu->dev, res);
> > + if (IS_ERR(vpu->base[i]))
> > + return PTR_ERR(vpu->base[i]);
> > + }
> > + } else {
> > + res = platform_get_resource(vpu->pdev, IORESOURCE_MEM, 0);
> > + vpu->base[0] = devm_ioremap_resource(vpu->dev, res);
> > + if (IS_ERR(vpu->base[0]))
> > + return PTR_ERR(vpu->base[0]);
> > + vpu->enc_base = vpu->base[0] + vpu->variant->enc_offset;
> > + vpu->dec_base = vpu->base[0] + vpu->variant->dec_offset;
>
> I see ->dec_based is assigned in ->hw_init() in patch 8, so maybe it's
> better to have the same workflow for rk variants: assign
> vpu->{dec,enc}_base in ->hw_init()
I didn't want to change this around too much, as dec_base is just needed
for the vdpu_read/write functions, and I expect we'll have to somehow
replace these anyway when adding G2 support.
Adding yet another set of register accessors for g1_read/write vs
g2_read/write isn't very convenient. Maybe it woudl be better to call
the register accessors with the base as a parameter instead of
hantro_dev.
Also the kerneldoc comment says .init() should "initialize hardware".
Should that be changed to "variant specific initialization" if the
enc/dec_base are set there?
> and set ->num_regs to 1 (plus a
> fallback to platform_get_resource() instead of
> platform_get_resource_byname() when ->reg_names[0] == NULL).
I suppose we could do that, but
static const char * const rk3288_regs[] = {
NULL
}
const struct hantro_variant rk3288_vpu_variant = {
.reg_n
ames = rk3288_regs,
.num_regs = ARRAY_SIZE(rk3288_regs)
};
would look a bit strange if we were to get rid of
HANTRO_MAX_REG_RANGES...
regards
Philipp
next prev parent reply other threads:[~2019-05-29 13:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-29 9:54 [PATCH v2 0/9] Rename Rockchip VPU driver to Hantro, add initial i.MX8M support Philipp Zabel
2019-05-29 9:54 ` [PATCH v2 1/9] rockchip/vpu: rename from rockchip to hantro Philipp Zabel
2019-05-29 11:16 ` Boris Brezillon
2019-05-29 9:54 ` [PATCH v2 2/9] media: hantro: print video device name in addition to device node Philipp Zabel
2019-05-29 11:16 ` Boris Brezillon
2019-05-29 9:54 ` [PATCH v2 3/9] media: hantro: add PM runtime resume callback Philipp Zabel
2019-05-29 11:18 ` Boris Brezillon
2019-05-29 9:54 ` [PATCH v2 4/9] media: hantro: make irq names configurable Philipp Zabel
2019-05-29 11:34 ` Boris Brezillon
2019-05-29 12:24 ` Philipp Zabel
2019-05-29 9:54 ` [PATCH v2 5/9] media: hantro: add support for named register ranges Philipp Zabel
2019-05-29 11:46 ` Boris Brezillon
2019-05-29 13:20 ` Philipp Zabel [this message]
2019-05-29 13:46 ` Boris Brezillon
2019-05-29 9:54 ` [PATCH v2 6/9] media: hantro: add support for separate control block Philipp Zabel
2019-05-29 9:54 ` [PATCH v2 7/9] media: dt-bindings: Document i.MX8MQ and i.MX8MM VPU bindings Philipp Zabel
2019-05-29 9:54 ` [PATCH v2 8/9] media: hantro: add initial i.MX8MQ support Philipp Zabel
2019-05-29 9:54 ` [PATCH v2 9/9] media: hantro: add initial i.MX8MM support (untested) Philipp Zabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1559136052.3651.9.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=boris.brezillon@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=ezequiel@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=jonas@kwiboo.se \
--cc=kernel@pengutronix.de \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=nicolas@ndufresne.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).