linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pinconf-single: pinctrl-single,bias-pull{up,down} bits help/explanation
@ 2022-10-16 12:14 Marty E. Plummer
  2022-11-01  6:20 ` Haojian Zhuang
  0 siblings, 1 reply; 3+ messages in thread
From: Marty E. Plummer @ 2022-10-16 12:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-gpio, linux-arm-kernel, tony, haojian.zhuang, linus.walleij

Greetings.

Working on setting up a dts for a new soc/board, along with the drivers
associated with it. The soc in question has four pinctrl/pinconf-single
blocks, which, as far as I can tell, use the exact same format for their
bitfields in the registers (could be one or more differ but that would
be an error of reading on my part).

The basic layout is thus, for each 32-bit field in the address space:

[31:11] reserved
[10:10] Level conversion rate control. The value 0 indicates a fast
        level conversion rate. The value 1 indicates a slow level
		conversion rate.
[9:9]	Pull-up resistor enable, active high.
[8:8]	Pull-down resistor enable, active high.
[7:4]   Drive capability.
[3:0]   Function select.

All of the registers are the same for bits [10:8]. Drive capability
given in several 'levels', which can have 4, 8, or 16 different values,
but that's not much of an issue. Given a specific register, iocfg_reg55,
and iocfg_reg56, which handles UART0_RXD and UART0_TXD, drive capability
values of 0-3 correspond to IO drive capablity IO_LEVEL1-4, respectively.
Their respective function select bits are:
0: GPIO5_4
1: UART0_RXD

and

0: GPIO5_5
1: UART0_TXD

Given a desire to mux this to uart0, I'd use the following dts/header snippet:

// header include/dt-bindings/pinctrl/hisi.h

/* iomg bit definition */
#define MUX_M0		0
#define MUX_M1		1
#define MUX_M2		2
#define MUX_M3		3
#define MUX_M4		4
#define MUX_M5		5
#define MUX_M6		6
#define MUX_M7		7

--- snip ---

// my additions
/* drive strength definition for hi3516dv300 */
#define IO_LEVEL_MASK	(15 << 4)
#define IO2_LEVEL1		(0 << 4)
#define IO2_LEVEL2		(1 << 4)
#define IO2_LEVEL3		(2 << 4)
#define IO2_LEVEL4		(3 << 4)

--- snip ---

// hi3516dv300-pinctrl.dtsi snippet
	pmx1: pinmux@111f0000 {
		compatible = "pinconf-single";
		reg = <0x111f0000 0x34>;
		#address-cells = <1>;
		#size-cells = <1>;
		#pinctrl-cells = <1>;
		#gpio-range-cells = <3>;
		ranges;

		pinctrl-single,register-width = <32>;
		pinctrl-single,function-mask = <7>;

		uart0_cfg_func: uart0_cfg_func {
			pinctrl-single,pins = <
				0x0010 MUX_M1 /* U21 UART0_RXD (iocfg_reg55)*/
				0x0014 MUX_M1 /* T20 UART0_TXD (iocfg_reg56)*/
			>;
			pinctrl-single,drive-strength = <
				IO2_LEVEL4 IO_LEVEL_MASK
			>;
		};
	};

All in all pretty simple.
What I'm having issue with is the pinctrl-single,bias-pull values. From
commit abe4e4675dfc62b7f2328e2c4bce8b5bdcdff7c0 I get a bit of it, and I
think I have it mostly figured out:

// <[input] [enabled] [disabled] [mask]>;
pinctrl-single,bias-pullup = <? 1 0 0x100>;
pinctrl-single,bias-pulldown = <? 1 0 0x200>;

using mask 0x100 to single out bit 8 and mask 0x200 to single out bit 9,
enable values being simple binary on/off. What I don't get is how the
input value is determined/calculated.

Aside from the above mentioned commit for the am335x-pocketbeagle.dts,
which uses a differing pullup control scheme, the only users I can find
in the tree are a handful of hisi socs which I don't have a datasheet
for to map their usage to register definitions and puzzle this out.

Hope someone can point out what I'm missing. I guarantee it'll be quite
obvious once it is but for the moment I'm stumped.

Regards,
Marty

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pinconf-single: pinctrl-single,bias-pull{up,down} bits help/explanation
  2022-10-16 12:14 pinconf-single: pinctrl-single,bias-pull{up,down} bits help/explanation Marty E. Plummer
@ 2022-11-01  6:20 ` Haojian Zhuang
  2022-11-01  6:39   ` Haojian Zhuang
  0 siblings, 1 reply; 3+ messages in thread
From: Haojian Zhuang @ 2022-11-01  6:20 UTC (permalink / raw)
  To: Marty E. Plummer
  Cc: linux-kernel, linux-gpio, linux-arm-kernel, tony, linus.walleij

On Sun, 16 Oct 2022 at 20:14, Marty E. Plummer <hanetzer@startmail.com> wrote:
>
> Greetings.
>
> What I'm having issue with is the pinctrl-single,bias-pull values. From
> commit abe4e4675dfc62b7f2328e2c4bce8b5bdcdff7c0 I get a bit of it, and I
> think I have it mostly figured out:
>
> // <[input] [enabled] [disabled] [mask]>;
> pinctrl-single,bias-pullup = <? 1 0 0x100>;
> pinctrl-single,bias-pulldown = <? 1 0 0x200>;
>
> using mask 0x100 to single out bit 8 and mask 0x200 to single out bit 9,
> enable values being simple binary on/off. What I don't get is how the
> input value is determined/calculated.
>
> Aside from the above mentioned commit for the am335x-pocketbeagle.dts,
> which uses a differing pullup control scheme, the only users I can find
> in the tree are a handful of hisi socs which I don't have a datasheet
> for to map their usage to register definitions and puzzle this out.
>
Excuse me for just noticing the email.

#define  PULL_DIS     0
#define  PULL_UP        0x100
#define  PULL_DOWN  0x200

// <[input] [enabled] [disabled] [mask]>

// If you want to pull-up, configure the pin as below.
pinctrl-single,bias-pullup = <PULL_UP  PULL_UP  0  PULL_UP>
// If you want to disable pull-up, configure the pin as below.
pinctrl-single,bias-pullup = <0  PULL_UP  0  PULL_UP>

It seems that the pin configuration in am335x-pocketbeagle.dts is wrong.
But I don't have the board to verify it.

And you can check the logic in pcs_pinconf_set().

Best Regards
Haojian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pinconf-single: pinctrl-single,bias-pull{up,down} bits help/explanation
  2022-11-01  6:20 ` Haojian Zhuang
