[U-Boot] [PATCH v5 02/12] spi: davinci_spi: Convert to driver to adapt to DM

Simon Glass sjg at chromium.org
Fri May 20 17:24:58 CEST 2016


Hi Vignesh,

On 19 May 2016 at 23:01, Vignesh R <vigneshr at ti.com> wrote:
>
> Convert davinci_spi driver so that it complies with SPI DM framework.
>
> Signed-off-by: Vignesh R <vigneshr at ti.com>
> Reviewed-by: Tom Rini <trini at konsulko.com>
> ---
>
> v5: correct error message.
>
> v4: Check error returned by dev_map_physmem().
>
> v3: No changes
>
> v2: Add comments to struct davinci_spi_slave members.
>     Use dev_map_physmem() added by previous patch.
>
>  drivers/spi/davinci_spi.c | 329 +++++++++++++++++++++++++++++++++-------------
>  1 file changed, 240 insertions(+), 89 deletions(-)

Sorry I missed something below.
[snip]

> +static int davinci_ofdata_to_platadata(struct udevice *bus)
> +{
> +       struct davinci_spi_slave *ds = dev_get_priv(bus);
> +       const void *blob = gd->fdt_blob;
> +       int node = bus->of_offset;
> +
> +       ds->regs = dev_map_physmem(bus, sizeof(struct davinci_spi_regs));
> +       if (!ds->regs) {
> +               printf("%s: could not map device address\n", __func__);
> +               return -ENODEV;

-EINVAL

We use -ENODEV to say there is no device. Here, we have a device but
the configuration is wrong.

>         }
> +       ds->num_cs = fdtdec_get_int(blob, node, "num-cs", 4);
> +
>         return 0;
>  }
> +
> +static const struct dm_spi_ops davinci_spi_ops = {
> +       .claim_bus      = davinci_spi_claim_bus,
> +       .release_bus    = davinci_spi_release_bus,
> +       .xfer           = davinci_spi_xfer,
> +       .set_speed      = davinci_spi_set_speed,
> +       .set_mode       = davinci_spi_set_mode,
> +};
> +
> +static const struct udevice_id davinci_spi_ids[] = {
> +       { .compatible = "ti,keystone-spi" },
> +       { .compatible = "ti,dm6441-spi" },
> +       { }
> +};
> +
> +U_BOOT_DRIVER(davinci_spi) = {
> +       .name = "davinci_spi",
> +       .id = UCLASS_SPI,
> +       .of_match = davinci_spi_ids,
> +       .ops = &davinci_spi_ops,
> +       .ofdata_to_platdata = davinci_ofdata_to_platadata,
> +       .priv_auto_alloc_size = sizeof(struct davinci_spi_slave),
> +       .probe = davinci_spi_probe,
> +};
> +#endif
> --
> 2.8.3
>


More information about the U-Boot mailing list