Skip to contentSkip to conversation

Add SW_MACHINE_COVER key

PATCH In review Merlijn Wajer 3 participants 7 messages Feb 15, 2020 – Jun 9, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Add SW_MACHINE_COVER key

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(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/2 Input: add `SW_MACHINE_COVER`

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

---
 include/linux/mod_devicetable.h        | 2 +-
 include/uapi/linux/input-event-codes.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
include/linux/mod_devicetable.h +1 -1
index 448621c32e4d..4c692cb3cc1d 100644
@@ -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
include/uapi/linux/input-event-codes.h +2 -1
index 64cee116928e..68f8ad8377a1 100644
@@ -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)
 
 /*
Signature · 1 line
2.23.0
#2 lore raw

PATCH 2/2 ARM: dts: n900: remove mmc1 card detect gpio

In reply to Merlijn Wajer

Instead, expose the key via the input framework, as SW_MACHINE_COVER

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.

---
 arch/arm/boot/dts/omap3-n900.dts | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
arch/arm/boot/dts/omap3-n900.dts +8 -4
index 7028a7cb2849..ed773e1609a5 100644
@@ -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 */
Signature · 1 line
2.23.0
Acked-by on the v1 series
#3 lore raw
In reply to Merlijn Wajer
Quoted 2 lines · Merlijn Wajer

this series adds the sw_machine_cover key, and changes the nokia n900 dts to expose the key via gpio-keys.

Looks good to me. It's probably best to apply these via the input subsystem tree because of the generci SW_MACHINE_COVER key addition. For both patches:

#4 lore raw
In reply to Merlijn Wajer

Hi,

Any objections or further comments on these two patches? It's been a while.

Cheers,
Merlijn

Quoted 31 lines · Merlijn Wajer

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(-)
#5 lore raw

Hi,

A while later (again) - any thoughts/comments?

Should I resend the series?

Thanks,
Merlijn

Quoted 41 lines · Merlijn Wajer

Hi,

Any objections or further comments on these two patches? It's been a while.

Cheers,
Merlijn

Quoted 31 lines · Merlijn Wajer

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(-)
#6 lore raw

Hi!

Quoted 3 lines

A while later (again) - any thoughts/comments?

Should I resend the series?

Sorry, I did not see this before. Can you cc me on the next patch iteration?

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html