@ 2022-11-01  6:39   ` Haojian Zhuang
  0 siblings, 0 replies; 3+ messages in thread
From: Haojian Zhuang @ 2022-11-01  6:39 UTC (permalink / raw)
  To: Marty E. Plummer
  Cc: linux-kernel, linux-gpio, linux-arm-kernel, tony, linus.walleij

On Tue, 1 Nov 2022 at 14:20, Haojian Zhuang <haojian.zhuang@linaro.org> wrote:
>
> On Sun, 16 Oct 2022 at 20:14, Marty E. Plummer <hanetzer@startmail.com> wrote:
> >
> > Greetings.
> >
> > What I'm having issue with is the pinctrl-single,bias-pull values. From
> > commit abe4e4675dfc62b7f2328e2c4bce8b5bdcdff7c0 I get a bit of it, and I
> > think I have it mostly figured out:
> >
> > // <[input] [enabled] [disabled] [mask]>;
> > pinctrl-single,bias-pullup = <? 1 0 0x100>;
> > pinctrl-single,bias-pulldown = <? 1 0 0x200>;
> >
> > using mask 0x100 to single out bit 8 and mask 0x200 to single out bit 9,
> > enable values being simple binary on/off. What I don't get is how the
> > input value is determined/calculated.
> >
> > Aside from the above mentioned commit for the am335x-pocketbeagle.dts,
> > which uses a differing pullup control scheme, the only users I can find
> > in the tree are a handful of hisi socs which I don't have a datasheet
> > for to map their usage to register definitions and puzzle this out.
> >
> Excuse me for just noticing the email.
>
> #define  PULL_DIS     0
> #define  PULL_UP        0x100
> #define  PULL_DOWN  0x200
>
> // <[input] [enabled] [disabled] [mask]>
>
> // If you want to pull-up, configure the pin as below.
> pinctrl-single,bias-pullup = <PULL_UP  PULL_UP  0  PULL_UP>
> // If you want to disable pull-up, configure the pin as below.
> pinctrl-single,bias-pullup = <0  PULL_UP  0  PULL_UP>
>
> It seems that the pin configuration in am335x-pocketbeagle.dts is wrong.
> But I don't have the board to verify it.
>

Sorry. I didn't check the comments in the commit carefully.

Obviously, the pinctrl definition is totally different in am335x chip.

bit4 is used to select pull-up or pull-down.
bit3 is used to enable the pull-up/pull-down.

In Hisilicon chip, bit9 is used to enable pull-down and bit8 is used
to enable pull-up.

They're totally different. I suggest you to enable the value in DTS
file and dump the register
value  to check for your own silicon.

Best Regards
Haojian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-01  6:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-16 12:14 pinconf-single: pinctrl-single,bias-pull{up,down} bits help/explanation Marty E. Plummer
2022-11-01  6:20 ` Haojian Zhuang
2022-11-01  6:39   ` Haojian Zhuang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).