diff --git a/projects/ROCKNIX/config.xml b/projects/ROCKNIX/config.xml index 48775989a4..53b9bb9110 100644 --- a/projects/ROCKNIX/config.xml +++ b/projects/ROCKNIX/config.xml @@ -33,7 +33,7 @@ rk3326-powkiddy-rgb10x rk3326-magicx-xu10 rk3326-magicx-xu-mini-m - rk3326-gameconsole-r36max + rk3326-gameconsole-eeclone diff --git a/projects/ROCKNIX/devices/RK3326/packages/u-boot/config/b_boot.ini b/projects/ROCKNIX/devices/RK3326/packages/u-boot/config/b_boot.ini index da592c1ce2..86cd26b2e1 100644 --- a/projects/ROCKNIX/devices/RK3326/packages/u-boot/config/b_boot.ini +++ b/projects/ROCKNIX/devices/RK3326/packages/u-boot/config/b_boot.ini @@ -40,7 +40,7 @@ if itest.w ${hwid_adc} > 139 && itest.w ${hwid_adc} < 191; then elif itest.w ${hwid_adc} > 999 && itest.w ${hwid_adc} < 1051; then setenv fdtfile "rk3326-magicx-xu-mini-m.dtb" elif itest.w ${hwid_adc} > 489 && itest.w ${hwid_adc} < 541; then - setenv fdtfile "rk3326-gameconsole-r36max.dtb" + setenv fdtfile "rk3326-gameconsole-eeclone.dtb" else echo "Unexpected ADC value ${hwid_adc}, falling back to OGA dtb" setenv fdtfile "rk3326-odroid-go2.dtb" diff --git a/projects/ROCKNIX/devices/RK3326/patches/linux/023-gameconsole-r36max.patch b/projects/ROCKNIX/devices/RK3326/patches/linux/023-gameconsole-eeclone.patch similarity index 90% rename from projects/ROCKNIX/devices/RK3326/patches/linux/023-gameconsole-r36max.patch rename to projects/ROCKNIX/devices/RK3326/patches/linux/023-gameconsole-eeclone.patch index 5e9aab069e..c946de6c1d 100644 --- a/projects/ROCKNIX/devices/RK3326/patches/linux/023-gameconsole-r36max.patch +++ b/projects/ROCKNIX/devices/RK3326/patches/linux/023-gameconsole-eeclone.patch @@ -1,7 +1,7 @@ new file mode 100644 --- /dev/null -+++ b/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-r36max.dts -@@ -0,0 +1,884 @@ ++++ b/arch/arm64/boot/dts/rockchip/rk3326-gameconsole-eeclone.dts +@@ -0,0 +1,926 @@ +/// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2024-present ROCKNIX (https://github.com/ROCKNIX) @@ -16,15 +16,15 @@ new file mode 100644 +#include "rk3326.dtsi" + +/ { -+ model = "K36 family clone"; -+ compatible = "gameconsole,r36max", "rockchip,rk3326"; ++ model = "Generic EE clone"; ++ compatible = "gameconsole,eeclone", "rockchip,rk3326"; + + aliases { + mmc0 = &emmc; + mmc1 = &sdmmc; + mmc2 = &sdio; + serial1 = &uart2; -+ serial2 = &uart1; ++ serial2 = &uart5; + }; + + backlight: backlight { @@ -93,6 +93,9 @@ new file mode 100644 + keyup-threshold-microvolt = <1800000>; + poll-interval = <100>; + ++ /* disabled by default, dtbo may enable it when needed */ ++ status = "disabled"; ++ + button-vol-up { + press-threshold-microvolt = <15000>; + label = "VOLUMEUP"; @@ -266,6 +269,30 @@ new file mode 100644 + }; + }; + ++ leds: gpio-leds { ++ compatible = "gpio-leds"; ++ pinctrl-0 = <&led_pins>; ++ pinctrl-names = "default"; ++ ++ /* charge_red_gpio = <&gpio0 17 0>; */ ++ led-0 { ++ color = ; ++ default-state = "off"; ++ function = LED_FUNCTION_CHARGING; ++ linux,default-trigger = "battery-charging-blink-full-solid"; ++ gpios = <&gpio0 RK_PC1 GPIO_ACTIVE_HIGH>; ++ }; ++ ++ /* charge_blue_gpio = <&gpio0 0 0>; */ ++ led-1 { ++ color = ; ++ default-state = "on"; ++ function = LED_FUNCTION_POWER; ++ linux,default-trigger = "default-on"; ++ gpios = <&gpio0 RK_PA0 GPIO_ACTIVE_HIGH>; ++ }; ++ }; ++ + spk_amp: audio-amplifier { + compatible = "simple-audio-amplifier"; + enable-gpios = <&gpio3 RK_PA7 GPIO_ACTIVE_HIGH>; @@ -304,10 +331,11 @@ new file mode 100644 + + vccsys: vccsys { + compatible = "regulator-fixed"; -+ regulator-name = "vcc3v8_sys"; ++ regulator-name = "vcc5v0_sys"; + regulator-always-on; -+ regulator-min-microvolt = <3800000>; -+ regulator-max-microvolt = <3800000>; ++ regulator-boot-on; ++ regulator-min-microvolt = <5000000>; ++ regulator-max-microvolt = <5000000>; + }; + + vcc-phy-regulator { @@ -331,19 +359,19 @@ new file mode 100644 + }; + }; + -+ vcc_host: vcc_host { -+ compatible = "regulator-fixed"; -+ regulator-name = "vcc_host"; -+ regulator-min-microvolt = <5000000>; -+ regulator-max-microvolt = <5000000>; -+ gpio = <&gpio3 RK_PA4 GPIO_ACTIVE_HIGH>; ++ vcc_host: vcc_host { ++ compatible = "regulator-fixed"; ++ regulator-name = "vcc_host"; ++ regulator-min-microvolt = <5000000>; ++ regulator-max-microvolt = <5000000>; ++ gpio = <&gpio3 RK_PA4 GPIO_ACTIVE_HIGH>; + pinctrl-0 = <&vcc5_usb>; + pinctrl-names = "default"; -+ enable-active-high; -+ regulator-always-on; -+ regulator-boot-on; -+ vin-supply = <&usb_midu>; -+ }; ++ enable-active-high; ++ regulator-always-on; ++ regulator-boot-on; ++ vin-supply = <&usb_midu>; ++ }; +}; + +&dmc { @@ -451,13 +479,13 @@ new file mode 100644 + vcc6-supply = <&vccsys>; + vcc7-supply = <&vcc_3v0>; + vcc8-supply = <&vccsys>; -+ vcc9-supply = <&usb_midu>; + + regulators { + vdd_logic: DCDC_REG1 { + regulator-name = "vdd_logic"; -+ regulator-min-microvolt = <850000>; -+ regulator-max-microvolt = <1150000>; ++ regulator-min-microvolt = <950000>; ++ regulator-max-microvolt = <1350000>; ++ regulator-initial-mode = <0x02>; + regulator-ramp-delay = <6001>; + regulator-always-on; + regulator-boot-on; @@ -473,6 +501,7 @@ new file mode 100644 + regulator-min-microvolt = <850000>; + regulator-max-microvolt = <1350000>; + regulator-ramp-delay = <6001>; ++ regulator-initial-mode = <0x02>; + regulator-always-on; + regulator-boot-on; + @@ -486,6 +515,7 @@ new file mode 100644 + regulator-name = "vcc_ddr"; + regulator-always-on; + regulator-boot-on; ++ regulator-initial-mode = <0x02>; + + regulator-state-mem { + regulator-on-in-suspend; @@ -496,6 +526,7 @@ new file mode 100644 + regulator-name = "vcc_3v0"; + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; ++ regulator-initial-mode = <0x02>; + regulator-always-on; + regulator-boot-on; + @@ -573,24 +604,24 @@ new file mode 100644 + vcc_sd: LDO_REG6 { + regulator-name = "vcc_sd"; + regulator-min-microvolt = <1800000>; -+ regulator-max-microvolt = <3000000>; -+ regulator-always-on; -+ regulator-boot-on; ++ regulator-max-microvolt = <3300000>; + + regulator-state-mem { + regulator-on-in-suspend; -+ regulator-suspend-microvolt = <3000000>; ++ regulator-suspend-microvolt = <3300000>; + }; + }; + + vcc2v8_dvp: LDO_REG7 { + regulator-name = "vcc2v8_dvp"; -+ regulator-min-microvolt = <2800000>; -+ regulator-max-microvolt = <2800000>; ++ regulator-min-microvolt = <1800000>; ++ regulator-max-microvolt = <3300000>; ++ regulator-always-on; ++ regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; -+ regulator-suspend-microvolt = <2800000>; ++ regulator-suspend-microvolt = <3300000>; + }; + }; + @@ -611,6 +642,8 @@ new file mode 100644 + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; + regulator-name = "vdd1v5_dvp"; ++ regulator-always-on; ++ regulator-boot-on; + + regulator-state-mem { + regulator-off-in-suspend; @@ -620,12 +653,13 @@ new file mode 100644 + + usb_midu: BOOST { + regulator-name = "usb_midu"; -+ regulator-min-microvolt = <4700000>; ++ regulator-min-microvolt = <4900000>; + regulator-max-microvolt = <5400000>; + regulator-always-on; + regulator-boot-on; + }; + ++ /* + otg_switch: OTG_SWITCH { + regulator-name = "otg_switch"; + @@ -633,6 +667,7 @@ new file mode 100644 + regulator-off-in-suspend; + }; + }; ++ */ + }; + + rk817_charger: charger { @@ -740,7 +775,7 @@ new file mode 100644 + }; + + u2phy_otg: otg-port { -+ status = "okay"; ++ status = "disabled"; + }; +}; + @@ -799,8 +834,15 @@ new file mode 100644 + + vcc5-usb { + vcc5_usb: vcc5-usb { -+ rockchip,pins = <0x03 0x04 0x00 0x9f>; -+ phandle = <0xb2>; ++ rockchip,pins = <3 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>; ++ }; ++ }; ++ ++ gpio-led { ++ led_pins: led-pins { ++ rockchip,pins = ++ <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>, /* charge_blue_gpio = <&gpio0 0 0>; */ ++ <0 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>; /* charge_red_gpio = <&gpio0 17 0>; */ + }; + }; + @@ -833,7 +875,7 @@ new file mode 100644 + }; +}; + -+&uart1 { ++&uart5 { + status = "okay"; +}; +&uart2 { diff --git a/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/001-device_config b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/001-device_config new file mode 100755 index 0000000000..737146c16e --- /dev/null +++ b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/001-device_config @@ -0,0 +1,11 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) + +cat </storage/.config/profile.d/001-device_config +# Device Features +DEVICE_PLAYBACK_PATH_SPK="HP" +DEVICE_PLAYBACK_PATH_HP="SPK" +DEVICE_BATTERY_LED_STATUS="true" +DEVICE_TEMP_SENSOR="/sys/devices/virtual/thermal/thermal_zone0/temp" +EOF diff --git a/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/002-generate_dtbo b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/002-generate_dtbo new file mode 100755 index 0000000000..00f76a4218 --- /dev/null +++ b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/002-generate_dtbo @@ -0,0 +1,46 @@ +#!/bin/bash + +set -e + +STOCKPART="/dev/disk/by-label/EMUELEC" +DTBDIR="/flash/stock" +DTBOPATH="/flash/overlays/mipi-panel.dtbo" +TMPDIR="/tmp/flash_prepare" + +# no-op if dtbo already exists +[ -f "${DTBOPATH}" ] && exit 0 + +# Obtain stock dtb if needed and possible +if ! ls "${DTBDIR}"/*.dtb; then + if [ ! -L "${STOCKPART}" ]; then + echo "No stock dtb nor stock firmware partition found. Skipping dtbo generation" >&2 + exit 1 + fi + + # Prepare temporary destination + mkdir -p "${TMPDIR}/${DTBDIR}" + # Prepare source + mkdir -p /tmp/stock + mount "${STOCKPART}" /tmp/stock + # Copy all the dtbs (actually, there should be exactly one) + cp /tmp/stock/*.dtb "${TMPDIR}/${DTBDIR}" +fi + +STOCKDTB=$(ls "${DTBDIR}"/*.dtb "${TMPDIR}/${DTBDIR}"/*.dtb | head -1) +mkdir -p "${TMPDIR}/$(dirname ${DTBOPATH})" +echo "Preparing dtbo. This may take about a minute" +/usr/libexec/generic-dsi/rocknix_dtbo.py "${STOCKDTB}" -o "${TMPDIR}/${DTBOPATH}" + + +# Modifications to be made on firmaware partition +if [ -d "${TMPDIR}/flash" ]; then + mount -o remount,rw /flash + + rsync -av ${TMPDIR}/flash/ /flash || true + + # Cleanup and reboot + mount -o remount,ro /flash + sync +fi + +[ -f "${DTBOPATH}" ] && reboot diff --git a/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/010-led_control b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/010-led_control new file mode 100755 index 0000000000..049c529d12 --- /dev/null +++ b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/010-led_control @@ -0,0 +1,9 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) + +cat </storage/.config/profile.d/010-led_control +DEVICE_LED_CONTROL="false" +DEVICE_LED_BRIGHTNESS="false" +DEVICE_LED_CHARGING="false" +EOF diff --git a/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/050-game_configs b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/050-game_configs new file mode 100755 index 0000000000..1bd303c31e --- /dev/null +++ b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/050-game_configs @@ -0,0 +1,58 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) + +#Set mupen64-plus-sa config for OGA +if [ ! -d "/storage/.config/mupen64plus" ]; then + mkdir -p "/storage/.config/mupen64plus/" + cp -r /usr/local/share/mupen64plus/mupen64plus.cfg* /storage/.config/mupen64plus/ +fi +if [ -f "/storage/.config/mupen64plus/mupen64plus.cfg.gen_2s" ]; then + rm /storage/.config/mupen64plus/mupen64plus.cfg + cp /storage/.config/mupen64plus/mupen64plus.cfg.gen_2s /storage/.config/mupen64plus/mupen64plus.cfg +fi + +#Set drastic-sa config for OGA +if [ ! -d "/storage/.config/drastic" ]; then + mkdir -p "/storage/.config/drastic" + cp -r "/usr/config/drastic" "/storage/.config/" +fi +if [ -f "/storage/.config/drastic/config/drastic.cfg.gen_2s" ]; then + cp /storage/.config/drastic/config/drastic.cfg.gen_2s /storage/.config/drastic/config/drastic.cfg +fi + +#Set ppsspp config for OGA +if [ ! -d "/storage/.config/ppsspp" ]; then + mkdir -p "/storage/.config/ppsspp" + cp -r "/usr/config/ppsspp" "/storage/.config/" +fi + +#Map ppsspp controls +if grep OGABE -q "/storage/.config/ppsspp/PSP/SYSTEM/controls.ini"; then + exit 1 +else + cat </storage/.config/ppsspp/PSP/SYSTEM/controls.ini +#OGABE +[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-4003 +An.Down = 10-4002 +An.Left = 10-4001 +An.Right = 10-4000 +Fast-forward = 1-61 +Pause = 10-106 +Save State = 10-4010 +Load State = 10-4008 +EOF +fi diff --git a/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/050-modifiers b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/050-modifiers new file mode 100755 index 0000000000..a710ab7129 --- /dev/null +++ b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/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_MODE" +DEVICE_FUNC_KEYB_MODIFIER="BTN_THUMBR" +EOF diff --git a/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/bin/battery_led_status b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/bin/battery_led_status new file mode 100755 index 0000000000..19afab14f7 --- /dev/null +++ b/projects/ROCKNIX/packages/hardware/quirks/devices/Generic EE clone/bin/battery_led_status @@ -0,0 +1,54 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2024-present ROCKNIX (https://github.com/ROCKNIX) + +# Simple script to watch the battery capacity and +# turn the power LED to different states: +# Blinking red when charge is less than 20% +# Blue turns off when charge is less than 10% + +RED_TRIGGER=/sys/class/leds/red\:charging/trigger +BLUE_TRIGGER=/sys/class/leds/blue\:status/trigger + +function red_led() { + case $1 in + none) echo none > ${RED_TRIGGER};; + blink) echo timer > ${RED_TRIGGER};; + steady) echo default-on > ${RED_TRIGGER};; + esac +} + +function blue_led() { + case $1 in + none) echo none > ${BLUE_TRIGGER};; + blink) echo timer > ${BLUE_TRIGGER};; + steady) echo default-on > ${BLUE_TRIGGER};; + esac +} + + +while true +do + CAP=$(cat /sys/class/power_supply/battery/capacity) + STAT=$(cat /sys/class/power_supply/battery/status) + if [[ ${STAT} == "Discharging" ]]; then + if (( ${CAP} <= 10 )); then + blue_led none + red_led blink + continue + elif (( ${CAP} <= 20 )); then + blue_led steady + red_led blink + else + blue_led steady + red_led none + fi + elif (( ${CAP} <= 95 )); then + blue_led steady + red_led steady + else + blue_led steady + red_led none + fi + sleep 15 +done diff --git a/projects/ROCKNIX/packages/linux-drivers/generic-dsi/package.mk b/projects/ROCKNIX/packages/linux-drivers/generic-dsi/package.mk index b6a86ff89b..6c544abbcc 100644 --- a/projects/ROCKNIX/packages/linux-drivers/generic-dsi/package.mk +++ b/projects/ROCKNIX/packages/linux-drivers/generic-dsi/package.mk @@ -2,12 +2,19 @@ # Copyright (C) 2024 ROCKNIX (https://github.com/ROCKNIX) PKG_NAME="generic-dsi" -PKG_VERSION="0.1.0" +PKG_VERSION="fa1bd4c5b55bb60bfded06a1c1964328b871345d" PKG_LICENSE="GPL" -PKG_LONGDESC="generic DSI panel driver" +PKG_LONGDESC="generic DSI panel driver and stock DTB import scripts" PKG_DEPENDS_TARGET="pyFDT" +PKG_URL="https://github.com/stolen/overlay_server/archive/${PKG_VERSION}.zip" PKG_TOOLCHAIN="manual" +unpack() { + mkdir -p "${PKG_BUILD}" + cd "${PKG_BUILD}" + unzip "${SOURCES}/${PKG_NAME}/${PKG_SOURCE_NAME}" +} + ### For development. Easier to check if code compiles and works. ### No need for a long build-transfer-reboot-wait-reboot-check loop make_target() { @@ -21,6 +28,9 @@ make_target() { makeinstall_target() { mkdir -p "${INSTALL}/usr/libexec/generic-dsi" + # rocknix_dtbo.py is a better script handling not just panel, but also joypad, headphones, etc. + cp -v "${PKG_BUILD}/"overlay_server*"/rocknix_dtbo.py" "${INSTALL}/usr/libexec/generic-dsi/" + # importpanel.py still here because it's simple, documented in wiki and performs just one task well cp -v "${PKG_DIR}/scripts/importpanel.py" "${INSTALL}/usr/libexec/generic-dsi/" }