gpio-omap: handle bias flag for gpio line
diff mbox series

Message ID 20200625002736.GA24954@x1
State New
Headers show
Series
  • gpio-omap: handle bias flag for gpio line
Related show

Commit Message

Drew Fustini June 25, 2020, 12:27 a.m. UTC
Tony and Linus -

I'm hoping you could give me some feedback on this approach. My goal is
to allow a userspace library (like libgpiod) to be able to set pull-up
and pull-downs on the AM3358.

I've changed gpio-omap.c so omap_gpio_set_config() will call
omap_gpio_bias() when the parameter is one of the PIN_CONFIG_BIAS_xxx
flags. That function will call gpiochip_generic_config() and the rest
proceeds normally without further changes.

However, this does require the following:
1) patch to fix return code in pcs_parse_pinconf() [0]
2) patch to add the gpio-ranges mappings [1]
2) change the compatible for the am33xx_pinmux node to "pinconf-single"
4) add "pinctrl-single,bias-pulldown" or "pinctrl-single,bias-pullup"
   property to a pin node.

I found the binding documentation [2] for the bias properties to be very
confusing as to how those 4 values work:

> - pinctrl-single,bias-pullup : array of value that are used to configure the
>   input bias pullup in the pinmux register.
>
> 		/* input, enabled pullup bits, disabled pullup bits, mask */
> 		pinctrl-single,bias-pullup = <0 1 0 1>;
> 
> - pinctrl-single,bias-pulldown : array of value that are used to configure the
>   input bias pulldown in the pinmux register.

>		/* input, enabled pulldown bits, disabled pulldown bits, mask */
>		pinctrl-single,bias-pulldown = <2 2 0 2>;

For AM3358, the pin conf register has the format [3]:

bit	attribute      value
  6	slew           { 0: fast, 1: slow }
  5     rx_active      { 0: rx disable, 1: rx enabled }
  4     pu_typesel     { 0: pulldown select, 1: pullup select }
  3     puden          { 0: pud enable, 1: disabled }
  2     mode           3 bits to selec mode 0 to 7
  1     mode
  0     mode

I figured out the values for bias-pull{up,down} properties based on:

        16      8       4       2       1
        2^4     2^3     2^2     2^1     2^0
mask    1       1       0       0       0       24
pull-up 1       1       0       0       0       24
pull-dn 0       1       0       0       0       8
none    0       0       0       0       0       0

Thus the properties are:

	pinctrl-single,bias-pulldown = < 8  8 0 24>;
	pinctrl-single,bias-pullup   = <24 24 0 24>;

For an example, I added "pinctrl-single,bias-pulldown" to the node
pinmux-ehrpwm1-pins in am335x-pocketbeagle.dts:

ehrpwm1_pins: pinmux-ehrpwm1-pins {
	pinctrl-single,pins = <
		AM33XX_PADCONF(AM335X_PIN_GPMC_A2, PIN_OUTPUT_PULLDOWN, MUX_MODE6)
		/* (U14) gpmc_a2.ehrpwm1A */
	>;
	pinctrl-single,bias-pulldown = <8 8 0 24>;
}

AM335X_PIN_GPMC_A2 is PIN18 based on the memory offset and corresponds
to gpiochip 1 line 18 (MUX_MODE1).

Here is function graph trace (note: I used -fno-inline) when gpiomon
runs with pull-down bias flag on gpiochip 1 line 18:

