Browse Source

Move the key expander and gpio-keys to radio-keyboard-tca

k4be 2 weeks ago
parent
commit
ca5e029a61
3 changed files with 22 additions and 133 deletions
  1. 8 24
      README.md
  2. 7 59
      dts/examples/orangepi-zero-i2c1.dtsi
  3. 7 50
      dts/radio-panel.dts

+ 8 - 24
README.md

@@ -23,7 +23,7 @@ same core from userspace, over i2c-dev or through this driver.
 | `driver/Kbuild` | Out-of-tree build |
 | `sim/` | Model of the TCA9539 and S1D13700 interface, with fault counters |
 | `tests/test_panel.c` | Core tests against the simulator |
-| `dts/radio-panel.dts` | Overlay: panel, key expander, `gpio-keys` |
+| `dts/radio-panel.dts` | Overlay: the panel |
 | `dts/examples/orangepi-zero-i2c1.dtsi` | The same for a board DT, as used on the Orange Pi Zero |
 | `docs/s1d13700-recommendations.md` | Review of the core and driver, applied |
 
@@ -119,35 +119,19 @@ cost roughly 2.5-3× more bus time per LCD byte).
 
 The pin assignment is fixed in `s1d13700_core.h`.
 
-**U2, TCA9539 at 0x76** (A1=H, A0=L), optional, for keys: stock
-`gpio-pca953x` plus `gpio-keys`, as in the device tree examples. Keys are
-active high, each pin with an external pull-down (the TCA9539 has none) and
-its key to the supply. `INT` (open drain, active low) goes to a host GPIO;
-without it, use `gpio-keys-polled`.
-
-| Pin | Key | Pin | Key |
-|---|---|---|---|
-| P0.0-2 | unused (pull-down) | P1.0 | Esc |
-| P0.3 | Next | P1.1 | OK |
-| P0.4 | Left | P1.2 | Menu |
-| P0.5 | Down | P1.3 | List |
-| P0.6 | Up | P1.4 | Stop |
-| P0.7 | Right | P1.5 | Pause |
-| | | P1.6 | Play |
-| | | P1.7 | Prev |
+The keys on the same bus (U2, a second TCA9539 at 0x76, with stock
+`gpio-pca953x` and `gpio-keys`) are in the sibling repository
+[radio-keyboard-tca](../radio-keyboard-tca): wiring, key map and device tree.
 
 ## Device tree
 
 `dts/radio-panel.dts` is an overlay written with plain numbers instead of
-`#include`, so it also works with `armbian-add-overlay`. It targets `i2c0`
-and puts U2's INT on PA6; check both against the board. For the i2c-dev
-userspace path, remove its `panel@74` node; with keys polled over i2c-dev,
-do not load the U2 node either.
+`#include`, so it also works with `armbian-add-overlay`. It targets `i2c0`;
+check that against the board. For the i2c-dev userspace path, do not load it.
 
 `dts/examples/orangepi-zero-i2c1.dtsi` is the version in use on the Orange Pi
-Zero, for inclusion in a board DTS: i2c1 at 400 kHz, panel, U2 with INT on
-PA6 and the `radio-keys` input device. The two key tables must stay the
-same; the OPi0 build compares the overlay's with its board DTB.
+Zero, for inclusion in a board DTS: i2c1 at 400 kHz and the panel. The keys'
+overlay and board fragment are in radio-keyboard-tca.
 
 ## How it works
 

+ 7 - 59
dts/examples/orangepi-zero-i2c1.dtsi

@@ -1,26 +1,21 @@
 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
 /*
- * Example for a board device tree (not an overlay): the panel (U1, 0x74),
- * the key expander (U2, 0x76) and the 13 keys on i2c1 of an Orange Pi Zero
- * (Allwinner H2+). Running on real hardware, built into the board DTB.
+ * Example for a board device tree (not an overlay): the panel (U1, 0x74) on
+ * i2c1 of an Orange Pi Zero (Allwinner H2+). Running on real hardware, built
+ * into the board DTB.
  *
  * Include it after the mainline board file, e.g.
  *
  *	#include "sun8i-h2-plus-orangepi-zero.dts"
  *	#include "orangepi-zero-i2c1.dtsi"
  *
- * For another board: change the bus (&i2c1, its pinctrl) and the INT pin
- * (PA6 here, in &pio and in the interrupts of gpio@76). Without INT wired,
- * drop the interrupt properties and use "gpio-keys-polled" with
- * poll-interval = <20> instead of "gpio-keys".
+ * For another board: change the bus (&i2c1, its pinctrl).
  *
- * The key table matches dts/radio-panel.dts. Keep the two the same.
+ * The keys (U2, 0x76) on the same bus are in the radio-keyboard-tca
+ * repository, dts/examples/orangepi-zero-i2c1-keys.dtsi, to be included
+ * after this file.
  */
 
