Re: (EXT) Re: [PATCH] spi-imx: remove num-cs support, set num_chipselect to 4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2020-09-04 at 09:35 -0300, Fabio Estevam wrote:
> Hi Matthias,
> 
> On Thu, Sep 3, 2020 at 11:40 AM Matthias Schiffer
> <matthias.schiffer@xxxxxxxxxxxxxxx> wrote:
> > 
> > The num-cs property is not considered useful, and no in-tree Device
> > Trees define it for spi-imx.
> > 
> > The default value to be used when no cs-gpios are defined is set to
> > 4 to
> > give access to all native CS pins of modern i.MX SoCs (i.MX6 and
> > newer).
> > 
> > In older SoCs, the number of CS pins varies (for example the i.MX27
> > has 3
> > CS pins on CSPI1 and CSPI2, and only a single CS on CSPI3).
> > Attempting
> > to use the nonexisting CS pin would be an easy to notice DT
> > misconfiguration; making the driver catch this doesn't seem
> > worthwhile.
> > 
> > Signed-off-by: Matthias Schiffer <matthias.schiffer@xxxxxxxxxxxxxxx
> > >
> > ---
> >  drivers/spi/spi-imx.c | 13 +------------
> >  1 file changed, 1 insertion(+), 12 deletions(-)
> > 
> > diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
> > index 197f60632072..aece8482739b 100644
> > --- a/drivers/spi/spi-imx.c
> > +++ b/drivers/spi/spi-imx.c
> > @@ -1581,7 +1581,6 @@ static int spi_imx_probe(struct
> > platform_device *pdev)
> >         const struct spi_imx_devtype_data *devtype_data = of_id ?
> > of_id->data :
> >                 (struct spi_imx_devtype_data *)pdev->id_entry-
> > >driver_data;
> >         bool slave_mode;
> > -       u32 val;
> > 
> >         slave_mode = devtype_data->has_slavemode &&
> >                         of_property_read_bool(np, "spi-slave");
> > @@ -1605,6 +1604,7 @@ static int spi_imx_probe(struct
> > platform_device *pdev)
> >         master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
> >         master->bus_num = np ? -1 : pdev->id;
> >         master->use_gpio_descriptors = true;
> > +       master->num_chipselect = 4;
> 
> On an imx6q-sabresd, which only has one SPI chip-select via GPIO,
> this
> makes the SPI core to understand that it has 4 chip selects.
> 
> From spi_get_gpio_descs() in drivers/spi/spi.c:
> 
> ctlr->num_chipselect = max_t(int, nb, ctlr->num_chipselect);
> 
> It is 4 now after your patch, it was 3 after 8cdcd8aeee28 ("spi:
> imx/fsl-lpspi: Convert to GPIO descriptors") and 1 before such
> commit.
> 
> Couldn't we just remove master->num_chipselect from the spi-imx.c
> driver?

This would make num_chipselect default to 1 again (set by
__spi_alloc_controller()), breaking every i.MX board that uses more
than 1 native CS.

I'm aware that using cs-gpios instead of native CS is probably a good
idea in any case, as the native CS of this SPI controller is kinda
flaky (and at a glance it looks like all in-tree DTs do this; not sure
about board files that don't use DTs?), but I'm not convinced that
breaking native CS support completely is desirable either.




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux