All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuanhua Han <chuanhua.han@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [EXT] Re: [PATCH 2/5] dm: spi: Convert Freescale ESPI driver to driver model
Date: Thu, 23 May 2019 02:28:07 +0000	[thread overview]
Message-ID: <AM6PR04MB43571A91CD552B3DF0DD189697010@AM6PR04MB4357.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <VI1PR0402MB38542A96FCEA6B03543FB99D97000@VI1PR0402MB3854.eurprd04.prod.outlook.com>



> -----Original Message-----
> From: Prabhakar Kushwaha
> Sent: 2019年5月23日 0:53
> To: Chuanhua Han <chuanhua.han@nxp.com>; Jagan Teki
> <jagan@amarulasolutions.com>
> Cc: U-Boot-Denx <u-boot@lists.denx.de>; Jiafei Pan <jiafei.pan@nxp.com>;
> Jagan Teki <jagan@openedev.com>; Yinbo Zhu <yinbo.zhu@nxp.com>; Ruchika
> Gupta <ruchika.gupta@nxp.com>; Xiaobo Xie <xiaobo.xie@nxp.com>; Rajan
> Srivastava <rajan.srivastava@nxp.com>
> Subject: RE: [U-Boot] [EXT] Re: [PATCH 2/5] dm: spi: Convert Freescale ESPI
> driver to driver model
> 
> Dear Chuanhua, Jagan,
> 
> > -----Original Message-----
> > From: U-Boot <u-boot-bounces@lists.denx.de> On Behalf Of Chuanhua Han
> > Sent: Thursday, May 9, 2019 9:03 AM
> > To: Jagan Teki <jagan@amarulasolutions.com>
> > Cc: U-Boot-Denx <u-boot@lists.denx.de>; Jiafei Pan
> > <jiafei.pan@nxp.com>; Jagan Teki <jagan@openedev.com>; Yinbo Zhu
> > <yinbo.zhu@nxp.com>; Ruchika Gupta <ruchika.gupta@nxp.com>
> > Subject: Re: [U-Boot] [EXT] Re: [PATCH 2/5] dm: spi: Convert Freescale
> > ESPI driver to driver model
> >
> >
> >
> > > -----Original Message-----
> > > From: Jagan Teki <jagan@amarulasolutions.com>
> > > Sent: 2019年5月6日 15:03
> > > To: Chuanhua Han <chuanhua.han@nxp.com>
> > > Cc: Jagan Teki <jagan@openedev.com>; Wolfgang Denk <wd@denx.de>;
> > > Shengzhou Liu <shengzhou.liu@nxp.com>; Ruchika Gupta
> > > <ruchika.gupta@nxp.com>; U-Boot-Denx <u-boot@lists.denx.de>; Jiafei
> > > Pan <jiafei.pan@nxp.com>; Yinbo Zhu <yinbo.zhu@nxp.com>
> > > Subject: Re: [EXT] Re: [U-Boot] [PATCH 2/5] dm: spi: Convert
> > > Freescale ESPI driver to driver model
> > >
> > > Caution: EXT Email
> > >
> > > On Mon, May 6, 2019 at 12:29 PM Chuanhua Han
> <chuanhua.han@nxp.com>
> > > wrote:
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Jagan Teki <jagan@amarulasolutions.com>
> > > > > Sent: 2019年4月26日 2:07
> > > > > To: Chuanhua Han <chuanhua.han@nxp.com>
> > > > > Cc: Jagan Teki <jagan@openedev.com>; Wolfgang Denk <wd@denx.de>;
> > > > > Shengzhou Liu <shengzhou.liu@nxp.com>; Ruchika Gupta
> > > > > <ruchika.gupta@nxp.com>; U-Boot-Denx <u-boot@lists.denx.de>;
> > > > > Jiafei Pan <jiafei.pan@nxp.com>; Yinbo Zhu <yinbo.zhu@nxp.com>
> > > > > Subject: Re: [EXT] Re: [U-Boot] [PATCH 2/5] dm: spi: Convert
> > > > > Freescale ESPI driver to driver model
> > > > >
> > > > > Caution: EXT Email
> > > > >
> > > > > On Thu, Apr 25, 2019 at 8:27 AM Chuanhua Han
> > > <chuanhua.han@nxp.com>
> > > > > wrote:
> > > > > >
> > > > > > Hi,jagan
> > > > > > Thank you for your replay!
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: Jagan Teki <jagan@amarulasolutions.com>
> > > > > > > Sent: 2019年4月24日 14:57
> > > > > > > To: Chuanhua Han <chuanhua.han@nxp.com>
> > > > > > > Cc: Jagan Teki <jagan@openedev.com>; Wolfgang Denk
> > > > > > > <wd@denx.de>; Shengzhou Liu <shengzhou.liu@nxp.com>; Ruchika
> > > > > > > Gupta <ruchika.gupta@nxp.com>; U-Boot-Denx
> > > > > > > <u-boot@lists.denx.de>; Jiafei Pan <jiafei.pan@nxp.com>;
> > > > > > > Yinbo Zhu <yinbo.zhu@nxp.com>
> > > > > > > Subject: [EXT] Re: [U-Boot] [PATCH 2/5] dm: spi: Convert
> > > > > > > Freescale ESPI driver to driver model
> > > > > > >
> > > > > > > WARNING: This email was created outside of NXP. DO NOT CLICK
> > > > > > > links or attachments unless you recognize the sender and
> > > > > > > know the content is
> > > > > safe.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Tue, Apr 23, 2019 at 4:17 PM Chuanhua Han
> > > > > <chuanhua.han@nxp.com>
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > Modify the Freescale ESPI driver to support the driver model.
> > > > > > > > Also resolved the following problems:
> > > > > > > >
> > > > > > > > ===================== WARNING ====================== This
> > > > > > > > board
> > > > > > > does
> > > > > > > > not use CONFIG_DM_SPI. Please update the board before
> > > > > > > > v2019.04 for no dm conversion and v2019.07 for partially
> > > > > > > > dm
> > converted drivers.
> > > > > > > > Failure to update can lead to driver/board removal See
> > > > > > > > doc/driver-model/MIGRATION.txt for more info.
> > > > > > > > ====================================================
> > > > > > > > ===================== WARNING ====================== This
> > > > > > > > board
> > > > > > > does
> > > > > > > > not use CONFIG_DM_SPI_FLASH. Please update the board to
> > > > > > > > use CONFIG_SPI_FLASH before the v2019.07 release.
> > > > > > > > Failure to update by the deadline may result in board removal.
> > > > > > > > See doc/driver-model/MIGRATION.txt for more info.
> > > > > > > > ====================================================
> > > > > > > >
> > > > > > > > Signed-off-by: Chuanhua Han <chuanhua.han@nxp.com>
> > > > > > > > ---
> > > > > > > > depends on:
> > > > > > > >         -
> > > > > > > > https://eur01.safelinks.protection.outlook.com/?url=https%
> > > > > > > > 3A
> > > > > > > > %2
> > > > > > > > F%2F
> > > > > > > > patc
> > > > > > > >
> > > > > > >
> > > > >
> > >
> hwork.ozlabs.org%2Fproject%2Fuboot%2Flist%2F%3Fseries%3D99439&amp;d
> > > > > > > ata
> > > > > > > >
> > > > > > >
> > > > >
> > >
> =02%7C01%7Cchuanhua.han%40nxp.com%7Cfa6bdd7859c4411b5d8608d6c8
> > > > > > > 8223e3%7
> > > > > > > >
> > > > > > >
> > > > >
> > >
> C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1%7C63691685860819371
> > > > > > > 5&amp;sda
> > > > > > > >
> > > > > > >
> > > > >
> > >
> ta=437CqPexTmJAzhl7wZ3lAUQVbmy%2B2NvHlurTcGTJKT0%3D&amp;reserve
> > > > > > > d=0
> > > > > > > >
> > > > > > > >  drivers/spi/fsl_espi.c | 450
> > > > > > > > +++++++++++++++++++++++++++++------------
> > > > > > > >  1 file changed, 316 insertions(+), 134 deletions(-)
> > > > > > > >
> > > > > > > > diff --git a/drivers/spi/fsl_espi.c
> > > > > > > > b/drivers/spi/fsl_espi.c index 7444ae1a06..6ebe57c30b
> > > > > > > > 100644
> > > > > > > > --- a/drivers/spi/fsl_espi.c
> > > > > > > > +++ b/drivers/spi/fsl_espi.c
> > > > > > > > @@ -4,17 +4,27 @@
> > > > > > > >   *
> > > > > > > >   * Copyright 2010-2011 Freescale Semiconductor, Inc.
> > > > > > > >   * Author: Mingkai Hu (Mingkai.hu at freescale.com)
> > > > > > > > + *        Chuanhua Han (chuanhua.han at nxp.com)
> > > > > > > >   */
> > > > > > > >
> > > > > > > >  #include <common.h>
> > > > > > > > -
> > > > > > > >  #include <malloc.h>
> > > > > > > >  #include <spi.h>
> > > > > > > >  #include <asm/immap_85xx.h>
> > > > > > > > +#include <dm.h>
> > > > > > > > +#include <errno.h>
> > > > > > > > +#include <fdtdec.h>
> > > > > > > > +
> > > > > > > > +struct fsl_espi_platdata {
> > > > > > > > +       uint flags;
> > > > > > > > +       uint speed_hz;
> > > > > > > > +       uint num_chipselect;
> > > > > > > > +       fdt_addr_t regs_addr; };
> > > > > > > >
> > > > > > > > -struct fsl_spi_slave {
> > > > > > > > -       struct spi_slave slave;
> > > > > > > > +struct fsl_espi_priv {
> > > > > > > >         ccsr_espi_t     *espi;
> > > > > > > > +       u32 speed_hz;
> > > > > > > >         unsigned int    div16;
> > > > > > > >         unsigned int    pm;
> > > > > > > >         int             tx_timeout;
> > > > > > > > @@ -25,9 +35,18 @@ struct fsl_spi_slave {
> > > > > > > >         unsigned int    max_transfer_length;
> > > > > > > >  };
> > > > > > > >
> > > > > > > > +struct fsl_spi_slave {
> > > > > > > > +       struct spi_slave slave;
> > > > > > > > +       struct fsl_espi_priv priv; };
> > > > > > > > +
> > > > > > > >  #define to_fsl_spi_slave(s) container_of(s, struct
> > > > > > > > fsl_spi_slave,
> > > > > > > > slave)
> > > > > > > > +#define to_fsl_spi_priv(p) container_of(p, struct
> > > > > > > > +fsl_spi_slave,
> > > > > > > > +priv)
> > > > > > > >  #define US_PER_SECOND          1000000UL
> > > > > > > >
> > > > > > > > +/* default SCK frequency, unit: HZ */
> > > > > > > > +#define FSL_ESPI_DEFAULT_SCK_FREQ   10000000
> > > > > > > > +
> > > > > > > >  #define ESPI_MAX_CS_NUM                4
> > > > > > > >  #define ESPI_FIFO_WIDTH_BIT    32
> > > > > > > >
> > > > > > > > @@ -62,121 +81,46 @@ struct fsl_spi_slave {
> > > > > > > >
> > > > > > > >  #define ESPI_MAX_DATA_TRANSFER_LEN 0xFFF0
> > > > > > > >
> > > > > > > > -struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int
> cs,
> > > > > > > > -               unsigned int max_hz, unsigned int mode)
> > > > > > > > -{
> > > > > > > > -       struct fsl_spi_slave *fsl;
> > > > > > > > -       sys_info_t sysinfo;
> > > > > > > > -       unsigned long spibrg = 0;
> > > > > > > > -       unsigned long spi_freq = 0;
> > > > > > > > -       unsigned char pm = 0;
> > > > > > > > -
> > > > > > > > -       if (!spi_cs_is_valid(bus, cs))
> > > > > > > > -               return NULL;
> > > > > > > > -
> > > > > > > > -       fsl = spi_alloc_slave(struct fsl_spi_slave, bus, cs);
> > > > > > > > -       if (!fsl)
> > > > > > > > -               return NULL;
> > > > > > > > -
> > > > > > > > -       fsl->espi = (void *)(CONFIG_SYS_MPC85xx_ESPI_ADDR);
> > > > > > > > -       fsl->mode = mode;
> > > > > > > > -       fsl->max_transfer_length =
> ESPI_MAX_DATA_TRANSFER_LEN;
> > > > > > > > -
> > > > > > > > -       /* Set eSPI BRG clock source */
> > > > > > > > -       get_sys_info(&sysinfo);
> > > > > > > > -       spibrg = sysinfo.freq_systembus / 2;
> > > > > > > > -       fsl->div16 = 0;
> > > > > > > > -       if ((spibrg / max_hz) > 32) {
> > > > > > > > -               fsl->div16 = ESPI_CSMODE_DIV16;
> > > > > > > > -               pm = spibrg / (max_hz * 16 * 2);
> > > > > > > > -               if (pm > 16) {
> > > > > > > > -                       pm = 16;
> > > > > > > > -                       debug("Requested speed is too
> low: %d
> > > > > Hz, %ld
> > > > > > > Hz "
> > > > > > > > -                               "is used.\n", max_hz, spibrg /
> (32
> > > *
> > > > > 16));
> > > > > > > > -               }
> > > > > > > > -       } else
> > > > > > > > -               pm = spibrg / (max_hz * 2);
> > > > > > > > -       if (pm)
> > > > > > > > -               pm--;
> > > > > > > > -       fsl->pm = pm;
> > > > > > > > -
> > > > > > > > -       if (fsl->div16)
> > > > > > > > -               spi_freq = spibrg / ((pm + 1) * 2 * 16);
> > > > > > > > -       else
> > > > > > > > -               spi_freq = spibrg / ((pm + 1) * 2);
> > > > > > > > -
> > > > > > > > -       /* set tx_timeout to 10 times of one espi FIFO entry go
> out
> > > */
> > > > > > > > -       fsl->tx_timeout = DIV_ROUND_UP((US_PER_SECOND *
> > > > > > > ESPI_FIFO_WIDTH_BIT
> > > > > > > > -                               * 10), spi_freq);
> > > > > > > > -
> > > > > > > > -       return &fsl->slave;
> > > > > > > > -}
> > > > > > > > -
> > > > > > > > -void spi_free_slave(struct spi_slave *slave)
> > > > > > > > +#ifndef CONFIG_DM_SPI
> > > > > > >
> > > > > > > Would you try for full dm-conversion? it would be hard to
> > > > > > > move all respective defconfigs to use but better try since
> > > > > > > we have next version deadline for full dm-conversion. thanks!
> > > > > > Currently my espi driver is modified to be compatible with dm
> > > > > > configuration and non-dm configuration.
> > > > > > If uboot don't need non-dm code in the future, I will remove
> > > > > > this compatibility and only keep the dm driver code. Thank you.
> > > > >
> > > > > Idea is to make fully dm supported and ie what we have migration
> > > > > deadline, doc/driver-model/MIGRATION.txt
> > > > Do you mean that I need to delete the original non-dm code?
> > > > Or there are some values in the dm code that do not come from dts!
> > > > Can you tell me something about it? Thank you!
> > >
> > > If not dt, can be done via platdata, we have few drivers with
> > > similar support drivers/spi/pl022_spi.c
> > >
> 
> I am trying to break dead-lock here.
> 
> Request from Jagan i.e.  convert this driver in full DM model. Remove non-dm
> compatibility.
> Considering most of the NXP's PowerPC platforms are not supported device
> tree.
> A middle path will be platdata similar to drivers/spi/pl022_spi.c.
> 
> @Chunahua: can you check it's feasibility and provide solution as early as
> possible.
I don't know too much about platdata, and now both dm and non-dm support are supported.
Based on the i2c support that currently has lx1028 on hand, 
if espi needs to use platdata for implementation, 
it is estimated that it will be developed in June.
> 
> --pk

  reply	other threads:[~2019-05-23  2:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23  8:05 [U-Boot] [PATCH 1/5] spl: dm: disable SPI DM flash for non-DM SPL Chuanhua Han
2019-04-23  8:05 ` [U-Boot] [PATCH 2/5] dm: spi: Convert Freescale ESPI driver to driver model Chuanhua Han
2019-04-24  6:57   ` Jagan Teki
2019-04-25  2:57     ` [U-Boot] [EXT] " Chuanhua Han
2019-04-25 18:06       ` Jagan Teki
2019-05-06  6:59         ` Chuanhua Han
2019-05-06  7:02           ` Jagan Teki
2019-05-06  8:08             ` Chuanhua Han
2019-05-23  4:36               ` Jagan Teki
2019-05-23  4:42                 ` Chuanhua Han
2019-05-23  4:52                 ` Prabhakar Kushwaha
2019-05-23  4:55                   ` Jagan Teki
2019-06-03  4:09                     ` Chuanhua Han
2019-05-09  3:33             ` Chuanhua Han
2019-05-22 16:53               ` Prabhakar Kushwaha
2019-05-23  2:28                 ` Chuanhua Han [this message]
2019-05-23  4:38                 ` Jagan Teki
2019-05-23  4:41                   ` Chuanhua Han
2019-04-23  8:05 ` [U-Boot] [PATCH 3/5] powerpc: dts: t2080: add espi controller node support Chuanhua Han
2019-04-23  8:05 ` [U-Boot] [PATCH 4/5] powerpc: dts: t2080qds: add espi slave nodes support Chuanhua Han
2019-04-23  8:05 ` [U-Boot] [PATCH 5/5] configs: enable espi device module in T2080QDS Chuanhua Han

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=AM6PR04MB43571A91CD552B3DF0DD189697010@AM6PR04MB4357.eurprd04.prod.outlook.com \
    --to=chuanhua.han@nxp.com \
    --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.