-#include <dt-bindings/gpio/gpio.h>
-#include <dt-bindings/input/input.h>
-#include <dt-bindings/interrupt-controller/irq.h>
-
 / {
 	aliases {
 		i2c1 = &i2c1;	/* keep /dev/i2c-1 */
@@ -42,52 +37,5 @@
 		compatible = "k4be,s1d13700-tca9539";
 		reg = <0x74>;
 	};
-
-	/* U2: A1=H, A0=L. INT is open drain, active low, on PA6. */
-	radio_u2: gpio@76 {
-		compatible = "ti,tca9539";
-		reg = <0x76>;
-		pinctrl-names = "default";
-		pinctrl-0 = <&radio_u2_int_pin>;
-		gpio-controller;
-		#gpio-cells = <2>;
-		interrupt-controller;
-		#interrupt-cells = <2>;
-		interrupt-parent = <&pio>;
-		interrupts = <0 6 IRQ_TYPE_LEVEL_LOW>;	/* PA6 */
-	};
-};
-
-&pio {
-	radio_u2_int_pin: radio-u2-int-pin {
-		pins = "PA6";
-		function = "irq";
-		bias-pull-up;
-	};
 };
 
-/ {
-	/*
-	 * Keys are active high: one pin each to the supply, with an external
-	 * pull-down. Pins 0-7 are P0.0-7, 8-15 are P1.0-7; P0.0-2 unused.
-	 */
-	radio-keys {
-		compatible = "gpio-keys";
-		label = "radio-keys";
-		autorepeat;
-
-		key-next  { label = "next";  gpios = <&radio_u2 3 GPIO_ACTIVE_HIGH>;  linux,code = <KEY_NEXTSONG>;     debounce-interval = <20>; };
-		key-left  { label = "left";  gpios = <&radio_u2 4 GPIO_ACTIVE_HIGH>;  linux,code = <KEY_LEFT>;         debounce-interval = <20>; };
-		key-down  { label = "down";  gpios = <&radio_u2 5 GPIO_ACTIVE_HIGH>;  linux,code = <KEY_DOWN>;         debounce-interval = <20>; };
-		key-up    { label = "up";    gpios = <&radio_u2 6 GPIO_ACTIVE_HIGH>;  linux,code = <KEY_UP>;           debounce-interval = <20>; };
-		key-right { label = "right"; gpios = <&radio_u2 7 GPIO_ACTIVE_HIGH>;  linux,code = <KEY_RIGHT>;        debounce-interval = <20>; };
-		key-esc   { label = "esc";   gpios = <&radio_u2 8 GPIO_ACTIVE_HIGH>;  linux,code = <KEY_ESC>;          debounce-interval = <20>; };
-		key-ok    { label = "ok";    gpios = <&radio_u2 9 GPIO_ACTIVE_HIGH>;  linux,code = <KEY_OK>;           debounce-interval = <20>; };
-		key-menu  { label = "menu";  gpios = <&radio_u2 10 GPIO_ACTIVE_HIGH>; linux,code = <KEY_MENU>;         debounce-interval = <20>; };
-		key-list  { label = "list";  gpios = <&radio_u2 11 GPIO_ACTIVE_HIGH>; linux,code = <KEY_LIST>;         debounce-interval = <20>; };
-		key-stop  { label = "stop";  gpios = <&radio_u2 12 GPIO_ACTIVE_HIGH>; linux,code = <KEY_STOPCD>;       debounce-interval = <20>; };
-		key-pause { label = "pause"; gpios = <&radio_u2 13 GPIO_ACTIVE_HIGH>; linux,code = <KEY_PAUSECD>;      debounce-interval = <20>; };
-		key-play  { label = "play";  gpios = <&radio_u2 14 GPIO_ACTIVE_HIGH>; linux,code = <KEY_PLAYCD>;       debounce-interval = <20>; };
-		key-prev  { label = "prev";  gpios = <&radio_u2 15 GPIO_ACTIVE_HIGH>; linux,code = <KEY_PREVIOUSSONG>; debounce-interval = <20>; };
-	};
-};

