diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/retrogame_joypad_s2_f1.dtsi b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/retrogame_joypad_s2_f1.dtsi new file mode 100644 index 00000000000..304ef1ef491 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/retrogame_joypad_s2_f1.dtsi @@ -0,0 +1,122 @@ +/* + This is a skeleton of joypad with 2 sticks and FN (MODE) button. + Fits devices with 1 stick and 2 extra face buttons too. + By including this ans setting I/O properties only, + devices should get consistent controller id and mapping + thus reusing non-game configs: + * SDL gamecontrollerdb.txt + * ES es_input.cfg + * Retroarch gamepad +*/ + +/ { + joypad: retrogame_joypad_s2_f1 { + /* These drivers emit the same button set which makes this skeleton ADC-agnostic */ + /* compatible = "rocknix-joypad"; */ + /* compatible = "rocknix-singleadc-joypad"; */ + + /* These are constants making Joystick Guid the same */ + joypad-name = "retrogame_joypad_s2_f1"; + joypad-vendor = <0x484B>; + joypad-product = <0x1121>; /* 11 inherited, 2 for number of sticks, 1 for number of FN */ + joypad-revision = <0x0100>; + + /* require explicit status = "okay"; */ + status = "disabled"; + + /* adc calculate scale */ + button-adc-scale = <2>; + + /* adc deadzone range */ + button-adc-deadzone = <64>; + + /* + specifies fuzz value that is used to filter noise from + the event stream. + */ + button-adc-fuzz = <32>; + button-adc-flat = <32>; + + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + + /* gpio button auto repeat set value : default disable */ + /* + autorepeat; + */ + + /* meaningful node names for easier use */ + up { + label = "GPIO DPAD-UP"; + linux,code = ; + }; + down { + label = "GPIO DPAD-DOWN"; + linux,code = ; + }; + left { + label = "GPIO DPAD-LEFT"; + linux,code = ; + }; + right { + label = "GPIO DPAD-RIGHT"; + linux,code = ; + }; + + a { + label = "GPIO BTN-A"; + linux,code = ; + }; + b { + label = "GPIO BTN-B"; + linux,code = ; + }; + x { + label = "GPIO BTN-X"; + linux,code = ; + }; + y { + label = "GPIO BTN-Y"; + linux,code = ; + }; + + select { + label = "GPIO BTN_SELECT"; + linux,code = ; + }; + start { + label = "GPIO BTN_START"; + linux,code = ; + }; + mode { + label = "GPIO BTN_F"; + linux,code = ; + }; + + tl { + label = "GPIO BTN_TL"; + linux,code = ; + }; + tr { + label = "GPIO BTN_TR"; + linux,code = ; + }; + tl2 { + label = "GPIO BTN_TL2"; + linux,code = ; + }; + tr2 { + label = "GPIO BTN_TR2"; + linux,code = ; + }; + + thumbl { + label = "GPIO BTN_THUMBL"; + linux,code = ; + }; + thumbr { + label = "GPIO BTN_THUMBR"; + linux,code = ; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-anbernic-rg351m.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-anbernic-rg351m.dts new file mode 100644 index 00000000000..d137e18262b --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-anbernic-rg351m.dts @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include "rk3326-odroid-go.dtsi" + +/ { + model = "Anbernic RG351M"; + compatible = "anbernic,rg351m", "rockchip,rk3326"; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <3500000>; + charge-term-current-microamp = <350000>; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3500000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, + <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, + <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, + <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, + <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, + <3574170 0>; + }; + + vibrator { + compatible = "pwm-vibrator"; + pwms = <&pwm0 0 1000000 0>; + pwm-names = "enable"; + }; +}; + +/delete-node/ &vcc_host; /* conflicts with pwm vibration motor */ + +#include "rk3326-panel-elida-kd35t133.dtsi" +&internal_display { + iovcc-supply = <&vcc_lcd>; + vdd-supply = <&vcc_lcd>; + rotation = <270>; +}; + +&pwm0 { + status = "okay"; +}; + +&rk817_charger { + /* This device does not have a current sense resistor */ + //rockchip,resistor-sense-micro-ohms = <0>; + monitored-battery = <&battery>; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-anbernic-rg351m.dtsi b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-anbernic-rg351m.dtsi new file mode 100644 index 00000000000..54395a40b08 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-anbernic-rg351m.dtsi @@ -0,0 +1,480 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include +#include +#include +#include +#include "rk3326.dtsi" + +/ { + aliases { + mmc0 = &sdmmc; + }; + + chosen { + stdout-path = "serial2:115200n8"; + }; + + backlight: backlight { + compatible = "pwm-backlight"; + power-supply = <&vcc_bl>; + pwms = <&pwm1 0 25000 0>; + }; + + /* + * LED is a tri-state. Driven high it is red, driven low it is + * green, and not driven at all (pin set to input) it is amber. + * Additionally, there is a 2nd LED that is not controllable + * that is on (red) when plugged in to power. + */ + gpio_led: gpio-leds { + compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&led_pin>; + + red_green_led: led-0 { + color = ; + gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_HIGH>; + function = LED_FUNCTION_CHARGING; + }; + }; + + rk817-sound { + compatible = "simple-audio-card"; + simple-audio-card,name = "rk817_int"; + simple-audio-card,format = "i2s"; + simple-audio-card,hp-det-gpios = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>; + simple-audio-card,mclk-fs = <256>; + simple-audio-card,widgets = + "Microphone", "Mic Jack", + "Headphone", "Headphones", + "Speaker", "Speaker"; + simple-audio-card,routing = + "MICL", "Mic Jack", + "Headphones", "HPOL", + "Headphones", "HPOR", + "Speaker", "SPKO"; + + simple-audio-card,codec { + sound-dai = <&rk817>; + }; + + simple-audio-card,cpu { + sound-dai = <&i2s1_2ch>; + }; + }; + + vccsys: regulator-vccsys { + compatible = "regulator-fixed"; + regulator-name = "vcc3v8_sys"; + regulator-always-on; + regulator-min-microvolt = <3800000>; + regulator-max-microvolt = <3800000>; + }; + + vibrator { + compatible = "pwm-vibrator"; + pwms = <&pwm0 0 1000000 0>; + pwm-names = "enable"; + }; +}; + +&cpu0 { + cpu-supply = <&vdd_arm>; +}; + +&cpu1 { + cpu-supply = <&vdd_arm>; +}; + +&cpu2 { + cpu-supply = <&vdd_arm>; +}; + +&cpu3 { + cpu-supply = <&vdd_arm>; +}; + +&cru { + assigned-clocks = <&cru PLL_NPLL>, + <&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>, + <&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>, + <&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>; + + assigned-clock-rates = <1188000000>, + <200000000>, <200000000>, + <150000000>, <150000000>, + <100000000>, <200000000>; +}; + +&display_subsystem { + status = "okay"; +}; + +&dsi { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + ports { + mipi_out: port@1 { + reg = <1>; + + mipi_out_panel: endpoint { + remote-endpoint = <&mipi_in_panel>; + }; + }; + }; + + internal_display: panel@0 { + reg = <0>; + backlight = <&backlight>; + reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>; + + port { + mipi_in_panel: endpoint { + remote-endpoint = <&mipi_out_panel>; + }; + }; + }; +}; + +&dsi_dphy { + status = "okay"; +}; + +&gpu { + mali-supply = <&vdd_logic>; + status = "okay"; +}; + +&i2c0 { + clock-frequency = <400000>; + i2c-scl-falling-time-ns = <16>; + i2c-scl-rising-time-ns = <280>; + status = "okay"; + + rk817: pmic@20 { + compatible = "rockchip,rk817"; + reg = <0x20>; + #clock-cells = <1>; + clock-names = "mclk"; + clock-output-names = "rk808-clkout1", "xin32k"; + clocks = <&cru SCLK_I2S1_OUT>; + interrupt-parent = <&gpio0>; + interrupts = ; + pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; + pinctrl-names = "default"; + #sound-dai-cells = <0>; + wakeup-source; + + vcc1-supply = <&vccsys>; + vcc2-supply = <&vccsys>; + vcc3-supply = <&vccsys>; + vcc4-supply = <&vccsys>; + vcc5-supply = <&vccsys>; + vcc6-supply = <&vccsys>; + vcc7-supply = <&vccsys>; + vcc8-supply = <&vccsys>; + + regulators { + vdd_logic: DCDC_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <1150000>; + regulator-min-microvolt = <950000>; + regulator-name = "vdd_logic"; + regulator-ramp-delay = <6001>; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vdd_arm: DCDC_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <1350000>; + regulator-min-microvolt = <950000>; + regulator-name = "vdd_arm"; + regulator-ramp-delay = <6001>; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vcc_ddr: DCDC_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_ddr"; + + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + vcc_3v3: DCDC_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <3300000>; + regulator-name = "vcc_3v3"; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_1v8: LDO_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <1800000>; + regulator-min-microvolt = <1800000>; + regulator-name = "vcc_1v8"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1800000>; + }; + }; + + vdd_1v0: LDO_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <1000000>; + regulator-min-microvolt = <1000000>; + regulator-name = "vdd_1v0"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1000000>; + }; + }; + + vcc3v3_pmu: LDO_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <3300000>; + regulator-name = "vcc3v3_pmu"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vccio_sd: LDO_REG5 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <1800000>; + regulator-name = "vccio_sd"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_sd: LDO_REG6 { + regulator-boot-on; + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <3300000>; + regulator-name = "vcc_sd"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_bl: LDO_REG7 { + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <3300000>; + regulator-name = "vcc_bl"; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_lcd: LDO_REG8 { + regulator-max-microvolt = <2800000>; + regulator-min-microvolt = <2800000>; + regulator-name = "vcc_lcd"; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <2800000>; + }; + }; + + vcc_wifi: LDO_REG9 { + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <3300000>; + regulator-name = "vcc_wifi"; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + usb_midu: BOOST { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <5400000>; + regulator-min-microvolt = <5000000>; + regulator-name = "usb_midu"; + }; + }; + + rk817_codec: codec { + rockchip,mic-in-differential; + }; + }; +}; + +&i2s1_2ch { + status = "okay"; +}; + +&io_domains { + vccio1-supply = <&vcc_3v3>; + vccio2-supply = <&vccio_sd>; + vccio3-supply = <&vcc_3v3>; + vccio4-supply = <&vcc_3v3>; + vccio5-supply = <&vcc_3v3>; + vccio6-supply = <&vcc_3v3>; + status = "okay"; +}; + +&pmu_io_domains { + pmuio1-supply = <&vcc3v3_pmu>; + pmuio2-supply = <&vcc3v3_pmu>; + status = "okay"; +}; + +&pwm0 { + status = "okay"; +}; + +&pwm1 { + status = "okay"; +}; + +&saradc { + vref-supply = <&vcc_1v8>; + status = "okay"; +}; + +&sdmmc { + cap-sd-highspeed; + card-detect-delay = <200>; + cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&sfc { + #address-cells = <1>; + pinctrl-0 = <&sfc_clk &sfc_cs0 &sfc_bus2>; + pinctrl-names = "default"; + #size-cells = <0>; + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <108000000>; + spi-rx-bus-width = <2>; + spi-tx-bus-width = <1>; + }; +}; + +&tsadc { + status = "okay"; +}; + +&u2phy { + status = "okay"; + + u2phy_host: host-port { + status = "okay"; + }; + + u2phy_otg: otg-port { + status = "disabled"; + }; +}; + +&usb20_otg { + status = "okay"; +}; + +&uart2 { + pinctrl-0 = <&uart2m1_xfer>; + pinctrl-names = "default"; + status = "okay"; +}; + +&vopb { + status = "okay"; +}; + +&vopb_mmu { + status = "okay"; +}; + +&pinctrl { + headphone { + hp_det: hp-det { + rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>; + }; + }; + + leds { + led_pin: led-pin { + rockchip,pins = <2 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + pmic { + dc_det: dc-det { + rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + pmic_int: pmic-int { + rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + soc_slppin_gpio: soc_slppin_gpio { + rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>; + }; + + soc_slppin_rst: soc_slppin_rst { + rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>; + }; + + soc_slppin_slp: soc_slppin_slp { + rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-anbernic-rg351v.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-anbernic-rg351v.dts new file mode 100644 index 00000000000..26658a37f4e --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-anbernic-rg351v.dts @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include "rk3326-odroid-go.dtsi" + +/ { + model = "Anbernic RG351V"; + compatible = "anbernic,rg351v", "rockchip,rk3326"; + + aliases { + mmc0 = &sdio; + mmc1 = &sdmmc; + }; + + gpio-keys-vol { + compatible = "gpio-keys"; + autorepeat; + pinctrl-0 = <&btn_pins_vol>; + pinctrl-names = "default"; + + button-vol-down { + gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; + label = "VOLUMEDOWN"; + linux,code = ; + }; + + button-volume-up { + gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "VOLUMEUP"; + linux,code = ; + }; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <3500000>; + charge-term-current-microamp = <350000>; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3500000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, + <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, + <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, + <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, + <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, + <3574170 0>; + }; + + vibrator { + compatible = "pwm-vibrator"; + pwms = <&pwm0 0 1000000 0>; + pwm-names = "enable"; + }; +}; + +/* conflicts with pwm vibration motor */ +/delete-node/ &vcc_host; + +/* Device only has 1 LED compared to Odroid Go Advance */ +/delete-node/ &gpio_led; + +&internal_display { + compatible = "anbernic,rg351v-panel", "newvision,nv3051d"; + iovcc-supply = <&vcc_lcd>; + vdd-supply = <&vcc_lcd>; +}; + +&io_domains { + vccio1-supply = <&vccio_sd>; +}; + +/delete-node/ &pwm_led; + +&pwm0 { + status = "okay"; +}; + +/delete-node/ &pwm3; + +&rk817_charger { + /* This device does not have a current sense resistor */ + rockchip,resistor-sense-micro-ohms = <0>; + monitored-battery = <&battery>; +}; + +&sdio { + cap-sd-highspeed; + card-detect-delay = <200>; + cd-gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&vcc_sd { + regulator-max-microvolt = <3000000>; + regulator-min-microvolt = <1800000>; +}; + +&vccio_sd { + regulator-max-microvolt = <1800000>; +}; + +&pinctrl { + btns { + btn_pins_vol: btn-pins-vol { + rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-eeclone.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-eeclone.dts new file mode 100644 index 00000000000..1dc8f70b431 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-eeclone.dts @@ -0,0 +1,926 @@ +/// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024-present ROCKNIX (https://github.com/ROCKNIX) + * Copyright (c) 2025 Danil Zagoskin + */ + +/dts-v1/; +#include +#include +#include +#include +#include "rk3326.dtsi" + +/ { + model = "Generic EE clone"; + compatible = "gameconsole,eeclone", "rockchip,rk3326"; + + aliases { + mmc0 = &emmc; + mmc1 = &sdmmc; + mmc2 = &sdio; + serial1 = &uart2; + serial2 = &uart5; + }; + + backlight: backlight { + compatible = "pwm-backlight"; + pwms = <&pwm1 0 25000 0>; + brightness-levels = < + 0 1 2 3 4 5 6 7 + 8 9 10 11 12 13 14 15 + 16 17 18 19 20 21 22 23 + 24 25 26 27 28 29 30 31 + 32 33 34 35 36 37 38 39 + 40 41 42 43 44 45 46 47 + 48 49 50 51 52 53 54 55 + 56 57 58 59 60 61 62 63 + 64 65 66 67 68 69 70 71 + 72 73 74 75 76 77 78 79 + 80 81 82 83 84 85 86 87 + 88 89 90 91 92 93 94 95 + 96 97 98 99 100 101 102 103 + 104 105 106 107 108 109 110 111 + 112 113 114 115 116 117 118 119 + 120 121 122 123 124 125 126 127 + 128 129 130 131 132 133 134 135 + 136 137 138 139 140 141 142 143 + 144 145 146 147 148 149 150 151 + 152 153 154 155 156 157 158 159 + 160 161 162 163 164 165 166 167 + 168 169 170 171 172 173 174 175 + 176 177 178 179 180 181 182 183 + 184 185 186 187 188 189 190 191 + 192 193 194 195 196 197 198 199 + 200 201 202 203 204 205 206 207 + 208 209 210 211 212 213 214 215 + 216 217 218 219 220 221 222 223 + 224 225 226 227 228 229 230 231 + 232 233 234 235 236 237 238 239 + 240 241 242 243 244 245 246 247 + 248 249 250 251 252 253 254 255>; + default-brightness-level = <128>; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <4000000>; + charge-term-current-microamp = <200000>; + constant-charge-current-max-microamp = <1500000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <100000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3300000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = + <4046950 100>, <4001920 95>, <3967900 90>, <3940000 85>, + <3910000 80>, <3870000 75>, <3830000 70>, <3790000 65>, + <3750000 60>, <3720000 55>, <3690000 50>, <3650000 45>, + <3610000 40>, <3570000 35>, <3540000 30>, <3500000 25>, + <3460000 20>, <3420000 15>, <3380000 10>, <3340000 5>, + <3300000 0>; + }; + + adc_keys: adc-keys { + compatible = "adc-keys"; + io-channels = <&saradc 2>; + io-channel-names = "buttons"; + keyup-threshold-microvolt = <1800000>; + poll-interval = <100>; + + /* disabled by default, dtbo may enable it when needed */ + status = "disabled"; + + button-vol-up { + press-threshold-microvolt = <15000>; + label = "VOLUMEUP"; + linux,code = ; + }; + + button-vol-down { + press-threshold-microvolt = <300000>; + label = "VOLUMEDOWN"; + linux,code = ; + }; + }; + + joypad: joypad { + compatible = "rocknix-singleadc-joypad"; + + joypad-name = "r36s_Gamepad"; + joypad-product = <0x1188>; + joypad-revision = <0x0188>; + + status = "okay"; + + /* gpio pincontrol setup */ + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + + /* Analog mux define */ + io-channel-names = "amux_adc"; + io-channels = <&saradc 1>; + + /* adc mux channel count */ + amux-count = <4>; + /* non-default wiring */ + amux-channel-mapping = <2 3 1 0>; + /* adc mux enable gpio */ + amux-en-gpios = <&gpio2 RK_PB4 GPIO_ACTIVE_LOW>; /* rocker0-gpios */ + /* adc mux select(a,b) gpio */ + amux-a-gpios = <&gpio2 RK_PC0 GPIO_ACTIVE_LOW>; /* rocker1-gpios */ + amux-b-gpios = <&gpio2 RK_PB7 GPIO_ACTIVE_LOW>; /* rocker-gpios */ + + /* adc calculate scale */ + button-adc-scale = <2>; + + /* adc deadzone range */ + button-adc-deadzone = <64>; + + /* + specifies fuzz value that is used to filter noise from + the event stream. + */ + button-adc-fuzz = <32>; + button-adc-flat = <32>; + + /* + Analog Stick data tuning value(precent) + p = positive direction, n = negative direction + report value = (real_adc_data * tuning_value) / 100 + */ + abs_x-p-tuning = <200>; + abs_x-n-tuning = <200>; + + abs_y-p-tuning = <200>; + abs_y-n-tuning = <200>; + + abs_rx-p-tuning = <200>; + abs_rx-n-tuning = <200>; + + abs_ry-p-tuning = <200>; + abs_ry-n-tuning = <200>; + + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + + /* gpio button auto repeat set value : default disable */ + /* + autorepeat; + */ + + /* + joypad driver is poll-device driver. + poll-device is does not support wakeup-source. + */ + sw1 { + gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-UP"; + linux,code = ; // 0x220 + }; + sw2 { + gpios = <&gpio3 RK_PC7 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-DOWN"; + linux,code = ; // 0x221 + }; + sw3 { + gpios = <&gpio3 RK_PC4 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-LEFT"; + linux,code = ; // 0x222 + }; + sw4 { + gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-RIGHT"; + linux,code = ; // 0x223 + }; + + sw5 { + gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>; + label = "GPIO KEY BTN-A"; + linux,code = ; // 0x131 + }; + sw6 { + gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-B"; + linux,code = ; // 0x130 + }; + sw7 { + gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-Y"; + linux,code = ; // 0x134 + }; + sw8 { + gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-X"; + linux,code = ; // 0x133 + }; + + sw11 { + gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_THUMBL"; + linux,code = ; // 0x2c2 + }; + sw12 { + gpios = <&gpio2 RK_PB6 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_THUMBR"; + linux,code = ; // 0x2c3 + }; + + sw13 { + gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_FN"; + linux,code = ; // 0x2c4 + }; + + sw15 { + gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-LEFT"; + linux,code = ; // 0x02 + }; + sw16 { + gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-RIGHT"; + linux,code = ; // 0x05 + }; + sw19 { + gpios = <&gpio3 RK_PD0 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_SELECT"; + linux,code = ; + }; + sw20 { + gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-RIGHT2"; + linux,code = ; + }; + sw21 { + gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-LEFT2"; + linux,code = ; + }; + sw22 { + gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_START"; + linux,code = ; + }; + }; + + leds: gpio-leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + /* charge_red_gpio = <&gpio0 17 0>; */ + led-0 { + color = ; + default-state = "off"; + function = LED_FUNCTION_CHARGING; + linux,default-trigger = "none"; + gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_HIGH>; + }; + + /* charge_blue_gpio = <&gpio0 0 0>; */ + led-1 { + color = ; + default-state = "on"; + function = LED_FUNCTION_POWER; + linux,default-trigger = "default-on"; + gpios = <&gpio0 RK_PA0 GPIO_ACTIVE_HIGH>; + }; + }; + + spk_amp: audio-amplifier { + compatible = "simple-audio-amplifier"; + enable-gpios = <&gpio3 RK_PA7 GPIO_ACTIVE_HIGH>; + pinctrl-0 = <&spk_amp_enable_h>; + pinctrl-names = "default"; + sound-name-prefix = "Speaker Amp"; + }; + + rk817-sound { + compatible = "simple-audio-card"; + pinctrl-names = "default"; + pinctrl-0 = <&hp_det>; + simple-audio-card,name = "rk817_ext"; + simple-audio-card,aux-devs = <&spk_amp>; + simple-audio-card,format = "i2s"; + simple-audio-card,hp-det-gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>; + simple-audio-card,mclk-fs = <256>; + simple-audio-card,widgets = + "Microphone", "Mic Jack", + "Headphone", "Headphones", + "Speaker", "Speaker"; + simple-audio-card,routing = + "MICL", "Mic Jack", + "Headphones", "HPOL", + "Headphones", "HPOR", + "Speaker", "SPKO"; + + simple-audio-card,codec { + sound-dai = <&rk817>; + }; + + simple-audio-card,cpu { + sound-dai = <&i2s1_2ch>; + }; + }; + + vccsys: vccsys { + compatible = "regulator-fixed"; + regulator-name = "vcc5v0_sys"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; + + vcc-phy-regulator { + compatible = "regulator-fixed"; + regulator-name = "vcc_phy"; + regulator-always-on; + regulator-boot-on; + }; + + vcc18_lcd0: vcc18-lcd0 { + compatible = "regulator-fixed"; + regulator-name = "vcc18_lcd0_n"; + gpio = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>; + enable-active-high; + pinctrl-0 = <&vcc18_lcd_n>; + pinctrl-names = "default"; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc_host: vcc_host { + compatible = "regulator-fixed"; + regulator-name = "vcc_host"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio3 RK_PA4 GPIO_ACTIVE_HIGH>; + pinctrl-0 = <&vcc5_usb>; + pinctrl-names = "default"; + enable-active-high; + regulator-always-on; + regulator-boot-on; + vin-supply = <&usb_midu>; + }; +}; + +&dmc { + center-supply = <&vdd_logic>; +}; + +&cpu0 { + cpu-supply = <&vdd_arm>; +}; + +&cpu1 { + cpu-supply = <&vdd_arm>; +}; + +&cpu2 { + cpu-supply = <&vdd_arm>; +}; + +&cpu3 { + cpu-supply = <&vdd_arm>; +}; + +&cru { + assigned-clocks = <&cru PLL_NPLL>, + <&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>, + <&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>, + <&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>; + + assigned-clock-rates = <1188000000>, + <200000000>, <200000000>, + <150000000>, <150000000>, + <100000000>, <200000000>; +}; + +&display_subsystem { + status = "okay"; +}; + +&dsi { + status = "okay"; + + ports { + mipi_out: port@1 { + reg = <1>; + + mipi_out_panel: endpoint { + remote-endpoint = <&mipi_in_panel>; + }; + }; + }; + + internal_display: panel@0 { + compatible = "magicx,xu10-panel", "sitronix,st7703"; + iovcc-supply = <&vcc18_lcd0>; + vcc-supply = <&vcc18_lcd0>; + reg = <0>; + backlight = <&backlight>; + reset-gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&lcd_rst>; + + port { + mipi_in_panel: endpoint { + remote-endpoint = <&mipi_out_panel>; + }; + }; + }; +}; + +&dsi_dphy { + status = "okay"; +}; + +&gpu { + mali-supply = <&vdd_logic>; + status = "okay"; +}; + +&i2c0 { + clock-frequency = <400000>; + i2c-scl-falling-time-ns = <16>; + i2c-scl-rising-time-ns = <280>; + status = "okay"; + + rk817: pmic@20 { + compatible = "rockchip,rk817"; + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = ; + clock-output-names = "rk808-clkout1", "xin32k"; + clock-names = "mclk"; + clocks = <&cru SCLK_I2S1_OUT>; + pinctrl-names = "default"; + pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; + rockchip,system-power-controller; + wakeup-source; + #clock-cells = <1>; + #sound-dai-cells = <0>; + + vcc1-supply = <&vccsys>; + vcc2-supply = <&vccsys>; + vcc3-supply = <&vccsys>; + vcc4-supply = <&vccsys>; + vcc5-supply = <&vccsys>; + vcc6-supply = <&vccsys>; + vcc7-supply = <&vcc_3v0>; + vcc8-supply = <&vccsys>; + + regulators { + vdd_logic: DCDC_REG1 { + regulator-name = "vdd_logic"; + regulator-min-microvolt = <950000>; + regulator-max-microvolt = <1350000>; + regulator-initial-mode = <0x02>; + regulator-ramp-delay = <6001>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vdd_arm: DCDC_REG2 { + regulator-name = "vdd_arm"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <1350000>; + regulator-ramp-delay = <6001>; + regulator-initial-mode = <0x02>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vcc_ddr: DCDC_REG3 { + regulator-name = "vcc_ddr"; + regulator-always-on; + regulator-boot-on; + regulator-initial-mode = <0x02>; + + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + vcc_3v0: DCDC_REG4 { + regulator-name = "vcc_3v0"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-initial-mode = <0x02>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vcc_1v0: LDO_REG1 { + regulator-name = "vcc_1v0"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1000000>; + }; + }; + + vcc1v8_soc: LDO_REG2 { + regulator-name = "vcc1v8_soc"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1800000>; + }; + }; + + vcc1v0_soc: LDO_REG3 { + regulator-name = "vcc1v0_soc"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1000000>; + }; + }; + + vcc3v0_pmu: LDO_REG4 { + regulator-name = "vcc3v0_pmu"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vccio_sd: LDO_REG5 { + regulator-name = "vccio_sd"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_sd: LDO_REG6 { + regulator-name = "vcc_sd"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc2v8_dvp: LDO_REG7 { + regulator-name = "vcc2v8_dvp"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc3v0_dvp: LDO_REG8 { + regulator-name = "vcc3v0_dvp"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vdd1v5_dvp: LDO_REG9 { + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; + regulator-name = "vdd1v5_dvp"; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <1500000>; + }; + }; + + usb_midu: BOOST { + regulator-name = "usb_midu"; + regulator-min-microvolt = <4900000>; + regulator-max-microvolt = <5400000>; + regulator-always-on; + regulator-boot-on; + }; + + /* + otg_switch: OTG_SWITCH { + regulator-name = "otg_switch"; + + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + */ + }; + + rk817_charger: charger { + monitored-battery = <&battery>; + rockchip,resistor-sense-micro-ohms = <10000>; + rockchip,sleep-enter-current-microamp = <300000>; + rockchip,sleep-filter-current-microamp = <100000>; + }; + + rk817_codec: codec { + rockchip,mic-in-differential; + }; + }; +}; + +/* I2S 1 Channel Used Header(P2):1(GPIO2.C3),2(.C2), 3(.C1), 4(.C5), 5(.C4) */ +&i2s1_2ch { + status = "okay"; + #sound-dai-cells = <0>; +}; + +&io_domains { + vccio1-supply = <&vcc2v8_dvp>; + vccio2-supply = <&vccio_sd>; + vccio3-supply = <&vcc1v8_soc>; + vccio4-supply = <&vcc_3v0>; + vccio5-supply = <&vcc_3v0>; + vccio6-supply = <&vcc1v8_soc>; + status = "okay"; +}; + +&isp { + status = "okay"; +}; + +&isp_mmu { + status = "okay"; +}; + +&pmu_io_domains { + pmuio1-supply = <&vcc3v0_pmu>; + pmuio2-supply = <&vcc3v0_pmu>; + status = "okay"; +}; + +&csi_dphy { + status = "okay"; +}; + +&pwm1 { + status = "okay"; +}; + +&saradc { + vref-supply = <&vcc1v8_soc>; + status = "okay"; +}; + +&sdmmc { + cap-sd-highspeed; + card-detect-delay = <800>; + cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; /*[> ff370000 PD_SDCARD CD GPIO <]*/ + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vqmmc-supply = <&vccio_sd>; + vmmc-supply = <&vcc_sd>; + status = "okay"; +}; + +&sdio { + cap-sd-highspeed; + max-frequency = <100000000>; + cd-gpios = <&gpio0 RK_PA2 GPIO_ACTIVE_LOW>; + card-detect-delay = <800>; + supports-sd; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vqmmc-supply = <&vcc2v8_dvp>; + vmmc-supply = <&vcc3v0_dvp>; + status = "okay"; +}; + +&emmc { + status = "okay"; + no-sdio; + no-sd; + disable-wp; + non-removable; + num-slots = <1>; +}; + +&tsadc { + status = "okay"; +}; + +&u2phy { + status = "okay"; + + u2phy_host: host-port { + status = "okay"; + }; + + u2phy_otg: otg-port { + status = "disabled"; + }; +}; + +&usb20_otg { + status = "okay"; +}; + +&vopb { + status = "okay"; +}; + +&vopb_mmu { + status = "okay"; +}; +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = + <2 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB3 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PC0 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PC1 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PC2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PC3 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PC4 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PC7 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PD0 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PD1 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + headphone { + hp_det: hp-det { + rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>; + }; + }; + + gpio-lcd { + lcd_rst: lcd-rst { + rockchip,pins = <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + vcc18-lcd { + vcc18_lcd_n: vcc18-lcd-n { + rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + vcc5-usb { + vcc5_usb: vcc5-usb { + rockchip,pins = <3 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + gpio-led { + led_pins: led-pins { + rockchip,pins = + <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>, /* charge_blue_gpio = <&gpio0 0 0>; */ + <0 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>; /* charge_red_gpio = <&gpio0 17 0>; */ + }; + }; + + pmic { + dc_det: dc-det { + rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + pmic_int: pmic-int { + rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + soc_slppin_gpio: soc_slppin_gpio { + rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>; + }; + + soc_slppin_rst: soc_slppin_rst { + rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>; + }; + + soc_slppin_slp: soc_slppin_slp { + rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>; + }; + }; + + speaker { + spk_amp_enable_h: spk-amp-enable-h { + rockchip,pins = <3 RK_PA7 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; + +&uart5 { + status = "okay"; +}; +&uart2 { + status = "disabled"; +}; + + +&internal_display { + compatible = "rocknix,generic-dsi"; + panel_description = + "G size=153,85 delays=20,20,20,120,20 format=rgb888 lanes=4 flags=0xe03", + + "M clock=50000 horizontal=720,140,80,140 vertical=720,20,4,20 default=1", + "M clock=50000 horizontal=720,140,100,140 vertical=720,20,150,20", + "M clock=50040 horizontal=720,140,112,140 vertical=720,20,140,20", + "M clock=51400 horizontal=720,140,132,140 vertical=720,20,148,20", + "M clock=50140 horizontal=720,140,90,140 vertical=720,20,40,20", + "M clock=56900 horizontal=720,140,90,140 vertical=720,20,114,20", + "M clock=50400 horizontal=720,140,92,140 vertical=720,20,10,20", + "M clock=50220 horizontal=720,140,80,140 vertical=720,20,15,20", + "M clock=54600 horizontal=720,140,112,140 vertical=720,20,57,20", + "M clock=75450 horizontal=720,140,95,140 vertical=720,20,153,20", + "M clock=75330 horizontal=720,140,80,140 vertical=720,20,15,20", + "M clock=100440 horizontal=720,140,80,140 vertical=720,20,15,20", + + "I seq=b9f11283", + "I seq=b1000000da80", + "I seq=b23c1230", + "I seq=b31010282803ff00000000", + "I seq=b480", + "I seq=b50a0a", + "I seq=b69797", + "I seq=b82622f013", + "I seq=ba338105f90e0e2000000000000000442500900a0000014f01000037", + "I seq=bc47", + "I seq=bf021100", + "I seq=c0737350500000127000", + "I seq=c12500323277e4ffffcccc7777", + "I seq=c68200bfff00ff", + "I seq=c7b8000a000000", + "I seq=c810401e02", + "I seq=cc0b", + "I seq=e0000b102c3d3f423a070d0f131513140f16000b102c3d3f423a070d0f131513140f16", + "I seq=e307070b0b0b0b00000000ff00c010", + "I seq=e9c8100a000080811231234f86a000470800000c00000000000c00000098028baf4602888888888898138baf5713888888888800000000000000000000000000", + "I seq=ea970c090909780000000000009f318ba8317588888888889f208ba820648888888888230000027100000000000000000000000000000040808100000000", + "I seq=efffff01", + "I seq=11 wait=250", + "I seq=29 wait=50"; +}; + + diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-r33s.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-r33s.dts new file mode 100644 index 00000000000..5a93510a762 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-r33s.dts @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * # Copyright (C) 2022-24 JELOS (https://github.com/JustEnoughLinuxOS) + */ + +/dts-v1/; +#include "rk3326-gameconsole-r3xs.dtsi" + +/ { + model = "Game Console R33S"; + compatible = "gameconsole,r33s", "rockchip,rk3326"; + + builtin_gamepad: r33s_joypad { + compatible = "rocknix-singleadc-joypad"; + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + joypad-name = "r33s_joypad"; + joypad-product = <0x0AA2>; + joypad-revision = <0x0100>; + joypad-vendor = <0x0001>; + + status = "okay"; + amux-count = <0>; + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + pwms = <&pwm0 0 1000000000 0>; + pwm-names = "enable"; + rumble-boost-weak = <0x0000>; + rumble-boost-strong = <0x0000>; + + button-sw1 { + gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; + label = "DPAD-UP"; + linux,code = ; + }; + button-sw2 { + gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; + label = "DPAD-DOWN"; + linux,code = ; + }; + button-sw3 { + gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; + label = "DPAD-LEFT"; + linux,code = ; + }; + button-sw4 { + gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; + label = "DPAD-RIGHT"; + linux,code = ; + }; + button-sw5 { + gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; + label = "BTN-A"; + linux,code = ; + }; + button-sw6 { + gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; + label = "BTN-B"; + linux,code = ; + }; + button-sw7 { + gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; + label = "BTN-Y"; + linux,code = ; + }; + button-sw8 { + gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; + label = "BTN-X"; + linux,code = ; + }; + button-sw9 { + gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; + label = "TOP-LEFT"; + linux,code = ; + }; + button-sw10 { + gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; + label = "TOP-RIGHT"; + linux,code = ; + }; + button-sw11 { + gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; + label = "SELECT"; + linux,code = ; + }; + button-sw12 { + gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; + label = "TOP-RIGHT 2"; + linux,code = ; + }; + button-sw13 { + gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; + label = "TOP-LEFT 2"; + linux,code = ; + }; + button-sw14 { + gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; + label = "START"; + linux,code = ; + }; + }; +}; + +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-r36s.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-r36s.dts new file mode 100644 index 00000000000..45ce5089626 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-r36s.dts @@ -0,0 +1,202 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * # Copyright (C) 2022-24 JELOS (https://github.com/JustEnoughLinuxOS) + */ + +/dts-v1/; +#include "rk3326-gameconsole-r3xs.dtsi" + +/ { + model = "Game Console R36S"; + compatible = "gameconsole,r35s", "gameconsole,r36s", "rockchip,rk3326"; + + joypad: odroidgo3-joypad { + compatible = "odroidgo3-joypad"; + pwms = <&pwm0 0 200000000 0>; + pwm-names = "enable"; + rumble-boost-weak = <0x0000>; + rumble-boost-strong = <0x0000>; + + joypad-name = "r36s_Gamepad"; + joypad-product = <0x1188>; + joypad-revision = <0x0188>; + + status = "okay"; + + /* gpio pincontrol setup */ + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + pinctrl-1 = <&pwm0_pin>; + + /* Analog mux define */ + io-channel-names = "amux_adc"; + io-channels = <&saradc 1>; + + /* adc mux channel count */ + amux-count = <4>; + /* adc mux select(a,b) gpio */ + amux-a-gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; + amux-b-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>; + /* adc mux enable gpio */ + amux-en-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; + + /* adc calculate scale */ + button-adc-scale = <2>; + + /* adc deadzone range */ + button-adc-deadzone = <64>; + + /* + specifies fuzz value that is used to filter noise from + the event stream. + */ + button-adc-fuzz = <32>; + button-adc-flat = <32>; + + /* + Analog Stick data tuning value(precent) + p = positive direction, n = negative direction + report value = (real_adc_data * tuning_value) / 100 + */ + abs_x-p-tuning = <200>; + abs_x-n-tuning = <200>; + + abs_y-p-tuning = <200>; + abs_y-n-tuning = <200>; + + abs_rx-p-tuning = <200>; + abs_rx-n-tuning = <200>; + + abs_ry-p-tuning = <200>; + abs_ry-n-tuning = <200>; + + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + + /* required for RG36S */ + invert-absx; + invert-absy; + + /* gpio button auto repeat set value : default disable */ + /* + autorepeat; + */ + + /* + joypad driver is poll-device driver. + poll-device is does not support wakeup-source. + */ + sw1 { + gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-UP"; + linux,code = ; // 0x220 + }; + sw2 { + gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-DOWN"; + linux,code = ; // 0x221 + }; + sw3 { + gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-LEFT"; + linux,code = ; // 0x222 + }; + sw4 { + gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-RIGHT"; + linux,code = ; // 0x223 + }; + sw5 { + gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; + label = "GPIO KEY BTN-A"; + linux,code = ; // 0x131 + }; + sw6 { + gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-B"; + linux,code = ; // 0x130 + }; + sw7 { + gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-Y"; + linux,code = ; // 0x134 + }; + sw8 { + gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-X"; + linux,code = ; // 0x133 + }; + sw11 { + gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_THUMBL"; + linux,code = ; // 0x2c2 + }; + sw12 { + gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_THUMBR"; + linux,code = ; // 0x2c3 + }; + sw13 { + gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_FN"; + linux,code = ; // 0x2c4 + }; + sw15 { + gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-LEFT"; + linux,code = ; // 0x02 + }; + sw16 { + gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-RIGHT"; + linux,code = ; // 0x05 + }; + sw19 { + gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_SELECT"; + linux,code = ; + }; + sw20 { + gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-RIGHT2"; + linux,code = ; + }; + sw21 { + gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-LEFT2"; + linux,code = ; + }; + sw22 { + gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO BTN_START"; + linux,code = ; + }; + }; +}; + +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; + + }; + + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-r3xs.dtsi b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-r3xs.dtsi new file mode 100644 index 00000000000..de1b0d51e23 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameconsole-r3xs.dtsi @@ -0,0 +1,545 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * # Copyright (C) 2022-24 JELOS (https://github.com/JustEnoughLinuxOS) + */ + +/dts-v1/; +#include +#include +#include +#include +#include "rk3326.dtsi" + +/ { + model = "Game Console R33S"; + compatible = "gameconsolec,r33s", "rockchip,rk3326"; + + aliases { + mmc0 = &sdio; + mmc1 = &sdmmc; + }; + + chosen { + stdout-path = "serial2:115200n8"; + }; + + backlight: backlight { + compatible = "pwm-backlight"; + power-supply = <&vcc_bl>; + pwms = <&pwm1 0 25000 0>; + brightness-levels = < + 0 1 2 3 4 5 6 7 + 8 9 10 11 12 13 14 15 + 16 17 18 19 20 21 22 23 + 24 25 26 27 28 29 30 31 + 32 33 34 35 36 37 38 39 + 40 41 42 43 44 45 46 47 + 48 49 50 51 52 53 54 55 + 56 57 58 59 60 61 62 63 + 64 65 66 67 68 69 70 71 + 72 73 74 75 76 77 78 79 + 80 81 82 83 84 85 86 87 + 88 89 90 91 92 93 94 95 + 96 97 98 99 100 101 102 103 + 104 105 106 107 108 109 110 111 + 112 113 114 115 116 117 118 119 + 120 121 122 123 124 125 126 127 + 128 129 130 131 132 133 134 135 + 136 137 138 139 140 141 142 143 + 144 145 146 147 148 149 150 151 + 152 153 154 155 156 157 158 159 + 160 161 162 163 164 165 166 167 + 168 169 170 171 172 173 174 175 + 176 177 178 179 180 181 182 183 + 184 185 186 187 188 189 190 191 + 192 193 194 195 196 197 198 199 + 200 201 202 203 204 205 206 207 + 208 209 210 211 212 213 214 215 + 216 217 218 219 220 221 222 223 + 224 225 226 227 228 229 230 231 + 232 233 234 235 236 237 238 239 + 240 241 242 243 244 245 246 247 + 248 249 250 251 252 253 254 255>; + default-brightness-level = <128>; + }; + + gpio-keys-vol { + compatible = "gpio-keys"; + autorepeat; + pinctrl-0 = <&btn_pins_vol>; + pinctrl-names = "default"; + + button-vol-down { + gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; + label = "VOLUMEDOWN"; + linux,code = ; + }; + + button-volume-up { + gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "VOLUMEUP"; + linux,code = ; + }; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <3200000>; + charge-term-current-microamp = <320000>; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3500000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, + <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, + <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, + <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, + <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, + <3574170 0>; + + }; + + rk817-sound { + compatible = "simple-audio-card"; + simple-audio-card,name = "rk817_int"; + simple-audio-card,format = "i2s"; + simple-audio-card,hp-det-gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>; + simple-audio-card,mclk-fs = <256>; + simple-audio-card,widgets = + "Microphone", "Mic Jack", + "Headphone", "Headphones", + "Speaker", "Speaker"; + simple-audio-card,routing = + "MICL", "Mic Jack", + "Headphones", "HPOL", + "Headphones", "HPOR", + "Speaker", "SPKO"; + + simple-audio-card,codec { + sound-dai = <&rk817>; + }; + + simple-audio-card,cpu { + sound-dai = <&i2s1_2ch>; + }; + }; + + vccsys: vccsys { + compatible = "regulator-fixed"; + regulator-name = "vcc3v8_sys"; + regulator-always-on; + regulator-min-microvolt = <3800000>; + regulator-max-microvolt = <3800000>; + }; +}; + +&dmc { + center-supply = <&vdd_logic>; +}; + +&cpu0 { + cpu-supply = <&vdd_arm>; +}; + +&cpu1 { + cpu-supply = <&vdd_arm>; +}; + +&cpu2 { + cpu-supply = <&vdd_arm>; +}; + +&cpu3 { + cpu-supply = <&vdd_arm>; +}; + +&cru { + assigned-clocks = <&cru PLL_NPLL>, + <&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>, + <&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>, + <&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>; + + assigned-clock-rates = <1188000000>, + <200000000>, <200000000>, + <150000000>, <150000000>, + <100000000>, <200000000>; +}; + +&display_subsystem { + status = "okay"; +}; + +&dsi { + status = "okay"; + + ports { + mipi_out: port@1 { + reg = <1>; + + mipi_out_panel: endpoint { + remote-endpoint = <&mipi_in_panel>; + }; + }; + }; + + internal_display: panel@0 { + reg = <0>; + backlight = <&backlight>; + reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>; + + port { + mipi_in_panel: endpoint { + remote-endpoint = <&mipi_out_panel>; + }; + }; + }; +}; + +&dsi_dphy { + status = "okay"; +}; + +&gpu { + mali-supply = <&vdd_logic>; + status = "okay"; +}; + +&internal_display { + compatible = "gameconsole,r36s-panel", "sitronix,st7703"; + iovcc-supply = <&vcc_lcd>; + vdd-supply = <&vcc_lcd>; +}; + +&i2c0 { + clock-frequency = <400000>; + i2c-scl-falling-time-ns = <16>; + i2c-scl-rising-time-ns = <280>; + status = "okay"; + + rk817: pmic@20 { + compatible = "rockchip,rk817"; + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = ; + clock-output-names = "rk808-clkout1", "xin32k"; + clock-names = "mclk"; + clocks = <&cru SCLK_I2S1_OUT>; + pinctrl-names = "default"; + pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; + rockchip,system-power-controller; + wakeup-source; + #clock-cells = <1>; + #sound-dai-cells = <0>; + + vcc1-supply = <&vccsys>; + vcc2-supply = <&vccsys>; + vcc3-supply = <&vccsys>; + vcc4-supply = <&vccsys>; + vcc5-supply = <&vccsys>; + vcc6-supply = <&vccsys>; + vcc7-supply = <&vccsys>; + vcc8-supply = <&vccsys>; + + regulators { + vdd_logic: DCDC_REG1 { + regulator-name = "vdd_logic"; + regulator-min-microvolt = <950000>; + regulator-max-microvolt = <1150000>; + regulator-ramp-delay = <6001>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vdd_arm: DCDC_REG2 { + regulator-name = "vdd_arm"; + regulator-min-microvolt = <950000>; + regulator-max-microvolt = <1350000>; + regulator-ramp-delay = <6001>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vcc_ddr: DCDC_REG3 { + regulator-name = "vcc_ddr"; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + vcc_3v3: DCDC_REG4 { + regulator-name = "vcc_3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_1v8: LDO_REG2 { + regulator-name = "vcc_1v8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1800000>; + }; + }; + + vdd_1v0: LDO_REG3 { + regulator-name = "vdd_1v0"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1000000>; + }; + }; + + vcc3v3_pmu: LDO_REG4 { + regulator-name = "vcc3v3_pmu"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vccio_sd: LDO_REG5 { + regulator-name = "vccio_sd"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1800000>; + }; + }; + + vcc_sd: LDO_REG6 { + regulator-name = "vcc_sd"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3000000>; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vcc_bl: LDO_REG7 { + regulator-name = "vcc_bl"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_lcd: LDO_REG8 { + regulator-name = "vcc_lcd"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <2800000>; + }; + }; + + LDO_REG9 { + /* unused */ + }; + + usb_midu: BOOST { + regulator-name = "usb_midu"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5400000>; + regulator-always-on; + regulator-boot-on; + }; + }; + + rk817_charger: charger { + rockchip,resistor-sense-micro-ohms = <10000>; + rockchip,sleep-enter-current-microamp = <300000>; + rockchip,sleep-filter-current-microamp = <100000>; + }; + + rk817_codec: codec { + rockchip,mic-in-differential; + }; + }; +}; + +&i2s1_2ch { + status = "okay"; +}; + +&io_domains { + vccio1-supply = <&vccio_sd>; + vccio2-supply = <&vccio_sd>; + vccio3-supply = <&vcc_3v3>; + vccio4-supply = <&vcc_3v3>; + vccio5-supply = <&vcc_3v3>; + vccio6-supply = <&vcc_3v3>; + status = "okay"; +}; + +&pmu_io_domains { + pmuio1-supply = <&vcc3v3_pmu>; + pmuio2-supply = <&vcc3v3_pmu>; + status = "okay"; +}; + +&pwm0 { + status = "okay"; +}; + +&pwm1 { + status = "okay"; +}; + +&saradc { + vref-supply = <&vcc_1v8>; + status = "okay"; +}; + +&sdmmc { + bus-width = <4>; + cap-sd-highspeed; + card-detect-delay = <800>; + cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ + disable-wp; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&sdio { + bus-width = <4>; + cap-sd-highspeed; + card-detect-delay = <800>; + cd-gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ + disable-wp; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&tsadc { + status = "okay"; +}; + +&u2phy { + status = "okay"; + + u2phy_host: host-port { + status = "okay"; + }; + + u2phy_otg: otg-port { + status = "disabled"; + }; +}; + +&usb20_otg { + status = "okay"; +}; + +&uart2 { + pinctrl-names = "default"; + pinctrl-0 = <&uart2m1_xfer>; + status = "okay"; +}; + +&vopb { + status = "okay"; +}; + +&vopb_mmu { + status = "okay"; +}; + +&rk817_charger { + monitored-battery = <&battery>; +}; + +&pinctrl { + btns { + btn_pins_vol: btn-pins-vol { + rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + headphone { + hp_det: hp-det { + rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>; + }; + }; + + pmic { + dc_det: dc-det { + rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + pmic_int: pmic-int { + rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + soc_slppin_gpio: soc_slppin_gpio { + rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>; + }; + + soc_slppin_rst: soc_slppin_rst { + rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>; + }; + + soc_slppin_slp: soc_slppin_slp { + rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameforce-chi.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameforce-chi.dts new file mode 100644 index 00000000000..4d306085646 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-gameforce-chi.dts @@ -0,0 +1,811 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024 Chris Morgan + */ + +/dts-v1/; +#include +#include +#include +#include +#include "rk3326.dtsi" + +/ { + model = "GameForce Chi"; + compatible = "gameforce,chi", "rockchip,rk3326"; + chassis-type = "handset"; + + aliases { + mmc0 = &sdmmc; + mmc1 = &sdio; + }; + + chosen { + stdout-path = "serial2:115200n8"; + }; + + adc_joystick: adc-joystick { + compatible = "adc-joystick"; + io-channels = <&saradc 0>, + <&saradc 1>; + poll-interval = <100>; + #address-cells = <1>; + #size-cells = <0>; + + axis@0 { + reg = <0>; + abs-flat = <10>; + abs-fuzz = <10>; + abs-range = <850 175>; + linux,code = ; + }; + + axis@1 { + reg = <1>; + abs-flat = <10>; + abs-fuzz = <10>; + abs-range = <800 190>; + linux,code = ; + }; + }; + + adc_keys: adc-keys { + compatible = "adc-keys"; + io-channels = <&saradc 2>; + io-channel-names = "buttons"; + keyup-threshold-microvolt = <1800000>; + poll-interval = <60>; + + button-1 { + label = "HAPPY1"; + linux,code = ; + press-threshold-microvolt = <15000>; + }; + + button-2 { + label = "HAPPY2"; + linux,code = ; + press-threshold-microvolt = <300000>; + }; + }; + + backlight: backlight { + compatible = "pwm-backlight"; + power-supply = <&vcc_bl>; + pwms = <&pwm1 0 25000 0>; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <3000000>; + charge-term-current-microamp = <300000>; + constant-charge-current-max-microamp = <1500000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4106000 100>, <4071000 95>, <4018000 90>, <3975000 85>, + <3946000 80>, <3908000 75>, <3877000 70>, <3853000 65>, + <3834000 60>, <3816000 55>, <3802000 50>, <3788000 45>, + <3774000 40>, <3760000 35>, <3748000 30>, <3735000 25>, + <3718000 20>, <3697000 15>, <3685000 10>, <3625000 5>, + <3400000 0>; + voltage-max-design-microvolt = <4250000>; + voltage-min-design-microvolt = <3400000>; + }; + + gpio_leds: gpio-leds { + compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&led_pins>; + + red_led: led-0 { + color = ; + gpios = <&gpio3 RK_PC4 GPIO_ACTIVE_HIGH>; + }; + + green_led: led-1 { + color = ; + gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_HIGH>; + }; + + blue_led: led-2 { + color = ; + gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_HIGH>; + }; + + white_led: led-3 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_HIGH>; + }; + + chg_led: led-4 { + color = ; + function = LED_FUNCTION_CHARGING; + gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_HIGH>; + }; + + }; + + gpio_keys: gpio-keys { + compatible = "gpio-keys"; + pinctrl-0 = <&btn_pins_ctrl>; + pinctrl-names = "default"; + + button-a { + gpios = <&gpio2 RK_PB0 GPIO_ACTIVE_LOW>; + label = "EAST"; + linux,code = ; + }; + + button-b { + gpios = <&gpio2 RK_PB1 GPIO_ACTIVE_LOW>; + label = "SOUTH"; + linux,code = ; + }; + + button-down { + gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; + label = "DPAD-DOWN"; + linux,code = ; + }; + + button-home { + gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "HOME"; + linux,code = ; + }; + + button-l1 { + gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; + label = "TL"; + linux,code = ; + }; + + button-l2 { + gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; + label = "TL2"; + linux,code = ; + }; + + button-left { + gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; + label = "DPAD-LEFT"; + linux,code = ; + }; + + button-r1 { + gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; + label = "TR"; + linux,code = ; + }; + + button-r2 { + gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; + label = "TR2"; + linux,code = ; + }; + + button-right { + gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; + label = "DPAD-RIGHT"; + linux,code = ; + }; + + button-select { + gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; + label = "SELECT"; + linux,code = ; + }; + + button-start { + gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; + label = "START"; + linux,code = ; + }; + + button-up { + gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; + label = "DPAD-UP"; + linux,code = ; + }; + + button-x { + gpios = <&gpio2 RK_PB3 GPIO_ACTIVE_LOW>; + label = "NORTH"; + linux,code = ; + }; + + button-y { + gpios = <&gpio2 RK_PB2 GPIO_ACTIVE_LOW>; + label = "WEST"; + linux,code = ; + }; + }; + + multi-led { + compatible = "leds-group-multicolor"; + color = ; + function = LED_FUNCTION_KBD_BACKLIGHT; + leds = <&red_led>, <&green_led>, <&blue_led>; + }; + + spk_amp: audio-amplifier { + compatible = "simple-audio-amplifier"; + enable-gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_HIGH>; + pinctrl-0 = <&spk_amp_enable_h>; + pinctrl-names = "default"; + sound-name-prefix = "Speaker Amp"; + }; + + sound { + compatible = "simple-audio-card"; + pinctrl-0 = <&hp_det>; + pinctrl-names = "default"; + simple-audio-card,name = "rk817_ext"; + simple-audio-card,aux-devs = <&spk_amp>; + simple-audio-card,format = "i2s"; + simple-audio-card,hp-det-gpios = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>; + simple-audio-card,mclk-fs = <256>; + simple-audio-card,widgets = + "Microphone", "Mic Jack", + "Headphone", "Headphones", + "Speaker", "Internal Speakers"; + simple-audio-card,routing = + "MICL", "Mic Jack", + "Headphones", "HPOL", + "Headphones", "HPOR", + "Internal Speakers", "Speaker Amp OUTL", + "Internal Speakers", "Speaker Amp OUTR", + "Speaker Amp INL", "HPOL", + "Speaker Amp INR", "HPOR"; + simple-audio-card,pin-switches = "Internal Speakers"; + + simple-audio-card,codec { + sound-dai = <&rk817>; + }; + + simple-audio-card,cpu { + sound-dai = <&i2s1_2ch>; + }; + }; + + vibrator_left: pwm-vibrator-l { + compatible = "pwm-vibrator"; + pwm-names = "enable"; + pwms = <&pwm4 0 25000 0>; + }; + + vibrator_right: pwm-vibrator-r { + compatible = "pwm-vibrator"; + pwm-names = "enable"; + pwms = <&pwm5 0 25000 0>; + }; + + sdio_pwrseq: sdio-pwrseq { + compatible = "mmc-pwrseq-simple"; + clocks = <&rk817 1>; + clock-names = "ext_clock"; + pinctrl-0 = <&wifi_enable_h>; + pinctrl-names = "default"; + post-power-on-delay-ms = <200>; + reset-gpios = <&gpio0 RK_PA2 GPIO_ACTIVE_LOW>; + }; + + vccsys: regulator-vccsys { + compatible = "regulator-fixed"; + regulator-name = "vcc3v8_sys"; + regulator-always-on; + regulator-min-microvolt = <3800000>; + regulator-max-microvolt = <3800000>; + }; +}; + +&cpu0 { + cpu-supply = <&vdd_arm>; +}; + +&cpu1 { + cpu-supply = <&vdd_arm>; +}; + +&cpu2 { + cpu-supply = <&vdd_arm>; +}; + +&cpu3 { + cpu-supply = <&vdd_arm>; +}; + +&display_subsystem { + status = "okay"; +}; + +&dsi { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + internal_display: panel@0 { + reg = <0>; + compatible = "gameforce,chi-panel"; + backlight = <&backlight>; + iovcc-supply = <&vcc_lcd>; + vcc-supply = <&vcc_lcd>; + reset-gpios = <&gpio3 RK_PA0 GPIO_ACTIVE_LOW>; + + port { + mipi_in_panel: endpoint { + remote-endpoint = <&mipi_out_panel>; + }; + }; + }; + + ports { + mipi_out: port@1 { + reg = <1>; + + mipi_out_panel: endpoint { + remote-endpoint = <&mipi_in_panel>; + }; + }; + }; +}; + +&dsi_dphy { + status = "okay"; +}; + +&gpu { + mali-supply = <&vdd_logic>; + status = "okay"; +}; + +&i2c0 { + clock-frequency = <400000>; + i2c-scl-falling-time-ns = <16>; + i2c-scl-rising-time-ns = <280>; + status = "okay"; + + rk817: pmic@20 { + compatible = "rockchip,rk817"; + reg = <0x20>; + #clock-cells = <1>; + clock-names = "mclk"; + clock-output-names = "rk808-clkout1", "xin32k"; + clocks = <&cru SCLK_I2S1_OUT>; + interrupt-parent = <&gpio0>; + interrupts = ; + pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; + pinctrl-names = "default"; + #sound-dai-cells = <0>; + system-power-controller; + wakeup-source; + + vcc1-supply = <&vccsys>; + vcc2-supply = <&vccsys>; + vcc3-supply = <&vccsys>; + vcc4-supply = <&vccsys>; + vcc5-supply = <&vccsys>; + vcc6-supply = <&vccsys>; + vcc7-supply = <&vcc_3v0>; + vcc8-supply = <&vccsys>; + vcc9-supply = <&dcdc_boost>; + + regulators { + vdd_logic: DCDC_REG1 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <1150000>; + regulator-min-microvolt = <950000>; + regulator-name = "vdd_logic"; + regulator-ramp-delay = <6001>; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vdd_arm: DCDC_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <1350000>; + regulator-min-microvolt = <950000>; + regulator-name = "vdd_arm"; + regulator-ramp-delay = <6001>; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vcc_ddr: DCDC_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-name = "vcc_ddr"; + + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + vcc_3v0: DCDC_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <3000000>; + regulator-min-microvolt = <3000000>; + regulator-name = "vcc_3v0"; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vcc_1v8: LDO_REG2 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <1800000>; + regulator-min-microvolt = <1800000>; + regulator-name = "vcc_1v8"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1800000>; + }; + }; + + vdd_1v0: LDO_REG3 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <1000000>; + regulator-min-microvolt = <1000000>; + regulator-name = "vdd_1v0"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1000000>; + }; + }; + + vcc_3v0_pmu: LDO_REG4 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <3000000>; + regulator-min-microvolt = <3000000>; + regulator-name = "vcc_3v0_pmu"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vccio_sd: LDO_REG5 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <1800000>; + regulator-name = "vccio_sd"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_sd: LDO_REG6 { + regulator-boot-on; + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <3300000>; + regulator-name = "vcc_sd"; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_bl: LDO_REG7 { + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <3300000>; + regulator-name = "vcc_bl"; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_lcd: LDO_REG8 { + regulator-max-microvolt = <2800000>; + regulator-min-microvolt = <2800000>; + regulator-name = "vcc_lcd"; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <2800000>; + }; + }; + + vcc_wifi: LDO_REG9 { + regulator-always-on; + regulator-boot-on; + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <3300000>; + regulator-name = "vcc_wifi"; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + dcdc_boost: BOOST { + regulator-max-microvolt = <5000000>; + regulator-min-microvolt = <5000000>; + regulator-name = "dcdc_boost"; + + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + otg_switch: OTG_SWITCH { + regulator-name = "otg_switch"; + + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + }; + + rk817_charger: charger { + monitored-battery = <&battery>; + rockchip,resistor-sense-micro-ohms = <10000>; + rockchip,sleep-enter-current-microamp = <300000>; + rockchip,sleep-filter-current-microamp = <100000>; + }; + }; +}; + +&i2s1_2ch { + status = "okay"; +}; + +&io_domains { + vccio1-supply = <&vcc_3v0_pmu>; + vccio2-supply = <&vccio_sd>; + vccio3-supply = <&vcc_3v0>; + vccio4-supply = <&vcc_3v0>; + vccio5-supply = <&vcc_3v0>; + vccio6-supply = <&vcc_3v0>; + status = "okay"; +}; + +&pinctrl { + bluetooth-pins { + bt_reset: bt-reset { + rockchip,pins = + <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_down>; + }; + + bt_wake_dev: bt-wake-dev { + rockchip,pins = + <0 RK_PA1 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + bt_wake_host: bt-wake-host { + rockchip,pins = + <0 RK_PA7 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + headphone { + hp_det: hp-det { + rockchip,pins = + <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + gpio-btns { + btn_pins_ctrl: btn-pins-ctrl { + rockchip,pins = + <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PB3 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + gpio-leds { + led_pins: led-pins { + rockchip,pins = + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>, + <3 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>, + <3 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>, + <3 RK_PC5 RK_FUNC_GPIO &pcfg_pull_none>, + <3 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + pmic { + pmic_int: pmic-int { + rockchip,pins = + <0 RK_PC1 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + soc_slppin_gpio: soc_slppin_gpio { + rockchip,pins = + <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>; + }; + + soc_slppin_rst: soc_slppin_rst { + rockchip,pins = + <0 RK_PA4 2 &pcfg_pull_none>; + }; + + soc_slppin_slp: soc_slppin_slp { + rockchip,pins = + <0 RK_PA4 1 &pcfg_pull_none>; + }; + }; + + sdio-pwrseq { + wifi_enable_h: wifi-enable-h { + rockchip,pins = + <0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + speaker { + spk_amp_enable_h: spk-amp-enable-h { + rockchip,pins = + <2 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; + +&pmu_io_domains { + pmuio1-supply = <&vcc_1v8>; + pmuio2-supply = <&vcc_3v0_pmu>; + status = "okay"; +}; + +&pwm1 { + status = "okay"; +}; + +&pwm4 { + status = "okay"; +}; + +&pwm5 { + status = "okay"; +}; + +&saradc { + vref-supply = <&vcc_1v8>; + status = "okay"; +}; + +&sdio { + bus-width = <4>; + cap-sd-highspeed; + cap-sdio-irq; + disable-wp; + keep-power-in-suspend; + mmc-pwrseq = <&sdio_pwrseq>; + no-mmc; + no-sd; + non-removable; + sd-uhs-sdr104; + status = "okay"; +}; + +&sdmmc { + cap-mmc-highspeed; + cap-sd-highspeed; + no-sdio; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&sfc { + #address-cells = <1>; + pinctrl-0 = <&sfc_clk &sfc_cs0 &sfc_bus2>; + pinctrl-names = "default"; + #size-cells = <0>; + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <108000000>; + spi-rx-bus-width = <2>; + spi-tx-bus-width = <1>; + }; +}; + +&tsadc { + status = "okay"; +}; + +&u2phy { + status = "okay"; + + u2phy_otg: otg-port { + status = "okay"; + }; +}; + +&usb20_otg { + status = "okay"; +}; + +/* + * The right ADC joystick exists connected to an unknown ADC + * controller which can be communicated with via uart0. This ADC device + * is an 8-pin SOIC with no markings located right next to the left ADC + * joystick ribbon cable. The pinout for this ADC controller appears to + * be pin 1 - VCC (2.8v), pin 2 - 1.8v (clk maybe?), pin 3 - GPIO 10, + * pin 4 - unknown, pin 5 - unknown, pin 6 - analog in, pin 7 - analog in, + * pin 8 - ground. There is currently a userspace UART driver for this + * device but it only works with the BSP joystick driver. + */ +&uart0 { + status = "okay"; +}; + +/* + * Bluetooth was not working on BSP and is not currently working on + * mainline due to missing firmware. Bluetooth requires removal of DMA + * or else it will not probe. + */ +&uart1 { + /delete-property/ dma-names; + /delete-property/ dmas; + uart-has-rtscts; + status = "okay"; + + bluetooth: bluetooth { + compatible = "realtek,rtl8723ds-bt"; + device-wake-gpios = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>; + enable-gpios = <&gpio0 RK_PA0 GPIO_ACTIVE_HIGH>; + host-wake-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_HIGH>; + pinctrl-0 = <&bt_reset>, <&bt_wake_dev>, <&bt_wake_host>; + pinctrl-names = "default"; + }; +}; + +&uart2 { + pinctrl-0 = <&uart2m1_xfer>; + pinctrl-names = "default"; + status = "okay"; +}; + +&vopb { + status = "okay"; +}; + +&vopb_mmu { + status = "okay"; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-magicx-xu-mini-m.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-magicx-xu-mini-m.dts new file mode 100644 index 00000000000..e857d9d4c87 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-magicx-xu-mini-m.dts @@ -0,0 +1,109 @@ +/// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024-present ROCKNIX (https://github.com/ROCKNIX) + * Copyright (c) 2024 Olivier Schonken + */ + +#include "rk3326-magicx-xu10.dts" + +/ { + model = "MagicX XU Mini M"; + compatible = "magicx,xu-mini-m", "rockchip,rk3326"; +}; + +&battery { + charge-full-design-microamp-hours = <2600000>; +}; + +&dsi { + internal_display: panel@0 { + compatible = "rocknix,generic-dsi"; + panel_description = + "G size=69,139 delays=5,20,20,120,20 format=rgb888 lanes=2 flags=0xe03", + + "M clock=25000 horizontal=480,60,10,54 vertical=640,20,10,20 default=1", + "M clock=25200 horizontal=480,60,22,54 vertical=640,20,139,20", + "M clock=25000 horizontal=480,60,31,54 vertical=640,20,120,20", + "M clock=25660 horizontal=480,60,22,54 vertical=640,20,153,20", + "M clock=25300 horizontal=480,60,31,54 vertical=640,20,24,20", + "M clock=28590 horizontal=480,60,15,54 vertical=640,20,106,20", + "M clock=25380 horizontal=480,60,17,54 vertical=640,20,13,20", + "M clock=25410 horizontal=480,60,11,54 vertical=640,20,20,20", + "M clock=29490 horizontal=480,60,24,54 vertical=640,20,114,20", + "M clock=33520 horizontal=480,60,36,54 vertical=640,20,25,20", + "M clock=38430 horizontal=480,60,16,54 vertical=640,20,20,20", + "M clock=50820 horizontal=480,60,11,54 vertical=640,20,20,20", + + "I seq=ff7701000013", + "I seq=ef08", + "I seq=ff7701000010", + "I seq=c04f00", "I seq=c11002", "I seq=c22002", "I seq=cc10", + "I seq=b006161e0e12060a0809230412102b311f", + "I seq=b1060f160d100704090720051210262f1f", + "I seq=ff7701000011", + "I seq=b065", "I seq=b185", "I seq=b282", "I seq=b380", "I seq=b542", "I seq=b785", + "I seq=b820", + "I seq=c178", "I seq=c278", + "I seq=d088", + "I seq=e0000002", + "I seq=e104a006a005a007a0004444", + "I seq=e2000000000000000000000000", + "I seq=e300002222", + "I seq=e44444", + "I seq=e50c90a0a00e92a0a0088ca0a00a8ea0a0", + "I seq=e600002222", + "I seq=e74444", + "I seq=e80d91a0a00f93a0a0098da0a00b8fa0a0", + "I seq=eb0000e4e4440040", + "I seq=edfff5476f0ba1abffffba1ab0f6745fff", + "I seq=ef080808403f64", + "I seq=ff7701000013", + "I seq=e6167c", "I seq=e8000e", + "I seq=e8000c wait=50", + "I seq=e80000", + "I seq=ff7701000000", + "I seq=11 wait=150", + "I seq=29 wait=120"; + rotation = <90>; + }; +}; + +&joypad { + joypad-name = "XU Mini M Gamepad"; + + invert-absrx; + /delete-property/ invert-absx; + + sw5 { + gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-B"; + }; + sw6 { + gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-A"; + }; + sw7 { + gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-X"; + }; + sw8 { + gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-Y"; + }; + sw16 { + gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; + }; + sw17 { + gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; + }; +}; + +&pinctrl { + headphone { + hp_det: hp-det { + rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>; + }; + }; +}; + + diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-magicx-xu10.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-magicx-xu10.dts new file mode 100644 index 00000000000..3fe532e06d5 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-magicx-xu10.dts @@ -0,0 +1,872 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include +#include +#include +#include +#include "rk3326.dtsi" + +/ { + model = "MagicX XU10"; + compatible = "magicx,xu10", "rockchip,rk3326"; + + aliases { + mmc0 = &sdio; + mmc1 = &sdmmc; + }; + + backlight: backlight { + compatible = "pwm-backlight"; + pwms = <&pwm1 0 25000 0>; + brightness-levels = < + 0 1 2 3 4 5 6 7 + 8 9 10 11 12 13 14 15 + 16 17 18 19 20 21 22 23 + 24 25 26 27 28 29 30 31 + 32 33 34 35 36 37 38 39 + 40 41 42 43 44 45 46 47 + 48 49 50 51 52 53 54 55 + 56 57 58 59 60 61 62 63 + 64 65 66 67 68 69 70 71 + 72 73 74 75 76 77 78 79 + 80 81 82 83 84 85 86 87 + 88 89 90 91 92 93 94 95 + 96 97 98 99 100 101 102 103 + 104 105 106 107 108 109 110 111 + 112 113 114 115 116 117 118 119 + 120 121 122 123 124 125 126 127 + 128 129 130 131 132 133 134 135 + 136 137 138 139 140 141 142 143 + 144 145 146 147 148 149 150 151 + 152 153 154 155 156 157 158 159 + 160 161 162 163 164 165 166 167 + 168 169 170 171 172 173 174 175 + 176 177 178 179 180 181 182 183 + 184 185 186 187 188 189 190 191 + 192 193 194 195 196 197 198 199 + 200 201 202 203 204 205 206 207 + 208 209 210 211 212 213 214 215 + 216 217 218 219 220 221 222 223 + 224 225 226 227 228 229 230 231 + 232 233 234 235 236 237 238 239 + 240 241 242 243 244 245 246 247 + 248 249 250 251 252 253 254 255>; + default-brightness-level = <128>; + }; + + joypad: xu10-joypad { + compatible = "xu10-joypad"; + + joypad-name = "XU10 Gamepad"; + joypad-product = <0x0200>; + joypad-revision = <0x0010>; + + status = "okay"; + /* + - xu10-joypad sysfs list - + * for poll device interval(ms) + /sys/devices/platform/odroidgo3_joypad/poll_interval [rw] + ex) echo 20 > poll_interval + * for button-adc-fuzz + /sys/devices/platform/odroidgo3_joypad/adc_fuzz [r] + * for button-adc-flat + /sys/devices/platform/odroidgo3_joypad/adc_flat [r] + + * for report control(1:enable, 0:disable) + /sys/devices/platform/odroidgo3_joypad/enable [rw] + * for adc calibration value setup(current adcs value -> cal value) + /sys/devices/platform/odroidgo3_joypad/adc_cal [rw] + ex) echo 0 > adc_cal + * for amux data debug + * Joypad driver is disabled when using this sysfs. + /sys/devices/platform/odroidgo3_joypad/amux_debug [rw] + ex) echo 0 > amux_debug --> select amux channel + ex) cat amux_debug --> get adc data of seleted channel + */ + + /* gpio pincontrol setup */ + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + + /* Analog mux define */ + io-channel-names = "joy_left", "joy_right"; + io-channels = <&saradc 1>, <&saradc 2>; + + /* adc mux channel count */ + amux-count = <4>; + + /* adc mux select(a,b) gpio */ + amux-a-gpios = <&gpio2 RK_PB3 GPIO_ACTIVE_LOW>; + amux-b-gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>; + + /* adc mux enable gpio */ + amux-en-gpios = <&gpio1 RK_PB0 GPIO_ACTIVE_LOW>; + + /* adc calculate scale */ + button-adc-scale = <2>; + + /* adc deadzone range */ + button-adc-deadzone = <180>; + + /* + specifies fuzz value that is used to filter noise from + the event stream. + */ + button-adc-fuzz = <32>; + button-adc-flat = <32>; + + /* + Analog Stick data tuning value(precent) + p = positive direction, n = negative direction + report value = (real_adc_data * tuning_value) / 100 + */ + abs_x-p-tuning = <200>; + abs_x-n-tuning = <200>; + + abs_y-p-tuning = <200>; + abs_y-n-tuning = <200>; + + abs_rx-p-tuning = <200>; + abs_rx-n-tuning = <200>; + + abs_ry-p-tuning = <200>; + abs_ry-n-tuning = <200>; + + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + + /* required for XU10 */ + invert-absx; + invert-absy; + + /* gpio button auto repeat set value : default disable */ + /* + autorepeat; + */ + + /* + *** MagicX XU10 - layoout *** + |-------------------------------| + | sw14 sw17 sw16 sw15 | + |-----|-------------------|-----| + | | | | + |vol+ | | sw13| + |vol- | | | + | | LCD Display | | + | | | | + | | | | + | |-------------------| | + | sw9 sw10 | + | | + | sw1 sw7 | + | sw3 sw4 sw8 sw6 | + | sw2 sw5 | + | | + | sw11 sw12 | + | | + |-------|---------------|-------| + */ + + /* + joypad driver is poll-device driver. + poll-device is does not support wakeup-source. + */ + + sw1 { + gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-UP"; + linux,code = ; // 0x220 + }; + sw2 { + gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-DOWN"; + linux,code = ; // 0x221 + }; + sw3 { + gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-LEFT"; + linux,code = ; // 0x222 + }; + sw4 { + gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-RIGHT"; + linux,code = ; // 0x223 + }; + sw5 { + gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-A"; + linux,code = ; // 0x130 + }; + sw6 { + gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-B"; + linux,code = ; // 0x131 + }; + sw7 { + gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-Y"; + linux,code = ; // 0x133 + }; + sw8 { + gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-X"; + linux,code = ; // 0x134 + }; + sw9 { + gpios = <&gpio2 RK_PB0 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-SELECT"; + linux,code = ; // 0x13a + }; + sw10 { + gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-START"; + linux,code = ; // 0x13b + }; + sw11 { + gpios = <&gpio2 RK_PB1 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-THUMBL"; + linux,code = ; // 0x13d + }; + sw12 { + gpios = <&gpio2 RK_PB2 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-THUMBR"; + linux,code = ; // 0x13e + }; + sw13 { + gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-G"; + linux,code = ; // 0x2c0 + }; + sw14 { + gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-LEFT"; + linux,code = ; // 0x136 + }; + sw15 { + gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-RIGHT"; + linux,code = ; // 0x137 + }; + sw16 { + gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-RIGHT2"; + linux,code = ; // 0x139 + }; + sw17 { + gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-LEFT2"; + linux,code = ; // 0x138 + }; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <3000000>; + charge-term-current-microamp = <200000>; + constant-charge-current-max-microamp = <1500000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <100000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3300000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = + <4046950 100>, <4001920 95>, <3967900 90>, <3940000 85>, + <3910000 80>, <3870000 75>, <3830000 70>, <3790000 65>, + <3750000 60>, <3720000 55>, <3690000 50>, <3650000 45>, + <3610000 40>, <3570000 35>, <3540000 30>, <3500000 25>, + <3460000 20>, <3420000 15>, <3380000 10>, <3340000 5>, + <3300000 0>; + }; + + gpio-keys-vol { + compatible = "gpio-keys"; + autorepeat; + pinctrl-0 = <&btn_pins_vol>; + pinctrl-names = "default"; + + button-vol-down { + gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_LOW>; + label = "VOLUMEDOWN"; + linux,code = ; + }; + + button-vol-up { + gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_LOW>; + label = "VOLUMEUP"; + linux,code = ; + }; + }; + + leds: gpio-leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led-0 { + color = ; + default-state = "off"; + function = LED_FUNCTION_CHARGING; + gpios = <&gpio0 RK_PB3 GPIO_ACTIVE_HIGH>; + }; + + led-1 { + color = ; + default-state = "off"; + function = LED_FUNCTION_STATUS; + gpios = <&gpio0 RK_PB4 GPIO_ACTIVE_HIGH>; + }; + }; + + rk817-sound { + compatible = "simple-audio-card"; + pinctrl-names = "default"; + pinctrl-0 = <&hp_det>; + simple-audio-card,name = "rk817_int"; + simple-audio-card,format = "i2s"; + simple-audio-card,hp-det-gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_LOW>; + simple-audio-card,mclk-fs = <256>; + simple-audio-card,widgets = + "Microphone", "Mic Jack", + "Headphone", "Headphones", + "Speaker", "Speaker"; + simple-audio-card,routing = + "MICL", "Mic Jack", + "Headphones", "HPOL", + "Headphones", "HPOR", + "Speaker", "SPKO"; + + simple-audio-card,codec { + sound-dai = <&rk817>; + }; + + simple-audio-card,cpu { + sound-dai = <&i2s1_2ch>; + }; + }; + + vccsys: vccsys { + compatible = "regulator-fixed"; + regulator-name = "vcc3v8_sys"; + regulator-always-on; + regulator-min-microvolt = <3800000>; + regulator-max-microvolt = <3800000>; + }; + + vcc-phy-regulator { + compatible = "regulator-fixed"; + regulator-name = "vcc_phy"; + regulator-always-on; + regulator-boot-on; + }; + + vcc18_lcd0: vcc18-lcd0 { + compatible = "regulator-fixed"; + regulator-name = "vcc18_lcd0_n"; + gpio = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>; + enable-active-high; + pinctrl-0 = <&vcc18_lcd_n>; + pinctrl-names = "default"; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + }; + }; + + vcc_host: vcc_host { + compatible = "regulator-fixed"; + regulator-name = "vcc_host"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-always-on; + regulator-boot-on; + vin-supply = <&usb_midu>; + }; +}; + +&dmc { + center-supply = <&vdd_logic>; +}; + +&cpu0 { + cpu-supply = <&vdd_arm>; +}; + +&cpu1 { + cpu-supply = <&vdd_arm>; +}; + +&cpu2 { + cpu-supply = <&vdd_arm>; +}; + +&cpu3 { + cpu-supply = <&vdd_arm>; +}; + +&cru { + assigned-clocks = <&cru PLL_NPLL>, + <&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>, + <&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>, + <&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>; + + assigned-clock-rates = <1188000000>, + <200000000>, <200000000>, + <150000000>, <150000000>, + <100000000>, <200000000>; +}; + +&display_subsystem { + status = "okay"; +}; + +&dsi { + status = "okay"; + + ports { + mipi_out: port@1 { + reg = <1>; + + mipi_out_panel: endpoint { + remote-endpoint = <&mipi_in_panel>; + }; + }; + }; + + internal_display: panel@0 { + compatible = "magicx,xu10-panel", "sitronix,st7703"; + iovcc-supply = <&vcc18_lcd0>; + vcc-supply = <&vcc18_lcd0>; + reg = <0>; + backlight = <&backlight>; + reset-gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&lcd_rst>; + + port { + mipi_in_panel: endpoint { + remote-endpoint = <&mipi_out_panel>; + }; + }; + }; +}; + +&dsi_dphy { + status = "okay"; +}; + +&gpu { + mali-supply = <&vdd_logic>; + status = "okay"; +}; + +&i2c0 { + clock-frequency = <400000>; + i2c-scl-falling-time-ns = <16>; + i2c-scl-rising-time-ns = <280>; + status = "okay"; + + rk817: pmic@20 { + compatible = "rockchip,rk817"; + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = ; + clock-output-names = "rk808-clkout1", "xin32k"; + clock-names = "mclk"; + clocks = <&cru SCLK_I2S1_OUT>; + pinctrl-names = "default"; + pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; + rockchip,system-power-controller; + wakeup-source; + #clock-cells = <1>; + #sound-dai-cells = <0>; + + vcc1-supply = <&vccsys>; + vcc2-supply = <&vccsys>; + vcc3-supply = <&vccsys>; + vcc4-supply = <&vccsys>; + vcc5-supply = <&vccsys>; + vcc6-supply = <&vccsys>; + vcc7-supply = <&vcc_3v0>; + vcc8-supply = <&vccsys>; + vcc9-supply = <&usb_midu>; + + regulators { + vdd_logic: DCDC_REG1 { + regulator-name = "vdd_logic"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <1150000>; + regulator-ramp-delay = <6001>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vdd_arm: DCDC_REG2 { + regulator-name = "vdd_arm"; + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <1350000>; + regulator-ramp-delay = <6001>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vcc_ddr: DCDC_REG3 { + regulator-name = "vcc_ddr"; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + vcc_3v0: DCDC_REG4 { + regulator-name = "vcc_3v0"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vcc_1v0: LDO_REG1 { + regulator-name = "vcc_1v0"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1000000>; + }; + }; + + vcc1v8_soc: LDO_REG2 { + regulator-name = "vcc1v8_soc"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1800000>; + }; + }; + + vcc1v0_soc: LDO_REG3 { + regulator-name = "vcc1v0_soc"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1000000>; + }; + }; + + vcc3v0_pmu: LDO_REG4 { + regulator-name = "vcc3v0_pmu"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vccio_sd: LDO_REG5 { + regulator-name = "vccio_sd"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_sd: LDO_REG6 { + regulator-name = "vcc_sd"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vcc2v8_dvp: LDO_REG7 { + regulator-name = "vcc2v8_dvp"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <2800000>; + }; + }; + + vcc3v0_dvp: LDO_REG8 { + regulator-name = "vcc3v0_dvp"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3000000>; + }; + }; + + vdd1v5_dvp: LDO_REG9 { + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; + regulator-name = "vdd1v5_dvp"; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <1500000>; + }; + }; + + usb_midu: BOOST { + regulator-name = "usb_midu"; + regulator-min-microvolt = <4700000>; + regulator-max-microvolt = <5400000>; + regulator-always-on; + regulator-boot-on; + }; + + }; + + rk817_charger: charger { + monitored-battery = <&battery>; + rockchip,resistor-sense-micro-ohms = <10000>; + rockchip,sleep-enter-current-microamp = <300000>; + rockchip,sleep-filter-current-microamp = <100000>; + }; + + rk817_codec: codec { + rockchip,mic-in-differential; + }; + }; +}; + +/* I2S 1 Channel Used Header(P2):1(GPIO2.C3),2(.C2), 3(.C1), 4(.C5), 5(.C4) */ +&i2s1_2ch { + status = "okay"; + #sound-dai-cells = <0>; +}; + +&io_domains { + vccio1-supply = <&vcc1v8_soc>; + vccio2-supply = <&vccio_sd>; + vccio3-supply = <&vcc3v0_dvp>; + vccio4-supply = <&vcc_3v0>; + vccio5-supply = <&vcc_3v0>; + vccio6-supply = <&vcc_3v0>; + status = "okay"; +}; + +&isp { + status = "okay"; +}; + +&isp_mmu { + status = "okay"; +}; + +&pmu_io_domains { + pmuio1-supply = <&vcc3v0_pmu>; + pmuio2-supply = <&vcc3v0_pmu>; + status = "okay"; +}; + +&csi_dphy { + status = "okay"; +}; + +&pwm1 { + status = "okay"; +}; + +&saradc { + vref-supply = <&vcc1v8_soc>; + status = "okay"; +}; + +&sdmmc { + cap-sd-highspeed; + card-detect-delay = <200>; + cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; /*[> ff370000 PD_SDCARD CD GPIO <]*/ + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&sdio { + cap-sd-highspeed; + card-detect-delay = <200>; + cd-gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&tsadc { + status = "okay"; +}; + +&u2phy { + status = "okay"; + + u2phy_host: host-port { + status = "okay"; + }; + + u2phy_otg: otg-port { + status = "disabled"; + }; +}; + +/* FIQ Header(P2): 2(RXD:GPIO2.B4),3(TXD:.B6) */ +&uart2 { + pinctrl-names = "default"; + pinctrl-0 = <&uart2m1_xfer>; + status = "okay"; +}; + +&usb20_otg { + status = "okay"; + dr_mode = "host"; +}; + +&vopb { + status = "okay"; +}; + +&vopb_mmu { + status = "okay"; +}; + +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + btn_pins_vol: btn-pins-vol { + rockchip,pins = + <0 RK_PC1 RK_FUNC_GPIO &pcfg_pull_up>, + <0 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + headphone { + hp_det: hp-det { + rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + gpio-lcd { + lcd_rst: lcd-rst { + rockchip,pins = <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + vcc18-lcd { + vcc18_lcd_n: vcc18-lcd-n { + rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + gpio-led { + led_pins: led-pins { + rockchip,pins = + <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>, + <0 RK_PB4 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + pmic { + dc_det: dc-det { + rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + pmic_int: pmic-int { + rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + soc_slppin_gpio: soc_slppin_gpio { + rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>; + }; + + soc_slppin_rst: soc_slppin_rst { + rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>; + }; + + soc_slppin_slp: soc_slppin_slp { + rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go.dtsi b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go.dtsi new file mode 100644 index 00000000000..a65b429c572 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go.dtsi @@ -0,0 +1,568 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include +#include +#include +#include +#include "rk3326.dtsi" + +/ { + aliases { + mmc0 = &sdmmc; + }; + + chosen { + stdout-path = "serial2:115200n8"; + }; + + backlight: backlight { + compatible = "pwm-backlight"; + power-supply = <&vcc_bl>; + pwms = <&pwm1 0 25000 0>; + brightness-levels = < + 0 1 2 3 4 5 6 7 + 8 9 10 11 12 13 14 15 + 16 17 18 19 20 21 22 23 + 24 25 26 27 28 29 30 31 + 32 33 34 35 36 37 38 39 + 40 41 42 43 44 45 46 47 + 48 49 50 51 52 53 54 55 + 56 57 58 59 60 61 62 63 + 64 65 66 67 68 69 70 71 + 72 73 74 75 76 77 78 79 + 80 81 82 83 84 85 86 87 + 88 89 90 91 92 93 94 95 + 96 97 98 99 100 101 102 103 + 104 105 106 107 108 109 110 111 + 112 113 114 115 116 117 118 119 + 120 121 122 123 124 125 126 127 + 128 129 130 131 132 133 134 135 + 136 137 138 139 140 141 142 143 + 144 145 146 147 148 149 150 151 + 152 153 154 155 156 157 158 159 + 160 161 162 163 164 165 166 167 + 168 169 170 171 172 173 174 175 + 176 177 178 179 180 181 182 183 + 184 185 186 187 188 189 190 191 + 192 193 194 195 196 197 198 199 + 200 201 202 203 204 205 206 207 + 208 209 210 211 212 213 214 215 + 216 217 218 219 220 221 222 223 + 224 225 226 227 228 229 230 231 + 232 233 234 235 236 237 238 239 + 240 241 242 243 244 245 246 247 + 248 249 250 251 252 253 254 255>; + default-brightness-level = <128>; + }; + + /* led-1 is wired directly to output of always-on regulator */ + + gpio_led: gpio-leds { + compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&red_led_pin>; + + red_led: led-3 { + color = ; + gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>; + function = LED_FUNCTION_CHARGING; + }; + }; + + pwm_led: led-controller { + compatible = "pwm-leds"; + + blue_led: led-2 { + color = ; + function = LED_FUNCTION_STATUS; + linux,default-trigger = "heartbeat"; + max-brightness = <255>; + pwms = <&pwm3 0 25000 0>; + }; + }; + + rk817-sound { + compatible = "simple-audio-card"; + simple-audio-card,name = "rk817_int"; + simple-audio-card,format = "i2s"; + simple-audio-card,hp-det-gpios = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>; + simple-audio-card,mclk-fs = <256>; + simple-audio-card,widgets = + "Microphone", "Mic Jack", + "Headphone", "Headphones", + "Speaker", "Speaker"; + simple-audio-card,routing = + "MICL", "Mic Jack", + "Headphones", "HPOL", + "Headphones", "HPOR", + "Speaker", "SPKO"; + + simple-audio-card,codec { + sound-dai = <&rk817>; + }; + + simple-audio-card,cpu { + sound-dai = <&i2s1_2ch>; + }; + }; + + vccsys: regulator-vccsys { + compatible = "regulator-fixed"; + regulator-name = "vcc3v8_sys"; + regulator-always-on; + regulator-min-microvolt = <3800000>; + regulator-max-microvolt = <3800000>; + }; + + vcc_host: regulator-vcc-host { + compatible = "regulator-fixed"; + regulator-name = "vcc_host"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + + gpio = <&gpio0 RK_PB7 GPIO_ACTIVE_HIGH>; + enable-active-high; + regulator-always-on; + regulator-boot-on; + vin-supply = <&usb_midu>; + }; +}; + +&dmc { + center-supply = <&vdd_logic>; +}; + +&cpu0 { + cpu-supply = <&vdd_arm>; +}; + +&cpu1 { + cpu-supply = <&vdd_arm>; +}; + +&cpu2 { + cpu-supply = <&vdd_arm>; +}; + +&cpu3 { + cpu-supply = <&vdd_arm>; +}; + +&cru { + assigned-clocks = <&cru PLL_NPLL>, + <&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>, + <&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>, + <&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>; + + assigned-clock-rates = <1188000000>, + <200000000>, <200000000>, + <150000000>, <150000000>, + <100000000>, <200000000>; +}; + +&display_subsystem { + status = "okay"; +}; + +&dsi { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + ports { + mipi_out: port@1 { + reg = <1>; + + mipi_out_panel: endpoint { + remote-endpoint = <&mipi_in_panel>; + }; + }; + }; + + internal_display: panel@0 { + reg = <0>; + backlight = <&backlight>; + reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>; + + port { + mipi_in_panel: endpoint { + remote-endpoint = <&mipi_out_panel>; + }; + }; + }; +}; + +&dsi_dphy { + status = "okay"; +}; + +&gpu { + mali-supply = <&vdd_logic>; + status = "okay"; +}; + +&i2c0 { + clock-frequency = <400000>; + i2c-scl-falling-time-ns = <16>; + i2c-scl-rising-time-ns = <280>; + status = "okay"; + + rk817: pmic@20 { + compatible = "rockchip,rk817"; + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = ; + clock-output-names = "rk808-clkout1", "xin32k"; + clock-names = "mclk"; + clocks = <&cru SCLK_I2S1_OUT>; + pinctrl-names = "default"; + pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; + rockchip,system-power-controller; + wakeup-source; + #clock-cells = <1>; + #sound-dai-cells = <0>; + + vcc1-supply = <&vccsys>; + vcc2-supply = <&vccsys>; + vcc3-supply = <&vccsys>; + vcc4-supply = <&vccsys>; + vcc5-supply = <&vccsys>; + vcc6-supply = <&vccsys>; + vcc7-supply = <&vccsys>; + vcc8-supply = <&vccsys>; + + regulators { + vdd_logic: DCDC_REG1 { + regulator-name = "vdd_logic"; + regulator-min-microvolt = <950000>; + regulator-max-microvolt = <1150000>; + regulator-ramp-delay = <6001>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vdd_arm: DCDC_REG2 { + regulator-name = "vdd_arm"; + regulator-min-microvolt = <950000>; + regulator-max-microvolt = <1350000>; + regulator-ramp-delay = <6001>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <950000>; + }; + }; + + vcc_ddr: DCDC_REG3 { + regulator-name = "vcc_ddr"; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + }; + }; + + vcc_3v3: DCDC_REG4 { + regulator-name = "vcc_3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_1v8: LDO_REG2 { + regulator-name = "vcc_1v8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1800000>; + }; + }; + + vdd_1v0: LDO_REG3 { + regulator-name = "vdd_1v0"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <1000000>; + }; + }; + + vcc3v3_pmu: LDO_REG4 { + regulator-name = "vcc3v3_pmu"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vccio_sd: LDO_REG5 { + regulator-name = "vccio_sd"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_sd: LDO_REG6 { + regulator-name = "vcc_sd"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_bl: LDO_REG7 { + regulator-name = "vcc_bl"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc_lcd: LDO_REG8 { + regulator-name = "vcc_lcd"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <2800000>; + }; + }; + + LDO_REG9 { + /* unused */ + }; + + usb_midu: BOOST { + regulator-name = "usb_midu"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5400000>; + regulator-always-on; + regulator-boot-on; + }; + }; + + rk817_charger: charger { + rockchip,resistor-sense-micro-ohms = <10000>; + rockchip,sleep-enter-current-microamp = <300000>; + rockchip,sleep-filter-current-microamp = <100000>; + }; + + rk817_codec: codec { + rockchip,mic-in-differential; + }; + }; +}; + +/* EXT Header(P2): 7(SCL:GPIO0.C2), 8(SDA:GPIO0.C3) */ +&i2c1 { + clock-frequency = <400000>; + status = "okay"; +}; + +/* I2S 1 Channel Used */ +&i2s1_2ch { + status = "okay"; +}; + +&io_domains { + vccio1-supply = <&vcc_3v3>; + vccio2-supply = <&vccio_sd>; + vccio3-supply = <&vcc_3v3>; + vccio4-supply = <&vcc_3v3>; + vccio5-supply = <&vcc_3v3>; + vccio6-supply = <&vcc_3v3>; + status = "okay"; +}; + +&pmu_io_domains { + pmuio1-supply = <&vcc3v3_pmu>; + pmuio2-supply = <&vcc3v3_pmu>; + status = "okay"; +}; + +&pwm1 { + status = "okay"; +}; + +&pwm3 { + status = "okay"; +}; + +&saradc { + vref-supply = <&vcc_1v8>; + status = "okay"; +}; + +&sdmmc { + cap-sd-highspeed; + card-detect-delay = <200>; + cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&sfc { + pinctrl-0 = <&sfc_clk &sfc_cs0 &sfc_bus2>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <108000000>; + spi-rx-bus-width = <2>; + spi-tx-bus-width = <1>; + }; +}; + +&tsadc { + status = "okay"; +}; + +&u2phy { + status = "okay"; + + u2phy_host: host-port { + status = "okay"; + }; + + u2phy_otg: otg-port { + status = "disabled"; + }; +}; + +&usb20_otg { + status = "okay"; +}; + +/* EXT Header(P2): 2(RXD:GPIO1.C0),3(TXD:.C1),4(CTS:.C2),5(RTS:.C3) */ +&uart1 { + pinctrl-names = "default"; + pinctrl-0 = <&uart1_xfer &uart1_cts>; + status = "okay"; +}; + +&uart2 { + pinctrl-names = "default"; + pinctrl-0 = <&uart2m1_xfer>; + status = "okay"; +}; + +&vopb { + status = "okay"; +}; + +&vopb_mmu { + status = "okay"; +}; + +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + headphone { + hp_det: hp-det { + rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>; + }; + }; + + leds { + red_led_pin: red-led-pin { + rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + pmic { + dc_det: dc-det { + rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>; + }; + + pmic_int: pmic-int { + rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + soc_slppin_gpio: soc_slppin_gpio { + rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>; + }; + + soc_slppin_rst: soc_slppin_rst { + rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>; + }; + + soc_slppin_slp: soc_slppin_slp { + rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go2-v11.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go2-v11.dts new file mode 100644 index 00000000000..58c1054abef --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go2-v11.dts @@ -0,0 +1,235 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include "rk3326-odroid-go.dtsi" +#include "retrogame_joypad_s2_f1.dtsi" + +/ { + model = "ODROID-GO Advance Black Edition"; + compatible = "hardkernel,rk3326-odroid-go2-v11", "rockchip,rk3326"; + + aliases { + mmc1 = &sdio; + }; + + gpio_keys: volume-keys { + compatible = "gpio-keys"; + autorepeat; + pinctrl-0 = <&btn_pins_vol>; + pinctrl-names = "default"; + + volume-up-button { + label = "VOLUMEUP"; + linux,code = ; + gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; + + }; + volume-down-button { + label = "VOLUMEDOWN"; + linux,code = ; + gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; + + }; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <3000000>; + charge-term-current-microamp = <300000>; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3500000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, + <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, + <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, + <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, + <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, + <3574170 0>; + }; + + wifi_pwrseq: wifi-pwrseq { + compatible = "mmc-pwrseq-simple"; + pinctrl-names = "default"; + pinctrl-0 = <&wifi_pwrseq_pins>; + reset-gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; + post-power-on-delay-ms = <300>; + power-off-delay-us = <200000>; + }; +}; + +&joypad { + compatible = "rocknix-joypad"; + joypad-name = "odroidgo2_v11_joypad"; + /* IDs from odroidgo2_v11_joypad */ + joypad-bustype = <0x0019>; /* BUS_HOST */ + joypad-vendor = <0x0001>; + joypad-product = <0x0002>; + joypad-revision = <0x0101>; + status = "okay"; + + /* gpio pincontrol setup */ + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + + /* JOY_X, JOY_Y Channel define */ + io-channel-names = "joy_x", "joy_y"; + io-channels = <&saradc 1>, <&saradc 2>; + abs-left-first; + + /* adc channel count */ + button-adc-count = <2>; + + /* adc calculate scale */ + button-adc-scale = <1>; + + /* adc deadzone range */ + button-adc-deadzone = <20>; + + invert-absx = <1>; + invert-absy = <0>; + + /* + specifies fuzz value that is used to filter noise from + the event stream. + */ + button-adc-fuzz = <32>; + button-adc-flat = <32>; + + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + + /* gpio button auto repeat set value : default disable */ + /* + autorepeat; + */ + + /* + *** ODROIDGO2-Advance Switch layoout *** + |------------------------------------------------| + | sw15 sw16 | + | sw20 sw21 | + |------------------------------------------------| + | sw1 |-------------------| sw8 | + | sw3 sw4 | | sw7 sw5 | + | sw2 | LCD Display | sw6 | + | | | | + | |-------------------| | + | sw9 sw10 vol- vol+ sw13 sw14 | + |------------------------------------------------| + */ + /* + joypad driver is poll-device driver. + poll-device is does not support wakeup-source. + */ + up { gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; }; + down { gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; }; + left { gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; }; + right { gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; }; + + a { gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; }; + b { gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; }; + x { gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; }; + y { gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; }; + + tl { gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; }; + tr { gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; }; + tl2 { gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; }; + tr2 { gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; }; + + select{ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; }; + start { gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; }; + + thumbl{ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; }; + thumbr{ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; }; + + /delete-node/ mode; +}; + +#include "rk3326-panel-elida-kd35t133.dtsi" +&internal_display { + iovcc-supply = <&vcc_lcd>; + vdd-supply = <&vcc_lcd>; + rotation = <270>; +}; + +&rk817 { + regulators { + vcc_wifi: LDO_REG9 { + regulator-name = "vcc_wifi"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + }; +}; + +&rk817_charger { + monitored-battery = <&battery>; +}; + +&sdio { + bus-width = <4>; + cap-sd-highspeed; + cap-sdio-irq; + disable-wp; + keep-power-in-suspend; + non-removable; + vmmc-supply = <&vcc_wifi>; + mmc-pwrseq = <&wifi_pwrseq>; + status = "okay"; + + esp8089: wifi@1 { + compatible = "esp,esp8089"; + reg = <1>; + esp,crystal-26M-en = <1>; + }; +}; + +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; + }; + btn_pins_vol: btn-pins-vol { + rockchip,pins = <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + wifi { + wifi_pwrseq_pins: wifi-pwrseq-pins { + rockchip,pins = <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB6 RK_FUNC_GPIO &pcfg_output_high>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go2.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go2.dts new file mode 100644 index 00000000000..1d149aebf4e --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go2.dts @@ -0,0 +1,235 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include "rk3326-odroid-go.dtsi" + +/ { + model = "ODROID-GO Advance"; + compatible = "hardkernel,rk3326-odroid-go2", "rockchip,rk3326"; + + gpio_keys: volume-keys { + compatible = "gpio-keys-polled"; + poll-interval = <5>; + autorepeat; + + volume-up-button { + label = "VOLUME-UP"; + linux,code = ; + gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; + + }; + volume-down-button { + label = "VOLUME-DOWN"; + linux,code = ; + gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; + + }; + }; + + joypad: odroidgo2-joypad { + compatible = "odroidgo2-joypad"; + + /* + - odroidgo2-joypad sysfs list - + * for poll device interval(ms) + /sys/devices/platform/odroidgo2_joypad/poll_interval [rw] + * for button-adc-fuzz + /sys/devices/platform/odroidgo2_joypad/adc_fuzz [r] + * for button-adc-flat + /sys/devices/platform/odroidgo2_joypad/adc_flat [r] + + * for report control(1:enable, 0:disable) + /sys/devices/platform/odroidgo2_joypad/enable [rw] + * for adc calibration value setup(1:current adcs value -> cal value) + /sys/devices/platform/odroidgo2_joypad/adc_cal [rw] + */ + + /* gpio pincontrol setup */ + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + + /* JOY_X, JOY_Y Channel define */ + io-channel-names = "joy_x", "joy_y"; + io-channels = <&saradc 1>, <&saradc 2>; + + /* adc channel count */ + button-adc-count = <2>; + + /* adc calculate scale */ + button-adc-scale = <2>; + + /* adc deadzone range */ + button-adc-deadzone = <20>; + + /* + joy-stick voltage range + /sys/devices/platform/ff288000.saradc/iio:device0 + adc-x : in_voltage1_raw + adc-y : in_voltage2_raw + + range calculate. + (adc raw max value - adc raw min value) * scale * 1.7515 + */ + button-adc-x-range = <1800>; + button-adc-y-range = <1800>; + + /* + specifies fuzz value that is used to filter noise from + the event stream. + */ + button-adc-fuzz = <32>; + button-adc-flat = <32>; + + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + + /* gpio button auto repeat set value : default disable */ + /* + autorepeat; + */ + + /* + *** ODROIDGO2-Advance Switch layoout *** + |------------------------------------------------| + | sw15 sw16 | + |------------------------------------------------| + | sw1 |-------------------| sw8 | + | sw3 sw4 | | sw7 sw5 | + | sw2 | LCD Display | sw6 | + | | | | + | |-------------------| | + | sw9 sw10 vol- vol+ sw13 sw14 | + |------------------------------------------------| + */ + /* + joypad driver is poll-device driver. + poll-device is does not support wakeup-source. + */ + sw1 { + gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-UP"; + linux,code = ; // 0x220 + }; + sw2 { + gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-DOWN"; + linux,code = ; // 0x221 + }; + sw3 { + gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-LEFT"; + linux,code = ; // 0x222 + }; + sw4 { + gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-RIGHT"; + linux,code = ; // 0x223 + }; + sw5 { + gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; + label = "GPIO KEY BTN-A"; + linux,code = ; // 0x131 + }; + sw6 { + gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-B"; + linux,code = ; // 0x130 + }; + sw7 { + gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-Y"; + linux,code = ; // 0x134 + }; + sw8 { + gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-X"; + linux,code = ; // 0x133 + }; + sw9 { + gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "GPIO F1"; + linux,code = ; // 0x2c0 + }; + sw10 { + gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; + label = "GPIO F2"; + linux,code = ; // 0x2c1 + }; + sw13 { + gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; + label = "GPIO F5"; + linux,code = ; // 0x2c4 + }; + sw14 { + gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; + label = "GPIO F6"; + linux,code = ; // 0x13c + }; + sw15 { + gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-LEFT"; + linux,code = ; // 0x02 + }; + sw16 { + gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-RIGHT"; + linux,code = ; // 0x05 + }; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <3000000>; + charge-term-current-microamp = <300000>; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3500000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, + <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, + <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, + <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, + <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, + <3574170 0>; + }; +}; + +#include "rk3326-panel-elida-kd35t133.dtsi" +&internal_display { + iovcc-supply = <&vcc_lcd>; + vdd-supply = <&vcc_lcd>; + rotation = <270>; +}; + +&rk817_charger { + monitored-battery = <&battery>; +}; + +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go3.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go3.dts new file mode 100644 index 00000000000..c3099f9cfe8 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-odroid-go3.dts @@ -0,0 +1,289 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include "rk3326-odroid-go.dtsi" + +/ { + model = "ODROID-GO Super"; + compatible = "hardkernel,rk3326-odroid-go3", "rockchip,rk3326"; + + joypad: odroidgo3-joypad { + compatible = "odroidgo3-joypad"; + + joypad-name = "odroidgo3_joypad"; + joypad-product = <0x0001>; + joypad-revision = <0x0101>; + + status = "okay"; + /* + - odroidgo3-joypad sysfs list - + * for poll device interval(ms) + /sys/devices/platform/odroidgo3_joypad/poll_interval [rw] + ex) echo 20 > poll_interval + * for button-adc-fuzz + /sys/devices/platform/odroidgo3_joypad/adc_fuzz [r] + * for button-adc-flat + /sys/devices/platform/odroidgo3_joypad/adc_flat [r] + + * for report control(1:enable, 0:disable) + /sys/devices/platform/odroidgo3_joypad/enable [rw] + * for adc calibration value setup(current adcs value -> cal value) + /sys/devices/platform/odroidgo3_joypad/adc_cal [rw] + ex) echo 0 > adc_cal + * for amux data debug + * Joypad driver is disabled when using this sysfs. + /sys/devices/platform/odroidgo3_joypad/amux_debug [rw] + ex) echo 0 > amux_debug --> select amux channel + ex) cat amux_debug --> get adc data of seleted channel + */ + + /* gpio pincontrol setup */ + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + + /* Analog mux define */ + io-channel-names = "amux_adc"; + io-channels = <&saradc 1>; + + /* adc mux channel count */ + amux-count = <4>; + /* adc mux select(a,b) gpio */ + amux-a-gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; + amux-b-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>; + /* adc mux enable gpio */ + amux-en-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; + + /* adc calculate scale */ + button-adc-scale = <2>; + + /* adc deadzone range */ + button-adc-deadzone = <64>; + + /* + specifies fuzz value that is used to filter noise from + the event stream. + */ + button-adc-fuzz = <32>; + button-adc-flat = <32>; + + /* + Analog Stick data tuning value(precent) + p = positive direction, n = negative direction + report value = (real_adc_data * tuning_value) / 100 + */ + abs_x-p-tuning = <180>; + abs_x-n-tuning = <180>; + + abs_y-p-tuning = <180>; + abs_y-n-tuning = <170>; + + abs_rx-p-tuning = <180>; + abs_rx-n-tuning = <180>; + + abs_ry-p-tuning = <180>; + abs_ry-n-tuning = <170>; + + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + + /* gpio button auto repeat set value : default disable */ + /* + autorepeat; + */ + + /* + *** ODROIDGO3-Advance Switch layoout *** + |------------------------------------------------| + | sw15 sw21 sw10 sw9 sw20 sw16 | + |------------------------------------------------| + | sw19 sw22 | + | |-------------------| | + | sw1 | | sw8 | + | sw3 sw4 | | sw7 sw5 | + | sw2 | LCD Display | sw6 | + | | | | + | | | | + | |-------------------| | + | sw11 sw12 | sd-slot | sw13 sw14 | + |-------------------| |------------------| + */ + /* + joypad driver is poll-device driver. + poll-device is does not support wakeup-source. + */ + sw1 { + gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-UP"; + linux,code = ; // 0x220 + }; + sw2 { + gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-DOWN"; + linux,code = ; // 0x221 + }; + sw3 { + gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-LEFT"; + linux,code = ; // 0x222 + }; + sw4 { + gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-RIGHT"; + linux,code = ; // 0x223 + }; + sw5 { + gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; + label = "GPIO KEY BTN-A"; + linux,code = ; // 0x131 + }; + sw6 { + gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-B"; + linux,code = ; // 0x130 + }; + sw7 { + gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-Y"; + linux,code = ; // 0x134 + }; + sw8 { + gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-X"; + linux,code = ; // 0x133 + }; + sw11 { + gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; + label = "GPIO F3"; + linux,code = ; // 0x2c2 + }; + sw12 { + gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; + label = "GPIO F4"; + linux,code = ; // 0x2c3 + }; + sw13 { + gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; + label = "GPIO F5"; + linux,code = ; // 0x2c4 + }; + sw14 { + gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; + label = "GPIO F6"; + linux,code = ; // 0x13c + }; + sw15 { + gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-LEFT"; + linux,code = ; // 0x02 + }; + sw16 { + gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-RIGHT"; + linux,code = ; // 0x05 + }; + sw19 { + gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; + label = "GPIO F1"; + linux,code = ; + }; + sw20 { + gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-RIGHT2"; + linux,code = ; + }; + sw21 { + gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-LEFT2"; + linux,code = ; + }; + sw22 { + gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO F2"; + linux,code = ; + }; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <4000000>; + charge-term-current-microamp = <300000>; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3500000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, + <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, + <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, + <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, + <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, + <3574170 0>; + }; + + gpio-keys-vol { + compatible = "gpio-keys"; + autorepeat; + pinctrl-0 = <&btn_pins_vol>; + pinctrl-names = "default"; + + button-vol-down { + gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; + label = "VOLUMEDOWN"; + linux,code = ; + }; + + button-volume-up { + gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "VOLUMEUP"; + linux,code = ; + }; + }; +}; + +&internal_display { + compatible = "elida,kd50t048a", "sitronix,st7701"; + reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_HIGH>; + IOVCC-supply = <&vcc_lcd>; + VCC-supply = <&vcc_lcd>; + rotation = <270>; +}; + +&rk817_charger { + monitored-battery = <&battery>; +}; + +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; + }; + btn_pins_vol: btn-pins-vol { + rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-panel-elida-kd35t133.dtsi b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-panel-elida-kd35t133.dtsi new file mode 100644 index 00000000000..e7fbff447e0 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-panel-elida-kd35t133.dtsi @@ -0,0 +1,41 @@ +/* + Replacement for in-tree driver panel-elida-kd35t133.c + (compatible = "elida,kd35t133") +*/ + +&dsi { + panel@0 { + compatible = "rocknix,generic-dsi"; + panel_description = + "G size=42,82 delays=2,1,20,120,20 format=rgb888 lanes=1 flags=0xe03", + + "M clock=17000 horizontal=320,130,4,130 vertical=480,2,1,2 default=1", // fps=60.019771 + "M clock=17000 horizontal=320,130,15,130 vertical=480,2,88,2", // fps=49.950050 + "M clock=17010 horizontal=320,130,20,130 vertical=480,2,83,2", // fps=50.000000 + "M clock=17200 horizontal=320,130,12,130 vertical=480,2,97,2", // fps=50.006978 + "M clock=17020 horizontal=320,130,12,130 vertical=480,2,16,2", // fps=57.500000 + "M clock=18500 horizontal=320,130,22,130 vertical=480,2,76,2", // fps=54.876602 + "M clock=19060 horizontal=320,130,29,130 vertical=480,2,40,2", // fps=59.727497 + "M clock=18900 horizontal=320,130,5,130 vertical=480,2,55,2", // fps=59.940060 + "M clock=17460 horizontal=320,130,20,130 vertical=480,2,1,2", // fps=60.000000 + "M clock=19100 horizontal=320,130,30,130 vertical=480,2,37,2", // fps=60.098801 + "M clock=25090 horizontal=320,130,30,130 vertical=480,2,61,2", // fps=75.469995 + "M clock=26190 horizontal=320,130,20,130 vertical=480,2,1,2", // fps=90.000000 + "M clock=34920 horizontal=320,130,20,130 vertical=480,2,1,2", // fps=120.000000 + + "I seq=11 wait=250", + "I seq=e0001318040f063a564d030a06303e0f", + "I seq=e100131801110638344d060d0b31370f", + "I seq=c01817", + "I seq=c141", + "I seq=c5001a80", + "I seq=3648", + "I seq=3a55", + "I seq=b000", "I seq=b1a0", "I seq=b402", + "I seq=b62002", + "I seq=e900", + "I seq=f7a9512c82", + "I seq=21", + "I seq=29 wait=50"; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-powkiddy-rgb10.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-powkiddy-rgb10.dts new file mode 100644 index 00000000000..8d63970967a --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-powkiddy-rgb10.dts @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include "rk3326-odroid-go.dtsi" +#include "retrogame_joypad_s2_f1.dtsi" + +/ { + model = "Powkiddy RGB10"; + compatible = "powkiddy,rk3326-rgb10", "rockchip,rk3326"; + + aliases { + mmc1 = &sdio; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <2800000>; + charge-term-current-microamp = <280000>; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3500000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, + <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, + <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, + <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, + <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, + <3574170 0>; + }; + + wifi_pwrseq: wifi-pwrseq { + compatible = "mmc-pwrseq-simple"; + pinctrl-names = "default"; + pinctrl-0 = <&wifi_pwrseq_pins>; + /*reset-gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>;*/ + }; +}; + +&joypad { + compatible = "rocknix-joypad"; + joypad-name = "odroidgo2_v11_joypad"; + /* IDs from odroidgo2_v11_joypad */ + joypad-bustype = <0x0019>; /* BUS_HOST */ + joypad-vendor = <0x0001>; + joypad-product = <0x0002>; + joypad-revision = <0x0101>; + status = "okay"; + + /* gpio pincontrol setup */ + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + + /* JOY_X, JOY_Y Channel define */ + io-channel-names = "joy_x", "joy_y"; + io-channels = <&saradc 1>, <&saradc 2>; + abs-left-first; + + /* adc channel count */ + button-adc-count = <2>; + + /* adc calculate scale */ + button-adc-scale = <1>; + + /* adc deadzone range */ + button-adc-deadzone = <20>; + + invert-absx = <1>; + invert-absy = <0>; + + /* + specifies fuzz value that is used to filter noise from + the event stream. + */ + button-adc-fuzz = <32>; + button-adc-flat = <32>; + + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + + /* gpio button auto repeat set value : default disable */ + /* + autorepeat; + */ + + /* + *** ODROIDGO2-Advance Switch layoout *** + |------------------------------------------------| + | sw15 sw16 | + | sw20 sw21 | + |------------------------------------------------| + | sw1 |-------------------| sw8 | + | sw3 sw4 | | sw7 sw5 | + | sw2 | LCD Display | sw6 | + | | | | + | |-------------------| | + | sw9 sw10 vol- vol+ sw13 sw14 | + |------------------------------------------------| + */ + /* + joypad driver is poll-device driver. + poll-device is does not support wakeup-source. + */ + up { gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; }; + down { gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; }; + left { gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; }; + right { gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; }; + + a { gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; }; + b { gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; }; + x { gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; }; + y { gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; }; + + tl { gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; }; + tr { gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; }; + tl2 { gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; }; + tr2 { gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; }; + + select{ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; }; + start { gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; }; + + thumbl{ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; }; + thumbr{ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; }; + + /delete-node/ mode; +}; + +#include "rk3326-panel-elida-kd35t133.dtsi" +&internal_display { + iovcc-supply = <&vcc_lcd>; + vdd-supply = <&vcc_lcd>; + rotation = <270>; +}; + +&rk817 { + regulators { + vcc_wifi: LDO_REG9 { + regulator-name = "vcc_wifi"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; + regulator-suspend-microvolt = <3300000>; + }; + }; + }; +}; + +&rk817_charger { + monitored-battery = <&battery>; +}; + +&sdio { + bus-width = <4>; + cap-sd-highspeed; + cap-sdio-irq; + disable-wp; + keep-power-in-suspend; + non-removable; + vmmc-supply = <&vcc_wifi>; + status = "okay"; + + esp8089: wifi@1 { + compatible = "esp,esp8089"; + reg = <1>; + esp,crystal-26M-en = <2>; + }; +}; + +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; + + wifi { + wifi_pwrseq_pins: wifi-pwrseq-pins { + rockchip,pins = /*<3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>,*/ + <3 RK_PB6 RK_FUNC_GPIO &pcfg_output_high>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-powkiddy-rgb10x.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-powkiddy-rgb10x.dts new file mode 100644 index 00000000000..3e50071189e --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-powkiddy-rgb10x.dts @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024 ROCKNIX + */ + +/dts-v1/; +#include "rk3326-odroid-go.dtsi" +#include "retrogame_joypad_s2_f1.dtsi" + +/ { + model = "Powkiddy RGB10X"; + compatible = "powkiddy,rk3326-rgb10x", "rockchip,rk3326"; + + aliases { + mmc1 = &sdio; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <2800000>; + charge-term-current-microamp = <280000>; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3500000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, + <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, + <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, + <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, + <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, + <3574170 0>; + }; + + gpio-keys-vol { + compatible = "gpio-keys"; + autorepeat; + pinctrl-0 = <&btn_pins_vol>; + pinctrl-names = "default"; + + button-vol-down { + gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; + label = "VOLUMEDOWN"; + linux,code = ; + }; + + button-volume-up { + gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "VOLUMEUP"; + linux,code = ; + }; + }; +}; + +&joypad { + compatible = "rocknix-singleadc-joypad"; + joypad-name = "retrogame_joypad_s1_f2"; /* distinct name to indicate there is 1 stick and 2 fn buttons */ + joypad-product = <0x1112>; /* 11 inherited, 1 for number of sticks, 2 for number of FN */ + status = "okay"; + + /* gpio pincontrol setup */ + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + + /* Analog mux define */ + io-channel-names = "amux_adc"; + io-channels = <&saradc 1>; + + /* adc mux channel count */ + /* despite there is only left stick, amux-count needs to be 4, */ + /* because amux 0 and 1 are hardcoded as RX and RY in the driver */ + amux-count = <4>; + /* adc mux select(a,b) gpio */ + amux-a-gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; + amux-b-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>; + /* adc mux enable gpio */ + amux-en-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; + + /* + Analog Stick data tuning value(precent) + p = positive direction, n = negative direction + report value = (real_adc_data * tuning_value) / 100 + */ + abs_x-p-tuning = <200>; + abs_x-n-tuning = <200>; + + abs_y-p-tuning = <200>; + abs_y-n-tuning = <200>; + + abs_rx-p-tuning = <200>; + abs_rx-n-tuning = <200>; + + abs_ry-p-tuning = <200>; + abs_ry-n-tuning = <200>; + + /* required for RGB10X */ + invert-absx; + invert-absy; + + /* + joypad driver is poll-device driver. + poll-device is does not support wakeup-source. + */ + up { gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; }; + down { gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; }; + left { gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; }; + right { gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; }; + + a { gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; }; + b { gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; }; + x { gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; }; + y { gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; }; + + tl { gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; }; + tr { gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; }; + tr2 { gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; }; + tl2 { gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; }; + + select{ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; }; + start { gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; }; + + thumbl{ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; }; + + /* Plus and Minus face buttons are mapped to mode and thumbr */ + mode { + gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; + label = "GPIO MINUS"; + }; + thumbr { + gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; + label = "GPIO PLUS"; + }; +}; + +&internal_display { + compatible = "powkiddy,rk2023-panel", "newvision,nv3051d"; + vdd-supply = <&vcc_lcd>; +}; + +&io_domains { + vccio1-supply = <&vccio_sd>; +}; + +/delete-node/ &pwm3; +/delete-node/ &pwm_led; + +&red_led { + gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_HIGH>; +}; + +&red_led_pin { + rockchip,pins = <2 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; +}; + +&rk817_charger { + monitored-battery = <&battery>; +}; + +&sdio { + cap-sd-highspeed; + card-detect-delay = <200>; + cd-gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&vcc_sd { + regulator-max-microvolt = <3000000>; + regulator-min-microvolt = <1800000>; +}; + +&vccio_sd { + regulator-max-microvolt = <1800000>; +}; + +&pinctrl { + btns { + btn_pins: btn-pins { + rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; + }; + btn_pins_vol: btn-pins-vol { + rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-powkiddy-rgb20s.dts b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-powkiddy-rgb20s.dts new file mode 100644 index 00000000000..cf507db957e --- /dev/null +++ b/projects/ROCKNIX/devices/RK3326/linux/dts/rockchip/rk3326-powkiddy-rgb20s.dts @@ -0,0 +1,340 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Hardkernel Co., Ltd + * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH + * Copyright (c) 2022 Maya Matuszczyk + */ + +/dts-v1/; +#include "rk3326-odroid-go.dtsi" + +/ { + model = "Powkiddy RGB20S"; + compatible = "powkiddy,rgb20s", "rockchip,rk3326"; + + aliases { + mmc0 = &sdio; + mmc1 = &sdmmc; + }; + + gpio-keys-vol { + compatible = "gpio-keys"; + autorepeat; + pinctrl-0 = <&btn_pins_vol>; + pinctrl-names = "default"; + + button-vol-down { + gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; + label = "VOLUMEDOWN"; + linux,code = ; + }; + + button-volume-up { + gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; + label = "VOLUMEUP"; + linux,code = ; + }; + }; + + joypad: rgb20s-joypad { + compatible = "rgb20s-joypad"; + + pwms = <&pwm0 0 200000000 0>; + pwm-names = "enable"; + rumble-boost-weak = <0x0000>; + rumble-boost-strong = <0x0000>; + + joypad-name = "RGB20S Gamepad"; + joypad-product = <0x1177>; + joypad-revision = <0x0177>; + + status = "okay"; + /* + - odroidgo3-joypad sysfs list - + * for poll device interval(ms) + /sys/devices/platform/odroidgo3_joypad/poll_interval [rw] + ex) echo 20 > poll_interval + * for button-adc-fuzz + /sys/devices/platform/odroidgo3_joypad/adc_fuzz [r] + * for button-adc-flat + /sys/devices/platform/odroidgo3_joypad/adc_flat [r] + + * for report control(1:enable, 0:disable) + /sys/devices/platform/odroidgo3_joypad/enable [rw] + * for adc calibration value setup(current adcs value -> cal value) + /sys/devices/platform/odroidgo3_joypad/adc_cal [rw] + ex) echo 0 > adc_cal + + * for rumble period(ns) + /sys/devices/platform/odroidgo3_joypad/rumble_period + ex) echo 20000000 > rumble_duty_cycle + ex) cat rumble_duty_cycle -->get current duty cycle + + * for rumble boost(0~65535) + /sys/devices/platform/odroidgo3_joypad/rumble_boost_weak + /sys/devices/platform/odroidgo3_joypad/rumble_boost_strong + + * for amux data debug + * Joypad driver is disabled when using this sysfs. + /sys/devices/platform/odroidgo3_joypad/amux_debug [rw] + ex) echo 0 > amux_debug --> select amux channel + ex) cat amux_debug --> get adc data of seleted channel + */ + + /* gpio pincontrol setup */ + pinctrl-names = "default"; + pinctrl-0 = <&btn_pins>; + pinctrl-1 = <&pwm0_pin>; + + /* Analog mux define */ + io-channel-names = "amux_adc"; + io-channels = <&saradc 1>; + + /* adc mux channel count */ + amux-count = <4>; + /* adc mux select(a,b) gpio */ + amux-a-gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; + amux-b-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>; + /* adc mux enable gpio */ + amux-en-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; + + /* adc calculate scale */ + button-adc-scale = <2>; + + /* adc deadzone range */ + button-adc-deadzone = <64>; + + /* + specifies fuzz value that is used to filter noise from + the event stream. + */ + button-adc-fuzz = <32>; + button-adc-flat = <32>; + + /* + Analog Stick data tuning value(precent) + p = positive direction, n = negative direction + report value = (real_adc_data * tuning_value) / 100 + */ + abs_x-p-tuning = <200>; + abs_x-n-tuning = <200>; + + abs_y-p-tuning = <200>; + abs_y-n-tuning = <200>; + + abs_rx-p-tuning = <200>; + abs_rx-n-tuning = <200>; + + abs_ry-p-tuning = <200>; + abs_ry-n-tuning = <200>; + + /* poll device interval (ms), adc read interval */ + poll-interval = <10>; + + /* required for RG351MP */ + invert-absx; + invert-absy; + + /* gpio button auto repeat set value : default disable */ + /* + autorepeat; + */ + + /* + joypad driver is poll-device driver. + poll-device is does not support wakeup-source. + */ + sw1 { + gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-UP"; + linux,code = ; // 0x220 + }; + sw2 { + gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-DOWN"; + linux,code = ; // 0x221 + }; + sw3 { + gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-LEFT"; + linux,code = ; // 0x222 + }; + sw4 { + gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; + label = "GPIO DPAD-RIGHT"; + linux,code = ; // 0x223 + }; + sw5 { + gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; + label = "GPIO KEY BTN-A"; + linux,code = ; // 0x131 + }; + sw6 { + gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-B"; + linux,code = ; // 0x130 + }; + sw7 { + gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-Y"; + linux,code = ; // 0x134 + }; + sw8 { + gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; + label = "GPIO BTN-X"; + linux,code = ; // 0x133 + }; + sw11 { + gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; + label = "GPIO F3"; + linux,code = ; // 0x2c2 + }; + sw12 { + gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; + label = "GPIO F4"; + linux,code = ; // 0x2c3 + }; + /*sw13 { + gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; + label = "GPIO F5"; + linux,code = ; // 0x2c4 + }; + sw14 { + gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; + label = "GPIO F6"; + linux,code = ; // 0x13c + };*/ + sw15 { + gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-LEFT"; + linux,code = ; // 0x02 + }; + sw16 { + gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-RIGHT"; + linux,code = ; // 0x05 + }; + sw19 { + gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; + label = "GPIO F1"; + linux,code = ; + }; + sw20 { + gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-RIGHT2"; + linux,code = ; + }; + sw21 { + gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; + label = "GPIO TOP-LEFT2"; + linux,code = ; + }; + sw22 { + gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; + label = "GPIO F2"; + linux,code = ; + }; + }; + + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <3500000>; + charge-term-current-microamp = <350000>; + constant-charge-current-max-microamp = <2000000>; + constant-charge-voltage-max-microvolt = <4200000>; + factory-internal-resistance-micro-ohms = <180000>; + voltage-max-design-microvolt = <4100000>; + voltage-min-design-microvolt = <3500000>; + + ocv-capacity-celsius = <20>; + ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, + <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, + <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, + <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, + <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, + <3574170 0>; + }; +}; + +/* conflicts with pwm vibration motor */ +/delete-node/ &vcc_host; + +/* Device only has 1 LED compared to Odroid Go Advance */ +/delete-node/ &gpio_led; + +&internal_display { +// compatible = "anbernic,rg351v-panel", "newvision,nv3051d"; + compatible = "powkiddy,rk2023-panel", "newvision,nv3051d"; + iovcc-supply = <&vcc_lcd>; + vdd-supply = <&vcc_lcd>; +}; + +&io_domains { + vccio1-supply = <&vccio_sd>; +}; + +/delete-node/ &pwm_led; + +&pwm0 { + status = "okay"; +}; + +/delete-node/ &pwm3; + +&rk817_charger { + /* This device does not have a current sense resistor */ + rockchip,resistor-sense-micro-ohms = <0>; + monitored-battery = <&battery>; +}; + +&sdio { + cap-sd-highspeed; + card-detect-delay = <200>; + cd-gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; + vmmc-supply = <&vcc_sd>; + vqmmc-supply = <&vccio_sd>; + status = "okay"; +}; + +&vcc_sd { + regulator-max-microvolt = <3000000>; + regulator-min-microvolt = <1800000>; +}; + +&vccio_sd { + regulator-max-microvolt = <1800000>; +}; + +&pinctrl { + btns { + btn_pins_vol: btn-pins-vol { + rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; + }; + + btn_pins: btn-pins { + rockchip,pins = <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, + <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, + <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; + }; + }; +}; diff --git a/projects/ROCKNIX/devices/RK3326/linux/linux.aarch64.conf b/projects/ROCKNIX/devices/RK3326/linux/linux.aarch64.conf index 092ab46619c..d1d290be615 100644 --- a/projects/ROCKNIX/devices/RK3326/linux/linux.aarch64.conf +++ b/projects/ROCKNIX/devices/RK3326/linux/linux.aarch64.conf @@ -2074,20 +2074,40 @@ CONFIG_RTL8XXXU=m CONFIG_RTW88=m CONFIG_RTW88_CORE=m CONFIG_RTW88_SDIO=m +CONFIG_RTW88_USB=m +CONFIG_RTW88_8822B=m +CONFIG_RTW88_8822C=m CONFIG_RTW88_8723X=m +CONFIG_RTW88_8703B=m CONFIG_RTW88_8723D=m -# CONFIG_RTW88_8822BS is not set -# CONFIG_RTW88_8822BU is not set -# CONFIG_RTW88_8822CS is not set -# CONFIG_RTW88_8822CU is not set +CONFIG_RTW88_8821C=m +CONFIG_RTW88_88XXA=m +CONFIG_RTW88_8821A=m +CONFIG_RTW88_8812A=m +CONFIG_RTW88_8822BS=m +CONFIG_RTW88_8822BU=m +CONFIG_RTW88_8822CS=m +CONFIG_RTW88_8822CU=m CONFIG_RTW88_8723DS=m -# CONFIG_RTW88_8723CS is not set -# CONFIG_RTW88_8723DU is not set -# CONFIG_RTW88_8821CS is not set -# CONFIG_RTW88_8821CU is not set +CONFIG_RTW88_8723CS=m +CONFIG_RTW88_8723DU=m +CONFIG_RTW88_8821CS=m +CONFIG_RTW88_8821CU=m +CONFIG_RTW88_8821AU=m +CONFIG_RTW88_8812AU=m +CONFIG_RTW88_8814AU=m # CONFIG_RTW88_DEBUG is not set # CONFIG_RTW88_DEBUGFS is not set +CONFIG_RTW88_LEDS=y CONFIG_RTW89=m +CONFIG_RTW89_CORE=m +CONFIG_RTW89_USB=m +CONFIG_RTW89_8851B=m +CONFIG_RTW89_8852B_COMMON=m +CONFIG_RTW89_8852B=m +CONFIG_RTW89_8851BU=m +CONFIG_RTW89_8852BU=m +# CONFIG_RTW89_DEBUGMSG is not set CONFIG_WLAN_VENDOR_RSI=y # CONFIG_RSI_91X is not set CONFIG_WLAN_VENDOR_SILABS=y @@ -5080,7 +5100,6 @@ CONFIG_DEVFREQ_GOV_PASSIVE=y # DEVFREQ Drivers # CONFIG_ARM_RK3399_DMC_DEVFREQ=y -# CONFIG_ARM_ROCKCHIP_BUS_DEVFREQ is not set CONFIG_PM_DEVFREQ_EVENT=y CONFIG_DEVFREQ_EVENT_ROCKCHIP_DFI=y CONFIG_EXTCON=y diff --git a/projects/ROCKNIX/devices/RK3326/options b/projects/ROCKNIX/devices/RK3326/options index 3a3856d8614..34272ff4394 100644 --- a/projects/ROCKNIX/devices/RK3326/options +++ b/projects/ROCKNIX/devices/RK3326/options @@ -58,7 +58,7 @@ # for a list of additional drivers see packages/linux-drivers # Space separated list is supported, # e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2" - ADDITIONAL_DRIVERS="RTL8812AU RTL8814AU RTL8821AU RTL8821CU RTL88x2BU RTL8851BU mali-bifrost" + ADDITIONAL_DRIVERS="mali-bifrost" # Additional Firmware to use ( ) # Space separated list is supported, diff --git a/projects/ROCKNIX/devices/RK3326/patches/linux/000-rk3326-dts.patch b/projects/ROCKNIX/devices/RK3326/patches/linux/000-rk3326-dts.patch index 63ba5da2b32..5d3e38f1ee8 100644 --- a/projects/ROCKNIX/devices/RK3326/patches/linux/000-rk3326-dts.patch +++ b/projects/ROCKNIX/devices/RK3326/patches/linux/000-rk3326-dts.patch @@ -133,3595 +133,3 @@ index 9137dd76e72c..882b91d8468d 100644 }; vpu: video-codec@ff442000 { -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts b/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts -index f4d20f29c1b4..c12bb7994441 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts -+++ b/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts -@@ -6,16 +6,53 @@ - */ - - /dts-v1/; --#include "rk3326-anbernic-rg351m.dtsi" -+#include "rk3326-odroid-go.dtsi" - - / { - model = "Anbernic RG351M"; - compatible = "anbernic,rg351m", "rockchip,rk3326"; -+ -+ battery: battery { -+ compatible = "simple-battery"; -+ charge-full-design-microamp-hours = <3500000>; -+ charge-term-current-microamp = <350000>; -+ constant-charge-current-max-microamp = <2000000>; -+ constant-charge-voltage-max-microvolt = <4200000>; -+ factory-internal-resistance-micro-ohms = <180000>; -+ voltage-max-design-microvolt = <4100000>; -+ voltage-min-design-microvolt = <3500000>; -+ -+ ocv-capacity-celsius = <20>; -+ ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, -+ <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, -+ <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, -+ <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, -+ <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, -+ <3574170 0>; -+ }; -+ -+ vibrator { -+ compatible = "pwm-vibrator"; -+ pwms = <&pwm0 0 1000000 0>; -+ pwm-names = "enable"; -+ }; - }; - -+/delete-node/ &vcc_host; /* conflicts with pwm vibration motor */ -+ - &internal_display { - compatible = "elida,kd35t133"; - iovcc-supply = <&vcc_lcd>; -- rotation = <270>; - vdd-supply = <&vcc_lcd>; -+ rotation = <270>; -+}; -+ -+&pwm0 { -+ status = "okay"; -+}; -+ -+&rk817_charger { -+ /* This device does not have a current sense resistor */ -+ //rockchip,resistor-sense-micro-ohms = <0>; -+ monitored-battery = <&battery>; - }; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts b/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts -index c79f7a7b38cb..26658a37f4e3 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts -+++ b/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts -@@ -1,32 +1,76 @@ - // SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * Copyright (c) 2019 Hardkernel Co., Ltd -+ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH -+ * Copyright (c) 2022 Maya Matuszczyk -+ */ - - /dts-v1/; --#include "rk3326-anbernic-rg351m.dtsi" -+#include "rk3326-odroid-go.dtsi" - - / { - model = "Anbernic RG351V"; - compatible = "anbernic,rg351v", "rockchip,rk3326"; - -- gpio_keys_vol: gpio-keys-vol { -- compatible = "gpio-keys"; -- autorepeat; -- -- button-vol-down { -- gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -- label = "VOLUMEDOWN"; -- linux,code = ; -- }; -- -- button-vol-up { -- gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -- label = "VOLUMEUP"; -- linux,code = ; -- }; -+ aliases { -+ mmc0 = &sdio; -+ mmc1 = &sdmmc; -+ }; -+ -+ gpio-keys-vol { -+ compatible = "gpio-keys"; -+ autorepeat; -+ pinctrl-0 = <&btn_pins_vol>; -+ pinctrl-names = "default"; -+ -+ button-vol-down { -+ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEDOWN"; -+ linux,code = ; -+ }; -+ -+ button-volume-up { -+ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEUP"; -+ linux,code = ; -+ }; -+ }; -+ -+ battery: battery { -+ compatible = "simple-battery"; -+ charge-full-design-microamp-hours = <3500000>; -+ charge-term-current-microamp = <350000>; -+ constant-charge-current-max-microamp = <2000000>; -+ constant-charge-voltage-max-microvolt = <4200000>; -+ factory-internal-resistance-micro-ohms = <180000>; -+ voltage-max-design-microvolt = <4100000>; -+ voltage-min-design-microvolt = <3500000>; -+ -+ ocv-capacity-celsius = <20>; -+ ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, -+ <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, -+ <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, -+ <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, -+ <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, -+ <3574170 0>; -+ }; -+ -+ vibrator { -+ compatible = "pwm-vibrator"; -+ pwms = <&pwm0 0 1000000 0>; -+ pwm-names = "enable"; - }; - }; - -+/* conflicts with pwm vibration motor */ -+/delete-node/ &vcc_host; -+ -+/* Device only has 1 LED compared to Odroid Go Advance */ -+/delete-node/ &gpio_led; -+ - &internal_display { - compatible = "anbernic,rg351v-panel", "newvision,nv3051d"; -+ iovcc-supply = <&vcc_lcd>; - vdd-supply = <&vcc_lcd>; - }; - -@@ -34,6 +78,33 @@ &io_domains { - vccio1-supply = <&vccio_sd>; - }; - -+/delete-node/ &pwm_led; -+ -+&pwm0 { -+ status = "okay"; -+}; -+ -+/delete-node/ &pwm3; -+ -+&rk817_charger { -+ /* This device does not have a current sense resistor */ -+ rockchip,resistor-sense-micro-ohms = <0>; -+ monitored-battery = <&battery>; -+}; -+ -+&sdio { -+ cap-sd-highspeed; -+ card-detect-delay = <200>; -+ cd-gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ -+ sd-uhs-sdr12; -+ sd-uhs-sdr25; -+ sd-uhs-sdr50; -+ sd-uhs-sdr104; -+ vmmc-supply = <&vcc_sd>; -+ vqmmc-supply = <&vccio_sd>; -+ status = "okay"; -+}; -+ - &vcc_sd { - regulator-max-microvolt = <3000000>; - regulator-min-microvolt = <1800000>; -@@ -42,3 +113,12 @@ &vcc_sd { - &vccio_sd { - regulator-max-microvolt = <1800000>; - }; -+ -+&pinctrl { -+ btns { -+ btn_pins_vol: btn-pins-vol { -+ rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ }; -+}; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r33s.dts b/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r33s.dts -new file mode 100644 -index 000000000000..3bef2baf90a4 ---- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r33s.dts -@@ -0,0 +1,124 @@ -+// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * # Copyright (C) 2022-24 JELOS (https://github.com/JustEnoughLinuxOS) -+ */ -+ -+/dts-v1/; -+#include "rk3326-gameconsole-r3xs.dtsi" -+ -+/ { -+ model = "Game Console R33S"; -+ compatible = "gameconsole,r33s", "rockchip,rk3326"; -+ -+ builtin_gamepad: r33s_joypad { -+ compatible = "rocknix-singleadc-joypad"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; -+ joypad-name = "r33s_joypad"; -+ joypad-product = <0x0AA2>; -+ joypad-revision = <0x0100>; -+ joypad-vendor = <0x0001>; -+ -+ status = "okay"; -+ amux-count = <0>; -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ pwms = <&pwm0 0 1000000000 0>; -+ pwm-names = "enable"; -+ rumble-boost-weak = <0x0000>; -+ rumble-boost-strong = <0x0000>; -+ -+ button-sw1 { -+ gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "DPAD-UP"; -+ linux,code = ; -+ }; -+ button-sw2 { -+ gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "DPAD-DOWN"; -+ linux,code = ; -+ }; -+ button-sw3 { -+ gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "DPAD-LEFT"; -+ linux,code = ; -+ }; -+ button-sw4 { -+ gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "DPAD-RIGHT"; -+ linux,code = ; -+ }; -+ button-sw5 { -+ gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "BTN-A"; -+ linux,code = ; -+ }; -+ button-sw6 { -+ gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "BTN-B"; -+ linux,code = ; -+ }; -+ button-sw7 { -+ gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "BTN-Y"; -+ linux,code = ; -+ }; -+ button-sw8 { -+ gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "BTN-X"; -+ linux,code = ; -+ }; -+ button-sw9 { -+ gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "TOP-LEFT"; -+ linux,code = ; -+ }; -+ button-sw10 { -+ gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "TOP-RIGHT"; -+ linux,code = ; -+ }; -+ button-sw11 { -+ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; -+ label = "SELECT"; -+ linux,code = ; -+ }; -+ button-sw12 { -+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "TOP-RIGHT 2"; -+ linux,code = ; -+ }; -+ button-sw13 { -+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -+ label = "TOP-LEFT 2"; -+ linux,code = ; -+ }; -+ button-sw14 { -+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "START"; -+ linux,code = ; -+ }; -+ }; -+}; -+ -+&pinctrl { -+ btns { -+ btn_pins: btn-pins { -+ rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ -+ }; -+}; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36s.dts b/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36s.dts -new file mode 100644 -index 000000000000..45ce50896267 ---- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36s.dts -@@ -0,0 +1,202 @@ -+// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * # Copyright (C) 2022-24 JELOS (https://github.com/JustEnoughLinuxOS) -+ */ -+ -+/dts-v1/; -+#include "rk3326-gameconsole-r3xs.dtsi" -+ -+/ { -+ model = "Game Console R36S"; -+ compatible = "gameconsole,r35s", "gameconsole,r36s", "rockchip,rk3326"; -+ -+ joypad: odroidgo3-joypad { -+ compatible = "odroidgo3-joypad"; -+ pwms = <&pwm0 0 200000000 0>; -+ pwm-names = "enable"; -+ rumble-boost-weak = <0x0000>; -+ rumble-boost-strong = <0x0000>; -+ -+ joypad-name = "r36s_Gamepad"; -+ joypad-product = <0x1188>; -+ joypad-revision = <0x0188>; -+ -+ status = "okay"; -+ -+ /* gpio pincontrol setup */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; -+ pinctrl-1 = <&pwm0_pin>; -+ -+ /* Analog mux define */ -+ io-channel-names = "amux_adc"; -+ io-channels = <&saradc 1>; -+ -+ /* adc mux channel count */ -+ amux-count = <4>; -+ /* adc mux select(a,b) gpio */ -+ amux-a-gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; -+ amux-b-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>; -+ /* adc mux enable gpio */ -+ amux-en-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; -+ -+ /* adc calculate scale */ -+ button-adc-scale = <2>; -+ -+ /* adc deadzone range */ -+ button-adc-deadzone = <64>; -+ -+ /* -+ specifies fuzz value that is used to filter noise from -+ the event stream. -+ */ -+ button-adc-fuzz = <32>; -+ button-adc-flat = <32>; -+ -+ /* -+ Analog Stick data tuning value(precent) -+ p = positive direction, n = negative direction -+ report value = (real_adc_data * tuning_value) / 100 -+ */ -+ abs_x-p-tuning = <200>; -+ abs_x-n-tuning = <200>; -+ -+ abs_y-p-tuning = <200>; -+ abs_y-n-tuning = <200>; -+ -+ abs_rx-p-tuning = <200>; -+ abs_rx-n-tuning = <200>; -+ -+ abs_ry-p-tuning = <200>; -+ abs_ry-n-tuning = <200>; -+ -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ -+ /* required for RG36S */ -+ invert-absx; -+ invert-absy; -+ -+ /* gpio button auto repeat set value : default disable */ -+ /* -+ autorepeat; -+ */ -+ -+ /* -+ joypad driver is poll-device driver. -+ poll-device is does not support wakeup-source. -+ */ -+ sw1 { -+ gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-UP"; -+ linux,code = ; // 0x220 -+ }; -+ sw2 { -+ gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-DOWN"; -+ linux,code = ; // 0x221 -+ }; -+ sw3 { -+ gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-LEFT"; -+ linux,code = ; // 0x222 -+ }; -+ sw4 { -+ gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-RIGHT"; -+ linux,code = ; // 0x223 -+ }; -+ sw5 { -+ gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO KEY BTN-A"; -+ linux,code = ; // 0x131 -+ }; -+ sw6 { -+ gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-B"; -+ linux,code = ; // 0x130 -+ }; -+ sw7 { -+ gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-Y"; -+ linux,code = ; // 0x134 -+ }; -+ sw8 { -+ gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-X"; -+ linux,code = ; // 0x133 -+ }; -+ sw11 { -+ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_THUMBL"; -+ linux,code = ; // 0x2c2 -+ }; -+ sw12 { -+ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_THUMBR"; -+ linux,code = ; // 0x2c3 -+ }; -+ sw13 { -+ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_FN"; -+ linux,code = ; // 0x2c4 -+ }; -+ sw15 { -+ gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT"; -+ linux,code = ; // 0x02 -+ }; -+ sw16 { -+ gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT"; -+ linux,code = ; // 0x05 -+ }; -+ sw19 { -+ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_SELECT"; -+ linux,code = ; -+ }; -+ sw20 { -+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT2"; -+ linux,code = ; -+ }; -+ sw21 { -+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT2"; -+ linux,code = ; -+ }; -+ sw22 { -+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_START"; -+ linux,code = ; -+ }; -+ }; -+}; -+ -+&pinctrl { -+ btns { -+ btn_pins: btn-pins { -+ rockchip,pins = <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; -+ -+ }; -+ -+ }; -+}; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r3xs.dtsi b/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r3xs.dtsi -new file mode 100644 -index 000000000000..de1b0d51e238 ---- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r3xs.dtsi -@@ -0,0 +1,545 @@ -+// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * # Copyright (C) 2022-24 JELOS (https://github.com/JustEnoughLinuxOS) -+ */ -+ -+/dts-v1/; -+#include -+#include -+#include -+#include -+#include "rk3326.dtsi" -+ -+/ { -+ model = "Game Console R33S"; -+ compatible = "gameconsolec,r33s", "rockchip,rk3326"; -+ -+ aliases { -+ mmc0 = &sdio; -+ mmc1 = &sdmmc; -+ }; -+ -+ chosen { -+ stdout-path = "serial2:115200n8"; -+ }; -+ -+ backlight: backlight { -+ compatible = "pwm-backlight"; -+ power-supply = <&vcc_bl>; -+ pwms = <&pwm1 0 25000 0>; -+ brightness-levels = < -+ 0 1 2 3 4 5 6 7 -+ 8 9 10 11 12 13 14 15 -+ 16 17 18 19 20 21 22 23 -+ 24 25 26 27 28 29 30 31 -+ 32 33 34 35 36 37 38 39 -+ 40 41 42 43 44 45 46 47 -+ 48 49 50 51 52 53 54 55 -+ 56 57 58 59 60 61 62 63 -+ 64 65 66 67 68 69 70 71 -+ 72 73 74 75 76 77 78 79 -+ 80 81 82 83 84 85 86 87 -+ 88 89 90 91 92 93 94 95 -+ 96 97 98 99 100 101 102 103 -+ 104 105 106 107 108 109 110 111 -+ 112 113 114 115 116 117 118 119 -+ 120 121 122 123 124 125 126 127 -+ 128 129 130 131 132 133 134 135 -+ 136 137 138 139 140 141 142 143 -+ 144 145 146 147 148 149 150 151 -+ 152 153 154 155 156 157 158 159 -+ 160 161 162 163 164 165 166 167 -+ 168 169 170 171 172 173 174 175 -+ 176 177 178 179 180 181 182 183 -+ 184 185 186 187 188 189 190 191 -+ 192 193 194 195 196 197 198 199 -+ 200 201 202 203 204 205 206 207 -+ 208 209 210 211 212 213 214 215 -+ 216 217 218 219 220 221 222 223 -+ 224 225 226 227 228 229 230 231 -+ 232 233 234 235 236 237 238 239 -+ 240 241 242 243 244 245 246 247 -+ 248 249 250 251 252 253 254 255>; -+ default-brightness-level = <128>; -+ }; -+ -+ gpio-keys-vol { -+ compatible = "gpio-keys"; -+ autorepeat; -+ pinctrl-0 = <&btn_pins_vol>; -+ pinctrl-names = "default"; -+ -+ button-vol-down { -+ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEDOWN"; -+ linux,code = ; -+ }; -+ -+ button-volume-up { -+ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEUP"; -+ linux,code = ; -+ }; -+ }; -+ -+ battery: battery { -+ compatible = "simple-battery"; -+ charge-full-design-microamp-hours = <3200000>; -+ charge-term-current-microamp = <320000>; -+ constant-charge-current-max-microamp = <2000000>; -+ constant-charge-voltage-max-microvolt = <4200000>; -+ factory-internal-resistance-micro-ohms = <180000>; -+ voltage-max-design-microvolt = <4100000>; -+ voltage-min-design-microvolt = <3500000>; -+ -+ ocv-capacity-celsius = <20>; -+ ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, -+ <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, -+ <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, -+ <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, -+ <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, -+ <3574170 0>; -+ -+ }; -+ -+ rk817-sound { -+ compatible = "simple-audio-card"; -+ simple-audio-card,name = "rk817_int"; -+ simple-audio-card,format = "i2s"; -+ simple-audio-card,hp-det-gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>; -+ simple-audio-card,mclk-fs = <256>; -+ simple-audio-card,widgets = -+ "Microphone", "Mic Jack", -+ "Headphone", "Headphones", -+ "Speaker", "Speaker"; -+ simple-audio-card,routing = -+ "MICL", "Mic Jack", -+ "Headphones", "HPOL", -+ "Headphones", "HPOR", -+ "Speaker", "SPKO"; -+ -+ simple-audio-card,codec { -+ sound-dai = <&rk817>; -+ }; -+ -+ simple-audio-card,cpu { -+ sound-dai = <&i2s1_2ch>; -+ }; -+ }; -+ -+ vccsys: vccsys { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc3v8_sys"; -+ regulator-always-on; -+ regulator-min-microvolt = <3800000>; -+ regulator-max-microvolt = <3800000>; -+ }; -+}; -+ -+&dmc { -+ center-supply = <&vdd_logic>; -+}; -+ -+&cpu0 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cpu1 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cpu2 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cpu3 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cru { -+ assigned-clocks = <&cru PLL_NPLL>, -+ <&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>, -+ <&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>, -+ <&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>; -+ -+ assigned-clock-rates = <1188000000>, -+ <200000000>, <200000000>, -+ <150000000>, <150000000>, -+ <100000000>, <200000000>; -+}; -+ -+&display_subsystem { -+ status = "okay"; -+}; -+ -+&dsi { -+ status = "okay"; -+ -+ ports { -+ mipi_out: port@1 { -+ reg = <1>; -+ -+ mipi_out_panel: endpoint { -+ remote-endpoint = <&mipi_in_panel>; -+ }; -+ }; -+ }; -+ -+ internal_display: panel@0 { -+ reg = <0>; -+ backlight = <&backlight>; -+ reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>; -+ -+ port { -+ mipi_in_panel: endpoint { -+ remote-endpoint = <&mipi_out_panel>; -+ }; -+ }; -+ }; -+}; -+ -+&dsi_dphy { -+ status = "okay"; -+}; -+ -+&gpu { -+ mali-supply = <&vdd_logic>; -+ status = "okay"; -+}; -+ -+&internal_display { -+ compatible = "gameconsole,r36s-panel", "sitronix,st7703"; -+ iovcc-supply = <&vcc_lcd>; -+ vdd-supply = <&vcc_lcd>; -+}; -+ -+&i2c0 { -+ clock-frequency = <400000>; -+ i2c-scl-falling-time-ns = <16>; -+ i2c-scl-rising-time-ns = <280>; -+ status = "okay"; -+ -+ rk817: pmic@20 { -+ compatible = "rockchip,rk817"; -+ reg = <0x20>; -+ interrupt-parent = <&gpio0>; -+ interrupts = ; -+ clock-output-names = "rk808-clkout1", "xin32k"; -+ clock-names = "mclk"; -+ clocks = <&cru SCLK_I2S1_OUT>; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; -+ rockchip,system-power-controller; -+ wakeup-source; -+ #clock-cells = <1>; -+ #sound-dai-cells = <0>; -+ -+ vcc1-supply = <&vccsys>; -+ vcc2-supply = <&vccsys>; -+ vcc3-supply = <&vccsys>; -+ vcc4-supply = <&vccsys>; -+ vcc5-supply = <&vccsys>; -+ vcc6-supply = <&vccsys>; -+ vcc7-supply = <&vccsys>; -+ vcc8-supply = <&vccsys>; -+ -+ regulators { -+ vdd_logic: DCDC_REG1 { -+ regulator-name = "vdd_logic"; -+ regulator-min-microvolt = <950000>; -+ regulator-max-microvolt = <1150000>; -+ regulator-ramp-delay = <6001>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <950000>; -+ }; -+ }; -+ -+ vdd_arm: DCDC_REG2 { -+ regulator-name = "vdd_arm"; -+ regulator-min-microvolt = <950000>; -+ regulator-max-microvolt = <1350000>; -+ regulator-ramp-delay = <6001>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <950000>; -+ }; -+ }; -+ -+ vcc_ddr: DCDC_REG3 { -+ regulator-name = "vcc_ddr"; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ }; -+ }; -+ -+ vcc_3v3: DCDC_REG4 { -+ regulator-name = "vcc_3v3"; -+ regulator-min-microvolt = <3300000>; -+ regulator-max-microvolt = <3300000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <3300000>; -+ }; -+ }; -+ -+ vcc_1v8: LDO_REG2 { -+ regulator-name = "vcc_1v8"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <1800000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <1800000>; -+ }; -+ }; -+ -+ vdd_1v0: LDO_REG3 { -+ regulator-name = "vdd_1v0"; -+ regulator-min-microvolt = <1000000>; -+ regulator-max-microvolt = <1000000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <1000000>; -+ }; -+ }; -+ -+ vcc3v3_pmu: LDO_REG4 { -+ regulator-name = "vcc3v3_pmu"; -+ regulator-min-microvolt = <3300000>; -+ regulator-max-microvolt = <3300000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3300000>; -+ }; -+ }; -+ -+ vccio_sd: LDO_REG5 { -+ regulator-name = "vccio_sd"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <1800000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <1800000>; -+ }; -+ }; -+ -+ vcc_sd: LDO_REG6 { -+ regulator-name = "vcc_sd"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <3000000>; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3000000>; -+ }; -+ }; -+ -+ vcc_bl: LDO_REG7 { -+ regulator-name = "vcc_bl"; -+ regulator-min-microvolt = <3300000>; -+ regulator-max-microvolt = <3300000>; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <3300000>; -+ }; -+ }; -+ -+ vcc_lcd: LDO_REG8 { -+ regulator-name = "vcc_lcd"; -+ regulator-min-microvolt = <2800000>; -+ regulator-max-microvolt = <2800000>; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <2800000>; -+ }; -+ }; -+ -+ LDO_REG9 { -+ /* unused */ -+ }; -+ -+ usb_midu: BOOST { -+ regulator-name = "usb_midu"; -+ regulator-min-microvolt = <5000000>; -+ regulator-max-microvolt = <5400000>; -+ regulator-always-on; -+ regulator-boot-on; -+ }; -+ }; -+ -+ rk817_charger: charger { -+ rockchip,resistor-sense-micro-ohms = <10000>; -+ rockchip,sleep-enter-current-microamp = <300000>; -+ rockchip,sleep-filter-current-microamp = <100000>; -+ }; -+ -+ rk817_codec: codec { -+ rockchip,mic-in-differential; -+ }; -+ }; -+}; -+ -+&i2s1_2ch { -+ status = "okay"; -+}; -+ -+&io_domains { -+ vccio1-supply = <&vccio_sd>; -+ vccio2-supply = <&vccio_sd>; -+ vccio3-supply = <&vcc_3v3>; -+ vccio4-supply = <&vcc_3v3>; -+ vccio5-supply = <&vcc_3v3>; -+ vccio6-supply = <&vcc_3v3>; -+ status = "okay"; -+}; -+ -+&pmu_io_domains { -+ pmuio1-supply = <&vcc3v3_pmu>; -+ pmuio2-supply = <&vcc3v3_pmu>; -+ status = "okay"; -+}; -+ -+&pwm0 { -+ status = "okay"; -+}; -+ -+&pwm1 { -+ status = "okay"; -+}; -+ -+&saradc { -+ vref-supply = <&vcc_1v8>; -+ status = "okay"; -+}; -+ -+&sdmmc { -+ bus-width = <4>; -+ cap-sd-highspeed; -+ card-detect-delay = <800>; -+ cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ -+ disable-wp; -+ sd-uhs-sdr12; -+ sd-uhs-sdr25; -+ sd-uhs-sdr50; -+ sd-uhs-sdr104; -+ vmmc-supply = <&vcc_sd>; -+ vqmmc-supply = <&vccio_sd>; -+ status = "okay"; -+}; -+ -+&sdio { -+ bus-width = <4>; -+ cap-sd-highspeed; -+ card-detect-delay = <800>; -+ cd-gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ -+ disable-wp; -+ sd-uhs-sdr12; -+ sd-uhs-sdr25; -+ sd-uhs-sdr50; -+ sd-uhs-sdr104; -+ vmmc-supply = <&vcc_sd>; -+ vqmmc-supply = <&vccio_sd>; -+ status = "okay"; -+}; -+ -+&tsadc { -+ status = "okay"; -+}; -+ -+&u2phy { -+ status = "okay"; -+ -+ u2phy_host: host-port { -+ status = "okay"; -+ }; -+ -+ u2phy_otg: otg-port { -+ status = "disabled"; -+ }; -+}; -+ -+&usb20_otg { -+ status = "okay"; -+}; -+ -+&uart2 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&uart2m1_xfer>; -+ status = "okay"; -+}; -+ -+&vopb { -+ status = "okay"; -+}; -+ -+&vopb_mmu { -+ status = "okay"; -+}; -+ -+&rk817_charger { -+ monitored-battery = <&battery>; -+}; -+ -+&pinctrl { -+ btns { -+ btn_pins_vol: btn-pins-vol { -+ rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ }; -+ -+ headphone { -+ hp_det: hp-det { -+ rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>; -+ }; -+ }; -+ -+ pmic { -+ dc_det: dc-det { -+ rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ -+ pmic_int: pmic-int { -+ rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ -+ soc_slppin_gpio: soc_slppin_gpio { -+ rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>; -+ }; -+ -+ soc_slppin_rst: soc_slppin_rst { -+ rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>; -+ }; -+ -+ soc_slppin_slp: soc_slppin_slp { -+ rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>; -+ }; -+ }; -+}; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu10.dts b/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu10.dts -new file mode 100644 -index 000000000000..3fe532e06d58 ---- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu10.dts -@@ -0,0 +1,872 @@ -+// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * Copyright (c) 2019 Hardkernel Co., Ltd -+ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH -+ * Copyright (c) 2022 Maya Matuszczyk -+ */ -+ -+/dts-v1/; -+#include -+#include -+#include -+#include -+#include "rk3326.dtsi" -+ -+/ { -+ model = "MagicX XU10"; -+ compatible = "magicx,xu10", "rockchip,rk3326"; -+ -+ aliases { -+ mmc0 = &sdio; -+ mmc1 = &sdmmc; -+ }; -+ -+ backlight: backlight { -+ compatible = "pwm-backlight"; -+ pwms = <&pwm1 0 25000 0>; -+ brightness-levels = < -+ 0 1 2 3 4 5 6 7 -+ 8 9 10 11 12 13 14 15 -+ 16 17 18 19 20 21 22 23 -+ 24 25 26 27 28 29 30 31 -+ 32 33 34 35 36 37 38 39 -+ 40 41 42 43 44 45 46 47 -+ 48 49 50 51 52 53 54 55 -+ 56 57 58 59 60 61 62 63 -+ 64 65 66 67 68 69 70 71 -+ 72 73 74 75 76 77 78 79 -+ 80 81 82 83 84 85 86 87 -+ 88 89 90 91 92 93 94 95 -+ 96 97 98 99 100 101 102 103 -+ 104 105 106 107 108 109 110 111 -+ 112 113 114 115 116 117 118 119 -+ 120 121 122 123 124 125 126 127 -+ 128 129 130 131 132 133 134 135 -+ 136 137 138 139 140 141 142 143 -+ 144 145 146 147 148 149 150 151 -+ 152 153 154 155 156 157 158 159 -+ 160 161 162 163 164 165 166 167 -+ 168 169 170 171 172 173 174 175 -+ 176 177 178 179 180 181 182 183 -+ 184 185 186 187 188 189 190 191 -+ 192 193 194 195 196 197 198 199 -+ 200 201 202 203 204 205 206 207 -+ 208 209 210 211 212 213 214 215 -+ 216 217 218 219 220 221 222 223 -+ 224 225 226 227 228 229 230 231 -+ 232 233 234 235 236 237 238 239 -+ 240 241 242 243 244 245 246 247 -+ 248 249 250 251 252 253 254 255>; -+ default-brightness-level = <128>; -+ }; -+ -+ joypad: xu10-joypad { -+ compatible = "xu10-joypad"; -+ -+ joypad-name = "XU10 Gamepad"; -+ joypad-product = <0x0200>; -+ joypad-revision = <0x0010>; -+ -+ status = "okay"; -+ /* -+ - xu10-joypad sysfs list - -+ * for poll device interval(ms) -+ /sys/devices/platform/odroidgo3_joypad/poll_interval [rw] -+ ex) echo 20 > poll_interval -+ * for button-adc-fuzz -+ /sys/devices/platform/odroidgo3_joypad/adc_fuzz [r] -+ * for button-adc-flat -+ /sys/devices/platform/odroidgo3_joypad/adc_flat [r] -+ -+ * for report control(1:enable, 0:disable) -+ /sys/devices/platform/odroidgo3_joypad/enable [rw] -+ * for adc calibration value setup(current adcs value -> cal value) -+ /sys/devices/platform/odroidgo3_joypad/adc_cal [rw] -+ ex) echo 0 > adc_cal -+ * for amux data debug -+ * Joypad driver is disabled when using this sysfs. -+ /sys/devices/platform/odroidgo3_joypad/amux_debug [rw] -+ ex) echo 0 > amux_debug --> select amux channel -+ ex) cat amux_debug --> get adc data of seleted channel -+ */ -+ -+ /* gpio pincontrol setup */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; -+ -+ /* Analog mux define */ -+ io-channel-names = "joy_left", "joy_right"; -+ io-channels = <&saradc 1>, <&saradc 2>; -+ -+ /* adc mux channel count */ -+ amux-count = <4>; -+ -+ /* adc mux select(a,b) gpio */ -+ amux-a-gpios = <&gpio2 RK_PB3 GPIO_ACTIVE_LOW>; -+ amux-b-gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>; -+ -+ /* adc mux enable gpio */ -+ amux-en-gpios = <&gpio1 RK_PB0 GPIO_ACTIVE_LOW>; -+ -+ /* adc calculate scale */ -+ button-adc-scale = <2>; -+ -+ /* adc deadzone range */ -+ button-adc-deadzone = <180>; -+ -+ /* -+ specifies fuzz value that is used to filter noise from -+ the event stream. -+ */ -+ button-adc-fuzz = <32>; -+ button-adc-flat = <32>; -+ -+ /* -+ Analog Stick data tuning value(precent) -+ p = positive direction, n = negative direction -+ report value = (real_adc_data * tuning_value) / 100 -+ */ -+ abs_x-p-tuning = <200>; -+ abs_x-n-tuning = <200>; -+ -+ abs_y-p-tuning = <200>; -+ abs_y-n-tuning = <200>; -+ -+ abs_rx-p-tuning = <200>; -+ abs_rx-n-tuning = <200>; -+ -+ abs_ry-p-tuning = <200>; -+ abs_ry-n-tuning = <200>; -+ -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ -+ /* required for XU10 */ -+ invert-absx; -+ invert-absy; -+ -+ /* gpio button auto repeat set value : default disable */ -+ /* -+ autorepeat; -+ */ -+ -+ /* -+ *** MagicX XU10 - layoout *** -+ |-------------------------------| -+ | sw14 sw17 sw16 sw15 | -+ |-----|-------------------|-----| -+ | | | | -+ |vol+ | | sw13| -+ |vol- | | | -+ | | LCD Display | | -+ | | | | -+ | | | | -+ | |-------------------| | -+ | sw9 sw10 | -+ | | -+ | sw1 sw7 | -+ | sw3 sw4 sw8 sw6 | -+ | sw2 sw5 | -+ | | -+ | sw11 sw12 | -+ | | -+ |-------|---------------|-------| -+ */ -+ -+ /* -+ joypad driver is poll-device driver. -+ poll-device is does not support wakeup-source. -+ */ -+ -+ sw1 { -+ gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-UP"; -+ linux,code = ; // 0x220 -+ }; -+ sw2 { -+ gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-DOWN"; -+ linux,code = ; // 0x221 -+ }; -+ sw3 { -+ gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-LEFT"; -+ linux,code = ; // 0x222 -+ }; -+ sw4 { -+ gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-RIGHT"; -+ linux,code = ; // 0x223 -+ }; -+ sw5 { -+ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-A"; -+ linux,code = ; // 0x130 -+ }; -+ sw6 { -+ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-B"; -+ linux,code = ; // 0x131 -+ }; -+ sw7 { -+ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-Y"; -+ linux,code = ; // 0x133 -+ }; -+ sw8 { -+ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-X"; -+ linux,code = ; // 0x134 -+ }; -+ sw9 { -+ gpios = <&gpio2 RK_PB0 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-SELECT"; -+ linux,code = ; // 0x13a -+ }; -+ sw10 { -+ gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-START"; -+ linux,code = ; // 0x13b -+ }; -+ sw11 { -+ gpios = <&gpio2 RK_PB1 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-THUMBL"; -+ linux,code = ; // 0x13d -+ }; -+ sw12 { -+ gpios = <&gpio2 RK_PB2 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-THUMBR"; -+ linux,code = ; // 0x13e -+ }; -+ sw13 { -+ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-G"; -+ linux,code = ; // 0x2c0 -+ }; -+ sw14 { -+ gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-LEFT"; -+ linux,code = ; // 0x136 -+ }; -+ sw15 { -+ gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-RIGHT"; -+ linux,code = ; // 0x137 -+ }; -+ sw16 { -+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-RIGHT2"; -+ linux,code = ; // 0x139 -+ }; -+ sw17 { -+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-LEFT2"; -+ linux,code = ; // 0x138 -+ }; -+ }; -+ -+ battery: battery { -+ compatible = "simple-battery"; -+ charge-full-design-microamp-hours = <3000000>; -+ charge-term-current-microamp = <200000>; -+ constant-charge-current-max-microamp = <1500000>; -+ constant-charge-voltage-max-microvolt = <4200000>; -+ factory-internal-resistance-micro-ohms = <100000>; -+ voltage-max-design-microvolt = <4100000>; -+ voltage-min-design-microvolt = <3300000>; -+ -+ ocv-capacity-celsius = <20>; -+ ocv-capacity-table-0 = -+ <4046950 100>, <4001920 95>, <3967900 90>, <3940000 85>, -+ <3910000 80>, <3870000 75>, <3830000 70>, <3790000 65>, -+ <3750000 60>, <3720000 55>, <3690000 50>, <3650000 45>, -+ <3610000 40>, <3570000 35>, <3540000 30>, <3500000 25>, -+ <3460000 20>, <3420000 15>, <3380000 10>, <3340000 5>, -+ <3300000 0>; -+ }; -+ -+ gpio-keys-vol { -+ compatible = "gpio-keys"; -+ autorepeat; -+ pinctrl-0 = <&btn_pins_vol>; -+ pinctrl-names = "default"; -+ -+ button-vol-down { -+ gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEDOWN"; -+ linux,code = ; -+ }; -+ -+ button-vol-up { -+ gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEUP"; -+ linux,code = ; -+ }; -+ }; -+ -+ leds: gpio-leds { -+ compatible = "gpio-leds"; -+ pinctrl-0 = <&led_pins>; -+ pinctrl-names = "default"; -+ -+ led-0 { -+ color = ; -+ default-state = "off"; -+ function = LED_FUNCTION_CHARGING; -+ gpios = <&gpio0 RK_PB3 GPIO_ACTIVE_HIGH>; -+ }; -+ -+ led-1 { -+ color = ; -+ default-state = "off"; -+ function = LED_FUNCTION_STATUS; -+ gpios = <&gpio0 RK_PB4 GPIO_ACTIVE_HIGH>; -+ }; -+ }; -+ -+ rk817-sound { -+ compatible = "simple-audio-card"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&hp_det>; -+ simple-audio-card,name = "rk817_int"; -+ simple-audio-card,format = "i2s"; -+ simple-audio-card,hp-det-gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_LOW>; -+ simple-audio-card,mclk-fs = <256>; -+ simple-audio-card,widgets = -+ "Microphone", "Mic Jack", -+ "Headphone", "Headphones", -+ "Speaker", "Speaker"; -+ simple-audio-card,routing = -+ "MICL", "Mic Jack", -+ "Headphones", "HPOL", -+ "Headphones", "HPOR", -+ "Speaker", "SPKO"; -+ -+ simple-audio-card,codec { -+ sound-dai = <&rk817>; -+ }; -+ -+ simple-audio-card,cpu { -+ sound-dai = <&i2s1_2ch>; -+ }; -+ }; -+ -+ vccsys: vccsys { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc3v8_sys"; -+ regulator-always-on; -+ regulator-min-microvolt = <3800000>; -+ regulator-max-microvolt = <3800000>; -+ }; -+ -+ vcc-phy-regulator { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc_phy"; -+ regulator-always-on; -+ regulator-boot-on; -+ }; -+ -+ vcc18_lcd0: vcc18-lcd0 { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc18_lcd0_n"; -+ gpio = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>; -+ enable-active-high; -+ pinctrl-0 = <&vcc18_lcd_n>; -+ pinctrl-names = "default"; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ }; -+ }; -+ -+ vcc_host: vcc_host { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc_host"; -+ regulator-min-microvolt = <5000000>; -+ regulator-max-microvolt = <5000000>; -+ gpio = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>; -+ enable-active-high; -+ regulator-always-on; -+ regulator-boot-on; -+ vin-supply = <&usb_midu>; -+ }; -+}; -+ -+&dmc { -+ center-supply = <&vdd_logic>; -+}; -+ -+&cpu0 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cpu1 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cpu2 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cpu3 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cru { -+ assigned-clocks = <&cru PLL_NPLL>, -+ <&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>, -+ <&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>, -+ <&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>; -+ -+ assigned-clock-rates = <1188000000>, -+ <200000000>, <200000000>, -+ <150000000>, <150000000>, -+ <100000000>, <200000000>; -+}; -+ -+&display_subsystem { -+ status = "okay"; -+}; -+ -+&dsi { -+ status = "okay"; -+ -+ ports { -+ mipi_out: port@1 { -+ reg = <1>; -+ -+ mipi_out_panel: endpoint { -+ remote-endpoint = <&mipi_in_panel>; -+ }; -+ }; -+ }; -+ -+ internal_display: panel@0 { -+ compatible = "magicx,xu10-panel", "sitronix,st7703"; -+ iovcc-supply = <&vcc18_lcd0>; -+ vcc-supply = <&vcc18_lcd0>; -+ reg = <0>; -+ backlight = <&backlight>; -+ reset-gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&lcd_rst>; -+ -+ port { -+ mipi_in_panel: endpoint { -+ remote-endpoint = <&mipi_out_panel>; -+ }; -+ }; -+ }; -+}; -+ -+&dsi_dphy { -+ status = "okay"; -+}; -+ -+&gpu { -+ mali-supply = <&vdd_logic>; -+ status = "okay"; -+}; -+ -+&i2c0 { -+ clock-frequency = <400000>; -+ i2c-scl-falling-time-ns = <16>; -+ i2c-scl-rising-time-ns = <280>; -+ status = "okay"; -+ -+ rk817: pmic@20 { -+ compatible = "rockchip,rk817"; -+ reg = <0x20>; -+ interrupt-parent = <&gpio0>; -+ interrupts = ; -+ clock-output-names = "rk808-clkout1", "xin32k"; -+ clock-names = "mclk"; -+ clocks = <&cru SCLK_I2S1_OUT>; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; -+ rockchip,system-power-controller; -+ wakeup-source; -+ #clock-cells = <1>; -+ #sound-dai-cells = <0>; -+ -+ vcc1-supply = <&vccsys>; -+ vcc2-supply = <&vccsys>; -+ vcc3-supply = <&vccsys>; -+ vcc4-supply = <&vccsys>; -+ vcc5-supply = <&vccsys>; -+ vcc6-supply = <&vccsys>; -+ vcc7-supply = <&vcc_3v0>; -+ vcc8-supply = <&vccsys>; -+ vcc9-supply = <&usb_midu>; -+ -+ regulators { -+ vdd_logic: DCDC_REG1 { -+ regulator-name = "vdd_logic"; -+ regulator-min-microvolt = <850000>; -+ regulator-max-microvolt = <1150000>; -+ regulator-ramp-delay = <6001>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <950000>; -+ }; -+ }; -+ -+ vdd_arm: DCDC_REG2 { -+ regulator-name = "vdd_arm"; -+ regulator-min-microvolt = <850000>; -+ regulator-max-microvolt = <1350000>; -+ regulator-ramp-delay = <6001>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <950000>; -+ }; -+ }; -+ -+ vcc_ddr: DCDC_REG3 { -+ regulator-name = "vcc_ddr"; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ }; -+ }; -+ -+ vcc_3v0: DCDC_REG4 { -+ regulator-name = "vcc_3v0"; -+ regulator-min-microvolt = <3000000>; -+ regulator-max-microvolt = <3000000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <3000000>; -+ }; -+ }; -+ -+ vcc_1v0: LDO_REG1 { -+ regulator-name = "vcc_1v0"; -+ regulator-always-on; -+ regulator-boot-on; -+ regulator-min-microvolt = <1000000>; -+ regulator-max-microvolt = <1000000>; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <1000000>; -+ }; -+ }; -+ -+ vcc1v8_soc: LDO_REG2 { -+ regulator-name = "vcc1v8_soc"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <1800000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <1800000>; -+ }; -+ }; -+ -+ vcc1v0_soc: LDO_REG3 { -+ regulator-name = "vcc1v0_soc"; -+ regulator-min-microvolt = <1000000>; -+ regulator-max-microvolt = <1000000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <1000000>; -+ }; -+ }; -+ -+ vcc3v0_pmu: LDO_REG4 { -+ regulator-name = "vcc3v0_pmu"; -+ regulator-min-microvolt = <3000000>; -+ regulator-max-microvolt = <3000000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3000000>; -+ }; -+ }; -+ -+ vccio_sd: LDO_REG5 { -+ regulator-name = "vccio_sd"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <3300000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3300000>; -+ }; -+ }; -+ -+ vcc_sd: LDO_REG6 { -+ regulator-name = "vcc_sd"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <3000000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3000000>; -+ }; -+ }; -+ -+ vcc2v8_dvp: LDO_REG7 { -+ regulator-name = "vcc2v8_dvp"; -+ regulator-min-microvolt = <2800000>; -+ regulator-max-microvolt = <2800000>; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <2800000>; -+ }; -+ }; -+ -+ vcc3v0_dvp: LDO_REG8 { -+ regulator-name = "vcc3v0_dvp"; -+ regulator-min-microvolt = <3000000>; -+ regulator-max-microvolt = <3000000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3000000>; -+ }; -+ }; -+ -+ vdd1v5_dvp: LDO_REG9 { -+ regulator-min-microvolt = <1500000>; -+ regulator-max-microvolt = <1500000>; -+ regulator-name = "vdd1v5_dvp"; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <1500000>; -+ }; -+ }; -+ -+ usb_midu: BOOST { -+ regulator-name = "usb_midu"; -+ regulator-min-microvolt = <4700000>; -+ regulator-max-microvolt = <5400000>; -+ regulator-always-on; -+ regulator-boot-on; -+ }; -+ -+ }; -+ -+ rk817_charger: charger { -+ monitored-battery = <&battery>; -+ rockchip,resistor-sense-micro-ohms = <10000>; -+ rockchip,sleep-enter-current-microamp = <300000>; -+ rockchip,sleep-filter-current-microamp = <100000>; -+ }; -+ -+ rk817_codec: codec { -+ rockchip,mic-in-differential; -+ }; -+ }; -+}; -+ -+/* I2S 1 Channel Used Header(P2):1(GPIO2.C3),2(.C2), 3(.C1), 4(.C5), 5(.C4) */ -+&i2s1_2ch { -+ status = "okay"; -+ #sound-dai-cells = <0>; -+}; -+ -+&io_domains { -+ vccio1-supply = <&vcc1v8_soc>; -+ vccio2-supply = <&vccio_sd>; -+ vccio3-supply = <&vcc3v0_dvp>; -+ vccio4-supply = <&vcc_3v0>; -+ vccio5-supply = <&vcc_3v0>; -+ vccio6-supply = <&vcc_3v0>; -+ status = "okay"; -+}; -+ -+&isp { -+ status = "okay"; -+}; -+ -+&isp_mmu { -+ status = "okay"; -+}; -+ -+&pmu_io_domains { -+ pmuio1-supply = <&vcc3v0_pmu>; -+ pmuio2-supply = <&vcc3v0_pmu>; -+ status = "okay"; -+}; -+ -+&csi_dphy { -+ status = "okay"; -+}; -+ -+&pwm1 { -+ status = "okay"; -+}; -+ -+&saradc { -+ vref-supply = <&vcc1v8_soc>; -+ status = "okay"; -+}; -+ -+&sdmmc { -+ cap-sd-highspeed; -+ card-detect-delay = <200>; -+ cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; /*[> ff370000 PD_SDCARD CD GPIO <]*/ -+ sd-uhs-sdr12; -+ sd-uhs-sdr25; -+ sd-uhs-sdr50; -+ sd-uhs-sdr104; -+ vmmc-supply = <&vcc_sd>; -+ vqmmc-supply = <&vccio_sd>; -+ status = "okay"; -+}; -+ -+&sdio { -+ cap-sd-highspeed; -+ card-detect-delay = <200>; -+ cd-gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ -+ sd-uhs-sdr12; -+ sd-uhs-sdr25; -+ sd-uhs-sdr50; -+ sd-uhs-sdr104; -+ vmmc-supply = <&vcc_sd>; -+ vqmmc-supply = <&vccio_sd>; -+ status = "okay"; -+}; -+ -+&tsadc { -+ status = "okay"; -+}; -+ -+&u2phy { -+ status = "okay"; -+ -+ u2phy_host: host-port { -+ status = "okay"; -+ }; -+ -+ u2phy_otg: otg-port { -+ status = "disabled"; -+ }; -+}; -+ -+/* FIQ Header(P2): 2(RXD:GPIO2.B4),3(TXD:.B6) */ -+&uart2 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&uart2m1_xfer>; -+ status = "okay"; -+}; -+ -+&usb20_otg { -+ status = "okay"; -+ dr_mode = "host"; -+}; -+ -+&vopb { -+ status = "okay"; -+}; -+ -+&vopb_mmu { -+ status = "okay"; -+}; -+ -+&pinctrl { -+ btns { -+ btn_pins: btn-pins { -+ rockchip,pins = <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ -+ btn_pins_vol: btn-pins-vol { -+ rockchip,pins = -+ <0 RK_PC1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <0 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ }; -+ -+ headphone { -+ hp_det: hp-det { -+ rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ }; -+ -+ gpio-lcd { -+ lcd_rst: lcd-rst { -+ rockchip,pins = <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ }; -+ -+ vcc18-lcd { -+ vcc18_lcd_n: vcc18-lcd-n { -+ rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ }; -+ -+ gpio-led { -+ led_pins: led-pins { -+ rockchip,pins = -+ <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>, -+ <0 RK_PB4 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ }; -+ -+ pmic { -+ dc_det: dc-det { -+ rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ -+ pmic_int: pmic-int { -+ rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ -+ soc_slppin_gpio: soc_slppin_gpio { -+ rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>; -+ }; -+ -+ soc_slppin_rst: soc_slppin_rst { -+ rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>; -+ }; -+ -+ soc_slppin_slp: soc_slppin_slp { -+ rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>; -+ }; -+ }; -+}; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi -index 80fc53c807a4..84dbabeb6e03 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi -+++ b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi -@@ -25,93 +25,40 @@ backlight: backlight { - compatible = "pwm-backlight"; - power-supply = <&vcc_bl>; - pwms = <&pwm1 0 25000 0>; -- }; -- -- builtin_gamepad: gpio-keys { -- compatible = "gpio-keys"; -- pinctrl-names = "default"; -- pinctrl-0 = <&btn_pins>; -- -- button-sw1 { -- gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; -- label = "DPAD-UP"; -- linux,code = ; -- }; -- button-sw2 { -- gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; -- label = "DPAD-DOWN"; -- linux,code = ; -- }; -- button-sw3 { -- gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; -- label = "DPAD-LEFT"; -- linux,code = ; -- }; -- button-sw4 { -- gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; -- label = "DPAD-RIGHT"; -- linux,code = ; -- }; -- button-sw5 { -- gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; -- label = "BTN-A"; -- linux,code = ; -- }; -- button-sw6 { -- gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; -- label = "BTN-B"; -- linux,code = ; -- }; -- button-sw7 { -- gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; -- label = "BTN-Y"; -- linux,code = ; -- }; -- button-sw8 { -- gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; -- label = "BTN-X"; -- linux,code = ; -- }; -- btn_f1: button-sw9 { -- gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -- label = "F1"; -- linux,code = ; -- }; -- btn_f2: button-sw10 { -- gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -- label = "F2"; -- linux,code = ; -- }; -- btn_f3: button-sw11 { -- gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; -- label = "F3"; -- linux,code = ; -- }; -- btn_f4: button-sw12 { -- gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -- label = "F4"; -- linux,code = ; -- }; -- btn_f5: button-sw13 { -- gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; -- label = "F5"; -- linux,code = ; -- }; -- btn_f6: button-sw14 { -- gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; -- label = "F6"; -- linux,code = ; -- }; -- button-sw15 { -- gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; -- label = "TOP-LEFT"; -- linux,code = ; -- }; -- button-sw16 { -- gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; -- label = "TOP-RIGHT"; -- linux,code = ; -- }; -+ brightness-levels = < -+ 0 1 2 3 4 5 6 7 -+ 8 9 10 11 12 13 14 15 -+ 16 17 18 19 20 21 22 23 -+ 24 25 26 27 28 29 30 31 -+ 32 33 34 35 36 37 38 39 -+ 40 41 42 43 44 45 46 47 -+ 48 49 50 51 52 53 54 55 -+ 56 57 58 59 60 61 62 63 -+ 64 65 66 67 68 69 70 71 -+ 72 73 74 75 76 77 78 79 -+ 80 81 82 83 84 85 86 87 -+ 88 89 90 91 92 93 94 95 -+ 96 97 98 99 100 101 102 103 -+ 104 105 106 107 108 109 110 111 -+ 112 113 114 115 116 117 118 119 -+ 120 121 122 123 124 125 126 127 -+ 128 129 130 131 132 133 134 135 -+ 136 137 138 139 140 141 142 143 -+ 144 145 146 147 148 149 150 151 -+ 152 153 154 155 156 157 158 159 -+ 160 161 162 163 164 165 166 167 -+ 168 169 170 171 172 173 174 175 -+ 176 177 178 179 180 181 182 183 -+ 184 185 186 187 188 189 190 191 -+ 192 193 194 195 196 197 198 199 -+ 200 201 202 203 204 205 206 207 -+ 208 209 210 211 212 213 214 215 -+ 216 217 218 219 220 221 222 223 -+ 224 225 226 227 228 229 230 231 -+ 232 233 234 235 236 237 238 239 -+ 240 241 242 243 244 245 246 247 -+ 248 249 250 251 252 253 254 255>; -+ default-brightness-level = <128>; - }; - - /* led-1 is wired directly to output of always-on regulator */ -@@ -187,6 +134,10 @@ vcc_host: vcc_host { - }; - }; - -+&dmc { -+ center-supply = <&vdd_logic>; -+}; -+ - &cpu0 { - cpu-supply = <&vdd_arm>; - }; -@@ -236,7 +187,6 @@ internal_display: panel@0 { - reg = <0>; - backlight = <&backlight>; - reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>; -- rotation = <270>; - - port { - mipi_in_panel: endpoint { -@@ -271,6 +221,7 @@ rk817: pmic@20 { - clocks = <&cru SCLK_I2S1_OUT>; - pinctrl-names = "default"; - pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; -+ rockchip,system-power-controller; - wakeup-source; - #clock-cells = <1>; - #sound-dai-cells = <0>; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts -index d94ac81eb4e6..1c276b93cb4a 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts -+++ b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts -@@ -16,31 +16,187 @@ aliases { - mmc1 = &sdio; - }; - -- analog_sticks: adc-joystick { -- compatible = "adc-joystick"; -- io-channels = <&saradc 1>, -- <&saradc 2>; -- poll-interval = <60>; -- #address-cells = <1>; -- #size-cells = <0>; -- -- axis@0 { -- reg = <0>; -- abs-flat = <10>; -- abs-fuzz = <10>; -- abs-range = <172 772>; -- linux,code = ; -- }; -+ gpio_keys: volume-keys { -+ compatible = "gpio-keys-polled"; -+ poll-interval = <5>; -+ autorepeat; -+ -+ volume-up-button { -+ label = "VOLUMEUP"; -+ linux,code = ; -+ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -+ -+ }; -+ volume-down-button { -+ label = "VOLUMEDOWN"; -+ linux,code = ; -+ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; - -- axis@1 { -- reg = <1>; -- abs-flat = <10>; -- abs-fuzz = <10>; -- abs-range = <278 815>; -- linux,code = ; - }; - }; - -+ joypad: odroidgo2-joypad { -+ compatible = "odroidgo2-v11-joypad"; -+ -+ /* -+ - odroidgo2-joypad sysfs list - -+ * for poll device interval(ms) -+ /sys/devices/platform/odroidgo2_joypad/poll_interval [rw] -+ * for button-adc-fuzz -+ /sys/devices/platform/odroidgo2_joypad/adc_fuzz [r] -+ * for button-adc-flat -+ /sys/devices/platform/odroidgo2_joypad/adc_flat [r] -+ -+ * for report control(1:enable, 0:disable) -+ /sys/devices/platform/odroidgo2_joypad/enable [rw] -+ * for adc calibration value setup(1:current adcs value -> cal value) -+ /sys/devices/platform/odroidgo2_joypad/adc_cal [rw] -+ */ -+ -+ /* gpio pincontrol setup */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; -+ -+ /* JOY_X, JOY_Y Channel define */ -+ io-channel-names = "joy_x", "joy_y"; -+ io-channels = <&saradc 1>, <&saradc 2>; -+ -+ /* adc channel count */ -+ button-adc-count = <2>; -+ -+ /* adc calculate scale */ -+ button-adc-scale = <2>; -+ -+ /* adc deadzone range */ -+ button-adc-deadzone = <20>; -+ -+ /* -+ joy-stick voltage range -+ /sys/devices/platform/ff288000.saradc/iio:device0 -+ adc-x : in_voltage1_raw -+ adc-y : in_voltage2_raw -+ -+ range calculate. -+ (adc raw max value - adc raw min value) * scale * 1.7515 -+ */ -+ button-adc-x-range = <1800>; -+ button-adc-y-range = <1800>; -+ -+ /* -+ specifies fuzz value that is used to filter noise from -+ the event stream. -+ */ -+ button-adc-fuzz = <32>; -+ button-adc-flat = <32>; -+ -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ -+ /* gpio button auto repeat set value : default disable */ -+ /* -+ autorepeat; -+ */ -+ -+ /* -+ *** ODROIDGO2-Advance Switch layoout *** -+ |------------------------------------------------| -+ | sw15 sw16 | -+ | sw20 sw21 | -+ |------------------------------------------------| -+ | sw1 |-------------------| sw8 | -+ | sw3 sw4 | | sw7 sw5 | -+ | sw2 | LCD Display | sw6 | -+ | | | | -+ | |-------------------| | -+ | sw9 sw10 vol- vol+ sw13 sw14 | -+ |------------------------------------------------| -+ */ -+ /* -+ joypad driver is poll-device driver. -+ poll-device is does not support wakeup-source. -+ */ -+ sw1 { -+ gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-UP"; -+ linux,code = ; // 0x220 -+ }; -+ sw2 { -+ gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-DOWN"; -+ linux,code = ; // 0x221 -+ }; -+ sw3 { -+ gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-LEFT"; -+ linux,code = ; // 0x222 -+ }; -+ sw4 { -+ gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-RIGHT"; -+ linux,code = ; // 0x223 -+ }; -+ sw5 { -+ gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO KEY BTN-A"; -+ linux,code = ; // 0x131 -+ }; -+ sw6 { -+ gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-B"; -+ linux,code = ; // 0x130 -+ }; -+ sw7 { -+ gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-Y"; -+ linux,code = ; // 0x134 -+ }; -+ sw8 { -+ gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-X"; -+ linux,code = ; // 0x133 -+ }; -+ sw9 { -+ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-SELECT"; -+ linux,code = ; // 0x2c0 -+ }; -+ sw10 { -+ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-THUMBL"; -+ linux,code = ; // 0x2c1 -+ }; -+ sw13 { -+ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-THUMBR"; -+ linux,code = ; // 0x2c4 -+ }; -+ sw14 { -+ gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-START"; -+ linux,code = ; // 0x13c -+ }; -+ sw15 { -+ gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT"; -+ linux,code = ; // 0x02 -+ }; -+ sw16 { -+ gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT"; -+ linux,code = ; // 0x05 -+ }; -+ sw20 { -+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT2"; -+ linux,code = ; -+ }; -+ sw21 { -+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT2"; -+ linux,code = ; -+ }; -+ }; -+ - battery: battery { - compatible = "simple-battery"; - charge-full-design-microamp-hours = <3000000>; -@@ -65,19 +221,8 @@ wifi_pwrseq: wifi-pwrseq { - pinctrl-names = "default"; - pinctrl-0 = <&wifi_pwrseq_pins>; - reset-gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; -- }; --}; -- --&builtin_gamepad { -- button-sw20 { -- gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; -- label = "TOP-LEFT 2"; -- linux,code = ; -- }; -- button-sw21 { -- gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -- label = "TOP-RIGHT 2"; -- linux,code = ; -+ post-power-on-delay-ms = <300>; -+ power-off-delay-us = <200000>; - }; - }; - -@@ -85,6 +230,7 @@ &internal_display { - compatible = "elida,kd35t133"; - iovcc-supply = <&vcc_lcd>; - vdd-supply = <&vcc_lcd>; -+ rotation = <270>; - }; - - &rk817 { -@@ -93,9 +239,11 @@ vcc_wifi: LDO_REG9 { - regulator-name = "vcc_wifi"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; -+ regulator-always-on; -+ regulator-boot-on; - - regulator-state-mem { -- regulator-on-in-suspend; -+ regulator-off-in-suspend; - regulator-suspend-microvolt = <3300000>; - }; - }; -@@ -112,16 +260,15 @@ &sdio { - cap-sdio-irq; - disable-wp; - keep-power-in-suspend; -- mmc-pwrseq = <&wifi_pwrseq>; - non-removable; - vmmc-supply = <&vcc_wifi>; -- #address-cells = <1>; -- #size-cells = <0>; -+ mmc-pwrseq = <&wifi_pwrseq>; - status = "okay"; - - esp8089: wifi@1 { - compatible = "esp,esp8089"; - reg = <1>; -+ esp,crystal-26M-en = <1>; - }; - }; - -@@ -138,8 +285,6 @@ btn_pins: btn-pins { - <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, - <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, - <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>, -- <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -- <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, - <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, - <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, - <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts -index aa6f5b12206b..f142737a0111 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts -+++ b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts -@@ -12,30 +12,175 @@ / { - model = "ODROID-GO Advance"; - compatible = "hardkernel,rk3326-odroid-go2", "rockchip,rk3326"; - -- analog_sticks: adc-joystick { -- compatible = "adc-joystick"; -- io-channels = <&saradc 1>, -- <&saradc 2>; -- poll-interval = <60>; -- #address-cells = <1>; -- #size-cells = <0>; -- -- axis@0 { -- reg = <0>; -- abs-flat = <10>; -- abs-fuzz = <10>; -- abs-range = <172 772>; -- linux,code = ; -- }; -- -- axis@1 { -- reg = <1>; -- abs-flat = <10>; -- abs-fuzz = <10>; -- abs-range = <278 815>; -- linux,code = ; -- }; -- }; -+ gpio_keys: volume-keys { -+ compatible = "gpio-keys-polled"; -+ poll-interval = <5>; -+ autorepeat; -+ -+ volume-up-button { -+ label = "VOLUME-UP"; -+ linux,code = ; -+ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -+ -+ }; -+ volume-down-button { -+ label = "VOLUME-DOWN"; -+ linux,code = ; -+ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; -+ -+ }; -+ }; -+ -+ joypad: odroidgo2-joypad { -+ compatible = "odroidgo2-joypad"; -+ -+ /* -+ - odroidgo2-joypad sysfs list - -+ * for poll device interval(ms) -+ /sys/devices/platform/odroidgo2_joypad/poll_interval [rw] -+ * for button-adc-fuzz -+ /sys/devices/platform/odroidgo2_joypad/adc_fuzz [r] -+ * for button-adc-flat -+ /sys/devices/platform/odroidgo2_joypad/adc_flat [r] -+ -+ * for report control(1:enable, 0:disable) -+ /sys/devices/platform/odroidgo2_joypad/enable [rw] -+ * for adc calibration value setup(1:current adcs value -> cal value) -+ /sys/devices/platform/odroidgo2_joypad/adc_cal [rw] -+ */ -+ -+ /* gpio pincontrol setup */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; -+ -+ /* JOY_X, JOY_Y Channel define */ -+ io-channel-names = "joy_x", "joy_y"; -+ io-channels = <&saradc 1>, <&saradc 2>; -+ -+ /* adc channel count */ -+ button-adc-count = <2>; -+ -+ /* adc calculate scale */ -+ button-adc-scale = <2>; -+ -+ /* adc deadzone range */ -+ button-adc-deadzone = <20>; -+ -+ /* -+ joy-stick voltage range -+ /sys/devices/platform/ff288000.saradc/iio:device0 -+ adc-x : in_voltage1_raw -+ adc-y : in_voltage2_raw -+ -+ range calculate. -+ (adc raw max value - adc raw min value) * scale * 1.7515 -+ */ -+ button-adc-x-range = <1800>; -+ button-adc-y-range = <1800>; -+ -+ /* -+ specifies fuzz value that is used to filter noise from -+ the event stream. -+ */ -+ button-adc-fuzz = <32>; -+ button-adc-flat = <32>; -+ -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ -+ /* gpio button auto repeat set value : default disable */ -+ /* -+ autorepeat; -+ */ -+ -+ /* -+ *** ODROIDGO2-Advance Switch layoout *** -+ |------------------------------------------------| -+ | sw15 sw16 | -+ |------------------------------------------------| -+ | sw1 |-------------------| sw8 | -+ | sw3 sw4 | | sw7 sw5 | -+ | sw2 | LCD Display | sw6 | -+ | | | | -+ | |-------------------| | -+ | sw9 sw10 vol- vol+ sw13 sw14 | -+ |------------------------------------------------| -+ */ -+ /* -+ joypad driver is poll-device driver. -+ poll-device is does not support wakeup-source. -+ */ -+ sw1 { -+ gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-UP"; -+ linux,code = ; // 0x220 -+ }; -+ sw2 { -+ gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-DOWN"; -+ linux,code = ; // 0x221 -+ }; -+ sw3 { -+ gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-LEFT"; -+ linux,code = ; // 0x222 -+ }; -+ sw4 { -+ gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-RIGHT"; -+ linux,code = ; // 0x223 -+ }; -+ sw5 { -+ gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO KEY BTN-A"; -+ linux,code = ; // 0x131 -+ }; -+ sw6 { -+ gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-B"; -+ linux,code = ; // 0x130 -+ }; -+ sw7 { -+ gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-Y"; -+ linux,code = ; // 0x134 -+ }; -+ sw8 { -+ gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-X"; -+ linux,code = ; // 0x133 -+ }; -+ sw9 { -+ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -+ label = "GPIO F1"; -+ linux,code = ; // 0x2c0 -+ }; -+ sw10 { -+ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -+ label = "GPIO F2"; -+ linux,code = ; // 0x2c1 -+ }; -+ sw13 { -+ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; -+ label = "GPIO F5"; -+ linux,code = ; // 0x2c4 -+ }; -+ sw14 { -+ gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO F6"; -+ linux,code = ; // 0x13c -+ }; -+ sw15 { -+ gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT"; -+ linux,code = ; // 0x02 -+ }; -+ sw16 { -+ gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT"; -+ linux,code = ; // 0x05 -+ }; -+ }; - - battery: battery { - compatible = "simple-battery"; -@@ -61,8 +206,30 @@ &internal_display { - compatible = "elida,kd35t133"; - iovcc-supply = <&vcc_lcd>; - vdd-supply = <&vcc_lcd>; -+ rotation = <270>; - }; - - &rk817_charger { - monitored-battery = <&battery>; - }; -+ -+&pinctrl { -+ btns { -+ btn_pins: btn-pins { -+ rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ }; -+}; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts -index 35bbaf559ca3..d03b3d9cb675 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts -+++ b/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts -@@ -12,67 +12,201 @@ / { - model = "ODROID-GO Super"; - compatible = "hardkernel,rk3326-odroid-go3", "rockchip,rk3326"; - -- joystick_mux_controller: mux-controller { -- compatible = "gpio-mux"; -- pinctrl = <&mux_en_pins>; -- #mux-control-cells = <0>; -+ joypad: odroidgo3-joypad { -+ compatible = "odroidgo3-joypad"; - -- mux-gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>, -- <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>; -- }; -+ joypad-name = "odroidgo3_joypad"; -+ joypad-product = <0x0001>; -+ joypad-revision = <0x0101>; -+ -+ status = "okay"; -+ /* -+ - odroidgo3-joypad sysfs list - -+ * for poll device interval(ms) -+ /sys/devices/platform/odroidgo3_joypad/poll_interval [rw] -+ ex) echo 20 > poll_interval -+ * for button-adc-fuzz -+ /sys/devices/platform/odroidgo3_joypad/adc_fuzz [r] -+ * for button-adc-flat -+ /sys/devices/platform/odroidgo3_joypad/adc_flat [r] -+ -+ * for report control(1:enable, 0:disable) -+ /sys/devices/platform/odroidgo3_joypad/enable [rw] -+ * for adc calibration value setup(current adcs value -> cal value) -+ /sys/devices/platform/odroidgo3_joypad/adc_cal [rw] -+ ex) echo 0 > adc_cal -+ * for amux data debug -+ * Joypad driver is disabled when using this sysfs. -+ /sys/devices/platform/odroidgo3_joypad/amux_debug [rw] -+ ex) echo 0 > amux_debug --> select amux channel -+ ex) cat amux_debug --> get adc data of seleted channel -+ */ -+ -+ /* gpio pincontrol setup */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; - -- joystick_mux: adc-mux { -- compatible = "io-channel-mux"; -+ /* Analog mux define */ -+ io-channel-names = "amux_adc"; - io-channels = <&saradc 1>; -- io-channel-names = "parent"; -- #io-channel-cells = <1>; - -- mux-controls = <&joystick_mux_controller>; -- channels = "0", "1", "2", "3"; -- }; -+ /* adc mux channel count */ -+ amux-count = <4>; -+ /* adc mux select(a,b) gpio */ -+ amux-a-gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; -+ amux-b-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>; -+ /* adc mux enable gpio */ -+ amux-en-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; - -- analog_sticks: adc-joystick { -- compatible = "adc-joystick"; -- io-channels = <&joystick_mux 0>, -- <&joystick_mux 1>, -- <&joystick_mux 2>, -- <&joystick_mux 3>; -- poll-interval = <60>; -- #address-cells = <1>; -- #size-cells = <0>; -- -- axis@0 { -- reg = <0>; -- abs-flat = <10>; -- abs-fuzz = <10>; -- abs-range = <180 800>; -- linux,code = ; -- }; -+ /* adc calculate scale */ -+ button-adc-scale = <2>; - -- axis@1 { -- reg = <1>; -- abs-flat = <10>; -- abs-fuzz = <10>; -- abs-range = <180 800>; -- linux,code = ; -- }; -+ /* adc deadzone range */ -+ button-adc-deadzone = <64>; - -- axis@2 { -- reg = <2>; -- abs-flat = <10>; -- abs-fuzz = <10>; -- abs-range = <180 800>; -- linux,code = ; -- }; -+ /* -+ specifies fuzz value that is used to filter noise from -+ the event stream. -+ */ -+ button-adc-fuzz = <32>; -+ button-adc-flat = <32>; - -- axis@3 { -- reg = <3>; -- abs-flat = <10>; -- abs-fuzz = <10>; -- abs-range = <180 800>; -- linux,code = ; -- }; -- }; -+ /* -+ Analog Stick data tuning value(precent) -+ p = positive direction, n = negative direction -+ report value = (real_adc_data * tuning_value) / 100 -+ */ -+ abs_x-p-tuning = <180>; -+ abs_x-n-tuning = <180>; -+ -+ abs_y-p-tuning = <180>; -+ abs_y-n-tuning = <170>; -+ -+ abs_rx-p-tuning = <180>; -+ abs_rx-n-tuning = <180>; -+ -+ abs_ry-p-tuning = <180>; -+ abs_ry-n-tuning = <170>; -+ -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ -+ /* gpio button auto repeat set value : default disable */ -+ /* -+ autorepeat; -+ */ -+ -+ /* -+ *** ODROIDGO3-Advance Switch layoout *** -+ |------------------------------------------------| -+ | sw15 sw21 sw10 sw9 sw20 sw16 | -+ |------------------------------------------------| -+ | sw19 sw22 | -+ | |-------------------| | -+ | sw1 | | sw8 | -+ | sw3 sw4 | | sw7 sw5 | -+ | sw2 | LCD Display | sw6 | -+ | | | | -+ | | | | -+ | |-------------------| | -+ | sw11 sw12 | sd-slot | sw13 sw14 | -+ |-------------------| |------------------| -+ */ -+ /* -+ joypad driver is poll-device driver. -+ poll-device is does not support wakeup-source. -+ */ -+ sw1 { -+ gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-UP"; -+ linux,code = ; // 0x220 -+ }; -+ sw2 { -+ gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-DOWN"; -+ linux,code = ; // 0x221 -+ }; -+ sw3 { -+ gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-LEFT"; -+ linux,code = ; // 0x222 -+ }; -+ sw4 { -+ gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-RIGHT"; -+ linux,code = ; // 0x223 -+ }; -+ sw5 { -+ gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO KEY BTN-A"; -+ linux,code = ; // 0x131 -+ }; -+ sw6 { -+ gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-B"; -+ linux,code = ; // 0x130 -+ }; -+ sw7 { -+ gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-Y"; -+ linux,code = ; // 0x134 -+ }; -+ sw8 { -+ gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-X"; -+ linux,code = ; // 0x133 -+ }; -+ sw11 { -+ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO F3"; -+ linux,code = ; // 0x2c2 -+ }; -+ sw12 { -+ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -+ label = "GPIO F4"; -+ linux,code = ; // 0x2c3 -+ }; -+ sw13 { -+ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; -+ label = "GPIO F5"; -+ linux,code = ; // 0x2c4 -+ }; -+ sw14 { -+ gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO F6"; -+ linux,code = ; // 0x13c -+ }; -+ sw15 { -+ gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT"; -+ linux,code = ; // 0x02 -+ }; -+ sw16 { -+ gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT"; -+ linux,code = ; // 0x05 -+ }; -+ sw19 { -+ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; -+ label = "GPIO F1"; -+ linux,code = ; -+ }; -+ sw20 { -+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT2"; -+ linux,code = ; -+ }; -+ sw21 { -+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT2"; -+ linux,code = ; -+ }; -+ sw22 { -+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO F2"; -+ linux,code = ; -+ }; -+ }; - - battery: battery { - compatible = "simple-battery"; -@@ -113,39 +247,12 @@ button-volume-up { - }; - }; - --/* f1 and f2 conflict with volume buttons */ --/delete-node/ &btn_f1; --/delete-node/ &btn_f2; -- --&builtin_gamepad { -- button-sw19 { -- gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; -- label = "SELECT"; -- linux,code = ; -- }; -- /* note that TR2 and TL2 are swapped */ -- button-sw20 { -- gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; -- label = "TOP-RIGHT 2"; -- linux,code = ; -- }; -- button-sw21 { -- gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -- label = "TOP-LEFT 2"; -- linux,code = ; -- }; -- button-sw22 { -- gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; -- label = "START"; -- linux,code = ; -- }; --}; -- - &internal_display { - compatible = "elida,kd50t048a", "sitronix,st7701"; - reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_HIGH>; - IOVCC-supply = <&vcc_lcd>; - VCC-supply = <&vcc_lcd>; -+ rotation = <270>; - }; - - &rk817_charger { -@@ -179,10 +286,4 @@ btn_pins_vol: btn-pins-vol { - <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; - }; - }; -- -- joystick { -- mux_en_pins: mux-pins { -- rockchip,pins = <3 RK_PB5 RK_FUNC_GPIO &pcfg_output_low>; -- }; -- }; - }; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10.dts b/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10.dts -new file mode 100644 -index 000000000000..23a30542b906 ---- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10.dts -@@ -0,0 +1,280 @@ -+// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * Copyright (c) 2019 Hardkernel Co., Ltd -+ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH -+ * Copyright (c) 2022 Maya Matuszczyk -+ */ -+ -+/dts-v1/; -+#include "rk3326-odroid-go.dtsi" -+ -+/ { -+ model = "Powkiddy RGB10"; -+ compatible = "powkiddy,rk3326-rgb10", "rockchip,rk3326"; -+ -+ aliases { -+ mmc1 = &sdio; -+ }; -+ -+ joypad: odroidgo2-joypad { -+ compatible = "odroidgo2-v11-joypad"; -+ -+ /* -+ - odroidgo2-joypad sysfs list - -+ * for poll device interval(ms) -+ /sys/devices/platform/odroidgo2_joypad/poll_interval [rw] -+ * for button-adc-fuzz -+ /sys/devices/platform/odroidgo2_joypad/adc_fuzz [r] -+ * for button-adc-flat -+ /sys/devices/platform/odroidgo2_joypad/adc_flat [r] -+ -+ * for report control(1:enable, 0:disable) -+ /sys/devices/platform/odroidgo2_joypad/enable [rw] -+ * for adc calibration value setup(1:current adcs value -> cal value) -+ /sys/devices/platform/odroidgo2_joypad/adc_cal [rw] -+ */ -+ -+ /* gpio pincontrol setup */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; -+ -+ /* JOY_X, JOY_Y Channel define */ -+ io-channel-names = "joy_x", "joy_y"; -+ io-channels = <&saradc 1>, <&saradc 2>; -+ -+ /* adc channel count */ -+ button-adc-count = <2>; -+ -+ /* adc calculate scale */ -+ button-adc-scale = <2>; -+ -+ /* adc deadzone range */ -+ button-adc-deadzone = <20>; -+ -+ /* -+ joy-stick voltage range -+ /sys/devices/platform/ff288000.saradc/iio:device0 -+ adc-x : in_voltage1_raw -+ adc-y : in_voltage2_raw -+ -+ range calculate. -+ (adc raw max value - adc raw min value) * scale * 1.7515 -+ */ -+ button-adc-x-range = <1800>; -+ button-adc-y-range = <1800>; -+ -+ /* -+ specifies fuzz value that is used to filter noise from -+ the event stream. -+ */ -+ button-adc-fuzz = <32>; -+ button-adc-flat = <32>; -+ -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ -+ /* gpio button auto repeat set value : default disable */ -+ /* -+ autorepeat; -+ */ -+ -+ /* -+ *** RGB10 Switch layoout *** -+ |------------------------------------------------| -+ | sw15 sw16 | -+ | sw20 sw21 | -+ |------------------------------------------------| -+ | sw1 sw10 |-------------------| sw13 sw8 | -+ | sw3 sw4 | | sw7 sw5 | -+ | sw2 | LCD Display | sw6 | -+ | | | | -+ | |-------------------| | -+ |------------------------------------------------| -+ */ -+ /* -+ joypad driver is poll-device driver. -+ poll-device is does not support wakeup-source. -+ */ -+ sw1 { -+ gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-UP"; -+ linux,code = ; // 0x220 -+ }; -+ sw2 { -+ gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-DOWN"; -+ linux,code = ; // 0x221 -+ }; -+ sw3 { -+ gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-LEFT"; -+ linux,code = ; // 0x222 -+ }; -+ sw4 { -+ gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-RIGHT"; -+ linux,code = ; // 0x223 -+ }; -+ sw5 { -+ gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO KEY BTN-A"; -+ linux,code = ; // 0x131 -+ }; -+ sw6 { -+ gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-B"; -+ linux,code = ; // 0x130 -+ }; -+ sw7 { -+ gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-Y"; -+ linux,code = ; // 0x134 -+ }; -+ sw8 { -+ gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-X"; -+ linux,code = ; // 0x133 -+ }; -+ sw9 { -+ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-SELECT"; -+ linux,code = ; // 0x2c0 -+ }; -+ sw10 { -+ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-THUMBL"; -+ linux,code = ; // 0x2c1 -+ }; -+ sw13 { -+ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-THUMBR"; -+ linux,code = ; // 0x2c4 -+ }; -+ sw14 { -+ gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-START"; -+ linux,code = ; // 0x13c -+ }; -+ sw15 { -+ gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT"; -+ linux,code = ; // 0x02 -+ }; -+ sw16 { -+ gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT"; -+ linux,code = ; // 0x05 -+ }; -+ sw20 { -+ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT2"; -+ linux,code = ; -+ }; -+ sw21 { -+ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT2"; -+ linux,code = ; -+ }; -+ }; -+ -+ battery: battery { -+ compatible = "simple-battery"; -+ charge-full-design-microamp-hours = <2800000>; -+ charge-term-current-microamp = <280000>; -+ constant-charge-current-max-microamp = <2000000>; -+ constant-charge-voltage-max-microvolt = <4200000>; -+ factory-internal-resistance-micro-ohms = <180000>; -+ voltage-max-design-microvolt = <4100000>; -+ voltage-min-design-microvolt = <3500000>; -+ -+ ocv-capacity-celsius = <20>; -+ ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, -+ <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, -+ <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, -+ <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, -+ <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, -+ <3574170 0>; -+ }; -+ -+ wifi_pwrseq: wifi-pwrseq { -+ compatible = "mmc-pwrseq-simple"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&wifi_pwrseq_pins>; -+ /*reset-gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>;*/ -+ }; -+}; -+ -+&internal_display { -+ compatible = "elida,kd35t133"; -+ iovcc-supply = <&vcc_lcd>; -+ vdd-supply = <&vcc_lcd>; -+ rotation = <270>; -+}; -+ -+&rk817 { -+ regulators { -+ vcc_wifi: LDO_REG9 { -+ regulator-name = "vcc_wifi"; -+ regulator-min-microvolt = <3300000>; -+ regulator-max-microvolt = <3300000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <3300000>; -+ }; -+ }; -+ }; -+}; -+ -+&rk817_charger { -+ monitored-battery = <&battery>; -+}; -+ -+&sdio { -+ bus-width = <4>; -+ cap-sd-highspeed; -+ cap-sdio-irq; -+ disable-wp; -+ keep-power-in-suspend; -+ non-removable; -+ vmmc-supply = <&vcc_wifi>; -+ status = "okay"; -+ -+ esp8089: wifi@1 { -+ compatible = "esp,esp8089"; -+ reg = <1>; -+ esp,crystal-26M-en = <2>; -+ }; -+}; -+ -+&pinctrl { -+ btns { -+ btn_pins: btn-pins { -+ rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ }; -+ -+ wifi { -+ wifi_pwrseq_pins: wifi-pwrseq-pins { -+ rockchip,pins = /*<3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>,*/ -+ <3 RK_PB6 RK_FUNC_GPIO &pcfg_output_high>; -+ }; -+ }; -+}; -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb20s.dts b/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb20s.dts -new file mode 100644 -index 000000000000..cf507db957ed ---- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb20s.dts -@@ -0,0 +1,340 @@ -+// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * Copyright (c) 2019 Hardkernel Co., Ltd -+ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH -+ * Copyright (c) 2022 Maya Matuszczyk -+ */ -+ -+/dts-v1/; -+#include "rk3326-odroid-go.dtsi" -+ -+/ { -+ model = "Powkiddy RGB20S"; -+ compatible = "powkiddy,rgb20s", "rockchip,rk3326"; -+ -+ aliases { -+ mmc0 = &sdio; -+ mmc1 = &sdmmc; -+ }; -+ -+ gpio-keys-vol { -+ compatible = "gpio-keys"; -+ autorepeat; -+ pinctrl-0 = <&btn_pins_vol>; -+ pinctrl-names = "default"; -+ -+ button-vol-down { -+ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEDOWN"; -+ linux,code = ; -+ }; -+ -+ button-volume-up { -+ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEUP"; -+ linux,code = ; -+ }; -+ }; -+ -+ joypad: rgb20s-joypad { -+ compatible = "rgb20s-joypad"; -+ -+ pwms = <&pwm0 0 200000000 0>; -+ pwm-names = "enable"; -+ rumble-boost-weak = <0x0000>; -+ rumble-boost-strong = <0x0000>; -+ -+ joypad-name = "RGB20S Gamepad"; -+ joypad-product = <0x1177>; -+ joypad-revision = <0x0177>; -+ -+ status = "okay"; -+ /* -+ - odroidgo3-joypad sysfs list - -+ * for poll device interval(ms) -+ /sys/devices/platform/odroidgo3_joypad/poll_interval [rw] -+ ex) echo 20 > poll_interval -+ * for button-adc-fuzz -+ /sys/devices/platform/odroidgo3_joypad/adc_fuzz [r] -+ * for button-adc-flat -+ /sys/devices/platform/odroidgo3_joypad/adc_flat [r] -+ -+ * for report control(1:enable, 0:disable) -+ /sys/devices/platform/odroidgo3_joypad/enable [rw] -+ * for adc calibration value setup(current adcs value -> cal value) -+ /sys/devices/platform/odroidgo3_joypad/adc_cal [rw] -+ ex) echo 0 > adc_cal -+ -+ * for rumble period(ns) -+ /sys/devices/platform/odroidgo3_joypad/rumble_period -+ ex) echo 20000000 > rumble_duty_cycle -+ ex) cat rumble_duty_cycle -->get current duty cycle -+ -+ * for rumble boost(0~65535) -+ /sys/devices/platform/odroidgo3_joypad/rumble_boost_weak -+ /sys/devices/platform/odroidgo3_joypad/rumble_boost_strong -+ -+ * for amux data debug -+ * Joypad driver is disabled when using this sysfs. -+ /sys/devices/platform/odroidgo3_joypad/amux_debug [rw] -+ ex) echo 0 > amux_debug --> select amux channel -+ ex) cat amux_debug --> get adc data of seleted channel -+ */ -+ -+ /* gpio pincontrol setup */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; -+ pinctrl-1 = <&pwm0_pin>; -+ -+ /* Analog mux define */ -+ io-channel-names = "amux_adc"; -+ io-channels = <&saradc 1>; -+ -+ /* adc mux channel count */ -+ amux-count = <4>; -+ /* adc mux select(a,b) gpio */ -+ amux-a-gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; -+ amux-b-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>; -+ /* adc mux enable gpio */ -+ amux-en-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; -+ -+ /* adc calculate scale */ -+ button-adc-scale = <2>; -+ -+ /* adc deadzone range */ -+ button-adc-deadzone = <64>; -+ -+ /* -+ specifies fuzz value that is used to filter noise from -+ the event stream. -+ */ -+ button-adc-fuzz = <32>; -+ button-adc-flat = <32>; -+ -+ /* -+ Analog Stick data tuning value(precent) -+ p = positive direction, n = negative direction -+ report value = (real_adc_data * tuning_value) / 100 -+ */ -+ abs_x-p-tuning = <200>; -+ abs_x-n-tuning = <200>; -+ -+ abs_y-p-tuning = <200>; -+ abs_y-n-tuning = <200>; -+ -+ abs_rx-p-tuning = <200>; -+ abs_rx-n-tuning = <200>; -+ -+ abs_ry-p-tuning = <200>; -+ abs_ry-n-tuning = <200>; -+ -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ -+ /* required for RG351MP */ -+ invert-absx; -+ invert-absy; -+ -+ /* gpio button auto repeat set value : default disable */ -+ /* -+ autorepeat; -+ */ -+ -+ /* -+ joypad driver is poll-device driver. -+ poll-device is does not support wakeup-source. -+ */ -+ sw1 { -+ gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-UP"; -+ linux,code = ; // 0x220 -+ }; -+ sw2 { -+ gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-DOWN"; -+ linux,code = ; // 0x221 -+ }; -+ sw3 { -+ gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-LEFT"; -+ linux,code = ; // 0x222 -+ }; -+ sw4 { -+ gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-RIGHT"; -+ linux,code = ; // 0x223 -+ }; -+ sw5 { -+ gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO KEY BTN-A"; -+ linux,code = ; // 0x131 -+ }; -+ sw6 { -+ gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-B"; -+ linux,code = ; // 0x130 -+ }; -+ sw7 { -+ gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-Y"; -+ linux,code = ; // 0x134 -+ }; -+ sw8 { -+ gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-X"; -+ linux,code = ; // 0x133 -+ }; -+ sw11 { -+ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO F3"; -+ linux,code = ; // 0x2c2 -+ }; -+ sw12 { -+ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -+ label = "GPIO F4"; -+ linux,code = ; // 0x2c3 -+ }; -+ /*sw13 { -+ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; -+ label = "GPIO F5"; -+ linux,code = ; // 0x2c4 -+ }; -+ sw14 { -+ gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; -+ label = "GPIO F6"; -+ linux,code = ; // 0x13c -+ };*/ -+ sw15 { -+ gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT"; -+ linux,code = ; // 0x02 -+ }; -+ sw16 { -+ gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT"; -+ linux,code = ; // 0x05 -+ }; -+ sw19 { -+ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; -+ label = "GPIO F1"; -+ linux,code = ; -+ }; -+ sw20 { -+ gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT2"; -+ linux,code = ; -+ }; -+ sw21 { -+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT2"; -+ linux,code = ; -+ }; -+ sw22 { -+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO F2"; -+ linux,code = ; -+ }; -+ }; -+ -+ battery: battery { -+ compatible = "simple-battery"; -+ charge-full-design-microamp-hours = <3500000>; -+ charge-term-current-microamp = <350000>; -+ constant-charge-current-max-microamp = <2000000>; -+ constant-charge-voltage-max-microvolt = <4200000>; -+ factory-internal-resistance-micro-ohms = <180000>; -+ voltage-max-design-microvolt = <4100000>; -+ voltage-min-design-microvolt = <3500000>; -+ -+ ocv-capacity-celsius = <20>; -+ ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, -+ <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, -+ <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, -+ <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, -+ <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, -+ <3574170 0>; -+ }; -+}; -+ -+/* conflicts with pwm vibration motor */ -+/delete-node/ &vcc_host; -+ -+/* Device only has 1 LED compared to Odroid Go Advance */ -+/delete-node/ &gpio_led; -+ -+&internal_display { -+// compatible = "anbernic,rg351v-panel", "newvision,nv3051d"; -+ compatible = "powkiddy,rk2023-panel", "newvision,nv3051d"; -+ iovcc-supply = <&vcc_lcd>; -+ vdd-supply = <&vcc_lcd>; -+}; -+ -+&io_domains { -+ vccio1-supply = <&vccio_sd>; -+}; -+ -+/delete-node/ &pwm_led; -+ -+&pwm0 { -+ status = "okay"; -+}; -+ -+/delete-node/ &pwm3; -+ -+&rk817_charger { -+ /* This device does not have a current sense resistor */ -+ rockchip,resistor-sense-micro-ohms = <0>; -+ monitored-battery = <&battery>; -+}; -+ -+&sdio { -+ cap-sd-highspeed; -+ card-detect-delay = <200>; -+ cd-gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; /*[> CD GPIO <]*/ -+ sd-uhs-sdr12; -+ sd-uhs-sdr25; -+ sd-uhs-sdr50; -+ sd-uhs-sdr104; -+ vmmc-supply = <&vcc_sd>; -+ vqmmc-supply = <&vccio_sd>; -+ status = "okay"; -+}; -+ -+&vcc_sd { -+ regulator-max-microvolt = <3000000>; -+ regulator-min-microvolt = <1800000>; -+}; -+ -+&vccio_sd { -+ regulator-max-microvolt = <1800000>; -+}; -+ -+&pinctrl { -+ btns { -+ btn_pins_vol: btn-pins-vol { -+ rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ -+ btn_pins: btn-pins { -+ rockchip,pins = <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ }; -+}; diff --git a/projects/ROCKNIX/devices/RK3326/patches/linux/003-dmc-driver.patch b/projects/ROCKNIX/devices/RK3326/patches/linux/003-dmc-driver.patch deleted file mode 100644 index ef87be675b7..00000000000 --- a/projects/ROCKNIX/devices/RK3326/patches/linux/003-dmc-driver.patch +++ /dev/null @@ -1,289 +0,0 @@ -diff -rupN linux.orig/drivers/devfreq/Kconfig linux/drivers/devfreq/Kconfig ---- linux.orig/drivers/devfreq/Kconfig 2024-01-10 19:42:04.697152003 +0000 -+++ linux/drivers/devfreq/Kconfig 2024-01-10 20:09:49.575772091 +0000 -@@ -141,6 +141,12 @@ config ARM_RK3399_DMC_DEVFREQ - It sets the frequency for the memory controller and reads the usage counts - from hardware. - -+config ARM_ROCKCHIP_BUS_DEVFREQ -+ tristate "rockchip bus" -+ depends on ARCH_ROCKCHIP -+ help -+ rk bus driver -+ - config ARM_SUN8I_A33_MBUS_DEVFREQ - tristate "sun8i/sun50i MBUS DEVFREQ Driver" - depends on ARCH_SUNXI || COMPILE_TEST -diff -rupN linux.orig/drivers/devfreq/Makefile linux/drivers/devfreq/Makefile ---- linux.orig/drivers/devfreq/Makefile 2024-01-10 19:42:04.697152003 +0000 -+++ linux/drivers/devfreq/Makefile 2024-01-10 20:09:49.575772091 +0000 -@@ -13,6 +13,7 @@ obj-$(CONFIG_ARM_IMX_BUS_DEVFREQ) += imx - obj-$(CONFIG_ARM_IMX8M_DDRC_DEVFREQ) += imx8m-ddrc.o - obj-$(CONFIG_ARM_MEDIATEK_CCI_DEVFREQ) += mtk-cci-devfreq.o - obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ) += rk3399_dmc.o -+obj-$(CONFIG_ARM_ROCKCHIP_BUS_DEVFREQ) += rockchip_bus.o - obj-$(CONFIG_ARM_SUN8I_A33_MBUS_DEVFREQ) += sun8i-a33-mbus.o - obj-$(CONFIG_ARM_TEGRA_DEVFREQ) += tegra30-devfreq.o - -diff -rupN linux.orig/drivers/devfreq/rockchip_bus.c linux/drivers/devfreq/rockchip_bus.c ---- linux.orig/drivers/devfreq/rockchip_bus.c 1970-01-01 00:00:00.000000000 +0000 -+++ linux/drivers/devfreq/rockchip_bus.c 2024-01-10 20:09:49.575772091 +0000 -@@ -0,0 +1,258 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Copyright (c) 2018, Fuzhou Rockchip Electronics Co., Ltd. -+ * Author: Tony Xie -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define CLUSTER0 0 -+#define CLUSTER1 1 -+#define MAX_CLUSTERS 2 -+ -+#define to_rockchip_bus_clk_nb(nb) \ -+ container_of(nb, struct rockchip_bus, clk_nb) -+#define to_rockchip_bus_cpufreq_nb(nb) \ -+ container_of(nb, struct rockchip_bus, cpufreq_nb) -+ -+struct busfreq_table { -+ unsigned long freq; -+ unsigned long volt; -+}; -+ -+struct rockchip_bus { -+ struct device *dev; -+ struct regulator *regulator; -+ struct clk *clk; -+ struct notifier_block clk_nb; -+ struct notifier_block cpufreq_nb; -+ struct busfreq_table *freq_table; -+ -+ unsigned int max_state; -+ -+ unsigned long cur_volt; -+ unsigned long cur_rate; -+ -+ /* -+ * Busfreq-policy-cpufreq: -+ * If the cpu frequency of two clusters are both less than or equal to -+ * cpu_high_freq, change bus rate to low_rate, otherwise change it to -+ * high_rate. -+ */ -+ unsigned long high_rate; -+ unsigned long low_rate; -+ unsigned int cpu_high_freq; -+ unsigned int cpu_freq[MAX_CLUSTERS]; -+}; -+ -+static int rockchip_bus_set_freq_table(struct rockchip_bus *bus) -+{ -+ struct device *dev = bus->dev; -+ struct dev_pm_opp *opp; -+ unsigned long freq; -+ int i, count; -+ -+ count = dev_pm_opp_get_opp_count(dev); -+ if (count <= 0) -+ return -EINVAL; -+ -+ bus->max_state = count; -+ bus->freq_table = devm_kcalloc(dev, -+ bus->max_state, -+ sizeof(*bus->freq_table), -+ GFP_KERNEL); -+ if (!bus->freq_table) { -+ bus->max_state = 0; -+ return -ENOMEM; -+ } -+ -+ for (i = 0, freq = 0; i < bus->max_state; i++, freq++) { -+ opp = dev_pm_opp_find_freq_ceil(dev, &freq); -+ if (IS_ERR(opp)) { -+ devm_kfree(dev, bus->freq_table); -+ bus->max_state = 0; -+ return PTR_ERR(opp); -+ } -+ bus->freq_table[i].volt = dev_pm_opp_get_voltage(opp); -+ bus->freq_table[i].freq = freq; -+ dev_pm_opp_put(opp); -+ } -+ -+ return 0; -+} -+ -+static int rockchip_bus_power_control_init(struct rockchip_bus *bus) -+{ -+ struct device *dev = bus->dev; -+ int ret = 0; -+ -+ bus->clk = devm_clk_get(dev, "bus"); -+ if (IS_ERR(bus->clk)) { -+ dev_err(dev, "failed to get bus clock\n"); -+ return PTR_ERR(bus->clk); -+ } -+ -+ bus->regulator = devm_regulator_get(dev, "bus"); -+ if (IS_ERR(bus->regulator)) { -+ dev_err(dev, "failed to get bus regulator\n"); -+ return PTR_ERR(bus->regulator); -+ } -+ -+ ret = dev_pm_opp_of_add_table(dev); -+ if (ret < 0) { -+ dev_err(dev, "failed to get OPP table\n"); -+ return ret; -+ } -+ -+ ret = rockchip_bus_set_freq_table(bus); -+ if (ret < 0) { -+ dev_err(dev, "failed to set bus freq table\n"); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int rockchip_bus_clkfreq_target(struct device *dev, unsigned long freq) -+{ -+ struct rockchip_bus *bus = dev_get_drvdata(dev); -+ unsigned long target_volt = bus->freq_table[bus->max_state - 1].volt; -+ int i; -+ -+ for (i = 0; i < bus->max_state; i++) { -+ if (freq <= bus->freq_table[i].freq) { -+ target_volt = bus->freq_table[i].volt; -+ break; -+ } -+ } -+ -+ printk("AAA target_volt: %lu\n", target_volt); -+ -+ if (bus->cur_volt != target_volt) { -+ if (regulator_set_voltage(bus->regulator, target_volt, -+ INT_MAX)) { -+ dev_err(dev, "failed to set voltage %lu uV\n", -+ target_volt); -+ return -EINVAL; -+ } -+ bus->cur_volt = target_volt; -+ } -+ -+ return 0; -+} -+ -+static int rockchip_bus_clk_notifier(struct notifier_block *nb, -+ unsigned long event, void *data) -+{ -+ struct clk_notifier_data *ndata = data; -+ struct rockchip_bus *bus = to_rockchip_bus_clk_nb(nb); -+ int ret = 0; -+ -+ printk("AAA event %lu, old_rate %lu, new_rate: %lu\n", -+ event, ndata->old_rate, ndata->new_rate); -+ -+ switch (event) { -+ case PRE_RATE_CHANGE: -+ if (ndata->new_rate > ndata->old_rate) -+ ret = rockchip_bus_clkfreq_target(bus->dev, -+ ndata->new_rate); -+ break; -+ case POST_RATE_CHANGE: -+ if (ndata->new_rate < ndata->old_rate) -+ ret = rockchip_bus_clkfreq_target(bus->dev, -+ ndata->new_rate); -+ break; -+ case ABORT_RATE_CHANGE: -+ if (ndata->new_rate > ndata->old_rate) -+ ret = rockchip_bus_clkfreq_target(bus->dev, -+ ndata->old_rate); -+ break; -+ default: -+ break; -+ } -+ -+ return notifier_from_errno(ret); -+} -+ -+static int rockchip_bus_clkfreq(struct rockchip_bus *bus) -+{ -+ struct device *dev = bus->dev; -+ unsigned long init_rate; -+ int ret = 0; -+ -+ ret = rockchip_bus_power_control_init(bus); -+ if (ret) { -+ dev_err(dev, "failed to init power control\n"); -+ return ret; -+ } -+ -+ init_rate = clk_get_rate(bus->clk); -+ printk("init rate %d", init_rate); -+ ret = rockchip_bus_clkfreq_target(dev, init_rate); -+ if (ret) -+ return ret; -+ -+ bus->clk_nb.notifier_call = rockchip_bus_clk_notifier; -+ ret = clk_notifier_register(bus->clk, &bus->clk_nb); -+ if (ret) { -+ dev_err(dev, "failed to register clock notifier\n"); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static const struct of_device_id rockchip_busfreq_of_match[] = { -+ { .compatible = "rockchip,px30-bus", }, -+ { .compatible = "rockchip,rk1808-bus", }, -+ { .compatible = "rockchip,rk3288-bus", }, -+ { .compatible = "rockchip,rk3368-bus", }, -+ { .compatible = "rockchip,rk3399-bus", }, -+ { .compatible = "rockchip,rv1126-bus", }, -+ { }, -+}; -+ -+MODULE_DEVICE_TABLE(of, rockchip_busfreq_of_match); -+ -+static int rockchip_busfreq_probe(struct platform_device *pdev) -+{ -+ struct device *dev = &pdev->dev; -+ struct device_node *np = dev->of_node; -+ struct rockchip_bus *bus; -+ const char *policy_name; -+ int ret = 0; -+ -+ bus = devm_kzalloc(dev, sizeof(*bus), GFP_KERNEL); -+ if (!bus) -+ return -ENOMEM; -+ bus->dev = dev; -+ platform_set_drvdata(pdev, bus); -+ -+ printk("asdfsadfsadffasdafsdhjfsdakasdfjfjasdklsfadkljsdfajklfsadjklfasdjklhasfdhjklafsdhkjsfdajkhfasdk"); -+ return rockchip_bus_clkfreq(bus); -+} -+ -+static struct platform_driver rockchip_busfreq_driver = { -+ .probe = rockchip_busfreq_probe, -+ .driver = { -+ .name = "rockchip-busfreq", -+ .of_match_table = rockchip_busfreq_of_match, -+ }, -+}; -+ -+module_platform_driver(rockchip_busfreq_driver); -+ -+MODULE_LICENSE("GPL v2"); -+MODULE_AUTHOR("Tony Xie "); -+MODULE_DESCRIPTION("rockchip busfreq driver with devfreq framework"); diff --git a/projects/ROCKNIX/devices/RK3326/patches/linux/004-input-drivers.patch b/projects/ROCKNIX/devices/RK3326/patches/linux/004-input-drivers.patch index 0cf37d73a6f..beef4e6ef63 100644 --- a/projects/ROCKNIX/devices/RK3326/patches/linux/004-input-drivers.patch +++ b/projects/ROCKNIX/devices/RK3326/patches/linux/004-input-drivers.patch @@ -973,7 +973,7 @@ index 000000000000..e2953433b491 + return -1; + + printk("%s get vibrator0-gpio = %d \n", __func__, joypad->vib->gpio0); -+ ret = devm_gpio_request(dev, joypad->vib->gpio0, "vibrator0"); ++ ret = devm_gpio_request_one(dev, joypad->vib->gpio0, GPIOF_IN, "vibrator0"); + if (ret < 0) + return ret; + @@ -982,7 +982,7 @@ index 000000000000..e2953433b491 + return -1; + + printk("%s get vibrator1-gpio = %d \n", __func__, joypad->vib->gpio1); -+ ret = devm_gpio_request(dev, joypad->vib->gpio1, "vibrator1"); ++ ret = devm_gpio_request_one(dev, joypad->vib->gpio1, GPIOF_IN, "vibrator1"); + if (ret < 0) + return ret; + @@ -3854,43 +3854,43 @@ index 000000000000..34f182175bcd + amux->sel_a_gpio = of_get_named_gpio_flags(dev->of_node, + "amux-a-gpios", 0, &flags); + if (gpio_is_valid(amux->sel_a_gpio)) { -+ ret = devm_gpio_request(dev, amux->sel_a_gpio, "amux-sel-a"); ++ ret = devm_gpio_request_one(dev, amux->sel_a_gpio, GPIOF_OUT_INIT_LOW, "amux-sel-a"); + if (ret < 0) { + dev_err(dev, "%s : failed to request amux-sel-a %d\n", + __func__, amux->sel_a_gpio); + goto err_out; + } -+ ret = gpio_direction_output(amux->sel_a_gpio, 0); -+ if (ret < 0) -+ goto err_out; ++ ++ ++ + } + + amux->sel_b_gpio = of_get_named_gpio_flags(dev->of_node, + "amux-b-gpios", 0, &flags); + if (gpio_is_valid(amux->sel_b_gpio)) { -+ ret = devm_gpio_request(dev, amux->sel_b_gpio, "amux-sel-b"); ++ ret = devm_gpio_request_one(dev, amux->sel_b_gpio, GPIOF_OUT_INIT_LOW, "amux-sel-b"); + if (ret < 0) { + dev_err(dev, "%s : failed to request amux-sel-b %d\n", + __func__, amux->sel_b_gpio); + goto err_out; + } -+ ret = gpio_direction_output(amux->sel_b_gpio, 0); -+ if (ret < 0) -+ goto err_out; ++ ++ ++ + } + + amux->en_gpio = of_get_named_gpio_flags(dev->of_node, + "amux-en-gpios", 0, &flags); + if (gpio_is_valid(amux->en_gpio)) { -+ ret = devm_gpio_request(dev, amux->en_gpio, "amux-en"); ++ ret = devm_gpio_request_one(dev, amux->en_gpio, GPIOF_OUT_INIT_LOW, "amux-en"); + if (ret < 0) { + dev_err(dev, "%s : failed to request amux-en %d\n", + __func__, amux->en_gpio); + goto err_out; + } -+ ret = gpio_direction_output(amux->en_gpio, 0); -+ if (ret < 0) -+ goto err_out; ++ ++ ++ + } + return 0; +err_out: @@ -5139,43 +5139,43 @@ index 000000000000..a52981eee9fb + amux->sel_a_gpio = of_get_named_gpio_flags(dev->of_node, + "amux-a-gpios", 0, &flags); + if (gpio_is_valid(amux->sel_a_gpio)) { -+ ret = devm_gpio_request(dev, amux->sel_a_gpio, "amux-sel-a"); ++ ret = devm_gpio_request_one(dev, amux->sel_a_gpio, GPIOF_OUT_INIT_LOW, "amux-sel-a"); + if (ret < 0) { + dev_err(dev, "%s : failed to request amux-sel-a %d\n", + __func__, amux->sel_a_gpio); + goto err_out; + } -+ ret = gpio_direction_output(amux->sel_a_gpio, 0); -+ if (ret < 0) -+ goto err_out; ++ ++ ++ + } + + amux->sel_b_gpio = of_get_named_gpio_flags(dev->of_node, + "amux-b-gpios", 0, &flags); + if (gpio_is_valid(amux->sel_b_gpio)) { -+ ret = devm_gpio_request(dev, amux->sel_b_gpio, "amux-sel-b"); ++ ret = devm_gpio_request_one(dev, amux->sel_b_gpio, GPIOF_OUT_INIT_LOW, "amux-sel-b"); + if (ret < 0) { + dev_err(dev, "%s : failed to request amux-sel-b %d\n", + __func__, amux->sel_b_gpio); + goto err_out; + } -+ ret = gpio_direction_output(amux->sel_b_gpio, 0); -+ if (ret < 0) -+ goto err_out; ++ ++ ++ + } + + amux->en_gpio = of_get_named_gpio_flags(dev->of_node, + "amux-en-gpios", 0, &flags); + if (gpio_is_valid(amux->en_gpio)) { -+ ret = devm_gpio_request(dev, amux->en_gpio, "amux-en"); ++ ret = devm_gpio_request_one(dev, amux->en_gpio, GPIOF_OUT_INIT_LOW, "amux-en"); + if (ret < 0) { + dev_err(dev, "%s : failed to request amux-en %d\n", + __func__, amux->en_gpio); + goto err_out; + } -+ ret = gpio_direction_output(amux->en_gpio, 0); -+ if (ret < 0) -+ goto err_out; ++ ++ ++ + } + return 0; +err_out: @@ -6377,43 +6377,43 @@ index 000000000000..f7832a8158d4 + amux->sel_a_gpio = of_get_named_gpio_flags(dev->of_node, + "amux-a-gpios", 0, &flags); + if (gpio_is_valid(amux->sel_a_gpio)) { -+ ret = devm_gpio_request(dev, amux->sel_a_gpio, "amux-sel-a"); ++ ret = devm_gpio_request_one(dev, amux->sel_a_gpio, GPIOF_OUT_INIT_LOW, "amux-sel-a"); + if (ret < 0) { + dev_err(dev, "%s : failed to request amux-sel-a %d\n", + __func__, amux->sel_a_gpio); + goto err_out; + } -+ ret = gpio_direction_output(amux->sel_a_gpio, 0); -+ if (ret < 0) -+ goto err_out; ++ ++ ++ + } + + amux->sel_b_gpio = of_get_named_gpio_flags(dev->of_node, + "amux-b-gpios", 0, &flags); + if (gpio_is_valid(amux->sel_b_gpio)) { -+ ret = devm_gpio_request(dev, amux->sel_b_gpio, "amux-sel-b"); ++ ret = devm_gpio_request_one(dev, amux->sel_b_gpio, GPIOF_OUT_INIT_LOW, "amux-sel-b"); + if (ret < 0) { + dev_err(dev, "%s : failed to request amux-sel-b %d\n", + __func__, amux->sel_b_gpio); + goto err_out; + } -+ ret = gpio_direction_output(amux->sel_b_gpio, 0); -+ if (ret < 0) -+ goto err_out; ++ ++ ++ + } + + amux->en_gpio = of_get_named_gpio_flags(dev->of_node, + "amux-en-gpios", 0, &flags); + if (gpio_is_valid(amux->en_gpio)) { -+ ret = devm_gpio_request(dev, amux->en_gpio, "amux-en"); ++ ret = devm_gpio_request_one(dev, amux->en_gpio, GPIOF_OUT_INIT_LOW, "amux-en"); + if (ret < 0) { + dev_err(dev, "%s : failed to request amux-en %d\n", + __func__, amux->en_gpio); + goto err_out; + } -+ ret = gpio_direction_output(amux->en_gpio, 0); -+ if (ret < 0) -+ goto err_out; ++ ++ ++ + } + return 0; +err_out: diff --git a/projects/ROCKNIX/devices/RK3326/patches/linux/006-powkiddy-rgb10x.patch b/projects/ROCKNIX/devices/RK3326/patches/linux/006-powkiddy-rgb10x.patch deleted file mode 100644 index 0964cbec808..00000000000 --- a/projects/ROCKNIX/devices/RK3326/patches/linux/006-powkiddy-rgb10x.patch +++ /dev/null @@ -1,215 +0,0 @@ -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10x.dts b/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10x.dts -new file mode 100644 -index 000000000000..70e642907531 ---- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10x.dts -@@ -0,0 +1,209 @@ -+// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * Copyright (c) 2024 ROCKNIX -+ */ -+ -+/dts-v1/; -+#include "rk3326-odroid-go.dtsi" -+#include "retrogame_joypad_s2_f1.dtsi" -+ -+/ { -+ model = "Powkiddy RGB10X"; -+ compatible = "powkiddy,rk3326-rgb10x", "rockchip,rk3326"; -+ -+ aliases { -+ mmc1 = &sdio; -+ }; -+ -+ battery: battery { -+ compatible = "simple-battery"; -+ charge-full-design-microamp-hours = <2800000>; -+ charge-term-current-microamp = <280000>; -+ constant-charge-current-max-microamp = <2000000>; -+ constant-charge-voltage-max-microvolt = <4200000>; -+ factory-internal-resistance-micro-ohms = <180000>; -+ voltage-max-design-microvolt = <4100000>; -+ voltage-min-design-microvolt = <3500000>; -+ -+ ocv-capacity-celsius = <20>; -+ ocv-capacity-table-0 = <4046950 100>, <4001920 95>, <3967900 90>, <3919950 85>, -+ <3888450 80>, <3861850 75>, <3831540 70>, <3799130 65>, -+ <3768190 60>, <3745650 55>, <3726610 50>, <3711630 45>, -+ <3696720 40>, <3685660 35>, <3674950 30>, <3663050 25>, -+ <3649470 20>, <3635260 15>, <3616920 10>, <3592440 5>, -+ <3574170 0>; -+ }; -+ -+ gpio-keys-vol { -+ compatible = "gpio-keys"; -+ autorepeat; -+ pinctrl-0 = <&btn_pins_vol>; -+ pinctrl-names = "default"; -+ -+ button-vol-down { -+ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEDOWN"; -+ linux,code = ; -+ }; -+ -+ button-volume-up { -+ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -+ label = "VOLUMEUP"; -+ linux,code = ; -+ }; -+ }; -+}; -+ -+&joypad { -+ compatible = "rocknix-singleadc-joypad"; -+ joypad-name = "retrogame_joypad_s1_f2"; /* distinct name to indicate there is 1 stick and 2 fn buttons */ -+ joypad-product = <0x1112>; /* 11 inherited, 1 for number of sticks, 2 for number of FN */ -+ status = "okay"; -+ -+ /* gpio pincontrol setup */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; -+ -+ /* Analog mux define */ -+ io-channel-names = "amux_adc"; -+ io-channels = <&saradc 1>; -+ -+ /* adc mux channel count */ -+ /* despite there is only left stick, amux-count needs to be 4, */ -+ /* because amux 0 and 1 are hardcoded as RX and RY in the driver */ -+ amux-count = <4>; -+ /* adc mux select(a,b) gpio */ -+ amux-a-gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; -+ amux-b-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_LOW>; -+ /* adc mux enable gpio */ -+ amux-en-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; -+ -+ /* -+ Analog Stick data tuning value(precent) -+ p = positive direction, n = negative direction -+ report value = (real_adc_data * tuning_value) / 100 -+ */ -+ abs_x-p-tuning = <200>; -+ abs_x-n-tuning = <200>; -+ -+ abs_y-p-tuning = <200>; -+ abs_y-n-tuning = <200>; -+ -+ abs_rx-p-tuning = <200>; -+ abs_rx-n-tuning = <200>; -+ -+ abs_ry-p-tuning = <200>; -+ abs_ry-n-tuning = <200>; -+ -+ /* required for RGB10X */ -+ invert-absx; -+ invert-absy; -+ -+ /* -+ joypad driver is poll-device driver. -+ poll-device is does not support wakeup-source. -+ */ -+ up { gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>; }; -+ down { gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_LOW>; }; -+ left { gpios = <&gpio1 RK_PB6 GPIO_ACTIVE_LOW>; }; -+ right { gpios = <&gpio1 RK_PB7 GPIO_ACTIVE_LOW>; }; -+ -+ a { gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; }; -+ b { gpios = <&gpio1 RK_PA5 GPIO_ACTIVE_LOW>; }; -+ x { gpios = <&gpio1 RK_PA7 GPIO_ACTIVE_LOW>; }; -+ y { gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>; }; -+ -+ tl { gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; }; -+ tr { gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; }; -+ tr2 { gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; }; -+ tl2 { gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; }; -+ -+ select{ gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; }; -+ start { gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; }; -+ -+ thumbl{ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; }; -+ -+ /* Plus and Minus face buttons are mapped to mode and thumbr */ -+ mode { -+ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; -+ label = "GPIO MINUS"; -+ }; -+ thumbr { -+ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -+ label = "GPIO PLUS"; -+ }; -+}; -+ -+&internal_display { -+ compatible = "powkiddy,rk2023-panel", "newvision,nv3051d"; -+ vdd-supply = <&vcc_lcd>; -+}; -+ -+&io_domains { -+ vccio1-supply = <&vccio_sd>; -+}; -+ -+/delete-node/ &pwm3; -+/delete-node/ &pwm_led; -+ -+&red_led { -+ gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_HIGH>; -+}; -+ -+&red_led_pin { -+ rockchip,pins = <2 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; -+}; -+ -+&rk817_charger { -+ monitored-battery = <&battery>; -+}; -+ -+&sdio { -+ cap-sd-highspeed; -+ card-detect-delay = <200>; -+ cd-gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; -+ sd-uhs-sdr12; -+ sd-uhs-sdr25; -+ sd-uhs-sdr50; -+ sd-uhs-sdr104; -+ vmmc-supply = <&vcc_sd>; -+ vqmmc-supply = <&vccio_sd>; -+ status = "okay"; -+}; -+ -+&vcc_sd { -+ regulator-max-microvolt = <3000000>; -+ regulator-min-microvolt = <1800000>; -+}; -+ -+&vccio_sd { -+ regulator-max-microvolt = <1800000>; -+}; -+ -+&pinctrl { -+ btns { -+ btn_pins: btn-pins { -+ rockchip,pins = <1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <1 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ btn_pins_vol: btn-pins-vol { -+ rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PA1 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ }; -+}; diff --git a/projects/ROCKNIX/devices/RK3326/patches/linux/008-esp-8089-wifi.patch b/projects/ROCKNIX/devices/RK3326/patches/linux/008-esp-8089-wifi.patch index 1ca6266df00..c06f577bf60 100644 --- a/projects/ROCKNIX/devices/RK3326/patches/linux/008-esp-8089-wifi.patch +++ b/projects/ROCKNIX/devices/RK3326/patches/linux/008-esp-8089-wifi.patch @@ -3858,7 +3858,7 @@ index 000000000000..14186365fdd4 + + if (evif->ap_up) { + evif->beacon_interval = 0; -+ del_timer_sync(&evif->beacon_timer); ++ timer_delete_sync(&evif->beacon_timer); + evif->ap_up = false; + } + epub->vif = NULL; @@ -3941,7 +3941,7 @@ index 000000000000..14186365fdd4 +#endif +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) -+ struct esp_vif *evif = from_timer(evif, t, beacon_timer); ++ struct esp_vif *evif = timer_container_of(evif, t, beacon_timer); + struct ieee80211_vif *vif = evif->epub->vif; +#else + struct ieee80211_vif *vif = (struct ieee80211_vif *) data; @@ -4018,7 +4018,7 @@ index 000000000000..14186365fdd4 + add_timer(&evif->beacon_timer); +} + -+static int esp_op_config(struct ieee80211_hw *hw, u32 changed) ++static int esp_op_config(struct ieee80211_hw *hw, int radio_idx, u32 changed) +{ + //struct ieee80211_conf *conf = &hw->conf; + @@ -4101,7 +4101,7 @@ index 000000000000..14186365fdd4 + __func__, + info->beacon_int); + evif->beacon_interval = 0; -+ del_timer_sync(&evif->beacon_timer); ++ timer_delete_sync(&evif->beacon_timer); + sip_send_bss_info_update(epub, evif, + (u8 *) info-> + bssid, 2); @@ -4313,7 +4313,7 @@ index 000000000000..14186365fdd4 +#endif +} + -+static int esp_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) ++static int esp_op_set_rts_threshold(struct ieee80211_hw *hw, int radio_idx, u32 value) +{ + ESP_IEEE80211_DBG(ESP_DBG_TRACE, "%s enter \n", __func__); + @@ -6273,7 +6273,7 @@ index 000000000000..6602a1e22ab1 +#endif +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) -+ struct esp_sip *sip = from_timer(sip, t, credit_timer); ++ struct esp_sip *sip = timer_container_of(sip, t, credit_timer); +#else + struct esp_sip *sip = (struct esp_sip *) data; +#endif @@ -6324,7 +6324,7 @@ index 000000000000..6602a1e22ab1 + + if (atomic_read(&sip->credit_status) == RECALC_CREDIT_ENABLE) { + atomic_set(&sip->credit_status, RECALC_CREDIT_DISABLE); -+ del_timer_sync(&sip->credit_timer); ++ timer_delete_sync(&sip->credit_timer); + } else + esp_dbg(ESP_SHOW, "maybe bogus credit"); +} diff --git a/projects/ROCKNIX/devices/RK3326/patches/linux/020-elida-refresh-rates.patch b/projects/ROCKNIX/devices/RK3326/patches/linux/020-elida-refresh-rates.patch deleted file mode 100644 index b96e4297928..00000000000 --- a/projects/ROCKNIX/devices/RK3326/patches/linux/020-elida-refresh-rates.patch +++ /dev/null @@ -1,79 +0,0 @@ -diff --git a/drivers/gpu/drm/panel/panel-elida-kd35t133.c b/drivers/gpu/drm/panel/panel-elida-kd35t133.c -index b904d5437444..abbeb18eb6b4 100644 ---- a/drivers/gpu/drm/panel/panel-elida-kd35t133.c -+++ b/drivers/gpu/drm/panel/panel-elida-kd35t133.c -@@ -148,7 +148,8 @@ static int kd35t133_prepare(struct drm_panel *panel) - return dsi_ctx.accum_err; - } - --static const struct drm_display_mode default_mode = { -+/* drm_display_mode template without clock as it is variable */ -+static const struct drm_display_mode mode_template = { - .hdisplay = 320, - .hsync_start = 320 + 130, - .hsync_end = 320 + 130 + 4, -@@ -157,33 +158,49 @@ static const struct drm_display_mode default_mode = { - .vsync_start = 480 + 2, - .vsync_end = 480 + 2 + 1, - .vtotal = 480 + 2 + 1 + 2, -- .clock = 17000, - .width_mm = 42, - .height_mm = 82, - }; - -+static const int pixel_clocks[] = { -+ 14118, /* 49.84 Hz PAL everything */ -+ 15545, /* 54.88 Hz Arcade: Midway, Toaplan, R-Type */ -+ 16300, /* 57.50 Hz Arcade: Toaplan, more? */ -+ 16900, /* 59.7 Hz GB/GBC/GBA */ -+ 17000, /* 60 Hz everything */ -+ 21375, /* 75.47 Hz Wonderswan(Color) */ -+}; -+ - static int kd35t133_get_modes(struct drm_panel *panel, - struct drm_connector *connector) - { - struct kd35t133 *ctx = panel_to_kd35t133(panel); -+ struct drm_display_mode mode_tmp; - struct drm_display_mode *mode; - -- mode = drm_mode_duplicate(connector->dev, &default_mode); -- if (!mode) { -- dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n", -- default_mode.hdisplay, default_mode.vdisplay, -- drm_mode_vrefresh(&default_mode)); -- return -ENOMEM; -+ unsigned int i; -+ -+ for (i = 0; i < ARRAY_SIZE(pixel_clocks); i++) { -+ mode_tmp = mode_template; -+ mode_tmp.clock = pixel_clocks[i]; -+ mode = drm_mode_duplicate(connector->dev, &mode_tmp); -+ if (!mode) { -+ dev_err(ctx->dev, "Failed to add mode %u\n", -+ drm_mode_vrefresh(mode)); -+ return -ENOMEM; -+ } -+ drm_mode_set_name(mode); -+ -+ mode->type = DRM_MODE_TYPE_DRIVER; -+ if (i == 4) -+ mode->type |= DRM_MODE_TYPE_PREFERRED; -+ -+ drm_mode_probed_add(connector, mode); -+ connector->display_info.width_mm = mode->width_mm; -+ connector->display_info.height_mm = mode->height_mm; - } - -- drm_mode_set_name(mode); -- -- mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; -- connector->display_info.width_mm = mode->width_mm; -- connector->display_info.height_mm = mode->height_mm; -- drm_mode_probed_add(connector, mode); -- -- return 1; -+ return ARRAY_SIZE(pixel_clocks); - } - - static enum drm_panel_orientation kd35t133_get_orientation(struct drm_panel *panel) diff --git a/projects/ROCKNIX/devices/RK3326/patches/linux/021-magicx-xu-mini-m.patch b/projects/ROCKNIX/devices/RK3326/patches/linux/021-magicx-xu-mini-m.patch deleted file mode 100644 index 8353d161dca..00000000000 --- a/projects/ROCKNIX/devices/RK3326/patches/linux/021-magicx-xu-mini-m.patch +++ /dev/null @@ -1,115 +0,0 @@ -diff --git a/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu-mini-m.dts b/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu-mini-m.dts -new file mode 100644 -index 000000000000..e57803b572b8 ---- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu-mini-m.dts -@@ -0,0 +1,109 @@ -+/// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * Copyright (c) 2024-present ROCKNIX (https://github.com/ROCKNIX) -+ * Copyright (c) 2024 Olivier Schonken -+ */ -+ -+#include "rk3326-magicx-xu10.dts" -+ -+/ { -+ model = "MagicX XU Mini M"; -+ compatible = "magicx,xu-mini-m", "rockchip,rk3326"; -+}; -+ -+&battery { -+ charge-full-design-microamp-hours = <2600000>; -+}; -+ -+&dsi { -+ internal_display: panel@0 { -+ compatible = "rocknix,generic-dsi"; -+ panel_description = -+ "G size=69,139 delays=5,20,20,120,20 format=rgb888 lanes=2 flags=0xe03", -+ -+ "M clock=25000 horizontal=480,60,10,54 vertical=640,20,10,20 default=1", -+ "M clock=25200 horizontal=480,60,22,54 vertical=640,20,139,20", -+ "M clock=25000 horizontal=480,60,31,54 vertical=640,20,120,20", -+ "M clock=25660 horizontal=480,60,22,54 vertical=640,20,153,20", -+ "M clock=25300 horizontal=480,60,31,54 vertical=640,20,24,20", -+ "M clock=28590 horizontal=480,60,15,54 vertical=640,20,106,20", -+ "M clock=25380 horizontal=480,60,17,54 vertical=640,20,13,20", -+ "M clock=25410 horizontal=480,60,11,54 vertical=640,20,20,20", -+ "M clock=29490 horizontal=480,60,24,54 vertical=640,20,114,20", -+ "M clock=33520 horizontal=480,60,36,54 vertical=640,20,25,20", -+ "M clock=38430 horizontal=480,60,16,54 vertical=640,20,20,20", -+ "M clock=50820 horizontal=480,60,11,54 vertical=640,20,20,20", -+ -+ "I seq=ff7701000013", -+ "I seq=ef08", -+ "I seq=ff7701000010", -+ "I seq=c04f00", "I seq=c11002", "I seq=c22002", "I seq=cc10", -+ "I seq=b006161e0e12060a0809230412102b311f", -+ "I seq=b1060f160d100704090720051210262f1f", -+ "I seq=ff7701000011", -+ "I seq=b065", "I seq=b185", "I seq=b282", "I seq=b380", "I seq=b542", "I seq=b785", -+ "I seq=b820", -+ "I seq=c178", "I seq=c278", -+ "I seq=d088", -+ "I seq=e0000002", -+ "I seq=e104a006a005a007a0004444", -+ "I seq=e2000000000000000000000000", -+ "I seq=e300002222", -+ "I seq=e44444", -+ "I seq=e50c90a0a00e92a0a0088ca0a00a8ea0a0", -+ "I seq=e600002222", -+ "I seq=e74444", -+ "I seq=e80d91a0a00f93a0a0098da0a00b8fa0a0", -+ "I seq=eb0000e4e4440040", -+ "I seq=edfff5476f0ba1abffffba1ab0f6745fff", -+ "I seq=ef080808403f64", -+ "I seq=ff7701000013", -+ "I seq=e6167c", "I seq=e8000e", -+ "I seq=e8000c wait=50", -+ "I seq=e80000", -+ "I seq=ff7701000000", -+ "I seq=11 wait=150", -+ "I seq=29 wait=120"; -+ rotation = <90>; -+ }; -+}; -+ -+&joypad { -+ joypad-name = "XU Mini M Gamepad"; -+ -+ invert-absrx; -+ /delete-property/ invert-absx; -+ -+ sw5 { -+ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-B"; -+ }; -+ sw6 { -+ gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-A"; -+ }; -+ sw7 { -+ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-X"; -+ }; -+ sw8 { -+ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-Y"; -+ }; -+ sw16 { -+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; -+ }; -+ sw17 { -+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -+ }; -+}; -+ -+&pinctrl { -+ headphone { -+ hp_det: hp-det { -+ rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>; -+ }; -+ }; -+}; -+ -+ diff --git a/projects/ROCKNIX/devices/RK3326/patches/linux/023-gameconsole-eeclone.patch b/projects/ROCKNIX/devices/RK3326/patches/linux/023-gameconsole-eeclone.patch deleted file mode 100644 index af8ddc1e234..00000000000 --- a/projects/ROCKNIX/devices/RK3326/patches/linux/023-gameconsole-eeclone.patch +++ /dev/null @@ -1,930 +0,0 @@ -new file mode 100644 ---- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-eeclone.dts -@@ -0,0 +1,926 @@ -+/// SPDX-License-Identifier: (GPL-2.0+ OR MIT) -+/* -+ * Copyright (c) 2024-present ROCKNIX (https://github.com/ROCKNIX) -+ * Copyright (c) 2025 Danil Zagoskin -+ */ -+ -+/dts-v1/; -+#include -+#include -+#include -+#include -+#include "rk3326.dtsi" -+ -+/ { -+ model = "Generic EE clone"; -+ compatible = "gameconsole,eeclone", "rockchip,rk3326"; -+ -+ aliases { -+ mmc0 = &emmc; -+ mmc1 = &sdmmc; -+ mmc2 = &sdio; -+ serial1 = &uart2; -+ serial2 = &uart5; -+ }; -+ -+ backlight: backlight { -+ compatible = "pwm-backlight"; -+ pwms = <&pwm1 0 25000 0>; -+ brightness-levels = < -+ 0 1 2 3 4 5 6 7 -+ 8 9 10 11 12 13 14 15 -+ 16 17 18 19 20 21 22 23 -+ 24 25 26 27 28 29 30 31 -+ 32 33 34 35 36 37 38 39 -+ 40 41 42 43 44 45 46 47 -+ 48 49 50 51 52 53 54 55 -+ 56 57 58 59 60 61 62 63 -+ 64 65 66 67 68 69 70 71 -+ 72 73 74 75 76 77 78 79 -+ 80 81 82 83 84 85 86 87 -+ 88 89 90 91 92 93 94 95 -+ 96 97 98 99 100 101 102 103 -+ 104 105 106 107 108 109 110 111 -+ 112 113 114 115 116 117 118 119 -+ 120 121 122 123 124 125 126 127 -+ 128 129 130 131 132 133 134 135 -+ 136 137 138 139 140 141 142 143 -+ 144 145 146 147 148 149 150 151 -+ 152 153 154 155 156 157 158 159 -+ 160 161 162 163 164 165 166 167 -+ 168 169 170 171 172 173 174 175 -+ 176 177 178 179 180 181 182 183 -+ 184 185 186 187 188 189 190 191 -+ 192 193 194 195 196 197 198 199 -+ 200 201 202 203 204 205 206 207 -+ 208 209 210 211 212 213 214 215 -+ 216 217 218 219 220 221 222 223 -+ 224 225 226 227 228 229 230 231 -+ 232 233 234 235 236 237 238 239 -+ 240 241 242 243 244 245 246 247 -+ 248 249 250 251 252 253 254 255>; -+ default-brightness-level = <128>; -+ }; -+ -+ battery: battery { -+ compatible = "simple-battery"; -+ charge-full-design-microamp-hours = <4000000>; -+ charge-term-current-microamp = <200000>; -+ constant-charge-current-max-microamp = <1500000>; -+ constant-charge-voltage-max-microvolt = <4200000>; -+ factory-internal-resistance-micro-ohms = <100000>; -+ voltage-max-design-microvolt = <4100000>; -+ voltage-min-design-microvolt = <3300000>; -+ -+ ocv-capacity-celsius = <20>; -+ ocv-capacity-table-0 = -+ <4046950 100>, <4001920 95>, <3967900 90>, <3940000 85>, -+ <3910000 80>, <3870000 75>, <3830000 70>, <3790000 65>, -+ <3750000 60>, <3720000 55>, <3690000 50>, <3650000 45>, -+ <3610000 40>, <3570000 35>, <3540000 30>, <3500000 25>, -+ <3460000 20>, <3420000 15>, <3380000 10>, <3340000 5>, -+ <3300000 0>; -+ }; -+ -+ adc_keys: adc-keys { -+ compatible = "adc-keys"; -+ io-channels = <&saradc 2>; -+ io-channel-names = "buttons"; -+ keyup-threshold-microvolt = <1800000>; -+ poll-interval = <100>; -+ -+ /* disabled by default, dtbo may enable it when needed */ -+ status = "disabled"; -+ -+ button-vol-up { -+ press-threshold-microvolt = <15000>; -+ label = "VOLUMEUP"; -+ linux,code = ; -+ }; -+ -+ button-vol-down { -+ press-threshold-microvolt = <300000>; -+ label = "VOLUMEDOWN"; -+ linux,code = ; -+ }; -+ }; -+ -+ joypad: joypad { -+ compatible = "rocknix-singleadc-joypad"; -+ -+ joypad-name = "r36s_Gamepad"; -+ joypad-product = <0x1188>; -+ joypad-revision = <0x0188>; -+ -+ status = "okay"; -+ -+ /* gpio pincontrol setup */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&btn_pins>; -+ -+ /* Analog mux define */ -+ io-channel-names = "amux_adc"; -+ io-channels = <&saradc 1>; -+ -+ /* adc mux channel count */ -+ amux-count = <4>; -+ /* non-default wiring */ -+ amux-channel-mapping = <2 3 1 0>; -+ /* adc mux enable gpio */ -+ amux-en-gpios = <&gpio2 RK_PB4 GPIO_ACTIVE_LOW>; /* rocker0-gpios */ -+ /* adc mux select(a,b) gpio */ -+ amux-a-gpios = <&gpio2 RK_PC0 GPIO_ACTIVE_LOW>; /* rocker1-gpios */ -+ amux-b-gpios = <&gpio2 RK_PB7 GPIO_ACTIVE_LOW>; /* rocker-gpios */ -+ -+ /* adc calculate scale */ -+ button-adc-scale = <2>; -+ -+ /* adc deadzone range */ -+ button-adc-deadzone = <64>; -+ -+ /* -+ specifies fuzz value that is used to filter noise from -+ the event stream. -+ */ -+ button-adc-fuzz = <32>; -+ button-adc-flat = <32>; -+ -+ /* -+ Analog Stick data tuning value(precent) -+ p = positive direction, n = negative direction -+ report value = (real_adc_data * tuning_value) / 100 -+ */ -+ abs_x-p-tuning = <200>; -+ abs_x-n-tuning = <200>; -+ -+ abs_y-p-tuning = <200>; -+ abs_y-n-tuning = <200>; -+ -+ abs_rx-p-tuning = <200>; -+ abs_rx-n-tuning = <200>; -+ -+ abs_ry-p-tuning = <200>; -+ abs_ry-n-tuning = <200>; -+ -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ -+ /* gpio button auto repeat set value : default disable */ -+ /* -+ autorepeat; -+ */ -+ -+ /* -+ joypad driver is poll-device driver. -+ poll-device is does not support wakeup-source. -+ */ -+ sw1 { -+ gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-UP"; -+ linux,code = ; // 0x220 -+ }; -+ sw2 { -+ gpios = <&gpio3 RK_PC7 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-DOWN"; -+ linux,code = ; // 0x221 -+ }; -+ sw3 { -+ gpios = <&gpio3 RK_PC4 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-LEFT"; -+ linux,code = ; // 0x222 -+ }; -+ sw4 { -+ gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_LOW>; -+ label = "GPIO DPAD-RIGHT"; -+ linux,code = ; // 0x223 -+ }; -+ -+ sw5 { -+ gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>; -+ label = "GPIO KEY BTN-A"; -+ linux,code = ; // 0x131 -+ }; -+ sw6 { -+ gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-B"; -+ linux,code = ; // 0x130 -+ }; -+ sw7 { -+ gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-Y"; -+ linux,code = ; // 0x134 -+ }; -+ sw8 { -+ gpios = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN-X"; -+ linux,code = ; // 0x133 -+ }; -+ -+ sw11 { -+ gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_THUMBL"; -+ linux,code = ; // 0x2c2 -+ }; -+ sw12 { -+ gpios = <&gpio2 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_THUMBR"; -+ linux,code = ; // 0x2c3 -+ }; -+ -+ sw13 { -+ gpios = <&gpio3 RK_PB2 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_FN"; -+ linux,code = ; // 0x2c4 -+ }; -+ -+ sw15 { -+ gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT"; -+ linux,code = ; // 0x02 -+ }; -+ sw16 { -+ gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT"; -+ linux,code = ; // 0x05 -+ }; -+ sw19 { -+ gpios = <&gpio3 RK_PD0 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_SELECT"; -+ linux,code = ; -+ }; -+ sw20 { -+ gpios = <&gpio3 RK_PB4 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-RIGHT2"; -+ linux,code = ; -+ }; -+ sw21 { -+ gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>; -+ label = "GPIO TOP-LEFT2"; -+ linux,code = ; -+ }; -+ sw22 { -+ gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_LOW>; -+ label = "GPIO BTN_START"; -+ linux,code = ; -+ }; -+ }; -+ -+ leds: gpio-leds { -+ compatible = "gpio-leds"; -+ pinctrl-0 = <&led_pins>; -+ pinctrl-names = "default"; -+ -+ /* charge_red_gpio = <&gpio0 17 0>; */ -+ led-0 { -+ color = ; -+ default-state = "off"; -+ function = LED_FUNCTION_CHARGING; -+ linux,default-trigger = "none"; -+ gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_HIGH>; -+ }; -+ -+ /* charge_blue_gpio = <&gpio0 0 0>; */ -+ led-1 { -+ color = ; -+ default-state = "on"; -+ function = LED_FUNCTION_POWER; -+ linux,default-trigger = "default-on"; -+ gpios = <&gpio0 RK_PA0 GPIO_ACTIVE_HIGH>; -+ }; -+ }; -+ -+ spk_amp: audio-amplifier { -+ compatible = "simple-audio-amplifier"; -+ enable-gpios = <&gpio3 RK_PA7 GPIO_ACTIVE_HIGH>; -+ pinctrl-0 = <&spk_amp_enable_h>; -+ pinctrl-names = "default"; -+ sound-name-prefix = "Speaker Amp"; -+ }; -+ -+ rk817-sound { -+ compatible = "simple-audio-card"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&hp_det>; -+ simple-audio-card,name = "rk817_ext"; -+ simple-audio-card,aux-devs = <&spk_amp>; -+ simple-audio-card,format = "i2s"; -+ simple-audio-card,hp-det-gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>; -+ simple-audio-card,mclk-fs = <256>; -+ simple-audio-card,widgets = -+ "Microphone", "Mic Jack", -+ "Headphone", "Headphones", -+ "Speaker", "Speaker"; -+ simple-audio-card,routing = -+ "MICL", "Mic Jack", -+ "Headphones", "HPOL", -+ "Headphones", "HPOR", -+ "Speaker", "SPKO"; -+ -+ simple-audio-card,codec { -+ sound-dai = <&rk817>; -+ }; -+ -+ simple-audio-card,cpu { -+ sound-dai = <&i2s1_2ch>; -+ }; -+ }; -+ -+ vccsys: vccsys { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc5v0_sys"; -+ regulator-always-on; -+ regulator-boot-on; -+ regulator-min-microvolt = <5000000>; -+ regulator-max-microvolt = <5000000>; -+ }; -+ -+ vcc-phy-regulator { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc_phy"; -+ regulator-always-on; -+ regulator-boot-on; -+ }; -+ -+ vcc18_lcd0: vcc18-lcd0 { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc18_lcd0_n"; -+ gpio = <&gpio0 RK_PB5 GPIO_ACTIVE_HIGH>; -+ enable-active-high; -+ pinctrl-0 = <&vcc18_lcd_n>; -+ pinctrl-names = "default"; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ }; -+ }; -+ -+ vcc_host: vcc_host { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc_host"; -+ regulator-min-microvolt = <5000000>; -+ regulator-max-microvolt = <5000000>; -+ gpio = <&gpio3 RK_PA4 GPIO_ACTIVE_HIGH>; -+ pinctrl-0 = <&vcc5_usb>; -+ pinctrl-names = "default"; -+ enable-active-high; -+ regulator-always-on; -+ regulator-boot-on; -+ vin-supply = <&usb_midu>; -+ }; -+}; -+ -+&dmc { -+ center-supply = <&vdd_logic>; -+}; -+ -+&cpu0 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cpu1 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cpu2 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cpu3 { -+ cpu-supply = <&vdd_arm>; -+}; -+ -+&cru { -+ assigned-clocks = <&cru PLL_NPLL>, -+ <&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>, -+ <&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>, -+ <&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>; -+ -+ assigned-clock-rates = <1188000000>, -+ <200000000>, <200000000>, -+ <150000000>, <150000000>, -+ <100000000>, <200000000>; -+}; -+ -+&display_subsystem { -+ status = "okay"; -+}; -+ -+&dsi { -+ status = "okay"; -+ -+ ports { -+ mipi_out: port@1 { -+ reg = <1>; -+ -+ mipi_out_panel: endpoint { -+ remote-endpoint = <&mipi_in_panel>; -+ }; -+ }; -+ }; -+ -+ internal_display: panel@0 { -+ compatible = "magicx,xu10-panel", "sitronix,st7703"; -+ iovcc-supply = <&vcc18_lcd0>; -+ vcc-supply = <&vcc18_lcd0>; -+ reg = <0>; -+ backlight = <&backlight>; -+ reset-gpios = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&lcd_rst>; -+ -+ port { -+ mipi_in_panel: endpoint { -+ remote-endpoint = <&mipi_out_panel>; -+ }; -+ }; -+ }; -+}; -+ -+&dsi_dphy { -+ status = "okay"; -+}; -+ -+&gpu { -+ mali-supply = <&vdd_logic>; -+ status = "okay"; -+}; -+ -+&i2c0 { -+ clock-frequency = <400000>; -+ i2c-scl-falling-time-ns = <16>; -+ i2c-scl-rising-time-ns = <280>; -+ status = "okay"; -+ -+ rk817: pmic@20 { -+ compatible = "rockchip,rk817"; -+ reg = <0x20>; -+ interrupt-parent = <&gpio0>; -+ interrupts = ; -+ clock-output-names = "rk808-clkout1", "xin32k"; -+ clock-names = "mclk"; -+ clocks = <&cru SCLK_I2S1_OUT>; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>; -+ rockchip,system-power-controller; -+ wakeup-source; -+ #clock-cells = <1>; -+ #sound-dai-cells = <0>; -+ -+ vcc1-supply = <&vccsys>; -+ vcc2-supply = <&vccsys>; -+ vcc3-supply = <&vccsys>; -+ vcc4-supply = <&vccsys>; -+ vcc5-supply = <&vccsys>; -+ vcc6-supply = <&vccsys>; -+ vcc7-supply = <&vcc_3v0>; -+ vcc8-supply = <&vccsys>; -+ -+ regulators { -+ vdd_logic: DCDC_REG1 { -+ regulator-name = "vdd_logic"; -+ regulator-min-microvolt = <950000>; -+ regulator-max-microvolt = <1350000>; -+ regulator-initial-mode = <0x02>; -+ regulator-ramp-delay = <6001>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <950000>; -+ }; -+ }; -+ -+ vdd_arm: DCDC_REG2 { -+ regulator-name = "vdd_arm"; -+ regulator-min-microvolt = <850000>; -+ regulator-max-microvolt = <1350000>; -+ regulator-ramp-delay = <6001>; -+ regulator-initial-mode = <0x02>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <950000>; -+ }; -+ }; -+ -+ vcc_ddr: DCDC_REG3 { -+ regulator-name = "vcc_ddr"; -+ regulator-always-on; -+ regulator-boot-on; -+ regulator-initial-mode = <0x02>; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ }; -+ }; -+ -+ vcc_3v0: DCDC_REG4 { -+ regulator-name = "vcc_3v0"; -+ regulator-min-microvolt = <3000000>; -+ regulator-max-microvolt = <3000000>; -+ regulator-initial-mode = <0x02>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <3000000>; -+ }; -+ }; -+ -+ vcc_1v0: LDO_REG1 { -+ regulator-name = "vcc_1v0"; -+ regulator-always-on; -+ regulator-boot-on; -+ regulator-min-microvolt = <1000000>; -+ regulator-max-microvolt = <1000000>; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <1000000>; -+ }; -+ }; -+ -+ vcc1v8_soc: LDO_REG2 { -+ regulator-name = "vcc1v8_soc"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <1800000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <1800000>; -+ }; -+ }; -+ -+ vcc1v0_soc: LDO_REG3 { -+ regulator-name = "vcc1v0_soc"; -+ regulator-min-microvolt = <1000000>; -+ regulator-max-microvolt = <1000000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <1000000>; -+ }; -+ }; -+ -+ vcc3v0_pmu: LDO_REG4 { -+ regulator-name = "vcc3v0_pmu"; -+ regulator-min-microvolt = <3000000>; -+ regulator-max-microvolt = <3000000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3000000>; -+ }; -+ }; -+ -+ vccio_sd: LDO_REG5 { -+ regulator-name = "vccio_sd"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <3300000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3300000>; -+ }; -+ }; -+ -+ vcc_sd: LDO_REG6 { -+ regulator-name = "vcc_sd"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <3300000>; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3300000>; -+ }; -+ }; -+ -+ vcc2v8_dvp: LDO_REG7 { -+ regulator-name = "vcc2v8_dvp"; -+ regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <3300000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <3300000>; -+ }; -+ }; -+ -+ vcc3v0_dvp: LDO_REG8 { -+ regulator-name = "vcc3v0_dvp"; -+ regulator-min-microvolt = <3000000>; -+ regulator-max-microvolt = <3000000>; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3000000>; -+ }; -+ }; -+ -+ vdd1v5_dvp: LDO_REG9 { -+ regulator-min-microvolt = <1500000>; -+ regulator-max-microvolt = <1500000>; -+ regulator-name = "vdd1v5_dvp"; -+ regulator-always-on; -+ regulator-boot-on; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ regulator-suspend-microvolt = <1500000>; -+ }; -+ }; -+ -+ usb_midu: BOOST { -+ regulator-name = "usb_midu"; -+ regulator-min-microvolt = <4900000>; -+ regulator-max-microvolt = <5400000>; -+ regulator-always-on; -+ regulator-boot-on; -+ }; -+ -+ /* -+ otg_switch: OTG_SWITCH { -+ regulator-name = "otg_switch"; -+ -+ regulator-state-mem { -+ regulator-off-in-suspend; -+ }; -+ }; -+ */ -+ }; -+ -+ rk817_charger: charger { -+ monitored-battery = <&battery>; -+ rockchip,resistor-sense-micro-ohms = <10000>; -+ rockchip,sleep-enter-current-microamp = <300000>; -+ rockchip,sleep-filter-current-microamp = <100000>; -+ }; -+ -+ rk817_codec: codec { -+ rockchip,mic-in-differential; -+ }; -+ }; -+}; -+ -+/* I2S 1 Channel Used Header(P2):1(GPIO2.C3),2(.C2), 3(.C1), 4(.C5), 5(.C4) */ -+&i2s1_2ch { -+ status = "okay"; -+ #sound-dai-cells = <0>; -+}; -+ -+&io_domains { -+ vccio1-supply = <&vcc2v8_dvp>; -+ vccio2-supply = <&vccio_sd>; -+ vccio3-supply = <&vcc1v8_soc>; -+ vccio4-supply = <&vcc_3v0>; -+ vccio5-supply = <&vcc_3v0>; -+ vccio6-supply = <&vcc1v8_soc>; -+ status = "okay"; -+}; -+ -+&isp { -+ status = "okay"; -+}; -+ -+&isp_mmu { -+ status = "okay"; -+}; -+ -+&pmu_io_domains { -+ pmuio1-supply = <&vcc3v0_pmu>; -+ pmuio2-supply = <&vcc3v0_pmu>; -+ status = "okay"; -+}; -+ -+&csi_dphy { -+ status = "okay"; -+}; -+ -+&pwm1 { -+ status = "okay"; -+}; -+ -+&saradc { -+ vref-supply = <&vcc1v8_soc>; -+ status = "okay"; -+}; -+ -+&sdmmc { -+ cap-sd-highspeed; -+ card-detect-delay = <800>; -+ cd-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_LOW>; /*[> ff370000 PD_SDCARD CD GPIO <]*/ -+ sd-uhs-sdr12; -+ sd-uhs-sdr25; -+ sd-uhs-sdr50; -+ sd-uhs-sdr104; -+ vqmmc-supply = <&vccio_sd>; -+ vmmc-supply = <&vcc_sd>; -+ status = "okay"; -+}; -+ -+&sdio { -+ cap-sd-highspeed; -+ max-frequency = <100000000>; -+ cd-gpios = <&gpio0 RK_PA2 GPIO_ACTIVE_LOW>; -+ card-detect-delay = <800>; -+ supports-sd; -+ sd-uhs-sdr12; -+ sd-uhs-sdr25; -+ sd-uhs-sdr50; -+ sd-uhs-sdr104; -+ vqmmc-supply = <&vcc2v8_dvp>; -+ vmmc-supply = <&vcc3v0_dvp>; -+ status = "okay"; -+}; -+ -+&emmc { -+ status = "okay"; -+ no-sdio; -+ no-sd; -+ disable-wp; -+ non-removable; -+ num-slots = <1>; -+}; -+ -+&tsadc { -+ status = "okay"; -+}; -+ -+&u2phy { -+ status = "okay"; -+ -+ u2phy_host: host-port { -+ status = "okay"; -+ }; -+ -+ u2phy_otg: otg-port { -+ status = "disabled"; -+ }; -+}; -+ -+&usb20_otg { -+ status = "okay"; -+}; -+ -+&vopb { -+ status = "okay"; -+}; -+ -+&vopb_mmu { -+ status = "okay"; -+}; -+&pinctrl { -+ btns { -+ btn_pins: btn-pins { -+ rockchip,pins = -+ <2 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <2 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB3 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PC0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PC1 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PC2 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PC3 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PC4 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PC5 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PC7 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PD0 RK_FUNC_GPIO &pcfg_pull_up>, -+ <3 RK_PD1 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ }; -+ -+ headphone { -+ hp_det: hp-det { -+ rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_down>; -+ }; -+ }; -+ -+ gpio-lcd { -+ lcd_rst: lcd-rst { -+ rockchip,pins = <3 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ }; -+ -+ vcc18-lcd { -+ vcc18_lcd_n: vcc18-lcd-n { -+ rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ }; -+ -+ vcc5-usb { -+ vcc5_usb: vcc5-usb { -+ rockchip,pins = <3 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ }; -+ -+ gpio-led { -+ led_pins: led-pins { -+ rockchip,pins = -+ <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>, /* charge_blue_gpio = <&gpio0 0 0>; */ -+ <0 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>; /* charge_red_gpio = <&gpio0 17 0>; */ -+ }; -+ }; -+ -+ pmic { -+ dc_det: dc-det { -+ rockchip,pins = <0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ -+ pmic_int: pmic-int { -+ rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>; -+ }; -+ -+ soc_slppin_gpio: soc_slppin_gpio { -+ rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_output_low>; -+ }; -+ -+ soc_slppin_rst: soc_slppin_rst { -+ rockchip,pins = <0 RK_PA4 2 &pcfg_pull_none>; -+ }; -+ -+ soc_slppin_slp: soc_slppin_slp { -+ rockchip,pins = <0 RK_PA4 1 &pcfg_pull_none>; -+ }; -+ }; -+ -+ speaker { -+ spk_amp_enable_h: spk-amp-enable-h { -+ rockchip,pins = <3 RK_PA7 RK_FUNC_GPIO &pcfg_pull_none>; -+ }; -+ }; -+}; -+ -+&uart5 { -+ status = "okay"; -+}; -+&uart2 { -+ status = "disabled"; -+}; -+ -+ -+&internal_display { -+ compatible = "rocknix,generic-dsi"; -+ panel_description = -+ "G size=153,85 delays=20,20,20,120,20 format=rgb888 lanes=4 flags=0xe03", -+ -+ "M clock=50000 horizontal=720,140,80,140 vertical=720,20,4,20 default=1", -+ "M clock=50000 horizontal=720,140,100,140 vertical=720,20,150,20", -+ "M clock=50040 horizontal=720,140,112,140 vertical=720,20,140,20", -+ "M clock=51400 horizontal=720,140,132,140 vertical=720,20,148,20", -+ "M clock=50140 horizontal=720,140,90,140 vertical=720,20,40,20", -+ "M clock=56900 horizontal=720,140,90,140 vertical=720,20,114,20", -+ "M clock=50400 horizontal=720,140,92,140 vertical=720,20,10,20", -+ "M clock=50220 horizontal=720,140,80,140 vertical=720,20,15,20", -+ "M clock=54600 horizontal=720,140,112,140 vertical=720,20,57,20", -+ "M clock=75450 horizontal=720,140,95,140 vertical=720,20,153,20", -+ "M clock=75330 horizontal=720,140,80,140 vertical=720,20,15,20", -+ "M clock=100440 horizontal=720,140,80,140 vertical=720,20,15,20", -+ -+ "I seq=b9f11283", -+ "I seq=b1000000da80", -+ "I seq=b23c1230", -+ "I seq=b31010282803ff00000000", -+ "I seq=b480", -+ "I seq=b50a0a", -+ "I seq=b69797", -+ "I seq=b82622f013", -+ "I seq=ba338105f90e0e2000000000000000442500900a0000014f01000037", -+ "I seq=bc47", -+ "I seq=bf021100", -+ "I seq=c0737350500000127000", -+ "I seq=c12500323277e4ffffcccc7777", -+ "I seq=c68200bfff00ff", -+ "I seq=c7b8000a000000", -+ "I seq=c810401e02", -+ "I seq=cc0b", -+ "I seq=e0000b102c3d3f423a070d0f131513140f16000b102c3d3f423a070d0f131513140f16", -+ "I seq=e307070b0b0b0b00000000ff00c010", -+ "I seq=e9c8100a000080811231234f86a000470800000c00000000000c00000098028baf4602888888888898138baf5713888888888800000000000000000000000000", -+ "I seq=ea970c090909780000000000009f318ba8317588888888889f208ba820648888888888230000027100000000000000000000000000000040808100000000", -+ "I seq=efffff01", -+ "I seq=11 wait=250", -+ "I seq=29 wait=50"; -+}; -+ -+ diff --git a/projects/ROCKNIX/devices/RK3326/patches/mali-bifrost/001-single-regulator.patch b/projects/ROCKNIX/devices/RK3326/patches/mali-bifrost/001-single-regulator.patch deleted file mode 100644 index 0ebd0b68a5f..00000000000 --- a/projects/ROCKNIX/devices/RK3326/patches/mali-bifrost/001-single-regulator.patch +++ /dev/null @@ -1,31 +0,0 @@ ---- a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_defs.h 2024-02-19 17:24:21.000000000 +0300 -+++ b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_defs.h 2024-03-18 23:51:35.201950500 +0300 -@@ -141,7 +141,7 @@ - * This is dependent on support for of_property_read_u64_array() in the - * kernel. - */ --#define BASE_MAX_NR_CLOCKS_REGULATORS (2) -+#define BASE_MAX_NR_CLOCKS_REGULATORS (1) - - /* Forward declarations */ - struct kbase_context; ---- a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c 2024-03-19 00:26:38.775395807 +0300 -+++ b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c 2024-03-19 00:23:39.644058337 +0300 -@@ -4725,7 +4725,7 @@ - int err = 0; - unsigned int i; - #if defined(CONFIG_REGULATOR) -- static const char *const regulator_names[] = { "mali", "shadercores" }; -+ static const char *const regulator_names[] = { "mali", NULL }; - BUILD_BUG_ON(ARRAY_SIZE(regulator_names) < BASE_MAX_NR_CLOCKS_REGULATORS); - #endif /* CONFIG_REGULATOR */ - -@@ -4771,7 +4771,7 @@ - * operating with a partial initialization of clocks. - */ - for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) { -- kbdev->clocks[i] = of_clk_get(kbdev->dev->of_node, (int)i); -+ kbdev->clocks[i] = of_clk_get_by_name(kbdev->dev->of_node, "bus"); - if (IS_ERR(kbdev->clocks[i])) { - err = PTR_ERR(kbdev->clocks[i]); - kbdev->clocks[i] = NULL; diff --git a/projects/ROCKNIX/devices/RK3326/patches/mali-bifrost/003-midgard-refactor-power-init-and-fixed-unbalanced-run.patch b/projects/ROCKNIX/devices/RK3326/patches/mali-bifrost/003-midgard-refactor-power-init-and-fixed-unbalanced-run.patch deleted file mode 100644 index 125dc126497..00000000000 --- a/projects/ROCKNIX/devices/RK3326/patches/mali-bifrost/003-midgard-refactor-power-init-and-fixed-unbalanced-run.patch +++ /dev/null @@ -1,199 +0,0 @@ -From 5b1c50b3e181a57f5ce0a7d8c50f0f0823ac1609 Mon Sep 17 00:00:00 2001 -From: Paul Reioux -Date: Wed, 12 Jun 2024 07:36:52 -0700 -Subject: [PATCH] midgard: refactor power init and fixed unbalanced runtime PM - calls - -Signed-off-by: Paul Reioux ---- - .../gpu/arm/midgard/mali_kbase_core_linux.c | 124 ++++++++++++------ - .../platform/meson/mali_kbase_runtime_pm.c | 11 +- - 2 files changed, 88 insertions(+), 47 deletions(-) - -diff --git a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c -index 0ad8a70..8db0c13 100644 ---- a/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c -+++ b/product/kernel/drivers/gpu/arm/midgard/mali_kbase_core_linux.c -@@ -4507,31 +4507,44 @@ int power_control_init(struct kbase_device *kbdev) - - pdev = to_platform_device(kbdev->dev); - --#if defined(CONFIG_REGULATOR) -- /* Since the error code EPROBE_DEFER causes the entire probing -- * procedure to be restarted from scratch at a later time, -- * all regulators will be released before returning. -- * -- * Any other error is ignored and the driver will continue -- * operating with a partial initialization of regulators. -- */ -- for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) { -- kbdev->regulators[i] = regulator_get_optional(kbdev->dev, regulator_names[i]); -- if (IS_ERR(kbdev->regulators[i])) { -- err = PTR_ERR(kbdev->regulators[i]); -- kbdev->regulators[i] = NULL; -- break; -- } -- } -- if (err == -EPROBE_DEFER) { -- while (i > 0) -- regulator_put(kbdev->regulators[--i]); -- return err; -+// #if defined(CONFIG_REGULATOR) -+// /* Since the error code EPROBE_DEFER causes the entire probing -+// * procedure to be restarted from scratch at a later time, -+// * all regulators will be released before returning. -+// * -+// * Any other error is ignored and the driver will continue -+// * operating with a partial initialization of regulators. -+// */ -+// for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) { -+// kbdev->regulators[i] = regulator_get_optional(kbdev->dev, regulator_names[i]); -+// if (IS_ERR(kbdev->regulators[i])) { -+// err = PTR_ERR(kbdev->regulators[i]); -+// kbdev->regulators[i] = NULL; -+// break; -+// } -+// } -+// if (err == -EPROBE_DEFER) { -+// while (i > 0) -+// regulator_put(kbdev->regulators[--i]); -+// return err; -+// } -+ kbdev->regulators[0] = devm_regulator_get_optional(kbdev->dev, regulator_names[0]); -+ -+ if (IS_ERR(kbdev->regulators[0])) { -+ err = PTR_ERR(kbdev->regulators[0]); -+ kbdev->regulators[0] = NULL; -+ kbdev->nr_regulators = 0; -+ } else { -+ kbdev->nr_regulators = 1; -+ -+ err = regulator_enable(kbdev->regulators[0]); -+ if (err) -+ dev_dbg(&pdev->dev, "regulator_enable failed\n"); - } - -- kbdev->nr_regulators = i; - dev_dbg(&pdev->dev, "Regulators probed: %u\n", kbdev->nr_regulators); --#endif -+ -+// #endif - - /* Having more clocks than regulators is acceptable, while the - * opposite shall not happen. -@@ -4543,30 +4556,55 @@ int power_control_init(struct kbase_device *kbdev) - * Any other error is ignored and the driver will continue - * operating with a partial initialization of clocks. - */ -- for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) { -- kbdev->clocks[i] = of_clk_get_by_name(kbdev->dev->of_node, "bus"); -- if (IS_ERR(kbdev->clocks[i])) { -- err = PTR_ERR(kbdev->clocks[i]); -- kbdev->clocks[i] = NULL; -- break; -- } - -- err = clk_prepare_enable(kbdev->clocks[i]); -- if (err) { -- dev_err(kbdev->dev, "Failed to prepare and enable clock (%d)\n", err); -- clk_put(kbdev->clocks[i]); -- break; -- } -- } -- if (err == -EPROBE_DEFER) { -- while (i > 0) { -- clk_disable_unprepare(kbdev->clocks[--i]); -- clk_put(kbdev->clocks[i]); -- } -- goto clocks_probe_defer; -+ kbdev->clocks[0] = devm_clk_get_optional(kbdev->dev, NULL); -+ if (!IS_ERR(kbdev->clocks[0])) -+ dev_dbg(kbdev->dev, "clk_get: %s\n", __clk_get_name(kbdev->clocks[0])); -+ else -+ dev_err(kbdev->dev, "clk_get: is NULL"); -+ -+ /* if platform device is enabled, disable it now */ -+ //if (__clk_is_enabled(kbdev->clocks[0])) { -+ // clk_disable(kbdev->clocks[0]); -+ //} -+ /* delete from clk tree */ -+ //clk_unprepare(kbdev->clocks[0]); -+ //clk_put(kbdev->clocks[0]); -+ -+ /* now grab the gpu clock node from device tree definition */ -+ //kbdev->clocks[0] = of_clk_get_by_name(kbdev->dev->of_node, "gpu"); -+ -+ /* we are kinda commited here.. if this fails, the system will lock up */ -+ err = clk_prepare_enable(kbdev->clocks[0]); -+ if (err) { -+ dev_err(kbdev->dev, "Failed to prepare and enable clock (%d)\n", err); -+ clk_put(kbdev->clocks[0]); - } - -- kbdev->nr_clocks = i; -+ // for (i = 0; i < BASE_MAX_NR_CLOCKS_REGULATORS; i++) { -+ // kbdev->clocks[i] = of_clk_get(kbdev->dev->of_node, (int)i); -+ // if (IS_ERR(kbdev->clocks[i])) { -+ // err = PTR_ERR(kbdev->clocks[i]); -+ // kbdev->clocks[i] = NULL; -+ // break; -+ // } -+ -+ // err = clk_prepare_enable(kbdev->clocks[i]); -+ // if (err) { -+ // dev_err(kbdev->dev, "Failed to prepare and enable clock (%d)\n", err); -+ // clk_put(kbdev->clocks[i]); -+ // break; -+ // } -+ // } -+ // if (err == -EPROBE_DEFER) { -+ // while (i > 0) { -+ // clk_disable_unprepare(kbdev->clocks[--i]); -+ // clk_put(kbdev->clocks[i]); -+ // } -+ // goto clocks_probe_defer; -+ // } -+ -+ kbdev->nr_clocks = 1; - dev_dbg(&pdev->dev, "Clocks probed: %u\n", kbdev->nr_clocks); - - /* Any error in parsing the OPP table from the device file -diff --git a/product/kernel/drivers/gpu/arm/midgard/platform/meson/mali_kbase_runtime_pm.c b/product/kernel/drivers/gpu/arm/midgard/platform/meson/mali_kbase_runtime_pm.c -index bd3b4b5..33a24bb 100644 ---- a/product/kernel/drivers/gpu/arm/midgard/platform/meson/mali_kbase_runtime_pm.c -+++ b/product/kernel/drivers/gpu/arm/midgard/platform/meson/mali_kbase_runtime_pm.c -@@ -113,7 +113,8 @@ static void enable_gpu_power_control(struct kbase_device *kbdev) - if (WARN_ON(kbdev->clocks[i] == NULL)) - ; - else if (!__clk_is_enabled(kbdev->clocks[i])) -- WARN_ON(clk_prepare_enable(kbdev->clocks[i])); -+ //WARN_ON(clk_prepare_enable(kbdev->clocks[i])); -+ ; - } - } - -@@ -125,8 +126,9 @@ static void disable_gpu_power_control(struct kbase_device *kbdev) - if (WARN_ON(kbdev->clocks[i] == NULL)) - ; - else if (__clk_is_enabled(kbdev->clocks[i])) { -- clk_disable_unprepare(kbdev->clocks[i]); -- WARN_ON(__clk_is_enabled(kbdev->clocks[i])); -+ //clk_disable_unprepare(kbdev->clocks[i]); -+ //WARN_ON(__clk_is_enabled(kbdev->clocks[i])); -+ ; - } - } - -@@ -135,7 +137,8 @@ static void disable_gpu_power_control(struct kbase_device *kbdev) - if (WARN_ON(kbdev->regulators[i] == NULL)) - ; - else if (regulator_is_enabled(kbdev->regulators[i])) -- WARN_ON(regulator_disable(kbdev->regulators[i])); -+ //WARN_ON(regulator_disable(kbdev->regulators[i])); -+ ; - } - #endif - } --- -2.34.1 - diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL8733BU/package.mk b/projects/ROCKNIX/packages/linux-drivers/RTL8733BU/package.mk deleted file mode 100644 index fa47a6450f5..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL8733BU/package.mk +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) - -PKG_NAME="RTL8733BU" -PKG_VERSION="308919f005f439de433aac977f925bb57f59acf4" -PKG_LICENSE="GPL" -PKG_SITE="https://github.com/wirenboard/rtl8733bu" -PKG_URL="https://github.com/ROCKNIX/RTL8733BU/archive/${PKG_VERSION}.tar.gz" -PKG_LONGDESC="RTL8733BU driver" -PKG_TOOLCHAIN="make" -PKG_IS_KERNEL_PKG="yes" - -pre_make_target() { - unset LDFLAGS -} - -make_target() { - make V=1 \ - ARCH=${TARGET_KERNEL_ARCH} \ - KSRC=$(kernel_path) \ - CROSS_COMPILE=${TARGET_KERNEL_PREFIX} \ - CONFIG_POWER_SAVING=y -} - -makeinstall_target() { - mkdir -p ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless - cp *.ko ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless -} diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL8812AU/modprobe.d/8812au.conf b/projects/ROCKNIX/packages/linux-drivers/RTL8812AU/modprobe.d/8812au.conf deleted file mode 100644 index abfc21fd604..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL8812AU/modprobe.d/8812au.conf +++ /dev/null @@ -1,155 +0,0 @@ -# /etc/modprobe.d/8812au.conf -# -# Purpose: Allow easy access to specific driver options. -# -# Edit the following line to change, add or delete options: -options 8812au rtw_drv_log_level=0 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_power_mgnt=1 rtw_beamform_cap=0 rtw_dfs_region_domain=0 rtw_switch_usb_mode=0 -# -# After editing is complete, save this file (if using nano: Ctrl + x, y, Enter) -# and reboot to activate the changes. -# -# Documentation: -# -# ----- -# -# Log options ( rtw_drv_log_level ) -# -# 0 = NONE (default) -# 1 = ALWAYS -# 2 = ERROR -# 3 = WARNING -# 4 = INFO -# 5 = DEBUG -# 6 = MAX -# -# Note: You can save a log file that only includes RTW log entries by running -# the following in a terminal: -# -# sudo ./save-log.sh -# -# Note: The name of the log file will be ```rtw.log```. -# -# ----- -# -# LED options ( rtw_led_ctrl ) -# -# 0 = Always off -# 1 = Normal blink (default) -# 2 = Always on -# -# ----- -# -# VHT options ( rtw_vht_enable ) -# -# 0 = Disable -# 1 = Enable (default) -# 2 = Force auto enable (use only for 5 GHz AP mode) -# -# Notes: -# - A non-default setting can degrade performance greatly in managed mode. -# - Option 2 allows 80 MHz channel width for 5GHz AP mode, such as when -# you are using hostapd. -# -# ----- -# -# Power options ( rtw_power_mgnt ) -# -# 0 = Disable power saving -# 1 = Power saving on, minPS (default) -# 2 = Power saving on, maxPS (not recommended for AP mode) -# -# ----- -# -# Beamforming options ( rtw_beamform_cap ) -# -# 0 = Disable (default) -# 1 = SU Beamformer -# 2 = SU Beamformee -# 3 = SU Beamformer and SU Beamformee -# 10= SU Beamformee and MU Beamformee -# 11= SU Beamformer and SU Beamformee and MU Beamformee -# -# Note: MU Beamformer is not supported. -# -# ----- -# -# Country Code options ( rtw_country_code ) -# -# Note: Allows the Country Code to be set in cases where it is unable to -# be obtained from the operating system. -# -# Example for the US: rtw_country_code=US -# Example for Panama: rtw_country_code=PA -# Example for Norway: rtw_country_code=NO -# Example for Kuwait: rtw_country_code=KW -# Example for Taiwan: rtw_country_code=TW -# -# ----- -# -# DFS Options ( rtw_dfs_region_domain ) -# -# 0 = NONE (default) -# 1 = FCC -# 2 = MKK -# 3 = ETSI -# -# Notes: -# - Activates DFS channels in AP mode. -# - DFS FCC 80 MHz channels for hostapd: 52(58), 100(106), 116(122) and 132(138) -# - For more information: https://en.wikipedia.org/wiki/List_of_WLAN_channels -# -# Note: An AP needs to listen on a DFS channel for a period of 60 seconds -# before transmitting on the channel. If any radar pulses are detected, -# the AP cannot use that channel and will have to try a different channel. -# -# ----- -# -# Select P2P interface in concurrent mode ( rtw_sel_p2p_iface ) -# -# 0 = Sets interface 0 to be p2p interface -# 1 = Sets interface 1 to be p2p interface (default) -# -# ----- -# -# USB options: ( rtw_switch_usb_mode ) -# -# 0 = No switch (default) -# 1 = Switch from usb 2.0 to usb 3.0 -# 2 = Switch from usb 3.0 to usb 2.0 -# -# ----- -# -# To see all options that are available: -# -# $ ls /sys/module/8812au/parameters/ -# -# ----- -# -# To see the values that are in use: -# -# $ grep [[:alnum:]] /sys/module/8812au/parameters/* -# -# ----- -# -# hostapd setup information for rtl8812au -# Note: The best settings can vary but the following may be a good place to start. -# -# /etc/modprobe.d/8812au.conf -# options 8812au rtw_drv_log_level=0 rtw_led_ctrl=0 rtw_vht_enable=2 rtw_power_mgnt=1 rtw_beamform_cap=0 rtw_dfs_region_domain=1 rtw_switch_usb_mode=1 -# -# Note: The best setting for `rtw_dfs_region_domain=` will depend on your location. -# -# /etc/hostapd/hostapd.conf -# -# hw ht capab: 0x862 -# ht_capab=[HT40+][HT40-][SHORT-GI-20][SHORT-GI-40][MAX-AMSDU-7935] -# -# hw vht capab: 0x03c001a2 -# vht_capab=[MAX-MPDU-11454][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][HTC-VHT][MAX-A-MPDU-LEN-EXP7] -# -# ----- - - - - - diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL8812AU/package.mk b/projects/ROCKNIX/packages/linux-drivers/RTL8812AU/package.mk deleted file mode 100644 index ebf9865ec13..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL8812AU/package.mk +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv) -# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv) -# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) - -PKG_NAME="RTL8812AU" -PKG_VERSION="3e8c73224cede1097c49fcd1ecd2e3e181f4540d" -PKG_LICENSE="GPL" -PKG_SITE="https://github.com/morrownr/8812au-20210820" -PKG_URL="${PKG_SITE}.git" -PKG_LONGDESC="Realtek 8812AU driver for 4.4-5.x" -PKG_TOOLCHAIN="make" -PKG_IS_KERNEL_PKG="yes" - -pre_make_target() { - unset LDFLAGS -} - -make_target() { - make V=1 \ - ARCH=${TARGET_KERNEL_ARCH} \ - KSRC=$(kernel_path) \ - CROSS_COMPILE=${TARGET_KERNEL_PREFIX} \ - CONFIG_POWER_SAVING=y -} - -makeinstall_target() { - mkdir -p ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ - cp *.ko ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ -} diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL8814AU/modprobe.d/8812au.conf b/projects/ROCKNIX/packages/linux-drivers/RTL8814AU/modprobe.d/8812au.conf deleted file mode 100644 index abfc21fd604..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL8814AU/modprobe.d/8812au.conf +++ /dev/null @@ -1,155 +0,0 @@ -# /etc/modprobe.d/8812au.conf -# -# Purpose: Allow easy access to specific driver options. -# -# Edit the following line to change, add or delete options: -options 8812au rtw_drv_log_level=0 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_power_mgnt=1 rtw_beamform_cap=0 rtw_dfs_region_domain=0 rtw_switch_usb_mode=0 -# -# After editing is complete, save this file (if using nano: Ctrl + x, y, Enter) -# and reboot to activate the changes. -# -# Documentation: -# -# ----- -# -# Log options ( rtw_drv_log_level ) -# -# 0 = NONE (default) -# 1 = ALWAYS -# 2 = ERROR -# 3 = WARNING -# 4 = INFO -# 5 = DEBUG -# 6 = MAX -# -# Note: You can save a log file that only includes RTW log entries by running -# the following in a terminal: -# -# sudo ./save-log.sh -# -# Note: The name of the log file will be ```rtw.log```. -# -# ----- -# -# LED options ( rtw_led_ctrl ) -# -# 0 = Always off -# 1 = Normal blink (default) -# 2 = Always on -# -# ----- -# -# VHT options ( rtw_vht_enable ) -# -# 0 = Disable -# 1 = Enable (default) -# 2 = Force auto enable (use only for 5 GHz AP mode) -# -# Notes: -# - A non-default setting can degrade performance greatly in managed mode. -# - Option 2 allows 80 MHz channel width for 5GHz AP mode, such as when -# you are using hostapd. -# -# ----- -# -# Power options ( rtw_power_mgnt ) -# -# 0 = Disable power saving -# 1 = Power saving on, minPS (default) -# 2 = Power saving on, maxPS (not recommended for AP mode) -# -# ----- -# -# Beamforming options ( rtw_beamform_cap ) -# -# 0 = Disable (default) -# 1 = SU Beamformer -# 2 = SU Beamformee -# 3 = SU Beamformer and SU Beamformee -# 10= SU Beamformee and MU Beamformee -# 11= SU Beamformer and SU Beamformee and MU Beamformee -# -# Note: MU Beamformer is not supported. -# -# ----- -# -# Country Code options ( rtw_country_code ) -# -# Note: Allows the Country Code to be set in cases where it is unable to -# be obtained from the operating system. -# -# Example for the US: rtw_country_code=US -# Example for Panama: rtw_country_code=PA -# Example for Norway: rtw_country_code=NO -# Example for Kuwait: rtw_country_code=KW -# Example for Taiwan: rtw_country_code=TW -# -# ----- -# -# DFS Options ( rtw_dfs_region_domain ) -# -# 0 = NONE (default) -# 1 = FCC -# 2 = MKK -# 3 = ETSI -# -# Notes: -# - Activates DFS channels in AP mode. -# - DFS FCC 80 MHz channels for hostapd: 52(58), 100(106), 116(122) and 132(138) -# - For more information: https://en.wikipedia.org/wiki/List_of_WLAN_channels -# -# Note: An AP needs to listen on a DFS channel for a period of 60 seconds -# before transmitting on the channel. If any radar pulses are detected, -# the AP cannot use that channel and will have to try a different channel. -# -# ----- -# -# Select P2P interface in concurrent mode ( rtw_sel_p2p_iface ) -# -# 0 = Sets interface 0 to be p2p interface -# 1 = Sets interface 1 to be p2p interface (default) -# -# ----- -# -# USB options: ( rtw_switch_usb_mode ) -# -# 0 = No switch (default) -# 1 = Switch from usb 2.0 to usb 3.0 -# 2 = Switch from usb 3.0 to usb 2.0 -# -# ----- -# -# To see all options that are available: -# -# $ ls /sys/module/8812au/parameters/ -# -# ----- -# -# To see the values that are in use: -# -# $ grep [[:alnum:]] /sys/module/8812au/parameters/* -# -# ----- -# -# hostapd setup information for rtl8812au -# Note: The best settings can vary but the following may be a good place to start. -# -# /etc/modprobe.d/8812au.conf -# options 8812au rtw_drv_log_level=0 rtw_led_ctrl=0 rtw_vht_enable=2 rtw_power_mgnt=1 rtw_beamform_cap=0 rtw_dfs_region_domain=1 rtw_switch_usb_mode=1 -# -# Note: The best setting for `rtw_dfs_region_domain=` will depend on your location. -# -# /etc/hostapd/hostapd.conf -# -# hw ht capab: 0x862 -# ht_capab=[HT40+][HT40-][SHORT-GI-20][SHORT-GI-40][MAX-AMSDU-7935] -# -# hw vht capab: 0x03c001a2 -# vht_capab=[MAX-MPDU-11454][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][HTC-VHT][MAX-A-MPDU-LEN-EXP7] -# -# ----- - - - - - diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL8814AU/package.mk b/projects/ROCKNIX/packages/linux-drivers/RTL8814AU/package.mk deleted file mode 100644 index 78b1ec6dbaf..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL8814AU/package.mk +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv) -# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv) -# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) - -PKG_NAME="RTL8814AU" -PKG_VERSION="b5a6f96cd20a1c6a35ccb000f2f4924dd19704a3" -PKG_LICENSE="GPL" -PKG_SITE="https://github.com/morrownr/8814au" -PKG_URL="${PKG_SITE}.git" -PKG_LONGDESC="Realtek 8814AU driver for 4.4-5.x" -PKG_TOOLCHAIN="make" -PKG_IS_KERNEL_PKG="yes" - -pre_make_target() { - unset LDFLAGS -} - -make_target() { - make V=1 \ - ARCH=${TARGET_KERNEL_ARCH} \ - KSRC=$(kernel_path) \ - CROSS_COMPILE=${TARGET_KERNEL_PREFIX} \ - CONFIG_POWER_SAVING=y -} - -makeinstall_target() { - mkdir -p ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ - cp *.ko ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ -} diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL8821AU/modprobe.d/8812au.conf b/projects/ROCKNIX/packages/linux-drivers/RTL8821AU/modprobe.d/8812au.conf deleted file mode 100644 index abfc21fd604..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL8821AU/modprobe.d/8812au.conf +++ /dev/null @@ -1,155 +0,0 @@ -# /etc/modprobe.d/8812au.conf -# -# Purpose: Allow easy access to specific driver options. -# -# Edit the following line to change, add or delete options: -options 8812au rtw_drv_log_level=0 rtw_led_ctrl=1 rtw_vht_enable=1 rtw_power_mgnt=1 rtw_beamform_cap=0 rtw_dfs_region_domain=0 rtw_switch_usb_mode=0 -# -# After editing is complete, save this file (if using nano: Ctrl + x, y, Enter) -# and reboot to activate the changes. -# -# Documentation: -# -# ----- -# -# Log options ( rtw_drv_log_level ) -# -# 0 = NONE (default) -# 1 = ALWAYS -# 2 = ERROR -# 3 = WARNING -# 4 = INFO -# 5 = DEBUG -# 6 = MAX -# -# Note: You can save a log file that only includes RTW log entries by running -# the following in a terminal: -# -# sudo ./save-log.sh -# -# Note: The name of the log file will be ```rtw.log```. -# -# ----- -# -# LED options ( rtw_led_ctrl ) -# -# 0 = Always off -# 1 = Normal blink (default) -# 2 = Always on -# -# ----- -# -# VHT options ( rtw_vht_enable ) -# -# 0 = Disable -# 1 = Enable (default) -# 2 = Force auto enable (use only for 5 GHz AP mode) -# -# Notes: -# - A non-default setting can degrade performance greatly in managed mode. -# - Option 2 allows 80 MHz channel width for 5GHz AP mode, such as when -# you are using hostapd. -# -# ----- -# -# Power options ( rtw_power_mgnt ) -# -# 0 = Disable power saving -# 1 = Power saving on, minPS (default) -# 2 = Power saving on, maxPS (not recommended for AP mode) -# -# ----- -# -# Beamforming options ( rtw_beamform_cap ) -# -# 0 = Disable (default) -# 1 = SU Beamformer -# 2 = SU Beamformee -# 3 = SU Beamformer and SU Beamformee -# 10= SU Beamformee and MU Beamformee -# 11= SU Beamformer and SU Beamformee and MU Beamformee -# -# Note: MU Beamformer is not supported. -# -# ----- -# -# Country Code options ( rtw_country_code ) -# -# Note: Allows the Country Code to be set in cases where it is unable to -# be obtained from the operating system. -# -# Example for the US: rtw_country_code=US -# Example for Panama: rtw_country_code=PA -# Example for Norway: rtw_country_code=NO -# Example for Kuwait: rtw_country_code=KW -# Example for Taiwan: rtw_country_code=TW -# -# ----- -# -# DFS Options ( rtw_dfs_region_domain ) -# -# 0 = NONE (default) -# 1 = FCC -# 2 = MKK -# 3 = ETSI -# -# Notes: -# - Activates DFS channels in AP mode. -# - DFS FCC 80 MHz channels for hostapd: 52(58), 100(106), 116(122) and 132(138) -# - For more information: https://en.wikipedia.org/wiki/List_of_WLAN_channels -# -# Note: An AP needs to listen on a DFS channel for a period of 60 seconds -# before transmitting on the channel. If any radar pulses are detected, -# the AP cannot use that channel and will have to try a different channel. -# -# ----- -# -# Select P2P interface in concurrent mode ( rtw_sel_p2p_iface ) -# -# 0 = Sets interface 0 to be p2p interface -# 1 = Sets interface 1 to be p2p interface (default) -# -# ----- -# -# USB options: ( rtw_switch_usb_mode ) -# -# 0 = No switch (default) -# 1 = Switch from usb 2.0 to usb 3.0 -# 2 = Switch from usb 3.0 to usb 2.0 -# -# ----- -# -# To see all options that are available: -# -# $ ls /sys/module/8812au/parameters/ -# -# ----- -# -# To see the values that are in use: -# -# $ grep [[:alnum:]] /sys/module/8812au/parameters/* -# -# ----- -# -# hostapd setup information for rtl8812au -# Note: The best settings can vary but the following may be a good place to start. -# -# /etc/modprobe.d/8812au.conf -# options 8812au rtw_drv_log_level=0 rtw_led_ctrl=0 rtw_vht_enable=2 rtw_power_mgnt=1 rtw_beamform_cap=0 rtw_dfs_region_domain=1 rtw_switch_usb_mode=1 -# -# Note: The best setting for `rtw_dfs_region_domain=` will depend on your location. -# -# /etc/hostapd/hostapd.conf -# -# hw ht capab: 0x862 -# ht_capab=[HT40+][HT40-][SHORT-GI-20][SHORT-GI-40][MAX-AMSDU-7935] -# -# hw vht capab: 0x03c001a2 -# vht_capab=[MAX-MPDU-11454][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][HTC-VHT][MAX-A-MPDU-LEN-EXP7] -# -# ----- - - - - - diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL8821AU/package.mk b/projects/ROCKNIX/packages/linux-drivers/RTL8821AU/package.mk deleted file mode 100644 index 17914d06525..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL8821AU/package.mk +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv) -# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv) -# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) - -PKG_NAME="RTL8821AU" -PKG_VERSION="847c74b1c272466f89c77947f7a9703222f0093b" -PKG_LICENSE="GPL" -PKG_SITE="https://github.com/morrownr/8821au-20210708" -PKG_URL="${PKG_SITE}.git" -PKG_LONGDESC="Realtek 8821AU driver for 4.4-5.x" -PKG_TOOLCHAIN="make" -PKG_IS_KERNEL_PKG="yes" - -pre_make_target() { - unset LDFLAGS -} - -make_target() { - make V=1 \ - ARCH=${TARGET_KERNEL_ARCH} \ - KSRC=$(kernel_path) \ - CROSS_COMPILE=${TARGET_KERNEL_PREFIX} \ - CONFIG_POWER_SAVING=y -} - -makeinstall_target() { - mkdir -p ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ - cp *.ko ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ -} diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL8851BU/package.mk b/projects/ROCKNIX/packages/linux-drivers/RTL8851BU/package.mk deleted file mode 100644 index 1dd1ea9f1bf..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL8851BU/package.mk +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) - -PKG_NAME="RTL8851BU" -PKG_VERSION="f94ea820634d3bd050009e861952d3b8eeef869a" -PKG_LICENSE="GPL" -PKG_SITE="https://github.com/neatojones/RTL8851bu" -PKG_URL="${PKG_SITE}.git" -PKG_LONGDESC="Realtek 8851BU Linux driver" -PKG_TOOLCHAIN="make" -PKG_IS_KERNEL_PKG="yes" - -pre_make_target() { - unset LDFLAGS -} - -make_target() { - make V=1 \ - ARCH=${TARGET_KERNEL_ARCH} \ - KSRC=$(kernel_path) \ - CROSS_COMPILE=${TARGET_KERNEL_PREFIX} \ - CONFIG_RTW_DEBUG=n -} - -makeinstall_target() { - mkdir -p ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ - cp *.ko ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ -} diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL8851BU/patches/001-fix-building-on-6-12.patch b/projects/ROCKNIX/packages/linux-drivers/RTL8851BU/patches/001-fix-building-on-6-12.patch deleted file mode 100644 index 7840acffb9e..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL8851BU/patches/001-fix-building-on-6-12.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/Makefile -+++ b/Makefile -@@ -14,6 +14,7 @@ - #EXTRA_CFLAGS += -Wno-unused-function - EXTRA_CFLAGS += -Wno-unused - #EXTRA_CFLAGS += -Wno-uninitialized -+EXTRA_CFLAGS += -w - - ############ ANDROID COMMON KERNEL ############ - # clang ---- a/os_dep/linux/ioctl_cfg80211.h -+++ b/os_dep/linux/ioctl_cfg80211.h -@@ -90,7 +90,7 @@ - - #if defined(CONFIG_DFS_MASTER) && (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)) - #ifndef CONFIG_RTW_CFG80211_CAC_EVENT --#define CONFIG_RTW_CFG80211_CAC_EVENT 1 -+#define CONFIG_RTW_CFG80211_CAC_EVENT 0 - #endif - #else - #ifdef CONFIG_RTW_CFG80211_CAC_EVENT diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL88x2BU/modprobe.d/8812bu.conf b/projects/ROCKNIX/packages/linux-drivers/RTL88x2BU/modprobe.d/8812bu.conf deleted file mode 100644 index aadea8748ab..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL88x2BU/modprobe.d/8812bu.conf +++ /dev/null @@ -1 +0,0 @@ -options 88x2bu rtw_power_mgnt=0 rtw_ips_mode=0 rtw_enusbss=0 diff --git a/projects/ROCKNIX/packages/linux-drivers/RTL88x2BU/package.mk b/projects/ROCKNIX/packages/linux-drivers/RTL88x2BU/package.mk deleted file mode 100644 index 80857d711c8..00000000000 --- a/projects/ROCKNIX/packages/linux-drivers/RTL88x2BU/package.mk +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv) -# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv) -# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) - -PKG_NAME="RTL88x2BU" -PKG_VERSION="6e4c5ccfd6607e9f4b1c1befd165ce56e7d6a653" -PKG_LICENSE="GPL" -PKG_SITE="https://github.com/morrownr/88x2bu-20210702" -PKG_URL="${PKG_SITE}.git" -PKG_LONGDESC="Realtek 88x2BU driver for 4.4-5.x" -PKG_TOOLCHAIN="make" -PKG_IS_KERNEL_PKG="yes" - -pre_make_target() { - unset LDFLAGS -} - -make_target() { - make V=1 \ - ARCH=${TARGET_KERNEL_ARCH} \ - KSRC=$(kernel_path) \ - CROSS_COMPILE=${TARGET_KERNEL_PREFIX} \ - CONFIG_POWER_SAVING=y -} - -makeinstall_target() { - mkdir -p ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ - cp *.ko ${INSTALL}/$(get_full_module_dir)/kernel/drivers/net/wireless/ -} diff --git a/projects/ROCKNIX/packages/linux-drivers/generic-dsi/scripts/importpanel.py b/projects/ROCKNIX/packages/linux-drivers/generic-dsi/scripts/importpanel.py index 9ff587c49ec..42b316802d3 100755 --- a/projects/ROCKNIX/packages/linux-drivers/generic-dsi/scripts/importpanel.py +++ b/projects/ROCKNIX/packages/linux-drivers/generic-dsi/scripts/importpanel.py @@ -123,7 +123,7 @@ def absfrac(x): def_fps = 60 if orig_def_fps: def_fps = orig_def_fps -common_fpss = [50/1.001, 50, 50.0070, 57.5, 59.7275, 60/1.001, 60, 60.0988, 75.47, 90, 120]; +common_fpss = [50/1.001, 50, 50.0070, 54.8766, 57.5, 59.7275, 60/1.001, 60, 60.0988, 75.47, 90, 120]; common_fpss = [ fps for fps in common_fpss if fps != orig_def_fps] for targetfps in [orig_def_fps] + common_fpss: if not targetfps: diff --git a/projects/ROCKNIX/packages/linux-drivers/mali-bifrost/package.mk b/projects/ROCKNIX/packages/linux-drivers/mali-bifrost/package.mk index 09c45e153c2..e3793f33fd3 100644 --- a/projects/ROCKNIX/packages/linux-drivers/mali-bifrost/package.mk +++ b/projects/ROCKNIX/packages/linux-drivers/mali-bifrost/package.mk @@ -9,11 +9,6 @@ PKG_TOOLCHAIN="manual" PKG_IS_KERNEL_PKG="yes" case ${DEVICE} in - RK3326) - PKG_VERSION="r52p0-00eac0" - PKG_URL="https://developer.arm.com/-/media/Files/downloads/mali-drivers/kernel/mali-valhall-gpu/VX504X08X-SW-99002-${PKG_VERSION}.tar" - PKG_PATCH_DIRS+=" 6.12-LTS" - ;; *) PKG_VERSION="f86d3dd4923b5d5de11ae7eaf7a6c4fee136528e" PKG_URL="http://github.com/sydarn/mali_kbase/archive/${PKG_VERSION}.tar.gz" diff --git a/projects/ROCKNIX/packages/linux-drivers/rocknix-joypad/package.mk b/projects/ROCKNIX/packages/linux-drivers/rocknix-joypad/package.mk index 507dbd7a7b3..f3e76dbc1f7 100644 --- a/projects/ROCKNIX/packages/linux-drivers/rocknix-joypad/package.mk +++ b/projects/ROCKNIX/packages/linux-drivers/rocknix-joypad/package.mk @@ -2,7 +2,7 @@ # Copyright (C) 2024 ROCKNIX (https://github.com/ROCKNIX) PKG_NAME="rocknix-joypad" -PKG_VERSION="d95d0372a907607d6795e02e5bba24856f4d412c" +PKG_VERSION="15b5a29b6b24c0fc59dd6f61602dacf34cbb7eae" PKG_LICENSE="GPL" PKG_SITE="https://github.com/ROCKNIX/rocknix-joypad" PKG_URL="${PKG_SITE}/archive/${PKG_VERSION}.tar.gz" diff --git a/projects/ROCKNIX/packages/linux/package.mk b/projects/ROCKNIX/packages/linux/package.mk index dc764dda123..192b9615c4f 100644 --- a/projects/ROCKNIX/packages/linux/package.mk +++ b/projects/ROCKNIX/packages/linux/package.mk @@ -30,15 +30,7 @@ case ${DEVICE} in PKG_PATCH_DIRS="${LINUX} ${DEVICE} default" ;; *) - case ${DEVICE} in - S922X|SM8550|SM8250|H700|SM8650|RK3566|RK3399) - PKG_VERSION="6.17.8" - ;; - *) - PKG_VERSION="6.12.57" - PKG_PATCH_DIRS+=" 6.12-LTS" - ;; - esac + PKG_VERSION="6.17.8" PKG_URL="https://www.kernel.org/pub/linux/kernel/v${PKG_VERSION/.*/}.x/${PKG_NAME}-${PKG_VERSION}.tar.xz" ;; esac @@ -89,6 +81,11 @@ post_patch() { cp -v $(get_pkg_directory generic-dsi)/sources/panel-generic-dsi.c ${PKG_BUILD}/drivers/gpu/drm/panel/ echo "obj-y" += panel-generic-dsi.o >> ${PKG_BUILD}/drivers/gpu/drm/panel/Makefile fi + + DTS_SOURCE_DIR="${PROJECT_DIR}/${PROJECT}/devices/${DEVICE}/linux/dts" + if [ -d "${DTS_SOURCE_DIR}" ]; then + rsync -av "${DTS_SOURCE_DIR}/" ${PKG_BUILD}/arch/arm64/boot/dts/ + fi } make_init() { diff --git a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0005-drm-panfrost-Add-SYSTEM_TIMESTAMP-and-SYSTEM_TIMESTA.patch b/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0005-drm-panfrost-Add-SYSTEM_TIMESTAMP-and-SYSTEM_TIMESTA.patch deleted file mode 100644 index 5923beef79c..00000000000 --- a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0005-drm-panfrost-Add-SYSTEM_TIMESTAMP-and-SYSTEM_TIMESTA.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 0e43544967428971a9518429e3f65cdbf8bd70a8 Mon Sep 17 00:00:00 2001 -From: Chris Healy -Date: Thu, 19 Dec 2024 13:49:13 -0800 -Subject: [PATCH 1/2] drm/panfrost: Add SYSTEM_TIMESTAMP and - SYSTEM_TIMESTAMP_FREQUENCY parameters - -Expose system timestamp and frequency supported by the GPU. - -Mali uses an external timer as GPU system time. On ARM, this is wired to -the generic arch timer so we wire cntfrq_el0 as device frequency. - -This new uAPI will be used in Mesa to implement timestamp queries and -VK_KHR_calibrated_timestamps. - -v2: -- Rewrote to use GPU timestamp register -- Add missing include for arch_timer_get_cntfrq -- Rework commit message - -v3: -- Move panfrost_cycle_counter_get and panfrost_cycle_counter_put to - panfrost_ioctl_query_timestamp -- Handle possible overflow in panfrost_timestamp_read - -Signed-off-by: Mary Guillemard -Tested-by: Heiko Stuebner -Reviewed-by: Steven Price -Signed-off-by: Steven Price -Link: https://patchwork.freedesktop.org/patch/msgid/20240819080224.24914-2-mary.guillemard@collabora.com ---- - drivers/gpu/drm/panfrost/panfrost_drv.c | 37 ++++++++++++++++++++++++ - drivers/gpu/drm/panfrost/panfrost_gpu.c | 12 ++++++++ - drivers/gpu/drm/panfrost/panfrost_gpu.h | 1 + - drivers/gpu/drm/panfrost/panfrost_regs.h | 2 ++ - include/uapi/drm/panfrost_drm.h | 2 ++ - 5 files changed, 54 insertions(+) - -diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c -index 671eed4ad..790c4ad31 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_drv.c -+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c -@@ -3,6 +3,10 @@ - /* Copyright 2019 Linaro, Ltd., Rob Herring */ - /* Copyright 2019 Collabora ltd. */ - -+#ifdef CONFIG_ARM_ARCH_TIMER -+#include -+#endif -+ - #include - #include - #include -@@ -24,10 +28,28 @@ - static bool unstable_ioctls; - module_param_unsafe(unstable_ioctls, bool, 0600); - -+static int panfrost_ioctl_query_timestamp(struct panfrost_device *pfdev, -+ u64 *arg) -+{ -+ int ret; -+ -+ ret = pm_runtime_resume_and_get(pfdev->dev); -+ if (ret) -+ return ret; -+ -+ panfrost_cycle_counter_get(pfdev); -+ *arg = panfrost_timestamp_read(pfdev); -+ panfrost_cycle_counter_put(pfdev); -+ -+ pm_runtime_put(pfdev->dev); -+ return 0; -+} -+ - static int panfrost_ioctl_get_param(struct drm_device *ddev, void *data, struct drm_file *file) - { - struct drm_panfrost_get_param *param = data; - struct panfrost_device *pfdev = ddev->dev_private; -+ int ret; - - if (param->pad != 0) - return -EINVAL; -@@ -69,6 +91,21 @@ static int panfrost_ioctl_get_param(struct drm_device *ddev, void *data, struct - PANFROST_FEATURE_ARRAY(JS_FEATURES, js_features, 15); - PANFROST_FEATURE(NR_CORE_GROUPS, nr_core_groups); - PANFROST_FEATURE(THREAD_TLS_ALLOC, thread_tls_alloc); -+ -+ case DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP: -+ ret = panfrost_ioctl_query_timestamp(pfdev, ¶m->value); -+ if (ret) -+ return ret; -+ break; -+ -+ case DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP_FREQUENCY: -+#ifdef CONFIG_ARM_ARCH_TIMER -+ param->value = arch_timer_get_cntfrq(); -+#else -+ param->value = 0; -+#endif -+ break; -+ - default: - return -EINVAL; - } -diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.c b/drivers/gpu/drm/panfrost/panfrost_gpu.c -index b52dd510e..f5abde386 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gpu.c -+++ b/drivers/gpu/drm/panfrost/panfrost_gpu.c -@@ -379,6 +379,18 @@ unsigned long long panfrost_cycle_counter_read(struct panfrost_device *pfdev) - return ((u64)hi << 32) | lo; - } - -+unsigned long long panfrost_timestamp_read(struct panfrost_device *pfdev) -+{ -+ u32 hi, lo; -+ -+ do { -+ hi = gpu_read(pfdev, GPU_TIMESTAMP_HI); -+ lo = gpu_read(pfdev, GPU_TIMESTAMP_LO); -+ } while (hi != gpu_read(pfdev, GPU_TIMESTAMP_HI)); -+ -+ return ((u64)hi << 32) | lo; -+} -+ - static u64 panfrost_get_core_mask(struct panfrost_device *pfdev) - { - u64 core_mask; -diff --git a/drivers/gpu/drm/panfrost/panfrost_gpu.h b/drivers/gpu/drm/panfrost/panfrost_gpu.h -index d841b8650..b4fef1121 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gpu.h -+++ b/drivers/gpu/drm/panfrost/panfrost_gpu.h -@@ -20,6 +20,7 @@ void panfrost_gpu_suspend_irq(struct panfrost_device *pfdev); - void panfrost_cycle_counter_get(struct panfrost_device *pfdev); - void panfrost_cycle_counter_put(struct panfrost_device *pfdev); - unsigned long long panfrost_cycle_counter_read(struct panfrost_device *pfdev); -+unsigned long long panfrost_timestamp_read(struct panfrost_device *pfdev); - - void panfrost_gpu_amlogic_quirk(struct panfrost_device *pfdev); - -diff --git a/drivers/gpu/drm/panfrost/panfrost_regs.h b/drivers/gpu/drm/panfrost/panfrost_regs.h -index c25743b05..c7bba476a 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_regs.h -+++ b/drivers/gpu/drm/panfrost/panfrost_regs.h -@@ -78,6 +78,8 @@ - - #define GPU_CYCLE_COUNT_LO 0x90 - #define GPU_CYCLE_COUNT_HI 0x94 -+#define GPU_TIMESTAMP_LO 0x98 -+#define GPU_TIMESTAMP_HI 0x9C - - #define GPU_THREAD_MAX_THREADS 0x0A0 /* (RO) Maximum number of threads per core */ - #define GPU_THREAD_MAX_WORKGROUP_SIZE 0x0A4 /* (RO) Maximum workgroup size */ -diff --git a/include/uapi/drm/panfrost_drm.h b/include/uapi/drm/panfrost_drm.h -index 9f231d40a..52b050e2b 100644 ---- a/include/uapi/drm/panfrost_drm.h -+++ b/include/uapi/drm/panfrost_drm.h -@@ -172,6 +172,8 @@ enum drm_panfrost_param { - DRM_PANFROST_PARAM_NR_CORE_GROUPS, - DRM_PANFROST_PARAM_THREAD_TLS_ALLOC, - DRM_PANFROST_PARAM_AFBC_FEATURES, -+ DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP, -+ DRM_PANFROST_PARAM_SYSTEM_TIMESTAMP_FREQUENCY, - }; - - struct drm_panfrost_get_param { --- -2.34.1 - diff --git a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0006-drm-panfrost-Add-cycle-counter-job-requirement.patch b/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0006-drm-panfrost-Add-cycle-counter-job-requirement.patch deleted file mode 100644 index e8ecba908ca..00000000000 --- a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0006-drm-panfrost-Add-cycle-counter-job-requirement.patch +++ /dev/null @@ -1,153 +0,0 @@ -From 62ace6b8516628a705b913706f6c51d559adfc43 Mon Sep 17 00:00:00 2001 -From: Chris Healy -Date: Thu, 19 Dec 2024 13:51:01 -0800 -Subject: [PATCH 2/2] drm/panfrost: Add cycle counter job requirement - -Extend the uAPI with a new job requirement flag for cycle -counters. This requirement is used by userland to indicate that a job -requires cycle counters or system timestamp to be propagated. (for use -with write value timestamp jobs) - -We cannot enable cycle counters unconditionally as this would result in -an increase of GPU power consumption. As a result, they should be left -off unless required by the application. - -If a job requires cycle counters or system timestamps propagation, we -must enable cycle counting before issuing a job and disable it right -after the job completes. - -Since this extends the uAPI and because userland needs a way to advertise -features like VK_KHR_shader_clock conditionally, we bumps the driver -minor version. - -v2: -- Rework commit message -- Squash uAPI changes and implementation in this commit -- Simplify changes based on Steven Price comments - -v3: -- Add Steven Price r-b -- Fix a codestyle issue - -Signed-off-by: Mary Guillemard -Reviewed-by: Steven Price -Tested-by: Heiko Stuebner -Signed-off-by: Steven Price -Link: https://patchwork.freedesktop.org/patch/msgid/20240819080224.24914-3-mary.guillemard@collabora.com ---- - drivers/gpu/drm/panfrost/panfrost_drv.c | 8 +++++-- - drivers/gpu/drm/panfrost/panfrost_job.c | 28 +++++++++++++++---------- - include/uapi/drm/panfrost_drm.h | 1 + - 3 files changed, 24 insertions(+), 13 deletions(-) - -diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c -index 790c4ad31..04d615df5 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_drv.c -+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c -@@ -25,6 +25,8 @@ - #include "panfrost_gpu.h" - #include "panfrost_perfcnt.h" - -+#define JOB_REQUIREMENTS (PANFROST_JD_REQ_FS | PANFROST_JD_REQ_CYCLE_COUNT) -+ - static bool unstable_ioctls; - module_param_unsafe(unstable_ioctls, bool, 0600); - -@@ -282,7 +284,7 @@ static int panfrost_ioctl_submit(struct drm_device *dev, void *data, - if (!args->jc) - return -EINVAL; - -- if (args->requirements && args->requirements != PANFROST_JD_REQ_FS) -+ if (args->requirements & ~JOB_REQUIREMENTS) - return -EINVAL; - - if (args->out_sync > 0) { -@@ -621,6 +623,8 @@ static const struct file_operations panfrost_drm_driver_fops = { - * - 1.0 - initial interface - * - 1.1 - adds HEAP and NOEXEC flags for CREATE_BO - * - 1.2 - adds AFBC_FEATURES query -+ * - 1.3 - adds JD_REQ_CYCLE_COUNT job requirement for SUBMIT -+ * - adds SYSTEM_TIMESTAMP and SYSTEM_TIMESTAMP_FREQUENCY queries - */ - static const struct drm_driver panfrost_drm_driver = { - .driver_features = DRIVER_RENDER | DRIVER_GEM | DRIVER_SYNCOBJ, -@@ -634,7 +638,7 @@ static const struct drm_driver panfrost_drm_driver = { - .desc = "panfrost DRM", - .date = "20180908", - .major = 1, -- .minor = 2, -+ .minor = 3, - - .gem_create_object = panfrost_gem_create_object, - .gem_prime_import_sg_table = panfrost_gem_prime_import_sg_table, -diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c -index a61ef0af9..05774d870 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_job.c -+++ b/drivers/gpu/drm/panfrost/panfrost_job.c -@@ -159,16 +159,17 @@ panfrost_dequeue_job(struct panfrost_device *pfdev, int slot) - struct panfrost_job *job = pfdev->jobs[slot][0]; - - WARN_ON(!job); -- if (job->is_profiled) { -- if (job->engine_usage) { -- job->engine_usage->elapsed_ns[slot] += -- ktime_to_ns(ktime_sub(ktime_get(), job->start_time)); -- job->engine_usage->cycles[slot] += -- panfrost_cycle_counter_read(pfdev) - job->start_cycles; -- } -- panfrost_cycle_counter_put(job->pfdev); -+ -+ if (job->is_profiled && job->engine_usage) { -+ job->engine_usage->elapsed_ns[slot] += -+ ktime_to_ns(ktime_sub(ktime_get(), job->start_time)); -+ job->engine_usage->cycles[slot] += -+ panfrost_cycle_counter_read(pfdev) - job->start_cycles; - } - -+ if (job->requirements & PANFROST_JD_REQ_CYCLE_COUNT || job->is_profiled) -+ panfrost_cycle_counter_put(pfdev); -+ - pfdev->jobs[slot][0] = pfdev->jobs[slot][1]; - pfdev->jobs[slot][1] = NULL; - -@@ -243,9 +244,13 @@ static void panfrost_job_hw_submit(struct panfrost_job *job, int js) - subslot = panfrost_enqueue_job(pfdev, js, job); - /* Don't queue the job if a reset is in progress */ - if (!atomic_read(&pfdev->reset.pending)) { -- if (pfdev->profile_mode) { -+ job->is_profiled = pfdev->profile_mode; -+ -+ if (job->requirements & PANFROST_JD_REQ_CYCLE_COUNT || -+ job->is_profiled) - panfrost_cycle_counter_get(pfdev); -- job->is_profiled = true; -+ -+ if (job->is_profiled) { - job->start_time = ktime_get(); - job->start_cycles = panfrost_cycle_counter_read(pfdev); - } -@@ -693,7 +698,8 @@ panfrost_reset(struct panfrost_device *pfdev, - spin_lock(&pfdev->js->job_lock); - for (i = 0; i < NUM_JOB_SLOTS; i++) { - for (j = 0; j < ARRAY_SIZE(pfdev->jobs[0]) && pfdev->jobs[i][j]; j++) { -- if (pfdev->jobs[i][j]->is_profiled) -+ if (pfdev->jobs[i][j]->requirements & PANFROST_JD_REQ_CYCLE_COUNT || -+ pfdev->jobs[i][j]->is_profiled) - panfrost_cycle_counter_put(pfdev->jobs[i][j]->pfdev); - pm_runtime_put_noidle(pfdev->dev); - panfrost_devfreq_record_idle(&pfdev->pfdevfreq); -diff --git a/include/uapi/drm/panfrost_drm.h b/include/uapi/drm/panfrost_drm.h -index 52b050e2b..568724be6 100644 ---- a/include/uapi/drm/panfrost_drm.h -+++ b/include/uapi/drm/panfrost_drm.h -@@ -40,6 +40,7 @@ extern "C" { - #define DRM_IOCTL_PANFROST_PERFCNT_DUMP DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_PERFCNT_DUMP, struct drm_panfrost_perfcnt_dump) - - #define PANFROST_JD_REQ_FS (1 << 0) -+#define PANFROST_JD_REQ_CYCLE_COUNT (1 << 1) - /** - * struct drm_panfrost_submit - ioctl argument for submitting commands to the 3D - * engine. --- -2.34.1 - diff --git a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0007-drm-panfrost-Add-BO-labelling-to-Panfrost.patch b/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0007-drm-panfrost-Add-BO-labelling-to-Panfrost.patch deleted file mode 100644 index 3b845041f11..00000000000 --- a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0007-drm-panfrost-Add-BO-labelling-to-Panfrost.patch +++ /dev/null @@ -1,131 +0,0 @@ -From 23703a8b6430d1570bf761a5a2a38479a8c2cceb Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= -Date: Tue, 20 May 2025 18:43:58 +0100 -Subject: [PATCH 3/7] drm/panfrost: Add BO labelling to Panfrost -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Functions for labelling UM-exposed an internal BOs are provided. An -example of the latter would be the Perfcnt sample buffer. - -This commit is done in preparation of a following one that will allow -UM to set BO labels through a new ioctl(). - -Signed-off-by: Adrián Larumbe -Reviewed-by: Steven Price -Reviewed-by: Boris Brezillon -Signed-off-by: Steven Price -Link: https://lore.kernel.org/r/20250520174634.353267-2-adrian.larumbe@collabora.com ---- - drivers/gpu/drm/panfrost/panfrost_gem.c | 42 +++++++++++++++++++++++++ - drivers/gpu/drm/panfrost/panfrost_gem.h | 17 ++++++++++ - 2 files changed, 59 insertions(+) - -diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c -index 8e0ff3efe..a2caa6ad9 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gem.c -+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c -@@ -1,6 +1,7 @@ - // SPDX-License-Identifier: GPL-2.0 - /* Copyright 2019 Linaro, Ltd, Rob Herring */ - -+#include - #include - #include - #include -@@ -35,6 +36,9 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj) - */ - WARN_ON_ONCE(!list_empty(&bo->mappings.list)); - -+ kfree_const(bo->label.str); -+ mutex_destroy(&bo->label.lock); -+ - if (bo->sgts) { - int i; - int n_sgt = bo->base.base.size / SZ_2M; -@@ -260,6 +264,7 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t - mutex_init(&obj->mappings.lock); - obj->base.base.funcs = &panfrost_gem_funcs; - obj->base.map_wc = !pfdev->coherent; -+ mutex_init(&obj->label.lock); - - return &obj->base.base; - } -@@ -302,3 +307,40 @@ panfrost_gem_prime_import_sg_table(struct drm_device *dev, - - return obj; - } -+ -+void -+panfrost_gem_set_label(struct drm_gem_object *obj, const char *label) -+{ -+ struct panfrost_gem_object *bo = to_panfrost_bo(obj); -+ const char *old_label; -+ -+ scoped_guard(mutex, &bo->label.lock) { -+ old_label = bo->label.str; -+ bo->label.str = label; -+ } -+ -+ kfree_const(old_label); -+} -+ -+void -+panfrost_gem_internal_set_label(struct drm_gem_object *obj, const char *label) -+{ -+ struct panfrost_gem_object *bo = to_panfrost_bo(obj); -+ const char *str; -+ -+ /* We should never attempt labelling a UM-exposed GEM object */ -+ if (drm_WARN_ON(bo->base.base.dev, bo->base.base.handle_count > 0)) -+ return; -+ -+ if (!label) -+ return; -+ -+ str = kstrdup_const(label, GFP_KERNEL); -+ if (!str) { -+ /* Failing to allocate memory for a label isn't a fatal condition */ -+ drm_warn(bo->base.base.dev, "Not enough memory to allocate BO label"); -+ return; -+ } -+ -+ panfrost_gem_set_label(obj, str); -+} -diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h -index 7516b7ecf..6c187b9b6 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gem.h -+++ b/drivers/gpu/drm/panfrost/panfrost_gem.h -@@ -41,6 +41,20 @@ struct panfrost_gem_object { - */ - size_t heap_rss_size; - -+ /** -+ * @label: BO tagging fields. The label can be assigned within the -+ * driver itself or through a specific IOCTL. -+ */ -+ struct { -+ /** -+ * @label.str: Pointer to NULL-terminated string, -+ */ -+ const char *str; -+ -+ /** @lock.str: Protects access to the @label.str field. */ -+ struct mutex lock; -+ } label; -+ - bool noexec :1; - bool is_heap :1; - }; -@@ -89,4 +103,7 @@ void panfrost_gem_teardown_mappings_locked(struct panfrost_gem_object *bo); - int panfrost_gem_shrinker_init(struct drm_device *dev); - void panfrost_gem_shrinker_cleanup(struct drm_device *dev); - -+void panfrost_gem_set_label(struct drm_gem_object *obj, const char *label); -+void panfrost_gem_internal_set_label(struct drm_gem_object *obj, const char *label); -+ - #endif /* __PANFROST_GEM_H__ */ --- -2.50.1 - diff --git a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0008-drm-panfrost-Internally-label-some-BOs.patch b/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0008-drm-panfrost-Internally-label-some-BOs.patch deleted file mode 100644 index 350599f156c..00000000000 --- a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0008-drm-panfrost-Internally-label-some-BOs.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 75692eeac1a4d3549d6ee821cd847a707f4f856d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= -Date: Tue, 20 May 2025 18:43:59 +0100 -Subject: [PATCH 4/7] drm/panfrost: Internally label some BOs -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Perfcnt samples buffer is not exposed to UM, but we would like to keep -a tag on it as a potential debug aid. - -PRIME imported GEM buffers are UM exposed, but since the usual Panfrost -UM driver code path is not followed in their creation, they might remain -unlabelled for their entire lifetime, so a generic tag was deemed -preferable. The tag is assigned before a UM handle is created so it -doesn't contradict the logic about labelling internal BOs. - -Signed-off-by: Adrián Larumbe -Reviewed-by: Boris Brezillon -Reviewed-by: Steven Price -Signed-off-by: Steven Price -Link: https://lore.kernel.org/r/20250520174634.353267-3-adrian.larumbe@collabora.com ---- - drivers/gpu/drm/panfrost/panfrost_gem.c | 10 ++++++++++ - drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 2 ++ - 2 files changed, 12 insertions(+) - -diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c -index a2caa6ad9..32e5c8076 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gem.c -+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c -@@ -305,6 +305,16 @@ panfrost_gem_prime_import_sg_table(struct drm_device *dev, - bo = to_panfrost_bo(obj); - bo->noexec = true; - -+ /* -+ * We assign this generic label because this function cannot -+ * be reached through any of the Panfrost UM driver-specific -+ * code paths, unless one is given by explicitly calling the -+ * SET_LABEL_BO ioctl. It is therefore preferable to have a -+ * blanket BO tag that tells us the object was imported from -+ * another driver than nothing at all. -+ */ -+ panfrost_gem_internal_set_label(obj, "GEM PRIME buffer"); -+ - return obj; - } - -diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c -index ba9b6e2b2..124885503 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c -+++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c -@@ -111,6 +111,8 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev, - goto err_put_mapping; - perfcnt->buf = map.vaddr; - -+ panfrost_gem_internal_set_label(&bo->base, "Perfcnt sample buffer"); -+ - /* - * Invalidate the cache and clear the counters to start from a fresh - * state. --- -2.50.1 - diff --git a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0009-drm-panfrost-Add-driver-IOCTL-for-setting-BO-labels.patch b/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0009-drm-panfrost-Add-driver-IOCTL-for-setting-BO-labels.patch deleted file mode 100644 index 30baf51d0c3..00000000000 --- a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0009-drm-panfrost-Add-driver-IOCTL-for-setting-BO-labels.patch +++ /dev/null @@ -1,159 +0,0 @@ -From 94c4a3ce8f7457242377c4ae3a1881905a802ac8 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= -Date: Tue, 20 May 2025 18:44:00 +0100 -Subject: [PATCH 5/7] drm/panfrost: Add driver IOCTL for setting BO labels -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Allow UM to label a BO for which it possesses a DRM handle. - -Signed-off-by: Adrián Larumbe -Reviewed-by: Steven Price -Reviewed-by: Boris Brezillon -Signed-off-by: Steven Price -Link: https://lore.kernel.org/r/20250520174634.353267-4-adrian.larumbe@collabora.com ---- - drivers/gpu/drm/panfrost/panfrost_drv.c | 44 ++++++++++++++++++++++++- - drivers/gpu/drm/panfrost/panfrost_gem.h | 2 ++ - include/uapi/drm/panfrost_drm.h | 21 ++++++++++++ - 3 files changed, 66 insertions(+), 1 deletion(-) - -diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c -index 04d615df5..8972d5985 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_drv.c -+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c -@@ -495,6 +495,46 @@ static int panfrost_ioctl_madvise(struct drm_device *dev, void *data, - return ret; - } - -+static int panfrost_ioctl_set_label_bo(struct drm_device *ddev, void *data, -+ struct drm_file *file) -+{ -+ struct drm_panfrost_set_label_bo *args = data; -+ struct drm_gem_object *obj; -+ const char *label = NULL; -+ int ret = 0; -+ -+ if (args->pad) -+ return -EINVAL; -+ -+ obj = drm_gem_object_lookup(file, args->handle); -+ if (!obj) -+ return -ENOENT; -+ -+ if (args->label) { -+ label = strndup_user(u64_to_user_ptr(args->label), -+ PANFROST_BO_LABEL_MAXLEN); -+ if (IS_ERR(label)) { -+ ret = PTR_ERR(label); -+ if (ret == -EINVAL) -+ ret = -E2BIG; -+ goto err_put_obj; -+ } -+ } -+ -+ /* -+ * We treat passing a label of length 0 and passing a NULL label -+ * differently, because even though they might seem conceptually -+ * similar, future uses of the BO label might expect a different -+ * behaviour in each case. -+ */ -+ panfrost_gem_set_label(obj, label); -+ -+err_put_obj: -+ drm_gem_object_put(obj); -+ -+ return ret; -+} -+ - int panfrost_unstable_ioctl_check(void) - { - if (!unstable_ioctls) -@@ -561,6 +601,7 @@ static const struct drm_ioctl_desc panfrost_drm_driver_ioctls[] = { - PANFROST_IOCTL(PERFCNT_ENABLE, perfcnt_enable, DRM_RENDER_ALLOW), - PANFROST_IOCTL(PERFCNT_DUMP, perfcnt_dump, DRM_RENDER_ALLOW), - PANFROST_IOCTL(MADVISE, madvise, DRM_RENDER_ALLOW), -+ PANFROST_IOCTL(SET_LABEL_BO, set_label_bo, DRM_RENDER_ALLOW), - }; - - static void panfrost_gpu_show_fdinfo(struct panfrost_device *pfdev, -@@ -625,6 +666,7 @@ static const struct file_operations panfrost_drm_driver_fops = { - * - 1.2 - adds AFBC_FEATURES query - * - 1.3 - adds JD_REQ_CYCLE_COUNT job requirement for SUBMIT - * - adds SYSTEM_TIMESTAMP and SYSTEM_TIMESTAMP_FREQUENCY queries -+ * - 1.4 - adds SET_LABEL_BO - */ - static const struct drm_driver panfrost_drm_driver = { - .driver_features = DRIVER_RENDER | DRIVER_GEM | DRIVER_SYNCOBJ, -@@ -638,7 +680,7 @@ static const struct drm_driver panfrost_drm_driver = { - .desc = "panfrost DRM", - .date = "20180908", - .major = 1, -- .minor = 3, -+ .minor = 4, - - .gem_create_object = panfrost_gem_create_object, - .gem_prime_import_sg_table = panfrost_gem_prime_import_sg_table, -diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h -index 6c187b9b6..3d87c41ad 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gem.h -+++ b/drivers/gpu/drm/panfrost/panfrost_gem.h -@@ -9,6 +9,8 @@ - - struct panfrost_mmu; - -+#define PANFROST_BO_LABEL_MAXLEN 4096 -+ - struct panfrost_gem_object { - struct drm_gem_shmem_object base; - struct sg_table *sgts; -diff --git a/include/uapi/drm/panfrost_drm.h b/include/uapi/drm/panfrost_drm.h -index 568724be6..ed6751039 100644 ---- a/include/uapi/drm/panfrost_drm.h -+++ b/include/uapi/drm/panfrost_drm.h -@@ -21,6 +21,7 @@ extern "C" { - #define DRM_PANFROST_PERFCNT_ENABLE 0x06 - #define DRM_PANFROST_PERFCNT_DUMP 0x07 - #define DRM_PANFROST_MADVISE 0x08 -+#define DRM_PANFROST_SET_LABEL_BO 0x09 - - #define DRM_IOCTL_PANFROST_SUBMIT DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_SUBMIT, struct drm_panfrost_submit) - #define DRM_IOCTL_PANFROST_WAIT_BO DRM_IOW(DRM_COMMAND_BASE + DRM_PANFROST_WAIT_BO, struct drm_panfrost_wait_bo) -@@ -29,6 +30,7 @@ extern "C" { - #define DRM_IOCTL_PANFROST_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_PARAM, struct drm_panfrost_get_param) - #define DRM_IOCTL_PANFROST_GET_BO_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_GET_BO_OFFSET, struct drm_panfrost_get_bo_offset) - #define DRM_IOCTL_PANFROST_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_MADVISE, struct drm_panfrost_madvise) -+#define DRM_IOCTL_PANFROST_SET_LABEL_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_PANFROST_SET_LABEL_BO, struct drm_panfrost_set_label_bo) - - /* - * Unstable ioctl(s): only exposed when the unsafe unstable_ioctls module -@@ -227,6 +229,25 @@ struct drm_panfrost_madvise { - __u32 retained; /* out, whether backing store still exists */ - }; - -+/** -+ * struct drm_panfrost_set_label_bo - ioctl argument for labelling Panfrost BOs. -+ */ -+struct drm_panfrost_set_label_bo { -+ /** @handle: Handle of the buffer object to label. */ -+ __u32 handle; -+ -+ /** @pad: MBZ. */ -+ __u32 pad; -+ -+ /** -+ * @label: User pointer to a NUL-terminated string -+ * -+ * Length cannot be greater than 4096. -+ * NULL is permitted and means clear the label. -+ */ -+ __u64 label; -+}; -+ - /* Definitions for coredump decoding in user space */ - #define PANFROSTDUMP_MAJOR 1 - #define PANFROSTDUMP_MINOR 0 --- -2.50.1 - diff --git a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0010-drm-panfrost-show-device-wide-list-of-DRM-GEM-object.patch b/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0010-drm-panfrost-show-device-wide-list-of-DRM-GEM-object.patch deleted file mode 100644 index 3a98d6386eb..00000000000 --- a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0010-drm-panfrost-show-device-wide-list-of-DRM-GEM-object.patch +++ /dev/null @@ -1,380 +0,0 @@ -From ce7291e87d4534b5231e2e4a6d09a7cb4cf0c0dc Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= -Date: Tue, 20 May 2025 18:44:01 +0100 -Subject: [PATCH 6/7] drm/panfrost: show device-wide list of DRM GEM objects - over DebugFS -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This change is essentially a Panfrost port of commit a3707f53eb3f -("drm/panthor: show device-wide list of DRM GEM objects over DebugFS"). - -The DebugFS file is almost the same as in Panthor, minus the GEM object -usage flags, since Panfrost has no kernel-only BO's. - -Two additional GEM state flags which are displayed but aren't relevant -to Panthor are 'Purged' and 'Purgeable', since Panfrost implements an -explicit shrinker and a madvise ioctl to flag objects as reclaimable. - -Signed-off-by: Adrián Larumbe -Reviewed-by: Boris Brezillon -Reviewed-by: Steven Price -Signed-off-by: Steven Price -Link: https://lore.kernel.org/r/20250520174634.353267-5-adrian.larumbe@collabora.com ---- - drivers/gpu/drm/panfrost/panfrost_device.c | 5 + - drivers/gpu/drm/panfrost/panfrost_device.h | 15 +++ - drivers/gpu/drm/panfrost/panfrost_drv.c | 35 ++++++ - drivers/gpu/drm/panfrost/panfrost_gem.c | 134 +++++++++++++++++++++ - drivers/gpu/drm/panfrost/panfrost_gem.h | 47 ++++++++ - 5 files changed, 236 insertions(+) - -diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c -index a45e4addc..74f9f2a75 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_device.c -+++ b/drivers/gpu/drm/panfrost/panfrost_device.c -@@ -235,6 +235,11 @@ int panfrost_device_init(struct panfrost_device *pfdev) - goto out_regulator; - } - -+#ifdef CONFIG_DEBUG_FS -+ mutex_init(&pfdev->debugfs.gems_lock); -+ INIT_LIST_HEAD(&pfdev->debugfs.gems_list); -+#endif -+ - err = panfrost_pm_domain_init(pfdev); - if (err) - goto out_reset; -diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h -index cffcb0ac7..bd20a5702 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_device.h -+++ b/drivers/gpu/drm/panfrost/panfrost_device.h -@@ -97,6 +97,17 @@ struct panfrost_compatible { - u8 pm_features; - }; - -+/** -+ * struct panfrost_device_debugfs - Device-wide DebugFS tracking structures -+ */ -+struct panfrost_device_debugfs { -+ /** @gems_list: Device-wide list of GEM objects owned by at least one file. */ -+ struct list_head gems_list; -+ -+ /** @gems_lock: Serializes access to the device-wide list of GEM objects. */ -+ struct mutex gems_lock; -+}; -+ - struct panfrost_device { - struct device *dev; - struct drm_device *ddev; -@@ -150,6 +161,10 @@ struct panfrost_device { - atomic_t use_count; - spinlock_t lock; - } cycle_counter; -+ -+#ifdef CONFIG_DEBUG_FS -+ struct panfrost_device_debugfs debugfs; -+#endif - }; - - struct panfrost_mmu { -diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c -index 8972d5985..594293914 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_drv.c -+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c -@@ -13,6 +13,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -659,6 +660,37 @@ static const struct file_operations panfrost_drm_driver_fops = { - .show_fdinfo = drm_show_fdinfo, - }; - -+#ifdef CONFIG_DEBUG_FS -+static int panthor_gems_show(struct seq_file *m, void *data) -+{ -+ struct drm_info_node *node = m->private; -+ struct drm_device *dev = node->minor->dev; -+ struct panfrost_device *pfdev = dev->dev_private; -+ -+ panfrost_gem_debugfs_print_bos(pfdev, m); -+ -+ return 0; -+} -+ -+static struct drm_info_list panthor_debugfs_list[] = { -+ {"gems", panthor_gems_show, 0, NULL}, -+}; -+ -+static int panthor_gems_debugfs_init(struct drm_minor *minor) -+{ -+ drm_debugfs_create_files(panthor_debugfs_list, -+ ARRAY_SIZE(panthor_debugfs_list), -+ minor->debugfs_root, minor); -+ -+ return 0; -+} -+ -+static void panfrost_debugfs_init(struct drm_minor *minor) -+{ -+ panthor_gems_debugfs_init(minor); -+} -+#endif -+ - /* - * Panfrost driver version: - * - 1.0 - initial interface -@@ -684,6 +716,9 @@ static const struct drm_driver panfrost_drm_driver = { - - .gem_create_object = panfrost_gem_create_object, - .gem_prime_import_sg_table = panfrost_gem_prime_import_sg_table, -+#ifdef CONFIG_DEBUG_FS -+ .debugfs_init = panfrost_debugfs_init, -+#endif - }; - - static int panfrost_probe(struct platform_device *pdev) -diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c -index 32e5c8076..fc26eae6f 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gem.c -+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c -@@ -12,6 +12,36 @@ - #include "panfrost_gem.h" - #include "panfrost_mmu.h" - -+#ifdef CONFIG_DEBUG_FS -+static void panfrost_gem_debugfs_bo_add(struct panfrost_device *pfdev, -+ struct panfrost_gem_object *bo) -+{ -+ bo->debugfs.creator.tgid = current->group_leader->pid; -+ get_task_comm(bo->debugfs.creator.process_name, current->group_leader); -+ -+ mutex_lock(&pfdev->debugfs.gems_lock); -+ list_add_tail(&bo->debugfs.node, &pfdev->debugfs.gems_list); -+ mutex_unlock(&pfdev->debugfs.gems_lock); -+} -+ -+static void panfrost_gem_debugfs_bo_rm(struct panfrost_gem_object *bo) -+{ -+ struct panfrost_device *pfdev = bo->base.base.dev->dev_private; -+ -+ if (list_empty(&bo->debugfs.node)) -+ return; -+ -+ mutex_lock(&pfdev->debugfs.gems_lock); -+ list_del_init(&bo->debugfs.node); -+ mutex_unlock(&pfdev->debugfs.gems_lock); -+} -+#else -+static void panfrost_gem_debugfs_bo_add(struct panfrost_device *pfdev, -+ struct panfrost_gem_object *bo) -+{} -+static void panfrost_gem_debugfs_bo_rm(struct panfrost_gem_object *bo) {} -+#endif -+ - /* Called DRM core on the last userspace/kernel unreference of the - * BO. - */ -@@ -37,6 +67,7 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj) - WARN_ON_ONCE(!list_empty(&bo->mappings.list)); - - kfree_const(bo->label.str); -+ panfrost_gem_debugfs_bo_rm(bo); - mutex_destroy(&bo->label.lock); - - if (bo->sgts) { -@@ -266,6 +297,8 @@ struct drm_gem_object *panfrost_gem_create_object(struct drm_device *dev, size_t - obj->base.map_wc = !pfdev->coherent; - mutex_init(&obj->label.lock); - -+ panfrost_gem_debugfs_bo_add(pfdev, obj); -+ - return &obj->base.base; - } - -@@ -354,3 +387,104 @@ panfrost_gem_internal_set_label(struct drm_gem_object *obj, const char *label) - - panfrost_gem_set_label(obj, str); - } -+ -+#ifdef CONFIG_DEBUG_FS -+struct gem_size_totals { -+ size_t size; -+ size_t resident; -+ size_t reclaimable; -+}; -+ -+struct flag_def { -+ u32 flag; -+ const char *name; -+}; -+ -+static void panfrost_gem_debugfs_print_flag_names(struct seq_file *m) -+{ -+ int len; -+ int i; -+ -+ static const struct flag_def gem_state_flags_names[] = { -+ {PANFROST_DEBUGFS_GEM_STATE_FLAG_IMPORTED, "imported"}, -+ {PANFROST_DEBUGFS_GEM_STATE_FLAG_EXPORTED, "exported"}, -+ {PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGED, "purged"}, -+ {PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGEABLE, "purgeable"}, -+ }; -+ -+ seq_puts(m, "GEM state flags: "); -+ for (i = 0, len = ARRAY_SIZE(gem_state_flags_names); i < len; i++) { -+ seq_printf(m, "%s (0x%x)%s", gem_state_flags_names[i].name, -+ gem_state_flags_names[i].flag, (i < len - 1) ? ", " : "\n\n"); -+ } -+} -+ -+static void panfrost_gem_debugfs_bo_print(struct panfrost_gem_object *bo, -+ struct seq_file *m, -+ struct gem_size_totals *totals) -+{ -+ unsigned int refcount = kref_read(&bo->base.base.refcount); -+ char creator_info[32] = {}; -+ size_t resident_size; -+ u32 gem_state_flags = 0; -+ -+ /* Skip BOs being destroyed. */ -+ if (!refcount) -+ return; -+ -+ resident_size = bo->base.pages ? bo->base.base.size : 0; -+ -+ snprintf(creator_info, sizeof(creator_info), -+ "%s/%d", bo->debugfs.creator.process_name, bo->debugfs.creator.tgid); -+ seq_printf(m, "%-32s%-16d%-16d%-16zd%-16zd0x%-16lx", -+ creator_info, -+ bo->base.base.name, -+ refcount, -+ bo->base.base.size, -+ resident_size, -+ drm_vma_node_start(&bo->base.base.vma_node)); -+ -+ if (bo->base.base.import_attach) -+ gem_state_flags |= PANFROST_DEBUGFS_GEM_STATE_FLAG_IMPORTED; -+ if (bo->base.base.dma_buf) -+ gem_state_flags |= PANFROST_DEBUGFS_GEM_STATE_FLAG_EXPORTED; -+ -+ if (bo->base.madv < 0) -+ gem_state_flags |= PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGED; -+ else if (bo->base.madv > 0) -+ gem_state_flags |= PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGEABLE; -+ -+ seq_printf(m, "0x%-10x", gem_state_flags); -+ -+ scoped_guard(mutex, &bo->label.lock) { -+ seq_printf(m, "%s\n", bo->label.str ? : ""); -+ } -+ -+ totals->size += bo->base.base.size; -+ totals->resident += resident_size; -+ if (bo->base.madv > 0) -+ totals->reclaimable += resident_size; -+} -+ -+void panfrost_gem_debugfs_print_bos(struct panfrost_device *pfdev, -+ struct seq_file *m) -+{ -+ struct gem_size_totals totals = {0}; -+ struct panfrost_gem_object *bo; -+ -+ panfrost_gem_debugfs_print_flag_names(m); -+ -+ seq_puts(m, "created-by global-name refcount size resident-size file-offset state label\n"); -+ seq_puts(m, "-----------------------------------------------------------------------------------------------------------------------------------\n"); -+ -+ scoped_guard(mutex, &pfdev->debugfs.gems_lock) { -+ list_for_each_entry(bo, &pfdev->debugfs.gems_list, debugfs.node) { -+ panfrost_gem_debugfs_bo_print(bo, m, &totals); -+ } -+ } -+ -+ seq_puts(m, "===================================================================================================================================\n"); -+ seq_printf(m, "Total size: %zd, Total resident: %zd, Total reclaimable: %zd\n", -+ totals.size, totals.resident, totals.reclaimable); -+} -+#endif -diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.h b/drivers/gpu/drm/panfrost/panfrost_gem.h -index 3d87c41ad..8de3e76f2 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gem.h -+++ b/drivers/gpu/drm/panfrost/panfrost_gem.h -@@ -8,9 +8,47 @@ - #include - - struct panfrost_mmu; -+struct panfrost_device; - - #define PANFROST_BO_LABEL_MAXLEN 4096 - -+enum panfrost_debugfs_gem_state_flags { -+ /** @PANFROST_DEBUGFS_GEM_STATE_FLAG_IMPORTED: GEM BO is PRIME imported. */ -+ PANFROST_DEBUGFS_GEM_STATE_FLAG_IMPORTED = BIT(0), -+ -+ /** @PANFROST_DEBUGFS_GEM_STATE_FLAG_EXPORTED: GEM BO is PRIME exported. */ -+ PANFROST_DEBUGFS_GEM_STATE_FLAG_EXPORTED = BIT(1), -+ -+ /** @PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGED: GEM BO was reclaimed by the shrinker. */ -+ PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGED = BIT(2), -+ -+ /** -+ * @PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGEABLE: GEM BO pages were marked as no longer -+ * needed by UM and can be reclaimed by the shrinker. -+ */ -+ PANFROST_DEBUGFS_GEM_STATE_FLAG_PURGEABLE = BIT(3), -+}; -+ -+/** -+ * struct panfrost_gem_debugfs - GEM object's DebugFS list information -+ */ -+struct panfrost_gem_debugfs { -+ /** -+ * @node: Node used to insert the object in the device-wide list of -+ * GEM objects, to display information about it through a DebugFS file. -+ */ -+ struct list_head node; -+ -+ /** @creator: Information about the UM process which created the GEM. */ -+ struct { -+ /** @creator.process_name: Group leader name in owning thread's process */ -+ char process_name[TASK_COMM_LEN]; -+ -+ /** @creator.tgid: PID of the thread's group leader within its process */ -+ pid_t tgid; -+ } creator; -+}; -+ - struct panfrost_gem_object { - struct drm_gem_shmem_object base; - struct sg_table *sgts; -@@ -59,6 +97,10 @@ struct panfrost_gem_object { - - bool noexec :1; - bool is_heap :1; -+ -+#ifdef CONFIG_DEBUG_FS -+ struct panfrost_gem_debugfs debugfs; -+#endif - }; - - struct panfrost_gem_mapping { -@@ -108,4 +150,9 @@ void panfrost_gem_shrinker_cleanup(struct drm_device *dev); - void panfrost_gem_set_label(struct drm_gem_object *obj, const char *label); - void panfrost_gem_internal_set_label(struct drm_gem_object *obj, const char *label); - -+#ifdef CONFIG_DEBUG_FS -+void panfrost_gem_debugfs_print_bos(struct panfrost_device *pfdev, -+ struct seq_file *m); -+#endif -+ - #endif /* __PANFROST_GEM_H__ */ --- -2.50.1 - diff --git a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0012-panfrost-fix-tiler-heap-reporting.patch b/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0012-panfrost-fix-tiler-heap-reporting.patch deleted file mode 100644 index 2c39ad9244d..00000000000 --- a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0012-panfrost-fix-tiler-heap-reporting.patch +++ /dev/null @@ -1,23 +0,0 @@ -Otherwise it would display the virtual allocation size, which is often -much bigger than the RSS. - -Signed-off-by: Adrián Larumbe -Fixes: e48ade5e23ba ("drm/panfrost: show device-wide list of DRM GEM objects over DebugFS") ---- - drivers/gpu/drm/panfrost/panfrost_gem.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c -index fc26eae..a61b542 100644 ---- a/drivers/gpu/drm/panfrost/panfrost_gem.c -+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c -@@ -432,7 +432,8 @@ static void panfrost_gem_debugfs_bo_print(struct panfrost_gem_object *bo, - if (!refcount) - return; - -- resident_size = bo->base.pages ? bo->base.base.size : 0; -+ resident_size = bo->base.pages ? -+ (bo->is_heap ? bo->heap_rss_size : bo->base.base.size) : 0; - - snprintf(creator_info, sizeof(creator_info), - "%s/%d", bo->debugfs.creator.process_name, bo->debugfs.creator.tgid); diff --git a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0013-ntsync.patch b/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0013-ntsync.patch deleted file mode 100644 index 80db4438015..00000000000 --- a/projects/ROCKNIX/packages/linux/patches/6.12-LTS/0013-ntsync.patch +++ /dev/null @@ -1,3038 +0,0 @@ -From 2ac5ccc07581a184e2bfdd6e5a6c875aae9ee0e1 Mon Sep 17 00:00:00 2001 -From: Peter Jung -Date: Tue, 26 Aug 2025 15:42:14 +0200 -Subject: [PATCH 5/7] ntsync - -Signed-off-by: Peter Jung ---- - Documentation/userspace-api/index.rst | 1 + - Documentation/userspace-api/ntsync.rst | 385 +++++ - MAINTAINERS | 9 + - drivers/misc/Kconfig | 1 - - drivers/misc/ntsync.c | 993 +++++++++++- - include/uapi/linux/ntsync.h | 42 +- - tools/testing/selftests/Makefile | 1 + - .../selftests/drivers/ntsync/.gitignore | 1 + - .../testing/selftests/drivers/ntsync/Makefile | 7 + - tools/testing/selftests/drivers/ntsync/config | 1 + - .../testing/selftests/drivers/ntsync/ntsync.c | 1343 +++++++++++++++++ - 11 files changed, 2768 insertions(+), 16 deletions(-) - create mode 100644 Documentation/userspace-api/ntsync.rst - create mode 100644 tools/testing/selftests/drivers/ntsync/.gitignore - create mode 100644 tools/testing/selftests/drivers/ntsync/Makefile - create mode 100644 tools/testing/selftests/drivers/ntsync/config - create mode 100644 tools/testing/selftests/drivers/ntsync/ntsync.c - -diff --git a/Documentation/userspace-api/index.rst b/Documentation/userspace-api/index.rst -index 274cc7546efc..9c1b15cd89ab 100644 ---- a/Documentation/userspace-api/index.rst -+++ b/Documentation/userspace-api/index.rst -@@ -63,6 +63,7 @@ Everything else - vduse - futex2 - perf_ring_buffer -+ ntsync - - .. only:: subproject and html - -diff --git a/Documentation/userspace-api/ntsync.rst b/Documentation/userspace-api/ntsync.rst -new file mode 100644 -index 000000000000..25e7c4aef968 ---- /dev/null -+++ b/Documentation/userspace-api/ntsync.rst -@@ -0,0 +1,385 @@ -+=================================== -+NT synchronization primitive driver -+=================================== -+ -+This page documents the user-space API for the ntsync driver. -+ -+ntsync is a support driver for emulation of NT synchronization -+primitives by user-space NT emulators. It exists because implementation -+in user-space, using existing tools, cannot match Windows performance -+while offering accurate semantics. It is implemented entirely in -+software, and does not drive any hardware device. -+ -+This interface is meant as a compatibility tool only, and should not -+be used for general synchronization. Instead use generic, versatile -+interfaces such as futex(2) and poll(2). -+ -+Synchronization primitives -+========================== -+ -+The ntsync driver exposes three types of synchronization primitives: -+semaphores, mutexes, and events. -+ -+A semaphore holds a single volatile 32-bit counter, and a static 32-bit -+integer denoting the maximum value. It is considered signaled (that is, -+can be acquired without contention, or will wake up a waiting thread) -+when the counter is nonzero. The counter is decremented by one when a -+wait is satisfied. Both the initial and maximum count are established -+when the semaphore is created. -+ -+A mutex holds a volatile 32-bit recursion count, and a volatile 32-bit -+identifier denoting its owner. A mutex is considered signaled when its -+owner is zero (indicating that it is not owned). The recursion count is -+incremented when a wait is satisfied, and ownership is set to the given -+identifier. -+ -+A mutex also holds an internal flag denoting whether its previous owner -+has died; such a mutex is said to be abandoned. Owner death is not -+tracked automatically based on thread death, but rather must be -+communicated using ``NTSYNC_IOC_MUTEX_KILL``. An abandoned mutex is -+inherently considered unowned. -+ -+Except for the "unowned" semantics of zero, the actual value of the -+owner identifier is not interpreted by the ntsync driver at all. The -+intended use is to store a thread identifier; however, the ntsync -+driver does not actually validate that a calling thread provides -+consistent or unique identifiers. -+ -+An event is similar to a semaphore with a maximum count of one. It holds -+a volatile boolean state denoting whether it is signaled or not. There -+are two types of events, auto-reset and manual-reset. An auto-reset -+event is designaled when a wait is satisfied; a manual-reset event is -+not. The event type is specified when the event is created. -+ -+Unless specified otherwise, all operations on an object are atomic and -+totally ordered with respect to other operations on the same object. -+ -+Objects are represented by files. When all file descriptors to an -+object are closed, that object is deleted. -+ -+Char device -+=========== -+ -+The ntsync driver creates a single char device /dev/ntsync. Each file -+description opened on the device represents a unique instance intended -+to back an individual NT virtual machine. Objects created by one ntsync -+instance may only be used with other objects created by the same -+instance. -+ -+ioctl reference -+=============== -+ -+All operations on the device are done through ioctls. There are four -+structures used in ioctl calls:: -+ -+ struct ntsync_sem_args { -+ __u32 count; -+ __u32 max; -+ }; -+ -+ struct ntsync_mutex_args { -+ __u32 owner; -+ __u32 count; -+ }; -+ -+ struct ntsync_event_args { -+ __u32 signaled; -+ __u32 manual; -+ }; -+ -+ struct ntsync_wait_args { -+ __u64 timeout; -+ __u64 objs; -+ __u32 count; -+ __u32 owner; -+ __u32 index; -+ __u32 alert; -+ __u32 flags; -+ __u32 pad; -+ }; -+ -+Depending on the ioctl, members of the structure may be used as input, -+output, or not at all. -+ -+The ioctls on the device file are as follows: -+ -+.. c:macro:: NTSYNC_IOC_CREATE_SEM -+ -+ Create a semaphore object. Takes a pointer to struct -+ :c:type:`ntsync_sem_args`, which is used as follows: -+ -+ .. list-table:: -+ -+ * - ``count`` -+ - Initial count of the semaphore. -+ * - ``max`` -+ - Maximum count of the semaphore. -+ -+ Fails with ``EINVAL`` if ``count`` is greater than ``max``. -+ On success, returns a file descriptor the created semaphore. -+ -+.. c:macro:: NTSYNC_IOC_CREATE_MUTEX -+ -+ Create a mutex object. Takes a pointer to struct -+ :c:type:`ntsync_mutex_args`, which is used as follows: -+ -+ .. list-table:: -+ -+ * - ``count`` -+ - Initial recursion count of the mutex. -+ * - ``owner`` -+ - Initial owner of the mutex. -+ -+ If ``owner`` is nonzero and ``count`` is zero, or if ``owner`` is -+ zero and ``count`` is nonzero, the function fails with ``EINVAL``. -+ On success, returns a file descriptor the created mutex. -+ -+.. c:macro:: NTSYNC_IOC_CREATE_EVENT -+ -+ Create an event object. Takes a pointer to struct -+ :c:type:`ntsync_event_args`, which is used as follows: -+ -+ .. list-table:: -+ -+ * - ``signaled`` -+ - If nonzero, the event is initially signaled, otherwise -+ nonsignaled. -+ * - ``manual`` -+ - If nonzero, the event is a manual-reset event, otherwise -+ auto-reset. -+ -+ On success, returns a file descriptor the created event. -+ -+The ioctls on the individual objects are as follows: -+ -+.. c:macro:: NTSYNC_IOC_SEM_POST -+ -+ Post to a semaphore object. Takes a pointer to a 32-bit integer, -+ which on input holds the count to be added to the semaphore, and on -+ output contains its previous count. -+ -+ If adding to the semaphore's current count would raise the latter -+ past the semaphore's maximum count, the ioctl fails with -+ ``EOVERFLOW`` and the semaphore is not affected. If raising the -+ semaphore's count causes it to become signaled, eligible threads -+ waiting on this semaphore will be woken and the semaphore's count -+ decremented appropriately. -+ -+.. c:macro:: NTSYNC_IOC_MUTEX_UNLOCK -+ -+ Release a mutex object. Takes a pointer to struct -+ :c:type:`ntsync_mutex_args`, which is used as follows: -+ -+ .. list-table:: -+ -+ * - ``owner`` -+ - Specifies the owner trying to release this mutex. -+ * - ``count`` -+ - On output, contains the previous recursion count. -+ -+ If ``owner`` is zero, the ioctl fails with ``EINVAL``. If ``owner`` -+ is not the current owner of the mutex, the ioctl fails with -+ ``EPERM``. -+ -+ The mutex's count will be decremented by one. If decrementing the -+ mutex's count causes it to become zero, the mutex is marked as -+ unowned and signaled, and eligible threads waiting on it will be -+ woken as appropriate. -+ -+.. c:macro:: NTSYNC_IOC_SET_EVENT -+ -+ Signal an event object. Takes a pointer to a 32-bit integer, which on -+ output contains the previous state of the event. -+ -+ Eligible threads will be woken, and auto-reset events will be -+ designaled appropriately. -+ -+.. c:macro:: NTSYNC_IOC_RESET_EVENT -+ -+ Designal an event object. Takes a pointer to a 32-bit integer, which -+ on output contains the previous state of the event. -+ -+.. c:macro:: NTSYNC_IOC_PULSE_EVENT -+ -+ Wake threads waiting on an event object while leaving it in an -+ unsignaled state. Takes a pointer to a 32-bit integer, which on -+ output contains the previous state of the event. -+ -+ A pulse operation can be thought of as a set followed by a reset, -+ performed as a single atomic operation. If two threads are waiting on -+ an auto-reset event which is pulsed, only one will be woken. If two -+ threads are waiting a manual-reset event which is pulsed, both will -+ be woken. However, in both cases, the event will be unsignaled -+ afterwards, and a simultaneous read operation will always report the -+ event as unsignaled. -+ -+.. c:macro:: NTSYNC_IOC_READ_SEM -+ -+ Read the current state of a semaphore object. Takes a pointer to -+ struct :c:type:`ntsync_sem_args`, which is used as follows: -+ -+ .. list-table:: -+ -+ * - ``count`` -+ - On output, contains the current count of the semaphore. -+ * - ``max`` -+ - On output, contains the maximum count of the semaphore. -+ -+.. c:macro:: NTSYNC_IOC_READ_MUTEX -+ -+ Read the current state of a mutex object. Takes a pointer to struct -+ :c:type:`ntsync_mutex_args`, which is used as follows: -+ -+ .. list-table:: -+ -+ * - ``owner`` -+ - On output, contains the current owner of the mutex, or zero -+ if the mutex is not currently owned. -+ * - ``count`` -+ - On output, contains the current recursion count of the mutex. -+ -+ If the mutex is marked as abandoned, the function fails with -+ ``EOWNERDEAD``. In this case, ``count`` and ``owner`` are set to -+ zero. -+ -+.. c:macro:: NTSYNC_IOC_READ_EVENT -+ -+ Read the current state of an event object. Takes a pointer to struct -+ :c:type:`ntsync_event_args`, which is used as follows: -+ -+ .. list-table:: -+ -+ * - ``signaled`` -+ - On output, contains the current state of the event. -+ * - ``manual`` -+ - On output, contains 1 if the event is a manual-reset event, -+ and 0 otherwise. -+ -+.. c:macro:: NTSYNC_IOC_KILL_OWNER -+ -+ Mark a mutex as unowned and abandoned if it is owned by the given -+ owner. Takes an input-only pointer to a 32-bit integer denoting the -+ owner. If the owner is zero, the ioctl fails with ``EINVAL``. If the -+ owner does not own the mutex, the function fails with ``EPERM``. -+ -+ Eligible threads waiting on the mutex will be woken as appropriate -+ (and such waits will fail with ``EOWNERDEAD``, as described below). -+ -+.. c:macro:: NTSYNC_IOC_WAIT_ANY -+ -+ Poll on any of a list of objects, atomically acquiring at most one. -+ Takes a pointer to struct :c:type:`ntsync_wait_args`, which is -+ used as follows: -+ -+ .. list-table:: -+ -+ * - ``timeout`` -+ - Absolute timeout in nanoseconds. If ``NTSYNC_WAIT_REALTIME`` -+ is set, the timeout is measured against the REALTIME clock; -+ otherwise it is measured against the MONOTONIC clock. If the -+ timeout is equal to or earlier than the current time, the -+ function returns immediately without sleeping. If ``timeout`` -+ is U64_MAX, the function will sleep until an object is -+ signaled, and will not fail with ``ETIMEDOUT``. -+ * - ``objs`` -+ - Pointer to an array of ``count`` file descriptors -+ (specified as an integer so that the structure has the same -+ size regardless of architecture). If any object is -+ invalid, the function fails with ``EINVAL``. -+ * - ``count`` -+ - Number of objects specified in the ``objs`` array. -+ If greater than ``NTSYNC_MAX_WAIT_COUNT``, the function fails -+ with ``EINVAL``. -+ * - ``owner`` -+ - Mutex owner identifier. If any object in ``objs`` is a mutex, -+ the ioctl will attempt to acquire that mutex on behalf of -+ ``owner``. If ``owner`` is zero, the ioctl fails with -+ ``EINVAL``. -+ * - ``index`` -+ - On success, contains the index (into ``objs``) of the object -+ which was signaled. If ``alert`` was signaled instead, -+ this contains ``count``. -+ * - ``alert`` -+ - Optional event object file descriptor. If nonzero, this -+ specifies an "alert" event object which, if signaled, will -+ terminate the wait. If nonzero, the identifier must point to a -+ valid event. -+ * - ``flags`` -+ - Zero or more flags. Currently the only flag is -+ ``NTSYNC_WAIT_REALTIME``, which causes the timeout to be -+ measured against the REALTIME clock instead of MONOTONIC. -+ * - ``pad`` -+ - Unused, must be set to zero. -+ -+ This function attempts to acquire one of the given objects. If unable -+ to do so, it sleeps until an object becomes signaled, subsequently -+ acquiring it, or the timeout expires. In the latter case the ioctl -+ fails with ``ETIMEDOUT``. The function only acquires one object, even -+ if multiple objects are signaled. -+ -+ A semaphore is considered to be signaled if its count is nonzero, and -+ is acquired by decrementing its count by one. A mutex is considered -+ to be signaled if it is unowned or if its owner matches the ``owner`` -+ argument, and is acquired by incrementing its recursion count by one -+ and setting its owner to the ``owner`` argument. An auto-reset event -+ is acquired by designaling it; a manual-reset event is not affected -+ by acquisition. -+ -+ Acquisition is atomic and totally ordered with respect to other -+ operations on the same object. If two wait operations (with different -+ ``owner`` identifiers) are queued on the same mutex, only one is -+ signaled. If two wait operations are queued on the same semaphore, -+ and a value of one is posted to it, only one is signaled. -+ -+ If an abandoned mutex is acquired, the ioctl fails with -+ ``EOWNERDEAD``. Although this is a failure return, the function may -+ otherwise be considered successful. The mutex is marked as owned by -+ the given owner (with a recursion count of 1) and as no longer -+ abandoned, and ``index`` is still set to the index of the mutex. -+ -+ The ``alert`` argument is an "extra" event which can terminate the -+ wait, independently of all other objects. -+ -+ It is valid to pass the same object more than once, including by -+ passing the same event in the ``objs`` array and in ``alert``. If a -+ wakeup occurs due to that object being signaled, ``index`` is set to -+ the lowest index corresponding to that object. -+ -+ The function may fail with ``EINTR`` if a signal is received. -+ -+.. c:macro:: NTSYNC_IOC_WAIT_ALL -+ -+ Poll on a list of objects, atomically acquiring all of them. Takes a -+ pointer to struct :c:type:`ntsync_wait_args`, which is used -+ identically to ``NTSYNC_IOC_WAIT_ANY``, except that ``index`` is -+ always filled with zero on success if not woken via alert. -+ -+ This function attempts to simultaneously acquire all of the given -+ objects. If unable to do so, it sleeps until all objects become -+ simultaneously signaled, subsequently acquiring them, or the timeout -+ expires. In the latter case the ioctl fails with ``ETIMEDOUT`` and no -+ objects are modified. -+ -+ Objects may become signaled and subsequently designaled (through -+ acquisition by other threads) while this thread is sleeping. Only -+ once all objects are simultaneously signaled does the ioctl acquire -+ them and return. The entire acquisition is atomic and totally ordered -+ with respect to other operations on any of the given objects. -+ -+ If an abandoned mutex is acquired, the ioctl fails with -+ ``EOWNERDEAD``. Similarly to ``NTSYNC_IOC_WAIT_ANY``, all objects are -+ nevertheless marked as acquired. Note that if multiple mutex objects -+ are specified, there is no way to know which were marked as -+ abandoned. -+ -+ As with "any" waits, the ``alert`` argument is an "extra" event which -+ can terminate the wait. Critically, however, an "all" wait will -+ succeed if all members in ``objs`` are signaled, *or* if ``alert`` is -+ signaled. In the latter case ``index`` will be set to ``count``. As -+ with "any" waits, if both conditions are filled, the former takes -+ priority, and objects in ``objs`` will be acquired. -+ -+ Unlike ``NTSYNC_IOC_WAIT_ANY``, it is not valid to pass the same -+ object more than once, nor is it valid to pass the same object in -+ ``objs`` and in ``alert``. If this is attempted, the function fails -+ with ``EINVAL``. -diff --git a/MAINTAINERS b/MAINTAINERS -index 879f598ca34e..2c2d1066c035 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -16494,6 +16494,15 @@ T: git https://github.com/Paragon-Software-Group/linux-ntfs3.git - F: Documentation/filesystems/ntfs3.rst - F: fs/ntfs3/ - -+NTSYNC SYNCHRONIZATION PRIMITIVE DRIVER -+M: Elizabeth Figura -+L: wine-devel@winehq.org -+S: Supported -+F: Documentation/userspace-api/ntsync.rst -+F: drivers/misc/ntsync.c -+F: include/uapi/linux/ntsync.h -+F: tools/testing/selftests/drivers/ntsync/ -+ - NUBUS SUBSYSTEM - M: Finn Thain - L: linux-m68k@lists.linux-m68k.org -diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig -index 3fe7e2a9bd29..6c8b999a5e08 100644 ---- a/drivers/misc/Kconfig -+++ b/drivers/misc/Kconfig -@@ -517,7 +517,6 @@ config OPEN_DICE - - config NTSYNC - tristate "NT synchronization primitive emulation" -- depends on BROKEN - help - This module provides kernel support for emulation of Windows NT - synchronization primitives. It is not a hardware driver. -diff --git a/drivers/misc/ntsync.c b/drivers/misc/ntsync.c -index 4954553b7baa..94b94c4cc579 100644 ---- a/drivers/misc/ntsync.c -+++ b/drivers/misc/ntsync.c -@@ -6,11 +6,17 @@ - */ - - #include -+#include - #include - #include -+#include -+#include - #include - #include -+#include - #include -+#include -+#include - #include - #include - #include -@@ -19,6 +25,8 @@ - - enum ntsync_type { - NTSYNC_TYPE_SEM, -+ NTSYNC_TYPE_MUTEX, -+ NTSYNC_TYPE_EVENT, - }; - - /* -@@ -30,10 +38,13 @@ enum ntsync_type { - * - * Both rely on struct file for reference counting. Individual - * ntsync_obj objects take a reference to the device when created. -+ * Wait operations take a reference to each object being waited on for -+ * the duration of the wait. - */ - - struct ntsync_obj { - spinlock_t lock; -+ int dev_locked; - - enum ntsync_type type; - -@@ -46,22 +57,344 @@ struct ntsync_obj { - __u32 count; - __u32 max; - } sem; -+ struct { -+ __u32 count; -+ pid_t owner; -+ bool ownerdead; -+ } mutex; -+ struct { -+ bool manual; -+ bool signaled; -+ } event; - } u; -+ -+ /* -+ * any_waiters is protected by the object lock, but all_waiters is -+ * protected by the device wait_all_lock. -+ */ -+ struct list_head any_waiters; -+ struct list_head all_waiters; -+ -+ /* -+ * Hint describing how many tasks are queued on this object in a -+ * wait-all operation. -+ * -+ * Any time we do a wake, we may need to wake "all" waiters as well as -+ * "any" waiters. In order to atomically wake "all" waiters, we must -+ * lock all of the objects, and that means grabbing the wait_all_lock -+ * below (and, due to lock ordering rules, before locking this object). -+ * However, wait-all is a rare operation, and grabbing the wait-all -+ * lock for every wake would create unnecessary contention. -+ * Therefore we first check whether all_hint is zero, and, if it is, -+ * we skip trying to wake "all" waiters. -+ * -+ * Since wait requests must originate from user-space threads, we're -+ * limited here by PID_MAX_LIMIT, so there's no risk of overflow. -+ */ -+ atomic_t all_hint; -+}; -+ -+struct ntsync_q_entry { -+ struct list_head node; -+ struct ntsync_q *q; -+ struct ntsync_obj *obj; -+ __u32 index; -+}; -+ -+struct ntsync_q { -+ struct task_struct *task; -+ __u32 owner; -+ -+ /* -+ * Protected via atomic_try_cmpxchg(). Only the thread that wins the -+ * compare-and-swap may actually change object states and wake this -+ * task. -+ */ -+ atomic_t signaled; -+ -+ bool all; -+ bool ownerdead; -+ __u32 count; -+ struct ntsync_q_entry entries[]; - }; - - struct ntsync_device { -+ /* -+ * Wait-all operations must atomically grab all objects, and be totally -+ * ordered with respect to each other and wait-any operations. -+ * If one thread is trying to acquire several objects, another thread -+ * cannot touch the object at the same time. -+ * -+ * This device-wide lock is used to serialize wait-for-all -+ * operations, and operations on an object that is involved in a -+ * wait-for-all. -+ */ -+ struct mutex wait_all_lock; -+ - struct file *file; - }; - -+/* -+ * Single objects are locked using obj->lock. -+ * -+ * Multiple objects are 'locked' while holding dev->wait_all_lock. -+ * In this case however, individual objects are not locked by holding -+ * obj->lock, but by setting obj->dev_locked. -+ * -+ * This means that in order to lock a single object, the sequence is slightly -+ * more complicated than usual. Specifically it needs to check obj->dev_locked -+ * after acquiring obj->lock, if set, it needs to drop the lock and acquire -+ * dev->wait_all_lock in order to serialize against the multi-object operation. -+ */ -+ -+static void dev_lock_obj(struct ntsync_device *dev, struct ntsync_obj *obj) -+{ -+ lockdep_assert_held(&dev->wait_all_lock); -+ lockdep_assert(obj->dev == dev); -+ spin_lock(&obj->lock); -+ /* -+ * By setting obj->dev_locked inside obj->lock, it is ensured that -+ * anyone holding obj->lock must see the value. -+ */ -+ obj->dev_locked = 1; -+ spin_unlock(&obj->lock); -+} -+ -+static void dev_unlock_obj(struct ntsync_device *dev, struct ntsync_obj *obj) -+{ -+ lockdep_assert_held(&dev->wait_all_lock); -+ lockdep_assert(obj->dev == dev); -+ spin_lock(&obj->lock); -+ obj->dev_locked = 0; -+ spin_unlock(&obj->lock); -+} -+ -+static void obj_lock(struct ntsync_obj *obj) -+{ -+ struct ntsync_device *dev = obj->dev; -+ -+ for (;;) { -+ spin_lock(&obj->lock); -+ if (likely(!obj->dev_locked)) -+ break; -+ -+ spin_unlock(&obj->lock); -+ mutex_lock(&dev->wait_all_lock); -+ spin_lock(&obj->lock); -+ /* -+ * obj->dev_locked should be set and released under the same -+ * wait_all_lock section, since we now own this lock, it should -+ * be clear. -+ */ -+ lockdep_assert(!obj->dev_locked); -+ spin_unlock(&obj->lock); -+ mutex_unlock(&dev->wait_all_lock); -+ } -+} -+ -+static void obj_unlock(struct ntsync_obj *obj) -+{ -+ spin_unlock(&obj->lock); -+} -+ -+static bool ntsync_lock_obj(struct ntsync_device *dev, struct ntsync_obj *obj) -+{ -+ bool all; -+ -+ obj_lock(obj); -+ all = atomic_read(&obj->all_hint); -+ if (unlikely(all)) { -+ obj_unlock(obj); -+ mutex_lock(&dev->wait_all_lock); -+ dev_lock_obj(dev, obj); -+ } -+ -+ return all; -+} -+ -+static void ntsync_unlock_obj(struct ntsync_device *dev, struct ntsync_obj *obj, bool all) -+{ -+ if (all) { -+ dev_unlock_obj(dev, obj); -+ mutex_unlock(&dev->wait_all_lock); -+ } else { -+ obj_unlock(obj); -+ } -+} -+ -+#define ntsync_assert_held(obj) \ -+ lockdep_assert((lockdep_is_held(&(obj)->lock) != LOCK_STATE_NOT_HELD) || \ -+ ((lockdep_is_held(&(obj)->dev->wait_all_lock) != LOCK_STATE_NOT_HELD) && \ -+ (obj)->dev_locked)) -+ -+static bool is_signaled(struct ntsync_obj *obj, __u32 owner) -+{ -+ ntsync_assert_held(obj); -+ -+ switch (obj->type) { -+ case NTSYNC_TYPE_SEM: -+ return !!obj->u.sem.count; -+ case NTSYNC_TYPE_MUTEX: -+ if (obj->u.mutex.owner && obj->u.mutex.owner != owner) -+ return false; -+ return obj->u.mutex.count < UINT_MAX; -+ case NTSYNC_TYPE_EVENT: -+ return obj->u.event.signaled; -+ } -+ -+ WARN(1, "bad object type %#x\n", obj->type); -+ return false; -+} -+ -+/* -+ * "locked_obj" is an optional pointer to an object which is already locked and -+ * should not be locked again. This is necessary so that changing an object's -+ * state and waking it can be a single atomic operation. -+ */ -+static void try_wake_all(struct ntsync_device *dev, struct ntsync_q *q, -+ struct ntsync_obj *locked_obj) -+{ -+ __u32 count = q->count; -+ bool can_wake = true; -+ int signaled = -1; -+ __u32 i; -+ -+ lockdep_assert_held(&dev->wait_all_lock); -+ if (locked_obj) -+ lockdep_assert(locked_obj->dev_locked); -+ -+ for (i = 0; i < count; i++) { -+ if (q->entries[i].obj != locked_obj) -+ dev_lock_obj(dev, q->entries[i].obj); -+ } -+ -+ for (i = 0; i < count; i++) { -+ if (!is_signaled(q->entries[i].obj, q->owner)) { -+ can_wake = false; -+ break; -+ } -+ } -+ -+ if (can_wake && atomic_try_cmpxchg(&q->signaled, &signaled, 0)) { -+ for (i = 0; i < count; i++) { -+ struct ntsync_obj *obj = q->entries[i].obj; -+ -+ switch (obj->type) { -+ case NTSYNC_TYPE_SEM: -+ obj->u.sem.count--; -+ break; -+ case NTSYNC_TYPE_MUTEX: -+ if (obj->u.mutex.ownerdead) -+ q->ownerdead = true; -+ obj->u.mutex.ownerdead = false; -+ obj->u.mutex.count++; -+ obj->u.mutex.owner = q->owner; -+ break; -+ case NTSYNC_TYPE_EVENT: -+ if (!obj->u.event.manual) -+ obj->u.event.signaled = false; -+ break; -+ } -+ } -+ wake_up_process(q->task); -+ } -+ -+ for (i = 0; i < count; i++) { -+ if (q->entries[i].obj != locked_obj) -+ dev_unlock_obj(dev, q->entries[i].obj); -+ } -+} -+ -+static void try_wake_all_obj(struct ntsync_device *dev, struct ntsync_obj *obj) -+{ -+ struct ntsync_q_entry *entry; -+ -+ lockdep_assert_held(&dev->wait_all_lock); -+ lockdep_assert(obj->dev_locked); -+ -+ list_for_each_entry(entry, &obj->all_waiters, node) -+ try_wake_all(dev, entry->q, obj); -+} -+ -+static void try_wake_any_sem(struct ntsync_obj *sem) -+{ -+ struct ntsync_q_entry *entry; -+ -+ ntsync_assert_held(sem); -+ lockdep_assert(sem->type == NTSYNC_TYPE_SEM); -+ -+ list_for_each_entry(entry, &sem->any_waiters, node) { -+ struct ntsync_q *q = entry->q; -+ int signaled = -1; -+ -+ if (!sem->u.sem.count) -+ break; -+ -+ if (atomic_try_cmpxchg(&q->signaled, &signaled, entry->index)) { -+ sem->u.sem.count--; -+ wake_up_process(q->task); -+ } -+ } -+} -+ -+static void try_wake_any_mutex(struct ntsync_obj *mutex) -+{ -+ struct ntsync_q_entry *entry; -+ -+ ntsync_assert_held(mutex); -+ lockdep_assert(mutex->type == NTSYNC_TYPE_MUTEX); -+ -+ list_for_each_entry(entry, &mutex->any_waiters, node) { -+ struct ntsync_q *q = entry->q; -+ int signaled = -1; -+ -+ if (mutex->u.mutex.count == UINT_MAX) -+ break; -+ if (mutex->u.mutex.owner && mutex->u.mutex.owner != q->owner) -+ continue; -+ -+ if (atomic_try_cmpxchg(&q->signaled, &signaled, entry->index)) { -+ if (mutex->u.mutex.ownerdead) -+ q->ownerdead = true; -+ mutex->u.mutex.ownerdead = false; -+ mutex->u.mutex.count++; -+ mutex->u.mutex.owner = q->owner; -+ wake_up_process(q->task); -+ } -+ } -+} -+ -+static void try_wake_any_event(struct ntsync_obj *event) -+{ -+ struct ntsync_q_entry *entry; -+ -+ ntsync_assert_held(event); -+ lockdep_assert(event->type == NTSYNC_TYPE_EVENT); -+ -+ list_for_each_entry(entry, &event->any_waiters, node) { -+ struct ntsync_q *q = entry->q; -+ int signaled = -1; -+ -+ if (!event->u.event.signaled) -+ break; -+ -+ if (atomic_try_cmpxchg(&q->signaled, &signaled, entry->index)) { -+ if (!event->u.event.manual) -+ event->u.event.signaled = false; -+ wake_up_process(q->task); -+ } -+ } -+} -+ - /* - * Actually change the semaphore state, returning -EOVERFLOW if it is made - * invalid. - */ --static int post_sem_state(struct ntsync_obj *sem, __u32 count) -+static int release_sem_state(struct ntsync_obj *sem, __u32 count) - { - __u32 sum; - -- lockdep_assert_held(&sem->lock); -+ ntsync_assert_held(sem); - - if (check_add_overflow(sem->u.sem.count, count, &sum) || - sum > sem->u.sem.max) -@@ -71,11 +404,13 @@ static int post_sem_state(struct ntsync_obj *sem, __u32 count) - return 0; - } - --static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) -+static int ntsync_sem_release(struct ntsync_obj *sem, void __user *argp) - { -+ struct ntsync_device *dev = sem->dev; - __u32 __user *user_args = argp; - __u32 prev_count; - __u32 args; -+ bool all; - int ret; - - if (copy_from_user(&args, argp, sizeof(args))) -@@ -84,12 +419,17 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) - if (sem->type != NTSYNC_TYPE_SEM) - return -EINVAL; - -- spin_lock(&sem->lock); -+ all = ntsync_lock_obj(dev, sem); - - prev_count = sem->u.sem.count; -- ret = post_sem_state(sem, args); -+ ret = release_sem_state(sem, args); -+ if (!ret) { -+ if (all) -+ try_wake_all_obj(dev, sem); -+ try_wake_any_sem(sem); -+ } - -- spin_unlock(&sem->lock); -+ ntsync_unlock_obj(dev, sem, all); - - if (!ret && put_user(prev_count, user_args)) - ret = -EFAULT; -@@ -97,6 +437,220 @@ static int ntsync_sem_post(struct ntsync_obj *sem, void __user *argp) - return ret; - } - -+/* -+ * Actually change the mutex state, returning -EPERM if not the owner. -+ */ -+static int unlock_mutex_state(struct ntsync_obj *mutex, -+ const struct ntsync_mutex_args *args) -+{ -+ ntsync_assert_held(mutex); -+ -+ if (mutex->u.mutex.owner != args->owner) -+ return -EPERM; -+ -+ if (!--mutex->u.mutex.count) -+ mutex->u.mutex.owner = 0; -+ return 0; -+} -+ -+static int ntsync_mutex_unlock(struct ntsync_obj *mutex, void __user *argp) -+{ -+ struct ntsync_mutex_args __user *user_args = argp; -+ struct ntsync_device *dev = mutex->dev; -+ struct ntsync_mutex_args args; -+ __u32 prev_count; -+ bool all; -+ int ret; -+ -+ if (copy_from_user(&args, argp, sizeof(args))) -+ return -EFAULT; -+ if (!args.owner) -+ return -EINVAL; -+ -+ if (mutex->type != NTSYNC_TYPE_MUTEX) -+ return -EINVAL; -+ -+ all = ntsync_lock_obj(dev, mutex); -+ -+ prev_count = mutex->u.mutex.count; -+ ret = unlock_mutex_state(mutex, &args); -+ if (!ret) { -+ if (all) -+ try_wake_all_obj(dev, mutex); -+ try_wake_any_mutex(mutex); -+ } -+ -+ ntsync_unlock_obj(dev, mutex, all); -+ -+ if (!ret && put_user(prev_count, &user_args->count)) -+ ret = -EFAULT; -+ -+ return ret; -+} -+ -+/* -+ * Actually change the mutex state to mark its owner as dead, -+ * returning -EPERM if not the owner. -+ */ -+static int kill_mutex_state(struct ntsync_obj *mutex, __u32 owner) -+{ -+ ntsync_assert_held(mutex); -+ -+ if (mutex->u.mutex.owner != owner) -+ return -EPERM; -+ -+ mutex->u.mutex.ownerdead = true; -+ mutex->u.mutex.owner = 0; -+ mutex->u.mutex.count = 0; -+ return 0; -+} -+ -+static int ntsync_mutex_kill(struct ntsync_obj *mutex, void __user *argp) -+{ -+ struct ntsync_device *dev = mutex->dev; -+ __u32 owner; -+ bool all; -+ int ret; -+ -+ if (get_user(owner, (__u32 __user *)argp)) -+ return -EFAULT; -+ if (!owner) -+ return -EINVAL; -+ -+ if (mutex->type != NTSYNC_TYPE_MUTEX) -+ return -EINVAL; -+ -+ all = ntsync_lock_obj(dev, mutex); -+ -+ ret = kill_mutex_state(mutex, owner); -+ if (!ret) { -+ if (all) -+ try_wake_all_obj(dev, mutex); -+ try_wake_any_mutex(mutex); -+ } -+ -+ ntsync_unlock_obj(dev, mutex, all); -+ -+ return ret; -+} -+ -+static int ntsync_event_set(struct ntsync_obj *event, void __user *argp, bool pulse) -+{ -+ struct ntsync_device *dev = event->dev; -+ __u32 prev_state; -+ bool all; -+ -+ if (event->type != NTSYNC_TYPE_EVENT) -+ return -EINVAL; -+ -+ all = ntsync_lock_obj(dev, event); -+ -+ prev_state = event->u.event.signaled; -+ event->u.event.signaled = true; -+ if (all) -+ try_wake_all_obj(dev, event); -+ try_wake_any_event(event); -+ if (pulse) -+ event->u.event.signaled = false; -+ -+ ntsync_unlock_obj(dev, event, all); -+ -+ if (put_user(prev_state, (__u32 __user *)argp)) -+ return -EFAULT; -+ -+ return 0; -+} -+ -+static int ntsync_event_reset(struct ntsync_obj *event, void __user *argp) -+{ -+ struct ntsync_device *dev = event->dev; -+ __u32 prev_state; -+ bool all; -+ -+ if (event->type != NTSYNC_TYPE_EVENT) -+ return -EINVAL; -+ -+ all = ntsync_lock_obj(dev, event); -+ -+ prev_state = event->u.event.signaled; -+ event->u.event.signaled = false; -+ -+ ntsync_unlock_obj(dev, event, all); -+ -+ if (put_user(prev_state, (__u32 __user *)argp)) -+ return -EFAULT; -+ -+ return 0; -+} -+ -+static int ntsync_sem_read(struct ntsync_obj *sem, void __user *argp) -+{ -+ struct ntsync_sem_args __user *user_args = argp; -+ struct ntsync_device *dev = sem->dev; -+ struct ntsync_sem_args args; -+ bool all; -+ -+ if (sem->type != NTSYNC_TYPE_SEM) -+ return -EINVAL; -+ -+ all = ntsync_lock_obj(dev, sem); -+ -+ args.count = sem->u.sem.count; -+ args.max = sem->u.sem.max; -+ -+ ntsync_unlock_obj(dev, sem, all); -+ -+ if (copy_to_user(user_args, &args, sizeof(args))) -+ return -EFAULT; -+ return 0; -+} -+ -+static int ntsync_mutex_read(struct ntsync_obj *mutex, void __user *argp) -+{ -+ struct ntsync_mutex_args __user *user_args = argp; -+ struct ntsync_device *dev = mutex->dev; -+ struct ntsync_mutex_args args; -+ bool all; -+ int ret; -+ -+ if (mutex->type != NTSYNC_TYPE_MUTEX) -+ return -EINVAL; -+ -+ all = ntsync_lock_obj(dev, mutex); -+ -+ args.count = mutex->u.mutex.count; -+ args.owner = mutex->u.mutex.owner; -+ ret = mutex->u.mutex.ownerdead ? -EOWNERDEAD : 0; -+ -+ ntsync_unlock_obj(dev, mutex, all); -+ -+ if (copy_to_user(user_args, &args, sizeof(args))) -+ return -EFAULT; -+ return ret; -+} -+ -+static int ntsync_event_read(struct ntsync_obj *event, void __user *argp) -+{ -+ struct ntsync_event_args __user *user_args = argp; -+ struct ntsync_device *dev = event->dev; -+ struct ntsync_event_args args; -+ bool all; -+ -+ if (event->type != NTSYNC_TYPE_EVENT) -+ return -EINVAL; -+ -+ all = ntsync_lock_obj(dev, event); -+ -+ args.manual = event->u.event.manual; -+ args.signaled = event->u.event.signaled; -+ -+ ntsync_unlock_obj(dev, event, all); -+ -+ if (copy_to_user(user_args, &args, sizeof(args))) -+ return -EFAULT; -+ return 0; -+} -+ - static int ntsync_obj_release(struct inode *inode, struct file *file) - { - struct ntsync_obj *obj = file->private_data; -@@ -114,8 +668,24 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd, - void __user *argp = (void __user *)parm; - - switch (cmd) { -- case NTSYNC_IOC_SEM_POST: -- return ntsync_sem_post(obj, argp); -+ case NTSYNC_IOC_SEM_RELEASE: -+ return ntsync_sem_release(obj, argp); -+ case NTSYNC_IOC_SEM_READ: -+ return ntsync_sem_read(obj, argp); -+ case NTSYNC_IOC_MUTEX_UNLOCK: -+ return ntsync_mutex_unlock(obj, argp); -+ case NTSYNC_IOC_MUTEX_KILL: -+ return ntsync_mutex_kill(obj, argp); -+ case NTSYNC_IOC_MUTEX_READ: -+ return ntsync_mutex_read(obj, argp); -+ case NTSYNC_IOC_EVENT_SET: -+ return ntsync_event_set(obj, argp, false); -+ case NTSYNC_IOC_EVENT_RESET: -+ return ntsync_event_reset(obj, argp); -+ case NTSYNC_IOC_EVENT_PULSE: -+ return ntsync_event_set(obj, argp, true); -+ case NTSYNC_IOC_EVENT_READ: -+ return ntsync_event_read(obj, argp); - default: - return -ENOIOCTLCMD; - } -@@ -140,6 +710,9 @@ static struct ntsync_obj *ntsync_alloc_obj(struct ntsync_device *dev, - obj->dev = dev; - get_file(dev->file); - spin_lock_init(&obj->lock); -+ INIT_LIST_HEAD(&obj->any_waiters); -+ INIT_LIST_HEAD(&obj->all_waiters); -+ atomic_set(&obj->all_hint, 0); - - return obj; - } -@@ -165,7 +738,6 @@ static int ntsync_obj_get_fd(struct ntsync_obj *obj) - - static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp) - { -- struct ntsync_sem_args __user *user_args = argp; - struct ntsync_sem_args args; - struct ntsync_obj *sem; - int fd; -@@ -182,12 +754,398 @@ static int ntsync_create_sem(struct ntsync_device *dev, void __user *argp) - sem->u.sem.count = args.count; - sem->u.sem.max = args.max; - fd = ntsync_obj_get_fd(sem); -- if (fd < 0) { -+ if (fd < 0) - kfree(sem); -- return fd; -+ -+ return fd; -+} -+ -+static int ntsync_create_mutex(struct ntsync_device *dev, void __user *argp) -+{ -+ struct ntsync_mutex_args args; -+ struct ntsync_obj *mutex; -+ int fd; -+ -+ if (copy_from_user(&args, argp, sizeof(args))) -+ return -EFAULT; -+ -+ if (!args.owner != !args.count) -+ return -EINVAL; -+ -+ mutex = ntsync_alloc_obj(dev, NTSYNC_TYPE_MUTEX); -+ if (!mutex) -+ return -ENOMEM; -+ mutex->u.mutex.count = args.count; -+ mutex->u.mutex.owner = args.owner; -+ fd = ntsync_obj_get_fd(mutex); -+ if (fd < 0) -+ kfree(mutex); -+ -+ return fd; -+} -+ -+static int ntsync_create_event(struct ntsync_device *dev, void __user *argp) -+{ -+ struct ntsync_event_args args; -+ struct ntsync_obj *event; -+ int fd; -+ -+ if (copy_from_user(&args, argp, sizeof(args))) -+ return -EFAULT; -+ -+ event = ntsync_alloc_obj(dev, NTSYNC_TYPE_EVENT); -+ if (!event) -+ return -ENOMEM; -+ event->u.event.manual = args.manual; -+ event->u.event.signaled = args.signaled; -+ fd = ntsync_obj_get_fd(event); -+ if (fd < 0) -+ kfree(event); -+ -+ return fd; -+} -+ -+static struct ntsync_obj *get_obj(struct ntsync_device *dev, int fd) -+{ -+ struct file *file = fget(fd); -+ struct ntsync_obj *obj; -+ -+ if (!file) -+ return NULL; -+ -+ if (file->f_op != &ntsync_obj_fops) { -+ fput(file); -+ return NULL; - } - -- return put_user(fd, &user_args->sem); -+ obj = file->private_data; -+ if (obj->dev != dev) { -+ fput(file); -+ return NULL; -+ } -+ -+ return obj; -+} -+ -+static void put_obj(struct ntsync_obj *obj) -+{ -+ fput(obj->file); -+} -+ -+static int ntsync_schedule(const struct ntsync_q *q, const struct ntsync_wait_args *args) -+{ -+ ktime_t timeout = ns_to_ktime(args->timeout); -+ clockid_t clock = CLOCK_MONOTONIC; -+ ktime_t *timeout_ptr; -+ int ret = 0; -+ -+ timeout_ptr = (args->timeout == U64_MAX ? NULL : &timeout); -+ -+ if (args->flags & NTSYNC_WAIT_REALTIME) -+ clock = CLOCK_REALTIME; -+ -+ do { -+ if (signal_pending(current)) { -+ ret = -ERESTARTSYS; -+ break; -+ } -+ -+ set_current_state(TASK_INTERRUPTIBLE); -+ if (atomic_read(&q->signaled) != -1) { -+ ret = 0; -+ break; -+ } -+ ret = schedule_hrtimeout_range_clock(timeout_ptr, 0, HRTIMER_MODE_ABS, clock); -+ } while (ret < 0); -+ __set_current_state(TASK_RUNNING); -+ -+ return ret; -+} -+ -+/* -+ * Allocate and initialize the ntsync_q structure, but do not queue us yet. -+ */ -+static int setup_wait(struct ntsync_device *dev, -+ const struct ntsync_wait_args *args, bool all, -+ struct ntsync_q **ret_q) -+{ -+ int fds[NTSYNC_MAX_WAIT_COUNT + 1]; -+ const __u32 count = args->count; -+ struct ntsync_q *q; -+ __u32 total_count; -+ __u32 i, j; -+ -+ if (args->pad || (args->flags & ~NTSYNC_WAIT_REALTIME)) -+ return -EINVAL; -+ -+ if (args->count > NTSYNC_MAX_WAIT_COUNT) -+ return -EINVAL; -+ -+ total_count = count; -+ if (args->alert) -+ total_count++; -+ -+ if (copy_from_user(fds, u64_to_user_ptr(args->objs), -+ array_size(count, sizeof(*fds)))) -+ return -EFAULT; -+ if (args->alert) -+ fds[count] = args->alert; -+ -+ q = kmalloc(struct_size(q, entries, total_count), GFP_KERNEL); -+ if (!q) -+ return -ENOMEM; -+ q->task = current; -+ q->owner = args->owner; -+ atomic_set(&q->signaled, -1); -+ q->all = all; -+ q->ownerdead = false; -+ q->count = count; -+ -+ for (i = 0; i < total_count; i++) { -+ struct ntsync_q_entry *entry = &q->entries[i]; -+ struct ntsync_obj *obj = get_obj(dev, fds[i]); -+ -+ if (!obj) -+ goto err; -+ -+ if (all) { -+ /* Check that the objects are all distinct. */ -+ for (j = 0; j < i; j++) { -+ if (obj == q->entries[j].obj) { -+ put_obj(obj); -+ goto err; -+ } -+ } -+ } -+ -+ entry->obj = obj; -+ entry->q = q; -+ entry->index = i; -+ } -+ -+ *ret_q = q; -+ return 0; -+ -+err: -+ for (j = 0; j < i; j++) -+ put_obj(q->entries[j].obj); -+ kfree(q); -+ return -EINVAL; -+} -+ -+static void try_wake_any_obj(struct ntsync_obj *obj) -+{ -+ switch (obj->type) { -+ case NTSYNC_TYPE_SEM: -+ try_wake_any_sem(obj); -+ break; -+ case NTSYNC_TYPE_MUTEX: -+ try_wake_any_mutex(obj); -+ break; -+ case NTSYNC_TYPE_EVENT: -+ try_wake_any_event(obj); -+ break; -+ } -+} -+ -+static int ntsync_wait_any(struct ntsync_device *dev, void __user *argp) -+{ -+ struct ntsync_wait_args args; -+ __u32 i, total_count; -+ struct ntsync_q *q; -+ int signaled; -+ bool all; -+ int ret; -+ -+ if (copy_from_user(&args, argp, sizeof(args))) -+ return -EFAULT; -+ -+ ret = setup_wait(dev, &args, false, &q); -+ if (ret < 0) -+ return ret; -+ -+ total_count = args.count; -+ if (args.alert) -+ total_count++; -+ -+ /* queue ourselves */ -+ -+ for (i = 0; i < total_count; i++) { -+ struct ntsync_q_entry *entry = &q->entries[i]; -+ struct ntsync_obj *obj = entry->obj; -+ -+ all = ntsync_lock_obj(dev, obj); -+ list_add_tail(&entry->node, &obj->any_waiters); -+ ntsync_unlock_obj(dev, obj, all); -+ } -+ -+ /* -+ * Check if we are already signaled. -+ * -+ * Note that the API requires that normal objects are checked before -+ * the alert event. Hence we queue the alert event last, and check -+ * objects in order. -+ */ -+ -+ for (i = 0; i < total_count; i++) { -+ struct ntsync_obj *obj = q->entries[i].obj; -+ -+ if (atomic_read(&q->signaled) != -1) -+ break; -+ -+ all = ntsync_lock_obj(dev, obj); -+ try_wake_any_obj(obj); -+ ntsync_unlock_obj(dev, obj, all); -+ } -+ -+ /* sleep */ -+ -+ ret = ntsync_schedule(q, &args); -+ -+ /* and finally, unqueue */ -+ -+ for (i = 0; i < total_count; i++) { -+ struct ntsync_q_entry *entry = &q->entries[i]; -+ struct ntsync_obj *obj = entry->obj; -+ -+ all = ntsync_lock_obj(dev, obj); -+ list_del(&entry->node); -+ ntsync_unlock_obj(dev, obj, all); -+ -+ put_obj(obj); -+ } -+ -+ signaled = atomic_read(&q->signaled); -+ if (signaled != -1) { -+ struct ntsync_wait_args __user *user_args = argp; -+ -+ /* even if we caught a signal, we need to communicate success */ -+ ret = q->ownerdead ? -EOWNERDEAD : 0; -+ -+ if (put_user(signaled, &user_args->index)) -+ ret = -EFAULT; -+ } else if (!ret) { -+ ret = -ETIMEDOUT; -+ } -+ -+ kfree(q); -+ return ret; -+} -+ -+static int ntsync_wait_all(struct ntsync_device *dev, void __user *argp) -+{ -+ struct ntsync_wait_args args; -+ struct ntsync_q *q; -+ int signaled; -+ __u32 i; -+ int ret; -+ -+ if (copy_from_user(&args, argp, sizeof(args))) -+ return -EFAULT; -+ -+ ret = setup_wait(dev, &args, true, &q); -+ if (ret < 0) -+ return ret; -+ -+ /* queue ourselves */ -+ -+ mutex_lock(&dev->wait_all_lock); -+ -+ for (i = 0; i < args.count; i++) { -+ struct ntsync_q_entry *entry = &q->entries[i]; -+ struct ntsync_obj *obj = entry->obj; -+ -+ atomic_inc(&obj->all_hint); -+ -+ /* -+ * obj->all_waiters is protected by dev->wait_all_lock rather -+ * than obj->lock, so there is no need to acquire obj->lock -+ * here. -+ */ -+ list_add_tail(&entry->node, &obj->all_waiters); -+ } -+ if (args.alert) { -+ struct ntsync_q_entry *entry = &q->entries[args.count]; -+ struct ntsync_obj *obj = entry->obj; -+ -+ dev_lock_obj(dev, obj); -+ list_add_tail(&entry->node, &obj->any_waiters); -+ dev_unlock_obj(dev, obj); -+ } -+ -+ /* check if we are already signaled */ -+ -+ try_wake_all(dev, q, NULL); -+ -+ mutex_unlock(&dev->wait_all_lock); -+ -+ /* -+ * Check if the alert event is signaled, making sure to do so only -+ * after checking if the other objects are signaled. -+ */ -+ -+ if (args.alert) { -+ struct ntsync_obj *obj = q->entries[args.count].obj; -+ -+ if (atomic_read(&q->signaled) == -1) { -+ bool all = ntsync_lock_obj(dev, obj); -+ try_wake_any_obj(obj); -+ ntsync_unlock_obj(dev, obj, all); -+ } -+ } -+ -+ /* sleep */ -+ -+ ret = ntsync_schedule(q, &args); -+ -+ /* and finally, unqueue */ -+ -+ mutex_lock(&dev->wait_all_lock); -+ -+ for (i = 0; i < args.count; i++) { -+ struct ntsync_q_entry *entry = &q->entries[i]; -+ struct ntsync_obj *obj = entry->obj; -+ -+ /* -+ * obj->all_waiters is protected by dev->wait_all_lock rather -+ * than obj->lock, so there is no need to acquire it here. -+ */ -+ list_del(&entry->node); -+ -+ atomic_dec(&obj->all_hint); -+ -+ put_obj(obj); -+ } -+ -+ mutex_unlock(&dev->wait_all_lock); -+ -+ if (args.alert) { -+ struct ntsync_q_entry *entry = &q->entries[args.count]; -+ struct ntsync_obj *obj = entry->obj; -+ bool all; -+ -+ all = ntsync_lock_obj(dev, obj); -+ list_del(&entry->node); -+ ntsync_unlock_obj(dev, obj, all); -+ -+ put_obj(obj); -+ } -+ -+ signaled = atomic_read(&q->signaled); -+ if (signaled != -1) { -+ struct ntsync_wait_args __user *user_args = argp; -+ -+ /* even if we caught a signal, we need to communicate success */ -+ ret = q->ownerdead ? -EOWNERDEAD : 0; -+ -+ if (put_user(signaled, &user_args->index)) -+ ret = -EFAULT; -+ } else if (!ret) { -+ ret = -ETIMEDOUT; -+ } -+ -+ kfree(q); -+ return ret; - } - - static int ntsync_char_open(struct inode *inode, struct file *file) -@@ -198,6 +1156,8 @@ static int ntsync_char_open(struct inode *inode, struct file *file) - if (!dev) - return -ENOMEM; - -+ mutex_init(&dev->wait_all_lock); -+ - file->private_data = dev; - dev->file = file; - return nonseekable_open(inode, file); -@@ -219,8 +1179,16 @@ static long ntsync_char_ioctl(struct file *file, unsigned int cmd, - void __user *argp = (void __user *)parm; - - switch (cmd) { -+ case NTSYNC_IOC_CREATE_EVENT: -+ return ntsync_create_event(dev, argp); -+ case NTSYNC_IOC_CREATE_MUTEX: -+ return ntsync_create_mutex(dev, argp); - case NTSYNC_IOC_CREATE_SEM: - return ntsync_create_sem(dev, argp); -+ case NTSYNC_IOC_WAIT_ALL: -+ return ntsync_wait_all(dev, argp); -+ case NTSYNC_IOC_WAIT_ANY: -+ return ntsync_wait_any(dev, argp); - default: - return -ENOIOCTLCMD; - } -@@ -238,6 +1206,7 @@ static struct miscdevice ntsync_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = NTSYNC_NAME, - .fops = &ntsync_fops, -+ .mode = 0666, // Setting file permissions to 0666 - }; - - module_misc_device(ntsync_misc); -diff --git a/include/uapi/linux/ntsync.h b/include/uapi/linux/ntsync.h -index dcfa38fdc93c..6d06793512b1 100644 ---- a/include/uapi/linux/ntsync.h -+++ b/include/uapi/linux/ntsync.h -@@ -11,13 +11,49 @@ - #include - - struct ntsync_sem_args { -- __u32 sem; - __u32 count; - __u32 max; - }; - --#define NTSYNC_IOC_CREATE_SEM _IOWR('N', 0x80, struct ntsync_sem_args) -+struct ntsync_mutex_args { -+ __u32 owner; -+ __u32 count; -+}; -+ -+struct ntsync_event_args { -+ __u32 manual; -+ __u32 signaled; -+}; -+ -+#define NTSYNC_WAIT_REALTIME 0x1 -+ -+struct ntsync_wait_args { -+ __u64 timeout; -+ __u64 objs; -+ __u32 count; -+ __u32 index; -+ __u32 flags; -+ __u32 owner; -+ __u32 alert; -+ __u32 pad; -+}; -+ -+#define NTSYNC_MAX_WAIT_COUNT 64 -+ -+#define NTSYNC_IOC_CREATE_SEM _IOW ('N', 0x80, struct ntsync_sem_args) -+#define NTSYNC_IOC_WAIT_ANY _IOWR('N', 0x82, struct ntsync_wait_args) -+#define NTSYNC_IOC_WAIT_ALL _IOWR('N', 0x83, struct ntsync_wait_args) -+#define NTSYNC_IOC_CREATE_MUTEX _IOW ('N', 0x84, struct ntsync_mutex_args) -+#define NTSYNC_IOC_CREATE_EVENT _IOW ('N', 0x87, struct ntsync_event_args) - --#define NTSYNC_IOC_SEM_POST _IOWR('N', 0x81, __u32) -+#define NTSYNC_IOC_SEM_RELEASE _IOWR('N', 0x81, __u32) -+#define NTSYNC_IOC_MUTEX_UNLOCK _IOWR('N', 0x85, struct ntsync_mutex_args) -+#define NTSYNC_IOC_MUTEX_KILL _IOW ('N', 0x86, __u32) -+#define NTSYNC_IOC_EVENT_SET _IOR ('N', 0x88, __u32) -+#define NTSYNC_IOC_EVENT_RESET _IOR ('N', 0x89, __u32) -+#define NTSYNC_IOC_EVENT_PULSE _IOR ('N', 0x8a, __u32) -+#define NTSYNC_IOC_SEM_READ _IOR ('N', 0x8b, struct ntsync_sem_args) -+#define NTSYNC_IOC_MUTEX_READ _IOR ('N', 0x8c, struct ntsync_mutex_args) -+#define NTSYNC_IOC_EVENT_READ _IOR ('N', 0x8d, struct ntsync_event_args) - - #endif -diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile -index 85c5f39131d3..6acf76df918a 100644 ---- a/tools/testing/selftests/Makefile -+++ b/tools/testing/selftests/Makefile -@@ -18,6 +18,7 @@ TARGETS += devices/error_logs - TARGETS += devices/probe - TARGETS += dmabuf-heaps - TARGETS += drivers/dma-buf -+TARGETS += drivers/ntsync - TARGETS += drivers/s390x/uvdevice - TARGETS += drivers/net - TARGETS += drivers/net/bonding -diff --git a/tools/testing/selftests/drivers/ntsync/.gitignore b/tools/testing/selftests/drivers/ntsync/.gitignore -new file mode 100644 -index 000000000000..848573a3d3ea ---- /dev/null -+++ b/tools/testing/selftests/drivers/ntsync/.gitignore -@@ -0,0 +1 @@ -+ntsync -diff --git a/tools/testing/selftests/drivers/ntsync/Makefile b/tools/testing/selftests/drivers/ntsync/Makefile -new file mode 100644 -index 000000000000..dbf2b055c0b2 ---- /dev/null -+++ b/tools/testing/selftests/drivers/ntsync/Makefile -@@ -0,0 +1,7 @@ -+# SPDX-LICENSE-IDENTIFIER: GPL-2.0-only -+TEST_GEN_PROGS := ntsync -+ -+CFLAGS += $(KHDR_INCLUDES) -+LDLIBS += -lpthread -+ -+include ../../lib.mk -diff --git a/tools/testing/selftests/drivers/ntsync/config b/tools/testing/selftests/drivers/ntsync/config -new file mode 100644 -index 000000000000..60539c826d06 ---- /dev/null -+++ b/tools/testing/selftests/drivers/ntsync/config -@@ -0,0 +1 @@ -+CONFIG_WINESYNC=y -diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testing/selftests/drivers/ntsync/ntsync.c -new file mode 100644 -index 000000000000..3aad311574c4 ---- /dev/null -+++ b/tools/testing/selftests/drivers/ntsync/ntsync.c -@@ -0,0 +1,1343 @@ -+// SPDX-License-Identifier: GPL-2.0-or-later -+/* -+ * Various unit tests for the "ntsync" synchronization primitive driver. -+ * -+ * Copyright (C) 2021-2022 Elizabeth Figura -+ */ -+ -+#define _GNU_SOURCE -+#include -+#include -+#include -+#include -+#include -+#include -+#include "../../kselftest_harness.h" -+ -+static int read_sem_state(int sem, __u32 *count, __u32 *max) -+{ -+ struct ntsync_sem_args args; -+ int ret; -+ -+ memset(&args, 0xcc, sizeof(args)); -+ ret = ioctl(sem, NTSYNC_IOC_SEM_READ, &args); -+ *count = args.count; -+ *max = args.max; -+ return ret; -+} -+ -+#define check_sem_state(sem, count, max) \ -+ ({ \ -+ __u32 __count, __max; \ -+ int ret = read_sem_state((sem), &__count, &__max); \ -+ EXPECT_EQ(0, ret); \ -+ EXPECT_EQ((count), __count); \ -+ EXPECT_EQ((max), __max); \ -+ }) -+ -+static int release_sem(int sem, __u32 *count) -+{ -+ return ioctl(sem, NTSYNC_IOC_SEM_RELEASE, count); -+} -+ -+static int read_mutex_state(int mutex, __u32 *count, __u32 *owner) -+{ -+ struct ntsync_mutex_args args; -+ int ret; -+ -+ memset(&args, 0xcc, sizeof(args)); -+ ret = ioctl(mutex, NTSYNC_IOC_MUTEX_READ, &args); -+ *count = args.count; -+ *owner = args.owner; -+ return ret; -+} -+ -+#define check_mutex_state(mutex, count, owner) \ -+ ({ \ -+ __u32 __count, __owner; \ -+ int ret = read_mutex_state((mutex), &__count, &__owner); \ -+ EXPECT_EQ(0, ret); \ -+ EXPECT_EQ((count), __count); \ -+ EXPECT_EQ((owner), __owner); \ -+ }) -+ -+static int unlock_mutex(int mutex, __u32 owner, __u32 *count) -+{ -+ struct ntsync_mutex_args args; -+ int ret; -+ -+ args.owner = owner; -+ args.count = 0xdeadbeef; -+ ret = ioctl(mutex, NTSYNC_IOC_MUTEX_UNLOCK, &args); -+ *count = args.count; -+ return ret; -+} -+ -+static int read_event_state(int event, __u32 *signaled, __u32 *manual) -+{ -+ struct ntsync_event_args args; -+ int ret; -+ -+ memset(&args, 0xcc, sizeof(args)); -+ ret = ioctl(event, NTSYNC_IOC_EVENT_READ, &args); -+ *signaled = args.signaled; -+ *manual = args.manual; -+ return ret; -+} -+ -+#define check_event_state(event, signaled, manual) \ -+ ({ \ -+ __u32 __signaled, __manual; \ -+ int ret = read_event_state((event), &__signaled, &__manual); \ -+ EXPECT_EQ(0, ret); \ -+ EXPECT_EQ((signaled), __signaled); \ -+ EXPECT_EQ((manual), __manual); \ -+ }) -+ -+static int wait_objs(int fd, unsigned long request, __u32 count, -+ const int *objs, __u32 owner, int alert, __u32 *index) -+{ -+ struct ntsync_wait_args args = {0}; -+ struct timespec timeout; -+ int ret; -+ -+ clock_gettime(CLOCK_MONOTONIC, &timeout); -+ -+ args.timeout = timeout.tv_sec * 1000000000 + timeout.tv_nsec; -+ args.count = count; -+ args.objs = (uintptr_t)objs; -+ args.owner = owner; -+ args.index = 0xdeadbeef; -+ args.alert = alert; -+ ret = ioctl(fd, request, &args); -+ *index = args.index; -+ return ret; -+} -+ -+static int wait_any(int fd, __u32 count, const int *objs, __u32 owner, __u32 *index) -+{ -+ return wait_objs(fd, NTSYNC_IOC_WAIT_ANY, count, objs, owner, 0, index); -+} -+ -+static int wait_all(int fd, __u32 count, const int *objs, __u32 owner, __u32 *index) -+{ -+ return wait_objs(fd, NTSYNC_IOC_WAIT_ALL, count, objs, owner, 0, index); -+} -+ -+static int wait_any_alert(int fd, __u32 count, const int *objs, -+ __u32 owner, int alert, __u32 *index) -+{ -+ return wait_objs(fd, NTSYNC_IOC_WAIT_ANY, -+ count, objs, owner, alert, index); -+} -+ -+static int wait_all_alert(int fd, __u32 count, const int *objs, -+ __u32 owner, int alert, __u32 *index) -+{ -+ return wait_objs(fd, NTSYNC_IOC_WAIT_ALL, -+ count, objs, owner, alert, index); -+} -+ -+TEST(semaphore_state) -+{ -+ struct ntsync_sem_args sem_args; -+ struct timespec timeout; -+ __u32 count, index; -+ int fd, ret, sem; -+ -+ clock_gettime(CLOCK_MONOTONIC, &timeout); -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ sem_args.count = 3; -+ sem_args.max = 2; -+ sem = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_EQ(-1, sem); -+ EXPECT_EQ(EINVAL, errno); -+ -+ sem_args.count = 2; -+ sem_args.max = 2; -+ sem = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_LE(0, sem); -+ check_sem_state(sem, 2, 2); -+ -+ count = 0; -+ ret = release_sem(sem, &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(2, count); -+ check_sem_state(sem, 2, 2); -+ -+ count = 1; -+ ret = release_sem(sem, &count); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOVERFLOW, errno); -+ check_sem_state(sem, 2, 2); -+ -+ ret = wait_any(fd, 1, &sem, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(sem, 1, 2); -+ -+ ret = wait_any(fd, 1, &sem, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(sem, 0, 2); -+ -+ ret = wait_any(fd, 1, &sem, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ count = 3; -+ ret = release_sem(sem, &count); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOVERFLOW, errno); -+ check_sem_state(sem, 0, 2); -+ -+ count = 2; -+ ret = release_sem(sem, &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, count); -+ check_sem_state(sem, 2, 2); -+ -+ ret = wait_any(fd, 1, &sem, 123, &index); -+ EXPECT_EQ(0, ret); -+ ret = wait_any(fd, 1, &sem, 123, &index); -+ EXPECT_EQ(0, ret); -+ -+ count = 1; -+ ret = release_sem(sem, &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, count); -+ check_sem_state(sem, 1, 2); -+ -+ count = ~0u; -+ ret = release_sem(sem, &count); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOVERFLOW, errno); -+ check_sem_state(sem, 1, 2); -+ -+ close(sem); -+ -+ close(fd); -+} -+ -+TEST(mutex_state) -+{ -+ struct ntsync_mutex_args mutex_args; -+ __u32 owner, count, index; -+ struct timespec timeout; -+ int fd, ret, mutex; -+ -+ clock_gettime(CLOCK_MONOTONIC, &timeout); -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ mutex_args.owner = 123; -+ mutex_args.count = 0; -+ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(-1, mutex); -+ EXPECT_EQ(EINVAL, errno); -+ -+ mutex_args.owner = 0; -+ mutex_args.count = 2; -+ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_EQ(-1, mutex); -+ EXPECT_EQ(EINVAL, errno); -+ -+ mutex_args.owner = 123; -+ mutex_args.count = 2; -+ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_LE(0, mutex); -+ check_mutex_state(mutex, 2, 123); -+ -+ ret = unlock_mutex(mutex, 0, &count); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EINVAL, errno); -+ -+ ret = unlock_mutex(mutex, 456, &count); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EPERM, errno); -+ check_mutex_state(mutex, 2, 123); -+ -+ ret = unlock_mutex(mutex, 123, &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(2, count); -+ check_mutex_state(mutex, 1, 123); -+ -+ ret = unlock_mutex(mutex, 123, &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, count); -+ check_mutex_state(mutex, 0, 0); -+ -+ ret = unlock_mutex(mutex, 123, &count); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EPERM, errno); -+ -+ ret = wait_any(fd, 1, &mutex, 456, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_mutex_state(mutex, 1, 456); -+ -+ ret = wait_any(fd, 1, &mutex, 456, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_mutex_state(mutex, 2, 456); -+ -+ ret = unlock_mutex(mutex, 456, &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(2, count); -+ check_mutex_state(mutex, 1, 456); -+ -+ ret = wait_any(fd, 1, &mutex, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ owner = 0; -+ ret = ioctl(mutex, NTSYNC_IOC_MUTEX_KILL, &owner); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EINVAL, errno); -+ -+ owner = 123; -+ ret = ioctl(mutex, NTSYNC_IOC_MUTEX_KILL, &owner); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EPERM, errno); -+ check_mutex_state(mutex, 1, 456); -+ -+ owner = 456; -+ ret = ioctl(mutex, NTSYNC_IOC_MUTEX_KILL, &owner); -+ EXPECT_EQ(0, ret); -+ -+ memset(&mutex_args, 0xcc, sizeof(mutex_args)); -+ ret = ioctl(mutex, NTSYNC_IOC_MUTEX_READ, &mutex_args); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOWNERDEAD, errno); -+ EXPECT_EQ(0, mutex_args.count); -+ EXPECT_EQ(0, mutex_args.owner); -+ -+ memset(&mutex_args, 0xcc, sizeof(mutex_args)); -+ ret = ioctl(mutex, NTSYNC_IOC_MUTEX_READ, &mutex_args); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOWNERDEAD, errno); -+ EXPECT_EQ(0, mutex_args.count); -+ EXPECT_EQ(0, mutex_args.owner); -+ -+ ret = wait_any(fd, 1, &mutex, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOWNERDEAD, errno); -+ EXPECT_EQ(0, index); -+ check_mutex_state(mutex, 1, 123); -+ -+ owner = 123; -+ ret = ioctl(mutex, NTSYNC_IOC_MUTEX_KILL, &owner); -+ EXPECT_EQ(0, ret); -+ -+ memset(&mutex_args, 0xcc, sizeof(mutex_args)); -+ ret = ioctl(mutex, NTSYNC_IOC_MUTEX_READ, &mutex_args); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOWNERDEAD, errno); -+ EXPECT_EQ(0, mutex_args.count); -+ EXPECT_EQ(0, mutex_args.owner); -+ -+ ret = wait_any(fd, 1, &mutex, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOWNERDEAD, errno); -+ EXPECT_EQ(0, index); -+ check_mutex_state(mutex, 1, 123); -+ -+ close(mutex); -+ -+ mutex_args.owner = 0; -+ mutex_args.count = 0; -+ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_LE(0, mutex); -+ check_mutex_state(mutex, 0, 0); -+ -+ ret = wait_any(fd, 1, &mutex, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_mutex_state(mutex, 1, 123); -+ -+ close(mutex); -+ -+ mutex_args.owner = 123; -+ mutex_args.count = ~0u; -+ mutex = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_LE(0, mutex); -+ check_mutex_state(mutex, ~0u, 123); -+ -+ ret = wait_any(fd, 1, &mutex, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ close(mutex); -+ -+ close(fd); -+} -+ -+TEST(manual_event_state) -+{ -+ struct ntsync_event_args event_args; -+ __u32 index, signaled; -+ int fd, event, ret; -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ event_args.manual = 1; -+ event_args.signaled = 0; -+ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, event); -+ check_event_state(event, 0, 1); -+ -+ signaled = 0xdeadbeef; -+ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ check_event_state(event, 1, 1); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, signaled); -+ check_event_state(event, 1, 1); -+ -+ ret = wait_any(fd, 1, &event, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_event_state(event, 1, 1); -+ -+ signaled = 0xdeadbeef; -+ ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, signaled); -+ check_event_state(event, 0, 1); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ check_event_state(event, 0, 1); -+ -+ ret = wait_any(fd, 1, &event, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_PULSE, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, signaled); -+ check_event_state(event, 0, 1); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_PULSE, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ check_event_state(event, 0, 1); -+ -+ close(event); -+ -+ close(fd); -+} -+ -+TEST(auto_event_state) -+{ -+ struct ntsync_event_args event_args; -+ __u32 index, signaled; -+ int fd, event, ret; -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ event_args.manual = 0; -+ event_args.signaled = 1; -+ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, event); -+ -+ check_event_state(event, 1, 0); -+ -+ signaled = 0xdeadbeef; -+ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, signaled); -+ check_event_state(event, 1, 0); -+ -+ ret = wait_any(fd, 1, &event, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_event_state(event, 0, 0); -+ -+ signaled = 0xdeadbeef; -+ ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ check_event_state(event, 0, 0); -+ -+ ret = wait_any(fd, 1, &event, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_PULSE, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, signaled); -+ check_event_state(event, 0, 0); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_PULSE, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ check_event_state(event, 0, 0); -+ -+ close(event); -+ -+ close(fd); -+} -+ -+TEST(test_wait_any) -+{ -+ int objs[NTSYNC_MAX_WAIT_COUNT + 1], fd, ret; -+ struct ntsync_mutex_args mutex_args = {0}; -+ struct ntsync_sem_args sem_args = {0}; -+ __u32 owner, index, count, i; -+ struct timespec timeout; -+ -+ clock_gettime(CLOCK_MONOTONIC, &timeout); -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ sem_args.count = 2; -+ sem_args.max = 3; -+ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_LE(0, objs[0]); -+ -+ mutex_args.owner = 0; -+ mutex_args.count = 0; -+ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_LE(0, objs[1]); -+ -+ ret = wait_any(fd, 2, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(objs[0], 1, 3); -+ check_mutex_state(objs[1], 0, 0); -+ -+ ret = wait_any(fd, 2, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(objs[0], 0, 3); -+ check_mutex_state(objs[1], 0, 0); -+ -+ ret = wait_any(fd, 2, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, index); -+ check_sem_state(objs[0], 0, 3); -+ check_mutex_state(objs[1], 1, 123); -+ -+ count = 1; -+ ret = release_sem(objs[0], &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, count); -+ -+ ret = wait_any(fd, 2, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(objs[0], 0, 3); -+ check_mutex_state(objs[1], 1, 123); -+ -+ ret = wait_any(fd, 2, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, index); -+ check_sem_state(objs[0], 0, 3); -+ check_mutex_state(objs[1], 2, 123); -+ -+ ret = wait_any(fd, 2, objs, 456, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ owner = 123; -+ ret = ioctl(objs[1], NTSYNC_IOC_MUTEX_KILL, &owner); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_any(fd, 2, objs, 456, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOWNERDEAD, errno); -+ EXPECT_EQ(1, index); -+ -+ ret = wait_any(fd, 2, objs, 456, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, index); -+ -+ close(objs[1]); -+ -+ /* test waiting on the same object twice */ -+ -+ count = 2; -+ ret = release_sem(objs[0], &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, count); -+ -+ objs[1] = objs[0]; -+ ret = wait_any(fd, 2, objs, 456, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(objs[0], 1, 3); -+ -+ ret = wait_any(fd, 0, NULL, 456, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ for (i = 1; i < NTSYNC_MAX_WAIT_COUNT + 1; ++i) -+ objs[i] = objs[0]; -+ -+ ret = wait_any(fd, NTSYNC_MAX_WAIT_COUNT, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ -+ ret = wait_any(fd, NTSYNC_MAX_WAIT_COUNT + 1, objs, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EINVAL, errno); -+ -+ ret = wait_any(fd, -1, objs, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EINVAL, errno); -+ -+ close(objs[0]); -+ -+ close(fd); -+} -+ -+TEST(test_wait_all) -+{ -+ struct ntsync_event_args event_args = {0}; -+ struct ntsync_mutex_args mutex_args = {0}; -+ struct ntsync_sem_args sem_args = {0}; -+ __u32 owner, index, count; -+ int objs[2], fd, ret; -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ sem_args.count = 2; -+ sem_args.max = 3; -+ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_LE(0, objs[0]); -+ -+ mutex_args.owner = 0; -+ mutex_args.count = 0; -+ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_LE(0, objs[1]); -+ -+ ret = wait_all(fd, 2, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(objs[0], 1, 3); -+ check_mutex_state(objs[1], 1, 123); -+ -+ ret = wait_all(fd, 2, objs, 456, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ check_sem_state(objs[0], 1, 3); -+ check_mutex_state(objs[1], 1, 123); -+ -+ ret = wait_all(fd, 2, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(objs[0], 0, 3); -+ check_mutex_state(objs[1], 2, 123); -+ -+ ret = wait_all(fd, 2, objs, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ check_sem_state(objs[0], 0, 3); -+ check_mutex_state(objs[1], 2, 123); -+ -+ count = 3; -+ ret = release_sem(objs[0], &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, count); -+ -+ ret = wait_all(fd, 2, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(objs[0], 2, 3); -+ check_mutex_state(objs[1], 3, 123); -+ -+ owner = 123; -+ ret = ioctl(objs[1], NTSYNC_IOC_MUTEX_KILL, &owner); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_all(fd, 2, objs, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EOWNERDEAD, errno); -+ check_sem_state(objs[0], 1, 3); -+ check_mutex_state(objs[1], 1, 123); -+ -+ close(objs[1]); -+ -+ event_args.manual = true; -+ event_args.signaled = true; -+ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, objs[1]); -+ -+ ret = wait_all(fd, 2, objs, 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ check_sem_state(objs[0], 0, 3); -+ check_event_state(objs[1], 1, 1); -+ -+ close(objs[1]); -+ -+ /* test waiting on the same object twice */ -+ objs[1] = objs[0]; -+ ret = wait_all(fd, 2, objs, 123, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(EINVAL, errno); -+ -+ close(objs[0]); -+ -+ close(fd); -+} -+ -+struct wake_args { -+ int fd; -+ int obj; -+}; -+ -+struct wait_args { -+ int fd; -+ unsigned long request; -+ struct ntsync_wait_args *args; -+ int ret; -+ int err; -+}; -+ -+static void *wait_thread(void *arg) -+{ -+ struct wait_args *args = arg; -+ -+ args->ret = ioctl(args->fd, args->request, args->args); -+ args->err = errno; -+ return NULL; -+} -+ -+static __u64 get_abs_timeout(unsigned int ms) -+{ -+ struct timespec timeout; -+ clock_gettime(CLOCK_MONOTONIC, &timeout); -+ return (timeout.tv_sec * 1000000000) + timeout.tv_nsec + (ms * 1000000); -+} -+ -+static int wait_for_thread(pthread_t thread, unsigned int ms) -+{ -+ struct timespec timeout; -+ -+ clock_gettime(CLOCK_REALTIME, &timeout); -+ timeout.tv_nsec += ms * 1000000; -+ timeout.tv_sec += (timeout.tv_nsec / 1000000000); -+ timeout.tv_nsec %= 1000000000; -+ return pthread_timedjoin_np(thread, NULL, &timeout); -+} -+ -+TEST(wake_any) -+{ -+ struct ntsync_event_args event_args = {0}; -+ struct ntsync_mutex_args mutex_args = {0}; -+ struct ntsync_wait_args wait_args = {0}; -+ struct ntsync_sem_args sem_args = {0}; -+ struct wait_args thread_args; -+ __u32 count, index, signaled; -+ int objs[2], fd, ret; -+ pthread_t thread; -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ sem_args.count = 0; -+ sem_args.max = 3; -+ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_LE(0, objs[0]); -+ -+ mutex_args.owner = 123; -+ mutex_args.count = 1; -+ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_LE(0, objs[1]); -+ -+ /* test waking the semaphore */ -+ -+ wait_args.timeout = get_abs_timeout(1000); -+ wait_args.objs = (uintptr_t)objs; -+ wait_args.count = 2; -+ wait_args.owner = 456; -+ wait_args.index = 0xdeadbeef; -+ thread_args.fd = fd; -+ thread_args.args = &wait_args; -+ thread_args.request = NTSYNC_IOC_WAIT_ANY; -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ count = 1; -+ ret = release_sem(objs[0], &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, count); -+ check_sem_state(objs[0], 0, 3); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, thread_args.ret); -+ EXPECT_EQ(0, wait_args.index); -+ -+ /* test waking the mutex */ -+ -+ /* first grab it again for owner 123 */ -+ ret = wait_any(fd, 1, &objs[1], 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ -+ wait_args.timeout = get_abs_timeout(1000); -+ wait_args.owner = 456; -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ ret = unlock_mutex(objs[1], 123, &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(2, count); -+ -+ ret = pthread_tryjoin_np(thread, NULL); -+ EXPECT_EQ(EBUSY, ret); -+ -+ ret = unlock_mutex(objs[1], 123, &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, mutex_args.count); -+ check_mutex_state(objs[1], 1, 456); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, thread_args.ret); -+ EXPECT_EQ(1, wait_args.index); -+ -+ close(objs[1]); -+ -+ /* test waking events */ -+ -+ event_args.manual = false; -+ event_args.signaled = false; -+ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, objs[1]); -+ -+ wait_args.timeout = get_abs_timeout(1000); -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ check_event_state(objs[1], 0, 0); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, thread_args.ret); -+ EXPECT_EQ(1, wait_args.index); -+ -+ wait_args.timeout = get_abs_timeout(1000); -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_PULSE, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ check_event_state(objs[1], 0, 0); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, thread_args.ret); -+ EXPECT_EQ(1, wait_args.index); -+ -+ close(objs[1]); -+ -+ event_args.manual = true; -+ event_args.signaled = false; -+ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, objs[1]); -+ -+ wait_args.timeout = get_abs_timeout(1000); -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ check_event_state(objs[1], 1, 1); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, thread_args.ret); -+ EXPECT_EQ(1, wait_args.index); -+ -+ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_RESET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, signaled); -+ -+ wait_args.timeout = get_abs_timeout(1000); -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ ret = ioctl(objs[1], NTSYNC_IOC_EVENT_PULSE, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ check_event_state(objs[1], 0, 1); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, thread_args.ret); -+ EXPECT_EQ(1, wait_args.index); -+ -+ /* delete an object while it's being waited on */ -+ -+ wait_args.timeout = get_abs_timeout(200); -+ wait_args.owner = 123; -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ close(objs[0]); -+ close(objs[1]); -+ -+ ret = wait_for_thread(thread, 200); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(-1, thread_args.ret); -+ EXPECT_EQ(ETIMEDOUT, thread_args.err); -+ -+ close(fd); -+} -+ -+TEST(wake_all) -+{ -+ struct ntsync_event_args manual_event_args = {0}; -+ struct ntsync_event_args auto_event_args = {0}; -+ struct ntsync_mutex_args mutex_args = {0}; -+ struct ntsync_wait_args wait_args = {0}; -+ struct ntsync_sem_args sem_args = {0}; -+ struct wait_args thread_args; -+ __u32 count, index, signaled; -+ int objs[4], fd, ret; -+ pthread_t thread; -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ sem_args.count = 0; -+ sem_args.max = 3; -+ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_LE(0, objs[0]); -+ -+ mutex_args.owner = 123; -+ mutex_args.count = 1; -+ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_LE(0, objs[1]); -+ -+ manual_event_args.manual = true; -+ manual_event_args.signaled = true; -+ objs[2] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &manual_event_args); -+ EXPECT_LE(0, objs[2]); -+ -+ auto_event_args.manual = false; -+ auto_event_args.signaled = true; -+ objs[3] = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &auto_event_args); -+ EXPECT_EQ(0, objs[3]); -+ -+ wait_args.timeout = get_abs_timeout(1000); -+ wait_args.objs = (uintptr_t)objs; -+ wait_args.count = 4; -+ wait_args.owner = 456; -+ thread_args.fd = fd; -+ thread_args.args = &wait_args; -+ thread_args.request = NTSYNC_IOC_WAIT_ALL; -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ count = 1; -+ ret = release_sem(objs[0], &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, count); -+ -+ ret = pthread_tryjoin_np(thread, NULL); -+ EXPECT_EQ(EBUSY, ret); -+ -+ check_sem_state(objs[0], 1, 3); -+ -+ ret = wait_any(fd, 1, &objs[0], 123, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ -+ ret = unlock_mutex(objs[1], 123, &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, count); -+ -+ ret = pthread_tryjoin_np(thread, NULL); -+ EXPECT_EQ(EBUSY, ret); -+ -+ check_mutex_state(objs[1], 0, 0); -+ -+ ret = ioctl(objs[2], NTSYNC_IOC_EVENT_RESET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, signaled); -+ -+ count = 2; -+ ret = release_sem(objs[0], &count); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, count); -+ check_sem_state(objs[0], 2, 3); -+ -+ ret = ioctl(objs[3], NTSYNC_IOC_EVENT_RESET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, signaled); -+ -+ ret = ioctl(objs[2], NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ -+ ret = ioctl(objs[3], NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, signaled); -+ -+ check_sem_state(objs[0], 1, 3); -+ check_mutex_state(objs[1], 1, 456); -+ check_event_state(objs[2], 1, 1); -+ check_event_state(objs[3], 0, 0); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, thread_args.ret); -+ -+ /* delete an object while it's being waited on */ -+ -+ wait_args.timeout = get_abs_timeout(200); -+ wait_args.owner = 123; -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ close(objs[0]); -+ close(objs[1]); -+ close(objs[2]); -+ close(objs[3]); -+ -+ ret = wait_for_thread(thread, 200); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(-1, thread_args.ret); -+ EXPECT_EQ(ETIMEDOUT, thread_args.err); -+ -+ close(fd); -+} -+ -+TEST(alert_any) -+{ -+ struct ntsync_event_args event_args = {0}; -+ struct ntsync_wait_args wait_args = {0}; -+ struct ntsync_sem_args sem_args = {0}; -+ __u32 index, count, signaled; -+ struct wait_args thread_args; -+ int objs[2], event, fd, ret; -+ pthread_t thread; -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ sem_args.count = 0; -+ sem_args.max = 2; -+ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_LE(0, objs[0]); -+ -+ sem_args.count = 1; -+ sem_args.max = 2; -+ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_LE(0, objs[1]); -+ -+ event_args.manual = true; -+ event_args.signaled = true; -+ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, event); -+ -+ ret = wait_any_alert(fd, 0, NULL, 123, event, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_any_alert(fd, 0, NULL, 123, event, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_any_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(1, index); -+ -+ ret = wait_any_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(2, index); -+ -+ /* test wakeup via alert */ -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); -+ EXPECT_EQ(0, ret); -+ -+ wait_args.timeout = get_abs_timeout(1000); -+ wait_args.objs = (uintptr_t)objs; -+ wait_args.count = 2; -+ wait_args.owner = 123; -+ wait_args.index = 0xdeadbeef; -+ wait_args.alert = event; -+ thread_args.fd = fd; -+ thread_args.args = &wait_args; -+ thread_args.request = NTSYNC_IOC_WAIT_ANY; -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, thread_args.ret); -+ EXPECT_EQ(2, wait_args.index); -+ -+ close(event); -+ -+ /* test with an auto-reset event */ -+ -+ event_args.manual = false; -+ event_args.signaled = true; -+ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, event); -+ -+ count = 1; -+ ret = release_sem(objs[0], &count); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_any_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ -+ ret = wait_any_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(2, index); -+ -+ ret = wait_any_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ close(event); -+ -+ close(objs[0]); -+ close(objs[1]); -+ -+ close(fd); -+} -+ -+TEST(alert_all) -+{ -+ struct ntsync_event_args event_args = {0}; -+ struct ntsync_wait_args wait_args = {0}; -+ struct ntsync_sem_args sem_args = {0}; -+ struct wait_args thread_args; -+ __u32 index, count, signaled; -+ int objs[2], event, fd, ret; -+ pthread_t thread; -+ -+ fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, fd); -+ -+ sem_args.count = 2; -+ sem_args.max = 2; -+ objs[0] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_LE(0, objs[0]); -+ -+ sem_args.count = 1; -+ sem_args.max = 2; -+ objs[1] = ioctl(fd, NTSYNC_IOC_CREATE_SEM, &sem_args); -+ EXPECT_LE(0, objs[1]); -+ -+ event_args.manual = true; -+ event_args.signaled = true; -+ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, event); -+ -+ ret = wait_all_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ -+ ret = wait_all_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(2, index); -+ -+ /* test wakeup via alert */ -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); -+ EXPECT_EQ(0, ret); -+ -+ wait_args.timeout = get_abs_timeout(1000); -+ wait_args.objs = (uintptr_t)objs; -+ wait_args.count = 2; -+ wait_args.owner = 123; -+ wait_args.index = 0xdeadbeef; -+ wait_args.alert = event; -+ thread_args.fd = fd; -+ thread_args.args = &wait_args; -+ thread_args.request = NTSYNC_IOC_WAIT_ALL; -+ ret = pthread_create(&thread, NULL, wait_thread, &thread_args); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(ETIMEDOUT, ret); -+ -+ ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_for_thread(thread, 100); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, thread_args.ret); -+ EXPECT_EQ(2, wait_args.index); -+ -+ close(event); -+ -+ /* test with an auto-reset event */ -+ -+ event_args.manual = false; -+ event_args.signaled = true; -+ event = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, event); -+ -+ count = 2; -+ ret = release_sem(objs[1], &count); -+ EXPECT_EQ(0, ret); -+ -+ ret = wait_all_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(0, index); -+ -+ ret = wait_all_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(0, ret); -+ EXPECT_EQ(2, index); -+ -+ ret = wait_all_alert(fd, 2, objs, 123, event, &index); -+ EXPECT_EQ(-1, ret); -+ EXPECT_EQ(ETIMEDOUT, errno); -+ -+ close(event); -+ -+ close(objs[0]); -+ close(objs[1]); -+ -+ close(fd); -+} -+ -+#define STRESS_LOOPS 10000 -+#define STRESS_THREADS 4 -+ -+static unsigned int stress_counter; -+static int stress_device, stress_start_event, stress_mutex; -+ -+static void *stress_thread(void *arg) -+{ -+ struct ntsync_wait_args wait_args = {0}; -+ __u32 index, count, i; -+ int ret; -+ -+ wait_args.timeout = UINT64_MAX; -+ wait_args.count = 1; -+ wait_args.objs = (uintptr_t)&stress_start_event; -+ wait_args.owner = gettid(); -+ wait_args.index = 0xdeadbeef; -+ -+ ioctl(stress_device, NTSYNC_IOC_WAIT_ANY, &wait_args); -+ -+ wait_args.objs = (uintptr_t)&stress_mutex; -+ -+ for (i = 0; i < STRESS_LOOPS; ++i) { -+ ioctl(stress_device, NTSYNC_IOC_WAIT_ANY, &wait_args); -+ -+ ++stress_counter; -+ -+ unlock_mutex(stress_mutex, wait_args.owner, &count); -+ } -+ -+ return NULL; -+} -+ -+TEST(stress_wait) -+{ -+ struct ntsync_event_args event_args; -+ struct ntsync_mutex_args mutex_args; -+ pthread_t threads[STRESS_THREADS]; -+ __u32 signaled, i; -+ int ret; -+ -+ stress_device = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); -+ ASSERT_LE(0, stress_device); -+ -+ mutex_args.owner = 0; -+ mutex_args.count = 0; -+ stress_mutex = ioctl(stress_device, NTSYNC_IOC_CREATE_MUTEX, &mutex_args); -+ EXPECT_LE(0, stress_mutex); -+ -+ event_args.manual = 1; -+ event_args.signaled = 0; -+ stress_start_event = ioctl(stress_device, NTSYNC_IOC_CREATE_EVENT, &event_args); -+ EXPECT_LE(0, stress_start_event); -+ -+ for (i = 0; i < STRESS_THREADS; ++i) -+ pthread_create(&threads[i], NULL, stress_thread, NULL); -+ -+ ret = ioctl(stress_start_event, NTSYNC_IOC_EVENT_SET, &signaled); -+ EXPECT_EQ(0, ret); -+ -+ for (i = 0; i < STRESS_THREADS; ++i) { -+ ret = pthread_join(threads[i], NULL); -+ EXPECT_EQ(0, ret); -+ } -+ -+ EXPECT_EQ(STRESS_LOOPS * STRESS_THREADS, stress_counter); -+ -+ close(stress_start_event); -+ close(stress_mutex); -+ close(stress_device); -+} -+ -+TEST_HARNESS_MAIN --- -2.51.0 - diff --git a/projects/ROCKNIX/packages/linux/patches/mainline/0006-stable-rocknix-joypad-dtsi.patch b/projects/ROCKNIX/packages/linux/patches/mainline/0006-stable-rocknix-joypad-dtsi.patch deleted file mode 100644 index f9bcc18d30a..00000000000 --- a/projects/ROCKNIX/packages/linux/patches/mainline/0006-stable-rocknix-joypad-dtsi.patch +++ /dev/null @@ -1,125 +0,0 @@ ---- /dev/null 2025-04-28 17:53:20.285890583 +0000 -+++ linux-6.12.17/arch/arm64/boot/dts/rockchip/retrogame_joypad_s2_f1.dtsi 2025-05-09 17:14:55.222064032 +0000 -@@ -0,0 +1,122 @@ -+/* -+ This is a skeleton of joypad with 2 sticks and FN (MODE) button. -+ Fits devices with 1 stick and 2 extra face buttons too. -+ By including this ans setting I/O properties only, -+ devices should get consistent controller id and mapping -+ thus reusing non-game configs: -+ * SDL gamecontrollerdb.txt -+ * ES es_input.cfg -+ * Retroarch gamepad -+*/ -+ -+/ { -+ joypad: retrogame_joypad_s2_f1 { -+ /* These drivers emit the same button set which makes this skeleton ADC-agnostic */ -+ /* compatible = "rocknix-joypad"; */ -+ /* compatible = "rocknix-singleadc-joypad"; */ -+ -+ /* These are constants making Joystick Guid the same */ -+ joypad-name = "retrogame_joypad_s2_f1"; -+ joypad-vendor = <0x484B>; -+ joypad-product = <0x1121>; /* 11 inherited, 2 for number of sticks, 1 for number of FN */ -+ joypad-revision = <0x0100>; -+ -+ /* require explicit status = "okay"; */ -+ status = "disabled"; -+ -+ /* adc calculate scale */ -+ button-adc-scale = <2>; -+ -+ /* adc deadzone range */ -+ button-adc-deadzone = <64>; -+ -+ /* -+ specifies fuzz value that is used to filter noise from -+ the event stream. -+ */ -+ button-adc-fuzz = <32>; -+ button-adc-flat = <32>; -+ -+ /* poll device interval (ms), adc read interval */ -+ poll-interval = <10>; -+ -+ /* gpio button auto repeat set value : default disable */ -+ /* -+ autorepeat; -+ */ -+ -+ /* meaningful node names for easier use */ -+ up { -+ label = "GPIO DPAD-UP"; -+ linux,code = ; -+ }; -+ down { -+ label = "GPIO DPAD-DOWN"; -+ linux,code = ; -+ }; -+ left { -+ label = "GPIO DPAD-LEFT"; -+ linux,code = ; -+ }; -+ right { -+ label = "GPIO DPAD-RIGHT"; -+ linux,code = ; -+ }; -+ -+ a { -+ label = "GPIO BTN-A"; -+ linux,code = ; -+ }; -+ b { -+ label = "GPIO BTN-B"; -+ linux,code = ; -+ }; -+ x { -+ label = "GPIO BTN-X"; -+ linux,code = ; -+ }; -+ y { -+ label = "GPIO BTN-Y"; -+ linux,code = ; -+ }; -+ -+ select { -+ label = "GPIO BTN_SELECT"; -+ linux,code = ; -+ }; -+ start { -+ label = "GPIO BTN_START"; -+ linux,code = ; -+ }; -+ mode { -+ label = "GPIO BTN_F"; -+ linux,code = ; -+ }; -+ -+ tl { -+ label = "GPIO BTN_TL"; -+ linux,code = ; -+ }; -+ tr { -+ label = "GPIO BTN_TR"; -+ linux,code = ; -+ }; -+ tl2 { -+ label = "GPIO BTN_TL2"; -+ linux,code = ; -+ }; -+ tr2 { -+ label = "GPIO BTN_TR2"; -+ linux,code = ; -+ }; -+ -+ thumbl { -+ label = "GPIO BTN_THUMBL"; -+ linux,code = ; -+ }; -+ thumbr { -+ label = "GPIO BTN_THUMBR"; -+ linux,code = ; -+ }; -+ }; -+};