Linux-Devicetree Archive on lore.kernel.org
 help / color / Atom feed
* [RFC PATCH 0/2] Add SW_MACHINE_COVER key
@ 2020-02-14 13:02 Merlijn Wajer
  2020-02-14 13:02 ` [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER` Merlijn Wajer
  2020-02-14 13:02 ` [RFC PATCH 2/2] ARM: dts: n900: remove mmc1 card detect gpio Merlijn Wajer
  0 siblings, 2 replies; 9+ messages in thread
From: Merlijn Wajer @ 2020-02-14 13:02 UTC (permalink / raw)
  To: merlijn
  Cc: Benoît Cousson, Tony Lindgren, Rob Herring, Mark Rutland,
	Dmitry Torokhov, Mattias Jacobsson, Darren Hart (VMware),
	linux-omap, devicetree, linux-kernel, linux-input

This series adds the SW_MACHINE_COVER key, and changes the Nokia N900 dts to
expose the key via gpio-keys.

Before, this gpio was used as card detect GPIO, causing the card not to show up
if the phone was booted without cover, see this thread on linux-omap:

    N900: Remove mmc1 "safety feature"? (was: Re: mmc0 on Nokia N900 on Linux 5.4.18)

Since there is no realistic use for using this gpio as card detect, instead
expose it to userspace via gpio-keys. There are no event type for machine covers
yet, so add that first.

The key should be 1 when the cover is closed, and 0 when the cover is open.

Starting the Nokia N900 with the cover removed, putting the cover in place:

    Event: time 1581684523.415296, type 5 (EV_SW), code 16 (?), value 1

Removing the cover again, exposing mmc1 and the battery:

    Event: time 1581684529.413706, type 5 (EV_SW), code 16 (?), value 0

Merlijn Wajer (2):
  Input: add `SW_MACHINE_COVER`
  ARM: dts: n900: remove mmc1 card detect gpio

 arch/arm/boot/dts/omap3-n900.dts       | 12 ++++++++----
 include/linux/mod_devicetable.h        |  2 +-
 include/uapi/linux/input-event-codes.h |  3 ++-
 3 files changed, 11 insertions(+), 6 deletions(-)

-- 
2.23.0


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

* [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER`
  2020-02-14 13:02 [RFC PATCH 0/2] Add SW_MACHINE_COVER key Merlijn Wajer
@ 2020-02-14 13:02 ` Merlijn Wajer
  2020-02-14 14:38   ` Sebastian Reichel
  2020-02-14 19:16   ` Ladislav Michl
  2020-02-14 13:02 ` [RFC PATCH 2/2] ARM: dts: n900: remove mmc1 card detect gpio Merlijn Wajer
  1 sibling, 2 replies; 9+ messages in thread
From: Merlijn Wajer @ 2020-02-14 13:02 UTC (permalink / raw)
  To: merlijn
  Cc: Benoît Cousson, Tony Lindgren, Rob Herring, Mark Rutland,
	Dmitry Torokhov, Mattias Jacobsson, Darren Hart (VMware),
	linux-omap, devicetree, linux-kernel, linux-input

This event code represents the state of a removable cover of a device.
Value 1 means that the cover is open or removed, value 0 means that the
cover is closed.