+ 7 - 50
dts/radio-panel.dts

@@ -1,19 +1,18 @@
 /*
- * Device tree overlay for the radio front panel on an Allwinner board.
+ * Device tree overlay for the radio front panel LCD on an Allwinner board.
  *
  * Plain numbers instead of #include, so it also works with armbian-add-overlay.
  *
- * TO CHECK against the actual board before use:
- *   - root compatible, and the i2c bus in fragment@0 (i2c0)
- *   - the U2 INT line: placeholder PA6 (<0 6 ...> = bank A, pin 6). Without
- *     INT (the USB test board), gpio-keys cannot work: use compatible
- *     "gpio-keys-polled" with poll-interval = <20>, or `radio-ui i2c`, which
- *     polls U2 itself and must then not have this overlay loaded.
+ * TO CHECK against the actual board before use: root compatible, and the
+ * i2c bus in fragment@0 (i2c0).
  *
  * U1 (0x74) is left to the s1d13700-tca driver and must not bind to pca953x;
  * it also drives the backlight (P1.0), which the driver registers as
  * radio-backlight.
- * For the i2c-dev frontend, remove the panel@74 node.
+ * For the i2c-dev frontend, do not load this overlay.
+ *
+ * The keys (U2, 0x76, and gpio-keys) are in the radio-keyboard-tca
+ * repository, dts/radio-keys.dts.
  */
 /dts-v1/;
 /plugin/;
@@ -34,48 +33,6 @@
 				compatible = "k4be,s1d13700-tca9539";
 				reg = <0x74>;
 			};
-
-			radio_u2: gpio@76 {
-				compatible = "ti,tca9539";
-				reg = <0x76>;
-				gpio-controller;
-				#gpio-cells = <2>;
-				interrupt-controller;
-				#interrupt-cells = <2>;
-				interrupt-parent = <&pio>;
-				interrupts = <0 6 8>;	/* PA6, level low: PLACEHOLDER */
-			};
-		};
-	};
-
-	fragment@1 {
-		target-path = "/";
-
-		__overlay__ {
-			/*
-			 * Keys are active high and read directly: one pin each to
-			 * the supply, with an external pull-down. Pins 0-7 are
-			 * P0.0-7, pins 8-15 are P1.0-7; P0.0-P0.2 are unused. Flag
-			 * 0 = GPIO_ACTIVE_HIGH. Same table as radio/keypad.py.
-			 */
-			radio-keys {
-				compatible = "gpio-keys";
-				autorepeat;
-
-				next	{ label = "next";  gpios = <&radio_u2 3 0>;  linux,code = <163>; debounce-interval = <20>; };
-				left	{ label = "left";  gpios = <&radio_u2 4 0>;  linux,code = <105>; debounce-interval = <20>; };
-				down	{ label = "down";  gpios = <&radio_u2 5 0>;  linux,code = <108>; debounce-interval = <20>; };
-				up	{ label = "up";    gpios = <&radio_u2 6 0>;  linux,code = <103>; debounce-interval = <20>; };
-				right	{ label = "right"; gpios = <&radio_u2 7 0>;  linux,code = <106>; debounce-interval = <20>; };
-				esc	{ label = "esc";   gpios = <&radio_u2 8 0>;  linux,code = <1>;   debounce-interval = <20>; };
-				ok	{ label = "ok";    gpios = <&radio_u2 9 0>;  linux,code = <352>; debounce-interval = <20>; };
-				menu	{ label = "menu";  gpios = <&radio_u2 10 0>; linux,code = <139>; debounce-interval = <20>; };
-				list	{ label = "list";  gpios = <&radio_u2 11 0>; linux,code = <395>; debounce-interval = <20>; };
-				stop	{ label = "stop";  gpios = <&radio_u2 12 0>; linux,code = <166>; debounce-interval = <20>; };
-				pause	{ label = "pause"; gpios = <&radio_u2 13 0>; linux,code = <201>; debounce-interval = <20>; };
-				play	{ label = "play";  gpios = <&radio_u2 14 0>; linux,code = <200>; debounce-interval = <20>; };
-				prev	{ label = "prev";  gpios = <&radio_u2 15 0>; linux,code = <165>; debounce-interval = <20>; };
-			};
 		};
 	};
 };