Message ID | 20170424044544.23810-1-benh@kernel.crashing.org |
---|---|
State | Accepted |
Headers | show |
Reviewed-by: Oliver O'Halloran <oohall@gmail.com> On Mon, Apr 24, 2017 at 2:45 PM, Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote: > The clock-frequency of the i2c master should be derived from > the xscom bus frequency (itself derived from the nest frequency). > > The bus-frequency of the i2c bus should be in Hz so convert the > HDAT value from kHz to Hz. > > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> > --- > hdata/i2c.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/hdata/i2c.c b/hdata/i2c.c > index 5a74a7f..24e9257 100644 > --- a/hdata/i2c.c > +++ b/hdata/i2c.c > @@ -31,6 +31,7 @@ static struct dt_node *get_i2cm_node(struct dt_node *xscom, int engine) > { > uint64_t xscom_base = P9_I2CM_XSCOM_BASE + P9_I2CM_XSCOM_SIZE * engine; > struct dt_node *i2cm; > + uint64_t freq, clock; > > i2cm = dt_find_by_name_addr(xscom, "i2cm", xscom_base); > if (!i2cm) { > @@ -45,8 +46,12 @@ static struct dt_node *get_i2cm_node(struct dt_node *xscom, int engine) > dt_add_property_cells(i2cm, "#address-cells", 1); > dt_add_property_cells(i2cm, "chip-engine#", engine); > > - /* XXX: verify this */ > - dt_add_property_cells(i2cm, "clock-frequency", 150000000); > + freq = dt_prop_get_u64_def(xscom, "bus-frequency", 0); > + clock = (u32)(freq / 4); > + if (clock) > + dt_add_property_cells(i2cm, "clock-frequency", clock); > + else > + dt_add_property_cells(i2cm, "clock-frequency", 150000000); > } > > return i2cm; > @@ -73,7 +78,7 @@ static struct dt_node *get_bus_node(struct dt_node *i2cm, int port, int freq) > * reduce the frequency to something that all devices > * can tolerate. > */ > - dt_add_property_cells(bus, "bus-frequency", freq); > + dt_add_property_cells(bus, "bus-frequency", freq * 1000); > } > > return bus; > -- > 2.9.3 > > _______________________________________________ > Skiboot mailing list > Skiboot@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/skiboot
Benjamin Herrenschmidt <benh@kernel.crashing.org> writes: > The clock-frequency of the i2c master should be derived from > the xscom bus frequency (itself derived from the nest frequency). > > The bus-frequency of the i2c bus should be in Hz so convert the > HDAT value from kHz to Hz. > > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> > --- > hdata/i2c.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) Series merged to master as of 0aff8c2f9e6d60a71bdbd7c6e06df3e4f1debccd
diff --git a/hdata/i2c.c b/hdata/i2c.c index 5a74a7f..24e9257 100644 --- a/hdata/i2c.c +++ b/hdata/i2c.c @@ -31,6 +31,7 @@ static struct dt_node *get_i2cm_node(struct dt_node *xscom, int engine) { uint64_t xscom_base = P9_I2CM_XSCOM_BASE + P9_I2CM_XSCOM_SIZE * engine; struct dt_node *i2cm; + uint64_t freq, clock; i2cm = dt_find_by_name_addr(xscom, "i2cm", xscom_base); if (!i2cm) { @@ -45,8 +46,12 @@ static struct dt_node *get_i2cm_node(struct dt_node *xscom, int engine) dt_add_property_cells(i2cm, "#address-cells", 1); dt_add_property_cells(i2cm, "chip-engine#", engine); - /* XXX: verify this */ - dt_add_property_cells(i2cm, "clock-frequency", 150000000); + freq = dt_prop_get_u64_def(xscom, "bus-frequency", 0); + clock = (u32)(freq / 4); + if (clock) + dt_add_property_cells(i2cm, "clock-frequency", clock); + else + dt_add_property_cells(i2cm, "clock-frequency", 150000000); } return i2cm; @@ -73,7 +78,7 @@ static struct dt_node *get_bus_node(struct dt_node *i2cm, int port, int freq) * reduce the frequency to something that all devices * can tolerate. */ - dt_add_property_cells(bus, "bus-frequency", freq); + dt_add_property_cells(bus, "bus-frequency", freq * 1000); } return bus;
The clock-frequency of the i2c master should be derived from the xscom bus frequency (itself derived from the nest frequency). The bus-frequency of the i2c bus should be in Hz so convert the HDAT value from kHz to Hz. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> --- hdata/i2c.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)