[U-Boot] [PATCH v2 17/18] spi: mtk_qspi: add qspi driver for MT7629 SoC
Guochun Mao
guochun.mao at mediatek.com
Wed Nov 21 11:46:49 UTC 2018
Hi Jagan,
On Wed, 2018-11-21 at 15:08 +0530, Jagan Teki wrote:
> > > > +static int mtk_qspi_tx_rx(struct mtk_qspi_priv *priv)
> > > > +{
> > > > + int len = 1 + priv->txlen + priv->rxlen;
> > > > + int i, ret, idx;
> > > > +
> > > > + if (len > MTK_QSPI_MAX_SHIFT)
> > > > + return -ERR_INVAL;
> > > > +
> > > > + writeb(len * 8, &priv->regs->cnt);
> > > > +
> > > > + /* start at PRGDATA5, go down to PRGDATA0 */
> > > > + idx = MTK_QSPI_MAX_RX_TX_SHIFT - 1;
> > > > +
> > > > + /* opcode */
> > > > + writeb(priv->op, &priv->regs->prgdata[idx]);
> > > > + idx--;
> > > > +
> > > > + /* program TX data */
> > > > + for (i = 0; i < priv->txlen; i++, idx--)
> > > > + writeb(priv->tx[i], &priv->regs->prgdata[idx]);
> > > > +
> > > > + /* clear out rest of TX registers */
> > > > + while (idx >= 0) {
> > > > + writeb(0, &priv->regs->prgdata[idx]);
> > > > + idx--;
> > > > + }
> > > > +
> > > > + ret = mtk_qspi_execute_cmd(priv, MTK_QSPI_PRG_CMD);
> > >
> > > What does this execute do?
> > It send command to flash, and latch data if need.
> >
> > > does it intiate the controller register
> > > based flash command or so?
> > No, it doesn't.
> >
> > >
> > > Do you have Linux driver on the controller?
> > Yes, it's drivers/mtd/spi-nor/mtk-quadspi.c
>
> This sounds more specific to flash controller rather than spi driver.
> Can you try to write driver in mtd side itself, like Linux spi-nor.
> use UCLASS_SPI_FLASH
Sorry, I'm a little confused.
There are many files(***qspi.c) those that used for accessing spi flash
under folder drivers/spi/.
However, there's no specific flash controller driver implemented under
drives/mtd, only common spi_flash framework. It's different with kernel.
It seems that we only need implement the spi control logic of
spi-flash-controller(this part not based on flash, it only do
data-xfer), and spi_flash framework will work well base on it.
Isn't that the purpose of this architecture?
More information about the U-Boot
mailing list