apm821xx: detect sd-card media changes for the WNDR4700
authorChristian Lamparter <chunkeey@googlemail.com>
Tue, 30 Aug 2016 17:42:38 +0000 (19:42 +0200)
committerJohn Crispin <john@phrozen.org>
Thu, 8 Sep 2016 11:40:02 +0000 (13:40 +0200)
The insertion or removal of the sd-card cannot be detected
by the hardware itself. This is by design. To workaround this,
for the WNDR4700 unload/load the dwc2 module in case the
the special SD CARD GPIO line is low/high.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
target/linux/apm821xx/base-files/etc/rc.button/BTN_1 [new file with mode: 0755]
target/linux/apm821xx/dts/wndr4700.dts

diff --git a/target/linux/apm821xx/base-files/etc/rc.button/BTN_1 b/target/linux/apm821xx/base-files/etc/rc.button/BTN_1
new file mode 100755 (executable)
index 0000000..9956412
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. /lib/apm821xx.sh
+
+BOARD=$(apm821xx_board_name)
+
+if [ $BOARD == "wndr4700" ]; then
+       case "$ACTION" in
+       released)
+               rmmod dwc2
+       ;;
+       pressed)
+               modprobe dwc2
+       ;;
+       esac
+fi
+
+return 0
index 9a2ceb9d75faaf433d849ea4d50b28837d88be9e..caaf05b3e877c3a3032190920e67c87c056544e9 100644 (file)
 
                                sdcard {
                                        label = "SDCard inserted";
-                                       gpios = <&GPIO0 7 0>;
+                                       gpios = <&GPIO0 7 1>;
                                        linux,code = <0x101>; /* BTN_1 */
                                };
                        };