Hi Jagan, On Wed, Oct 10, 2018 at 11:28:17AM +0530, Jagan Teki wrote: > On Wed, Oct 10, 2018 at 5:10 AM Angelo Dureghello <ang...@sysam.it> wrote: > > > > Adding DM and DT support and removing old non-DM code. > > Commit head can be: spi: cf_spi: Convert to driver model > Ok, as you prefer. Will do in v3. > > > > Signed-off-by: Angelo Dureghello <ang...@sysam.it> > > --- > > Changes for v2: > > - removed non DM code part > > - add default setup of CTAR registers > > - add DT CTAR register setup support > > --- > > drivers/spi/cf_spi.c | 510 +++++++++++++++--------- > > include/dm/platform_data/spi_coldfire.h | 29 ++ > > 2 files changed, 346 insertions(+), 193 deletions(-) > > create mode 100644 include/dm/platform_data/spi_coldfire.h > > > > diff --git a/drivers/spi/cf_spi.c b/drivers/spi/cf_spi.c > > index 522631cbbf..55e2c9d7b7 100644 > > --- a/drivers/spi/cf_spi.c > > +++ b/drivers/spi/cf_spi.c > > @@ -6,16 +6,28 @@ > > * > > * Copyright (C) 2004-2009 Freescale Semiconductor, Inc. > > * TsiChung Liew (tsi-chung.l...@freescale.com) > > + * > > + * Support for DM and DT, non-DM code removed. > > + * Copyright (C) 2018 Angelo Dureghello <ang...@sysam.it> > > + * > > + * TODO: fsl_dspi.c should work as a driver for the DSPI module. > > what is this for? >
cf_spi.c is here for historical reasons, but may probably be removed completely, since fsl_dspi.c is for the same Freescale DSPI hardware module, with the minimal difference of the FIFO size, that is raised to 16 words (from 4) in ColdFire. If you look fsl_dspi.c you will find some CONFIG_M68K references so this means someone already tried to use it for m68k, even if actually still only cf_spi.c is used from the ColdFire family. In linux i mainlined usage of fsl_dspi for ColdFire, so very likely it is possible to use fsl_dspi and remove totally cf_spi also in u-boot). But this would need a further step to verify feasibility and to test it carefully. > > */ > > > > #include <common.h> > > +#include <dm.h> > > +#include <dm/platform_data/spi_coldfire.h> > > #include <spi.h> > > #include <malloc.h> > > #include <asm/immap.h> > > +#include <asm/io.h> > > > > -struct cf_spi_slave { > > +struct coldfire_spi_priv { > > +#ifndef CONFIG_DM_SPI > > struct spi_slave slave; > > +#endif > > do you still maintain non-dm code? if yes can't we get rid of? > Ack, will rmeove. > > + struct dspi *regs; > > uint baudrate; > > + int mode; > > int charbit; > > }; > > > > @@ -38,14 +50,30 @@ DECLARE_GLOBAL_DATA_PTR; > > #define SPI_MODE_MOD 0x00200000 > > #define SPI_DBLRATE 0x00100000 > > > > -static inline struct cf_spi_slave *to_cf_spi_slave(struct spi_slave *slave) > > -{ > > - return container_of(slave, struct cf_spi_slave, slave); > > -} > > +#define MCF_DSPI_MAX_CTAR_REGS 8 > > + > > +/* Default values */ > > +#define MCF_DSPI_DEFAULT_SCK_FREQ 10000000 > > +#define MCF_DSPI_DEFAULT_MAX_CS 4 > > +#define MCF_DSPI_DEFAULT_MODE 0 > > > > -static void cfspi_init(void) > > +#define MCF_DSPI_DEFAULT_CTAR (DSPI_CTAR_TRSZ(7) | \ > > + DSPI_CTAR_PCSSCK_1CLK | \ > > + DSPI_CTAR_PASC(0) | \ > > + DSPI_CTAR_PDT(0) | \ > > + DSPI_CTAR_CSSCK(0) | \ > > + DSPI_CTAR_ASC(0) | \ > > [snip] > > > -int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void > > *dout, > > - void *din, unsigned long flags) > > +static int coldfire_spi_probe(struct udevice *bus) > > { > > - return cfspi_xfer(slave, bitlen, dout, din, flags); > > + struct coldfire_spi_platdata *plat = dev_get_platdata(bus); > > + struct coldfire_spi_priv *cfspi = dev_get_priv(bus); > > + int i; > > + > > + cfspi->regs = (struct dspi *)plat->regs_addr; > > + > > + cfspi->baudrate = plat->speed_hz; > > + cfspi->mode = plat->mode; > > + > > + for (i = 0; i < MCF_DSPI_MAX_CTAR_REGS; i++) { > > + unsigned int ctar = 0; > > + > > + if (plat->ctar[i][0] == 0) > > + break; > > + > > + ctar = DSPI_CTAR_TRSZ(plat->ctar[i][0]) | > > + DSPI_CTAR_PCSSCK(plat->ctar[i][1]) | > > + DSPI_CTAR_PASC(plat->ctar[i][2]) | > > + DSPI_CTAR_PDT(plat->ctar[i][3]) | > > + DSPI_CTAR_CSSCK(plat->ctar[i][4]) | > > + DSPI_CTAR_ASC(plat->ctar[i][5]) | > > + DSPI_CTAR_DT(plat->ctar[i][6]) | > > + DSPI_CTAR_BR(plat->ctar[i][7]); > > + > > + writel(ctar, &cfspi->regs->ctar[i]); > > + } > > + > > + __spi_init(cfspi); > > + > > + return 0; > > } > > -#endif /* CONFIG_CMD_SPI */ > > + > > +static int coldfire_dspi_ofdata_to_platdata(struct udevice *bus) > > If you want to support platdata, it shouldn't available for DT so add > ifdef for DT. See recent patches about this change. Ok, will do. Regards, Angelo _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot