[PATCH v2 28/44] i2c: designware_i2c: Support ACPI table generation
Bin Meng
bmeng.cn at gmail.com
Tue Jul 14 03:59:16 CEST 2020
Hi Simon,
On Mon, Jul 13, 2020 at 2:07 PM Bin Meng <bmeng.cn at gmail.com> wrote:
>
> Hi Simon,
>
> On Mon, Jul 13, 2020 at 1:54 PM Bin Meng <bmeng.cn at gmail.com> wrote:
> >
> > On Wed, Jul 8, 2020 at 7:11 PM Wolfgang Wallner
> > <wolfgang.wallner at br-automation.com> wrote:
> > >
> > > Hi Simon,
> > >
> > > -----"Simon Glass" <sjg at chromium.org> schrieb: -----
> > > > Betreff: [PATCH v2 28/44] i2c: designware_i2c: Support ACPI table generation
> > > >
> > > > Update the PCI driver to generate ACPI information so that Linux has the
> > > > full information about each I2C bus.
> > > >
> > > > Signed-off-by: Simon Glass <sjg at chromium.org>
> > > >
> > > > Reviewed-by: Heiko Schocher <hs at denx.de>
> > > > ---
> > > >
> > > > Changes in v2:
> > > > - Add a few blank lines
> > > > - Drop dead code behind if (0)
> > > >
> > > > Changes in v1:
> > > > - Capitalise ACPI_OPS_PTR
> > > >
> > > > drivers/i2c/designware_i2c.c | 26 +++++++++
> > > > drivers/i2c/designware_i2c.h | 15 +++++
> > > > drivers/i2c/designware_i2c_pci.c | 96 +++++++++++++++++++++++++++++++-
> > > > 3 files changed, 136 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
> > > > index 44a1f33398..cf892c69d9 100644
> > > > --- a/drivers/i2c/designware_i2c.c
> > > > +++ b/drivers/i2c/designware_i2c.c
> > > > @@ -333,6 +333,32 @@ static int _dw_i2c_set_bus_speed(struct dw_i2c *priv, struct i2c_regs *i2c_base,
> > > > /* Restore back i2c now speed set */
> > > > if (ena == IC_ENABLE_0B)
> > > > dw_i2c_enable(i2c_base, true);
> > > > + if (priv)
> > > > + priv->config = config;
> > > > +
> > > > + return 0;
> > > > +}
> > > > +
> > > > +int dw_i2c_gen_speed_config(const struct udevice *dev, int speed_hz,
> > > > + struct dw_i2c_speed_config *config)
> > > > +{
> > > > + struct dw_i2c *priv = dev_get_priv(dev);
> > > > + ulong rate;
> > > > + int ret;
> > > > +
> > > > +#if CONFIG_IS_ENABLED(CLK)
> > > > + rate = clk_get_rate(&priv->clk);
> > > > + if (IS_ERR_VALUE(rate))
> > > > + return log_msg_ret("clk", -EINVAL);
> > > > +#else
> > > > + rate = IC_CLK;
> > > > +#endif
> > > > +
> > > > + ret = calc_bus_speed(priv, priv->regs, speed_hz, rate, config);
> > > > + if (ret)
> > > > + printf("%s: ret=%d\n", __func__, ret);
> > > > + if (ret)
> > > > + return log_msg_ret("calc_bus_speed", ret);
> > > >
> > > > return 0;
> > > > }
> > > > diff --git a/drivers/i2c/designware_i2c.h b/drivers/i2c/designware_i2c.h
> > > > index dc9a6ccb63..d87a3bff93 100644
> > > > --- a/drivers/i2c/designware_i2c.h
> > > > +++ b/drivers/i2c/designware_i2c.h
> > > > @@ -205,6 +205,7 @@ struct dw_i2c {
> > > > #if CONFIG_IS_ENABLED(CLK)
> > > > struct clk clk;
> > > > #endif
> > > > + struct dw_i2c_speed_config config;
> > > > };
> > > >
> > > > extern const struct dm_i2c_ops designware_i2c_ops;
> > > > @@ -213,4 +214,18 @@ int designware_i2c_probe(struct udevice *bus);
> > > > int designware_i2c_remove(struct udevice *dev);
> > > > int designware_i2c_ofdata_to_platdata(struct udevice *bus);
> > > >
> > > > +/**
> > > > + * dw_i2c_gen_speed_config() - Calculate config info from requested speed1
> > >
> > > Nit: is "speed1" a typo?
> >
> > I think so. Will fix it when applying.
>
> Since this series requires rebasing on top of u-boot-x86/master,
> please fix this in your next version.
Please note I have applied this patch in u-boot-x86 and fixed the typo here.
>
> >
> > >
> > > > + *
> > > > + * Calculate the speed config from the given @speed_hz and return it so that
> > > > + * it can be incorporated in ACPI tables
> > > > + *
> > > > + * @dev: I2C bus to check
> > > > + * @speed_hz: Requested speed in Hz
> > > > + * @config: Returns config to use for that speed
> > > > + * @return 0 if OK, -ve on error
> > > > + */
> > > > +int dw_i2c_gen_speed_config(const struct udevice *dev, int speed_hz,
> > > > + struct dw_i2c_speed_config *config);
> > > > +
> > > > #endif /* __DW_I2C_H_ */
Regards,
Bin
More information about the U-Boot
mailing list