2021-03-01 00:03:55 +00:00
|
|
|
From 22a0f55b0e505fbbbb680e451a62878bc97f7ff1 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Ansuel Smith <ansuelsmth@gmail.com>
|
|
|
|
Date: Sun, 7 Feb 2021 17:23:38 +0100
|
|
|
|
Subject: [PATCH 4/4] ipq806x: gcc: add missing clk and reset for crypto engine
|
|
|
|
|
|
|
|
Add missing clk and reset needed for nss additional core and crypto
|
|
|
|
engine.
|
|
|
|
|
|
|
|
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
|
|
|
|
---
|
|
|
|
drivers/clk/qcom/gcc-ipq806x.c | 250 +++++++++++++++++++
|
|
|
|
include/dt-bindings/clock/qcom,gcc-ipq806x.h | 5 +-
|
|
|
|
include/dt-bindings/reset/qcom,gcc-ipq806x.h | 5 +
|
|
|
|
3 files changed, 259 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
--- a/drivers/clk/qcom/gcc-ipq806x.c
|
|
|
|
+++ b/drivers/clk/qcom/gcc-ipq806x.c
|
|
|
|
@@ -223,7 +223,9 @@ static struct clk_regmap pll14_vote = {
|
|
|
|
|
|
|
|
static struct pll_freq_tbl pll18_freq_tbl[] = {
|
|
|
|
NSS_PLL_RATE(550000000, 44, 0, 1, 0x01495625),
|
|
|
|
+ NSS_PLL_RATE(600000000, 48, 0, 1, 0x01495625),
|
|
|
|
NSS_PLL_RATE(733000000, 58, 16, 25, 0x014b5625),
|
|
|
|
+ NSS_PLL_RATE(800000000, 64, 0, 1, 0x01495625),
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct clk_pll pll18 = {
|
|
|
|
@@ -245,6 +247,22 @@ static struct clk_pll pll18 = {
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
+static struct clk_pll pll11 = {
|
|
|
|
+ .l_reg = 0x3184,
|
|
|
|
+ .m_reg = 0x3188,
|
|
|
|
+ .n_reg = 0x318c,
|
|
|
|
+ .config_reg = 0x3194,
|
|
|
|
+ .mode_reg = 0x3180,
|
|
|
|
+ .status_reg = 0x3198,
|
|
|
|
+ .status_bit = 16,
|
|
|
|
+ .clkr.hw.init = &(struct clk_init_data){
|
|
|
|
+ .name = "pll11",
|
|
|
|
+ .parent_names = (const char *[]){ "pxo" },
|
|
|
|
+ .num_parents = 1,
|
|
|
|
+ .ops = &clk_pll_ops,
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
enum {
|
|
|
|
P_PXO,
|
|
|
|
P_PLL8,
|
|
|
|
@@ -253,6 +271,7 @@ enum {
|
|
|
|
P_CXO,
|
|
|
|
P_PLL14,
|
|
|
|
P_PLL18,
|
|
|
|
+ P_PLL11,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct parent_map gcc_pxo_pll8_map[] = {
|
2021-03-03 22:01:37 +00:00
|
|
|
@@ -320,6 +339,42 @@ static const char * const gcc_pxo_pll8_p
|
2021-03-01 00:03:55 +00:00
|
|
|
"pll18",
|
|
|
|
};
|
|
|
|
|
|
|
|
+static const struct parent_map gcc_pxo_pll8_pll0_pll14_pll18_pll11_map[] = {
|
|
|
|
+ { P_PXO, 0 },
|
|
|
|
+ { P_PLL8, 4 },
|
|
|
|
+ { P_PLL0, 2 },
|
|
|
|
+ { P_PLL14, 5 },
|
|
|
|
+ { P_PLL18, 1 },
|
|
|
|
+ { P_PLL11, 3 },
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static const char *gcc_pxo_pll8_pll0_pll14_pll18_pll11[] = {
|
|
|
|
+ "pxo",
|
|
|
|
+ "pll8_vote",
|
|
|
|
+ "pll0_vote",
|
|
|
|
+ "pll14",
|
|
|
|
+ "pll18",
|
|
|
|
+ "pll11"
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static const struct parent_map gcc_pxo_pll3_pll0_pll14_pll18_pll11_map[] = {
|
|
|
|
+ { P_PXO, 0 },
|
|
|
|
+ { P_PLL3, 6 },
|
|
|
|
+ { P_PLL0, 2 },
|
|
|
|
+ { P_PLL14, 5 },
|
|
|
|
+ { P_PLL18, 1 },
|
|
|
|
+ { P_PLL11, 3 },
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static const char *gcc_pxo_pll3_pll0_pll14_pll18_pll11[] = {
|
|
|
|
+ "pxo",
|
|
|
|
+ "pll3",
|
|
|
|
+ "pll0_vote",
|
|
|
|
+ "pll14",
|
|
|
|
+ "pll18",
|
|
|
|
+ "pll11"
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
static struct freq_tbl clk_tbl_gsbi_uart[] = {
|
|
|
|
{ 1843200, P_PLL8, 2, 6, 625 },
|
|
|
|
{ 3686400, P_PLL8, 2, 12, 625 },
|
2021-03-03 22:01:37 +00:00
|
|
|
@@ -1261,6 +1316,7 @@ static const struct freq_tbl clk_tbl_sdc
|
2021-03-01 00:03:55 +00:00
|
|
|
{ 20210000, P_PLL8, 1, 1, 19 },
|
|
|
|
{ 24000000, P_PLL8, 4, 1, 4 },
|
|
|
|
{ 48000000, P_PLL8, 4, 1, 2 },
|
|
|
|
+ { 52000000, P_PLL8, 1, 2, 15 }, /* 51.2 Mhz */
|
|
|
|
{ 64000000, P_PLL8, 3, 1, 2 },
|
|
|
|
{ 96000000, P_PLL8, 4, 0, 0 },
|
|
|
|
{ 192000000, P_PLL8, 2, 0, 0 },
|
ipq806x: revert SDC clock changes for NBG6817 MMC
Revert the SDC "CLK_SET_RATE_GATE" changes to the SDC clock regulator
structures.
See https://elinux.org/images/b/b8/Elc2013_Clement.pdf
> if ((clk->flags & CLK_SET_RATE_GATE) && clk->prepare_count) {
>
> For this particular clock, setting its rate is possible only if the
> clock is ungated (not yet prepared)
This fixes the MMC failing to initialize on newer ZyXEL NBG6817
hardware revisions with Kingston MMC. Older revisions should
hopefully be unaffected.
Check MMC hardware details with:
cd /sys/block/mmcblk0/device/ && \
tail -v cid date name manfid fwrev hwrev oemid rev
Known problematic MMC names (broken before this commit):
* M62704 (dated 12/2018) via myself
* M62704 (dated 11/2018) via Drake Stefani
Known unaffected MMC names (already working without this commit):
* S10004 (dated 12/2015) via slh
Without enabling dynamic debugging, this error manifests in the kernel
hardware serial console as the following:
[ 2.746605] mmc0: error -110 whilst initialising MMC card
[…trimmed other messages…]
[ 2.877832] Waiting for root device /dev/mmcblk0p5...
Enabling Linux dynamic kernel debugging provides additional messages.
For guidance, see the Linux kernel documentation:
https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html
First, enable dynamic debugging in OpenWRT's configuration:
1. Run "make menuconfig"
2. Select "Global build settings --->"
3. Select "Kernel build options --->"
4. Enable "Compile the kernel with dynamic printk" via spacebar
5. Save and exit (arrow key to "Exit" until prompted to save, save)
Alternatively, set "CONFIG_KERNEL_DYNAMIC_DEBUG=y" in your .config.
Then, turn on dynamic debugging at boot:
Modify bootargs in
target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8065-nbg6817.dts
to add…
bootargs = "[…existing bootargs…] dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
For example:
chosen {
- bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1";
+ bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1 dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
append-rootblock = "root=/dev/mmcblk0p";
Then, compile and flash the resulting build. If you are testing
before this commit on newer MMC hardware, be prepared to recover!
NOTE: If you have hardware serial console access, you don't need to
use TFTP recovery to change the active boot partition.
Reboot to working alternative partition via serial console:
1. Connect to hardware serial console
* See https://openwrt.org/toh/zyxel/nbg6817#serial
2. Interrupt boot at "Hit any key to stop autoboot:"
3. Run "ATSE NBG6817"
4. Copy the result (e.g. "001976FE4B04")
* Changes with **every boot** - can't reuse this
5. On your local system, run
"./zyxel-uboot-password-tool.sh <copied value here>"
* Example: "./zyxel-uboot-password-tool.sh 001976FE4B04"
6. Run the command provided by the password tool
* Example: "ATEN 1,910F129B"
* Changes with **every boot** - can't reuse this
7. Run "ATGU"
* You now have full u-boot shell until next boot - unlocking is
not remembered
8. Run either "run boot_mmc" (for booting partition set "FF") or
"run boot_mmc_1" (for booting partition set "01")
* These commands are not affected by dual-boot partition flags
NOTE: This will NOT set the dual-boot partition flag. You'll need to
fix that manually. The "nbg6817-dualboot" script may help:
https://github.com/pkgadd/nbg6817/blob/master/nbg6817-dualboot
zyxel-uboot-password-tool.sh - sourced from
commit 459c8c9ef816156107e297964d088ddee2b4eef5:
ror32() {
echo $(( ($1 >> $2) | (($1 << (32 - $2) & (2**32-1)) ) ))
}
v="0x$1"
a="0x${v:2:6}"
b=$(( a + 0x10F0A563))
c=$(( 0x${v:12:14} & 7 ))
p=$(( $(ror32 $b $c) ^ a ))
printf "ATEN 1,%X\n" $p
Kernel serial console log BEFORE commit with dynamic debug enabled:
[…trimmed…]
[ 3.171343] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.171397] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.175811] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.181134] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.186788] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.192902] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.215609] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.227532] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.247518] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 3.997725] mmc0: req done (CMD2): -110: 00000000 00000000 00000000 00000000
[ 4.003631] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.003659] mmc0: error -110 whilst initialising MMC card
[ 4.016481] mmc0: clock 0Hz busmode 2 powermode 0 cs 0 Vdd 0 width 1 timing 0
Notice how the initial clock is 52 MHz, which is incorrect - MMC
requires negotiation to enable higher speeds.
Kernel serial console log AFTER commit with dynamic debug enabled:
[…trimmed…]
[ 3.168996] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.169051] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.173492] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.178808] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.184702] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.190573] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.217873] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.229250] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.249111] mmc0: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 4.392652] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.392785] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 1
[ 4.406554] mmc0: starting CMD6 arg 03b70201 flags 0000049d
[…trimmed…]
Now, the MMC properly initializes and later switches to high speed.
Thanks to:
* Ansuel for maintaining/help with the IPQ806x platform, kernel code
* slh for additional debugging and suggestions
* dwfreed for confirming newer MMC details, clock frequency
* robimarko for device driver debug printing help, clock debugging
* Drake for testing and confirmation with their own newer NBG6817
...and anyone else I missed!
Signed-off-by: Shane Synan <digitalcircuit36939@gmail.com>
Tested-by: Shane Synan <digitalcircuit36939@gmail.com>
2021-12-03 20:46:36 +00:00
|
|
|
@@ -2645,7 +2701,9 @@ static const struct freq_tbl clk_tbl_nss
|
2021-03-01 00:03:55 +00:00
|
|
|
{ 110000000, P_PLL18, 1, 1, 5 },
|
|
|
|
{ 275000000, P_PLL18, 2, 0, 0 },
|
|
|
|
{ 550000000, P_PLL18, 1, 0, 0 },
|
|
|
|
+ { 600000000, P_PLL18, 1, 0, 0 },
|
|
|
|
{ 733000000, P_PLL18, 1, 0, 0 },
|
|
|
|
+ { 800000000, P_PLL18, 1, 0, 0 },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
ipq806x: revert SDC clock changes for NBG6817 MMC
Revert the SDC "CLK_SET_RATE_GATE" changes to the SDC clock regulator
structures.
See https://elinux.org/images/b/b8/Elc2013_Clement.pdf
> if ((clk->flags & CLK_SET_RATE_GATE) && clk->prepare_count) {
>
> For this particular clock, setting its rate is possible only if the
> clock is ungated (not yet prepared)
This fixes the MMC failing to initialize on newer ZyXEL NBG6817
hardware revisions with Kingston MMC. Older revisions should
hopefully be unaffected.
Check MMC hardware details with:
cd /sys/block/mmcblk0/device/ && \
tail -v cid date name manfid fwrev hwrev oemid rev
Known problematic MMC names (broken before this commit):
* M62704 (dated 12/2018) via myself
* M62704 (dated 11/2018) via Drake Stefani
Known unaffected MMC names (already working without this commit):
* S10004 (dated 12/2015) via slh
Without enabling dynamic debugging, this error manifests in the kernel
hardware serial console as the following:
[ 2.746605] mmc0: error -110 whilst initialising MMC card
[…trimmed other messages…]
[ 2.877832] Waiting for root device /dev/mmcblk0p5...
Enabling Linux dynamic kernel debugging provides additional messages.
For guidance, see the Linux kernel documentation:
https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html
First, enable dynamic debugging in OpenWRT's configuration:
1. Run "make menuconfig"
2. Select "Global build settings --->"
3. Select "Kernel build options --->"
4. Enable "Compile the kernel with dynamic printk" via spacebar
5. Save and exit (arrow key to "Exit" until prompted to save, save)
Alternatively, set "CONFIG_KERNEL_DYNAMIC_DEBUG=y" in your .config.
Then, turn on dynamic debugging at boot:
Modify bootargs in
target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8065-nbg6817.dts
to add…
bootargs = "[…existing bootargs…] dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
For example:
chosen {
- bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1";
+ bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1 dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
append-rootblock = "root=/dev/mmcblk0p";
Then, compile and flash the resulting build. If you are testing
before this commit on newer MMC hardware, be prepared to recover!
NOTE: If you have hardware serial console access, you don't need to
use TFTP recovery to change the active boot partition.
Reboot to working alternative partition via serial console:
1. Connect to hardware serial console
* See https://openwrt.org/toh/zyxel/nbg6817#serial
2. Interrupt boot at "Hit any key to stop autoboot:"
3. Run "ATSE NBG6817"
4. Copy the result (e.g. "001976FE4B04")
* Changes with **every boot** - can't reuse this
5. On your local system, run
"./zyxel-uboot-password-tool.sh <copied value here>"
* Example: "./zyxel-uboot-password-tool.sh 001976FE4B04"
6. Run the command provided by the password tool
* Example: "ATEN 1,910F129B"
* Changes with **every boot** - can't reuse this
7. Run "ATGU"
* You now have full u-boot shell until next boot - unlocking is
not remembered
8. Run either "run boot_mmc" (for booting partition set "FF") or
"run boot_mmc_1" (for booting partition set "01")
* These commands are not affected by dual-boot partition flags
NOTE: This will NOT set the dual-boot partition flag. You'll need to
fix that manually. The "nbg6817-dualboot" script may help:
https://github.com/pkgadd/nbg6817/blob/master/nbg6817-dualboot
zyxel-uboot-password-tool.sh - sourced from
commit 459c8c9ef816156107e297964d088ddee2b4eef5:
ror32() {
echo $(( ($1 >> $2) | (($1 << (32 - $2) & (2**32-1)) ) ))
}
v="0x$1"
a="0x${v:2:6}"
b=$(( a + 0x10F0A563))
c=$(( 0x${v:12:14} & 7 ))
p=$(( $(ror32 $b $c) ^ a ))
printf "ATEN 1,%X\n" $p
Kernel serial console log BEFORE commit with dynamic debug enabled:
[…trimmed…]
[ 3.171343] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.171397] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.175811] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.181134] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.186788] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.192902] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.215609] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.227532] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.247518] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 3.997725] mmc0: req done (CMD2): -110: 00000000 00000000 00000000 00000000
[ 4.003631] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.003659] mmc0: error -110 whilst initialising MMC card
[ 4.016481] mmc0: clock 0Hz busmode 2 powermode 0 cs 0 Vdd 0 width 1 timing 0
Notice how the initial clock is 52 MHz, which is incorrect - MMC
requires negotiation to enable higher speeds.
Kernel serial console log AFTER commit with dynamic debug enabled:
[…trimmed…]
[ 3.168996] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.169051] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.173492] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.178808] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.184702] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.190573] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.217873] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.229250] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.249111] mmc0: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 4.392652] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.392785] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 1
[ 4.406554] mmc0: starting CMD6 arg 03b70201 flags 0000049d
[…trimmed…]
Now, the MMC properly initializes and later switches to high speed.
Thanks to:
* Ansuel for maintaining/help with the IPQ806x platform, kernel code
* slh for additional debugging and suggestions
* dwfreed for confirming newer MMC details, clock frequency
* robimarko for device driver debug printing help, clock debugging
* Drake for testing and confirmation with their own newer NBG6817
...and anyone else I missed!
Signed-off-by: Shane Synan <digitalcircuit36939@gmail.com>
Tested-by: Shane Synan <digitalcircuit36939@gmail.com>
2021-12-03 20:46:36 +00:00
|
|
|
@@ -2757,6 +2815,186 @@ static struct clk_dyn_rcg ubi32_core2_sr
|
2021-03-01 00:03:55 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
+static const struct freq_tbl clk_tbl_ce5_core[] = {
|
|
|
|
+ { 150000000, P_PLL3, 8, 1, 1 },
|
|
|
|
+ { 213200000, P_PLL11, 5, 1, 1 },
|
|
|
|
+ { }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct clk_dyn_rcg ce5_core_src = {
|
|
|
|
+ .ns_reg[0] = 0x36C4,
|
|
|
|
+ .ns_reg[1] = 0x36C8,
|
|
|
|
+ .bank_reg = 0x36C0,
|
|
|
|
+ .s[0] = {
|
|
|
|
+ .src_sel_shift = 0,
|
|
|
|
+ .parent_map = gcc_pxo_pll3_pll0_pll14_pll18_pll11_map,
|
|
|
|
+ },
|
|
|
|
+ .s[1] = {
|
|
|
|
+ .src_sel_shift = 0,
|
|
|
|
+ .parent_map = gcc_pxo_pll3_pll0_pll14_pll18_pll11_map,
|
|
|
|
+ },
|
|
|
|
+ .p[0] = {
|
|
|
|
+ .pre_div_shift = 3,
|
|
|
|
+ .pre_div_width = 4,
|
|
|
|
+ },
|
|
|
|
+ .p[1] = {
|
|
|
|
+ .pre_div_shift = 3,
|
|
|
|
+ .pre_div_width = 4,
|
|
|
|
+ },
|
|
|
|
+ .mux_sel_bit = 0,
|
|
|
|
+ .freq_tbl = clk_tbl_ce5_core,
|
|
|
|
+ .clkr = {
|
|
|
|
+ .enable_reg = 0x36C0,
|
|
|
|
+ .enable_mask = BIT(1),
|
|
|
|
+ .hw.init = &(struct clk_init_data){
|
|
|
|
+ .name = "ce5_core_src",
|
|
|
|
+ .parent_names = gcc_pxo_pll3_pll0_pll14_pll18_pll11,
|
|
|
|
+ .num_parents = 6,
|
|
|
|
+ .ops = &clk_dyn_rcg_ops,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct clk_branch ce5_core_clk = {
|
|
|
|
+ .halt_reg = 0x2FDC,
|
|
|
|
+ .halt_bit = 5,
|
|
|
|
+ .hwcg_reg = 0x36CC,
|
|
|
|
+ .hwcg_bit = 6,
|
|
|
|
+ .clkr = {
|
|
|
|
+ .enable_reg = 0x36CC,
|
|
|
|
+ .enable_mask = BIT(4),
|
|
|
|
+ .hw.init = &(struct clk_init_data){
|
|
|
|
+ .name = "ce5_core_clk",
|
|
|
|
+ .parent_names = (const char *[]){
|
|
|
|
+ "ce5_core_src",
|
|
|
|
+ },
|
|
|
|
+ .num_parents = 1,
|
|
|
|
+ .ops = &clk_branch_ops,
|
|
|
|
+ .flags = CLK_SET_RATE_PARENT,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static const struct freq_tbl clk_tbl_ce5_a_clk[] = {
|
|
|
|
+ { 160000000, P_PLL0, 5, 1, 1 },
|
|
|
|
+ { 213200000, P_PLL11, 5, 1, 1 },
|
|
|
|
+ { }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct clk_dyn_rcg ce5_a_clk_src = {
|
|
|
|
+ .ns_reg[0] = 0x3d84,
|
|
|
|
+ .ns_reg[1] = 0x3d88,
|
|
|
|
+ .bank_reg = 0x3d80,
|
|
|
|
+ .s[0] = {
|
|
|
|
+ .src_sel_shift = 0,
|
|
|
|
+ .parent_map = gcc_pxo_pll8_pll0_pll14_pll18_pll11_map,
|
|
|
|
+ },
|
|
|
|
+ .s[1] = {
|
|
|
|
+ .src_sel_shift = 0,
|
|
|
|
+ .parent_map = gcc_pxo_pll8_pll0_pll14_pll18_pll11_map,
|
|
|
|
+ },
|
|
|
|
+ .p[0] = {
|
|
|
|
+ .pre_div_shift = 3,
|
|
|
|
+ .pre_div_width = 4,
|
|
|
|
+ },
|
|
|
|
+ .p[1] = {
|
|
|
|
+ .pre_div_shift = 3,
|
|
|
|
+ .pre_div_width = 4,
|
|
|
|
+ },
|
|
|
|
+ .mux_sel_bit = 0,
|
|
|
|
+ .freq_tbl = clk_tbl_ce5_a_clk,
|
|
|
|
+ .clkr = {
|
|
|
|
+ .enable_reg = 0x3d80,
|
|
|
|
+ .enable_mask = BIT(1),
|
|
|
|
+ .hw.init = &(struct clk_init_data){
|
|
|
|
+ .name = "ce5_a_clk_src",
|
|
|
|
+ .parent_names = gcc_pxo_pll8_pll0_pll14_pll18_pll11,
|
|
|
|
+ .num_parents = 6,
|
|
|
|
+ .ops = &clk_dyn_rcg_ops,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct clk_branch ce5_a_clk = {
|
|
|
|
+ .halt_reg = 0x3c20,
|
|
|
|
+ .halt_bit = 12,
|
|
|
|
+ .hwcg_reg = 0x3d8c,
|
|
|
|
+ .hwcg_bit = 6,
|
|
|
|
+ .clkr = {
|
|
|
|
+ .enable_reg = 0x3d8c,
|
|
|
|
+ .enable_mask = BIT(4),
|
|
|
|
+ .hw.init = &(struct clk_init_data){
|
|
|
|
+ .name = "ce5_a_clk",
|
|
|
|
+ .parent_names = (const char *[]){
|
|
|
|
+ "ce5_a_clk_src",
|
|
|
|
+ },
|
|
|
|
+ .num_parents = 1,
|
|
|
|
+ .ops = &clk_branch_ops,
|
|
|
|
+ .flags = CLK_SET_RATE_PARENT,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static const struct freq_tbl clk_tbl_ce5_h_clk[] = {
|
|
|
|
+ { 160000000, P_PLL0, 5, 1, 1 },
|
|
|
|
+ { 213200000, P_PLL11, 5, 1, 1 },
|
|
|
|
+ { }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct clk_dyn_rcg ce5_h_clk_src = {
|
|
|
|
+ .ns_reg[0] = 0x3c64,
|
|
|
|
+ .ns_reg[1] = 0x3c68,
|
|
|
|
+ .bank_reg = 0x3c60,
|
|
|
|
+ .s[0] = {
|
|
|
|
+ .src_sel_shift = 0,
|
|
|
|
+ .parent_map = gcc_pxo_pll8_pll0_pll14_pll18_pll11_map,
|
|
|
|
+ },
|
|
|
|
+ .s[1] = {
|
|
|
|
+ .src_sel_shift = 0,
|
|
|
|
+ .parent_map = gcc_pxo_pll8_pll0_pll14_pll18_pll11_map,
|
|
|
|
+ },
|
|
|
|
+ .p[0] = {
|
|
|
|
+ .pre_div_shift = 3,
|
|
|
|
+ .pre_div_width = 4,
|
|
|
|
+ },
|
|
|
|
+ .p[1] = {
|
|
|
|
+ .pre_div_shift = 3,
|
|
|
|
+ .pre_div_width = 4,
|
|
|
|
+ },
|
|
|
|
+ .mux_sel_bit = 0,
|
|
|
|
+ .freq_tbl = clk_tbl_ce5_h_clk,
|
|
|
|
+ .clkr = {
|
|
|
|
+ .enable_reg = 0x3c60,
|
|
|
|
+ .enable_mask = BIT(1),
|
|
|
|
+ .hw.init = &(struct clk_init_data){
|
|
|
|
+ .name = "ce5_h_clk_src",
|
|
|
|
+ .parent_names = gcc_pxo_pll8_pll0_pll14_pll18_pll11,
|
|
|
|
+ .num_parents = 6,
|
|
|
|
+ .ops = &clk_dyn_rcg_ops,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct clk_branch ce5_h_clk = {
|
|
|
|
+ .halt_reg = 0x3c20,
|
|
|
|
+ .halt_bit = 11,
|
|
|
|
+ .hwcg_reg = 0x3c6c,
|
|
|
|
+ .hwcg_bit = 6,
|
|
|
|
+ .clkr = {
|
|
|
|
+ .enable_reg = 0x3c6c,
|
|
|
|
+ .enable_mask = BIT(4),
|
|
|
|
+ .hw.init = &(struct clk_init_data){
|
|
|
|
+ .name = "ce5_h_clk",
|
|
|
|
+ .parent_names = (const char *[]){
|
|
|
|
+ "ce5_h_clk_src",
|
|
|
|
+ },
|
|
|
|
+ .num_parents = 1,
|
|
|
|
+ .ops = &clk_branch_ops,
|
|
|
|
+ .flags = CLK_SET_RATE_PARENT,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
static struct clk_regmap *gcc_ipq806x_clks[] = {
|
|
|
|
[PLL0] = &pll0.clkr,
|
|
|
|
[PLL0_VOTE] = &pll0_vote,
|
ipq806x: revert SDC clock changes for NBG6817 MMC
Revert the SDC "CLK_SET_RATE_GATE" changes to the SDC clock regulator
structures.
See https://elinux.org/images/b/b8/Elc2013_Clement.pdf
> if ((clk->flags & CLK_SET_RATE_GATE) && clk->prepare_count) {
>
> For this particular clock, setting its rate is possible only if the
> clock is ungated (not yet prepared)
This fixes the MMC failing to initialize on newer ZyXEL NBG6817
hardware revisions with Kingston MMC. Older revisions should
hopefully be unaffected.
Check MMC hardware details with:
cd /sys/block/mmcblk0/device/ && \
tail -v cid date name manfid fwrev hwrev oemid rev
Known problematic MMC names (broken before this commit):
* M62704 (dated 12/2018) via myself
* M62704 (dated 11/2018) via Drake Stefani
Known unaffected MMC names (already working without this commit):
* S10004 (dated 12/2015) via slh
Without enabling dynamic debugging, this error manifests in the kernel
hardware serial console as the following:
[ 2.746605] mmc0: error -110 whilst initialising MMC card
[…trimmed other messages…]
[ 2.877832] Waiting for root device /dev/mmcblk0p5...
Enabling Linux dynamic kernel debugging provides additional messages.
For guidance, see the Linux kernel documentation:
https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html
First, enable dynamic debugging in OpenWRT's configuration:
1. Run "make menuconfig"
2. Select "Global build settings --->"
3. Select "Kernel build options --->"
4. Enable "Compile the kernel with dynamic printk" via spacebar
5. Save and exit (arrow key to "Exit" until prompted to save, save)
Alternatively, set "CONFIG_KERNEL_DYNAMIC_DEBUG=y" in your .config.
Then, turn on dynamic debugging at boot:
Modify bootargs in
target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8065-nbg6817.dts
to add…
bootargs = "[…existing bootargs…] dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
For example:
chosen {
- bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1";
+ bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1 dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
append-rootblock = "root=/dev/mmcblk0p";
Then, compile and flash the resulting build. If you are testing
before this commit on newer MMC hardware, be prepared to recover!
NOTE: If you have hardware serial console access, you don't need to
use TFTP recovery to change the active boot partition.
Reboot to working alternative partition via serial console:
1. Connect to hardware serial console
* See https://openwrt.org/toh/zyxel/nbg6817#serial
2. Interrupt boot at "Hit any key to stop autoboot:"
3. Run "ATSE NBG6817"
4. Copy the result (e.g. "001976FE4B04")
* Changes with **every boot** - can't reuse this
5. On your local system, run
"./zyxel-uboot-password-tool.sh <copied value here>"
* Example: "./zyxel-uboot-password-tool.sh 001976FE4B04"
6. Run the command provided by the password tool
* Example: "ATEN 1,910F129B"
* Changes with **every boot** - can't reuse this
7. Run "ATGU"
* You now have full u-boot shell until next boot - unlocking is
not remembered
8. Run either "run boot_mmc" (for booting partition set "FF") or
"run boot_mmc_1" (for booting partition set "01")
* These commands are not affected by dual-boot partition flags
NOTE: This will NOT set the dual-boot partition flag. You'll need to
fix that manually. The "nbg6817-dualboot" script may help:
https://github.com/pkgadd/nbg6817/blob/master/nbg6817-dualboot
zyxel-uboot-password-tool.sh - sourced from
commit 459c8c9ef816156107e297964d088ddee2b4eef5:
ror32() {
echo $(( ($1 >> $2) | (($1 << (32 - $2) & (2**32-1)) ) ))
}
v="0x$1"
a="0x${v:2:6}"
b=$(( a + 0x10F0A563))
c=$(( 0x${v:12:14} & 7 ))
p=$(( $(ror32 $b $c) ^ a ))
printf "ATEN 1,%X\n" $p
Kernel serial console log BEFORE commit with dynamic debug enabled:
[…trimmed…]
[ 3.171343] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.171397] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.175811] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.181134] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.186788] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.192902] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.215609] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.227532] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.247518] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 3.997725] mmc0: req done (CMD2): -110: 00000000 00000000 00000000 00000000
[ 4.003631] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.003659] mmc0: error -110 whilst initialising MMC card
[ 4.016481] mmc0: clock 0Hz busmode 2 powermode 0 cs 0 Vdd 0 width 1 timing 0
Notice how the initial clock is 52 MHz, which is incorrect - MMC
requires negotiation to enable higher speeds.
Kernel serial console log AFTER commit with dynamic debug enabled:
[…trimmed…]
[ 3.168996] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.169051] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.173492] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.178808] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.184702] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.190573] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.217873] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.229250] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.249111] mmc0: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 4.392652] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.392785] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 1
[ 4.406554] mmc0: starting CMD6 arg 03b70201 flags 0000049d
[…trimmed…]
Now, the MMC properly initializes and later switches to high speed.
Thanks to:
* Ansuel for maintaining/help with the IPQ806x platform, kernel code
* slh for additional debugging and suggestions
* dwfreed for confirming newer MMC details, clock frequency
* robimarko for device driver debug printing help, clock debugging
* Drake for testing and confirmation with their own newer NBG6817
...and anyone else I missed!
Signed-off-by: Shane Synan <digitalcircuit36939@gmail.com>
Tested-by: Shane Synan <digitalcircuit36939@gmail.com>
2021-12-03 20:46:36 +00:00
|
|
|
@@ -2764,6 +3002,7 @@ static struct clk_regmap *gcc_ipq806x_cl
|
2021-03-01 00:03:55 +00:00
|
|
|
[PLL4_VOTE] = &pll4_vote,
|
|
|
|
[PLL8] = &pll8.clkr,
|
|
|
|
[PLL8_VOTE] = &pll8_vote,
|
|
|
|
+ [PLL11] = &pll11.clkr,
|
|
|
|
[PLL14] = &pll14.clkr,
|
|
|
|
[PLL14_VOTE] = &pll14_vote,
|
|
|
|
[PLL18] = &pll18.clkr,
|
ipq806x: revert SDC clock changes for NBG6817 MMC
Revert the SDC "CLK_SET_RATE_GATE" changes to the SDC clock regulator
structures.
See https://elinux.org/images/b/b8/Elc2013_Clement.pdf
> if ((clk->flags & CLK_SET_RATE_GATE) && clk->prepare_count) {
>
> For this particular clock, setting its rate is possible only if the
> clock is ungated (not yet prepared)
This fixes the MMC failing to initialize on newer ZyXEL NBG6817
hardware revisions with Kingston MMC. Older revisions should
hopefully be unaffected.
Check MMC hardware details with:
cd /sys/block/mmcblk0/device/ && \
tail -v cid date name manfid fwrev hwrev oemid rev
Known problematic MMC names (broken before this commit):
* M62704 (dated 12/2018) via myself
* M62704 (dated 11/2018) via Drake Stefani
Known unaffected MMC names (already working without this commit):
* S10004 (dated 12/2015) via slh
Without enabling dynamic debugging, this error manifests in the kernel
hardware serial console as the following:
[ 2.746605] mmc0: error -110 whilst initialising MMC card
[…trimmed other messages…]
[ 2.877832] Waiting for root device /dev/mmcblk0p5...
Enabling Linux dynamic kernel debugging provides additional messages.
For guidance, see the Linux kernel documentation:
https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html
First, enable dynamic debugging in OpenWRT's configuration:
1. Run "make menuconfig"
2. Select "Global build settings --->"
3. Select "Kernel build options --->"
4. Enable "Compile the kernel with dynamic printk" via spacebar
5. Save and exit (arrow key to "Exit" until prompted to save, save)
Alternatively, set "CONFIG_KERNEL_DYNAMIC_DEBUG=y" in your .config.
Then, turn on dynamic debugging at boot:
Modify bootargs in
target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8065-nbg6817.dts
to add…
bootargs = "[…existing bootargs…] dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
For example:
chosen {
- bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1";
+ bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1 dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
append-rootblock = "root=/dev/mmcblk0p";
Then, compile and flash the resulting build. If you are testing
before this commit on newer MMC hardware, be prepared to recover!
NOTE: If you have hardware serial console access, you don't need to
use TFTP recovery to change the active boot partition.
Reboot to working alternative partition via serial console:
1. Connect to hardware serial console
* See https://openwrt.org/toh/zyxel/nbg6817#serial
2. Interrupt boot at "Hit any key to stop autoboot:"
3. Run "ATSE NBG6817"
4. Copy the result (e.g. "001976FE4B04")
* Changes with **every boot** - can't reuse this
5. On your local system, run
"./zyxel-uboot-password-tool.sh <copied value here>"
* Example: "./zyxel-uboot-password-tool.sh 001976FE4B04"
6. Run the command provided by the password tool
* Example: "ATEN 1,910F129B"
* Changes with **every boot** - can't reuse this
7. Run "ATGU"
* You now have full u-boot shell until next boot - unlocking is
not remembered
8. Run either "run boot_mmc" (for booting partition set "FF") or
"run boot_mmc_1" (for booting partition set "01")
* These commands are not affected by dual-boot partition flags
NOTE: This will NOT set the dual-boot partition flag. You'll need to
fix that manually. The "nbg6817-dualboot" script may help:
https://github.com/pkgadd/nbg6817/blob/master/nbg6817-dualboot
zyxel-uboot-password-tool.sh - sourced from
commit 459c8c9ef816156107e297964d088ddee2b4eef5:
ror32() {
echo $(( ($1 >> $2) | (($1 << (32 - $2) & (2**32-1)) ) ))
}
v="0x$1"
a="0x${v:2:6}"
b=$(( a + 0x10F0A563))
c=$(( 0x${v:12:14} & 7 ))
p=$(( $(ror32 $b $c) ^ a ))
printf "ATEN 1,%X\n" $p
Kernel serial console log BEFORE commit with dynamic debug enabled:
[…trimmed…]
[ 3.171343] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.171397] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.175811] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.181134] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.186788] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.192902] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.215609] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.227532] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.247518] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 3.997725] mmc0: req done (CMD2): -110: 00000000 00000000 00000000 00000000
[ 4.003631] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.003659] mmc0: error -110 whilst initialising MMC card
[ 4.016481] mmc0: clock 0Hz busmode 2 powermode 0 cs 0 Vdd 0 width 1 timing 0
Notice how the initial clock is 52 MHz, which is incorrect - MMC
requires negotiation to enable higher speeds.
Kernel serial console log AFTER commit with dynamic debug enabled:
[…trimmed…]
[ 3.168996] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.169051] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.173492] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.178808] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.184702] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.190573] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.217873] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.229250] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.249111] mmc0: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 4.392652] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.392785] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 1
[ 4.406554] mmc0: starting CMD6 arg 03b70201 flags 0000049d
[…trimmed…]
Now, the MMC properly initializes and later switches to high speed.
Thanks to:
* Ansuel for maintaining/help with the IPQ806x platform, kernel code
* slh for additional debugging and suggestions
* dwfreed for confirming newer MMC details, clock frequency
* robimarko for device driver debug printing help, clock debugging
* Drake for testing and confirmation with their own newer NBG6817
...and anyone else I missed!
Signed-off-by: Shane Synan <digitalcircuit36939@gmail.com>
Tested-by: Shane Synan <digitalcircuit36939@gmail.com>
2021-12-03 20:46:36 +00:00
|
|
|
@@ -2878,6 +3117,12 @@ static struct clk_regmap *gcc_ipq806x_cl
|
2021-03-01 00:03:55 +00:00
|
|
|
[PLL9] = &hfpll0.clkr,
|
|
|
|
[PLL10] = &hfpll1.clkr,
|
|
|
|
[PLL12] = &hfpll_l2.clkr,
|
|
|
|
+ [CE5_A_CLK_SRC] = &ce5_a_clk_src.clkr,
|
|
|
|
+ [CE5_A_CLK] = &ce5_a_clk.clkr,
|
|
|
|
+ [CE5_H_CLK_SRC] = &ce5_h_clk_src.clkr,
|
|
|
|
+ [CE5_H_CLK] = &ce5_h_clk.clkr,
|
|
|
|
+ [CE5_CORE_CLK_SRC] = &ce5_core_src.clkr,
|
|
|
|
+ [CE5_CORE_CLK] = &ce5_core_clk.clkr,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct qcom_reset_map gcc_ipq806x_resets[] = {
|
ipq806x: revert SDC clock changes for NBG6817 MMC
Revert the SDC "CLK_SET_RATE_GATE" changes to the SDC clock regulator
structures.
See https://elinux.org/images/b/b8/Elc2013_Clement.pdf
> if ((clk->flags & CLK_SET_RATE_GATE) && clk->prepare_count) {
>
> For this particular clock, setting its rate is possible only if the
> clock is ungated (not yet prepared)
This fixes the MMC failing to initialize on newer ZyXEL NBG6817
hardware revisions with Kingston MMC. Older revisions should
hopefully be unaffected.
Check MMC hardware details with:
cd /sys/block/mmcblk0/device/ && \
tail -v cid date name manfid fwrev hwrev oemid rev
Known problematic MMC names (broken before this commit):
* M62704 (dated 12/2018) via myself
* M62704 (dated 11/2018) via Drake Stefani
Known unaffected MMC names (already working without this commit):
* S10004 (dated 12/2015) via slh
Without enabling dynamic debugging, this error manifests in the kernel
hardware serial console as the following:
[ 2.746605] mmc0: error -110 whilst initialising MMC card
[…trimmed other messages…]
[ 2.877832] Waiting for root device /dev/mmcblk0p5...
Enabling Linux dynamic kernel debugging provides additional messages.
For guidance, see the Linux kernel documentation:
https://www.kernel.org/doc/html/latest/admin-guide/dynamic-debug-howto.html
First, enable dynamic debugging in OpenWRT's configuration:
1. Run "make menuconfig"
2. Select "Global build settings --->"
3. Select "Kernel build options --->"
4. Enable "Compile the kernel with dynamic printk" via spacebar
5. Save and exit (arrow key to "Exit" until prompted to save, save)
Alternatively, set "CONFIG_KERNEL_DYNAMIC_DEBUG=y" in your .config.
Then, turn on dynamic debugging at boot:
Modify bootargs in
target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8065-nbg6817.dts
to add…
bootargs = "[…existing bootargs…] dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
For example:
chosen {
- bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1";
+ bootargs = "rootfstype=squashfs,ext4 rootwait noinitrd fstools_ignore_partname=1 dyndbg=\"file drivers/mmc/* +p\" dynamic_debug.verbose=1 loglevel=8";
append-rootblock = "root=/dev/mmcblk0p";
Then, compile and flash the resulting build. If you are testing
before this commit on newer MMC hardware, be prepared to recover!
NOTE: If you have hardware serial console access, you don't need to
use TFTP recovery to change the active boot partition.
Reboot to working alternative partition via serial console:
1. Connect to hardware serial console
* See https://openwrt.org/toh/zyxel/nbg6817#serial
2. Interrupt boot at "Hit any key to stop autoboot:"
3. Run "ATSE NBG6817"
4. Copy the result (e.g. "001976FE4B04")
* Changes with **every boot** - can't reuse this
5. On your local system, run
"./zyxel-uboot-password-tool.sh <copied value here>"
* Example: "./zyxel-uboot-password-tool.sh 001976FE4B04"
6. Run the command provided by the password tool
* Example: "ATEN 1,910F129B"
* Changes with **every boot** - can't reuse this
7. Run "ATGU"
* You now have full u-boot shell until next boot - unlocking is
not remembered
8. Run either "run boot_mmc" (for booting partition set "FF") or
"run boot_mmc_1" (for booting partition set "01")
* These commands are not affected by dual-boot partition flags
NOTE: This will NOT set the dual-boot partition flag. You'll need to
fix that manually. The "nbg6817-dualboot" script may help:
https://github.com/pkgadd/nbg6817/blob/master/nbg6817-dualboot
zyxel-uboot-password-tool.sh - sourced from
commit 459c8c9ef816156107e297964d088ddee2b4eef5:
ror32() {
echo $(( ($1 >> $2) | (($1 << (32 - $2) & (2**32-1)) ) ))
}
v="0x$1"
a="0x${v:2:6}"
b=$(( a + 0x10F0A563))
c=$(( 0x${v:12:14} & 7 ))
p=$(( $(ror32 $b $c) ^ a ))
printf "ATEN 1,%X\n" $p
Kernel serial console log BEFORE commit with dynamic debug enabled:
[…trimmed…]
[ 3.171343] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.171397] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.175811] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.181134] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.186788] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.192902] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.215609] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.227532] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.247518] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 3.997725] mmc0: req done (CMD2): -110: 00000000 00000000 00000000 00000000
[ 4.003631] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.003659] mmc0: error -110 whilst initialising MMC card
[ 4.016481] mmc0: clock 0Hz busmode 2 powermode 0 cs 0 Vdd 0 width 1 timing 0
Notice how the initial clock is 52 MHz, which is incorrect - MMC
requires negotiation to enable higher speeds.
Kernel serial console log AFTER commit with dynamic debug enabled:
[…trimmed…]
[ 3.168996] mmci-pl18x 12400000.sdcc: designer ID = 0x51
[ 3.169051] mmci-pl18x 12400000.sdcc: revision = 0x0
[ 3.173492] mmci-pl18x 12400000.sdcc: clocking block at 96000000 Hz
[ 3.178808] mmci-pl18x 12400000.sdcc: No vqmmc regulator found
[ 3.184702] mmci-pl18x 12400000.sdcc: mmc0: PL180 manf 51 rev0 at 0x12400000 irq 41,0 (pio)
[ 3.190573] mmci-pl18x 12400000.sdcc: DMA channels RX dma1chan1, TX dma1chan2
[ 3.217873] mmc0: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 3.229250] mmci-pl18x 12400000.sdcc: Initial signal voltage of 3.3v
[ 3.249111] mmc0: clock 400000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 0
[…trimmed…]
[ 4.392652] mmci-pl18x 12400000.sdcc: irq0 (data+cmd) 00000000
[ 4.392785] mmc0: clock 52000000Hz busmode 2 powermode 2 cs 0 Vdd 21 width 1 timing 1
[ 4.406554] mmc0: starting CMD6 arg 03b70201 flags 0000049d
[…trimmed…]
Now, the MMC properly initializes and later switches to high speed.
Thanks to:
* Ansuel for maintaining/help with the IPQ806x platform, kernel code
* slh for additional debugging and suggestions
* dwfreed for confirming newer MMC details, clock frequency
* robimarko for device driver debug printing help, clock debugging
* Drake for testing and confirmation with their own newer NBG6817
...and anyone else I missed!
Signed-off-by: Shane Synan <digitalcircuit36939@gmail.com>
Tested-by: Shane Synan <digitalcircuit36939@gmail.com>
2021-12-03 20:46:36 +00:00
|
|
|
@@ -3009,6 +3254,11 @@ static const struct qcom_reset_map gcc_i
|
2021-03-01 00:03:55 +00:00
|
|
|
[GMAC_CORE3_RESET] = { 0x3cfc, 0 },
|
|
|
|
[GMAC_CORE4_RESET] = { 0x3d1c, 0 },
|
|
|
|
[GMAC_AHB_RESET] = { 0x3e24, 0 },
|
|
|
|
+ [CRYPTO_ENG1_RESET] = { 0x3e00, 0},
|
|
|
|
+ [CRYPTO_ENG2_RESET] = { 0x3e04, 0},
|
|
|
|
+ [CRYPTO_ENG3_RESET] = { 0x3e08, 0},
|
|
|
|
+ [CRYPTO_ENG4_RESET] = { 0x3e0c, 0},
|
|
|
|
+ [CRYPTO_AHB_RESET] = { 0x3e10, 0},
|
|
|
|
[NSS_CH0_RST_RX_CLK_N_RESET] = { 0x3b60, 0 },
|
|
|
|
[NSS_CH0_RST_TX_CLK_N_RESET] = { 0x3b60, 1 },
|
|
|
|
[NSS_CH0_RST_RX_125M_N_RESET] = { 0x3b60, 2 },
|
|
|
|
--- a/include/dt-bindings/clock/qcom,gcc-ipq806x.h
|
|
|
|
+++ b/include/dt-bindings/clock/qcom,gcc-ipq806x.h
|
|
|
|
@@ -240,7 +240,7 @@
|
|
|
|
#define PLL14 232
|
|
|
|
#define PLL14_VOTE 233
|
|
|
|
#define PLL18 234
|
|
|
|
-#define CE5_SRC 235
|
|
|
|
+#define CE5_A_CLK 235
|
|
|
|
#define CE5_H_CLK 236
|
|
|
|
#define CE5_CORE_CLK 237
|
|
|
|
#define CE3_SLEEP_CLK 238
|
|
|
|
@@ -283,5 +283,8 @@
|
|
|
|
#define EBI2_AON_CLK 281
|
|
|
|
#define NSSTCM_CLK_SRC 282
|
|
|
|
#define NSSTCM_CLK 283
|
|
|
|
+#define CE5_A_CLK_SRC 285
|
|
|
|
+#define CE5_H_CLK_SRC 286
|
|
|
|
+#define CE5_CORE_CLK_SRC 287
|
|
|
|
|
|
|
|
#endif
|
|
|
|
--- a/include/dt-bindings/reset/qcom,gcc-ipq806x.h
|
|
|
|
+++ b/include/dt-bindings/reset/qcom,gcc-ipq806x.h
|
|
|
|
@@ -163,5 +163,10 @@
|
|
|
|
#define NSS_CAL_PRBS_RST_N_RESET 154
|
|
|
|
#define NSS_LCKDT_RST_N_RESET 155
|
|
|
|
#define NSS_SRDS_N_RESET 156
|
|
|
|
+#define CRYPTO_ENG1_RESET 157
|
|
|
|
+#define CRYPTO_ENG2_RESET 158
|
|
|
|
+#define CRYPTO_ENG3_RESET 159
|
|
|
|
+#define CRYPTO_ENG4_RESET 160
|
|
|
|
+#define CRYPTO_AHB_RESET 161
|
|
|
|
|
|
|
|
#endif
|