debian@beaglebone:~$ ./libgpiod/tools/gpiomon -B pull-down 1 18

 0)               |  gpio_ioctl() { 
 0)   2.708 us    |    gpiochip_get_desc();
 0)               |    gpiod_request() {
 0)               |      gpiod_request_commit() {
 0)   2.834 us    |        gpiochip_line_is_valid();
 0)               |        omap_gpio_request() {
 0)   2.708 us    |          omap_enable_gpio_module();
 0) + 15.375 us   |        }
 0)               |        gpiod_get_direction() {
 0)   2.500 us    |          gpiod_to_chip();
 0)   3.459 us    |          omap_gpio_get_direction();
 0) + 16.125 us   |        }
 0) + 52.875 us   |      }
 0) + 60.750 us   |    }
 0)               |    gpiod_direction_input() {
 0)               |      omap_gpio_input() {
 0)   2.500 us    |        omap_set_gpio_direction();
 0)   8.125 us    |      }
 0)               |      gpio_set_bias() {
 0)               |        gpio_set_config() {
 0)               |          gpio_do_set_config() {
 0)               |            omap_gpio_set_config() {
 0)               |              omap_gpio_bias() {
 0)               |                gpiochip_generic_config() {
 0)               |                  pinctrl_gpio_set_config() {
 0)               |                    pinctrl_get_device_gpio_range() {
 0)   3.292 us    |                      pinctrl_match_gpio_range();
 0)   8.667 us    |                    }
 0)               |                    pinconf_set_config() {
 0)               |                      pcs_pinconf_set() {
 0)   5.250 us    |                        pcs_get_function();
 0)   3.417 us    |                        pcs_readl();
 0)               |                        pcs_pinconf_clear_bias() {
 0)               |                          pcs_pinconf_set() {
 0)   3.125 us    |                            pcs_get_function();
 0)   2.833 us    |                            pcs_readl();
 0)   3.792 us    |                            pcs_writel();
 0) + 20.958 us   |                          }
 0)               |                          pcs_pinconf_set() {
 0)   2.750 us    |                            pcs_get_function();
 0)   8.083 us    |                          }
 0) + 37.333 us   |                        }
 0)   2.708 us    |                        pcs_writel();
 0) + 65.916 us   |                      }
 0) + 71.375 us   |                    }
 0) + 89.083 us   |                  }
 0) + 95.292 us   |                }
 0) ! 100.750 us  |              }
 0) ! 106.667 us  |            }
 0) ! 111.791 us  |          }
 0) ! 117.167 us  |        }
 0) ! 122.917 us  |      }
 0)   2.750 us    |      desc_to_gpio();
 0) ! 146.459 us  |    }

Thus, all it seems I can do is set a bias flag on a gpio line if the
corresponding bias property is already set for that pin in dts.  This
does not accomplish anything.

The ideal capability in my mind would be for pinctrl-single to
understand that a pin defined by a "pinctrl-single,pins" property has
both a configuration value and a mux mode value.  The current pinconf
support is based on "pinctrl-single,bias-pull{up,down}" which does not
seem useful.

I would appreciate any feedback.

Thanks,
Drew

[0] https://lore.kernel.org/linux-omap/20200608125143.GA2789203@x1/
[1] https://lore.kernel.org/linux-omap/20200602131428.GA496390@x1/
[2] Documentation/devicetree/bindings/pinctrl/pinctrl-single.txt
[3] https://www.ti.com/lit/ug/spruh73q/spruh73q.pdf (see Figure 9-51)
---
 arch/arm/boot/dts/am335x-pocketbeagle.dts |  2 ++
 arch/arm/boot/dts/am33xx-l4.dtsi          |  2 +-
 drivers/gpio/Makefile                     |  2 +-
 drivers/gpio/gpio-omap.c                  | 37 ++++++++++++++++++++---
 drivers/pinctrl/Makefile                  |  2 +-
 5 files changed, 38 insertions(+), 7 deletions(-)

Comments

Linus Walleij July 7, 2020, 12:38 p.m. UTC | #1
On Thu, Jun 25, 2020 at 2:27 AM Drew Fustini <drew@beagleboard.org> wrote:

> Tony and Linus -
>
> I'm hoping you could give me some feedback on this approach. My goal is
> to allow a userspace library (like libgpiod) to be able to set pull-up
> and pull-downs on the AM3358.

