From 008f3fd47cfbd7ea3e30f54f6e8406a4035b9f07 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 5 Feb 2020 00:37:02 +0100 Subject: [PATCH] [xt-q8l-v10] fixed act8846 regulator against kernel 5.4, enabled eMMC DDR mode (#1778) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added ALSA configuration bits for rk3288 HDMI and SPDIF to allow pulseaudio show proper sound device/profile/mapping names instead of just "Built-in Audio" for all of them * Added ALSA device description in asound.conf to provide correct labels for PulseAudio for RK3288 devices when SPDIF and DW-I2S-HDMI simple audio cards are exposed Removed unnecessary ALSA configuration files previously added from rockchip.conf * Fixed cpu operating points tables and raised a bit (+5°C) cooling for non-critical temperatures for xt-q8l-v10 in dev and next kernel flavours * Fixed again cpu opp table * Removed whole cpu opp table and retouch only necessary operating points * Enabled gpiomem driver for xt-q8l-v10 in next kernel flavour * Added debounce delay and card detect gpio pins for sdmmc card holder for xt-q8l-v10 board * Added card-detect and debounce delay for sdmmc for xt-q8l-v10 board in next kernel flavour too * Fixed missing comment in xt-q8l-v10 device tree patch * Added gpiomem to xt-q8l-v10 board for dev kernel * Fixed FAN53555/Silergy patches to accomodate changes in u-boot v2019.04 * Changed property property flags for USB regulators in u-boot and kernel: kernel is now informed that bootloader is going to turn the USB power on * Fixed indentation in rk3288-xt-q8l-v10.dts, raised debounce delay to sdmmc, added vbus-supply to USB host, removed some unneeded properties * Added working DDR52 mode for eMMC on xt-q8l-v10 * Removed regulator-off-in-suspend for some xt-q8l-v10 regulators due to changed in act8865.c driver which causes the regulators to be misconfigured * Adjusted targets for xt-q8l-v10 (provides bionic desktop + buster server) * Removed all regular-state-mem nodes in xt-q8l-v10 device tree because the change in act8865.c affects also non-off entries * Brought xt-q8l-v10 device tree from rockchip-current to rockchip-dev --- config/targets.conf | 6 +- .../xt-q8l-v10-add-device-tree.patch | 332 +++++++++++------- .../xt-q8l-v10-add-device-tree.patch | 332 +++++++++++------- 3 files changed, 416 insertions(+), 254 deletions(-) diff --git a/config/targets.conf b/config/targets.conf index f810e8aaf..29949cdaf 100644 --- a/config/targets.conf +++ b/config/targets.conf @@ -620,10 +620,8 @@ tritium-h5 current bionic cli stable yes # xt-q8l-v10 -xt-q8l-v10 legacy buster cli stable yes -xt-q8l-v10 legacy bionic desktop stable yes -xt-q8l-v10 current bionic minimal stable yes -xt-q8l-v10 current bullseye minimal stable yes +xt-q8l-v10 current bionic desktop stable yes +xt-q8l-v10 current buster minimal stable yes # Z28 pro diff --git a/patch/kernel/rockchip-current/xt-q8l-v10-add-device-tree.patch b/patch/kernel/rockchip-current/xt-q8l-v10-add-device-tree.patch index 4a3517698..d60aeb7f0 100644 --- a/patch/kernel/rockchip-current/xt-q8l-v10-add-device-tree.patch +++ b/patch/kernel/rockchip-current/xt-q8l-v10-add-device-tree.patch @@ -1,6 +1,9 @@ +diff --git a/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts +new file mode 100644 +index 000000000..539e445b4 --- /dev/null -+++ b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts 2019-08-03 13:55:48.719992666 +0000 -@@ -0,0 +1,982 @@ ++++ b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts +@@ -0,0 +1,1061 @@ +/* + * Copyright (c) 2014, 2015 FUKAUMI Naoki + * 2018 Paolo Sabatino @@ -53,7 +56,7 @@ + model = "XT-Q8L-V10-RK3288"; + compatible = "generic,xt-q8l-v10-rk3288", "rockchip,rk3288"; + -+ memory { ++ memory@0 { + reg = <0x0 0x0 0x0 0x80000000>; + device_type = "memory"; + }; @@ -83,7 +86,7 @@ + clock-frequency = <125000000>; + clock-output-names = "ext_gmac"; + }; -+ ++ + /* + * Handle the IR receiver using the gpio-ir-receiver kernel module. + * This works flawlessy, the original xt-q8l-v10 remote uses a NEC @@ -97,13 +100,13 @@ + pinctrl-0 = <&ir_int>; + linux,rc-map-name = "rc-xt-q8l-v10"; + wakeup-source; -+ }; ++ }; + + keys: gpio-keys { + compatible = "gpio-keys"; + #address-cells = <1>; + #size-cells = <0>; -+ ++ + pinctrl-names = "default"; + pinctrl-0 = <&pwr_key>; + @@ -115,7 +118,7 @@ + wakeup-source; + debounce-interval = <100>; + }; -+ ++ + }; + + leds { @@ -127,7 +130,7 @@ + so while there is mass storage access it turns red and + when it is idle is blue + */ -+ gpios = <&gpio7 2 GPIO_ACTIVE_LOW>; ++ gpios = <&gpio7 2 GPIO_ACTIVE_LOW>; + label = "power"; + linux,default-trigger = "mmc0"; + pinctrl-names = "default"; @@ -162,7 +165,12 @@ + regulator-name = "vcc_flash"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; ++ /*gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>; ++ states = <1800000 0>, ++ <3300000 1>; ++ */ + vin-supply = <&vcc_io>; ++ startup-delay-us = <100000>; + }; + + vcc_host_5v: usb-host-regulator { @@ -171,8 +179,8 @@ + regulator-name = "vcc_host_5v"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; -+ regulator-boot-on; -+ enable-active-high; ++ regulator-boot-on; ++ enable-active-high; + vin-supply = <&vcc_sys>; + }; + @@ -200,6 +208,13 @@ + post-power-on-delay-ms = <100>; + }; + ++ emmc_pwrseq: emmc-pwrseq { ++ compatible = "mmc-pwrseq-emmc"; ++ pinctrl-0 = <&emmc_reset>; ++ pinctrl-names = "default"; ++ reset-gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; ++ }; ++ + /* + * Sound taken from tinkerboard device tree, adapted to q8. + */ @@ -217,27 +232,27 @@ + sound-dai = <&i2s>; + }; + }; -+ -+ soundcard-spdif { -+ compatible = "simple-audio-card"; -+ simple-audio-card,name = "SPDIF"; -+ simple-audio-card,dai-link@1 { -+ -+ cpu { -+ sound-dai = <&spdif>; -+ }; -+ -+ codec { -+ sound-dai = <&spdif_out>; -+ }; -+ -+ }; -+ }; + -+ spdif_out: spdif-out { -+ compatible = "linux,spdif-dit"; -+ #sound-dai-cells = <0>; -+ }; ++ soundcard-spdif { ++ compatible = "simple-audio-card"; ++ simple-audio-card,name = "SPDIF"; ++ simple-audio-card,dai-link@1 { ++ ++ cpu { ++ sound-dai = <&spdif>; ++ }; ++ ++ codec { ++ sound-dai = <&spdif_out>; ++ }; ++ ++ }; ++ }; ++ ++ spdif_out: spdif-out { ++ compatible = "linux,spdif-dit"; ++ #sound-dai-cells = <0>; ++ }; + +}; + @@ -303,8 +318,8 @@ + regulator-boot-on; + vin-supply = <&vcc_sys>; + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; + }; + + vdd_gpu: syr828@41 { @@ -318,8 +333,8 @@ + regulator-always-on; + vin-supply = <&vcc_sys>; + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; + }; + + hym8563: hym8563@51 { @@ -351,7 +366,7 @@ + wakeup-source; + + regulators { -+ ++ + /* + * Regulator controlling DDR memory - always on + */ @@ -360,9 +375,12 @@ + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -374,9 +392,12 @@ + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -390,9 +411,12 @@ + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -405,9 +429,12 @@ + regulator-min-microvolt = <2000000>; + regulator-max-microvolt = <2000000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -416,13 +443,16 @@ + */ + vccio_sd: REG5 { + regulator-name = "vccio_sd"; -+ regulator-min-microvolt = <1800000>; ++ regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; ++ regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; -+ }; ++ }; ++ */ + }; + + /* @@ -434,9 +464,12 @@ + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -449,9 +482,14 @@ + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; ++ ++ /* ++ The regulator can be set off in suspend, but kernel 5.4 modifications ++ to enable suspend for ACT8865 device break the ACT8846 + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; ++ */ + }; + + /* @@ -463,9 +501,14 @@ + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; // Turn this on to get SPDIF! ++ ++ /* ++ The regulator can be set off in suspend, but kernel 5.4 modifications ++ to enable suspend for ACT8865 device break the ACT8846 + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; ++ */ + }; + + /* @@ -475,9 +518,13 @@ + regulator-name = "vcc_lan"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; ++ ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -489,9 +536,13 @@ + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-always-on; ++ ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -503,9 +554,13 @@ + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; ++ ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -518,9 +573,14 @@ + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; ++ ++ /* ++ The regulator can be set off in suspend, but kernel 5.4 modifications ++ to enable suspend for ACT8865 device break the ACT8846 + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; ++ */ + }; + }; + }; @@ -535,7 +595,7 @@ +}; + +&i2c4 { -+ ++ + /* + * Here should go the RK1000 audio codec parts, but seems that + * there is no driver in linux kernel at the moment, so we can't @@ -545,7 +605,7 @@ + * http://dl.radxa.com/rock/docs/hw/ds/RK1000-S%20DATASHEET%20V14.pdf + */ + status = "okay"; -+ ++ +}; + +&i2c5 { @@ -575,12 +635,12 @@ + bias-pull-up; + drive-strength = <8>; + }; -+ ++ + pcfg_pull_up_drv_8ma: pcfg-pull-up-drv-8ma { + bias-pull-up; + drive-strength = <8>; + }; -+ ++ + pcfg_pull_none_8ma: pcfg-pull-none-8ma { + bias-disable; + drive-strength = <8>; @@ -594,18 +654,18 @@ + pcfg_wl_int: pcfg-wl-int { + bias-pull-up; + }; -+ ++ + act8846 { -+ ++ + /* + * Original q8 device tree says: + * - gpio0 11 HIGH -> power hold -+ * - gpio7 1 LOW -> possibly pmic-vsel, we don't care -+ */ ++ * - gpio7 1 LOW -> possibly pmic-vsel, we don't care ++ */ + pmic_vsel: pmic-vsel { + rockchip,pins = <7 1 RK_FUNC_GPIO &pcfg_output_low>; + }; -+ ++ + pwr_hold: pwr-hold { + rockchip,pins = <0 11 RK_FUNC_GPIO &pcfg_pull_up>; + }; @@ -650,7 +710,7 @@ + }; + + sdmmc { -+ ++ + /* + * Copied from firefly board definition to give more drive to + * the sdmmc pins. The Q8 seems to be quite able to drive @@ -701,14 +761,22 @@ + }; + + }; -+ -+ ++ ++ + wireless-bluetooth { + uart0_gpios: uart0-gpios { + rockchip,pins = <4 19 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + ++ emmc { ++ ++ emmc_reset: emmc-reset { ++ rockchip,pins = <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>; ++ }; ++ ++ }; ++ +}; + +&saradc { @@ -717,24 +785,34 @@ +}; + +&emmc { -+ ++ + /* -+ * eMMC seems to be 52Mhz device on q8 devices, so set it here -+ * vmmc-supply and vqmmc-supply are removed because they hang -+ * u-boot >= v2018.03 -+ * From the original q8l firmware and eMMC datasheet it also should -+ * support DDR highspeed mode, but using mmc-ddr-3_3v or mmc-ddr-1_8v -+ * properties are not working ++ * eMMC is a 52Mhz DDR device on q8 devices, so set it here. ++ * Setting default-sample-rate to 180 degrees is very important, ++ * otherwise the eMMC is not stable and may not be able to negotiate ++ * the right clock. ++ * Despite the code already seems to use 180 degree phase when ++ * MMC + 8bit bus is set, we need to set default phase here too. ++ * ++ * Huge hint came from this patch: ++ * https://patchwork.kernel.org/patch/11129183/ ++ * + */ -+ clock-frequency = <50000000>; -+ + broken-cd; + bus-width = <8>; + cap-mmc-highspeed; ++ + disable-wp; + non-removable; + pinctrl-names = "default"; -+ pinctrl-0 = <&emmc_clk>, <&emmc_cmd>, <&emmc_pwr>, <&emmc_bus8>; ++ pinctrl-0 = <&emmc_clk>, <&emmc_cmd>, <&emmc_bus8>; ++ ++ vmmc-supply = <&vcc_io>; ++ vqmmc-supply = <&vcc_flash>; ++ ++ mmc-pwrseq = <&emmc_pwrseq>; ++ mmc-ddr-1_8v; ++ rockchip,default-sample-phase = <180>; + + status = "okay"; +}; @@ -746,9 +824,7 @@ + cap-mmc-highspeed; + cap-sd-highspeed; + cd-gpios = <&gpio6 RK_PC6 GPIO_ACTIVE_LOW>; -+ cd-debounce-delay-ms = <200>; -+ post-power-on-delay-ms = <50>; -+ supports-cqe; ++ cd-debounce-delay-ms = <500>; + disable-wp; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc_clk>, <&sdmmc_cmd>, <&sdmmc_cd>, <&sdmmc_bus4>; @@ -766,33 +842,33 @@ +&sdio0 { + #address-cells = <1>; + #size-cells = <0>; -+ ++ + bus-width = <4>; + mmc-pwrseq = <&sdio0_pwrseq>; -+ ++ + vmmc-supply = <&vcc_io>; -+ vqmmc-supply = <&vcc_18>; // This must be the same as in io_domains, ++ vqmmc-supply = <&vcc_18>; // This must be the same as in io_domains, + // otherwise the mmc1 device won't be detected properly -+ -+// clock-frequency = <50000000>; -+// max-frequency = <50000000>; ++ ++ // clock-frequency = <50000000>; ++ // max-frequency = <50000000>; + + pinctrl-names = "default"; -+ pinctrl-0 = <&sdio0_bus4>, <&sdio0_cmd>, <&sdio0_clk>, <&sdio0_int>; -+ ++ pinctrl-0 = <&sdio0_bus4>, <&sdio0_cmd>, <&sdio0_clk>, <&sdio0_int>; ++ + cap-sdio-irq; + no-mmc; + no-sd; + cap-sd-highspeed; // required, otherwise does not work! -+ supports-sdio; ++ supports-sdio; + non-removable; -+ ++ + keep-power-in-suspend; + disable-wp; -+ -+ ++ ++ + status = "okay"; -+ ++ + brcmf: bcrmf@1 { + reg = <1>; + compatible = "brcm,bcm4329-fmac"; @@ -800,8 +876,8 @@ + interrupts = <30 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "host-wake"; + status = "okay"; -+ }; -+ ++ }; ++ + //sd-uhs-sdr104; // required to be disabled, otherwise the device get + // detected, but there is no communication + @@ -823,13 +899,13 @@ + * These dmas described here for uarts are present in original q8 board + * dts, so I replicate them here because documentation says that serial + * ports can have dmas. -+ * note: ++ * note: + * - uart0 is the serial port connected to the bluetooth module -+ * - uart2 is the onboard serial port -+ * ++ * - uart2 is the onboard serial port ++ * + * As ok kernel 4.19 DMA for serial ports is disabled because it makes + * the ports unusable -+ * ++ * + */ +&uart0 { + pinctrl-names = "default"; @@ -873,31 +949,25 @@ + * specify the proper resources for all the phys though. + * The reference patch which works in conjuction with the reset lines: + * https://patchwork.kernel.org/patch/9469811/ -+ * ++ * + */ +&usbphy { + status = "okay"; +}; -+ -+&usbphy0 { -+ vbus-supply = <&vcc_otg_5v>; -+}; -+ -+&usbphy2 { -+ vbus-supply = <&vcc_host_5v>; -+}; + +&usb_host0_ehci { -+ dr_mode = "host"; -+ reg = <0x0 0xff500000 0x0 0x20000>; -+ status = "disable"; ++ dr_mode = "host"; ++ reg = <0x0 0xff500000 0x0 0x20000>; ++ status = "disable"; +}; + +&usb_host1 { ++ vbus-supply = <&vcc_host_5v>; + status = "okay"; +}; + +&usb_otg { ++ vbus-supply = <&vcc_otg_5v>; + status = "okay"; +}; + @@ -924,18 +994,10 @@ + status = "okay"; +}; + -+//&vpu_service { -+// status = "okay"; -+//}; -+ +&hevc_mmu { + status = "okay"; +}; + -+//&hevc_service { -+// status = "okay"; -+//}; -+ +&wdt { + status = "okay"; +}; @@ -978,8 +1040,28 @@ + opp-1608000000 { + opp-microvolt = <1300000>; + }; ++ ++ /* ++ Remove the overclocking/turbo frequencies ++ */ ++ /delete-node/ opp@1704000000; ++ /delete-node/ opp@1800000000; ++ /delete-node/ opp@1896000000; ++ /delete-node/ opp@1920000000; ++ /delete-node/ opp@1992000000; ++ /delete-node/ opp@2016000000; ++ /delete-node/ opp@2040000000; ++ /delete-node/ opp@2064000000; ++ /delete-node/ opp@2088000000; ++ /delete-node/ opp@2112000000; ++ /delete-node/ opp@2136000000; ++ /delete-node/ opp@2160000000; ++ /delete-node/ opp@2184000000; ++ /delete-node/ opp@2208000000; ++ ++ +}; + +&gpiomem { -+ status = "okay"; ++ status = "okay"; +}; diff --git a/patch/kernel/rockchip-dev/xt-q8l-v10-add-device-tree.patch b/patch/kernel/rockchip-dev/xt-q8l-v10-add-device-tree.patch index 4a3517698..d60aeb7f0 100644 --- a/patch/kernel/rockchip-dev/xt-q8l-v10-add-device-tree.patch +++ b/patch/kernel/rockchip-dev/xt-q8l-v10-add-device-tree.patch @@ -1,6 +1,9 @@ +diff --git a/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts +new file mode 100644 +index 000000000..539e445b4 --- /dev/null -+++ b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts 2019-08-03 13:55:48.719992666 +0000 -@@ -0,0 +1,982 @@ ++++ b/arch/arm/boot/dts/rk3288-xt-q8l-v10.dts +@@ -0,0 +1,1061 @@ +/* + * Copyright (c) 2014, 2015 FUKAUMI Naoki + * 2018 Paolo Sabatino @@ -53,7 +56,7 @@ + model = "XT-Q8L-V10-RK3288"; + compatible = "generic,xt-q8l-v10-rk3288", "rockchip,rk3288"; + -+ memory { ++ memory@0 { + reg = <0x0 0x0 0x0 0x80000000>; + device_type = "memory"; + }; @@ -83,7 +86,7 @@ + clock-frequency = <125000000>; + clock-output-names = "ext_gmac"; + }; -+ ++ + /* + * Handle the IR receiver using the gpio-ir-receiver kernel module. + * This works flawlessy, the original xt-q8l-v10 remote uses a NEC @@ -97,13 +100,13 @@ + pinctrl-0 = <&ir_int>; + linux,rc-map-name = "rc-xt-q8l-v10"; + wakeup-source; -+ }; ++ }; + + keys: gpio-keys { + compatible = "gpio-keys"; + #address-cells = <1>; + #size-cells = <0>; -+ ++ + pinctrl-names = "default"; + pinctrl-0 = <&pwr_key>; + @@ -115,7 +118,7 @@ + wakeup-source; + debounce-interval = <100>; + }; -+ ++ + }; + + leds { @@ -127,7 +130,7 @@ + so while there is mass storage access it turns red and + when it is idle is blue + */ -+ gpios = <&gpio7 2 GPIO_ACTIVE_LOW>; ++ gpios = <&gpio7 2 GPIO_ACTIVE_LOW>; + label = "power"; + linux,default-trigger = "mmc0"; + pinctrl-names = "default"; @@ -162,7 +165,12 @@ + regulator-name = "vcc_flash"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; ++ /*gpios = <&gpio3 RK_PC3 GPIO_ACTIVE_LOW>; ++ states = <1800000 0>, ++ <3300000 1>; ++ */ + vin-supply = <&vcc_io>; ++ startup-delay-us = <100000>; + }; + + vcc_host_5v: usb-host-regulator { @@ -171,8 +179,8 @@ + regulator-name = "vcc_host_5v"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; -+ regulator-boot-on; -+ enable-active-high; ++ regulator-boot-on; ++ enable-active-high; + vin-supply = <&vcc_sys>; + }; + @@ -200,6 +208,13 @@ + post-power-on-delay-ms = <100>; + }; + ++ emmc_pwrseq: emmc-pwrseq { ++ compatible = "mmc-pwrseq-emmc"; ++ pinctrl-0 = <&emmc_reset>; ++ pinctrl-names = "default"; ++ reset-gpios = <&gpio3 RK_PB1 GPIO_ACTIVE_LOW>; ++ }; ++ + /* + * Sound taken from tinkerboard device tree, adapted to q8. + */ @@ -217,27 +232,27 @@ + sound-dai = <&i2s>; + }; + }; -+ -+ soundcard-spdif { -+ compatible = "simple-audio-card"; -+ simple-audio-card,name = "SPDIF"; -+ simple-audio-card,dai-link@1 { -+ -+ cpu { -+ sound-dai = <&spdif>; -+ }; -+ -+ codec { -+ sound-dai = <&spdif_out>; -+ }; -+ -+ }; -+ }; + -+ spdif_out: spdif-out { -+ compatible = "linux,spdif-dit"; -+ #sound-dai-cells = <0>; -+ }; ++ soundcard-spdif { ++ compatible = "simple-audio-card"; ++ simple-audio-card,name = "SPDIF"; ++ simple-audio-card,dai-link@1 { ++ ++ cpu { ++ sound-dai = <&spdif>; ++ }; ++ ++ codec { ++ sound-dai = <&spdif_out>; ++ }; ++ ++ }; ++ }; ++ ++ spdif_out: spdif-out { ++ compatible = "linux,spdif-dit"; ++ #sound-dai-cells = <0>; ++ }; + +}; + @@ -303,8 +318,8 @@ + regulator-boot-on; + vin-supply = <&vcc_sys>; + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; + }; + + vdd_gpu: syr828@41 { @@ -318,8 +333,8 @@ + regulator-always-on; + vin-supply = <&vcc_sys>; + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; + }; + + hym8563: hym8563@51 { @@ -351,7 +366,7 @@ + wakeup-source; + + regulators { -+ ++ + /* + * Regulator controlling DDR memory - always on + */ @@ -360,9 +375,12 @@ + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -374,9 +392,12 @@ + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -390,9 +411,12 @@ + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -405,9 +429,12 @@ + regulator-min-microvolt = <2000000>; + regulator-max-microvolt = <2000000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -416,13 +443,16 @@ + */ + vccio_sd: REG5 { + regulator-name = "vccio_sd"; -+ regulator-min-microvolt = <1800000>; ++ regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; ++ regulator-on-in-suspend; + regulator-suspend-microvolt = <3300000>; -+ }; ++ }; ++ */ + }; + + /* @@ -434,9 +464,12 @@ + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-always-on; ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -449,9 +482,14 @@ + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; ++ ++ /* ++ The regulator can be set off in suspend, but kernel 5.4 modifications ++ to enable suspend for ACT8865 device break the ACT8846 + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; ++ */ + }; + + /* @@ -463,9 +501,14 @@ + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; // Turn this on to get SPDIF! ++ ++ /* ++ The regulator can be set off in suspend, but kernel 5.4 modifications ++ to enable suspend for ACT8865 device break the ACT8846 + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; ++ */ + }; + + /* @@ -475,9 +518,13 @@ + regulator-name = "vcc_lan"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; ++ ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -489,9 +536,13 @@ + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-always-on; ++ ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -503,9 +554,13 @@ + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; ++ ++ /* ++ * Broken in kernel 5.4 + regulator-state-mem { -+ regulator-on-in-suspend; -+ }; ++ regulator-on-in-suspend; ++ }; ++ */ + }; + + /* @@ -518,9 +573,14 @@ + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; ++ ++ /* ++ The regulator can be set off in suspend, but kernel 5.4 modifications ++ to enable suspend for ACT8865 device break the ACT8846 + regulator-state-mem { -+ regulator-off-in-suspend; -+ }; ++ regulator-off-in-suspend; ++ }; ++ */ + }; + }; + }; @@ -535,7 +595,7 @@ +}; + +&i2c4 { -+ ++ + /* + * Here should go the RK1000 audio codec parts, but seems that + * there is no driver in linux kernel at the moment, so we can't @@ -545,7 +605,7 @@ + * http://dl.radxa.com/rock/docs/hw/ds/RK1000-S%20DATASHEET%20V14.pdf + */ + status = "okay"; -+ ++ +}; + +&i2c5 { @@ -575,12 +635,12 @@ + bias-pull-up; + drive-strength = <8>; + }; -+ ++ + pcfg_pull_up_drv_8ma: pcfg-pull-up-drv-8ma { + bias-pull-up; + drive-strength = <8>; + }; -+ ++ + pcfg_pull_none_8ma: pcfg-pull-none-8ma { + bias-disable; + drive-strength = <8>; @@ -594,18 +654,18 @@ + pcfg_wl_int: pcfg-wl-int { + bias-pull-up; + }; -+ ++ + act8846 { -+ ++ + /* + * Original q8 device tree says: + * - gpio0 11 HIGH -> power hold -+ * - gpio7 1 LOW -> possibly pmic-vsel, we don't care -+ */ ++ * - gpio7 1 LOW -> possibly pmic-vsel, we don't care ++ */ + pmic_vsel: pmic-vsel { + rockchip,pins = <7 1 RK_FUNC_GPIO &pcfg_output_low>; + }; -+ ++ + pwr_hold: pwr-hold { + rockchip,pins = <0 11 RK_FUNC_GPIO &pcfg_pull_up>; + }; @@ -650,7 +710,7 @@ + }; + + sdmmc { -+ ++ + /* + * Copied from firefly board definition to give more drive to + * the sdmmc pins. The Q8 seems to be quite able to drive @@ -701,14 +761,22 @@ + }; + + }; -+ -+ ++ ++ + wireless-bluetooth { + uart0_gpios: uart0-gpios { + rockchip,pins = <4 19 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + ++ emmc { ++ ++ emmc_reset: emmc-reset { ++ rockchip,pins = <3 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>; ++ }; ++ ++ }; ++ +}; + +&saradc { @@ -717,24 +785,34 @@ +}; + +&emmc { -+ ++ + /* -+ * eMMC seems to be 52Mhz device on q8 devices, so set it here -+ * vmmc-supply and vqmmc-supply are removed because they hang -+ * u-boot >= v2018.03 -+ * From the original q8l firmware and eMMC datasheet it also should -+ * support DDR highspeed mode, but using mmc-ddr-3_3v or mmc-ddr-1_8v -+ * properties are not working ++ * eMMC is a 52Mhz DDR device on q8 devices, so set it here. ++ * Setting default-sample-rate to 180 degrees is very important, ++ * otherwise the eMMC is not stable and may not be able to negotiate ++ * the right clock. ++ * Despite the code already seems to use 180 degree phase when ++ * MMC + 8bit bus is set, we need to set default phase here too. ++ * ++ * Huge hint came from this patch: ++ * https://patchwork.kernel.org/patch/11129183/ ++ * + */ -+ clock-frequency = <50000000>; -+ + broken-cd; + bus-width = <8>; + cap-mmc-highspeed; ++ + disable-wp; + non-removable; + pinctrl-names = "default"; -+ pinctrl-0 = <&emmc_clk>, <&emmc_cmd>, <&emmc_pwr>, <&emmc_bus8>; ++ pinctrl-0 = <&emmc_clk>, <&emmc_cmd>, <&emmc_bus8>; ++ ++ vmmc-supply = <&vcc_io>; ++ vqmmc-supply = <&vcc_flash>; ++ ++ mmc-pwrseq = <&emmc_pwrseq>; ++ mmc-ddr-1_8v; ++ rockchip,default-sample-phase = <180>; + + status = "okay"; +}; @@ -746,9 +824,7 @@ + cap-mmc-highspeed; + cap-sd-highspeed; + cd-gpios = <&gpio6 RK_PC6 GPIO_ACTIVE_LOW>; -+ cd-debounce-delay-ms = <200>; -+ post-power-on-delay-ms = <50>; -+ supports-cqe; ++ cd-debounce-delay-ms = <500>; + disable-wp; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc_clk>, <&sdmmc_cmd>, <&sdmmc_cd>, <&sdmmc_bus4>; @@ -766,33 +842,33 @@ +&sdio0 { + #address-cells = <1>; + #size-cells = <0>; -+ ++ + bus-width = <4>; + mmc-pwrseq = <&sdio0_pwrseq>; -+ ++ + vmmc-supply = <&vcc_io>; -+ vqmmc-supply = <&vcc_18>; // This must be the same as in io_domains, ++ vqmmc-supply = <&vcc_18>; // This must be the same as in io_domains, + // otherwise the mmc1 device won't be detected properly -+ -+// clock-frequency = <50000000>; -+// max-frequency = <50000000>; ++ ++ // clock-frequency = <50000000>; ++ // max-frequency = <50000000>; + + pinctrl-names = "default"; -+ pinctrl-0 = <&sdio0_bus4>, <&sdio0_cmd>, <&sdio0_clk>, <&sdio0_int>; -+ ++ pinctrl-0 = <&sdio0_bus4>, <&sdio0_cmd>, <&sdio0_clk>, <&sdio0_int>; ++ + cap-sdio-irq; + no-mmc; + no-sd; + cap-sd-highspeed; // required, otherwise does not work! -+ supports-sdio; ++ supports-sdio; + non-removable; -+ ++ + keep-power-in-suspend; + disable-wp; -+ -+ ++ ++ + status = "okay"; -+ ++ + brcmf: bcrmf@1 { + reg = <1>; + compatible = "brcm,bcm4329-fmac"; @@ -800,8 +876,8 @@ + interrupts = <30 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "host-wake"; + status = "okay"; -+ }; -+ ++ }; ++ + //sd-uhs-sdr104; // required to be disabled, otherwise the device get + // detected, but there is no communication + @@ -823,13 +899,13 @@ + * These dmas described here for uarts are present in original q8 board + * dts, so I replicate them here because documentation says that serial + * ports can have dmas. -+ * note: ++ * note: + * - uart0 is the serial port connected to the bluetooth module -+ * - uart2 is the onboard serial port -+ * ++ * - uart2 is the onboard serial port ++ * + * As ok kernel 4.19 DMA for serial ports is disabled because it makes + * the ports unusable -+ * ++ * + */ +&uart0 { + pinctrl-names = "default"; @@ -873,31 +949,25 @@ + * specify the proper resources for all the phys though. + * The reference patch which works in conjuction with the reset lines: + * https://patchwork.kernel.org/patch/9469811/ -+ * ++ * + */ +&usbphy { + status = "okay"; +}; -+ -+&usbphy0 { -+ vbus-supply = <&vcc_otg_5v>; -+}; -+ -+&usbphy2 { -+ vbus-supply = <&vcc_host_5v>; -+}; + +&usb_host0_ehci { -+ dr_mode = "host"; -+ reg = <0x0 0xff500000 0x0 0x20000>; -+ status = "disable"; ++ dr_mode = "host"; ++ reg = <0x0 0xff500000 0x0 0x20000>; ++ status = "disable"; +}; + +&usb_host1 { ++ vbus-supply = <&vcc_host_5v>; + status = "okay"; +}; + +&usb_otg { ++ vbus-supply = <&vcc_otg_5v>; + status = "okay"; +}; + @@ -924,18 +994,10 @@ + status = "okay"; +}; + -+//&vpu_service { -+// status = "okay"; -+//}; -+ +&hevc_mmu { + status = "okay"; +}; + -+//&hevc_service { -+// status = "okay"; -+//}; -+ +&wdt { + status = "okay"; +}; @@ -978,8 +1040,28 @@ + opp-1608000000 { + opp-microvolt = <1300000>; + }; ++ ++ /* ++ Remove the overclocking/turbo frequencies ++ */ ++ /delete-node/ opp@1704000000; ++ /delete-node/ opp@1800000000; ++ /delete-node/ opp@1896000000; ++ /delete-node/ opp@1920000000; ++ /delete-node/ opp@1992000000; ++ /delete-node/ opp@2016000000; ++ /delete-node/ opp@2040000000; ++ /delete-node/ opp@2064000000; ++ /delete-node/ opp@2088000000; ++ /delete-node/ opp@2112000000; ++ /delete-node/ opp@2136000000; ++ /delete-node/ opp@2160000000; ++ /delete-node/ opp@2184000000; ++ /delete-node/ opp@2208000000; ++ ++ +}; + +&gpiomem { -+ status = "okay"; ++ status = "okay"; +};