All of lore.kernel.org
 help / color / mirror / Atom feed
* Properly using gpio_request and muxing
@ 2020-11-11 17:16 Oliver Westermann
  0 siblings, 0 replies; only message in thread
From: Oliver Westermann @ 2020-11-11 17:16 UTC (permalink / raw)
  To: u-boot

Hey,

I'm wondering if there is documentation or a good example on how to
configure pin muxing in combination with the gpio_request functions. Our
current implementation is incomplete as it doesn't handle the muxing, but
before randomly copying code I would like to know what the "upstream" way
of doing things like this is, so maybe someone can advise.

The goal is to define N pins as "revision pins" (basically pull up/down
resistors for board revisions) in the dts and based upon this definition
read the pins and calculate a value. Our current implementation just has a
pin list like this:

board-rev-gpios = <
      &gpio0 1 GPIO_ACTIVE_HIGH
      &gpio0 2 GPIO_ACTIVE_HIGH
      &gpio0 3 GPIO_ACTIVE_HIGH
>;

and uses gpio_request_list_by_name() to access those by name, this works as
long as no muxing is required.

My current understanding of the full solution would be to define not only
the gpios, but also a pinctrl, sth like this:

DTS:
    board_rev {
        pinctrl-names = "gpio";
        pinctrl-0 = <&pinctrl_board_rev>;
        gpios = <
          &gpio0 1 GPIO_ACTIVE_HIGH
          &gpio0 2 GPIO_ACTIVE_HIGH
          &gpio0 3 GPIO_ACTIVE_HIGH
        >;
    };

    pinctrl_board_rev: i2c1grp {
        fsl,pins = <
            MX8MM_IOMUXC_GPIO1_IO00_GPIO1_IO0           0x400001c3
            MX8MM_IOMUXC_GPIO1_IO00_GPIO1_IO2           0x400001c3
            MX8MM_IOMUXC_GPIO1_IO00_GPIO1_IO3           0x400001c3
        >;
    };

Code:
    /* get board_rev node as board_rev, prepare arrays, ... */
    gpio_request_list_by_name(board_rev, "gpios", gpios, ARRAY_SIZE(gpios),
GPIOD_IS_IN);
    pinctrl_select_state(board_rev, "gpio");

Would this be the correct way to use the muxing functionality?

Best regards, Olli

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-11 17:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 17:16 Properly using gpio_request and muxing Oliver Westermann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.