2023-06-04 15:00:07

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi,

Here's a set of patches to add support for the WiFi / Bluetooth chip on
the CI20.

WiFi works pretty well, provided it is used with the latest firmware
provided by linux-firmware. Bluetooth does not work very well here, as
I cannot get my wireless keyboard to pair; but it does detect it, and it
does see they key presses when I type the pairing code.

I only tested with a somewhat recent (~2022) Buildroot-based userspace.
I enabled WEXT compatibility because the CI20 is typically used with a
very old userspace, but I did not try to use it with old tools like
ifconfig/iwconfig.

Cheers,
-Paul

Paul Cercueil (9):
MIPS: DTS: CI20: Fix regulators
MIPS: DTS: CI20: Fix ACT8600 regulator node names
MIPS: DTS: CI20: Add parent supplies to ACT8600 regulators
MIPS: DTS: CI20: Do not force-enable CIM and WiFi regulators
MIPS: DTS: CI20: Misc. cleanups
MIPS: DTS: CI20: Parent MSCMUX clock to MPLL
MIPS: DTS: CI20: Enable support for WiFi / Bluetooth
MIPS: configs: CI20: Regenerate defconfig
MIPS: configs: CI20: Enable WiFi / Bluetooth

arch/mips/boot/dts/ingenic/ci20.dts | 148 +++++++++++++++++++---------
arch/mips/configs/ci20_defconfig | 47 ++++++---
2 files changed, 133 insertions(+), 62 deletions(-)

--
2.39.2



2023-06-04 15:00:10

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 1/9] MIPS: DTS: CI20: Fix regulators

The regulators don't have any "reg" property, and therefore shouldn't
use an unit address in their node names. They also don't need to specify
the GPIO_ACTIVE_LOW flag, which will be ignored anyway, as they are
active-high.

Signed-off-by: Paul Cercueil <[email protected]>
---
arch/mips/boot/dts/ingenic/ci20.dts | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
index 239c4537484d..e76953dce2e7 100644
--- a/arch/mips/boot/dts/ingenic/ci20.dts
+++ b/arch/mips/boot/dts/ingenic/ci20.dts
@@ -67,14 +67,14 @@ led-3 {
};
};

