[PATCH 3/3] spi: mxic: add maximum speed of spi host

Miquel Raynal miquel.raynal at bootlin.com
Tue Feb 2 03:04:24 EST 2021


Hello,

> > > @@ -536,7 +537,9 @@ static int mxic_spi_probe(struct platform_device   
> *pdev)
> > >  {
> > >     struct spi_master *master;
> > >     struct resource *res;
> > > +   struct device_node *np = pdev->dev.of_node;
> > >     struct mxic_spi *mxic;
> > > +   u32 max_freq;
> > >     int ret;
> > > 
> > >     master = devm_spi_alloc_master(&pdev->dev, sizeof(struct   
> mxic_spi));
> > > @@ -580,6 +583,10 @@ static int mxic_spi_probe(struct platform_device   
> *pdev)
> > >           SPI_RX_QUAD | SPI_TX_QUAD |
> > >           SPI_RX_OCTAL | SPI_TX_OCTAL;
> > > 
> > > +   if (of_property_read_u32(np, "spi-max-frequency",
> > > +             &master->max_speed_hz))
> > > +      master->max_speed_hz = 25000000; /* 25MHz */  
> > 
> > As said before, there are two limitations to take into account:
> > 1- your controller maximum speed
> > 2- your flash maximum speed
> > 
> > (1) I don't think this needs to be exported through the DT, the driver
> >     knows his own limitations and enforces them.  
> 
> In fact, if master->max_speed_hz is not set, spi->max_speed_hz will be 0 
> and the
> host frequency cannot be set correctly.

You should set master->max_speed_hz in the probe. This is the maximum
speed your host can run at and has *nothing to do* with whatever device
is attached on the bus.

In the DT, use the spi-max-frequency property to inform the controller
about the maximum speed the device supports.

Then the controller should receive requests at the frequency chosen
with: min(master_max_freq, device_max_freq).

Thanks,
Miquèl



More information about the linux-mtd mailing list