mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robin van der Gracht <robin@protonic.nl>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: Marco Felsch <m.felsch@pengutronix.de>,
	Sascha Hauer <sha@pengutronix.de>,
	Oleksij Rempel <linux@rempel-privat.de>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	barebox@lists.infradead.org, david@protonic.nl
Subject: Re: [PATCH 1/9] ARM: boards: protonic-imx6: prtvt7 hardkey inputs are active low
Date: Mon, 20 Jun 2022 10:16:44 +0200	[thread overview]
Message-ID: <57ffd31813f339c84242f90226e36361@protonic.nl> (raw)
In-Reply-To: <ead464cf-803f-5795-4269-7ff4d15cf9ed@pengutronix.de>

Hi Ahmand,

On 2022-06-20 09:51, Ahmad Fatoum wrote:
> Hello,
> 
> On 17.06.22 10:44, Marco Felsch wrote:
>> On 22-06-17, Sascha Hauer wrote:
>>>> Or, it is active low and your patch is correct :D
>>> 
>>> If they are, can we add a comment or _N suffix to the names?
>> 
>> Does barebox not have gpiod? The board code just should check if it is
>> active or not. Whatever active means in this case.
> 
> There is gpiod_get(), but there's also gpio-keys support. See
> drivers/input/specialkeys.c for an example on how to register an input
> notifier.

I dont think I can use gpiod_get() due to the device tree format for
gpio-keys. I didn't know about the input_notifier framework. I'll check
if I can get it to work with that as-well.


> Robin, did you test this works with barebox v2022.05.0?
> I'd have assumed this to be broken by f349b662674e ("gpio: allocate dynamic
> gpio numbers top down"). Especially, with deep probe, you can't and 
> shouldn't
> depend on GPIO expanders numbering being fixed. If you use an input 
> notifier,
> you should sidestep this issue altogether.

I just notiched that as well. I was just making some changes including the
feadback from this thread:

diff --git a/arch/arm/boards/protonic-imx6/board.c 
b/arch/arm/boards/protonic-imx6/board.c
index cdbb8debe6..374ec11364 100644
--- a/arch/arm/boards/protonic-imx6/board.c
+++ b/arch/arm/boards/protonic-imx6/board.c
@@ -635,17 +635,24 @@ static int prt_imx6_init_kvg_yaco(struct prt_imx6_priv 
*priv)
         return prt_imx6_init_kvg_power(priv, PW_MODE_KVG_WITH_YACO);
  }

-#define GPIO_KEY_F6     (0xe0 + 5)
-#define GPIO_KEY_CYCLE  (0xe0 + 2)
-
  static int prt_imx6_init_prtvt7(struct prt_imx6_priv *priv)
  {
-       /* This function relies heavely on the gpio-pca9539 driver */
+       int gpio_f6, gpio_cycle;
+       struct device_d *gpio_expander;
+
+       gpio_expander = get_device_by_name("pca95390");
+       if (!gpio_expander) {
+               dev_err(priv->dev, "Can't find pca9539 gpio expander\n");
+               return -ENODEV;
+       }
+
+       gpio_cycle = gpio_get_num(gpio_expander, 2);
+       gpio_request_one(gpio_cycle, GPIOF_ACTIVE_LOW | GPIOF_DIR_IN, 
"Cycle");

-       gpio_direction_input(GPIO_KEY_F6);
-       gpio_direction_input(GPIO_KEY_CYCLE);
+       gpio_f6 = gpio_get_num(gpio_expander, 5);
+       gpio_request_one(gpio_f6, GPIOF_ACTIVE_LOW | GPIOF_DIR_IN, "F6");

-       if (gpio_get_value(GPIO_KEY_CYCLE) && gpio_get_value(GPIO_KEY_F6))
+       if (!(gpio_is_active(gpio_cycle) && gpio_is_active(gpio_f6)))
                 priv->no_usb_check = 1;

         return 0;

I'll make a proposal with the input_notifier aswell.

- Robin



  reply	other threads:[~2022-06-20  8:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16 13:11 [PATCH 0/9] ARM: boards: protonic-imx6: Updates Robin van der Gracht
2022-06-16 13:11 ` [PATCH 1/9] ARM: boards: protonic-imx6: prtvt7 hardkey inputs are active low Robin van der Gracht
2022-06-16 16:28   ` Oleksij Rempel
2022-06-16 16:38     ` Oleksij Rempel
2022-06-17  6:57       ` Sascha Hauer
2022-06-17  8:44         ` Marco Felsch
2022-06-20  7:51           ` Ahmad Fatoum
2022-06-20  8:16             ` Robin van der Gracht [this message]
2022-06-20 15:42             ` Robin van der Gracht
2022-06-20  6:48       ` Robin van der Gracht
2022-06-20  7:23         ` Oleksij Rempel
2022-06-16 13:11 ` [PATCH 2/9] ARM: boards: protonic-imx6: Update comment to match a recent code update Robin van der Gracht
2022-06-17  7:00   ` Sascha Hauer
2022-06-20  6:40     ` Robin van der Gracht
2022-06-16 13:11 ` [PATCH 3/9] ARM: boards: protonic-imx6: Free allocated autoboot_timeout string Robin van der Gracht
2022-06-16 13:11 ` [PATCH 4/9] ARM: boards: protonic-imx6: Always free allocated alias string Robin van der Gracht
2022-06-16 13:11 ` [PATCH 5/9] ARM: boards: protonic-imx6: Remove unsused argument from prt_imx6_usb_mount Robin van der Gracht
2022-06-16 13:11 ` [PATCH 6/9] ARM: boards: protonic-imx6: Register prt-usb boot entry Robin van der Gracht
2022-06-16 13:11 ` [PATCH 7/9] ARM: boards: protonic-imx6: Remove usb_delay from the priv struct Robin van der Gracht
2022-06-16 13:11 ` [PATCH 8/9] ARM: boards: protonic-imx6: Read serial and mac from fuses if available Robin van der Gracht
2022-06-16 13:11 ` [PATCH 9/9] ARM: boards: protonic-imx6: Register serial_number parameter with ocotp Robin van der Gracht
2022-06-17  7:10 ` (subset) [PATCH 0/9] ARM: boards: protonic-imx6: Updates Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57ffd31813f339c84242f90226e36361@protonic.nl \
    --to=robin@protonic.nl \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=david@protonic.nl \
    --cc=linux@rempel-privat.de \
    --cc=m.felsch@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=sha@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox