Skip to content

Commit

Permalink
fw: switch to pm runtime, add pm control, i2c changes etc
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiobaltieri committed Oct 13, 2024
1 parent 99ee085 commit c13feea
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 43 deletions.
3 changes: 2 additions & 1 deletion firmware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ target_sources(app PRIVATE

zephyr_linker_sources(ROM_SECTIONS src/event.ld)

target_sources_ifdef(CONFIG_BT app PRIVATE src/ble.c src/ble_status.c src/ble_shell.c)
target_sources_ifdef(CONFIG_BT app PRIVATE src/ble.c src/ble_shell.c)

target_sources_ifdef(CONFIG_APP_BAS_FUEL_GAUGE app PRIVATE src/bas_fuel_gauge.c)
target_sources_ifdef(CONFIG_APP_BAS_FUEL_GAUGE_SENSOR app PRIVATE src/bas_fuel_gauge_sensor.c)
Expand All @@ -34,5 +34,6 @@ target_sources_ifdef(CONFIG_DT_HAS_USB_HID_ENABLED app PRIVATE src/usb_hid.c)
target_sources_ifdef(CONFIG_DT_HAS_BLE_UNPAIR_ENABLED app PRIVATE src/ble_unpair.c)
target_sources_ifdef(CONFIG_DT_HAS_XINPUT_ENABLED app PRIVATE src/xinput.c)
target_sources_ifdef(CONFIG_DT_HAS_TI_DRV8830_ENABLED app PRIVATE src/drv8830.c)
target_sources_ifdef(CONFIG_DT_HAS_PM_CONTROL_ENABLED app PRIVATE src/pm_control.c)

target_sources_ifdef(CONFIG_USB_DEVICE_STACK_NEXT app PRIVATE src/usbd.c)
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
};
};

sensor: gpio_qdec: gpio-qdec {
gpio_qdec: gpio-qdec {
compatible = "gpio-qdec";
gpios = <&gpio0 17 GPIO_ACTIVE_LOW>,
<&gpio0 13 GPIO_ACTIVE_LOW>;
Expand Down Expand Up @@ -97,6 +97,12 @@
key-a = <INPUT_BTN_LEFT>;
key-b = <INPUT_BTN_RIGHT>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&gpio_qdec>;
};
};

&uicr {
Expand Down
8 changes: 7 additions & 1 deletion firmware/boards/balto/ds2_retrofit/ds2_retrofit.dts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@
key-a = <INPUT_BTN_MODE>;
key-b = <INPUT_BTN_START>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&aa &button_scan>;
};
};

&uicr {
Expand Down Expand Up @@ -260,7 +266,7 @@
};

&i2c0 {
compatible = "nordic,nrf-twi";
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_default>;
Expand Down
9 changes: 7 additions & 2 deletions firmware/boards/balto/kbd_matrix/kbd_matrix.dts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
};
};

