pinctrl states vs pinmux vs gpio (i2c bus recovery)

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

 



Hi Linus,

There seems to be a problem in pinctrl land when pinctrls interact with
GPIOs.

If, for example, an I2C driver wants to attempt bus recovery, and needs
to use GPIO mode to control the I2C bus pins to do this, then one may
expect code such as found in i2c_imx_init_recovery_info() to work.

However, consider that devm_gpiod_get() may invoke
pinctrl_gpio_request(), which changes the pinmux settings independently
of the pinctrl layer.

The result is that after devm_gpiod_get() has completed, the I2C bus
pins are in GPIO mode.

One may expect:

	pinctrl_select_state(i2c_imx->pinctrl, i2c_imx->pinctrl_pins_default);

to change them back to the default state, but that would be incorrect.
The first thing that pinctrl_select_state() does is check whether

	p->state == state

which it will do, as the pinctrl layer hasn't been informed of the
change that has happened behind its back at the pinmux level.

The result is, one needs to switch the state to gpio mode, and then
back to default to ensure that the pins are muxed back to the I2C
controller while the I2C controller is supposed to be operational.

GPIO mode is only used to recover the bus when a bus hang has happened
due to a slave device holding SDA low - and the only way that can be
recovered is by toggling the SCL signal. If the controller provides no
means to do this other than switching to GPIO mode, the above is
necessary.

I spotted this while trying out this method of i2c bus recovery on a
different I2C controller.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up



[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