This can be used to preempt users removing a removable mmc card or even
the battery, allowing userspace to attempt to safely unmount a card.
---
 include/linux/mod_devicetable.h        | 2 +-
 include/uapi/linux/input-event-codes.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 448621c32e4d..4c692cb3cc1d 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -299,7 +299,7 @@ struct pcmcia_device_id {
 #define INPUT_DEVICE_ID_LED_MAX		0x0f
 #define INPUT_DEVICE_ID_SND_MAX		0x07
 #define INPUT_DEVICE_ID_FF_MAX		0x7f
-#define INPUT_DEVICE_ID_SW_MAX		0x0f
+#define INPUT_DEVICE_ID_SW_MAX		0x10
 #define INPUT_DEVICE_ID_PROP_MAX	0x1f
 
 #define INPUT_DEVICE_ID_MATCH_BUS	1
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index 64cee116928e..318a6387cdfb 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -807,7 +807,8 @@
 #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
 #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
 #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
-#define SW_MAX			0x0f
+#define SW_MACHINE_COVER	 0x10 /* set = cover closed */
+#define SW_MAX			0x10
 #define SW_CNT			(SW_MAX+1)
 
 /*
-- 
2.23.0


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

* [RFC PATCH 2/2] ARM: dts: n900: remove mmc1 card detect gpio
  2020-02-14 13:02 [RFC PATCH 0/2] Add SW_MACHINE_COVER key Merlijn Wajer
  2020-02-14 13:02 ` [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER` Merlijn Wajer
@ 2020-02-14 13:02 ` Merlijn Wajer
  2020-02-14 14:49   ` Sebastian Reichel
  1 sibling, 1 reply; 9+ messages in thread
From: Merlijn Wajer @ 2020-02-14 13:02 UTC (permalink / raw)
  To: merlijn
  Cc: Benoît Cousson, Tony Lindgren, Rob Herring, Mark Rutland,
	Dmitry Torokhov, Mattias Jacobsson, Darren Hart (VMware),
	linux-omap, devicetree, linux-kernel, linux-input

Instead, expose the key via the input framework, as SW_MACHINE_COVER
---
 arch/arm/boot/dts/omap3-n900.dts | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 7028a7cb2849..ed773e1609a5 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -108,6 +108,14 @@
 			linux,code = <SW_FRONT_PROXIMITY>;
 			linux,can-disable;
 		};
+
+		machine_cover {
+			label = "Machine Cover";
+			gpios = <&gpio6 0 GPIO_ACTIVE_LOW>; /* 160 */
+			linux,input-type = <EV_SW>;
+			linux,code = <SW_MACHINE_COVER>;
+			linux,can-disable;
+		};
 	};
 
 	isp1707: isp1707 {
@@ -805,10 +813,6 @@
 	pinctrl-0 = <&mmc1_pins>;
 	vmmc-supply = <&vmmc1>;
 	bus-width = <4>;
-	/* For debugging, it is often good idea to remove this GPIO.
-	   It means you can remove back cover (to reboot by removing
-	   battery) and still use the MMC card. */
-	cd-gpios = <&gpio6 0 GPIO_ACTIVE_LOW>; /* 160 */
 };
 
 /* most boards use vaux3, only some old versions use vmmc2 instead */
-- 
2.23.0


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