sensor: kbd-matrix {
kbd_matrix: kbd-matrix {
compatible = "gpio-kbd-matrix";
/*
row-gpios = <&gpio0 14 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>,
Expand Down Expand Up @@ -105,6 +105,11 @@
key-a = <INPUT_KEY_A>;
key-b = <INPUT_KEY_LEFTSHIFT>;
};

pm-control {
compatible = "pm-control";
connect-on = <&kbd_matrix>;
};
};

&uicr {
Expand Down Expand Up @@ -134,7 +139,7 @@
};

&i2c0 {
compatible = "nordic,nrf-twi";
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_default>;
Expand Down
8 changes: 7 additions & 1 deletion firmware/boards/balto/negcon-retro/negcon_retro.dts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@
key-a = <INPUT_BTN_START>;
key-b = <INPUT_BTN_NORTH>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&aa>;
};
};

&uicr {
Expand Down Expand Up @@ -226,7 +232,7 @@
};

&i2c0 {
compatible = "nordic,nrf-twi";
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_default>;
Expand Down
11 changes: 9 additions & 2 deletions firmware/boards/balto/paw_g3/paw_g3.dts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
key-a = <INPUT_BTN_LEFT>;
key-b = <INPUT_BTN_RIGHT>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&paw &pat>;
};
};

&uicr {
Expand All @@ -114,8 +120,9 @@
};

&i2c0 {
compatible = "nordic,nrf-twi";
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
Expand Down Expand Up @@ -157,7 +164,7 @@

cs-gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;

sensor: paw: paw3222@0 {
paw: paw3222@0 {
compatible = "pixart,paw32xx";
reg = <0>;
spi-max-frequency = <DT_FREQ_M(2)>;
Expand Down
6 changes: 6 additions & 0 deletions firmware/boards/balto/paw_pogo/paw_pogo.dts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
in-report-size = <16>;
in-polling-period-us = <1000>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&paw &pat>;
};
};

&clk_lsi {
Expand Down
11 changes: 9 additions & 2 deletions firmware/boards/balto/paw_testboard/paw_testboard.dts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
key-a = <INPUT_BTN_LEFT>;
key-b = <INPUT_BTN_RIGHT>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&paw>;
};
};

&uicr {
Expand Down Expand Up @@ -140,8 +146,9 @@
};

&i2c0 {
compatible = "nordic,nrf-twi";
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
Expand All @@ -162,7 +169,7 @@

cs-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;

sensor: paw: paw3222@0 {
paw: paw3222@0 {
compatible = "pixart,paw32xx";
reg = <0>;
spi-max-frequency = <DT_FREQ_M(2)>;
Expand Down
11 changes: 9 additions & 2 deletions firmware/boards/balto/ploopy_mouse_nrf/ploopy_mouse_nrf.dts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
key-a = <INPUT_BTN_LEFT>;
key-b = <INPUT_BTN_RIGHT>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&pmw &gpio_qdec>;
};
};

&uicr {
Expand Down Expand Up @@ -173,8 +179,9 @@
};

&i2c0 {
compatible = "nordic,nrf-twi";
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
Expand Down Expand Up @@ -206,7 +213,7 @@

cs-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;

sensor: pmw: pmw3610@0 {
pmw: pmw3610@0 {
compatible = "pixart,pmw3610";
reg = <0>;
spi-max-frequency = <DT_FREQ_M(2)>;
Expand Down
11 changes: 9 additions & 2 deletions firmware/boards/balto/pmw_testboard/pmw_testboard.dts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
key-a = <INPUT_BTN_LEFT>;
key-b = <INPUT_BTN_RIGHT>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&pmw>;
};
};

&uicr {
Expand Down Expand Up @@ -140,8 +146,9 @@
};

&i2c0 {
compatible = "nordic,nrf-twi";
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
Expand All @@ -162,7 +169,7 @@

cs-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;

sensor: pmw: pmw3610@0 {
pmw: pmw3610@0 {
compatible = "pixart,pmw3610";
reg = <0>;
spi-max-frequency = <DT_FREQ_M(2)>;
Expand Down
7 changes: 6 additions & 1 deletion firmware/boards/balto/zalpakka/zalpakka.dts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@
};
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&aa &gyro &gpio_qdec>;
};
};

&uicr {
Expand Down Expand Up @@ -337,7 +342,7 @@
};

&i2c0 {
compatible = "nordic,nrf-twi";
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c0_default>;
Expand Down
1 change: 1 addition & 0 deletions firmware/boards/darfon.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ CONFIG_APP_DEVICE_NAME="ZDarfon"
CONFIG_PWM=y
CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_APP_USB_REMOTE_WAKEUP=y
CONFIG_PM_DEVICE_RUNTIME=n
6 changes: 6 additions & 0 deletions firmware/boards/mimxrt1010_evk.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
compatible = "xinput";
input = <&buttons>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&buttons>;
};
};

led_input_activity: &green_led {};
Expand Down
6 changes: 6 additions & 0 deletions firmware/boards/nrf52840dongle.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
compatible = "xinput";
input = <&buttons>;
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&buttons>;
};
};

led_input_activity: &led1_red {};
6 changes: 6 additions & 0 deletions firmware/boards/nrf52dk_nrf52832.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
};
};
};

pm-control {
compatible = "pm-control";
always-on = <&buttons>;
connect-on = <&buttons_2>;
};
};

led_status: &led0 {};
Expand Down
2 changes: 2 additions & 0 deletions firmware/boards/paw_pogo.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ CONFIG_CONSOLE=y

CONFIG_USB_DEVICE_STACK=n
CONFIG_USB_DEVICE_STACK_NEXT=y

CONFIG_PM_DEVICE_RUNTIME=n
10 changes: 10 additions & 0 deletions firmware/dts/bindings/pm-control.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
description: PM control node

compatible: pm-control

properties:
always-on:
type: phandles

connect-on:
type: phandles
1 change: 1 addition & 0 deletions firmware/prj.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
CONFIG_GPIO=y
CONFIG_LOG=y
CONFIG_DEBUG_THREAD_INFO=y
Expand Down
28 changes: 0 additions & 28 deletions firmware/src/ble_status.c

This file was deleted.

Loading

0 comments on commit c13feea

Please sign in to comment.