I'm lost on any pinctrl-single specifics, sorry... Generic questions about
pinctrl I can maybe answer.

Yours,
Linus Walleij
Drew Fustini July 12, 2020, 9:56 p.m. UTC | #2
On Tue, Jul 07, 2020 at 02:38:36PM +0200, Linus Walleij wrote:
> On Thu, Jun 25, 2020 at 2:27 AM Drew Fustini <drew@beagleboard.org> wrote:
> 
> > Tony and Linus -
> >
> > I'm hoping you could give me some feedback on this approach. My goal is
> > to allow a userspace library (like libgpiod) to be able to set pull-up
> > and pull-downs on the AM3358.
> 
> I'm lost on any pinctrl-single specifics, sorry... Generic questions about
> pinctrl I can maybe answer.
> 
> Yours,
> Linus Walleij

I now have a way to set bias with libgpiod on the AM3358 (BeagleBone
and PocketBeagle) with these two patches:

[PATCH] gpio: omap: handle pin config bias flags [0]
------------------------------------------------
Modify omap_gpio_set_config() to handle pin config bias flags by calling
gpiochip_generic_config().

The pin group for the gpio line must have the corresponding pinconf
properties:

PIN_CONFIG_BIAS_PULL_UP requires "pinctrl-single,bias-pullup"
PIN_CONFIG_BIAS_PULL_DOWN requires "pinctrl-single,bias-pulldown

This means the ability to set bias from userspace is controlled from
device tree. If there is concern about potiental damage caused by
userspace setting bias to an unsafe value then those pins should not
have the bias property in the dts.


[PATCH] ARM: dts: am335x-pocketbeagle: set default mux for gpio pins [1]
--------------------------------------------------------------------
These pins on the PocketBeagle P1 and P2 headers are connected to AM3358
balls with gpio lines, and these pins are not used for any other
peripherals by default.  This patch adds "pinctrl-single,bias-pullup"
and "pinctrl-single,bias-pulldown" pinconf properties for each pin per
the ball reset state in the datasheet.

Here is an example for P2.03 header pin on the PocketBeagle:

        /* P2_03 (ZCZ ball T10) gpio0_23 0x824 PIN 9 */
        P2_03_gpio: pinmux_P2_03_gpio {
                pinctrl-single,pins = <
                        AM33XX_PADCONF(AM335X_PIN_GPMC_AD9, PIN_INPUT_PULLUP, MUX_MODE7)
                >;
                pinctrl-single,bias-pullup   =   < 0x10  0x10  0x00  0x18>;
                pinctrl-single,bias-pulldown   = < 0x10  0x00  0x10  0x18>;
        };

P2.03 header pin on PocketBeagle maps to gpiochip 0 line 23. It is PIN9
which value on boot: 0x37 (input [0x20] pull-up [0x10] gpio mode [0x7])

$ cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins |grep ^'pin 9' |head -1
pin 9 (PIN9) 44e10824 00000037 pinctrl-single

$ gpiomon -B pull-down 0 23
^C

Value 0x27 means it switched to pull-down [0x0] but still input [0x20]
and gpio mode [0x7]:

$ cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins |grep ^'pin 9' |head -1
pin 9 (PIN9) 44e10824 00000027 pinctrl-single

Now switch it back to pull-up:

$ gpiomon -B pull-up 0 23
^C

Value 0x37 means it switched to pull-up [0x10] and is still input [0x20]
and gpio mode [0x7]:

$ cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins |grep ^'pin 9' |head -1
pin 9 (PIN9) 44e10824 00000037 pinctrl-single


Question: does this seem like a reasonable solution?

Thanks,
Drew

[0] https://lore.kernel.org/linux-omap/20200712103717.1219765-1-drew@beagleboard.org/
[1] https://lore.kernel.org/linux-omap/20200709223401.780051-1-drew@beagleboard.org/
Tony Lindgren July 13, 2020, 3:02 p.m. UTC | #3
Hi,

* Drew Fustini <drew@beagleboard.org> [200712 21:56]:
> P2.03 header pin on PocketBeagle maps to gpiochip 0 line 23. It is PIN9
> which value on boot: 0x37 (input [0x20] pull-up [0x10] gpio mode [0x7])
> 
> $ cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins |grep ^'pin 9' |head -1
> pin 9 (PIN9) 44e10824 00000037 pinctrl-single
> 
> $ gpiomon -B pull-down 0 23

Nice it's getting quite close to a user usable feature :)

I think we really should have an easy way to use the dts configured
GPIO line names here though. Can we make the dts configured GPIO
line name show up in the pinctrl output directly?

This would allow grepping for the device specific GPIO line name
directly in from the debugfs "pins" output.

But Ideally this should be done with the gpio sysfs interface though
somehow rather than rely on pinctrl debugfs. The debugfs interface
should be optional, and can change.

Regards,

Tony
Drew Fustini July 13, 2020, 5:47 p.m. UTC | #4
On Mon, Jul 13, 2020 at 08:02:20AM -0700, Tony Lindgren wrote:
> Hi,
> 
> * Drew Fustini <drew@beagleboard.org> [200712 21:56]:
> > P2.03 header pin on PocketBeagle maps to gpiochip 0 line 23. It is PIN9
> > which value on boot: 0x37 (input [0x20] pull-up [0x10] gpio mode [0x7])
> > 
> > $ cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins |grep ^'pin 9' |head -1
> > pin 9 (PIN9) 44e10824 00000037 pinctrl-single
> > 
> > $ gpiomon -B pull-down 0 23
> 
> Nice it's getting quite close to a user usable feature :)
> 
> I think we really should have an easy way to use the dts configured
> GPIO line names here though. Can we make the dts configured GPIO
> line name show up in the pinctrl output directly?
> 
> This would allow grepping for the device specific GPIO line name
> directly in from the debugfs "pins" output.
> 
> But Ideally this should be done with the gpio sysfs interface though
> somehow rather than rely on pinctrl debugfs. The debugfs interface
> should be optional, and can change.
> 
> Regards,
> 
> Tony

There is gpio-ranges for pinctrl-single in debugfs:

debian@beaglebone:~$ sudo more /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/gpio-ranges
GPIO ranges handled:
0: gpio-0-31 GPIOS [0 - 7] PINS [82 - 89]
8: gpio-0-31 GPIOS [8 - 11] PINS [52 - 55]
12: gpio-0-31 GPIOS [12 - 15] PINS [94 - 97]
16: gpio-0-31 GPIOS [16 - 17] PINS [71 - 72]
18: gpio-0-31 GPIOS [18 - 18] PINS [135 - 135]
19: gpio-0-31 GPIOS [19 - 20] PINS [108 - 109]
21: gpio-0-31 GPIOS [21 - 21] PINS [73 - 73]
22: gpio-0-31 GPIOS [22 - 23] PINS [8 - 9]
26: gpio-0-31 GPIOS [26 - 27] PINS [10 - 11]
28: gpio-0-31 GPIOS [28 - 28] PINS [74 - 74]
29: gpio-0-31 GPIOS [29 - 29] PINS [81 - 81]
30: gpio-0-31 GPIOS [30 - 31] PINS [28 - 29]
0: gpio-32-63 GPIOS [32 - 39] PINS [0 - 7]
8: gpio-32-63 GPIOS [40 - 43] PINS [90 - 93]
12: gpio-32-63 GPIOS [44 - 59] PINS [12 - 27]
28: gpio-32-63 GPIOS [60 - 63] PINS [30 - 33]
0: gpio-64-95 GPIOS [64 - 81] PINS [34 - 51]
18: gpio-64-95 GPIOS [82 - 85] PINS [77 - 80]
22: gpio-64-95 GPIOS [86 - 95] PINS [56 - 65]
0: gpio-96-127 GPIOS [96 - 100] PINS [66 - 70]
5: gpio-96-127 GPIOS [101 - 102] PINS [98 - 99]
7: gpio-96-127 GPIOS [103 - 104] PINS [75 - 76]
13: gpio-96-127 GPIOS [109 - 109] PINS [141 - 141]
14: gpio-96-127 GPIOS [110 - 117] PINS [100 - 107]

