From: Jeremy Kerr <jk@codeconstruct.com.au>
To: Vitor Soares <ivitro@gmail.com>, linux-i3c@lists.infradead.org
Cc: linux-aspeed@lists.ozlabs.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH] i3c: dw: Use configured rate and bus mode for clock configuration
Date: Fri, 24 Feb 2023 16:22:55 +0800 [thread overview]
Message-ID: <1cb6effca796c914a523d62a4dfff17ef7368ce7.camel@codeconstruct.com.au> (raw)
In-Reply-To: <547646005ac9e5013350c8ed84136088b6be7bad.camel@codeconstruct.com.au>
Hi Vitor,
> > > scl_timing = SCL_EXT_LCNT_1(lcnt);
> > > - lcnt = DIV_ROUND_UP(core_rate, I3C_BUS_SDR2_SCL_RATE) - hcnt;
> > > + lcnt = max_t(u8, lcnt,
> > > + DIV_ROUND_UP(core_rate, I3C_BUS_SDR2_SCL_RATE) - hcnt);
> > > scl_timing |= SCL_EXT_LCNT_2(lcnt);
> > > - lcnt = DIV_ROUND_UP(core_rate, I3C_BUS_SDR3_SCL_RATE) - hcnt;
> > > + lcnt = max_t(u8, lcnt,
> > > + DIV_ROUND_UP(core_rate, I3C_BUS_SDR3_SCL_RATE) - hcnt);
> > > scl_timing |= SCL_EXT_LCNT_3(lcnt);
> > > - lcnt = DIV_ROUND_UP(core_rate, I3C_BUS_SDR4_SCL_RATE) - hcnt;
> > > + lcnt = max_t(u8, lcnt,
> > > + DIV_ROUND_UP(core_rate, I3C_BUS_SDR4_SCL_RATE) - hcnt);
> >
> > what about to use a for loop and only do lcnt calculation if
> >
> > bus->scl_rate.i3c > I3C_BUS_SDRx_SCL_RATE ?
>
> I have intended for this to be the same as the existing calculations,
> just applying the limit of the global scl_rate.
>
> We could restructure as a for-loop (which I'd suggest splitting as a
> separate change, so that the calculation changes are more obvious),
> but it's going to get a bit weird with the macro usage there.
Actually, a for-loop isn't too bad:
static const struct {
unsigned int freq;
unsigned int shift;
} sdrs[] = {
{ I3C_BUS_SDR1_SCL_RATE, 0 },
{ I3C_BUS_SDR2_SCL_RATE, 8 },
{ I3C_BUS_SDR3_SCL_RATE, 16 },
{ I3C_BUS_SDR4_SCL_RATE, 24 },
};
static int dw_i3c_clk_cfg(struct dw_i3c_master *master, unsigned long i3c_rate,
bool pure)
{
/* ... */
/*
* Timings for lower SDRx rates where specified by device MXDS values;
* we limit these to the global max rate provided, which also prevents
* weird duty cycles
*/
scl_timing = 0;
for (i = 0; i < ARRAY_SIZE(sdrs); i++) {
tmp = DIV_ROUND_UP(core_rate, sdrs[i].freq) & 0xff;
if (tmp < lcnt)
tmp = lcnt;
scl_timing |= tmp << sdrs[i].shift;
}
writel(scl_timing, master->regs + SCL_EXT_LCNT_TIMING);
}
Is this what you were intending?
Cheers,
Jeremy
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
prev parent reply other threads:[~2023-02-25 21:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 6:20 [PATCH] i3c: dw: Use configured rate and bus mode for clock configuration Jeremy Kerr
2023-02-23 22:29 ` Vitor Soares
2023-02-24 2:32 ` Jeremy Kerr
2023-02-24 8:22 ` Jeremy Kerr [this message]
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=1cb6effca796c914a523d62a4dfff17ef7368ce7.camel@codeconstruct.com.au \
--to=jk@codeconstruct.com.au \
--cc=alexandre.belloni@bootlin.com \
--cc=ivitro@gmail.com \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-i3c@lists.infradead.org \
/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