From: Angelo Dureghello <angelo@sysam.it>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 03/11] drivers: spi: cf_spi: migrate to DM and DT
Date: Wed, 10 Oct 2018 11:57:21 +0200 [thread overview]
Message-ID: <20181010095721.GC26361@jerusalem> (raw)
In-Reply-To: <CAMty3ZD3tASJ8ws1ubs_ddhKMy37M4OiMajrrB03MB-g3NaOmg@mail.gmail.com>
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 <angelo@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 <angelo@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.Liew at freescale.com)
> > + *
> > + * Support for DM and DT, non-DM code removed.
> > + * Copyright (C) 2018 Angelo Dureghello <angelo@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
next prev parent reply other threads:[~2018-10-10 9:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-09 21:43 [U-Boot] [PATCH v2 00/11] m68k: initial devicetree support Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 01/11] m68k: add basic set of devicetrees Angelo Dureghello
2018-10-10 5:49 ` Jagan Teki
2018-10-10 9:38 ` Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 02/11] drivers: spi: cf_spi: add Kconfig option Angelo Dureghello
2018-10-10 5:51 ` Jagan Teki
2018-10-10 9:40 ` Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 03/11] drivers: spi: cf_spi: migrate to DM and DT Angelo Dureghello
2018-10-10 5:58 ` Jagan Teki
2018-10-10 9:57 ` Angelo Dureghello [this message]
2018-10-09 21:43 ` [U-Boot] [PATCH v2 04/11] drivers: serial: mcfuart: add DT support Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 05/11] drivers: serial: mcfuart: add Kconfig option Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 06/11] m68k: architecture changes to support fdt Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 07/11] m68k: add initial dts files for all m68k boards Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 08/11] m68k: enabling long jumps on mcf54x5 SoCs Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 09/11] configs: enable use of DT for all m68k boards Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 10/11] configs: add DM_SPI config option Angelo Dureghello
2018-10-09 21:43 ` [U-Boot] [PATCH v2 11/11] configs: remove CONFIG_SYS_DSPI_XX references Angelo Dureghello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181010095721.GC26361@jerusalem \
--to=angelo@sysam.it \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.