Re: [PATCH RFC] gpiolib: Take MUX usage into account

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

 



Hi Linus,

Am 14.01.19 um 14:30 schrieb Linus Walleij:
> On Sun, Jan 13, 2019 at 10:22 PM Stefan Wahren <stefan.wahren@xxxxxxxx> wrote:
>
>> as proposed in a recent discussion [1], this is a hack to improve gpioinfo.
>> I think this could a start point for a discussion.
> I like the idea.
>
>> +bool pinmux_is_in_use(struct pinctrl_dev *pctldev, unsigned pin)
>> +{
>> +       struct pin_desc *desc = pin_desc_get(pctldev, pin);
>> +
>> +       if (!desc) {
>> +               dev_err(pctldev->dev,
>> +                       "pin %u is not registered so it cannot be requested\n",
>> +                       pin);
>> +               return false;
>> +       }
>> +
>> +       if (desc->mux_usecount)
>> +               return true;
>> +
>> +       return !!desc->gpio_owner;
>> +}
> This needs to be augmented to respect the .strict attribute of the
> pin.

sure

>
> Only if the pin controller is strict can you assume that it's
> use by something else than GPIO blocks the GPIO
> usecase. Further explanations to this are detailed in
> Documentation/driver-api/pinctl.rst section
> "GPIO mode pitfalls".
>
> Since BCM2835 which IIRC is your target does not set
> .strict to true, you might first have to look into and solve that.

According to the BCM2835 datasheet (GPIO Function Select Registers
GPFSELn on p.92) a pin can be configured as

0 = input
1 = output
2 = alternative function 5 (UART, PWM, ...)
3 = alternative function 4 (SPI, JTAG)
...

so it's not possible to have GPIO and a alternative function at the same
time. So in case bcm2835_pmx_gpio_set_direction is called the original
function get lost. From this i conclude strict should set to true.

BUT i must check that this doesn't break any BCM283x board.

Does this make sense to you?

Best regards
Stefan

[1] -
https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

>
> Yours,
> Linus Walleij




[Index of Archives]     [Linux SPI]     [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