- eth0_power: fixedregulator@0 {
+ eth0_power: fixedregulator-0 {
compatible = "regulator-fixed";

regulator-name = "eth0_power";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;

- gpio = <&gpb 25 GPIO_ACTIVE_LOW>;
+ gpio = <&gpb 25 0>;
enable-active-high;
};

@@ -97,23 +97,23 @@ ir: ir {
gpios = <&gpe 3 GPIO_ACTIVE_LOW>;
};

- wlan0_power: fixedregulator@1 {
+ wlan0_power: fixedregulator-1 {
compatible = "regulator-fixed";

regulator-name = "wlan0_power";

- gpio = <&gpb 19 GPIO_ACTIVE_LOW>;
+ gpio = <&gpb 19 0>;
enable-active-high;
};

- otg_power: fixedregulator@2 {
+ otg_power: fixedregulator-2 {
compatible = "regulator-fixed";

regulator-name = "otg_power";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;

- gpio = <&gpf 15 GPIO_ACTIVE_LOW>;
+ gpio = <&gpf 15 0>;
enable-active-high;
};
};
--
2.39.2


2023-06-04 15:00:33

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 2/9] MIPS: DTS: CI20: Fix ACT8600 regulator node names

The Device Tree was using invalid node names for the ACT8600 regulators.
To be fair, it is not the original committer's fault, as the
documentation did gives invalid names as well.

In theory, the fix should have been to modify the driver to accept the
alternative names. However, even though the act8865 driver spits
warnings, the kernel seemed to work fine with what is currently
supported upstream. For that reason, I think it is okay to just update
the DTS.

I removed the "regulator-name" too, since they really didn't bring any
information. The node names are enough.

Fixes: 73f2b940474d ("MIPS: CI20: DTS: Add I2C nodes")
Signed-off-by: Paul Cercueil <[email protected]>
---
arch/mips/boot/dts/ingenic/ci20.dts | 27 ++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
index e76953dce2e7..5361606c5e13 100644
--- a/arch/mips/boot/dts/ingenic/ci20.dts
+++ b/arch/mips/boot/dts/ingenic/ci20.dts
@@ -237,59 +237,49 @@ &i2c0 {
act8600: act8600@5a {
compatible = "active-semi,act8600";
reg = <0x5a>;
- status = "okay";

regulators {
- vddcore: SUDCDC1 {
- regulator-name = "DCDC_REG1";
+ vddcore: DCDC1 {
regulator-min-microvolt = <1100000>;
regulator-max-microvolt = <1100000>;
regulator-always-on;
};
- vddmem: SUDCDC2 {
- regulator-name = "DCDC_REG2";
+ vddmem: DCDC2 {
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <1500000>;
regulator-always-on;
};
- vcc_33: SUDCDC3 {
- regulator-name = "DCDC_REG3";
+ vcc_33: DCDC3 {
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
- vcc_50: SUDCDC4 {
- regulator-name = "SUDCDC_REG4";
+ vcc_50: SUDCDC_REG4 {
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-always-on;
};
- vcc_25: LDO_REG5 {
- regulator-name = "LDO_REG5";
+ vcc_25: LDO5 {
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <2500000>;
regulator-always-on;
};
- wifi_io: LDO_REG6 {
- regulator-name = "LDO_REG6";
+ wifi_io: LDO6 {
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <2500000>;
regulator-always-on;
};
- vcc_28: LDO_REG7 {
- regulator-name = "LDO_REG7";
+ cim_io_28: LDO7 {
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-always-on;
};
- vcc_15: LDO_REG8 {
- regulator-name = "LDO_REG8";
+ cim_io_15: LDO8 {
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <1500000>;
regulator-always-on;
};
vrtc_18: LDO_REG9 {
- regulator-name = "LDO_REG9";
/* Despite the datasheet stating 3.3V
* for REG9 and the driver expecting that,
* REG9 outputs 1.8V.
@@ -303,7 +293,6 @@ vrtc_18: LDO_REG9 {
regulator-always-on;
};
vcc_11: LDO_REG10 {
- regulator-name = "LDO_REG10";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1200000>;
regulator-always-on;
--
2.39.2


2023-06-04 15:00:42

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 3/9] MIPS: DTS: CI20: Add parent supplies to ACT8600 regulators

Provide parent regulators to the ACT8600 regulators that need one.

Signed-off-by: Paul Cercueil <[email protected]>
---
arch/mips/boot/dts/ingenic/ci20.dts | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
index 5361606c5e13..662796acda41 100644
--- a/arch/mips/boot/dts/ingenic/ci20.dts
+++ b/arch/mips/boot/dts/ingenic/ci20.dts
@@ -242,16 +242,19 @@ regulators {
vddcore: DCDC1 {
regulator-min-microvolt = <1100000>;
regulator-max-microvolt = <1100000>;
+ vp1-supply = <&vcc_33v>;
regulator-always-on;
};
vddmem: DCDC2 {
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <1500000>;
+ vp2-supply = <&vcc_33v>;
regulator-always-on;
};
vcc_33: DCDC3 {
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
+ vp3-supply = <&vcc_33v>;
regulator-always-on;
};
vcc_50: SUDCDC_REG4 {
@@ -262,21 +265,25 @@ vcc_50: SUDCDC_REG4 {
vcc_25: LDO5 {
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <2500000>;
+ inl-supply = <&vcc_33v>;
regulator-always-on;
};
wifi_io: LDO6 {
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <2500000>;
+ inl-supply = <&vcc_33v>;
regulator-always-on;
};
cim_io_28: LDO7 {
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
+ inl-supply = <&vcc_33v>;
regulator-always-on;
};
cim_io_15: LDO8 {
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <1500000>;
+ inl-supply = <&vcc_33v>;
regulator-always-on;
};
vrtc_18: LDO_REG9 {
--
2.39.2


2023-06-04 15:00:46

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 4/9] MIPS: DTS: CI20: Do not force-enable CIM and WiFi regulators

These regulators should be enabled by their respective drivers.

Signed-off-by: Paul Cercueil <[email protected]>
---
arch/mips/boot/dts/ingenic/ci20.dts | 3 ---
1 file changed, 3 deletions(-)

diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
index 662796acda41..7f6e7a4e3915 100644
--- a/arch/mips/boot/dts/ingenic/ci20.dts
+++ b/arch/mips/boot/dts/ingenic/ci20.dts
@@ -272,19 +272,16 @@ wifi_io: LDO6 {
regulator-min-microvolt = <2500000>;
regulator-max-microvolt = <2500000>;
inl-supply = <&vcc_33v>;
- regulator-always-on;
};
cim_io_28: LDO7 {
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
inl-supply = <&vcc_33v>;
- regulator-always-on;
};
cim_io_15: LDO8 {
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <1500000>;
inl-supply = <&vcc_33v>;
- regulator-always-on;
};
vrtc_18: LDO_REG9 {
/* Despite the datasheet stating 3.3V
--
2.39.2


2023-06-04 15:01:02

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 5/9] MIPS: DTS: CI20: Misc. cleanups

- Use the standard "ecc-engine" property instead of the custom
"ingenic,bch-controller" to get a handle to the BCH controller.

- Respect cell sizes in the Ethernet controller node.

- Use proper macro for interrupt type instead of hardcoding magic
values.

Signed-off-by: Paul Cercueil <[email protected]>
---
arch/mips/boot/dts/ingenic/ci20.dts | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
index 7f6e7a4e3915..b7dbafa1f85d 100644
--- a/arch/mips/boot/dts/ingenic/ci20.dts
+++ b/arch/mips/boot/dts/ingenic/ci20.dts
@@ -356,7 +356,7 @@ nandc: nand-controller@1 {
#address-cells = <1>;
#size-cells = <0>;

- ingenic,bch-controller = <&bch>;
+ ecc-engine = <&bch>;

ingenic,nemc-tAS = <10>;
ingenic,nemc-tAH = <5>;
@@ -422,8 +422,8 @@ dm9000@6 {
pinctrl-names = "default";
pinctrl-0 = <&pins_nemc_cs6>;

- reg = <6 0 1 /* addr */
- 6 2 1>; /* data */
+ reg = <6 0 1>, /* addr */
+ <6 2 1>; /* data */

ingenic,nemc-tAS = <15>;
ingenic,nemc-tAH = <10>;
@@ -435,7 +435,7 @@ dm9000@6 {
vcc-supply = <&eth0_power>;

interrupt-parent = <&gpe>;
- interrupts = <19 4>;
+ interrupts = <19 IRQ_TYPE_EDGE_RISING>;

nvmem-cells = <&eth0_addr>;
nvmem-cell-names = "mac-address";
--
2.39.2


2023-06-04 15:01:21

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 7/9] MIPS: DTS: CI20: Enable support for WiFi / Bluetooth

Wire the WiFi/Bluetooth chip properly in the Device Tree.

- Provide it with the correct regulators and clocks;
- Change the MMC I/O bus to 1.8V which seems to be enough;
- Change the MMC I/O bus frequency to 25 MHz as 50 MHz causes errors;
- Fix the Bluetooth powerdown GPIO being inverted and add reset GPIO;
- Convert host-wakeup-gpios to IRQ.

With these changes, the WiFi works properly with the latest firmware
provided by linux-firmware. The Bluetooth does not work very well here,
as I cannot get my wireless keyboard to pair; but it does detect it, and
it does see the key presses when I type the pairing code.

Signed-off-by: Paul Cercueil <[email protected]>
---
arch/mips/boot/dts/ingenic/ci20.dts | 88 ++++++++++++++++++++++++-----
1 file changed, 73 insertions(+), 15 deletions(-)

diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
index bdbd064c90e1..cec0caa2350c 100644
--- a/arch/mips/boot/dts/ingenic/ci20.dts
+++ b/arch/mips/boot/dts/ingenic/ci20.dts
@@ -97,10 +97,15 @@ ir: ir {
gpios = <&gpe 3 GPIO_ACTIVE_LOW>;
};

- wlan0_power: fixedregulator-1 {
+ bt_power: fixedregulator-1 {
compatible = "regulator-fixed";

- regulator-name = "wlan0_power";
+ regulator-name = "bt_power";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-settling-time-us = <1400>;
+
+ vin-supply = <&vcc_50>;

gpio = <&gpb 19 0>;
enable-active-high;
@@ -116,6 +121,40 @@ otg_power: fixedregulator-2 {
gpio = <&gpf 15 0>;
enable-active-high;
};
+
+ wifi_power: fixedregulator-4 {
+ compatible = "regulator-fixed";
+
+ regulator-name = "wifi_power";
+
+ /*
+ * Technically it's 5V, the WiFi chip has its own internal
+ * regulators; but the MMC/SD subsystem won't accept such a
+ * value.
+ */
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-settling-time-us = <150000>;
+
+ vin-supply = <&bt_power>;
+ };
+
+ vcc_33v: fixedregulator-5 {
+ compatible = "regulator-fixed";
+
+ regulator-name = "vcc_33v";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ };
+
+ wifi_pwrseq: pwrseq {
+ compatible = "mmc-pwrseq-simple";
+ reset-gpios = <&gpf 7 GPIO_ACTIVE_LOW>;
+
+ clocks = <&rtc_dev>;
+ clock-names = "ext_clock";
+ };
};

&ext {
@@ -161,24 +200,33 @@ &mmc0 {
pinctrl-0 = <&pins_mmc0>;

cd-gpios = <&gpf 20 GPIO_ACTIVE_LOW>;
+ vmmc-supply = <&vcc_33v>;
+ vqmmc-supply = <&vcc_33v>;
};

&mmc1 {
status = "okay";

bus-width = <4>;
- max-frequency = <50000000>;
+ max-frequency = <25000000>;
+ mmc-pwrseq = <&wifi_pwrseq>;
+ vmmc-supply = <&wifi_power>;
+ vqmmc-supply = <&wifi_io>;
non-removable;

pinctrl-names = "default";
pinctrl-0 = <&pins_mmc1>;

- brcmf: wifi@1 {
-/* reg = <4>;*/
- compatible = "brcm,bcm4330-fmac";
- vcc-supply = <&wlan0_power>;
- device-wakeup-gpios = <&gpd 9 GPIO_ACTIVE_HIGH>;
- shutdown-gpios = <&gpf 7 GPIO_ACTIVE_LOW>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ wifi@1 {
+ compatible = "brcm,bcm4329-fmac";
+ reg = <1>;
+
+ interrupt-parent = <&gpd>;
+ interrupts = <9 IRQ_TYPE_EDGE_FALLING>;
+ interrupt-names = "host-wake";
};
};

@@ -205,11 +253,20 @@ &uart2 {

bluetooth {
compatible = "brcm,bcm4330-bt";
- reset-gpios = <&gpf 8 GPIO_ACTIVE_HIGH>;
- vcc-supply = <&wlan0_power>;
+
+ vbat-supply = <&bt_power>;
+ vddio-supply = <&wifi_io>;
+
+ interrupt-parent = <&gpf>;
+ interrupts = <6 IRQ_TYPE_EDGE_RISING>;
+ interrupt-names = "host-wakeup";
+
+ clocks = <&rtc_dev>;
+ clock-names = "lpo";
+
+ reset-gpios = <&gpf 8 GPIO_ACTIVE_LOW>;
device-wakeup-gpios = <&gpf 5 GPIO_ACTIVE_HIGH>;
- host-wakeup-gpios = <&gpf 6 GPIO_ACTIVE_HIGH>;
- shutdown-gpios = <&gpf 4 GPIO_ACTIVE_LOW>;
+ shutdown-gpios = <&gpf 4 GPIO_ACTIVE_HIGH>;
};
};

@@ -270,8 +327,9 @@ vcc_25: LDO5 {
regulator-always-on;
};
wifi_io: LDO6 {
- regulator-min-microvolt = <2500000>;
- regulator-max-microvolt = <2500000>;
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-settling-time-us = <150000>;
inl-supply = <&vcc_33v>;
};
cim_io_28: LDO7 {
--
2.39.2


2023-06-04 15:01:41

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 8/9] MIPS: configs: CI20: Regenerate defconfig

Just a "make ci20_defconfig menuconfig savedefconfig"
Without changing anything in the menuconfig. No functional change.

Signed-off-by: Paul Cercueil <[email protected]>
---
arch/mips/configs/ci20_defconfig | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/arch/mips/configs/ci20_defconfig b/arch/mips/configs/ci20_defconfig
index 11f08b6a3013..a161387f8fce 100644
--- a/arch/mips/configs/ci20_defconfig
+++ b/arch/mips/configs/ci20_defconfig
@@ -19,19 +19,19 @@ CONFIG_USER_NS=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_KALLSYMS_ALL=y
CONFIG_EMBEDDED=y
-# CONFIG_VM_EVENT_COUNTERS is not set
-# CONFIG_COMPAT_BRK is not set
-CONFIG_SLAB=y
CONFIG_MACH_INGENIC_SOC=y
CONFIG_JZ4780_CI20=y
CONFIG_HIGHMEM=y
CONFIG_HZ_100=y
-# CONFIG_SECCOMP is not set
# CONFIG_SUSPEND is not set
+# CONFIG_SECCOMP is not set
CONFIG_MODULES=y
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_SLAB=y
+# CONFIG_COMPAT_BRK is not set
# CONFIG_COMPACTION is not set
CONFIG_CMA=y
+# CONFIG_VM_EVENT_COUNTERS is not set
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
@@ -71,7 +71,6 @@ CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL=y
# CONFIG_WLAN is not set
CONFIG_KEYBOARD_GPIO=m
# CONFIG_INPUT_MOUSE is not set
-CONFIG_VT_HW_CONSOLE_BINDING=y
CONFIG_LEGACY_PTY_COUNT=2
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
@@ -99,13 +98,12 @@ CONFIG_IR_GPIO_CIR=m
CONFIG_IR_GPIO_TX=m
CONFIG_MEDIA_SUPPORT=m
CONFIG_DRM=m
+CONFIG_DRM_DISPLAY_CONNECTOR=m
CONFIG_DRM_INGENIC=m
CONFIG_DRM_INGENIC_DW_HDMI=m
-CONFIG_DRM_DISPLAY_CONNECTOR=m
-# CONFIG_VGA_CONSOLE is not set
CONFIG_FB=y
+# CONFIG_VGA_CONSOLE is not set
CONFIG_FRAMEBUFFER_CONSOLE=y
-# CONFIG_HID is not set
CONFIG_USB=y
CONFIG_USB_STORAGE=y
CONFIG_USB_DWC2=y
@@ -125,7 +123,6 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=y
CONFIG_LEDS_TRIGGER_BACKLIGHT=m
CONFIG_LEDS_TRIGGER_CPU=y
CONFIG_LEDS_TRIGGER_ACTIVITY=y
-CONFIG_LEDS_TRIGGER_GPIO=y
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
CONFIG_LEDS_TRIGGER_TRANSIENT=y
CONFIG_LEDS_TRIGGER_CAMERA=m
@@ -144,7 +141,6 @@ CONFIG_JZ4780_NEMC=y
CONFIG_PWM=y
CONFIG_PWM_JZ4740=m
CONFIG_NVMEM_JZ4780_EFUSE=y
-CONFIG_JZ4770_PHY=y
CONFIG_EXT4_FS=y
# CONFIG_DNOTIFY is not set
CONFIG_AUTOFS_FS=y
@@ -157,7 +153,6 @@ CONFIG_CONFIGFS_FS=y
CONFIG_UBIFS_FS=y
CONFIG_NFS_FS=y
CONFIG_ROOT_NFS=y
-CONFIG_NLS=y
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_CODEPAGE_737=y
CONFIG_NLS_CODEPAGE_775=y
@@ -206,7 +201,6 @@ CONFIG_DEBUG_FS=y
CONFIG_PANIC_ON_OOPS=y
CONFIG_PANIC_TIMEOUT=10
# CONFIG_SCHED_DEBUG is not set
-# CONFIG_DEBUG_PREEMPT is not set
CONFIG_STACKTRACE=y
# CONFIG_FTRACE is not set
CONFIG_CMDLINE_BOOL=y
--
2.39.2


2023-06-04 15:02:36

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 9/9] MIPS: configs: CI20: Enable WiFi / Bluetooth

Enable the required drivers for the WiFi / Bluetooth functionality.

I enabled WEXT compatibility as well since the CI20 is typically used
with a very old userspace.

Signed-off-by: Paul Cercueil <[email protected]>
---
arch/mips/configs/ci20_defconfig | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/arch/mips/configs/ci20_defconfig b/arch/mips/configs/ci20_defconfig
index a161387f8fce..920b27977dac 100644
--- a/arch/mips/configs/ci20_defconfig
+++ b/arch/mips/configs/ci20_defconfig
@@ -40,7 +40,12 @@ CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
# CONFIG_INET_DIAG is not set
# CONFIG_IPV6 is not set
-# CONFIG_WIRELESS is not set
+CONFIG_BT=m
+# CONFIG_BT_LE is not set
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_BCM=y
+CONFIG_CFG80211=m
+CONFIG_CFG80211_WEXT=y
CONFIG_DEVTMPFS=y
CONFIG_FW_LOADER=m
# CONFIG_ALLOW_DEV_COREDUMP is not set
@@ -68,7 +73,25 @@ CONFIG_DM9000_FORCE_SIMPLE_PHY_POLL=y
# CONFIG_NET_VENDOR_STMICRO is not set
# CONFIG_NET_VENDOR_VIA is not set
# CONFIG_NET_VENDOR_WIZNET is not set
-# CONFIG_WLAN is not set
+# CONFIG_WLAN_VENDOR_ADMTEK is not set
+# CONFIG_WLAN_VENDOR_ATH is not set
+# CONFIG_WLAN_VENDOR_ATMEL is not set
+CONFIG_BRCMFMAC=m
+# CONFIG_WLAN_VENDOR_CISCO is not set
+# CONFIG_WLAN_VENDOR_INTEL is not set
+# CONFIG_WLAN_VENDOR_INTERSIL is not set
+# CONFIG_WLAN_VENDOR_MARVELL is not set
+# CONFIG_WLAN_VENDOR_MEDIATEK is not set
+# CONFIG_WLAN_VENDOR_MICROCHIP is not set
+# CONFIG_WLAN_VENDOR_PURELIFI is not set
+# CONFIG_WLAN_VENDOR_RALINK is not set
+# CONFIG_WLAN_VENDOR_REALTEK is not set
+# CONFIG_WLAN_VENDOR_RSI is not set
+# CONFIG_WLAN_VENDOR_SILABS is not set
+# CONFIG_WLAN_VENDOR_ST is not set
+# CONFIG_WLAN_VENDOR_TI is not set
+# CONFIG_WLAN_VENDOR_ZYDAS is not set
+# CONFIG_WLAN_VENDOR_QUANTENNA is not set
CONFIG_KEYBOARD_GPIO=m
# CONFIG_INPUT_MOUSE is not set
CONFIG_LEGACY_PTY_COUNT=2
@@ -78,6 +101,7 @@ CONFIG_SERIAL_8250_NR_UARTS=5
CONFIG_SERIAL_8250_RUNTIME_UARTS=5
CONFIG_SERIAL_8250_INGENIC=y
CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_SERIAL_DEV_BUS=y
CONFIG_I2C=y
CONFIG_I2C_JZ4780=y
CONFIG_SPI=y
@@ -191,6 +215,7 @@ CONFIG_NLS_ISO8859_15=y
CONFIG_NLS_KOI8_R=y
CONFIG_NLS_KOI8_U=y
CONFIG_NLS_UTF8=y
+# CONFIG_CRYPTO_AES is not set
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=32
CONFIG_PRINTK_TIME=y
--
2.39.2


2023-06-04 15:10:29

by Paul Cercueil

[permalink] [raw]
Subject: [PATCH 6/9] MIPS: DTS: CI20: Parent MSCMUX clock to MPLL

This makes it possible to clock the SD cards much higher, as the MPLL is
running at 1.2 GHz by default. The previous parent was the EXT clock,
which caused the SD cards to be clocked at 24 MHz maximum.

Signed-off-by: Paul Cercueil <[email protected]>
---
arch/mips/boot/dts/ingenic/ci20.dts | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
index b7dbafa1f85d..bdbd064c90e1 100644
--- a/arch/mips/boot/dts/ingenic/ci20.dts
+++ b/arch/mips/boot/dts/ingenic/ci20.dts
@@ -129,10 +129,11 @@ &cgu {
*/
assigned-clocks = <&cgu JZ4780_CLK_OTGPHY>, <&cgu JZ4780_CLK_RTC>,
<&cgu JZ4780_CLK_SSIPLL>, <&cgu JZ4780_CLK_SSI>,
- <&cgu JZ4780_CLK_HDMI>;
+ <&cgu JZ4780_CLK_HDMI>, <&cgu JZ4780_CLK_MSCMUX>;
assigned-clock-parents = <0>, <&cgu JZ4780_CLK_RTCLK>,
<&cgu JZ4780_CLK_MPLL>,
- <&cgu JZ4780_CLK_SSIPLL>;
+ <&cgu JZ4780_CLK_SSIPLL>,
+ <0>, <&cgu JZ4780_CLK_MPLL>;
assigned-clock-rates = <48000000>, <0>, <54000000>, <0>, <27000000>;
};

--
2.39.2


2023-06-09 09:32:32

by Thomas Bogendoerfer

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

On Sun, Jun 04, 2023 at 04:56:33PM +0200, Paul Cercueil wrote:
> Hi,
>
> Here's a set of patches to add support for the WiFi / Bluetooth chip on
> the CI20.
>
> WiFi works pretty well, provided it is used with the latest firmware
> provided by linux-firmware. Bluetooth does not work very well here, as
> I cannot get my wireless keyboard to pair; but it does detect it, and it
> does see they key presses when I type the pairing code.
>
> I only tested with a somewhat recent (~2022) Buildroot-based userspace.
> I enabled WEXT compatibility because the CI20 is typically used with a
> very old userspace, but I did not try to use it with old tools like
> ifconfig/iwconfig.
>
> Cheers,
> -Paul
>
> Paul Cercueil (9):
> MIPS: DTS: CI20: Fix regulators
> MIPS: DTS: CI20: Fix ACT8600 regulator node names
> MIPS: DTS: CI20: Add parent supplies to ACT8600 regulators
> MIPS: DTS: CI20: Do not force-enable CIM and WiFi regulators
> MIPS: DTS: CI20: Misc. cleanups
> MIPS: DTS: CI20: Parent MSCMUX clock to MPLL
> MIPS: DTS: CI20: Enable support for WiFi / Bluetooth
> MIPS: configs: CI20: Regenerate defconfig
> MIPS: configs: CI20: Enable WiFi / Bluetooth
>
> arch/mips/boot/dts/ingenic/ci20.dts | 148 +++++++++++++++++++---------
> arch/mips/configs/ci20_defconfig | 47 ++++++---
> 2 files changed, 133 insertions(+), 62 deletions(-)
>
> --
> 2.39.2

series applied to mips-next.

Thomas.

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]

2023-06-15 07:18:30

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 2/9] MIPS: DTS: CI20: Fix ACT8600 regulator node names



> Am 04.06.2023 um 16:56 schrieb Paul Cercueil <[email protected]>:
>
> The Device Tree was using invalid node names for the ACT8600 regulators.
> To be fair, it is not the original committer's fault, as the
> documentation did gives invalid names as well.

s/did gives /did give /

>
> In theory, the fix should have been to modify the driver to accept the
> alternative names. However, even though the act8865 driver spits
> warnings, the kernel seemed to work fine with what is currently
> supported upstream. For that reason, I think it is okay to just update
> the DTS.
>
> I removed the "regulator-name" too, since they really didn't bring any
> information. The node names are enough.

For me this patch breaks boot on my CI20 V2a - but I don't see why.
Maybe the driver or something else relies on regulator names indirectly?

Last and only signs of activity:

U-Boot 2013.10-rc3-00096-gef995a1-dirty (Apr 13 2019 - 19:15:18)

Board: ci20 (r2) (Ingenic XBurst JZ4780 SoC)
DRAM: 1 GiB
NAND: 8192 MiB
MMC: jz_mmc msc1: 0
*** Warning - bad CRC, using default environment

In: eserial4
Out: eserial4
Err: eserial4
Net: dm9000
Hit any key to stop autoboot: 0
4357173 bytes read in 724 ms (5.7 MiB/s)
## Booting kernel from Legacy Image at 88000000 ...
Image Name: Linux-6.4.0-rc6+
Image Type: MIPS Linux Kernel Image (gzip compressed)
Data Size: 4357109 Bytes = 4.2 MiB
Load Address: 80100000
Entry Point: 80718080
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK

Starting kernel ...

[ 0.070854] jz4780-nemc 13410000.nemc: /nemc@13410000/efuse@d0 requests invalid bank 0
[ 0.078858] jz4780-nemc 13410000.nemc: /nemc@13410000/efuse@d0 has no addresses
[ 0.109013] jz4740-rtc 10003000.rtc: hctosys: unable to read the hardware clock
[ 0.199104] dm9000 16000000.dm9000: read wrong id 0x00000a46

--- hangs ---

>
> Fixes: 73f2b940474d ("MIPS: CI20: DTS: Add I2C nodes")
> Signed-off-by: Paul Cercueil <[email protected]>
> ---
> arch/mips/boot/dts/ingenic/ci20.dts | 27 ++++++++-------------------
> 1 file changed, 8 insertions(+), 19 deletions(-)
>
> diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
> index e76953dce2e7..5361606c5e13 100644
> --- a/arch/mips/boot/dts/ingenic/ci20.dts
> +++ b/arch/mips/boot/dts/ingenic/ci20.dts
> @@ -237,59 +237,49 @@ &i2c0 {
> act8600: act8600@5a {
> compatible = "active-semi,act8600";
> reg = <0x5a>;
> - status = "okay";
>
> regulators {
> - vddcore: SUDCDC1 {
> - regulator-name = "DCDC_REG1";
> + vddcore: DCDC1 {
> regulator-min-microvolt = <1100000>;
> regulator-max-microvolt = <1100000>;
> regulator-always-on;
> };
> - vddmem: SUDCDC2 {
> - regulator-name = "DCDC_REG2";
> + vddmem: DCDC2 {
> regulator-min-microvolt = <1500000>;
> regulator-max-microvolt = <1500000>;
> regulator-always-on;
> };
> - vcc_33: SUDCDC3 {
> - regulator-name = "DCDC_REG3";
> + vcc_33: DCDC3 {
> regulator-min-microvolt = <3300000>;
> regulator-max-microvolt = <3300000>;
> regulator-always-on;
> };
> - vcc_50: SUDCDC4 {
> - regulator-name = "SUDCDC_REG4";
> + vcc_50: SUDCDC_REG4 {
> regulator-min-microvolt = <5000000>;
> regulator-max-microvolt = <5000000>;
> regulator-always-on;
> };
> - vcc_25: LDO_REG5 {
> - regulator-name = "LDO_REG5";
> + vcc_25: LDO5 {
> regulator-min-microvolt = <2500000>;
> regulator-max-microvolt = <2500000>;
> regulator-always-on;
> };
> - wifi_io: LDO_REG6 {
> - regulator-name = "LDO_REG6";
> + wifi_io: LDO6 {
> regulator-min-microvolt = <2500000>;
> regulator-max-microvolt = <2500000>;
> regulator-always-on;
> };
> - vcc_28: LDO_REG7 {
> - regulator-name = "LDO_REG7";
> + cim_io_28: LDO7 {
> regulator-min-microvolt = <2800000>;
> regulator-max-microvolt = <2800000>;
> regulator-always-on;
> };
> - vcc_15: LDO_REG8 {
> - regulator-name = "LDO_REG8";
> + cim_io_15: LDO8 {
> regulator-min-microvolt = <1500000>;
> regulator-max-microvolt = <1500000>;
> regulator-always-on;
> };
> vrtc_18: LDO_REG9 {
> - regulator-name = "LDO_REG9";
> /* Despite the datasheet stating 3.3V
> * for REG9 and the driver expecting that,
> * REG9 outputs 1.8V.
> @@ -303,7 +293,6 @@ vrtc_18: LDO_REG9 {
> regulator-always-on;
> };
> vcc_11: LDO_REG10 {
> - regulator-name = "LDO_REG10";
> regulator-min-microvolt = <1200000>;
> regulator-max-microvolt = <1200000>;
> regulator-always-on;
> --
> 2.39.2
>


2023-06-15 07:31:45

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 3/9] MIPS: DTS: CI20: Add parent supplies to ACT8600 regulators



> Am 04.06.2023 um 16:56 schrieb Paul Cercueil <[email protected]>:
>
> Provide parent regulators to the ACT8600 regulators that need one.
>
> Signed-off-by: Paul Cercueil <[email protected]>
> ---
> arch/mips/boot/dts/ingenic/ci20.dts | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
> index 5361606c5e13..662796acda41 100644
> --- a/arch/mips/boot/dts/ingenic/ci20.dts
> +++ b/arch/mips/boot/dts/ingenic/ci20.dts
> @@ -242,16 +242,19 @@ regulators {
> vddcore: DCDC1 {
> regulator-min-microvolt = <1100000>;
> regulator-max-microvolt = <1100000>;
> + vp1-supply = <&vcc_33v>;

where is vcc_33v defined?

Unless [7/9] "MIPS: DTS: CI20: Enable support for WiFi / Bluetooth" is applied?

This way the patches in between can't be bisected.

> regulator-always-on;
> };
> vddmem: DCDC2 {
> regulator-min-microvolt = <1500000>;
> regulator-max-microvolt = <1500000>;
> + vp2-supply = <&vcc_33v>;
> regulator-always-on;
> };
> vcc_33: DCDC3 {
> regulator-min-microvolt = <3300000>;
> regulator-max-microvolt = <3300000>;
> + vp3-supply = <&vcc_33v>;
> regulator-always-on;
> };
> vcc_50: SUDCDC_REG4 {
> @@ -262,21 +265,25 @@ vcc_50: SUDCDC_REG4 {
> vcc_25: LDO5 {
> regulator-min-microvolt = <2500000>;
> regulator-max-microvolt = <2500000>;
> + inl-supply = <&vcc_33v>;
> regulator-always-on;
> };
> wifi_io: LDO6 {
> regulator-min-microvolt = <2500000>;
> regulator-max-microvolt = <2500000>;
> + inl-supply = <&vcc_33v>;
> regulator-always-on;
> };
> cim_io_28: LDO7 {
> regulator-min-microvolt = <2800000>;
> regulator-max-microvolt = <2800000>;
> + inl-supply = <&vcc_33v>;
> regulator-always-on;
> };
> cim_io_15: LDO8 {
> regulator-min-microvolt = <1500000>;
> regulator-max-microvolt = <1500000>;
> + inl-supply = <&vcc_33v>;
> regulator-always-on;
> };
> vrtc_18: LDO_REG9 {
> --
> 2.39.2
>


2023-06-15 07:32:03

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 7/9] MIPS: DTS: CI20: Enable support for WiFi / Bluetooth



> Am 04.06.2023 um 16:56 schrieb Paul Cercueil <[email protected]>:
>
> Wire the WiFi/Bluetooth chip properly in the Device Tree.
>
> - Provide it with the correct regulators and clocks;
> - Change the MMC I/O bus to 1.8V which seems to be enough;
> - Change the MMC I/O bus frequency to 25 MHz as 50 MHz causes errors;
> - Fix the Bluetooth powerdown GPIO being inverted and add reset GPIO;
> - Convert host-wakeup-gpios to IRQ.
>
> With these changes, the WiFi works properly with the latest firmware
> provided by linux-firmware. The Bluetooth does not work very well here,
> as I cannot get my wireless keyboard to pair; but it does detect it, and
> it does see the key presses when I type the pairing code.
>
> Signed-off-by: Paul Cercueil <[email protected]>
> ---
> arch/mips/boot/dts/ingenic/ci20.dts | 88 ++++++++++++++++++++++++-----
> 1 file changed, 73 insertions(+), 15 deletions(-)
>
> diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
> index bdbd064c90e1..cec0caa2350c 100644
> --- a/arch/mips/boot/dts/ingenic/ci20.dts
> +++ b/arch/mips/boot/dts/ingenic/ci20.dts
> @@ -97,10 +97,15 @@ ir: ir {
> gpios = <&gpe 3 GPIO_ACTIVE_LOW>;
> };
>
> - wlan0_power: fixedregulator-1 {
> + bt_power: fixedregulator-1 {
> compatible = "regulator-fixed";
>
> - regulator-name = "wlan0_power";
> + regulator-name = "bt_power";
> + regulator-min-microvolt = <3300000>;
> + regulator-max-microvolt = <3300000>;
> + regulator-settling-time-us = <1400>;
> +
> + vin-supply = <&vcc_50>;
>
> gpio = <&gpb 19 0>;
> enable-active-high;
> @@ -116,6 +121,40 @@ otg_power: fixedregulator-2 {
> gpio = <&gpf 15 0>;
> enable-active-high;
> };
> +
> + wifi_power: fixedregulator-4 {
> + compatible = "regulator-fixed";
> +
> + regulator-name = "wifi_power";
> +
> + /*
> + * Technically it's 5V, the WiFi chip has its own internal
> + * regulators; but the MMC/SD subsystem won't accept such a
> + * value.
> + */
> + regulator-min-microvolt = <3300000>;
> + regulator-max-microvolt = <3300000>;
> + regulator-settling-time-us = <150000>;
> +
> + vin-supply = <&bt_power>;
> + };
> +
> + vcc_33v: fixedregulator-5 {

why is this defined here? It is used earlier in [3/9] and not directly related to WiFi / Bluetooth

So please move into [3/9] or even before [3/9] as a separate patch.

> + compatible = "regulator-fixed";
> +
> + regulator-name = "vcc_33v";
> + regulator-min-microvolt = <3300000>;
> + regulator-max-microvolt = <3300000>;
> + regulator-always-on;
> + };
> +
> + wifi_pwrseq: pwrseq {
> + compatible = "mmc-pwrseq-simple";
> + reset-gpios = <&gpf 7 GPIO_ACTIVE_LOW>;
> +
> + clocks = <&rtc_dev>;
> + clock-names = "ext_clock";
> + };
> };
>
> &ext {
> @@ -161,24 +200,33 @@ &mmc0 {
> pinctrl-0 = <&pins_mmc0>;
>
> cd-gpios = <&gpf 20 GPIO_ACTIVE_LOW>;
> + vmmc-supply = <&vcc_33v>;
> + vqmmc-supply = <&vcc_33v>;
> };
>
> &mmc1 {
> status = "okay";
>
> bus-width = <4>;
> - max-frequency = <50000000>;
> + max-frequency = <25000000>;
> + mmc-pwrseq = <&wifi_pwrseq>;
> + vmmc-supply = <&wifi_power>;
> + vqmmc-supply = <&wifi_io>;
> non-removable;
>
> pinctrl-names = "default";
> pinctrl-0 = <&pins_mmc1>;
>
> - brcmf: wifi@1 {
> -/* reg = <4>;*/
> - compatible = "brcm,bcm4330-fmac";
> - vcc-supply = <&wlan0_power>;
> - device-wakeup-gpios = <&gpd 9 GPIO_ACTIVE_HIGH>;
> - shutdown-gpios = <&gpf 7 GPIO_ACTIVE_LOW>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + wifi@1 {
> + compatible = "brcm,bcm4329-fmac";
> + reg = <1>;
> +
> + interrupt-parent = <&gpd>;
> + interrupts = <9 IRQ_TYPE_EDGE_FALLING>;
> + interrupt-names = "host-wake";
> };
> };
>
> @@ -205,11 +253,20 @@ &uart2 {
>
> bluetooth {
> compatible = "brcm,bcm4330-bt";
> - reset-gpios = <&gpf 8 GPIO_ACTIVE_HIGH>;
> - vcc-supply = <&wlan0_power>;
> +
> + vbat-supply = <&bt_power>;
> + vddio-supply = <&wifi_io>;
> +
> + interrupt-parent = <&gpf>;
> + interrupts = <6 IRQ_TYPE_EDGE_RISING>;
> + interrupt-names = "host-wakeup";
> +
> + clocks = <&rtc_dev>;
> + clock-names = "lpo";
> +
> + reset-gpios = <&gpf 8 GPIO_ACTIVE_LOW>;
> device-wakeup-gpios = <&gpf 5 GPIO_ACTIVE_HIGH>;
> - host-wakeup-gpios = <&gpf 6 GPIO_ACTIVE_HIGH>;
> - shutdown-gpios = <&gpf 4 GPIO_ACTIVE_LOW>;
> + shutdown-gpios = <&gpf 4 GPIO_ACTIVE_HIGH>;
> };
> };
>
> @@ -270,8 +327,9 @@ vcc_25: LDO5 {
> regulator-always-on;
> };
> wifi_io: LDO6 {
> - regulator-min-microvolt = <2500000>;
> - regulator-max-microvolt = <2500000>;
> + regulator-min-microvolt = <1800000>;
> + regulator-max-microvolt = <1800000>;
> + regulator-settling-time-us = <150000>;
> inl-supply = <&vcc_33v>;
> };
> cim_io_28: LDO7 {
> --
> 2.39.2
>


2023-06-15 07:32:15

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Paul,
I was in holidays and could not review this series earlier.


> Am 04.06.2023 um 16:56 schrieb Paul Cercueil <[email protected]>:
>
> Hi,
>
> Here's a set of patches to add support for the WiFi / Bluetooth chip on
> the CI20.
>
> WiFi works pretty well, provided it is used with the latest firmware
> provided by linux-firmware. Bluetooth does not work very well here, as
> I cannot get my wireless keyboard to pair; but it does detect it, and it
> does see they key presses when I type the pairing code.
>
> I only tested with a somewhat recent (~2022) Buildroot-based userspace.
> I enabled WEXT compatibility because the CI20 is typically used with a
> very old userspace, but I did not try to use it with old tools like
> ifconfig/iwconfig.

^^^ great since not everyone is using memory hungry latest user-space and
ifconfig/iwconfig is also available on some other OS so users like me
can share scripts.


But I had quite some issues with this series.

1. I could not boot my CI20 V2a board after applying the full series to v6.4-rc6
2. bisecting failed because vcc_33v is used in a patch preceding its definition
leading to DTC compile abort
3. after fixing I could bisect that "MIPS: DTS: CI20: Fix ACT8600 regulator node names"
is the first bad commit - although I don't see immediately why

So this series seems to be severely broken and I could not even come to
a test of WiFi and/or Bluetooth which the series claims to support.

Comments to some individual patches follow.

Best regards and looking forward to a v2 for testing,
Nikolaus


>
> Cheers,
> -Paul
>
> Paul Cercueil (9):
> MIPS: DTS: CI20: Fix regulators
> MIPS: DTS: CI20: Fix ACT8600 regulator node names
> MIPS: DTS: CI20: Add parent supplies to ACT8600 regulators

^^^ should IMHO be a separate series since it is not directly related to WiFi / Bluetooth

> MIPS: DTS: CI20: Do not force-enable CIM and WiFi regulators
> MIPS: DTS: CI20: Misc. cleanups

^^^ these two do not compile
The Misc. cleanups do not belong to this topic.

> MIPS: DTS: CI20: Parent MSCMUX clock to MPLL

^^^ this is only loosely related to Wifi / Bluetooth

> MIPS: DTS: CI20: Enable support for WiFi / Bluetooth
> MIPS: configs: CI20: Regenerate defconfig
> MIPS: configs: CI20: Enable WiFi / Bluetooth
>
> arch/mips/boot/dts/ingenic/ci20.dts | 148 +++++++++++++++++++---------
> arch/mips/configs/ci20_defconfig | 47 ++++++---
> 2 files changed, 133 insertions(+), 62 deletions(-)
>
> --
> 2.39.2
>


2023-06-15 07:55:00

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 5/9] MIPS: DTS: CI20: Misc. cleanups

Please find a more useful subject.

> Am 04.06.2023 um 16:56 schrieb Paul Cercueil <[email protected]>:
>
> - Use the standard "ecc-engine" property instead of the custom
> "ingenic,bch-controller" to get a handle to the BCH controller.
>
> - Respect cell sizes in the Ethernet controller node.
>
> - Use proper macro for interrupt type instead of hardcoding magic
> values.
>
> Signed-off-by: Paul Cercueil <[email protected]>
> ---
> arch/mips/boot/dts/ingenic/ci20.dts | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
> index 7f6e7a4e3915..b7dbafa1f85d 100644
> --- a/arch/mips/boot/dts/ingenic/ci20.dts
> +++ b/arch/mips/boot/dts/ingenic/ci20.dts
> @@ -356,7 +356,7 @@ nandc: nand-controller@1 {
> #address-cells = <1>;
> #size-cells = <0>;
>
> - ingenic,bch-controller = <&bch>;
> + ecc-engine = <&bch>;
>
> ingenic,nemc-tAS = <10>;
> ingenic,nemc-tAH = <5>;
> @@ -422,8 +422,8 @@ dm9000@6 {
> pinctrl-names = "default";
> pinctrl-0 = <&pins_nemc_cs6>;
>
> - reg = <6 0 1 /* addr */
> - 6 2 1>; /* data */
> + reg = <6 0 1>, /* addr */
> + <6 2 1>; /* data */
>
> ingenic,nemc-tAS = <15>;
> ingenic,nemc-tAH = <10>;
> @@ -435,7 +435,7 @@ dm9000@6 {
> vcc-supply = <&eth0_power>;
>
> interrupt-parent = <&gpe>;
> - interrupts = <19 4>;
> + interrupts = <19 IRQ_TYPE_EDGE_RISING>;
>
> nvmem-cells = <&eth0_addr>;
> nvmem-cell-names = "mac-address";


For better bisecting it would be helpful to split this into 3 patches.

And they are not really related to WiFi/Bluetooth.


2023-06-15 07:56:53

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Thomas,

> Am 09.06.2023 um 10:23 schrieb Thomas Bogendoerfer <[email protected]>:
>
> On Sun, Jun 04, 2023 at 04:56:33PM +0200, Paul Cercueil wrote:
>> Hi,
>>
>> Here's a set of patches to add support for the WiFi / Bluetooth chip on
>> the CI20.
>>
>> WiFi works pretty well, provided it is used with the latest firmware
>> provided by linux-firmware. Bluetooth does not work very well here, as
>> I cannot get my wireless keyboard to pair; but it does detect it, and it
>> does see they key presses when I type the pairing code.
>>
>> I only tested with a somewhat recent (~2022) Buildroot-based userspace.
>> I enabled WEXT compatibility because the CI20 is typically used with a
>> very old userspace, but I did not try to use it with old tools like
>> ifconfig/iwconfig.
>>
>> Cheers,
>> -Paul
>>
>> Paul Cercueil (9):
>> MIPS: DTS: CI20: Fix regulators
>> MIPS: DTS: CI20: Fix ACT8600 regulator node names
>> MIPS: DTS: CI20: Add parent supplies to ACT8600 regulators
>> MIPS: DTS: CI20: Do not force-enable CIM and WiFi regulators
>> MIPS: DTS: CI20: Misc. cleanups
>> MIPS: DTS: CI20: Parent MSCMUX clock to MPLL
>> MIPS: DTS: CI20: Enable support for WiFi / Bluetooth
>> MIPS: configs: CI20: Regenerate defconfig
>> MIPS: configs: CI20: Enable WiFi / Bluetooth
>>
>> arch/mips/boot/dts/ingenic/ci20.dts | 148 +++++++++++++++++++---------
>> arch/mips/configs/ci20_defconfig | 47 ++++++---
>> 2 files changed, 133 insertions(+), 62 deletions(-)
>>
>> --
>> 2.39.2
>
> series applied to mips-next.

I think this was a little too early. Please see my review.

Best regards,
Nikolaus

>
> Thomas.
>
> --
> Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
> good idea. [ RFC1925, 2.3 ]


2023-06-15 09:19:34

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Pual,


> Am 15.06.2023 um 10:45 schrieb H. Nikolaus Schaller <[email protected]>:
>
> Hi Paul,
>
>> Am 15.06.2023 um 10:39 schrieb Paul Cercueil <[email protected]>:
>>
>> Hi Nikolaus,
>>
>> Le 15 juin 2023 09:00, "H. Nikolaus Schaller" <[email protected]> a écrit :
>>>
>>> Hi Paul,
>>> I was in holidays and could not review this series earlier.
>>>
>>>
>>>> Am 04.06.2023 um 16:56 schrieb Paul Cercueil <[email protected]>:
>>>>
>>>> Hi,
>>>>
>>>> Here's a set of patches to add support for the WiFi / Bluetooth chip on
>>>> the CI20.
>>>>
>>>> WiFi works pretty well, provided it is used with the latest firmware
>>>> provided by linux-firmware. Bluetooth does not work very well here, as
>>>> I cannot get my wireless keyboard to pair; but it does detect it, and it
>>>> does see they key presses when I type the pairing code.
>>>>
>>>> I only tested with a somewhat recent (~2022) Buildroot-based userspace.
>>>> I enabled WEXT compatibility because the CI20 is typically used with a
>>>> very old userspace, but I did not try to use it with old tools like
>>>> ifconfig/iwconfig.
>>>
>>> ^^^ great since not everyone is using memory hungry latest user-space and
>>> ifconfig/iwconfig is also available on some other OS so users like me
>>> can share scripts.
>>>
>>>
>>> But I had quite some issues with this series.
>>>
>>> 1. I could not boot my CI20 V2a board after applying the full series to v6.4-rc6
>>> 2. bisecting failed because vcc_33v is used in a patch preceding its definition
>>> leading to DTC compile abort
>>> 3. after fixing I could bisect that "MIPS: DTS: CI20: Fix ACT8600 regulator node names"
>>> is the first bad commit - although I don't see immediately why
>>>
>>> So this series seems to be severely broken and I could not even come to
>>> a test of WiFi and/or Bluetooth which the series claims to support.
>>
>> Well, that's strange. I can assure you it boots and works here.
>>
>> Maybe it is a board difference; I have a non-square green board - so the earlier version.
>
> Ok, my V2a is the bordeaux one. That may indeed make a difference.
>
>>
>> Since this patch will actually make the various ACT8600 regulators work at their specified voltage, maybe the voltage on one of the updated regulators is wrong?
>>
>> Maybe change the regulators one by one back to their old name, until you find the one that is problematic? That may give us more info.
>
> That is what I also have though about but have not yet done.
> Will try as soon as I find a time slot.

I have reverted the whole patch (had only a conflict in wifi_io / LDO6) and now I can boot.

But do not see a WiFi or Bluetooth interface.

So it looks as if the CI20 variants are indeed different. Which would also explain why we
originally came up with two different solutions to add WiFi.

Next I will try to bisect the individual changes...

>
>>
>>> Comments to some individual patches follow.
>>
>> Sorry about the vcc_33v. Honest mistake.
>>
>> Thomas: are you able to drop this series from mips-next, or should I/we send fixup patches instead?
>
> Well, mistakes happen.
>
> Best regards,
> Nikolaus
>
>>
>> Cheers,
>> -Paul
>>
>>> Best regards and looking forward to a v2 for testing,
>>> Nikolaus
>>>
>>>
>>>>
>>>> Cheers,
>>>> -Paul
>>>>
>>>> Paul Cercueil (9):
>>>> MIPS: DTS: CI20: Fix regulators
>>>> MIPS: DTS: CI20: Fix ACT8600 regulator node names
>>>> MIPS: DTS: CI20: Add parent supplies to ACT8600 regulators
>>>
>>> ^^^ should IMHO be a separate series since it is not directly related to WiFi / Bluetooth
>>>
>>>> MIPS: DTS: CI20: Do not force-enable CIM and WiFi regulators
>>>> MIPS: DTS: CI20: Misc. cleanups
>>>
>>> ^^^ these two do not compile
>>> The Misc. cleanups do not belong to this topic.
>>>
>>>> MIPS: DTS: CI20: Parent MSCMUX clock to MPLL
>>>
>>> ^^^ this is only loosely related to Wifi / Bluetooth
>>>
>>>> MIPS: DTS: CI20: Enable support for WiFi / Bluetooth
>>>> MIPS: configs: CI20: Regenerate defconfig
>>>> MIPS: configs: CI20: Enable WiFi / Bluetooth
>>>>
>>>> arch/mips/boot/dts/ingenic/ci20.dts | 148 +++++++++++++++++++---------
>>>> arch/mips/configs/ci20_defconfig | 47 ++++++---
>>>> 2 files changed, 133 insertions(+), 62 deletions(-)
>>>>
>>>> --
>>>> 2.39.2
>>>>
>>>
>


2023-06-15 09:21:08

by Thomas Bogendoerfer

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

On Thu, Jun 15, 2023 at 10:39:53AM +0200, Paul Cercueil wrote:
> Thomas: are you able to drop this series from mips-next, or should I/we send fixup patches instead?

as I'm not rebasing mips-next I need fixup patches. This won't solve
bisectability, but not doing rebases is the what Linus prefers.

Thomas.

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]

2023-06-15 09:21:53

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Paul,

> Am 15.06.2023 um 10:39 schrieb Paul Cercueil <[email protected]>:
>
> Hi Nikolaus,
>
> Le 15 juin 2023 09:00, "H. Nikolaus Schaller" <[email protected]> a écrit :
>>
>> Hi Paul,
>> I was in holidays and could not review this series earlier.
>>
>>
>>> Am 04.06.2023 um 16:56 schrieb Paul Cercueil <[email protected]>:
>>>
>>> Hi,
>>>
>>> Here's a set of patches to add support for the WiFi / Bluetooth chip on
>>> the CI20.
>>>
>>> WiFi works pretty well, provided it is used with the latest firmware
>>> provided by linux-firmware. Bluetooth does not work very well here, as
>>> I cannot get my wireless keyboard to pair; but it does detect it, and it
>>> does see they key presses when I type the pairing code.
>>>
>>> I only tested with a somewhat recent (~2022) Buildroot-based userspace.
>>> I enabled WEXT compatibility because the CI20 is typically used with a
>>> very old userspace, but I did not try to use it with old tools like
>>> ifconfig/iwconfig.
>>
>> ^^^ great since not everyone is using memory hungry latest user-space and
>> ifconfig/iwconfig is also available on some other OS so users like me
>> can share scripts.
>>
>>
>> But I had quite some issues with this series.
>>
>> 1. I could not boot my CI20 V2a board after applying the full series to v6.4-rc6
>> 2. bisecting failed because vcc_33v is used in a patch preceding its definition
>> leading to DTC compile abort
>> 3. after fixing I could bisect that "MIPS: DTS: CI20: Fix ACT8600 regulator node names"
>> is the first bad commit - although I don't see immediately why
>>
>> So this series seems to be severely broken and I could not even come to
>> a test of WiFi and/or Bluetooth which the series claims to support.
>
> Well, that's strange. I can assure you it boots and works here.
>
> Maybe it is a board difference; I have a non-square green board - so the earlier version.

Ok, my V2a is the bordeaux one. That may indeed make a difference.

>
> Since this patch will actually make the various ACT8600 regulators work at their specified voltage, maybe the voltage on one of the updated regulators is wrong?
>
> Maybe change the regulators one by one back to their old name, until you find the one that is problematic? That may give us more info.

That is what I also have though about but have not yet done.
Will try as soon as I find a time slot.

>
>> Comments to some individual patches follow.
>
> Sorry about the vcc_33v. Honest mistake.
>
> Thomas: are you able to drop this series from mips-next, or should I/we send fixup patches instead?

Well, mistakes happen.

Best regards,
Nikolaus

>
> Cheers,
> -Paul
>
>> Best regards and looking forward to a v2 for testing,
>> Nikolaus
>>
>>
>>>
>>> Cheers,
>>> -Paul
>>>
>>> Paul Cercueil (9):
>>> MIPS: DTS: CI20: Fix regulators
>>> MIPS: DTS: CI20: Fix ACT8600 regulator node names
>>> MIPS: DTS: CI20: Add parent supplies to ACT8600 regulators
>>
>> ^^^ should IMHO be a separate series since it is not directly related to WiFi / Bluetooth
>>
>>> MIPS: DTS: CI20: Do not force-enable CIM and WiFi regulators
>>> MIPS: DTS: CI20: Misc. cleanups
>>
>> ^^^ these two do not compile
>> The Misc. cleanups do not belong to this topic.
>>
>>> MIPS: DTS: CI20: Parent MSCMUX clock to MPLL
>>
>> ^^^ this is only loosely related to Wifi / Bluetooth
>>
>>> MIPS: DTS: CI20: Enable support for WiFi / Bluetooth
>>> MIPS: configs: CI20: Regenerate defconfig
>>> MIPS: configs: CI20: Enable WiFi / Bluetooth
>>>
>>> arch/mips/boot/dts/ingenic/ci20.dts | 148 +++++++++++++++++++---------
>>> arch/mips/configs/ci20_defconfig | 47 ++++++---
>>> 2 files changed, 133 insertions(+), 62 deletions(-)
>>>
>>> --
>>> 2.39.2
>>>
>>


2023-06-15 09:51:33

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support



> Am 15.06.2023 um 11:08 schrieb Thomas Bogendoerfer <[email protected]>:
>
> On Thu, Jun 15, 2023 at 10:39:53AM +0200, Paul Cercueil wrote:
>> Thomas: are you able to drop this series from mips-next, or should I/we send fixup patches instead?
>
> as I'm not rebasing mips-next I need fixup patches. This won't solve
> bisectability, but not doing rebases is the what Linus prefers.

Indeed. I have found some very old statements on this topic:
https://yarchive.net/comp/linux/git_rebase.html

> > How do I insert build fixes into existing changesets so that the tree
> > is more bisectable?
>
> Just delay pushing out. There really is _zero_ downside to this. None at
> all. There are only upsides.

...

> Also, I'd *much* rather have a few problems in the tree than have people
> screw up history in order to hide them. Sure, we want to keep things
> bisectable, but quite frankly, if you do a reasonable job and compile the
> kernel before you push out, it will be "mostly bisectable".
>
> And yes, mistakes happen. Mistakes will *always* happen. It's ok. Relax.

...

> So in short:
>
> - clean trees and bisectability are all wonderful things. No doubt about
> that at all.
>
> - but if getting there means that you lose a lot of _other_ wonderful
> things (like being able to trust history, and the people being under
> your watchful eyes having to deal with you re-writing their trees),
> we'd be much better off taking the occasional commit that fixes things
> up _after_ the fact rather than before!
>
> - and you actually can help fix your issues by doing some simple things
> *before* pushing out, rather than push out immediately. IOW, do your
> whitespace sanity fixes, your compile checks etc early, and don't push
> out until after you've done them.

...

> So:
> - making things public is *different* from developing them. Don't push
> out just because you committed something!
>
> - you shouldn't publicize a tree until it's in reasonable shape. EVER.
> Even -mm or -next is *not* better off with a pile of sh*t just because
> you're working in that area.
>
> I cannot stress this enough. I think Andrew has been way too polite to
> some people.
>
> - and once it is, you generally shouldn't mess with old commits even when
> you fix things. Full cleanliness or always being able to bisect
> specific configurations is not an excuse for messing up all the other
> things, and if this problem happens a lot, I would like to point you to
> the two previous points.
>

...

> And btw, a *big* part of the above is also:
>
> - mistakes happen.
>
> There will be bugs. There will be cases where things aren't bisectable
> (although they should generally be bisectable for *your* configuration,
> because if they aren't, that shows that you didn't even compile the
> commits you made).
>
> And there will be kernels that don't boot. Even expecting people to always
> boot-test every single commit would be unrealistic - let's face it, most
> things look really obvious, and the fact that even obvious fixes can have
> bugs doesn't mean that there should be hard rules about "every single
> commit has to be boot-tested on X machines".
>
> So it's an important part of the process to try to do a good job, and not
> publicizing crap - but it's *equally* important to realize that crap
> happens, and that it's easily *more* distracting to try to clean it up
> after-the-fact than it is to just admit that it happened.

Ok, then we have to keep this series as is and fix it on top (just for
my V2a board since it seems to work for Paul for a different version).

So let's focus on the fixes.

Best regards,
Nikolaus


>
> Thomas.
>
> --
> Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
> good idea. [ RFC1925, 2.3 ]


2023-06-15 12:54:33

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Paul,

>>>
>>> Since this patch will actually make the various ACT8600 regulators work at their specified voltage, maybe the voltage on one of the updated regulators is wrong?
>>>
>>> Maybe change the regulators one by one back to their old name, until you find the one that is problematic? That may give us more info.
>>
>> That is what I also have though about but have not yet done.
>> Will try as soon as I find a time slot.
>
> I have reverted the whole patch (had only a conflict in wifi_io / LDO6) and now I can boot.
>
> But do not see a WiFi or Bluetooth interface.
>
> So it looks as if the CI20 variants are indeed different. Which would also explain why we
> originally came up with two different solutions to add WiFi.
>
> Next I will try to bisect the individual changes...

It is this and not the regulator names:

diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
index e2221d44e4269..391be48e6427a 100644
--- a/arch/mips/boot/dts/ingenic/ci20.dts
+++ b/arch/mips/boot/dts/ingenic/ci20.dts
@@ -295,7 +295,6 @@ &i2c0 {
act8600: act8600@5a {
compatible = "active-semi,act8600";
reg = <0x5a>;
- status = "okay";

regulators {
vddcore: SUDCDC1 {


Now I wonder how it works without status = "okay" for you but not for me.

Does your test branch have additional patches which add this back?

Or does your board variant have better or different burnt in defaults than
my act8600 so that it runs without any driver?

The chip reads as:

ACTIVE
8601QJ
MD361

BR,
Nikolaus


2023-06-16 20:35:39

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Paul,

>
>>>> Since this patch will actually make the various ACT8600 regulators work at their specified voltage, maybe the voltage on one of the updated regulators is wrong?
>>>>
>>>> Maybe change the regulators one by one back to their old name, until you find the one that is problematic? That may give us more info.
>>>
>>> That is what I also have thought about but have not yet done.
>>> Will try as soon as I find a time slot.
>>
>> I have reverted the whole patch (had only a conflict in wifi_io / LDO6) and now I can boot.
>>
>> But do not see a WiFi or Bluetooth interface.
>>
>> So it looks as if the CI20 variants are indeed different. Which would also explain why we
>> originally came up with two different solutions to add WiFi.
>>
>> Next I will try to bisect the individual changes...
>
> It is this and not the regulator names:
>
> diff --git a/arch/mips/boot/dts/ingenic/ci20.dts b/arch/mips/boot/dts/ingenic/ci20.dts
> index e2221d44e4269..391be48e6427a 100644
> --- a/arch/mips/boot/dts/ingenic/ci20.dts
> +++ b/arch/mips/boot/dts/ingenic/ci20.dts
> @@ -295,7 +295,6 @@ &i2c0 {
> act8600: act8600@5a {
> compatible = "active-semi,act8600";
> reg = <0x5a>;
> - status = "okay";
>
> regulators {
> vddcore: SUDCDC1 {
>
>
> Now I wonder how it works without status = "okay" for you but not for me.

I have not found a reason for this and it was difficult to repeat. Potentially a bisect
with failed boot and wrong setup of some voltages may have damaged the file system on my
SD card (see below). At least I had to fsck -f after running the bisect, but I did not
do it for every bisect step. Sometimes bisecting is difficult if hardware effects are
involved...

So I started with the series + a revert of the offending patch, added some more logging
to the kernel and printk() in the driver.

Results:

- driver is always loaded, so the status = "okay" was spurious and not the problem.

- Adding/Removing the regulator names also does not make a difference.

- But renaming the DT nodes (e.g. SUDCDC1 -> DCDC1) (with or without regulator_name) makes
boot hang with strange errors which indicate that the processor power supply is not stable.
Once a while it did even automatically reboot. In most cases there are some EXT4 errors
afterwards.

Example:

[ 3.003096] EXT4-fs error (device mmcblk0p1): ext4_mb_generate_buddy:1100: group 81, block bitmap and bg descriptor inconsistent: 30994 vs 31229 free clusters
/sbin/init: error while loading shared libraries: /lib/mipsel-li
[ 3.291901] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[ 3.305122] Rebooting in 10 seconds..

I have not found a reason but it appears that if the DT nodes do match the
struct regulator_desc list, it is different from having them not match.

At least the result of regulator_of_get_init_data() is NULL if there is no
match and then some other code path is followed in regulator_register().

So at the moment I think that matching DT node names with the act8600_regulators[] list
changes something in the chip initialization which has influence depending on hardware
variation. Maybe your board is simply more robust than mine to that.

Deeper analysis will reveal the issue and indicate a solution...

BR,
Nikolaus


2023-06-17 11:12:29

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Paul,

> Am 16.06.2023 um 22:21 schrieb H. Nikolaus Schaller <[email protected]>:

> - But renaming the DT nodes (e.g. SUDCDC1 -> DCDC1) (with or without regulator_name) makes
> boot hang with strange errors which indicate that the processor power supply is not stable.
> Once a while it did even automatically reboot. In most cases there are some EXT4 errors
> afterwards.

I am coming closer, I think. I have now touched only the DCDC1 node name.

a) with "SUDCDC1" -> "DCDC1" (bad bood):

regulator_of_get_init_node() returns the child node

Then:
[ 0.666962] act8865 0-005a: Looking up vp1-supply from device tree
[ 0.673191] DCDC1: supplied by vcc_33v
[ 0.727070] DCDC1: Bringing 1200000uV into 1100000-1100000uV
[ 0.739398] DCDC1: 1100 mV, enabled

b) without patch/series or reverted (good boot):

regulator_of_get_init_node() returns NULL

Then:
[ 1.016487] DCDC1: at 1200 mV, enabled
[ 1.020578] act8865 0-005a: Looking up vp1-supply from device tree
[ 1.026917] DCDC1: supplied by vcc_33v

So at least for my board the patched series seems to reduce DCDC1 voltage
to 1.1V which may trigger the boot and stability problems on my board while
it is fine for yours. This could explain the hardware dependency.

Now I have no data sheets or information which voltages are the right ones
and where the 1200mV come from (most likely some default programmed
into the PMU chip).

And the issue seems to be that without matching the node names the
voltages in the device tree may have been ignored completely all the
time... Now it sets up voltages, which should happen. But different
ones for my board which breaks boot.

Finally I did risk (I have no replacement CI20 board and they are no longer
on sale... RS part# was 125-3305 Mouser 456-VL-62851) to run a test with
rename to "DCDC1" but changing the voltage to 1200mV. And this version boots.

Still without WiFi/Bluetooth but that may be related to missing rename
of the other regulators.

So I tried renaming all regulators as by your [PATCH 2/9], and now I
see something from WiFi (haven't installed firmware yet) and the Bluetooth chip:

[ 1.977876] mmc1: new high speed SDIO card at address 0001

[ 11.341994] Bluetooth: hci0: BCM: chip id 62
[ 11.348811] Bluetooth: hci0: BCM: features 0x0f
[ 11.376698] Bluetooth: hci0: BCM4330B1
[ 11.380662] Bluetooth: hci0: BCM4330B1 (002.001.003) build 0000
[ 11.392053] Bluetooth: hci0: BCM4330B1 'brcm/BCM4330B1.hcd' Patch

[ 12.145330] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac4330-sdio.img,ci20.bin failed with error -2
[ 12.208001] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac4330-sdio.clm_blob failed with error -2

Unfortunatley systemd bailed out starting Bluetooth service but
failed to provide a login:

In summary it looks like a potential fix could be to replace the DCDC1
min/max range by 1.0 - 1.2V instead of 1.1 - 1.1V but we need deeper
understanding first. Usually this has something to do with dynamic voltage
scaling depending on processor clock and lower voltages are only allowed
for lower frequencies but max. clock requires the highest possible voltage.
AFAIK we have no cpufreq integrated and therefore always run at max. speed.

BR,
Nikolaus

PS: here is what I read back from the regulator voltages (for DCDC1 min/max = 1.2V):

root@letux:~# cat /sys/kernel/debug/regulator/regulator_summary
regulator use open bypass opmode voltage current min max
---------------------------------------------------------------------------------------
regulator-dummy 1 0 0 unknown 0mV 0mA 0mV 0mV
eth0_power 1 1 0 unknown 3300mV 0mA 3300mV 3300mV
16000000.dm9000-vcc 1 0mA 0mV 0mV
otg_power 0 0 0 unknown 5000mV 0mA 5000mV 5000mV
vcc_33v 4 9 0 unknown 3300mV 0mA 3300mV 3300mV
13450000.mmc-vqmmc 1 0mA 0mV 0mV
13450000.mmc-vmmc 1 0mA 3300mV 3400mV
DCDC1 1 0 0 standby 1200mV 0mA 1200mV 1200mV
DCDC2 0 0 0 standby 1500mV 0mA 0mV 0mV
DCDC3 0 0 0 unknown 3300mV 0mA 0mV 0mV
LDO5 0 0 0 unknown 2500mV 0mA 0mV 0mV
LDO6 0 0 0 normal 1800mV 0mA 1800mV 1800mV
LDO7 0 0 0 unknown 3300mV 0mA 0mV 0mV
LDO8 0 0 0 unknown 3300mV 0mA 0mV 0mV
SUDCDC_REG4 0 0 0 normal 5000mV 0mA 0mV 0mV
LDO_REG9 1 0 0 unknown 3300mV 0mA 3300mV 3300mV
LDO_REG10 1 0 0 unknown 1200mV 0mA 1200mV 1200mV
bt_power 0 0 0 unknown 3300mV 0mA 3300mV 3300mV
root@letux:~#

This matches device tree except DCDC1, LDO7 and LDO8 (camera).


2023-06-18 12:13:04

by Paul Cercueil

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Nikolaus,

Le samedi 17 juin 2023 à 12:45 +0200, H. Nikolaus Schaller a écrit :
> Hi Paul,
>
> > Am 16.06.2023 um 22:21 schrieb H. Nikolaus Schaller
> > <[email protected]>:
>
> > - But renaming the DT nodes (e.g. SUDCDC1 -> DCDC1) (with or
> > without regulator_name) makes
> > boot hang with strange errors which indicate that the processor
> > power supply is not stable.
> > Once a while it did even automatically reboot. In most cases there
> > are some EXT4 errors
> > afterwards.
>
> I am coming closer, I think. I have now touched only the DCDC1 node
> name.
>
> a) with "SUDCDC1" -> "DCDC1" (bad bood):
>
> regulator_of_get_init_node() returns the child node
>
> Then:
> [    0.666962] act8865 0-005a: Looking up vp1-supply from device tree
> [    0.673191] DCDC1: supplied by vcc_33v
> [    0.727070] DCDC1: Bringing 1200000uV into 1100000-1100000uV
> [    0.739398] DCDC1: 1100 mV, enabled
>
> b) without patch/series or reverted (good boot):
>
> regulator_of_get_init_node() returns NULL
>
> Then:
> [    1.016487] DCDC1: at 1200 mV, enabled
> [    1.020578] act8865 0-005a: Looking up vp1-supply from device tree
> [    1.026917] DCDC1: supplied by vcc_33v
>
> So at least for my board the patched series seems to reduce DCDC1
> voltage
> to 1.1V which may trigger the boot and stability problems on my board
> while
> it is fine for yours. This could explain the hardware dependency.
>
> Now I have no data sheets or information which voltages are the right
> ones
> and where the 1200mV come from (most likely some default programmed
> into the PMU chip).
>
> And the issue seems to be that without matching the node names the
> voltages in the device tree may have been ignored completely all the
> time... Now it sets up voltages, which should happen. But different
> ones for my board which breaks boot.

So the node names fix caused the driver to actually use the info from
DT, which doesn't allow the board to boot. Nice.

> Finally I did risk (I have no replacement CI20 board and they are no
> longer
> on sale... RS part# was 125-3305 Mouser 456-VL-62851) to run a test
> with
> rename to "DCDC1" but changing the voltage to 1200mV. And this
> version boots.

Looking at the JZ4780_DS.PDF file, the SoC actually wants 1.1V so the
DT is not wrong - in theory. But in practice it does not work, as you
experienced yourself. However, if the ACT8600 defaults to 1.2V, or if
the bootloader configures it to 1.2V, I would think that this is
actually a voltage that the SoC can handle - otherwise the SoC would be
overvolted until the kernel starts, and the board design would be
flawed.

I measured that the old 3.x kernel keeps the SoC voltage at 1.2V, so it
sounds like a better default. Therefore the fix here would be to raise
the DCDC1 regulator to 1.2V.

I'll send a patch later today.

Cheers,
-Paul

> Still without WiFi/Bluetooth but that may be related to missing
> rename
> of the other regulators.
>
> So I tried renaming all regulators as by your [PATCH 2/9], and now I
> see something from WiFi (haven't installed firmware yet) and the
> Bluetooth chip:
>
> [    1.977876] mmc1: new high speed SDIO card at address 0001
>
> [   11.341994] Bluetooth: hci0: BCM: chip id 62
> [   11.348811] Bluetooth: hci0: BCM: features 0x0f
> [   11.376698] Bluetooth: hci0: BCM4330B1
> [   11.380662] Bluetooth: hci0: BCM4330B1 (002.001.003) build 0000
> [   11.392053] Bluetooth: hci0: BCM4330B1 'brcm/BCM4330B1.hcd' Patch
>
> [   12.145330] brcmfmac mmc1:0001:1: Direct firmware load for
> brcm/brcmfmac4330-sdio.img,ci20.bin failed with error -2
> [   12.208001] brcmfmac mmc1:0001:1: Direct firmware load for
> brcm/brcmfmac4330-sdio.clm_blob failed with error -2
>
> Unfortunatley systemd bailed out starting Bluetooth service but
> failed to provide a login:
>
> In summary it looks like a potential fix could be to replace the
> DCDC1
> min/max range by 1.0 - 1.2V instead of 1.1 - 1.1V but we need deeper
> understanding first. Usually this has something to do with dynamic
> voltage
> scaling depending on processor clock and lower voltages are only
> allowed
> for lower frequencies but max. clock requires the highest possible
> voltage.
> AFAIK we have no cpufreq integrated and therefore always run at max.
> speed.
>
> BR,
> Nikolaus
>
> PS: here is what I read back from the regulator voltages (for DCDC1 
> min/max = 1.2V):
>
> root@letux:~# cat /sys/kernel/debug/regulator/regulator_summary
>  regulator                      use open bypass  opmode voltage
> current     min     max
> ---------------------------------------------------------------------
> ------------------
>  regulator-dummy                  1    0      0 unknown     0mV    
> 0mA     0mV     0mV
>  eth0_power                       1    1      0 unknown  3300mV    
> 0mA  3300mV  3300mV
>     16000000.dm9000-vcc           1                                
> 0mA     0mV     0mV
>  otg_power                        0    0      0 unknown  5000mV    
> 0mA  5000mV  5000mV
>  vcc_33v                          4    9      0 unknown  3300mV    
> 0mA  3300mV  3300mV
>     13450000.mmc-vqmmc            1                                
> 0mA     0mV     0mV
>     13450000.mmc-vmmc             1                                
> 0mA  3300mV  3400mV
>     DCDC1                         1    0      0 standby  1200mV    
> 0mA  1200mV  1200mV
>     DCDC2                         0    0      0 standby  1500mV    
> 0mA     0mV     0mV
>     DCDC3                         0    0      0 unknown  3300mV    
> 0mA     0mV     0mV
>     LDO5                          0    0      0 unknown  2500mV    
> 0mA     0mV     0mV
>     LDO6                          0    0      0  normal  1800mV    
> 0mA  1800mV  1800mV
>     LDO7                          0    0      0 unknown  3300mV    
> 0mA     0mV     0mV
>     LDO8                          0    0      0 unknown  3300mV    
> 0mA     0mV     0mV
>  SUDCDC_REG4                      0    0      0  normal  5000mV    
> 0mA     0mV     0mV
>  LDO_REG9                         1    0      0 unknown  3300mV    
> 0mA  3300mV  3300mV
>  LDO_REG10                        1    0      0 unknown  1200mV    
> 0mA  1200mV  1200mV
>  bt_power                         0    0      0 unknown  3300mV    
> 0mA  3300mV  3300mV
> root@letux:~#
>
> This matches device tree except DCDC1, LDO7 and LDO8 (camera).
>

2023-06-18 14:14:10

by Paul Cercueil

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi All,

[...]

> Looking at the JZ4780_DS.PDF file, the SoC actually wants 1.1V so the
> DT is not wrong - in theory. But in practice it does not work, as you
> experienced yourself. However, if the ACT8600 defaults to 1.2V, or if
> the bootloader configures it to 1.2V, I would think that this is
> actually a voltage that the SoC can handle - otherwise the SoC would
> be
> overvolted until the kernel starts, and the board design would be
> flawed.
>
> I measured that the old 3.x kernel keeps the SoC voltage at 1.2V, so
> it
> sounds like a better default. Therefore the fix here would be to
> raise
> the DCDC1 regulator to 1.2V.
>
> I'll send a patch later today.

After a talk with Christophe (Cc'd), I changed my mind.

A +100 mV overvolt is a *huge* step up, and although the SoC doesn't
burst into flames, it could very well reduce its life span.

I used to have huge stability issues (kernel not booting to userspace
half the times, or just plain reboots after a few minutes of uptime)
and I now realize it's because I was running the core at 1.1V, because
these issues disappeared the moment I switched to 1.2V.

However, I am now running at 1.125 volts, which is just 25mV above the
nominal voltage - and it's been extremely stable so far.

Nikolaus: could you test at 1.125 volts? If it's stable for you as
well, I'd suggest to use this as the new default.

Paul (Burton): As you wrote most of the drivers (and uboot?) for the
board, do you know why VDDCORE was set to 1.2V?

Cheers,
-Paul

2023-06-19 05:20:13

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Paul,

> Am 18.06.2023 um 15:58 schrieb Paul Cercueil <[email protected]>:
>
> Hi All,
>
> [...]
>
>> Looking at the JZ4780_DS.PDF file, the SoC actually wants 1.1V so the
>> DT is not wrong - in theory. But in practice it does not work, as you
>> experienced yourself. However, if the ACT8600 defaults to 1.2V, or if
>> the bootloader configures it to 1.2V, I would think that this is
>> actually a voltage that the SoC can handle - otherwise the SoC would
>> be
>> overvolted until the kernel starts, and the board design would be
>> flawed.
>>
>> I measured that the old 3.x kernel keeps the SoC voltage at 1.2V, so
>> it
>> sounds like a better default. Therefore the fix here would be to
>> raise
>> the DCDC1 regulator to 1.2V.
>>
>> I'll send a patch later today.
>
> After a talk with Christophe (Cc'd), I changed my mind.
>
> A +100 mV overvolt is a *huge* step up, and although the SoC doesn't
> burst into flames, it could very well reduce its life span.

Well, 1.2V is still within the recommended and absolute limits. See my
previous mail. And it appears that my board simply did run at 1.2V
since I bought it many years ago...

So it should neither burn nor burst into flames since it is no change
at least for my board :)

Anyways running at the lowest possible voltage would be good.
The question is if the driver should enforce this more than e.g. U-Boot.

>
> I used to have huge stability issues (kernel not booting to userspace
> half the times, or just plain reboots after a few minutes of uptime)

That is exactly what I see with the new 1.10V.

> and I now realize it's because I was running the core at 1.1V, because
> these issues disappeared the moment I switched to 1.2V.

For me as well (and I had 1.2V over the past years).

>
> However, I am now running at 1.125 volts, which is just 25mV above the
> nominal voltage - and it's been extremely stable so far.

Well, what also could be is that the transient of changing the voltage
from the default 1.20V (it either gets from U-Boot or a preprogrammed
chip setting) to the new 1.1V voltage gives an undershoot.

I remember that I studied the OMAP OPP and dynamic voltage scaling control
some years ago and there it was very critical that voltages and clock
frequencies are changed in a specific sequence and with some delays.

And for the OMAP5 we did find a band within the permitted range where
everything was fine and spurious kernel issues (sudden illegal instructions
or segfaults) outside. The result was that there was a minimum voltage
for low frequencies higher than the maximum voltage for higher frequencies.
So there was not even a single core voltage that could support all
clock frequencies.

>
> Nikolaus: could you test at 1.125 volts? If it's stable for you as
> well, I'd suggest to use this as the new default.

Yes, this is a good idea!

Especially as there are wires between the regulator output inside
the act chip and the core. There may be a small voltage drop so
that setting 1.10V may be too low and 1.25V may end up in real
1.1V.

>
> Paul (Burton): As you wrote most of the drivers (and uboot?) for the
> board, do you know why VDDCORE was set to 1.2V?
>
> Cheers,
> -Paul

Best regards,
Nikolaus



2023-06-19 05:22:35

by H. Nikolaus Schaller

[permalink] [raw]
Subject: Re: [PATCH 0/9] MIPS: CI20: Add WiFi / Bluetooth support

Hi Paul,

> Am 18.06.2023 um 13:51 schrieb Paul Cercueil <[email protected]>:

>> And the issue seems to be that without matching the node names the
>> voltages in the device tree may have been ignored completely all the
>> time... Now it sets up voltages, which should happen. But different
>> ones for my board which breaks boot.
>
> So the node names fix caused the driver to actually use the info from
> DT, which doesn't allow the board to boot. Nice.

Very good summary :)

As usual the fix is just a one-liner, finding what to do is multi-hours.

>
>> Finally I did risk (I have no replacement CI20 board and they are no
>> longer
>> on sale... RS part# was 125-3305 Mouser 456-VL-62851) to run a test
>> with
>> rename to "DCDC1" but changing the voltage to 1200mV. And this
>> version boots.
>
> Looking at the JZ4780_DS.PDF file, the SoC actually wants 1.1V so the
> DT is not wrong - in theory. But in practice it does not work, as you
> experienced yourself. However, if the ACT8600 defaults to 1.2V, or if
> the bootloader configures it to 1.2V, I would think that this is
> actually a voltage that the SoC can handle - otherwise the SoC would be
> overvolted until the kernel starts, and the board design would be
> flawed.
>
> I measured that the old 3.x kernel keeps the SoC voltage at 1.2V, so it
> sounds like a better default. Therefore the fix here would be to raise
> the DCDC1 regulator to 1.2V.

I finally found my JZ4780_DS.pdf (Release Date: Nov. 20, 2014).

According to Table 3-1 the absolute maximum for VDDcore is 1.21V.
According to Table 3-2 the recommended range is 0.99V to 1.21V. 1.1V is only "typical".
According to 1.3 Characteristic: "the Core should run at 1.1 -0.1/+0.2V"

So 1.1V should be right...

But in practise it may be that the ACT8 seems to come up with 1.2V
as chip-internal default during boot. Or U-Boot is initializing it as well.

Maybe I find some time to measure some test point or capacitor while
breaking into U-Boot.

BR,
Nikolaus