diff --git a/packages/hardware/quirks/devices/Gameforce CHI/001-device_config b/packages/hardware/quirks/devices/Gameforce CHI/001-device_config new file mode 100644 index 000000000..65b60bc8f --- /dev/null +++ b/packages/hardware/quirks/devices/Gameforce CHI/001-device_config @@ -0,0 +1,17 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) + +cat </storage/.config/profile.d/001-device_config +# Device Features +DEVICE_VOLUMECTL="true" +DEVICE_POWER_LED="false" +DEVICE_PLAYBACK_PATH_SPK="HP" +DEVICE_PLAYBACK_PATH_HP="SPK" +DEVICE_BRIGHTNESS="128" +DEVICE_VOLUME="100" +DEVICE_BATTERY_LED_STATUS="true" +DEVICE_PWR_LED_GPIO="77" +DEVICE_TEMP_SENSOR="/sys/devices/virtual/thermal/thermal_zone0/temp" +DEVICE_MMC_EJECT="false" +EOF diff --git a/packages/hardware/quirks/devices/Gameforce CHI/002-start-input b/packages/hardware/quirks/devices/Gameforce CHI/002-start-input new file mode 100644 index 000000000..a4ec4930e --- /dev/null +++ b/packages/hardware/quirks/devices/Gameforce CHI/002-start-input @@ -0,0 +1,5 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) + +/usr/bin/gameforce-chi-gamepad diff --git a/packages/hardware/quirks/devices/Gameforce CHI/050-game_configs b/packages/hardware/quirks/devices/Gameforce CHI/050-game_configs new file mode 100644 index 000000000..88f79e326 --- /dev/null +++ b/packages/hardware/quirks/devices/Gameforce CHI/050-game_configs @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS) + +. /etc/profile + +#Set up gzdoom +if [ ! -d "/storage/.config/gzdoom/" ]; then + cp -rf /usr/config/gzdoom /storage/.config/ + sed -i '/Joy7=/c\Joy7=togglemap' /storage/.config/gzdoom/gzdoom.ini + sed -i '/Joy8=/c\Joy8=menu_main' /storage/.config/gzdoom/gzdoom.ini + sed -i '/Axis0scale=/c\Axis0scale=-0.8' /storage/.config/gzdoom/gzdoom.ini + sed -i '/Axis1scale=/c\Axis1scale=-0.6' /storage/.config/gzdoom/gzdoom.ini + sed -i '/vid_defheight=/c\vid_defheight=320' /storage/.config/gzdoom/gzdoom.ini + sed -i '/vid_defwidth=/c\vid_defwidth=480' /storage/.config/gzdoom/gzdoom.ini +fi + +#Map ppsspp controls +if grep RG351M -q "/stprage/.config/ppsspp/PSP/SYSTEM/controls.ini" +then + exit 1 +else +cat </storage/.config/ppsspp/PSP/SYSTEM/controls.ini +#RG351M +[ControlMapping] +Up = 10-19 +Down = 10-20 +Left = 10-21 +Right = 10-22 +Circle = 10-189 +Cross = 10-190 +Square = 10-188 +Triangle = 10-191 +Start = 10-197 +Select = 10-196 +L = 10-193 +R = 10-192 +An.Up = 10-4002 +An.Down = 10-4003 +An.Left = 10-4000 +An.Right = 10-4001 +Fast-forward = 1-61 +Pause = 10-106 +Save State = 10-4010 +Load State = 10-4008 +RightAn.Up = 10-4007 +RightAn.Down = 10-4006 +RightAn.Left = 10-4005 +RightAn.Right = 10-4004 +EOF +fi diff --git a/packages/hardware/quirks/devices/Gameforce CHI/050-modifiers b/packages/hardware/quirks/devices/Gameforce CHI/050-modifiers new file mode 100644 index 000000000..36df82c36 --- /dev/null +++ b/packages/hardware/quirks/devices/Gameforce CHI/050-modifiers @@ -0,0 +1,8 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) + +cat </storage/.config/profile.d/050-modifiers +DEVICE_FUNC_KEYA_MODIFIER="BTN_THUMBL" +DEVICE_FUNC_KEYB_MODIFIER="BTN_THUMBR" +EOF diff --git a/packages/hardware/quirks/devices/Gameforce CHI/100-jslisten-hotkey b/packages/hardware/quirks/devices/Gameforce CHI/100-jslisten-hotkey new file mode 100644 index 000000000..6b615ebd6 --- /dev/null +++ b/packages/hardware/quirks/devices/Gameforce CHI/100-jslisten-hotkey @@ -0,0 +1,8 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS) + +#Set dummy key for RG351M/P +cat </storage/.config/profile.d/100-jslisten-hotkey +BTN_VOLBRIGHT_HOTKEY=16 # Select +EOF diff --git a/packages/kernel/drivers/RTL8723DS/package.mk b/packages/kernel/drivers/RTL8723DS/package.mk new file mode 100644 index 000000000..67202e8de --- /dev/null +++ b/packages/kernel/drivers/RTL8723DS/package.mk @@ -0,0 +1,32 @@ +# 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) + +PKG_NAME="RTL8723DS" +PKG_VERSION="52e593e8c889b68ba58bd51cbdbcad7fe71362e4" +PKG_LICENSE="GPL" +PKG_ARCH="aarch64 x86_64" +PKG_SITE="https://github.com/lwfinger/rtl8723ds" +PKG_URL="https://github.com/lwfinger/rtl8723ds/archive/${PKG_VERSION}.tar.gz" +PKG_DEPENDS_TARGET="toolchain linux linux kernel-firmware" +PKG_NEED_UNPACK="${LINUX_DEPENDS}" +PKG_LONGDESC="Realtek RTL81xxEU Linux 3.x driver" +PKG_IS_KERNEL_PKG="yes" +PKG_TOOLCHAIN="make" + +pre_make_target() { + unset LDFLAGS +} + +make_target() { + make modules \ + 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/Rockchip/devices/RK3326/boot/boot.ini b/projects/Rockchip/devices/RK3326/boot/boot.ini index 443841164..53b20bb9d 100644 --- a/projects/Rockchip/devices/RK3326/boot/boot.ini +++ b/projects/Rockchip/devices/RK3326/boot/boot.ini @@ -24,13 +24,12 @@ elif test ${hwrev} = 'v10'; then elif test ${hwrev} = 'rg351v'; then load mmc 1:1 ${dtb_loadaddr} rk3326-anbernic-rg351v.dtb elif test ${hwrev} = 'r33s'; then -# if gpio input 11; then -# load mmc 1:1 ${dtb_loadaddr} rk3326-powkiddy-rgb20s.dtb -# else +# load mmc 1:1 ${dtb_loadaddr} rk3326-powkiddy-rgb20s.dtb load mmc 1:1 ${dtb_loadaddr} rk3326-gameconsole-r33s.dtb -# fi elif test ${hwrev} = 'xu10'; then load mmc 1:1 ${dtb_loadaddr} rk3326-magicx-xu10.dtb +elif test ${hwrev} = 'chi'; then + load mmc 1:1 ${dtb_loadaddr} rk3326-gameforce-chi.dtb fi booti ${loadaddr} - ${dtb_loadaddr} diff --git a/projects/Rockchip/devices/RK3326/linux/linux.aarch64.conf b/projects/Rockchip/devices/RK3326/linux/linux.aarch64.conf index f761e7e63..6b97635e4 100644 --- a/projects/Rockchip/devices/RK3326/linux/linux.aarch64.conf +++ b/projects/Rockchip/devices/RK3326/linux/linux.aarch64.conf @@ -2165,6 +2165,7 @@ CONFIG_JOYSTICK_ODROIDGO2_V11=y CONFIG_JOYSTICK_ODROIDGO3=y CONFIG_JOYSTICK_RGB20S=y CONFIG_JOYSTICK_XU10=y +CONFIG_JOYSTICK_GAMEFORCE_CHI=y # CONFIG_JOYSTICK_SENSEHAT is not set # CONFIG_INPUT_TABLET is not set # CONFIG_INPUT_TOUCHSCREEN is not set diff --git a/projects/Rockchip/devices/RK3326/options b/projects/Rockchip/devices/RK3326/options index 3fe6557cf..a9a1dddae 100644 --- a/projects/Rockchip/devices/RK3326/options +++ b/projects/Rockchip/devices/RK3326/options @@ -31,7 +31,7 @@ BOOTLOADER="u-boot" TRUST_LABEL="trust" PARTITION_TABLE="msdos" - DEVICE_DTB=("rk3326-anbernic-rg351m" "rk3326-anbernic-rg351v" "rk3326-gameconsole-r33s" "rk3326-gameconsole-r36s" "rk3326-odroid-go2" "rk3326-odroid-go2-v11" "rk3326-odroid-go3" "rk3326-powkiddy-rgb10" "rk3326-powkiddy-rgb20s" "rk3326-magicx-xu10") + DEVICE_DTB=("rk3326-anbernic-rg351m" "rk3326-anbernic-rg351v" "rk3326-gameconsole-r33s" "rk3326-gameconsole-r36s" "rk3326-gameforce-chi" "rk3326-odroid-go2" "rk3326-odroid-go2-v11" "rk3326-odroid-go3" "rk3326-powkiddy-rgb10" "rk3326-powkiddy-rgb20s" "rk3326-magicx-xu10") UBOOT_DTB="${DEVICE_DTB[0]}" UBOOT_CONFIG="odroidgoa_defconfig" PKG_SOC="px30" @@ -84,7 +84,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" + ADDITIONAL_DRIVERS="RTL8812AU RTL8814AU RTL8821AU RTL8821CU RTL88x2BU RTL8723DS" # build and install driver addons (yes / no) DRIVER_ADDONS_SUPPORT="no" diff --git a/projects/Rockchip/packages/linux/patches/RK3326/000-rk3326-dts.patch b/projects/Rockchip/packages/linux/patches/RK3326/000-rk3326-dts.patch index 5f2b03da5..10c728606 100644 --- a/projects/Rockchip/packages/linux/patches/RK3326/000-rk3326-dts.patch +++ b/projects/Rockchip/packages/linux/patches/RK3326/000-rk3326-dts.patch @@ -1,13 +1,14 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/Makefile linux/arch/arm64/boot/dts/rockchip/Makefile ---- linux.orig/arch/arm64/boot/dts/rockchip/Makefile 2024-02-03 14:24:30.507369024 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/Makefile 2024-02-03 14:49:01.857898202 +0000 -@@ -9,9 +9,15 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3308-ro +--- linux.orig/arch/arm64/boot/dts/rockchip/Makefile 2024-02-15 14:44:49.334307319 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/Makefile 2024-02-17 06:35:22.915906533 +0000 +@@ -9,9 +9,16 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3308-ro dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3308-rock-pi-s.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3318-a95x-z2.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3326-anbernic-rg351m.dtb +dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3326-anbernic-rg351v.dtb +dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3326-gameconsole-r33s.dtb +dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3326-gameconsole-r36s.dtb ++dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3326-gameforce-chi.dtb +dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3326-magicx-xu10.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3326-odroid-go2.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3326-odroid-go2-v11.dtb @@ -18,8 +19,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/Makefile linux/arch/arm64/boo dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3328-evb.dtb dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3328-nanopi-r2c.dtb diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/px30.dtsi linux/arch/arm64/boot/dts/rockchip/px30.dtsi ---- linux.orig/arch/arm64/boot/dts/rockchip/px30.dtsi 2024-02-03 14:24:30.507369024 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/px30.dtsi 2024-02-03 14:25:41.221185291 +0000 +--- linux.orig/arch/arm64/boot/dts/rockchip/px30.dtsi 2024-02-15 14:44:49.334307319 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/px30.dtsi 2024-02-17 06:32:20.483322663 +0000 @@ -114,32 +114,22 @@ compatible = "operating-points-v2"; opp-shared; @@ -118,8 +119,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/px30.dtsi linux/arch/arm64/bo }; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts linux/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts ---- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts 2024-02-03 14:24:30.507369024 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts 2024-02-03 14:25:41.221185291 +0000 +--- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts 2024-02-15 14:44:49.334307319 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts 2024-02-17 06:32:20.483322663 +0000 @@ -12,6 +12,25 @@ model = "Anbernic RG351M"; compatible = "anbernic,rg351m", "rockchip,rk3326"; @@ -172,7 +173,7 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351m.dts li +}; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts linux/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts --- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts 1970-01-01 00:00:00.000000000 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts 2024-02-03 14:25:41.221185291 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts 2024-02-17 06:32:20.483322663 +0000 @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* @@ -300,7 +301,7 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-anbernic-rg351v.dts li +}; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r33s.dts linux/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r33s.dts --- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r33s.dts 1970-01-01 00:00:00.000000000 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r33s.dts 2024-02-03 14:53:29.435899433 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r33s.dts 2024-02-17 06:32:20.483322663 +0000 @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* @@ -421,7 +422,7 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r33s.dts l +}; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36s.dts linux/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36s.dts --- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36s.dts 1970-01-01 00:00:00.000000000 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36s.dts 2024-02-03 14:56:33.563329307 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36s.dts 2024-02-17 06:32:20.483322663 +0000 @@ -0,0 +1,207 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* @@ -632,7 +633,7 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36s.dts l +}; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r3xs.dtsi linux/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r3xs.dtsi --- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r3xs.dtsi 1970-01-01 00:00:00.000000000 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r3xs.dtsi 2024-02-03 14:46:31.754519839 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r3xs.dtsi 2024-02-17 06:32:20.483322663 +0000 @@ -0,0 +1,545 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* @@ -1179,9 +1180,828 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r3xs.dtsi + }; + }; +}; +diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameforce-chi.dts linux/arch/arm64/boot/dts/rockchip/rk3326-gameforce-chi.dts +--- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-gameforce-chi.dts 1970-01-01 00:00:00.000000000 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-gameforce-chi.dts 2024-02-17 06:34:23.866426919 +0000 +@@ -0,0 +1,815 @@ ++// 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 ++ * Copyright (c) 2024 Batocera https://github.com/batocera-linux/batocera.linux/blob/master/board/batocera/rockchip/rk3326/linux_patches/0002-rk3326-gameforce-dts.patch ++ * Copyright (c) 2024 Juliano Dorigão ++ */ ++ ++/dts-v1/; ++#include ++#include ++#include ++#include ++#include "rk3326.dtsi" ++ ++/ { ++ model = "Gameforce CHI"; ++ compatible = "gameforce,chi", "rockchip,rk3326"; ++ ++ 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 = <200>; ++ }; ++ ++ adc-keys { ++ compatible = "volume-keys"; ++ keyup-threshold-microvolt = <1800000>; ++ ++ happy1-key { ++ linux,code = ; ++ label = "volume down"; ++ press-threshold-microvolt = <15000>; ++ }; ++ ++ happy2-key { ++ linux,code = ; ++ label = "volume up"; ++ press-threshold-microvolt = <300000>; ++ }; ++ }; ++ ++ vibrators { ++ compatible = "gpio,vibrators"; ++ vibrator0-gpio = <&gpio3 RK_PC3 GPIO_ACTIVE_HIGH>; ++ vibrator1-gpio = <&gpio3 RK_PC2 GPIO_ACTIVE_HIGH>; ++ status = "okay"; ++ }; ++ ++ joypad: gameforce-gamepad { ++ compatible = "gameforce-gamepad"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&btn_pins>; ++ ++ io-channel-names = "joy_x", "joy_y", "volume-buttons"; ++ io-channels = <&saradc 0>, <&saradc 1>, <&saradc 2>; ++ ++ button-adc-count = <2>; ++ button-adc-scale = <2>; ++ button-adc-deadzone = <20>; ++ ++ button-adc-x-range = <1800>; ++ button-adc-y-range = <1800>; ++ ++ button-adc-fuzz = <32>; ++ button-adc-flat = <32>; ++ ++ poll-interval = <10>; ++ ++ 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 = <&gpio2 RK_PB0 GPIO_ACTIVE_LOW>; ++ label = "BTN-A"; ++ linux,code = ; ++ }; ++ ++ button-sw6 { ++ gpios = <&gpio2 RK_PB1 GPIO_ACTIVE_LOW>; ++ label = "BTN-B"; ++ linux,code = ; ++ }; ++ ++ button-sw7 { ++ gpios = <&gpio2 RK_PB2 GPIO_ACTIVE_LOW>; ++ label = "BTN-Y"; ++ linux,code = ; ++ }; ++ ++ button-sw8 { ++ gpios = <&gpio2 RK_PB3 GPIO_ACTIVE_LOW>; ++ label = "BTN-X"; ++ linux,code = ; ++ }; ++ ++ btn_home: button-sw9 { ++ gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>; ++ label = "BTN-HOME"; ++ linux,code = ; ++ }; ++ ++ btn_select: button-sw10 { ++ gpios = <&gpio2 RK_PA3 GPIO_ACTIVE_LOW>; ++ label = "BTN-SET"; ++ linux,code = ; ++ }; ++ ++ btn_start: button-sw11 { ++ gpios = <&gpio2 RK_PA2 GPIO_ACTIVE_LOW>; ++ label = "BTN-START"; ++ linux,code = ; ++ }; ++ ++ button-sw12 { ++ gpios = <&gpio2 RK_PA6 GPIO_ACTIVE_LOW>; ++ label = "TOP-LEFT"; ++ linux,code = ; ++ }; ++ ++ button-sw13 { ++ gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_LOW>; ++ label = "TOP-LEFT2"; ++ linux,code = ; ++ }; ++ ++ button-sw14 { ++ gpios = <&gpio2 RK_PA7 GPIO_ACTIVE_LOW>; ++ label = "TOP-RIGHT"; ++ linux,code = ; ++ }; ++ ++ button-sw15 { ++ gpios = <&gpio2 RK_PA5 GPIO_ACTIVE_LOW>; ++ label = "TOP-RIGHT2"; ++ linux,code = ; ++ }; ++ }; ++ ++ leds: gpio_leds { ++ compatible = "gpio-leds"; ++ pinctrl-names = "led_pins"; ++ pinctrl-0 = <&led_pins>; ++ ++ heartbeat { ++ label = "heartbeat"; ++ gpios = <&gpio3 RK_PB3 GPIO_ACTIVE_HIGH>; ++ linux,default-trigger = "heartbeat"; ++ }; ++ ++ red { ++ label = "red"; ++ gpios = <&gpio3 RK_PC4 GPIO_ACTIVE_HIGH>; ++ default-state = "off"; ++ }; ++ ++ green { ++ label = "green"; ++ gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_HIGH>; ++ default-state = "off"; ++ }; ++ ++ blue { ++ label = "blue"; ++ gpios = <&gpio3 RK_PC6 GPIO_ACTIVE_HIGH>; ++ default-state = "off"; ++ }; ++ }; ++ ++ rk817-sound { ++ compatible = "simple-audio-card"; ++ 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", "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>; ++ }; ++ }; ++ ++ 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"; ++ }; ++ ++ wifi_pwrseq: wifi-pwrseq { ++ compatible = "mmc-pwrseq-simple"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&wifi_pwrseq_pins>; ++ reset-gpios = <&gpio0 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 = <1500000>; ++ constant-charge-voltage-max-microvolt = <4200000>; ++ factory-internal-resistance-micro-ohms = <180000>; ++ voltage-max-design-microvolt = <4100000>; ++ voltage-min-design-microvolt = <3400000>; ++ ++ 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>; ++ }; ++ ++ vccsys: vccsys { ++ compatible = "regulator-fixed"; ++ regulator-name = "vcc3v8_sys"; ++ regulator-always-on; ++ regulator-min-microvolt = <3800000>; ++ regulator-max-microvolt = <3800000>; ++ }; ++ ++ vcc_host: 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>; ++ }; ++}; ++ ++&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 = "gameforce,chi-panel"; ++ reg = <0>; ++ backlight = <&backlight>; ++ reset-gpios = <&gpio3 RK_PC0 GPIO_ACTIVE_LOW>; ++ rotation = <0>; ++ iovcc-supply = <&vcc_lcd>; ++ vdd-supply = <&vcc_lcd>; ++ ++ port { ++ mipi_in_panel: endpoint { ++ remote-endpoint = <&mipi_out_panel>; ++ }; ++ }; ++ }; ++}; ++ ++&dsi_dphy { ++ status = "okay"; ++}; ++ ++&emmc { ++ status = "disabled"; ++}; ++ ++ ++&sfc { ++ status = "disabled"; ++}; ++ ++&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", "rk808-clkout2"; ++ 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-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_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_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>; ++ }; ++ }; ++ ++ 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 = <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>; ++ }; ++ }; ++}; ++ ++/* EXT Header(P2): 7(SCL:GPIO0.C2), 8(SDA:GPIO0.C3) */ ++&i2c1 { ++ clock-frequency = <400000>; ++ status = "disabled"; ++}; ++ ++/* MIPI CSI I2C */ ++&i2c2 { ++ status = "disabled"; ++}; ++ ++/* I2S 1 Channel Used */ ++&i2s1_2ch { ++ status = "okay"; ++ #sound-dai-cells = <0>; ++}; ++ ++&io_domains { ++ vccio1-supply = <&vcc3v0_pmu>; ++ vccio2-supply = <&vccio_sd>; ++ vccio3-supply = <&vcc_3v0>; ++ vccio4-supply = <&vcc_3v0>; ++ vccio5-supply = <&vcc_3v0>; ++ vccio6-supply = <&vcc_3v0>; ++ status = "okay"; ++}; ++ ++&isp_mmu { ++ status = "okay"; ++}; ++ ++&spi0 { ++ status = "disabled"; ++}; ++ ++&pmu_io_domains { ++ pmuio1-supply = <&vcc_1v8>; ++ pmuio2-supply = <&vcc3v0_pmu>; ++ status = "okay"; ++}; ++ ++&pwm1 { ++ status = "okay"; ++}; ++ ++&pwm3 { ++ status = "okay"; ++}; ++ ++&saradc { ++ vref-supply = <&vcc_1v8>; ++ status = "okay"; ++}; ++ ++&sdmmc { ++ bus-width = <4>; ++ cap-mmc-highspeed; ++ cap-sd-highspeed; ++ supports-sd; ++ card-detect-delay = <800>; ++ ignore-pm-notify; ++ 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"; ++}; ++ ++&sdio { ++ bus-width = <4>; ++ cap-sd-highspeed; ++ cap-sdio-irq; ++ disable-wp; ++ supports-sdio; ++ ignore-pm-notify; ++ keep-power-in-suspend; ++ non-removable; ++ mmc-pwrseq = <&wifi_pwrseq>; ++ sd-uhs-sdr104; ++ status = "okay"; ++ ++ rtl8723ds: wifi@1 { ++ compatible = "wlan-platdata"; ++ rockchip,grf = <&grf>; ++ wifi_chip_type = "realtek,rtl8723ds"; ++ WIFI,host_wake_irq = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>; ++ sdio_vref = <3300>; ++ 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 = "disable"; ++ }; ++}; ++/* ++&uart0 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&uart0_xfer &uart0_cts>; ++ 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"; ++}; ++ ++&rk817_charger { ++ monitored-battery = <&battery>; ++}; ++ ++&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_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>, ++ <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>; ++ }; ++ }; ++ ++ audio-amplifier { ++ spk_amp_enable_h: spk-amp-enable-h { ++ rockchip,pins = <2 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>; ++ }; ++ }; ++ ++ headphone { ++ hp_det: hp-det { ++ rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>; ++ }; ++ }; ++ ++ leds { ++ led_pins: led-pins { ++ rockchip,pins = <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 { ++ 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>; ++ }; ++ }; ++ ++ wifi { ++ wifi_pwrseq_pins: wifi-pwrseq-pins { ++ rockchip,pins = <0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>; ++ }; ++ }; ++}; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu10.dts linux/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu10.dts --- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu10.dts 1970-01-01 00:00:00.000000000 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu10.dts 2024-02-03 14:25:41.221185291 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu10.dts 2024-02-17 06:32:20.483322663 +0000 @@ -0,0 +1,828 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* @@ -2012,8 +2832,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-magicx-xu10.dts linux/ + }; +}; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi ---- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi 2024-02-03 14:24:30.507369024 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi 2024-02-03 14:25:41.221185291 +0000 +--- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi 2024-02-15 14:44:49.334307319 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi 2024-02-17 06:32:20.487322762 +0000 @@ -25,93 +25,40 @@ compatible = "pwm-backlight"; power-supply = <&vcc_bl>; @@ -2170,8 +2990,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go.dtsi linux/a #clock-cells = <1>; #sound-dai-cells = <0>; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts ---- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts 2024-02-03 14:24:30.507369024 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts 2024-02-03 14:25:41.221185291 +0000 +--- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts 2024-02-15 14:44:49.334307319 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts 2024-02-17 06:32:20.487322762 +0000 @@ -16,31 +16,187 @@ mmc1 = &sdio; }; @@ -2453,8 +3273,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2-v11.dts lin <2 RK_PA5 RK_FUNC_GPIO &pcfg_pull_up>, <2 RK_PA6 RK_FUNC_GPIO &pcfg_pull_up>, diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts ---- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts 2024-02-03 14:24:30.507369024 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts 2024-02-03 14:25:41.221185291 +0000 +--- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts 2024-02-15 14:44:49.334307319 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts 2024-02-17 06:32:20.487322762 +0000 @@ -12,30 +12,175 @@ model = "ODROID-GO Advance"; compatible = "hardkernel,rk3326-odroid-go2", "rockchip,rk3326"; @@ -2687,8 +3507,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts linux/a + }; +}; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts ---- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts 2024-02-03 14:24:30.507369024 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts 2024-02-03 14:25:41.221185291 +0000 +--- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts 2024-02-15 14:44:49.334307319 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts 2024-02-17 06:32:20.487322762 +0000 @@ -12,67 +12,196 @@ model = "ODROID-GO Super"; compatible = "hardkernel,rk3326-odroid-go3", "rockchip,rk3326"; @@ -2998,7 +3818,7 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-odroid-go3.dts linux/a }; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10.dts linux/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10.dts --- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10.dts 1970-01-01 00:00:00.000000000 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10.dts 2024-02-03 14:25:41.221185291 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10.dts 2024-02-17 06:32:20.487322762 +0000 @@ -0,0 +1,280 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* @@ -3282,7 +4102,7 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb10.dts lin +}; diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb20s.dts linux/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb20s.dts --- linux.orig/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb20s.dts 1970-01-01 00:00:00.000000000 +0000 -+++ linux/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb20s.dts 2024-02-03 14:25:41.221185291 +0000 ++++ linux/arch/arm64/boot/dts/rockchip/rk3326-powkiddy-rgb20s.dts 2024-02-17 06:32:20.487322762 +0000 @@ -0,0 +1,340 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* diff --git a/projects/Rockchip/packages/linux/patches/RK3326/001-panel-updates.patch b/projects/Rockchip/packages/linux/patches/RK3326/001-panel-updates.patch index fd554be65..7538dbdd5 100644 --- a/projects/Rockchip/packages/linux/patches/RK3326/001-panel-updates.patch +++ b/projects/Rockchip/packages/linux/patches/RK3326/001-panel-updates.patch @@ -1,6 +1,6 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-elida-kd35t133.c linux/drivers/gpu/drm/panel/panel-elida-kd35t133.c ---- linux.orig/drivers/gpu/drm/panel/panel-elida-kd35t133.c 2024-01-29 19:42:59.344227350 +0000 -+++ linux/drivers/gpu/drm/panel/panel-elida-kd35t133.c 2024-01-29 19:46:14.500635108 +0000 +--- linux.orig/drivers/gpu/drm/panel/panel-elida-kd35t133.c 2024-02-15 14:44:51.546356020 +0000 ++++ linux/drivers/gpu/drm/panel/panel-elida-kd35t133.c 2024-02-15 15:05:47.414681181 +0000 @@ -109,6 +109,8 @@ static int kd35t133_unprepare(struct drm regulator_disable(ctx->iovcc); regulator_disable(ctx->vdd); @@ -11,8 +11,8 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-elida-kd35t133.c linux/drivers return 0; diff -rupN linux.orig/drivers/gpu/drm/panel/panel-newvision-nv3051d.c linux/drivers/gpu/drm/panel/panel-newvision-nv3051d.c ---- linux.orig/drivers/gpu/drm/panel/panel-newvision-nv3051d.c 2024-01-29 19:42:59.344227350 +0000 -+++ linux/drivers/gpu/drm/panel/panel-newvision-nv3051d.c 2024-01-29 21:01:52.715952484 +0000 +--- linux.orig/drivers/gpu/drm/panel/panel-newvision-nv3051d.c 2024-02-15 14:44:51.550356106 +0000 ++++ linux/drivers/gpu/drm/panel/panel-newvision-nv3051d.c 2024-02-15 15:05:47.414681181 +0000 @@ -28,6 +28,7 @@ struct nv3051d_panel_info { unsigned int num_modes; u16 width_mm, height_mm; @@ -99,8 +99,8 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-newvision-nv3051d.c linux/driv }; MODULE_DEVICE_TABLE(of, newvision_nv3051d_of_match); diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/drivers/gpu/drm/panel/panel-sitronix-st7703.c ---- linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c 2024-01-29 19:42:59.348227440 +0000 -+++ linux/drivers/gpu/drm/panel/panel-sitronix-st7703.c 2024-01-29 19:46:14.500635108 +0000 +--- linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c 2024-02-15 14:44:51.554356195 +0000 ++++ linux/drivers/gpu/drm/panel/panel-sitronix-st7703.c 2024-02-15 15:10:41.576698949 +0000 @@ -13,7 +13,7 @@ #include #include @@ -334,7 +334,193 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver 0x00, 0x09, 0x0D, 0x23, 0x27, 0x3C, 0x41, 0x35, 0x07, 0x0D, 0x0E, 0x12, 0x13, 0x10, 0x12, 0x12, 0x18, 0x00, 0x09, 0x0D, 0x23, 0x27, 0x3C, 0x41, -@@ -341,7 +361,15 @@ static const struct st7703_panel_desc xb +@@ -333,6 +353,185 @@ static const struct drm_display_mode xbd + .height_mm = 136, + }; + ++ ++// Copyright (C) Batocera (https://github.com/batocera-linux/batocera.linux/blob/master/board/batocera/rockchip/rk3326/linux_patches/0001-gameforce-panel-st7703.patch) ++static int gameforce_init_sequence(struct st7703 *ctx) ++{ ++ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); ++ ++ /* ++ * Init sequence was supplied by the panel vendor. ++ */ ++ ++ /* Magic sequence to unlock user commands below. */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETEXTC, 0xF1, 0x12, 0x83); ++ msleep(20); ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETMIPI, ++ 0x31, /* VC_main = 0, Lane_Number = 3 (4 lanes) */ ++ 0x81, /* DSI_LDO_SEL = 1.7V, RTERM = 90 Ohm */ ++ 0x05, /* IHSRX = x6 (Low High Speed driving ability) */ ++ 0xF9, /* TX_CLK_SEL = fDSICLK/16 */ ++ 0x0E, /* HFP_OSC (min. HFP number in DSI mode) */ ++ 0x0E, /* HBP_OSC (min. HBP number in DSI mode) */ ++ /* The rest is undocumented in ST7703 datasheet */ ++ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x44, 0x25, 0x00, 0x91, 0x0a, 0x00, 0x00, 0x02, ++ 0x4F, 0xD1, 0x00, 0x00, 0x37); ++ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER_EXT, 0x25); /* PCCS = 2, ECP_DC_DIV = 1/4 HSYNC */ ++ ++ /* Undocumented command. */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_UNKNOWN_BF, 0x02, 0x11, 0x00); ++ ++ /* RGB I/F porch timing */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETRGBIF, ++ 0x0C, /* VBP_RGB_GEN */ ++ 0x10, /* VFP_RGB_GEN */ ++ 0x0A, /* DE_BP_RGB_GEN */ ++ 0x50, /* DE_FP_RGB_GEN */ ++ /* The rest is undocumented in ST7703 datasheet */ ++ 0x03, 0xFF, ++ 0x00, 0x00, ++ 0x00, 0x00); ++ ++ /* Source driving settings. */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETSCR, ++ 0x73, /* N_POPON */ ++ 0x73, /* N_NOPON */ ++ 0x50, /* I_POPON */ ++ 0x50, /* I_NOPON */ ++ 0x00, /* SCR[31,24] */ ++ 0x00, /* SCR[23,16] */ ++ 0x08, /* SCR[15,8] */ ++ 0x70, /* SCR[7,0] */ ++ 0x00 /* Undocumented */); ++ ++ /* NVDDD_SEL = -1.8V, VDDD_SEL = out of range (possibly 1.9V?) */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETVDC, 0x46); ++ ++ /* ++ * SS_PANEL = 1 (reverse scan), GS_PANEL = 0 (normal scan) ++ * REV_PANEL = 1 (normally black panel), BGR_PANEL = 1 (BGR) ++ */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETPANEL, 0x0B); ++ ++ /* Zig-Zag Type C column inversion. */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETCYC, 0x80); ++ ++ /* Set display resolution. */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETDISP, ++ 0x00, /* NL = 480 */ ++ 0x13, /* RES_V_LSB = 0, BLK_CON = VSSD, ++ * RESO_SEL = 720RGB ++ */ ++ 0xF0 /* WHITE_GND_EN = 1 (GND), ++ * WHITE_FRAME_SEL = 7 frames, ++ * ISC = 0 frames ++ */); ++ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETEQ, ++ 0x07, /* PNOEQ */ ++ 0x07, /* NNOEQ */ ++ 0x0B, /* PEQGND */ ++ 0x0B, /* NEQGND */ ++ 0x03, /* PEQVCI */ ++ 0x0B, /* NEQVCI */ ++ 0x00, /* PEQVCI1 */ ++ 0x00, /* NEQVCI1 */ ++ 0x00, /* reserved */ ++ 0x00, /* reserved */ ++ 0xFF, /* reserved */ ++ 0x00, /* reserved */ ++ 0xC0, /* ESD_DET_DATA_WHITE = 1, ESD_WHITE_EN = 1 */ ++ 0x10 /* SLPIN_OPTION = 1 (no need vsync after sleep-in) ++ * VEDIO_NO_CHECK_EN = 0 ++ * ESD_WHITE_GND_EN = 0 ++ * ESD_DET_TIME_SEL = 0 frames ++ */); ++ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER, ++ 0x53, /* VBTHS, VBTLS: VGH = 17V, VBL = -11V */ ++ 0x00, /* FBOFF_VGH = 0, FBOFF_VGL = 0 */ ++ 0x1E, /* VRP */ ++ 0x1E, /* VRN */ ++ 0x77, /* reserved */ ++ 0xE1, /* APS = 1 (small), ++ * VGL_DET_EN = 1, VGH_DET_EN = 1, ++ * VGL_TURBO = 1, VGH_TURBO = 1 ++ */ ++ 0xCC, /* VGH1_L_DIV, VGL1_L_DIV (1.5MHz) */ ++ 0xDD, /* VGH1_R_DIV, VGL1_R_DIV (1.5MHz) */ ++ 0x67, /* VGH2_L_DIV, VGL2_L_DIV (2.6MHz) */ ++ 0x77, /* VGH2_R_DIV, VGL2_R_DIV (2.6MHz) */ ++ 0x33, /* VGH3_L_DIV, VGL3_L_DIV (4.5MHz) */ ++ 0x33 /* VGH3_R_DIV, VGL3_R_DIV (4.5MHz) */); ++ ++ /* Reference voltage. */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETBGP, ++ 0x10, /* VREF_SEL = 4.2V */ ++ 0x10 /* NVREF_SEL = 4.2V */); ++ msleep(20); ++ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETVCOM, ++ 0x6C, /* VCOMDC_F = -0.67V */ ++ 0x7C /* VCOMDC_B = -0.67V */); ++ ++ /* This command is to set forward GIP timing. */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETGIP1, ++ 0x08, 0x00, 0x0E, 0x00, 0x00, 0xB0, 0xB1, 0x11, ++ 0x31, 0x23, 0x28, 0x10, 0xB0, 0xB1, 0x27, 0x08, ++ 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, ++ 0x02, 0x00, 0x00, 0x00, 0x88, 0x88, 0xBA, 0x60, ++ 0x24, 0x08, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, ++ 0x88, 0xBA, 0x71, 0x35, 0x18, 0x88, 0x88, 0x88, ++ 0x88, 0x88, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); ++ ++ /* This command is to set backward GIP timing. */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETGIP2, ++ 0x97, 0x0A, 0x82, 0x02, 0x13, 0x07, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x80, 0x88, 0xBA, 0x17, ++ 0x53, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x81, ++ 0x88, 0xBA, 0x06, 0x42, 0x88, 0x88, 0x88, 0x88, ++ 0x88, 0x88, 0x23, 0x10, 0x00, 0x02, 0x80, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x00, 0x00); ++ ++ /* Adjust the gamma characteristics of the panel. */ ++ mipi_dsi_dcs_write_seq(dsi, ST7703_CMD_SETGAMMA, ++ 0x00, 0x07, 0x0B, 0x27, 0x2D, 0x3F, 0x3B, 0x37, ++ 0x05, 0x0A, 0x0B, 0x0F, 0x11, 0x0F, 0x12, 0x12, ++ 0x18, 0x00, 0x07, 0x0B, 0x27, 0x2D, 0x3F, 0x3B, ++ 0x37, 0x05, 0x0A, 0x0B, 0x0F, 0x11, 0x0F, 0x12, ++ 0x12, 0x18); ++ ++ return 0; ++} ++ ++static const struct drm_display_mode gameforce_mode = { ++ .hdisplay = 640, ++ .hsync_start = 640 + 120, ++ .hsync_end = 640 + 120 + 120, ++ .htotal = 640 + 120 + 120 + 120, ++ .vdisplay = 480, ++ .vsync_start = 480 + 13, ++ .vsync_end = 480 + 13 + 17, ++ .vtotal = 480 + 13 + 17 + 5, ++ .clock = 30900, ++ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, ++ .width_mm = 53, ++ .height_mm = 71, ++}; ++ ++static const struct st7703_panel_desc gameforce_desc = { ++ .mode = &gameforce_mode, ++ .lanes = 2, ++ .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM /*| MIPI_DSI_MODE_EOT_PACKET*/, ++ .format = MIPI_DSI_FMT_RGB888, ++ .init_sequence = gameforce_init_sequence, ++}; ++ + static const struct st7703_panel_desc xbd599_desc = { + .mode = &xbd599_mode, + .lanes = 4, +@@ -341,7 +540,15 @@ static const struct st7703_panel_desc xb .init_sequence = xbd599_init_sequence, }; @@ -351,7 +537,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver { struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); -@@ -349,44 +377,44 @@ static int rg353v2_init_sequence(struct +@@ -349,44 +556,44 @@ static int rg353v2_init_sequence(struct * Init sequence was supplied by the panel vendor. */ @@ -416,7 +602,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver 0x00, 0xb0, 0xb1, 0x11, 0x31, 0x23, 0x28, 0x80, 0xb0, 0xb1, 0x27, 0x08, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, -@@ -395,7 +423,7 @@ static int rg353v2_init_sequence(struct +@@ -395,7 +602,7 @@ static int rg353v2_init_sequence(struct 0x18, 0x88, 0x88, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); @@ -425,7 +611,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver 0x03, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x88, 0xba, 0x17, 0x53, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x80, 0x88, 0xba, 0x06, 0x42, -@@ -404,12 +432,12 @@ static int rg353v2_init_sequence(struct +@@ -404,12 +611,12 @@ static int rg353v2_init_sequence(struct 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); @@ -440,7 +626,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver .hdisplay = 640, .hsync_start = 640 + 40, .hsync_end = 640 + 40 + 2, -@@ -424,15 +452,210 @@ static const struct drm_display_mode rg3 +@@ -424,15 +631,210 @@ static const struct drm_display_mode rg3 .height_mm = 57, }; @@ -448,13 +634,14 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver - .mode = &rg353v2_mode, +static const struct st7703_panel_desc rg351v2_desc = { + .mode = &rg351v2_mode, -+ .lanes = 4, -+ .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | -+ MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_LPM, -+ .format = MIPI_DSI_FMT_RGB888, + .lanes = 4, + .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | + MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_LPM, + .format = MIPI_DSI_FMT_RGB888, +- .init_sequence = rg353v2_init_sequence, + .init_sequence = rg351v2_init_sequence, -+}; -+ + }; + +static int xu10_init_sequence(struct st7703 *ctx) +{ + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); @@ -542,14 +729,13 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver + +static const struct st7703_panel_desc xu10_desc = { + .mode = &xu10_mode, - .lanes = 4, - .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | - MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_LPM, - .format = MIPI_DSI_FMT_RGB888, -- .init_sequence = rg353v2_init_sequence, ++ .lanes = 4, ++ .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | ++ MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_LPM, ++ .format = MIPI_DSI_FMT_RGB888, + .init_sequence = xu10_init_sequence, - }; - ++}; ++ +static int r36s_init_sequence(struct st7703 *ctx) +{ + struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); @@ -654,7 +840,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver static int rgb30panel_init_sequence(struct st7703 *ctx) { struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); -@@ -446,31 +669,31 @@ static int rgb30panel_init_sequence(stru +@@ -446,31 +848,31 @@ static int rgb30panel_init_sequence(stru mipi_dsi_dcs_exit_sleep_mode(dsi); msleep(250); @@ -701,7 +887,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver 0x0f, 0xa1, 0x80, 0x12, 0x31, 0x23, 0x47, 0x86, 0xa1, 0x80, 0x47, 0x08, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, -@@ -479,7 +702,7 @@ static int rgb30panel_init_sequence(stru +@@ -479,7 +881,7 @@ static int rgb30panel_init_sequence(stru 0x13, 0x88, 0x88, 0x88, 0x88, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); @@ -710,7 +896,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver 0x01, 0x78, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x31, 0x8b, 0xa8, 0x31, 0x75, 0x88, 0x88, 0x88, 0x88, 0x88, 0x4f, 0x20, 0x8b, 0xa8, 0x20, -@@ -488,7 +711,7 @@ static int rgb30panel_init_sequence(stru +@@ -488,7 +890,7 @@ static int rgb30panel_init_sequence(stru 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xa1, 0x80, 0x00, 0x00, 0x00, 0x00); @@ -719,7 +905,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver 0x29, 0x3b, 0x3f, 0x42, 0x39, 0x06, 0x0d, 0x10, 0x13, 0x15, 0x14, 0x15, 0x10, 0x17, 0x00, 0x0a, 0x0f, 0x29, 0x3b, 0x3f, 0x42, 0x39, 0x06, 0x0d, -@@ -667,7 +890,7 @@ static int allpixelson_set(void *data, u +@@ -667,7 +1069,7 @@ static int allpixelson_set(void *data, u struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); dev_dbg(ctx->dev, "Setting all pixels on\n"); @@ -728,7 +914,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver msleep(val * 1000); /* Reset the panel to get video back */ drm_panel_disable(&ctx->panel); -@@ -783,7 +1006,9 @@ static void st7703_remove(struct mipi_ds +@@ -783,10 +1185,13 @@ static void st7703_remove(struct mipi_ds } static const struct of_device_id st7703_of_match[] = { @@ -739,7 +925,11 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sitronix-st7703.c linux/driver { .compatible = "powkiddy,rgb30-panel", .data = &rgb30panel_desc }, { .compatible = "rocktech,jh057n00900", .data = &jh057n00900_panel_desc }, { .compatible = "xingbangda,xbd599", .data = &xbd599_desc }, -@@ -802,6 +1027,6 @@ static struct mipi_dsi_driver st7703_dri ++ { .compatible = "gameforce,chi-panel", .data = &gameforce_desc }, + { /* sentinel */ } + }; + MODULE_DEVICE_TABLE(of, st7703_of_match); +@@ -802,6 +1207,6 @@ static struct mipi_dsi_driver st7703_dri }; module_mipi_dsi_driver(st7703_driver); diff --git a/projects/Rockchip/packages/linux/patches/RK3326/004-input-drivers.patch b/projects/Rockchip/packages/linux/patches/RK3326/004-input-drivers.patch index ec3598263..934c4e70a 100644 --- a/projects/Rockchip/packages/linux/patches/RK3326/004-input-drivers.patch +++ b/projects/Rockchip/packages/linux/patches/RK3326/004-input-drivers.patch @@ -1,6 +1,6 @@ diff -rupN linux.orig/drivers/gpio/gpiolib-of.c linux/drivers/gpio/gpiolib-of.c ---- linux.orig/drivers/gpio/gpiolib-of.c 2024-01-29 06:18:08.163711909 +0000 -+++ linux/drivers/gpio/gpiolib-of.c 2024-01-29 06:19:30.953540557 +0000 +--- linux.orig/drivers/gpio/gpiolib-of.c 2024-02-15 14:44:50.566334442 +0000 ++++ linux/drivers/gpio/gpiolib-of.c 2024-02-15 15:26:39.682128004 +0000 @@ -25,21 +25,6 @@ #include "gpiolib.h" #include "gpiolib-of.h" @@ -45,8 +45,8 @@ diff -rupN linux.orig/drivers/gpio/gpiolib-of.c linux/drivers/gpio/gpiolib-of.c * of_get_named_gpio() - Get a GPIO number to use with GPIO API * @np: device node to get GPIO from diff -rupN linux.orig/drivers/input/Kconfig linux/drivers/input/Kconfig ---- linux.orig/drivers/input/Kconfig 2024-01-29 06:18:08.495719572 +0000 -+++ linux/drivers/input/Kconfig 2024-01-29 06:19:30.953540557 +0000 +--- linux.orig/drivers/input/Kconfig 2024-02-15 14:44:51.830362270 +0000 ++++ linux/drivers/input/Kconfig 2024-02-15 15:26:39.682128004 +0000 @@ -51,6 +51,19 @@ config INPUT_FF_MEMLESS To compile this driver as a module, choose M here: the module will be called ff-memless. @@ -68,8 +68,8 @@ diff -rupN linux.orig/drivers/input/Kconfig linux/drivers/input/Kconfig tristate "Sparse keymap support library" help diff -rupN linux.orig/drivers/input/Makefile linux/drivers/input/Makefile ---- linux.orig/drivers/input/Makefile 2024-01-29 06:18:08.495719572 +0000 -+++ linux/drivers/input/Makefile 2024-01-29 06:19:30.953540557 +0000 +--- linux.orig/drivers/input/Makefile 2024-02-15 14:44:51.830362270 +0000 ++++ linux/drivers/input/Makefile 2024-02-15 15:26:39.682128004 +0000 @@ -10,6 +10,7 @@ input-core-y := input.o input-compat.o i input-core-y += touchscreen.o @@ -80,7 +80,7 @@ diff -rupN linux.orig/drivers/input/Makefile linux/drivers/input/Makefile obj-$(CONFIG_INPUT_VIVALDIFMAP) += vivaldi-fmap.o diff -rupN linux.orig/drivers/input/input-polldev.c linux/drivers/input/input-polldev.c --- linux.orig/drivers/input/input-polldev.c 1970-01-01 00:00:00.000000000 +0000 -+++ linux/drivers/input/input-polldev.c 2024-01-29 06:19:30.953540557 +0000 ++++ linux/drivers/input/input-polldev.c 2024-02-15 15:26:39.682128004 +0000 @@ -0,0 +1,362 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* @@ -445,9 +445,9 @@ diff -rupN linux.orig/drivers/input/input-polldev.c linux/drivers/input/input-po +} +EXPORT_SYMBOL(input_unregister_polled_device); diff -rupN linux.orig/drivers/input/joystick/Kconfig linux/drivers/input/joystick/Kconfig ---- linux.orig/drivers/input/joystick/Kconfig 2024-01-29 06:18:08.495719572 +0000 -+++ linux/drivers/input/joystick/Kconfig 2024-01-29 06:29:57.539189141 +0000 -@@ -400,6 +400,31 @@ config JOYSTICK_N64 +--- linux.orig/drivers/input/joystick/Kconfig 2024-02-15 14:44:51.834362359 +0000 ++++ linux/drivers/input/joystick/Kconfig 2024-02-16 13:56:59.646751062 +0000 +@@ -400,6 +400,36 @@ config JOYSTICK_N64 Say Y here if you want enable support for the four built-in controller ports on the Nintendo 64 console. @@ -475,14 +475,27 @@ diff -rupN linux.orig/drivers/input/joystick/Kconfig linux/drivers/input/joystic + tristate "XU10 joypad driver" + help + Made for XU10. ++ ++config JOYSTICK_GAMEFORCE_CHI ++ tristate "gameforce joypad driver" ++ help ++ Made for Gameforce CHI. + config JOYSTICK_SENSEHAT tristate "Raspberry Pi Sense HAT joystick" depends on INPUT && I2C diff -rupN linux.orig/drivers/input/joystick/Makefile linux/drivers/input/joystick/Makefile ---- linux.orig/drivers/input/joystick/Makefile 2024-01-29 06:18:08.495719572 +0000 -+++ linux/drivers/input/joystick/Makefile 2024-01-29 06:28:09.660788600 +0000 -@@ -25,6 +25,10 @@ obj-$(CONFIG_JOYSTICK_JOYDUMP) += joydu +--- linux.orig/drivers/input/joystick/Makefile 2024-02-15 14:44:51.834362359 +0000 ++++ linux/drivers/input/joystick/Makefile 2024-02-15 22:21:50.407922538 +0000 +@@ -15,6 +15,7 @@ obj-$(CONFIG_JOYSTICK_COBRA) += cobra.o + obj-$(CONFIG_JOYSTICK_DB9) += db9.o + obj-$(CONFIG_JOYSTICK_FSIA6B) += fsia6b.o + obj-$(CONFIG_JOYSTICK_GAMECON) += gamecon.o ++obj-$(CONFIG_JOYSTICK_GAMEFORCE_CHI) += gameforce-joypad.o + obj-$(CONFIG_JOYSTICK_GF2K) += gf2k.o + obj-$(CONFIG_JOYSTICK_GRIP) += grip.o + obj-$(CONFIG_JOYSTICK_GRIP_MP) += grip_mp.o +@@ -25,6 +26,10 @@ obj-$(CONFIG_JOYSTICK_JOYDUMP) += joydu obj-$(CONFIG_JOYSTICK_MAGELLAN) += magellan.o obj-$(CONFIG_JOYSTICK_MAPLE) += maplecontrol.o obj-$(CONFIG_JOYSTICK_N64) += n64joy.o @@ -493,15 +506,1349 @@ diff -rupN linux.orig/drivers/input/joystick/Makefile linux/drivers/input/joysti obj-$(CONFIG_JOYSTICK_PSXPAD_SPI) += psxpad-spi.o obj-$(CONFIG_JOYSTICK_PXRC) += pxrc.o obj-$(CONFIG_JOYSTICK_QWIIC) += qwiic-joystick.o -@@ -39,4 +43,5 @@ obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidj +@@ -39,4 +44,5 @@ obj-$(CONFIG_JOYSTICK_TWIDJOY) += twidj obj-$(CONFIG_JOYSTICK_WARRIOR) += warrior.o obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o +obj-$(CONFIG_JOYSTICK_XU10) += xu10-joypad.o obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o +diff -rupN linux.orig/drivers/input/joystick/gameforce-joypad.c linux/drivers/input/joystick/gameforce-joypad.c +--- linux.orig/drivers/input/joystick/gameforce-joypad.c 1970-01-01 00:00:00.000000000 +0000 ++++ linux/drivers/input/joystick/gameforce-joypad.c 2024-02-15 22:18:17.735235573 +0000 +@@ -0,0 +1,1330 @@ ++/* ++ * SARADC joystick & GPIO Button driver for Linux(Gameforce CHI) ++ */ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Should you need to contact me, the author, you can do so either by ++ * e-mail - mail your message to , or by paper mail: ++ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic ++ */ ++ ++/*----------------------------------------------------------------------------*/ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define RIGHT_ADC_JOYSTICK ++#define VOLUME_ADC_KEYS ++#define VIBRATORS_FF ++ ++#ifdef RIGHT_ADC_JOYSTICK ++#include ++#include "../input-compat.h" ++#endif ++ ++/*----------------------------------------------------------------------------*/ ++#define DRV_NAME "gameforce_gamepad" ++/*----------------------------------------------------------------------------*/ ++#ifdef VOLUME_ADC_KEYS ++struct of_device_id adckeys_of_match[] = { ++ { .compatible = "volume-keys", }, ++ {}, ++}; ++#endif ++ ++#ifdef VIBRATORS_FF ++struct of_device_id vibrators_of_match[] = { ++ { .compatible = "gpio,vibrators", }, ++ {}, ++}; ++ ++ ++struct gpio_vib { ++ struct work_struct work; ++ int speed; ++ int index; ++ int last_index; ++ bool active; ++ int gpio0; ++ int gpio1; ++}; ++#endif ++ ++#ifdef VOLUME_ADC_KEYS ++struct adc_keys_button { ++ u32 voltage; ++ u32 keycode; ++}; ++ ++struct adc_keys_state { ++ struct iio_channel *channel; ++ u32 num_keys; ++ u32 last_key; ++ u32 keyup_voltage; ++ const struct adc_keys_button *map; ++}; ++#endif ++ ++struct bt_adc { ++ /* IIO ADC Channel */ ++ struct iio_channel *channel; ++ /* report value (mV) */ ++ int old_value; ++ /* report type */ ++ int report_type; ++ /* input device init value (mV) */ ++ int max, min; ++ /* calibrated adc value */ ++ int cal; ++ /* adc scale value */ ++ int scale; ++ /* invert report */ ++ bool invert; ++}; ++ ++struct bt_gpio { ++ /* GPIO Request label */ ++ const char *label; ++ /* GPIO Number */ ++ int num; ++ /* report type */ ++ int report_type; ++ /* report linux code */ ++ int linux_code; ++ /* prev button value */ ++ bool old_value; ++ /* button press level */ ++ bool active_level; ++}; ++ ++struct joypad { ++ struct device *dev; ++ int poll_interval; ++ ++ /* report enable/disable */ ++ bool enable; ++ ++ /* report reference point */ ++ bool invert_absx; ++ bool invert_absy; ++ ++ /* report interval (ms) */ ++ int bt_gpio_count; ++ struct bt_gpio *gpios; ++ /* button auto repeat */ ++ int auto_repeat; ++ ++ /* report threshold (mV) */ ++ int bt_adc_fuzz, bt_adc_flat; ++ int bt_adc_x_range, bt_adc_y_range; ++ /* adc read value scale */ ++ int bt_adc_scale; ++ /* joystick deadzone control */ ++ int bt_adc_deadzone; ++ int bt_adc_count; ++ struct bt_adc *adcs; ++#ifdef VOLUME_ADC_KEYS ++ /*adc key saradc[2]*/ ++ struct adc_keys_state *st; ++#endif ++#ifdef VIBRATORS_FF ++ /* vibrator */ ++ struct gpio_vib *vib; ++#endif ++ struct mutex lock; ++}; ++ ++#ifdef RIGHT_ADC_JOYSTICK ++struct input_dev *global_input = NULL; ++#endif ++/*----------------------------------------------------------------------------*/ ++// ++// set to the value in the boot.ini file. (if exist) ++// ++/*----------------------------------------------------------------------------*/ ++static unsigned int g_button_adc_x_range = 0; ++static unsigned int g_button_adc_y_range = 0; ++static unsigned int g_button_adc_fuzz = 0; ++static unsigned int g_button_adc_flat = 0; ++static unsigned int g_button_adc_scale = 0; ++static unsigned int g_button_adc_deadzone = 0; ++ ++static int __init button_adcx_range_setup(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ ++ g_button_adc_x_range = simple_strtoul(str, NULL, 10); ++ ++ return 0; ++} ++__setup("button-adc-x-range=", button_adcx_range_setup); ++ ++static int __init button_adcy_range_setup(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ ++ g_button_adc_y_range = simple_strtoul(str, NULL, 10); ++ ++ return 0; ++} ++__setup("button-adc-y-range=", button_adcy_range_setup); ++ ++static int button_adc_fuzz(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ g_button_adc_fuzz = simple_strtoul(str, NULL, 10); ++ return 0; ++} ++__setup("button-adc-fuzz=", button_adc_fuzz); ++ ++static int button_adc_flat(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ g_button_adc_flat = simple_strtoul(str, NULL, 10); ++ return 0; ++} ++__setup("button-adc-flat=", button_adc_flat); ++ ++static int button_adc_scale(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ g_button_adc_scale = simple_strtoul(str, NULL, 10); ++ return 0; ++} ++__setup("button-adc-scale=", button_adc_scale); ++ ++static int button_adc_deadzone(char *str) ++{ ++ if (!str) ++ return -EINVAL; ++ g_button_adc_deadzone = simple_strtoul(str, NULL, 10); ++ return 0; ++} ++__setup("button-adc-deadzone=", button_adc_deadzone); ++ ++/*----------------------------------------------------------------------------*/ ++/*----------------------------------------------------------------------------*/ ++static int joypad_adc_read(struct bt_adc *adc) ++{ ++ int value; ++ ++ if (iio_read_channel_processed(adc->channel, &value)) ++ return 0; ++ ++ value *= adc->scale; ++ ++ return (adc->invert ? (adc->max - value) : value); ++} ++ ++/*----------------------------------------------------------------------------*/ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/DRV_NAME/poll_interval [rw] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_store_poll_interval(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, ++ size_t count) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ mutex_lock(&joypad->lock); ++ joypad->poll_interval = simple_strtoul(buf, NULL, 10); ++ mutex_unlock(&joypad->lock); ++ ++ return count; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_poll_interval(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ return sprintf(buf, "%d\n", joypad->poll_interval); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(poll_interval, S_IWUSR | S_IRUGO, ++ joypad_show_poll_interval, ++ joypad_store_poll_interval); ++ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/DRV_NAME/adc_fuzz [r] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_adc_fuzz(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ return sprintf(buf, "%d\n", joypad->bt_adc_fuzz); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(adc_fuzz, S_IWUSR | S_IRUGO, ++ joypad_show_adc_fuzz, ++ NULL); ++ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/DRV_NAME/adc_flat [r] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_adc_flat(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ return sprintf(buf, "%d\n", joypad->bt_adc_flat); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(adc_flat, S_IWUSR | S_IRUGO, ++ joypad_show_adc_flat, ++ NULL); ++ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/DRV_NAME/enable [rw] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_store_enable(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, ++ size_t count) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ mutex_lock(&joypad->lock); ++ joypad->enable = simple_strtoul(buf, NULL, 10); ++ mutex_unlock(&joypad->lock); ++ ++ return count; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_enable(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ ++ return sprintf(buf, "%d\n", joypad->enable); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(enable, S_IWUSR | S_IRUGO, ++ joypad_show_enable, ++ joypad_store_enable); ++ ++/*----------------------------------------------------------------------------*/ ++/* ++ * ATTRIBUTES: ++ * ++ * /sys/devices/platform/DRV_NAME/adc_cal [rw] ++ */ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_store_adc_cal(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, ++ size_t count) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ bool calibration; ++ ++ calibration = simple_strtoul(buf, NULL, 10); ++ ++ if (calibration) { ++ int nbtn; ++ ++ mutex_lock(&joypad->lock); ++ for (nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ ++ adc->cal = joypad_adc_read(adc); ++ if (!adc->cal) { ++ dev_err(joypad->dev, "%s : saradc channels[%d]!\n", ++ __func__, nbtn); ++ continue; ++ } ++ adc->old_value = adc->cal; ++ } ++ mutex_unlock(&joypad->lock); ++ } ++ return count; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static ssize_t joypad_show_adc_cal(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct platform_device *pdev = to_platform_device(dev); ++ struct joypad *joypad = platform_get_drvdata(pdev); ++ int nbtn; ++ ssize_t pos; ++ ++ for (nbtn = 0, pos = 0; nbtn < joypad->bt_adc_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ pos += sprintf(&buf[pos], "adc[%d]->cal = %d ", ++ nbtn, adc->cal); ++ } ++ pos += sprintf(&buf[pos], "\n"); ++ return pos; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static DEVICE_ATTR(adc_cal, S_IWUSR | S_IRUGO, ++ joypad_show_adc_cal, ++ joypad_store_adc_cal); ++ ++/*----------------------------------------------------------------------------*/ ++/*----------------------------------------------------------------------------*/ ++static struct attribute *joypad_attrs[] = { ++ &dev_attr_poll_interval.attr, ++ &dev_attr_adc_fuzz.attr, ++ &dev_attr_adc_flat.attr, ++ &dev_attr_enable.attr, ++ &dev_attr_adc_cal.attr, ++ NULL, ++}; ++ ++static struct attribute_group joypad_attr_group = { ++ .attrs = joypad_attrs, ++}; ++ ++/*----------------------------------------------------------------------------*/ ++/*----------------------------------------------------------------------------*/ ++static void joypad_gpio_check(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ int nbtn, value; ++ ++ for (nbtn = 0; nbtn < joypad->bt_gpio_count; nbtn++) { ++ struct bt_gpio *gpio = &joypad->gpios[nbtn]; ++ ++ if (gpio_get_value_cansleep(gpio->num) < 0) { ++ dev_err(joypad->dev, "failed to get gpio state\n"); ++ continue; ++ } ++ value = gpio_get_value(gpio->num); ++ if (value != gpio->old_value) { ++ input_event(poll_dev->input, ++ gpio->report_type, ++ gpio->linux_code, ++ (value == gpio->active_level) ? 1 : 0); ++ gpio->old_value = value; ++ } ++ } ++ input_sync(poll_dev->input); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void joypad_adc_check(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ int nbtn, value; ++ ++ for (nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ ++ value = joypad_adc_read(adc); ++ if (!value) { ++ dev_err(joypad->dev, "%s : saradc channels[%d]!\n", ++ __func__, nbtn); ++ continue; ++ } ++ ++ /* Joystick Deadzone check */ ++ if (joypad->bt_adc_deadzone) { ++ if ((value < adc->cal + joypad->bt_adc_deadzone) && ++ (value > adc->cal - joypad->bt_adc_deadzone)) ++ value = adc->cal; ++ } ++ value = value - adc->cal; ++ value = value > adc->max ? adc->max : value; ++ value = value < adc->min ? adc->min : value; ++ ++ if (nbtn == 0) ++ { ++ // adc-x value is default inverted(h/w) ++ input_report_abs(poll_dev->input, ++ adc->report_type, value); ++ } ++ else ++ { ++ input_report_abs(poll_dev->input, ++ adc->report_type, value * (-1)); ++ } ++ adc->old_value = value; ++ } ++ input_sync(poll_dev->input); ++} ++ ++/*----------------------------------------------------------------------------*/ ++#ifdef VOLUME_ADC_KEYS ++static int joypad_vol_check(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ //struct adc_keys_state *st = dev->private; ++ int i, value, ret; ++ u32 diff, closest = 0xffffffff; ++ int keycode = 0; ++ ++ ret = iio_read_channel_processed(joypad->st->channel, &value); ++ if (unlikely(ret < 0)) { ++ /* Forcibly release key if any was pressed */ ++ value = joypad->st->keyup_voltage; ++ } else { ++ for (i = 0; i < joypad->st->num_keys; i++) { ++ diff = abs(joypad->st->map[i].voltage - value); ++ if (diff < closest) { ++ closest = diff; ++ keycode = joypad->st->map[i].keycode; ++ } ++ } ++ } ++ ++ if (((157 320) && (value<1700))) ++ return -1; ++ if (abs(joypad->st->keyup_voltage - value) < closest) ++ keycode = 0; ++ ++ if (joypad->st->last_key && joypad->st->last_key != keycode) ++ input_report_key(poll_dev->input, joypad->st->last_key, 0); ++ ++ if (keycode) ++ input_report_key(poll_dev->input, keycode, 1); ++ ++ input_sync(poll_dev->input); ++ joypad->st->last_key = keycode; ++ ++ return 0; ++} ++#endif ++/*----------------------------------------------------------------------------*/ ++static void joypad_poll(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ ++ if (joypad->enable) { ++ joypad_adc_check(poll_dev); ++ joypad_gpio_check(poll_dev); ++ #ifdef VOLUME_ADC_KEYS ++ joypad_vol_check(poll_dev); ++ #endif ++ } ++ if (poll_dev->poll_interval != joypad->poll_interval) { ++ mutex_lock(&joypad->lock); ++ poll_dev->poll_interval = joypad->poll_interval; ++ mutex_unlock(&joypad->lock); ++ } ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void joypad_open(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ int nbtn; ++ ++ for (nbtn = 0; nbtn < joypad->bt_gpio_count; nbtn++) { ++ struct bt_gpio *gpio = &joypad->gpios[nbtn]; ++ gpio->old_value = gpio->active_level ? 0 : 1; ++ } ++ for (nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ ++ adc->old_value = joypad_adc_read(adc); ++ if (!adc->old_value) { ++ dev_err(joypad->dev, "%s : saradc channels[%d]!\n", ++ __func__, nbtn); ++ continue; ++ } ++ adc->cal = adc->old_value; ++ dev_info(joypad->dev, "%s : adc[%d] adc->cal = %d\n", ++ __func__, nbtn, adc->cal); ++ } ++ /* buttons status sync */ ++ joypad_adc_check(poll_dev); ++ joypad_gpio_check(poll_dev); ++ ++ /* button report enable */ ++ mutex_lock(&joypad->lock); ++ joypad->enable = true; ++ mutex_unlock(&joypad->lock); ++ ++ dev_info(joypad->dev, "%s : opened\n", __func__); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void joypad_close(struct input_polled_dev *poll_dev) ++{ ++ struct joypad *joypad = poll_dev->private; ++ ++ /* button report disable */ ++ mutex_lock(&joypad->lock); ++ joypad->enable = false; ++ mutex_unlock(&joypad->lock); ++ ++ dev_info(joypad->dev, "%s : closed\n", __func__); ++} ++#ifdef VIBRATORS_FF ++/** ++ * gpio_vib_set - handler to start/stop vibration ++ * @vib: pointer to vibrator structure ++ * @on: state to set ++ */ ++static int gpio_vib_set(struct gpio_vib *vib, bool on) ++{ ++ if (on) { ++ if (vib->last_index) { ++ gpio_direction_output(vib->gpio1, 1); ++ gpio_set_value(vib->gpio1, 1); ++ } else { ++ gpio_direction_output(vib->gpio0, 1); ++ gpio_set_value(vib->gpio0, 1); ++ } ++ } ++ else { ++ if (vib->last_index) { ++ gpio_direction_output(vib->gpio1, 0); ++ gpio_set_value(vib->gpio1, 0); ++ } else { ++ gpio_direction_output(vib->gpio0, 0); ++ gpio_set_value(vib->gpio0, 0); ++ } ++ } ++ ++ return 0; ++} ++ ++/** ++ * vib_work_handler - worker to set vibration level ++ * @work: pointer to work_struct ++ */ ++static void vib_work_handler(struct work_struct *work) ++{ ++ struct gpio_vib *vib = container_of(work, struct gpio_vib, work); ++ //struct joypad *joypad = container_of(vib, struct joypad, vib); ++ ++ /* ++ * pmic vibrator supports voltage ranges from 1.2 to 3.1V, so ++ * scale the level to fit into these ranges. ++ */ ++ printk("%s speed = %d\n", __func__, vib->speed); ++ if (vib->speed) { ++ vib->active = true; ++ } else { ++ vib->active = false; ++ } ++ ++ gpio_vib_set(vib, vib->active); ++} ++#endif ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_adc_setup(struct device *dev, struct joypad *joypad) ++{ ++ int nbtn = 0; ++ ++ joypad->adcs = devm_kzalloc(dev, joypad->bt_adc_count * ++ sizeof(struct bt_adc), GFP_KERNEL); ++ ++ if (!joypad->adcs) { ++ dev_err(dev, "%s devm_kzmalloc error!", __func__); ++ return -ENOMEM; ++ } ++ ++ for (nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ enum iio_chan_type type; ++ ++ adc->scale = joypad->bt_adc_scale; ++ if (nbtn) { ++ adc->channel = ++ devm_iio_channel_get(dev, "joy_y"); ++ adc->report_type = ABS_Y; ++ if (joypad->invert_absy) ++ adc->invert = true; ++ ++ adc->max = (joypad->bt_adc_y_range / 2) - 1; ++ adc->min = -(joypad->bt_adc_y_range / 2); ++ } ++ else { ++ adc->channel = ++ devm_iio_channel_get(dev, "joy_x"); ++ adc->report_type = ABS_X; ++ if (joypad->invert_absx) ++ adc->invert = true; ++ ++ adc->max = (joypad->bt_adc_x_range / 2) - 1; ++ adc->min = -(joypad->bt_adc_x_range / 2); ++ } ++ ++ if (IS_ERR(adc->channel)) { ++ dev_err(dev, "iio channel[%d] get error\n", nbtn); ++ return -EINVAL; ++ } ++ if (!adc->channel->indio_dev) ++ return -ENXIO; ++ ++ if (iio_get_channel_type(adc->channel, &type)) ++ return -EINVAL; ++ ++ if (type != IIO_VOLTAGE) { ++ dev_err(dev, "Incompatible channel %d type %d\n", ++ nbtn, type); ++ return -EINVAL; ++ } ++ } ++ if (nbtn == 0) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_gpio_setup(struct device *dev, struct joypad *joypad) ++{ ++ struct device_node *node, *pp; ++ int nbtn; ++ ++ node = dev->of_node; ++ if (!node) ++ return -ENODEV; ++ ++ joypad->gpios = devm_kzalloc(dev, joypad->bt_gpio_count * ++ sizeof(struct bt_gpio), GFP_KERNEL); ++ ++ if (!joypad->gpios) { ++ dev_err(dev, "%s devm_kzmalloc error!", __func__); ++ return -ENOMEM; ++ } ++ ++ nbtn = 0; ++ for_each_child_of_node(node, pp) { ++ enum of_gpio_flags flags; ++ struct bt_gpio *gpio = &joypad->gpios[nbtn++]; ++ int error; ++ ++ gpio->num = of_get_gpio_flags(pp, 0, &flags); ++ if (gpio->num < 0) { ++ error = gpio->num; ++ dev_err(dev, "Failed to get gpio flags, error: %d\n", ++ error); ++ return error; ++ } ++ ++ /* gpio active level(key press level) */ ++ gpio->active_level = (flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1; ++ ++ gpio->label = of_get_property(pp, "label", NULL); ++ ++ if (gpio_is_valid(gpio->num)) { ++ error = devm_gpio_request_one(dev, gpio->num, ++ GPIOF_IN, gpio->label); ++ if (error < 0) { ++ dev_err(dev, ++ "Failed to request GPIO %d, error %d\n", ++ gpio->num, error); ++ return error; ++ } ++ } ++ if (of_property_read_u32(pp, "linux,code", &gpio->linux_code)) { ++ dev_err(dev, "Button without keycode: 0x%x\n", ++ gpio->num); ++ return -EINVAL; ++ } ++ if (of_property_read_u32(pp, "linux,input-type", ++ &gpio->report_type)) ++ gpio->report_type = EV_KEY; ++ } ++ if (nbtn == 0) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++/*----------------------------------------------------------------------------*/ ++#ifdef VOLUME_ADC_KEYS ++static int joypad_vol_setup(struct device *dev, struct joypad *joypad) ++{ ++ struct device_node *node, *pp; ++ struct adc_keys_button *map; ++ //struct device *adckey_dev; ++ enum iio_chan_type type; ++ int i; ++ int error; ++ ++ node = NULL; ++ node = of_find_matching_node(NULL, adckeys_of_match); ++ ++ if(node) { ++ ++ printk("%s into ...\n", __func__); ++ //adckey_dev = container_of(node, struct device, of_node); ++ joypad->st = devm_kzalloc(dev, sizeof(*joypad->st), GFP_KERNEL); ++ ++ joypad->st->channel = devm_iio_channel_get(dev, "volume-buttons"); ++ if (IS_ERR(joypad->st->channel)) ++ return PTR_ERR(joypad->st->channel); ++ ++ if (!joypad->st->channel->indio_dev) ++ return -ENXIO; ++ ++ error = iio_get_channel_type(joypad->st->channel, &type); ++ if (error < 0) ++ return error; ++ ++ if (type != IIO_VOLTAGE) { ++ dev_err(dev, "Incompatible channel type %d\n", type); ++ return -EINVAL; ++ } ++ ++ if (of_property_read_u32(node, "keyup-threshold-microvolt", ++ &joypad->st->keyup_voltage)) { ++ dev_err(dev, "Invalid or missing keyup voltage\n"); ++ return -EINVAL; ++ } ++ joypad->st->keyup_voltage /= 1000; ++ printk("%s : keyup_voltage = %d\n", __func__, joypad->st->keyup_voltage); ++ ++ joypad->st->num_keys = of_get_child_count(node); ++ if (joypad->st->num_keys == 0) { ++ dev_err(dev, "keymap is missing\n"); ++ return -EINVAL; ++ } ++ printk("%s : adc_keys = %d\n", __func__, joypad->st->num_keys); ++ ++ map = devm_kmalloc_array(dev, joypad->st->num_keys, sizeof(*map), GFP_KERNEL); ++ if (!map) ++ return -ENOMEM; ++ ++ i = 0; ++ for_each_child_of_node(node, pp) { ++ if (of_property_read_u32(pp, "press-threshold-microvolt", &map[i].voltage)) { ++ dev_err(dev, "Key with invalid or missing voltage\n"); ++ return -EINVAL; ++ } ++ map[i].voltage /= 1000; ++ printk("%s : key[%d] voltage = %d\n", __func__, i, map[i].voltage); ++ ++ if (of_property_read_u32(pp, "linux,code", &map[i].keycode)) { ++ dev_err(dev, "Key with invalid or missing linux,code\n"); ++ return -EINVAL; ++ } ++ printk("%s : key[%d] keycode = %d\n", __func__, i, map[i].keycode); ++ ++ i++; ++ } ++ joypad->st->map = map; ++ ++ } ++ if (i == 0) ++ return -EINVAL; ++ ++ printk("%s end ...\n", __func__); ++ return 0; ++} ++#endif ++/*----------------------------------------------------------------------------*/ ++#ifdef VIBRATORS_FF ++static int joypad_vib_setup(struct device *dev, struct joypad *joypad) ++{ ++ struct device_node *node; ++ int ret = 0; ++ ++ node = NULL; ++ node = of_find_matching_node(NULL, vibrators_of_match); ++ ++ if(node) { ++ ++ printk("%s into ... joypad = %p\n", __func__, joypad); ++ joypad->vib = devm_kzalloc(dev, sizeof(*joypad->vib), GFP_KERNEL); ++ ++ joypad->vib->gpio0 = of_get_named_gpio_flags(node, "vibrator0-gpio", 0, NULL); ++ if (!gpio_is_valid(joypad->vib->gpio0)) ++ return -1; ++ ++ printk("%s get vibrator0-gpio = %d \n", __func__, joypad->vib->gpio0); ++ ret = devm_gpio_request(dev, joypad->vib->gpio0, "vibrator0"); ++ if (ret < 0) ++ return ret; ++ ++ joypad->vib->gpio1 = of_get_named_gpio_flags(node, "vibrator1-gpio", 0, NULL); ++ if (!gpio_is_valid(joypad->vib->gpio1)) ++ return -1; ++ ++ printk("%s get vibrator1-gpio = %d \n", __func__, joypad->vib->gpio1); ++ ret = devm_gpio_request(dev, joypad->vib->gpio1, "vibrator1"); ++ if (ret < 0) ++ return ret; ++ ++ INIT_WORK(&joypad->vib->work, vib_work_handler); ++ ++ } ++ ++ printk("%s end ...\n", __func__); ++ return 0; ++} ++ ++/** ++ * gpio_vib_play_effect - function to handle vib effects. ++ * @dev: input device pointer ++ * @data: data of effect ++ * @effect: effect to play ++ * ++ * Currently this driver supports only rumble effects. ++ */ ++static int gpio_vib_play_effect(struct input_dev *dev, void *data, ++ struct ff_effect *effect) ++{ ++ __u16 strong; ++ __u16 weak; ++ //struct joypad *joypad = input_get_drvdata(dev); ++ struct joypad *joypad = data; ++ ++ printk("%s joypad gpio key count = %d\n", __func__, joypad->bt_gpio_count); ++ printk("%s joypad = %p, get vibrator0-gpio = %d \n", __func__, joypad, joypad->vib->gpio0); ++ strong = effect->u.rumble.strong_magnitude; ++ weak = effect->u.rumble.weak_magnitude; ++ ++ printk("%s strong = 0x%x, weak = 0x%x\n", __func__, strong, weak); ++ #if 1 ++ if ((strong > 1) && ((weak == 0) || (weak == 1))) { ++ joypad->vib->speed = effect->u.rumble.strong_magnitude >> 8; ++ joypad->vib->index = weak; ++ joypad->vib->last_index = joypad->vib->index; ++ } ++ else if ((strong == 0) && ((weak == 0) || (weak == 1))) { ++ joypad->vib->speed = 0; ++ } ++ else if ((weak > 0) && ((strong == 0) || (strong == 1))) { ++ joypad->vib->speed = effect->u.rumble.weak_magnitude >> 8; ++ joypad->vib->index = strong; ++ joypad->vib->last_index = joypad->vib->index; ++ } ++ else if ((weak > 0) && ((strong == 0) || (strong == 1))) { ++ joypad->vib->speed = 0; ++ } ++ ++ printk("%s speed = %d, index = %d\n", __func__, joypad->vib->speed, joypad->vib->index); ++ schedule_work(&joypad->vib->work); ++ #endif ++ return 0; ++} ++#endif ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_input_setup(struct device *dev, struct joypad *joypad) ++{ ++ struct input_polled_dev *poll_dev; ++ struct input_dev *input; ++ int nbtn, error; ++ ++ poll_dev = devm_input_allocate_polled_device(dev); ++ if (!poll_dev) { ++ dev_err(dev, "no memory for polled device\n"); ++ return -ENOMEM; ++ } ++ ++ poll_dev->private = joypad; ++ poll_dev->poll = joypad_poll; ++ poll_dev->poll_interval = joypad->poll_interval; ++ poll_dev->open = joypad_open; ++ poll_dev->close = joypad_close; ++ ++ input = poll_dev->input; ++ #ifdef RIGHT_ADC_JOYSTICK ++ global_input = poll_dev->input; ++ #endif ++ input->name = DRV_NAME; ++ input->phys = DRV_NAME"/input0"; ++ ++ input->id.bustype = BUS_HOST; ++ input->id.vendor = 0x0003; ++ input->id.product = 0x0003; ++ input->id.version = 0x0302; ++ ++ /* IIO ADC key setup (0 mv ~ 1800 mv) * adc->scale */ ++ __set_bit(EV_ABS, input->evbit); ++ for(nbtn = 0; nbtn < joypad->bt_adc_count; nbtn++) { ++ struct bt_adc *adc = &joypad->adcs[nbtn]; ++ input_set_abs_params(input, adc->report_type, ++ adc->min, adc->max, ++ joypad->bt_adc_fuzz, ++ joypad->bt_adc_flat); ++ dev_info(dev, ++ "%s : SCALE = %d, ABS min = %d, max = %d," ++ " fuzz = %d, flat = %d, deadzone = %d\n", ++ __func__, adc->scale, adc->min, adc->max, ++ joypad->bt_adc_fuzz, joypad->bt_adc_flat, ++ joypad->bt_adc_deadzone); ++ } ++ #ifdef RIGHT_ADC_JOYSTICK ++ /* Right Analog */ ++ input_set_abs_params(input, ABS_RX, -900, 899, 32, 32); ++ input_set_abs_params(input, ABS_RY, -900, 899, 32, 32); ++ #endif ++ ++ /* GPIO key setup */ ++ __set_bit(EV_KEY, input->evbit); ++ for(nbtn = 0; nbtn < joypad->bt_gpio_count; nbtn++) { ++ struct bt_gpio *gpio = &joypad->gpios[nbtn]; ++ input_set_capability(input, gpio->report_type, ++ gpio->linux_code); ++ } ++#ifdef VOLUME_ADC_KEYS ++ /* ADC key setup */ ++ for (nbtn = 0; nbtn < joypad->st->num_keys; nbtn++) ++ __set_bit(joypad->st->map[nbtn].keycode, input->keybit); ++#endif ++ if (joypad->auto_repeat) ++ __set_bit(EV_REP, input->evbit); ++#ifdef VIBRATORS_FF ++ /* vibrator for ff */ ++ input_set_capability(input, EV_FF, FF_RUMBLE); ++ error = input_ff_create_memless(input, joypad, gpio_vib_play_effect); ++ if (error) ++ return error; ++#endif ++ joypad->dev = dev; ++ ++ error = input_register_polled_device(poll_dev); ++ if (error) { ++ dev_err(dev, "unable to register polled device, err=%d\n", ++ error); ++ return error; ++ } ++ return 0; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void joypad_setup_value_check(struct device *dev, struct joypad *joypad) ++{ ++ /* ++ fuzz: specifies fuzz value that is used to filter noise from ++ the event stream. ++ */ ++ if (g_button_adc_fuzz) ++ joypad->bt_adc_fuzz = g_button_adc_fuzz; ++ else ++ device_property_read_u32(dev, "button-adc-fuzz", ++ &joypad->bt_adc_fuzz); ++ /* ++ flat: values that are within this value will be discarded by ++ joydev interface and reported as 0 instead. ++ */ ++ if (g_button_adc_flat) ++ joypad->bt_adc_flat = g_button_adc_flat; ++ else ++ device_property_read_u32(dev, "button-adc-flat", ++ &joypad->bt_adc_flat); ++ ++ /* Joystick report value control */ ++ if (g_button_adc_scale) ++ joypad->bt_adc_scale = g_button_adc_scale; ++ else ++ device_property_read_u32(dev, "button-adc-scale", ++ &joypad->bt_adc_scale); ++ ++ /* Joystick deadzone value control */ ++ if (g_button_adc_deadzone) ++ joypad->bt_adc_deadzone = g_button_adc_deadzone; ++ else ++ device_property_read_u32(dev, "button-adc-deadzone", ++ &joypad->bt_adc_deadzone); ++ ++ if (g_button_adc_x_range) ++ joypad->bt_adc_x_range = g_button_adc_x_range; ++ else ++ device_property_read_u32(dev, "button-adc-x-range", ++ &joypad->bt_adc_x_range); ++ if (g_button_adc_y_range) ++ joypad->bt_adc_y_range = g_button_adc_y_range; ++ else ++ device_property_read_u32(dev, "button-adc-y-range", ++ &joypad->bt_adc_y_range); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static int joypad_dt_parse(struct device *dev, struct joypad *joypad) ++{ ++ int error = 0; ++ ++ /* initialize value check from boot.ini */ ++ joypad_setup_value_check(dev, joypad); ++ ++ device_property_read_u32(dev, "button-adc-count", ++ &joypad->bt_adc_count); ++ ++ device_property_read_u32(dev, "poll-interval", ++ &joypad->poll_interval); ++ ++ joypad->auto_repeat = device_property_present(dev, "autorepeat"); ++ ++ /* change the report reference point? (ADC MAX - read value) */ ++ joypad->invert_absx = device_property_present(dev, "invert-absx"); ++ joypad->invert_absy = device_property_present(dev, "invert-absy"); ++ dev_info(dev, "%s : invert-absx = %d, inveret-absy = %d\n", ++ __func__, joypad->invert_absx, joypad->invert_absy); ++ ++ joypad->bt_gpio_count = device_get_child_node_count(dev); ++ ++ if ((joypad->bt_adc_count == 0) || (joypad->bt_gpio_count == 0)) { ++ dev_err(dev, "adc key = %d, gpio key = %d error!", ++ joypad->bt_adc_count, joypad->bt_gpio_count); ++ return -EINVAL; ++ } ++ ++ error = joypad_adc_setup(dev, joypad); ++ if (error) ++ return error; ++ ++ error = joypad_gpio_setup(dev, joypad); ++ if (error) ++ return error; ++#ifdef VOLUME_ADC_KEYS ++ error = joypad_vol_setup(dev, joypad); ++ printk("222 %s : error = %d\n", __func__, error); ++ if (error) ++ return error; ++#endif ++#ifdef VIBRATORS_FF ++ error = joypad_vib_setup(dev, joypad); ++ printk("333 %s : error = %d\n", __func__, error); ++ if (error) ++ return error; ++#endif ++ return error; ++} ++ ++#ifdef RIGHT_ADC_JOYSTICK ++static int joypad_misc_open(struct inode *inode, struct file *file) ++{ ++ printk("%s ...\n", __func__); ++ ++ //file->private_data = global_input; ++ nonseekable_open(inode, file); ++ ++ return 0; ++} ++ ++static int joypad_misc_release(struct inode *inode, struct file *file) ++{ ++ //struct input_dev *dev = file->private_data; ++ ++ //input_unregister_device(dev); ++ //kfree(dev); ++ ++ return 0; ++} ++ ++//static ssize_t joypad_inject_events(struct input_dev *dev, const char __user *buffer, size_t count ++static ssize_t joypad_inject_events(const char __user *buffer, size_t count) ++{ ++ struct input_event ev; ++ size_t bytes = 0; ++ ++ if (count != 0 && count < input_event_size()) ++ return -EINVAL; ++ ++ while (bytes + input_event_size() <= count) { ++ /* ++ * Note that even if some events were fetched successfully ++ * we are still going to return EFAULT instead of partial ++ * count to let userspace know that it got it's buffers ++ * all wrong. ++ */ ++ if (input_event_from_user(buffer + bytes, &ev)) ++ return -EFAULT; ++ ++ //input_event(dev, ev.type, ev.code, ev.value); ++ input_event(global_input, ev.type, ev.code, ev.value); ++ bytes += input_event_size(); ++ } ++ ++ return bytes; ++} ++ ++static ssize_t joypad_misc_write(struct file *file, const char __user *buffer, ++ size_t count, loff_t *ppos) ++{ ++ //struct input_dev *dev = file->private_data; ++ int retval; ++ ++ if (count == 0) ++ return 0; ++ ++ retval = mutex_lock_interruptible(&global_input->mutex); ++ if (retval) ++ return retval; ++ ++ //retval = joypad_inject_events(dev, buffer, count); ++ retval = joypad_inject_events(buffer, count); ++ ++ mutex_unlock(&global_input->mutex); ++ ++ return retval; ++} ++ ++static long joypad_misc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ++{ ++ int ret = 0; ++ return ret; ++} ++ ++ ++static const struct file_operations joypad_fops = { ++ .owner = THIS_MODULE, ++ .open = joypad_misc_open, ++ .release = joypad_misc_release, ++ .write = joypad_misc_write, ++ .unlocked_ioctl = joypad_misc_ioctl, ++ .llseek = no_llseek, ++ ++}; ++ ++ ++static struct miscdevice joypad_misc_dev = { ++ .minor = MISC_DYNAMIC_MINOR, ++ .name = "joypad", ++ .fops = &joypad_fops, ++}; ++#endif ++/*----------------------------------------------------------------------------*/ ++static int joypad_probe(struct platform_device *pdev) ++{ ++ struct joypad *joypad; ++ struct device *dev = &pdev->dev; ++ int error; ++ ++ joypad = devm_kzalloc(dev, sizeof(struct joypad), GFP_KERNEL); ++ if (!joypad) { ++ dev_err(dev, "joypad devm_kzmalloc error!"); ++ return -ENOMEM; ++ } ++ ++ /* device tree data parse */ ++ error = joypad_dt_parse(dev, joypad); ++ if (error) { ++ dev_err(dev, "dt parse error!(err = %d)\n", error); ++ return error; ++ } ++ ++ mutex_init(&joypad->lock); ++ platform_set_drvdata(pdev, joypad); ++ ++ error = sysfs_create_group(&pdev->dev.kobj, &joypad_attr_group); ++ if (error) { ++ dev_err(dev, "create sysfs group fail, error: %d\n", ++ error); ++ return error; ++ } ++ ++ /* poll input device setup */ ++ error = joypad_input_setup(dev, joypad); ++ if (error) { ++ dev_err(dev, "input setup failed!(err = %d)\n", error); ++ return error; ++ } ++#ifdef RIGHT_ADC_JOYSTICK ++ error = misc_register(&joypad_misc_dev); ++ if (error < 0) ++ printk("%s :fail to register misc device.\n", __func__); ++#endif ++ dev_info(dev, "%s : probe success\n", __func__); ++ return 0; ++} ++ ++/*----------------------------------------------------------------------------*/ ++static const struct of_device_id joypad_of_match[] = { ++ /*{ .compatible = "odroidgo2-joypad", },*/ ++ { .compatible = "gameforce-gamepad", }, ++ {}, ++}; ++ ++MODULE_DEVICE_TABLE(of, joypad_of_match); ++ ++/*----------------------------------------------------------------------------*/ ++static struct platform_driver joypad_driver = { ++ .probe = joypad_probe, ++ .driver = { ++ .name = DRV_NAME, ++ .of_match_table = of_match_ptr(joypad_of_match), ++ }, ++}; ++ ++/*----------------------------------------------------------------------------*/ ++static int __init joypad_init(void) ++{ ++ return platform_driver_register(&joypad_driver); ++} ++ ++/*----------------------------------------------------------------------------*/ ++static void __exit joypad_exit(void) ++{ ++ platform_driver_unregister(&joypad_driver); ++} ++ ++/*----------------------------------------------------------------------------*/ ++late_initcall(joypad_init); ++module_exit(joypad_exit); ++ ++/*----------------------------------------------------------------------------*/ ++MODULE_AUTHOR("Hardkernel Co.,LTD"); ++MODULE_DESCRIPTION("Keypad driver(ADC&GPIO) for Gameforce CHI"); ++MODULE_LICENSE("GPL v2"); ++MODULE_ALIAS("platform:" DRV_NAME); ++ ++/*----------------------------------------------------------------------------*/ diff -rupN linux.orig/drivers/input/joystick/odroidgo2-joypad.c linux/drivers/input/joystick/odroidgo2-joypad.c --- linux.orig/drivers/input/joystick/odroidgo2-joypad.c 1970-01-01 00:00:00.000000000 +0000 -+++ linux/drivers/input/joystick/odroidgo2-joypad.c 2024-01-29 06:19:30.953540557 +0000 ++++ linux/drivers/input/joystick/odroidgo2-joypad.c 2024-02-15 15:26:39.682128004 +0000 @@ -0,0 +1,878 @@ +/* + * SARADC joystick & GPIO Button driver for Linux(Hardkernel ODROIDGO2-Advance) @@ -1383,7 +2730,7 @@ diff -rupN linux.orig/drivers/input/joystick/odroidgo2-joypad.c linux/drivers/in +/*----------------------------------------------------------------------------*/ diff -rupN linux.orig/drivers/input/joystick/odroidgo2-v11-joypad.c linux/drivers/input/joystick/odroidgo2-v11-joypad.c --- linux.orig/drivers/input/joystick/odroidgo2-v11-joypad.c 1970-01-01 00:00:00.000000000 +0000 -+++ linux/drivers/input/joystick/odroidgo2-v11-joypad.c 2024-01-29 06:19:30.953540557 +0000 ++++ linux/drivers/input/joystick/odroidgo2-v11-joypad.c 2024-02-15 15:26:39.682128004 +0000 @@ -0,0 +1,878 @@ +/* + * SARADC joystick & GPIO Button driver for Linux(Hardkernel ODROIDGO2-Advance) @@ -2264,8 +3611,8 @@ diff -rupN linux.orig/drivers/input/joystick/odroidgo2-v11-joypad.c linux/driver + +/*----------------------------------------------------------------------------*/ diff -rupN linux.orig/drivers/input/joystick/odroidgo3-joypad.c linux/drivers/input/joystick/odroidgo3-joypad.c ---- linux.orig/drivers/input/joystick/odroidgo3-joypad.c 1969-12-31 19:00:00.000000000 -0500 -+++ linux/drivers/input/joystick/odroidgo3-joypad.c 2024-02-01 13:43:52.000000000 -0500 +--- linux.orig/drivers/input/joystick/odroidgo3-joypad.c 1970-01-01 00:00:00.000000000 +0000 ++++ linux/drivers/input/joystick/odroidgo3-joypad.c 2024-02-15 15:26:39.682128004 +0000 @@ -0,0 +1,1108 @@ +/* + * SARADC joystick & GPIO Button driver for Linux(Hardkernel ODROIDGO2-Advance) @@ -3377,7 +4724,7 @@ diff -rupN linux.orig/drivers/input/joystick/odroidgo3-joypad.c linux/drivers/in +/*----------------------------------------------------------------------------*/ diff -rupN linux.orig/drivers/input/joystick/rgb20s-joypad.c linux/drivers/input/joystick/rgb20s-joypad.c --- linux.orig/drivers/input/joystick/rgb20s-joypad.c 1970-01-01 00:00:00.000000000 +0000 -+++ linux/drivers/input/joystick/rgb20s-joypad.c 2024-01-29 06:27:07.151404545 +0000 ++++ linux/drivers/input/joystick/rgb20s-joypad.c 2024-02-15 15:26:39.682128004 +0000 @@ -0,0 +1,1373 @@ +/* + * SARADC joystick & GPIO Button driver for Linux(Powkiddy RGB20S) @@ -4754,7 +6101,7 @@ diff -rupN linux.orig/drivers/input/joystick/rgb20s-joypad.c linux/drivers/input +/*----------------------------------------------------------------------------*/ diff -rupN linux.orig/drivers/input/joystick/xu10-joypad.c linux/drivers/input/joystick/xu10-joypad.c --- linux.orig/drivers/input/joystick/xu10-joypad.c 1970-01-01 00:00:00.000000000 +0000 -+++ linux/drivers/input/joystick/xu10-joypad.c 2024-01-29 06:19:30.953540557 +0000 ++++ linux/drivers/input/joystick/xu10-joypad.c 2024-02-15 15:26:39.682128004 +0000 @@ -0,0 +1,1119 @@ +/* + * SARADC joystick & GPIO Button driver for Linux(Hardkernel MagicX-XU10) @@ -5876,8 +7223,8 @@ diff -rupN linux.orig/drivers/input/joystick/xu10-joypad.c linux/drivers/input/j + +/*----------------------------------------------------------------------------*/ diff -rupN linux.orig/drivers/power/supply/rk817_charger.c linux/drivers/power/supply/rk817_charger.c ---- linux.orig/drivers/power/supply/rk817_charger.c 2024-01-29 06:18:08.779726126 +0000 -+++ linux/drivers/power/supply/rk817_charger.c 2024-01-29 06:19:30.953540557 +0000 +--- linux.orig/drivers/power/supply/rk817_charger.c 2024-02-15 14:44:53.330395291 +0000 ++++ linux/drivers/power/supply/rk817_charger.c 2024-02-15 15:26:39.682128004 +0000 @@ -679,7 +679,7 @@ static enum power_supply_usb_type rk817_ }; @@ -5889,7 +7236,7 @@ diff -rupN linux.orig/drivers/power/supply/rk817_charger.c linux/drivers/power/s .num_properties = ARRAY_SIZE(rk817_bat_props), diff -rupN linux.orig/include/linux/input-polldev.h linux/include/linux/input-polldev.h --- linux.orig/include/linux/input-polldev.h 1970-01-01 00:00:00.000000000 +0000 -+++ linux/include/linux/input-polldev.h 2024-01-29 06:19:30.953540557 +0000 ++++ linux/include/linux/input-polldev.h 2024-02-15 15:26:39.682128004 +0000 @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _INPUT_POLLDEV_H @@ -5950,8 +7297,8 @@ diff -rupN linux.orig/include/linux/input-polldev.h linux/include/linux/input-po + +#endif diff -rupN linux.orig/include/linux/of_gpio.h linux/include/linux/of_gpio.h ---- linux.orig/include/linux/of_gpio.h 2024-01-29 06:18:09.007731389 +0000 -+++ linux/include/linux/of_gpio.h 2024-01-29 06:19:30.953540557 +0000 +--- linux.orig/include/linux/of_gpio.h 2024-02-15 14:44:54.398418804 +0000 ++++ linux/include/linux/of_gpio.h 2024-02-15 15:26:39.682128004 +0000 @@ -17,8 +17,26 @@ struct device_node; diff --git a/projects/Rockchip/packages/u-boot/patches/RK3326/001-add-rg351x.patch b/projects/Rockchip/packages/u-boot/patches/RK3326/001-set-hwrev.patch similarity index 63% rename from projects/Rockchip/packages/u-boot/patches/RK3326/001-add-rg351x.patch rename to projects/Rockchip/packages/u-boot/patches/RK3326/001-set-hwrev.patch index 36ff9a08a..f85cf3281 100644 --- a/projects/Rockchip/packages/u-boot/patches/RK3326/001-add-rg351x.patch +++ b/projects/Rockchip/packages/u-boot/patches/RK3326/001-set-hwrev.patch @@ -1,7 +1,7 @@ -diff -rupN uboot.orig/cmd/hwrev.c uboot/cmd/hwrev.c ---- uboot.orig/cmd/hwrev.c 2024-01-04 18:59:49.400779885 +0000 -+++ uboot/cmd/hwrev.c 2024-01-04 19:02:14.336283106 +0000 -@@ -34,6 +34,21 @@ int do_hwrev(cmd_tbl_t *cmdtp, int flag, +diff -rupN u-boot.orig/cmd/hwrev.c u-boot/cmd/hwrev.c +--- u-boot.orig/cmd/hwrev.c 2024-02-15 14:49:02.135798042 +0000 ++++ u-boot/cmd/hwrev.c 2024-02-15 14:54:37.885602790 +0000 +@@ -34,6 +34,26 @@ int do_hwrev(cmd_tbl_t *cmdtp, int flag, env_set("hwrev", "v10-go3"); env_set("dtb_name", "rk3326-odroidgo3-linux.dtb"); } @@ -19,6 +19,11 @@ diff -rupN uboot.orig/cmd/hwrev.c uboot/cmd/hwrev.c + else if (check_range(1000, 1050, hwrev_adc)) { + env_set("hwrev", "xu10"); + env_set("dtb_name", "rk3326-magicx-xu10.dtb"); ++ } ++ /* CHI */ ++ else if (check_range(460, 489, hwrev_adc)) { ++ env_set("hwrev", "chi"); ++ env_set("dtb_name", "rk3326-gameforce-chi.dtb"); + } /* engineer samples */ else {