[Skiboot] [PATCH 1/5] hdata/i2c: Fix bus and clock frequencies

Oliver O'Halloran oohall at gmail.com
Thu Apr 27 18:47:56 AEST 2017


Reviewed-by: Oliver O'Halloran <oohall at gmail.com>

On Mon, Apr 24, 2017 at 2:45 PM, Benjamin Herrenschmidt
<benh at 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 at 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 at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot


More information about the Skiboot mailing list