refactor(ext_power): Remove label property

Changed the label property on zmk,ext-power-generic to be optional and
removed it from existing uses. Renamed the nodes for all non-development
boards to "EXT_POWER" to preserve user settings.

rgb_underglow.c now finds the correct device by finding the first
instance of zmk,ext-power-generic instead of looking for a node named
"EXT_POWER".
This commit is contained in:
Joel Spadin 2023-09-05 17:52:18 -05:00
parent 179bdbc41a
commit 05925c72d7
17 changed files with 34 additions and 36 deletions

View file

@ -29,9 +29,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
init-delay-ms = <20>;
control-gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
};

View file

@ -66,9 +66,9 @@
;
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
};

View file

@ -28,9 +28,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>; /* WS2812_CE */
init-delay-ms = <100>;
};

View file

@ -29,9 +29,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>; /* WS2812_CE */
init-delay-ms = <100>;
};

View file

@ -29,9 +29,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
init-delay-ms = <50>;
};

View file

@ -78,9 +78,9 @@ RC(4,0) RC(4,1) RC(4,2) RC(4,5) R
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
};

View file

@ -12,9 +12,9 @@
zmk,battery = &vbatt;
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
};

View file

@ -12,9 +12,9 @@
zmk,battery = &vbatt;
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
init-delay-ms = <50>;
};

View file

@ -28,9 +28,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
};
};

View file

@ -28,9 +28,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
};
};

View file

@ -29,9 +29,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
};

View file

@ -29,9 +29,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
};

View file

@ -30,9 +30,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
init-delay-ms = <50>;
};

View file

@ -29,9 +29,9 @@
};
};
ext-power {
// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
};

View file

@ -49,15 +49,12 @@ nice_view_spi: &arduino_spi {
// Commented out until we add more powerful power domain support
// external_power {
// compatible = "zmk,ext-power-generic";
// label = "EXT_POWER";
// init-delay-ms = <200>;
// control-gpios = <&arduino_header 1 GPIO_ACTIVE_LOW>;
// };
rgb_power {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
// label = "RGB_POWER";
init-delay-ms = <200>;
control-gpios = <&arduino_header 1 GPIO_ACTIVE_LOW>;
};

View file

@ -14,7 +14,8 @@ properties:
required: true
label:
type: string
required: true
required: false
deprecated: true
init-delay-ms:
type: int
description: Number of milliseconds to delay after initializing driver

View file

@ -67,7 +67,7 @@ static struct led_rgb pixels[STRIP_NUM_PIXELS];
static struct rgb_underglow_state state;
#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
static const struct device *ext_power;
static const struct device *const ext_power = DEVICE_DT_GET(DT_INST(0, zmk_ext_power_generic));
#endif
static struct zmk_led_hsb hsb_scale_min_max(struct zmk_led_hsb hsb) {
@ -243,9 +243,9 @@ static int zmk_rgb_underglow_init(const struct device *_arg) {
led_strip = DEVICE_DT_GET(STRIP_CHOSEN);
#if IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER)
ext_power = device_get_binding("EXT_POWER");
if (ext_power == NULL) {
LOG_ERR("Unable to retrieve ext_power device: EXT_POWER");
if (!device_is_ready(ext_power)) {
LOG_ERR("External power device \"%s\" is not ready", ext_power->name);
return -ENODEV;
}
#endif