* Re: [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER`
  2020-02-14 13:02 ` [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER` Merlijn Wajer
@ 2020-02-14 14:38   ` Sebastian Reichel
  2020-02-15  9:09     ` Merlijn Wajer
  2020-02-14 19:16   ` Ladislav Michl
  1 sibling, 1 reply; 9+ messages in thread
From: Sebastian Reichel @ 2020-02-14 14:38 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: Benoît Cousson, Tony Lindgren, Rob Herring, Mark Rutland,
	Dmitry Torokhov, Mattias Jacobsson, Darren Hart (VMware),
	linux-omap, devicetree, linux-kernel, linux-input

[-- Attachment #1: Type: text/plain, Size: 2193 bytes --]

Hi,

On Fri, Feb 14, 2020 at 02:02:47PM +0100, Merlijn Wajer wrote:
> This event code represents the state of a removable cover of a device.
> Value 1 means that the cover is open or removed, value 0 means that the
> cover is closed.

This is the opposit of what is being stated everywhere else. It does
not really matter, but it must be used consistently :)

> This can be used to preempt users removing a removable mmc card or even
> the battery, allowing userspace to attempt to safely unmount a card.

I would drop this sentence, since its very specific to the N900. The
name is generic enough to e.g. also apply for desktop machines, which
sometimes have a cover switch for doing a shutdown (because of poor
airflow when open).

> ---

Missing Signed-off-by. 

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  include/linux/mod_devicetable.h        | 2 +-
>  include/uapi/linux/input-event-codes.h | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 448621c32e4d..4c692cb3cc1d 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -299,7 +299,7 @@ struct pcmcia_device_id {
>  #define INPUT_DEVICE_ID_LED_MAX		0x0f
>  #define INPUT_DEVICE_ID_SND_MAX		0x07
>  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> +#define INPUT_DEVICE_ID_SW_MAX		0x10
>  #define INPUT_DEVICE_ID_PROP_MAX	0x1f
>  
>  #define INPUT_DEVICE_ID_MATCH_BUS	1
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 64cee116928e..318a6387cdfb 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -807,7 +807,8 @@
>  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
>  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
>  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> -#define SW_MAX			0x0f
> +#define SW_MACHINE_COVER	 0x10 /* set = cover closed */
> +#define SW_MAX			0x10
>  #define SW_CNT			(SW_MAX+1)
>  
>  /*
> -- 
> 2.23.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [RFC PATCH 2/2] ARM: dts: n900: remove mmc1 card detect gpio
  2020-02-14 13:02 ` [RFC PATCH 2/2] ARM: dts: n900: remove mmc1 card detect gpio Merlijn Wajer
@ 2020-02-14 14:49   ` Sebastian Reichel
  2020-02-15  9:13     ` Merlijn Wajer
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Reichel @ 2020-02-14 14:49 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: Benoît Cousson, Tony Lindgren, Rob Herring, Mark Rutland,
	Dmitry Torokhov, Mattias Jacobsson, Darren Hart (VMware),
	linux-omap, devicetree, linux-kernel, linux-input

[-- Attachment #1: Type: text/plain, Size: 1911 bytes --]

Hi,

On Fri, Feb 14, 2020 at 02:02:48PM +0100, Merlijn Wajer wrote:
> Instead, expose the key via the input framework, as SW_MACHINE_COVER

How about:

The chip-detect GPIO is actually detecting if the cover is closed.
Technically it's possible to use the SD card with open cover. The
only downside is risk of battery falling out and user being able
to physically remove the card.

The behaviour of SD card not being available when the device is
open is unexpected and creates more problems than it solves. There
is a high chance, that more people accidently break their rootfs
by opening the case without physically removing the card.

> ---

Missing SoB.

Patch itself is

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  arch/arm/boot/dts/omap3-n900.dts | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
> index 7028a7cb2849..ed773e1609a5 100644
> --- a/arch/arm/boot/dts/omap3-n900.dts
> +++ b/arch/arm/boot/dts/omap3-n900.dts
> @@ -108,6 +108,14 @@
>  			linux,code = <SW_FRONT_PROXIMITY>;
>  			linux,can-disable;
>  		};
> +
> +		machine_cover {
> +			label = "Machine Cover";
> +			gpios = <&gpio6 0 GPIO_ACTIVE_LOW>; /* 160 */
> +			linux,input-type = <EV_SW>;
> +			linux,code = <SW_MACHINE_COVER>;
> +			linux,can-disable;
> +		};
>  	};
>  
>  	isp1707: isp1707 {
> @@ -805,10 +813,6 @@
>  	pinctrl-0 = <&mmc1_pins>;
>  	vmmc-supply = <&vmmc1>;
>  	bus-width = <4>;
> -	/* For debugging, it is often good idea to remove this GPIO.
> -	   It means you can remove back cover (to reboot by removing
> -	   battery) and still use the MMC card. */
> -	cd-gpios = <&gpio6 0 GPIO_ACTIVE_LOW>; /* 160 */
>  };
>  
>  /* most boards use vaux3, only some old versions use vmmc2 instead */
> -- 
> 2.23.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER`
  2020-02-14 13:02 ` [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER` Merlijn Wajer
  2020-02-14 14:38   ` Sebastian Reichel
@ 2020-02-14 19:16   ` Ladislav Michl
  2020-02-15  9:03     ` Merlijn Wajer
  1 sibling, 1 reply; 9+ messages in thread
From: Ladislav Michl @ 2020-02-14 19:16 UTC (permalink / raw)
  To: Merlijn Wajer
  Cc: Benoît Cousson, Tony Lindgren, Rob Herring, Mark Rutland,
	Dmitry Torokhov, Mattias Jacobsson, Darren Hart (VMware),
	linux-omap, devicetree, linux-kernel, linux-input

Hi Merlijn,

On Fri, Feb 14, 2020 at 02:02:47PM +0100, Merlijn Wajer wrote:
> This event code represents the state of a removable cover of a device.
> Value 1 means that the cover is open or removed, value 0 means that the
> cover is closed.
> 
> This can be used to preempt users removing a removable mmc card or even
> the battery, allowing userspace to attempt to safely unmount a card.
> ---
>  include/linux/mod_devicetable.h        | 2 +-
>  include/uapi/linux/input-event-codes.h | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 448621c32e4d..4c692cb3cc1d 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -299,7 +299,7 @@ struct pcmcia_device_id {
>  #define INPUT_DEVICE_ID_LED_MAX		0x0f
>  #define INPUT_DEVICE_ID_SND_MAX		0x07
>  #define INPUT_DEVICE_ID_FF_MAX		0x7f
> -#define INPUT_DEVICE_ID_SW_MAX		0x0f
> +#define INPUT_DEVICE_ID_SW_MAX		0x10
>  #define INPUT_DEVICE_ID_PROP_MAX	0x1f
>  
>  #define INPUT_DEVICE_ID_MATCH_BUS	1
> diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
> index 64cee116928e..318a6387cdfb 100644
> --- a/include/uapi/linux/input-event-codes.h
> +++ b/include/uapi/linux/input-event-codes.h
> @@ -807,7 +807,8 @@
>  #define SW_LINEIN_INSERT	0x0d  /* set = inserted */
>  #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
>  #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
> -#define SW_MAX			0x0f
> +#define SW_MACHINE_COVER	 0x10 /* set = cover closed */

There is an extra space above ^

> +#define SW_MAX			0x10
>  #define SW_CNT			(SW_MAX+1)
>  
>  /*
> -- 
> 2.23.0

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

* Re: [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER`
  2020-02-14 19:16   ` Ladislav Michl
@ 2020-02-15  9:03     ` Merlijn Wajer
  0 siblings, 0 replies; 9+ messages in thread
From: Merlijn Wajer @ 2020-02-15  9:03 UTC (permalink / raw)
  To: Ladislav Michl
  Cc: Benoît Cousson, Tony Lindgren, Rob Herring, Mark Rutland,
	Dmitry Torokhov, Mattias Jacobsson, Darren Hart (VMware),
	linux-omap, devicetree, linux-kernel, linux-input

[-- Attachment #1.1: Type: text/plain, Size: 222 bytes --]

Hi Ladislav,

On 14/02/2020 20:16, Ladislav Michl wrote:
> Hi Merlijn,
> 
>> +#define SW_MACHINE_COVER	 0x10 /* set = cover closed */
> 
> There is an extra space above ^

Thanks, will fix.

Cheers,
Merlijn


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER`
  2020-02-14 14:38   ` Sebastian Reichel
@ 2020-02-15  9:09     ` Merlijn Wajer
  0 siblings, 0 replies; 9+ messages in thread
From: Merlijn Wajer @ 2020-02-15  9:09 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Benoît Cousson, Tony Lindgren, Rob Herring, Mark Rutland,
	Dmitry Torokhov, Mattias Jacobsson, Darren Hart (VMware),
	linux-omap, devicetree, linux-kernel, linux-input

[-- Attachment #1.1: Type: text/plain, Size: 1085 bytes --]

Hi Sebastian,

On 14/02/2020 15:38, Sebastian Reichel wrote:
> Hi,
> 
> On Fri, Feb 14, 2020 at 02:02:47PM +0100, Merlijn Wajer wrote:
>> This event code represents the state of a removable cover of a device.
>> Value 1 means that the cover is open or removed, value 0 means that the
>> cover is closed.
> 
> This is the opposit of what is being stated everywhere else. It does
> not really matter, but it must be used consistently :)

Oh, my bad. Indeed, value 1 means that the cover is closed, will fix.

>> This can be used to preempt users removing a removable mmc card or even
>> the battery, allowing userspace to attempt to safely unmount a card.
> 
> I would drop this sentence, since its very specific to the N900. The
> name is generic enough to e.g. also apply for desktop machines, which
> sometimes have a cover switch for doing a shutdown (because of poor
> airflow when open).

Fair enough.

>> ---
> 
> Missing Signed-off-by. 

Will add - thanks.

> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

Cheers,
Merlijn


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [RFC PATCH 2/2] ARM: dts: n900: remove mmc1 card detect gpio
  2020-02-14 14:49   ` Sebastian Reichel
@ 2020-02-15  9:13     ` Merlijn Wajer
  0 siblings, 0 replies; 9+ messages in thread
From: Merlijn Wajer @ 2020-02-15  9:13 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Benoît Cousson, Tony Lindgren, Rob Herring, Mark Rutland,
	Dmitry Torokhov, Mattias Jacobsson, Darren Hart (VMware),
	linux-omap, devicetree, linux-kernel, linux-input

[-- Attachment #1.1: Type: text/plain, Size: 910 bytes --]

Hi,

On 14/02/2020 15:49, Sebastian Reichel wrote:
> Hi,
> 
> On Fri, Feb 14, 2020 at 02:02:48PM +0100, Merlijn Wajer wrote:
>> Instead, expose the key via the input framework, as SW_MACHINE_COVER
> 
> How about:
> 
> The chip-detect GPIO is actually detecting if the cover is closed.
> Technically it's possible to use the SD card with open cover. The
> only downside is risk of battery falling out and user being able
> to physically remove the card.
> 
> The behaviour of SD card not being available when the device is
> open is unexpected and creates more problems than it solves. There
> is a high chance, that more people accidently break their rootfs
> by opening the case without physically removing the card.

Sounds good.

> Missing SoB.

Will add.

> Patch itself is
> 
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

Thanks.

Cheers,
Merlijn


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 13:02 [RFC PATCH 0/2] Add SW_MACHINE_COVER key Merlijn Wajer
2020-02-14 13:02 ` [RFC PATCH 1/2] Input: add `SW_MACHINE_COVER` Merlijn Wajer
2020-02-14 14:38   ` Sebastian Reichel
2020-02-15  9:09     ` Merlijn Wajer
2020-02-14 19:16   ` Ladislav Michl
2020-02-15  9:03     ` Merlijn Wajer
2020-02-14 13:02 ` [RFC PATCH 2/2] ARM: dts: n900: remove mmc1 card detect gpio Merlijn Wajer
2020-02-14 14:49   ` Sebastian Reichel
2020-02-15  9:13     ` Merlijn Wajer

Linux-Devicetree Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-devicetree/0 linux-devicetree/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-devicetree linux-devicetree/ https://lore.kernel.org/linux-devicetree \
		devicetree@vger.kernel.org
	public-inbox-index linux-devicetree

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-devicetree


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git