Do you mean you would like to see the mapping added as a column in the pins file?

debian@beaglebone:~$ sudo cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins  |head
registered pins: 142
pin 0 (PIN0) 44e10800 00000027 pinctrl-single
pin 1 (PIN1) 44e10804 00000027 pinctrl-single
pin 2 (PIN2) 44e10808 00000027 pinctrl-single
pin 3 (PIN3) 44e1080c 00000027 pinctrl-single
pin 4 (PIN4) 44e10810 00000027 pinctrl-single
pin 5 (PIN5) 44e10814 00000027 pinctrl-single
pin 6 (PIN6) 44e10818 00000027 pinctrl-single
pin 7 (PIN7) 44e1081c 00000027 pinctrl-single
pin 8 (PIN8) 44e10820 00000027 pinctrl-single

So that could be:

debian@beaglebone:~$ sudo cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins  |head
registered pins: 142
pin 0 (PIN0) 44e10800 00000027 pinctrl-single GPIO-32
pin 1 (PIN1) 44e10804 00000027 pinctrl-single GPIO-33
pin 2 (PIN2) 44e10808 00000027 pinctrl-single GPIO-34
pin 3 (PIN3) 44e1080c 00000027 pinctrl-single GPIO-35
pin 4 (PIN4) 44e10810 00000027 pinctrl-single GPIO-36
pin 5 (PIN5) 44e10814 00000027 pinctrl-single GPIO-37
pin 6 (PIN6) 44e10818 00000027 pinctrl-single GPIO-38
pin 7 (PIN7) 44e1081c 00000027 pinctrl-single GPIO-39
pin 8 (PIN8) 44e10820 00000027 pinctrl-single GPIO-22

Should I try to add that in pcs_pin_dbg_show()?

It currently prints:

        seq_printf(s, "%zx %08x %s ", pa, val, DRIVER_NAME);

so I could change that to include the GPIO number if mapping exists.


thanks,
drew
Tony Lindgren July 13, 2020, 6:05 p.m. UTC | #5
* Drew Fustini <drew@beagleboard.org> [200713 17:47]:
> Do you mean you would like to see the mapping added as a column in the pins file?
> 
> debian@beaglebone:~$ sudo cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins  |head
> registered pins: 142
> pin 0 (PIN0) 44e10800 00000027 pinctrl-single
> pin 1 (PIN1) 44e10804 00000027 pinctrl-single
> pin 2 (PIN2) 44e10808 00000027 pinctrl-single
> pin 3 (PIN3) 44e1080c 00000027 pinctrl-single
> pin 4 (PIN4) 44e10810 00000027 pinctrl-single
> pin 5 (PIN5) 44e10814 00000027 pinctrl-single
> pin 6 (PIN6) 44e10818 00000027 pinctrl-single
> pin 7 (PIN7) 44e1081c 00000027 pinctrl-single
> pin 8 (PIN8) 44e10820 00000027 pinctrl-single
> 
> So that could be:
> 
> debian@beaglebone:~$ sudo cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins  |head
> registered pins: 142
> pin 0 (PIN0) 44e10800 00000027 pinctrl-single GPIO-32
> pin 1 (PIN1) 44e10804 00000027 pinctrl-single GPIO-33
> pin 2 (PIN2) 44e10808 00000027 pinctrl-single GPIO-34
> pin 3 (PIN3) 44e1080c 00000027 pinctrl-single GPIO-35
> pin 4 (PIN4) 44e10810 00000027 pinctrl-single GPIO-36
> pin 5 (PIN5) 44e10814 00000027 pinctrl-single GPIO-37
> pin 6 (PIN6) 44e10818 00000027 pinctrl-single GPIO-38
> pin 7 (PIN7) 44e1081c 00000027 pinctrl-single GPIO-39
> pin 8 (PIN8) 44e10820 00000027 pinctrl-single GPIO-22

