RE: [PATCH v5 2/2] pinctrl: Add driver for Sunplus SP7021

From: Wells Lu 呂芳騰
Date: Fri Jan 14 2022 - 05:56:07 EST


> ...
>
> > > > > > > > + bool "Sunplus SP7021 PinMux and GPIO driver"
> > > > > > >
> > > > > > > Why bool and not tristate?
> > > > > >
> > > > > > Pinctrl driver is selected by many drivers in SP7021 platform.
> > > > > > We never build it as a module, but build-in to kernel.
> > > > > > So we use "bool".
> > > > > >
> > > > > > Should we set it to tristate?
> > > > >
> > > > > You still haven't answered "why", so I can't tell you.
> > > >
> > > > I am puzzled because I think I have answered "why".
> > >
> > > Nope. :-)
> > >
> > > > Because Pinctrl driver is necessary for all SP7021-based platforms.
> > >
> > > "Why?" Why is it necessary (to be built-in)?
> >
> > Pinctrl is necessary to be built-in because drivers of boot-device,
> > like eMMC, SD card, NAND flash, and NOR flash drivers, need it.
> >
> > SP7021 supports booting from eMMC, SD card, NAND flash and NOR flash
> > devices. Their drivers need Pinctrl driver probes in advance.
>
> On x86 platforms, for example, booting from eMMC and SD card does not require a pin
> control driver to be built-in. Why is this requirement for SP platforms?
>
> --
> With Best Regards,
> Andy Shevchenko

Because all pins of boot-device multiplex with GPIO pins.

SP7021 platforms support multi boot devices, including eMMC, SD card,
SPI-NOR flash, SPI-NAND flash. Each boot device has control-bit(s)
to enable it.

For example #1, if control-bits of SPI-NOR flash is set 1,
GPIO 83, 84, 86, 87 are connected to SPI-NOR flash.
If control-bits of SPI-NOR flash is set 2,
GPIO 76, 78, 79, 81 are connected to SPI-NOR flash.
If control-bits of SPI-NOR flash is set 0, no pin is
connected SPI-NOR flash.

For example #2, if control-bits of eMMC device is set 1,
GPIO 72, 73, 74, 75, 76, 77, 78, 79, 80, 81 are connected to
eMMC device.
If control-bits of eMMC device is set 0, no pin is connected
eMMC device.

For example #3, if control-bits of SDCard device is set 1,
GPIO 65, 66, 67, 68, 69, 70 are connected to SD Card device.
If control-bits of SDCard device is set 0, no pin is connected
SDCard device.

Note that all pins multiplex with GPIO pins.

Normally, only a boot-device is enabled. All other GPIO pins
are released for peripherals (controlled by fully-pinmux
Or group pinmux) or IO processor

Pinctrl driver is responsible for setup the pins.
If Pinctrl fails to probe, boot-device also fails to probe.


Best regards,
Wells Lu