Yes that would make the debugfs output more understandable and
easier to use.

> Should I try to add that in pcs_pin_dbg_show()?
> 
> It currently prints:
> 
>         seq_printf(s, "%zx %08x %s ", pa, val, DRIVER_NAME);
> 
> so I could change that to include the GPIO number if mapping exists.

Sounds good to me yeah :) However, the issue of relying on
debugfs for this still remains unsolved. But seems that
probably should be done with the existing GPIO related
API instead and a different issue from the pinctrl
changes.

Regards,

Tony
Drew Fustini July 17, 2020, 1:42 a.m. UTC | #6
On Mon, Jul 13, 2020 at 11:05:19AM -0700, Tony Lindgren wrote:
> * Drew Fustini <drew@beagleboard.org> [200713 17:47]:
> > Do you mean you would like to see the mapping added as a column in the pins file?
> > 
> > debian@beaglebone:~$ sudo cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins  |head
> > registered pins: 142
> > pin 0 (PIN0) 44e10800 00000027 pinctrl-single
> > pin 1 (PIN1) 44e10804 00000027 pinctrl-single
> > pin 2 (PIN2) 44e10808 00000027 pinctrl-single
> > pin 3 (PIN3) 44e1080c 00000027 pinctrl-single
> > pin 4 (PIN4) 44e10810 00000027 pinctrl-single
> > pin 5 (PIN5) 44e10814 00000027 pinctrl-single
> > pin 6 (PIN6) 44e10818 00000027 pinctrl-single
> > pin 7 (PIN7) 44e1081c 00000027 pinctrl-single
> > pin 8 (PIN8) 44e10820 00000027 pinctrl-single
> > 
> > So that could be:
> > 
> > debian@beaglebone:~$ sudo cat /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/pins  |head
> > registered pins: 142
> > pin 0 (PIN0) 44e10800 00000027 pinctrl-single GPIO-32
> > pin 1 (PIN1) 44e10804 00000027 pinctrl-single GPIO-33
> > pin 2 (PIN2) 44e10808 00000027 pinctrl-single GPIO-34
> > pin 3 (PIN3) 44e1080c 00000027 pinctrl-single GPIO-35
> > pin 4 (PIN4) 44e10810 00000027 pinctrl-single GPIO-36
> > pin 5 (PIN5) 44e10814 00000027 pinctrl-single GPIO-37
> > pin 6 (PIN6) 44e10818 00000027 pinctrl-single GPIO-38
> > pin 7 (PIN7) 44e1081c 00000027 pinctrl-single GPIO-39
> > pin 8 (PIN8) 44e10820 00000027 pinctrl-single GPIO-22
> 
> Yes that would make the debugfs output more understandable and
> easier to use.

I have posted a patch [0] to add the GPIO-xx column to the pins file.

Thanks,
Drew

[0] https://lore.kernel.org/linux-gpio/20200717013338.1741659-1-drew@beagleboard.org/

Patch
diff mbox series

diff --git a/arch/arm/boot/dts/am335x-pocketbeagle.dts b/arch/arm/boot/dts/am335x-pocketbeagle.dts
index 22d52516b7fc..f6de2028ba53 100644
--- a/arch/arm/boot/dts/am335x-pocketbeagle.dts
+++ b/arch/arm/boot/dts/am335x-pocketbeagle.dts
@@ -221,6 +221,8 @@  ehrpwm1_pins: pinmux-ehrpwm1-pins {
 		pinctrl-single,pins = <
 			AM33XX_PADCONF(AM335X_PIN_GPMC_A2, PIN_OUTPUT_PULLDOWN, MUX_MODE6)	/* (U14) gpmc_a2.ehrpwm1A */
 		>;
+		pinctrl-single,bias-pulldown = <8 8 0 24>;
+		/*pinctrl-single,bias-pullup = <24 24 0 24>;*/
 	};
 
 	mmc0_pins: pinmux-mmc0-pins {
diff --git a/arch/arm/boot/dts/am33xx-l4.dtsi b/arch/arm/boot/dts/am33xx-l4.dtsi
index 903338015a68..cb8a57ed13c1 100644
--- a/arch/arm/boot/dts/am33xx-l4.dtsi
+++ b/arch/arm/boot/dts/am33xx-l4.dtsi
@@ -288,7 +288,7 @@  scm: scm@0 {
 				ranges = <0 0 0x2000>;
 
 				am33xx_pinmux: pinmux@800 {
-					compatible = "pinctrl-single";
+					compatible = "pinconf-single";
 					reg = <0x800 0x238>;
 					#pinctrl-cells = <2>;
 					pinctrl-single,register-width = <32>;
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 1e4894e0bf0f..c55a5c167c43 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: GPL-2.0
 # generic gpio support: platform drivers, dedicated expander chips, etc
 
-ccflags-$(CONFIG_DEBUG_GPIO)	+= -DDEBUG
+ccflags-$(CONFIG_DEBUG_GPIO)	+= -DDEBUG -fno-inline
 
 obj-$(CONFIG_GPIOLIB)		+= gpiolib.o
 obj-$(CONFIG_GPIOLIB)		+= gpiolib-devres.o
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index b8e2ecc3eade..972629d69917 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -871,6 +871,21 @@  static int omap_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask,
 	return 0;
 }
 
+/**
+ * omap_gpio_bias() - apply configuration for a pin
+ * @gc: the gpiochip owning the GPIO
+ * @offset: the offset of the GPIO to apply the configuration
+ * @config: the configuration to be applied
+ */
+static int omap_gpio_bias(struct gpio_chip *gc, unsigned offset, unsigned long config)
+{
+	int ret = 0;
+
+	ret = gpiochip_generic_config(gc, offset, config);
+	return ret;
+}
+
+
 static int omap_gpio_debounce(struct gpio_chip *chip, unsigned offset,
 			      unsigned debounce)
 {
@@ -896,12 +911,26 @@  static int omap_gpio_set_config(struct gpio_chip *chip, unsigned offset,
 				unsigned long config)
 {
 	u32 debounce;
+	u32 config_arg;
+	int ret;
 
-	if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE)
-		return -ENOTSUPP;
+	if ((pinconf_to_config_param(config) == PIN_CONFIG_BIAS_DISABLE) ||
+	    (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_UP) ||
+	    (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_DOWN))
+	{
+		ret = omap_gpio_bias(chip, offset, config);
+	}
+	else if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE)
+	{
+		debounce = pinconf_to_config_argument(config);
+		ret = omap_gpio_debounce(chip, offset, debounce);
+	}
+	else
+	{
+		ret = -ENOTSUPP;
+	}
 
-	debounce = pinconf_to_config_argument(config);
-	return omap_gpio_debounce(chip, offset, debounce);
+	return ret;
 }
 
 static void omap_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 1731b2154df9..fc62c20702c6 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -1,7 +1,7 @@ 
 # SPDX-License-Identifier: GPL-2.0
 # generic pinmux support
 
-subdir-ccflags-$(CONFIG_DEBUG_PINCTRL)	+= -DDEBUG
+subdir-ccflags-$(CONFIG_DEBUG_PINCTRL)	+= -DDEBUG -fno-inline
 
 obj-y				+= core.o pinctrl-utils.o
 obj-$(CONFIG_PINMUX)		+= pinmux.o