mmc: sunxi: Enable DM_MMC
Subsystems (6)
v3 cover mmc: sunxi: Enable DM_MMC
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's
[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/
Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock support
Jagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: Add DM_MMC support for H6
mmc: sunxi: Add DM_MMC support for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: Enable DM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1
arch/arm/Kconfig | 1 + arch/arm/dts/sunxi-u-boot.dtsi | 4 ++ arch/arm/mach-sunxi/Kconfig | 1 - configs/Linksprite_pcDuino3_defconfig | 1 - drivers/clk/sunxi/clk_a10.c | 4 ++ drivers/clk/sunxi/clk_a10s.c | 3 + drivers/clk/sunxi/clk_a23.c | 6 ++ drivers/clk/sunxi/clk_a31.c | 8 +++ drivers/clk/sunxi/clk_a64.c | 6 ++ drivers/clk/sunxi/clk_a80.c | 28 ++++++++- drivers/clk/sunxi/clk_a83t.c | 6 ++ drivers/clk/sunxi/clk_h3.c | 6 ++ drivers/clk/sunxi/clk_h6.c | 6 ++ drivers/clk/sunxi/clk_r40.c | 8 +++ drivers/clk/sunxi/clk_v3s.c | 6 ++ drivers/mmc/sunxi_mmc.c | 84 +++++++++++++++++++++++++-- 16 files changed, 170 insertions(+), 8 deletions(-)
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 1/9 sunxi: clk: add MMC gates/resets
From: Andre Przywara <[email protected]>
Add the MMC clock gates and reset bits for all the Allwinner SoCs. This allows them to be used by the MMC driver.
We don't advertise the mod clock yet, as this is still handled by the MMC driver.
--- drivers/clk/sunxi/clk_a10.c | 4 ++++ drivers/clk/sunxi/clk_a10s.c | 3 +++ drivers/clk/sunxi/clk_a23.c | 6 ++++++ drivers/clk/sunxi/clk_a31.c | 8 ++++++++ drivers/clk/sunxi/clk_a64.c | 6 ++++++ drivers/clk/sunxi/clk_a83t.c | 6 ++++++ drivers/clk/sunxi/clk_h3.c | 6 ++++++ drivers/clk/sunxi/clk_h6.c | 6 ++++++ drivers/clk/sunxi/clk_r40.c | 8 ++++++++ drivers/clk/sunxi/clk_v3s.c | 6 ++++++ 10 files changed, 59 insertions(+)
drivers/clk/sunxi/clk_a10.c +4 -0
@@ -18,6 +18,10 @@ static struct ccu_clk_gate a10_gates[] = { [CLK_AHB_OHCI0] = GATE(0x060, BIT(2)), [CLK_AHB_EHCI1] = GATE(0x060, BIT(3)), [CLK_AHB_OHCI1] = GATE(0x060, BIT(4)), + [CLK_AHB_MMC0] = GATE(0x060, BIT(8)), + [CLK_AHB_MMC1] = GATE(0x060, BIT(9)), + [CLK_AHB_MMC2] = GATE(0x060, BIT(10)), + [CLK_AHB_MMC3] = GATE(0x060, BIT(11)), [CLK_APB1_UART0] = GATE(0x06c, BIT(16)), [CLK_APB1_UART1] = GATE(0x06c, BIT(17)),
drivers/clk/sunxi/clk_a10s.c +3 -0
@@ -16,6 +16,9 @@ static struct ccu_clk_gate a10s_gates[] = { [CLK_AHB_OTG] = GATE(0x060, BIT(0)), [CLK_AHB_EHCI] = GATE(0x060, BIT(1)), [CLK_AHB_OHCI] = GATE(0x060, BIT(2)), + [CLK_AHB_MMC0] = GATE(0x060, BIT(8)), + [CLK_AHB_MMC1] = GATE(0x060, BIT(9)), + [CLK_AHB_MMC2] = GATE(0x060, BIT(10)), [CLK_APB1_UART0] = GATE(0x06c, BIT(16)), [CLK_APB1_UART1] = GATE(0x06c, BIT(17)),
drivers/clk/sunxi/clk_a23.c +6 -0
@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun8i-a23-a33-ccu.h> static struct ccu_clk_gate a23_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_EHCI ] =GATE (0x060 ,BIT (26 )), [CLK_BUS_OHCI ] =GATE (0x060 ,BIT (29 )),
@@ -35,6 +38,9 @@ static struct ccu_reset a23_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_HSIC] = RESET(0x0cc, BIT(2)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), [RST_BUS_OTG] = RESET(0x2c0, BIT(24)), [RST_BUS_EHCI] = RESET(0x2c0, BIT(26)), [RST_BUS_OHCI] = RESET(0x2c0, BIT(29)),
drivers/clk/sunxi/clk_a31.c +8 -0
@@ -13,6 +13,10 @@#include <dt-bindings/reset/sun6i-a31-ccu.h> static struct ccu_clk_gate a31_gates[] = { + [CLK_AHB1_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_AHB1_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_AHB1_MMC2 ] =GATE (0x060 ,BIT (10 )), + [CLK_AHB1_MMC3 ] =GATE (0x060 ,BIT (12 )), [CLK_AHB1_OTG ] =GATE (0x060 ,BIT (24 )), [CLK_AHB1_EHCI0 ] =GATE (0x060 ,BIT (26 )), [CLK_AHB1_EHCI1 ] =GATE (0x060 ,BIT (27 )),
@@ -40,6 +44,10 @@ static struct ccu_reset a31_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), + [RST_AHB1_MMC0] = RESET(0x2c0, BIT(8)), + [RST_AHB1_MMC1] = RESET(0x2c0, BIT(9)), + [RST_AHB1_MMC2] = RESET(0x2c0, BIT(10)), + [RST_AHB1_MMC3] = RESET(0x2c0, BIT(11)), [RST_AHB1_OTG] = RESET(0x2c0, BIT(24)), [RST_AHB1_EHCI0] = RESET(0x2c0, BIT(26)), [RST_AHB1_EHCI1] = RESET(0x2c0, BIT(27)),
drivers/clk/sunxi/clk_a64.c +6 -0
@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun50i-a64-ccu.h> static const struct ccu_clk_gate a64_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (23 )), [CLK_BUS_EHCI0 ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_EHCI1 ] =GATE (0x060 ,BIT (25 )),
@@ -38,6 +41,9 @@ static const struct ccu_reset a64_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_HSIC] = RESET(0x0cc, BIT(2)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), [RST_BUS_OTG] = RESET(0x2c0, BIT(23)), [RST_BUS_EHCI0] = RESET(0x2c0, BIT(24)), [RST_BUS_EHCI1] = RESET(0x2c0, BIT(25)),
drivers/clk/sunxi/clk_a83t.c +6 -0
@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun8i-a83t-ccu.h> static struct ccu_clk_gate a83t_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_EHCI0 ] =GATE (0x060 ,BIT (26 )), [CLK_BUS_EHCI1 ] =GATE (0x060 ,BIT (27 )),
@@ -36,6 +39,9 @@ static struct ccu_reset a83t_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_HSIC] = RESET(0x0cc, BIT(2)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), [RST_BUS_OTG] = RESET(0x2c0, BIT(24)), [RST_BUS_EHCI0] = RESET(0x2c0, BIT(26)), [RST_BUS_EHCI1] = RESET(0x2c0, BIT(27)),
drivers/clk/sunxi/clk_h3.c +6 -0
@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun8i-h3-ccu.h> static struct ccu_clk_gate h3_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (23 )), [CLK_BUS_EHCI0 ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_EHCI1 ] =GATE (0x060 ,BIT (25 )),
@@ -44,6 +47,9 @@ static struct ccu_reset h3_resets[] = { [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), [RST_USB_PHY3] = RESET(0x0cc, BIT(3)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(10)), [RST_BUS_OTG] = RESET(0x2c0, BIT(23)), [RST_BUS_EHCI0] = RESET(0x2c0, BIT(24)), [RST_BUS_EHCI1] = RESET(0x2c0, BIT(25)),
drivers/clk/sunxi/clk_h6.c +6 -0
@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun50i-h6-ccu.h> static struct ccu_clk_gate h6_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x84c ,BIT (0 )), + [CLK_BUS_MMC1 ] =GATE (0x84c ,BIT (1 )), + [CLK_BUS_MMC2 ] =GATE (0x84c ,BIT (2 )), [CLK_BUS_UART0 ] =GATE (0x90c ,BIT (0 )), [CLK_BUS_UART1 ] =GATE (0x90c ,BIT (1 )), [CLK_BUS_UART2 ] =GATE (0x90c ,BIT (2 )),
@@ -20,6 +23,9 @@ static struct ccu_clk_gate h6_gates[] = { };static struct ccu_reset h6_resets[] = { + [RST_BUS_MMC0 ] =RESET (0x84c ,BIT (16 )), + [RST_BUS_MMC1 ] =RESET (0x84c ,BIT (17 )), + [RST_BUS_MMC2 ] =RESET (0x84c ,BIT (18 )), [RST_BUS_UART0 ] =RESET (0x90c ,BIT (16 )), [RST_BUS_UART1 ] =RESET (0x90c ,BIT (17 )), [RST_BUS_UART2 ] =RESET (0x90c ,BIT (18 )),
drivers/clk/sunxi/clk_r40.c +8 -0
@@ -13,6 +13,10 @@#include <dt-bindings/reset/sun8i-r40-ccu.h> static struct ccu_clk_gate r40_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), + [CLK_BUS_MMC3 ] =GATE (0x060 ,BIT (11 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (25 )), [CLK_BUS_EHCI0 ] =GATE (0x060 ,BIT (26 )), [CLK_BUS_EHCI1 ] =GATE (0x060 ,BIT (27 )),
@@ -43,6 +47,10 @@ static struct ccu_reset r40_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), + [RST_BUS_MMC3] = RESET(0x2c0, BIT(11)), [RST_BUS_OTG] = RESET(0x2c0, BIT(25)), [RST_BUS_EHCI0] = RESET(0x2c0, BIT(26)), [RST_BUS_EHCI1] = RESET(0x2c0, BIT(27)),
drivers/clk/sunxi/clk_v3s.c +6 -0
@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun8i-v3s-ccu.h> static struct ccu_clk_gate v3s_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_UART0 ] =GATE (0x06c ,BIT (16 )),
@@ -25,6 +28,9 @@ static struct ccu_clk_gate v3s_gates[] = {static struct ccu_reset v3s_resets[] = { [RST_USB_PHY0 ] =RESET (0x0cc ,BIT (0 )), + [RST_BUS_MMC0 ] =RESET (0x2c0 ,BIT (8 )), + [RST_BUS_MMC1 ] =RESET (0x2c0 ,BIT (9 )), + [RST_BUS_MMC2 ] =RESET (0x2c0 ,BIT (10 )), [RST_BUS_OTG ] =RESET (0x2c0 ,BIT (24 )), [RST_BUS_UART0 ] =RESET (0x2d8 ,BIT (16 )),
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 1/9 sunxi: clk: add MMC gates/resets
Quoted 10 lines · Jagan Teki
From: Andre Przywara <[email protected]>
Add the MMC clock gates and reset bits for all the Allwinner SoCs. This allows them to be used by the MMC driver.
We don't advertise the mod clock yet, as this is still handled by the MMC driver.
Signed-off-by Andre Przywara <[email protected]>[jagan: add V3S gates/resets, fix CLK_AHB1_MMC3 bit]
Thanks for adding the V3S (looks correct to me), but the CLK_AHB1_MMC3 for the A31 smells like a Linux bug copied: According to the manual this is bit 11, and Linux seems to be off-by-one here (check the next bit!). Sent a fix for Linux.
Please set this back to bit 11 here.
Cheers,
Andre.
Quoted 240 lines
Signed-off-by Jagan Teki <[email protected]>--- drivers/clk/sunxi/clk_a10.c | 4 ++++ drivers/clk/sunxi/clk_a10s.c | 3 +++ drivers/clk/sunxi/clk_a23.c | 6 ++++++ drivers/clk/sunxi/clk_a31.c | 8 ++++++++ drivers/clk/sunxi/clk_a64.c | 6 ++++++ drivers/clk/sunxi/clk_a83t.c | 6 ++++++ drivers/clk/sunxi/clk_h3.c | 6 ++++++ drivers/clk/sunxi/clk_h6.c | 6 ++++++ drivers/clk/sunxi/clk_r40.c | 8 ++++++++ drivers/clk/sunxi/clk_v3s.c | 6 ++++++ 10 files changed, 59 insertions(+)drivers/clk/sunxi/clk_a10.c +4
-0@@ -18,6 +18,10 @@ static struct ccu_clk_gate a10_gates[] = { [CLK_AHB_OHCI0] = GATE(0x060, BIT(2)), [CLK_AHB_EHCI1] = GATE(0x060, BIT(3)), [CLK_AHB_OHCI1] = GATE(0x060, BIT(4)), + [CLK_AHB_MMC0] = GATE(0x060, BIT(8)), + [CLK_AHB_MMC1] = GATE(0x060, BIT(9)), + [CLK_AHB_MMC2] = GATE(0x060, BIT(10)), + [CLK_AHB_MMC3] = GATE(0x060, BIT(11)), [CLK_APB1_UART0] = GATE(0x06c, BIT(16)), [CLK_APB1_UART1] = GATE(0x06c, BIT(17)),drivers/clk/sunxi/clk_a10s.c +3
-0@@ -16,6 +16,9 @@ static struct ccu_clk_gate a10s_gates[] = { [CLK_AHB_OTG] = GATE(0x060, BIT(0)), [CLK_AHB_EHCI] = GATE(0x060, BIT(1)), [CLK_AHB_OHCI] = GATE(0x060, BIT(2)), + [CLK_AHB_MMC0] = GATE(0x060, BIT(8)), + [CLK_AHB_MMC1] = GATE(0x060, BIT(9)), + [CLK_AHB_MMC2] = GATE(0x060, BIT(10)), [CLK_APB1_UART0] = GATE(0x06c, BIT(16)), [CLK_APB1_UART1] = GATE(0x06c, BIT(17)),drivers/clk/sunxi/clk_a23.c +6
-0@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun8i-a23-a33-ccu.h> static struct ccu_clk_gate a23_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_EHCI ] =GATE (0x060 ,BIT (26 )), [CLK_BUS_OHCI ] =GATE (0x060 ,BIT (29 )),@@ -35,6 +38,9 @@ static struct ccu_reset a23_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_HSIC] = RESET(0x0cc, BIT(2)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), [RST_BUS_OTG] = RESET(0x2c0, BIT(24)), [RST_BUS_EHCI] = RESET(0x2c0, BIT(26)), [RST_BUS_OHCI] = RESET(0x2c0, BIT(29)),drivers/clk/sunxi/clk_a31.c +8
-0@@ -13,6 +13,10 @@#include <dt-bindings/reset/sun6i-a31-ccu.h> static struct ccu_clk_gate a31_gates[] = { + [CLK_AHB1_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_AHB1_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_AHB1_MMC2 ] =GATE (0x060 ,BIT (10 )), + [CLK_AHB1_MMC3 ] =GATE (0x060 ,BIT (12 )), [CLK_AHB1_OTG ] =GATE (0x060 ,BIT (24 )), [CLK_AHB1_EHCI0 ] =GATE (0x060 ,BIT (26 )), [CLK_AHB1_EHCI1 ] =GATE (0x060 ,BIT (27 )),@@ -40,6 +44,10 @@ static struct ccu_reset a31_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), + [RST_AHB1_MMC0] = RESET(0x2c0, BIT(8)), + [RST_AHB1_MMC1] = RESET(0x2c0, BIT(9)), + [RST_AHB1_MMC2] = RESET(0x2c0, BIT(10)), + [RST_AHB1_MMC3] = RESET(0x2c0, BIT(11)), [RST_AHB1_OTG] = RESET(0x2c0, BIT(24)), [RST_AHB1_EHCI0] = RESET(0x2c0, BIT(26)), [RST_AHB1_EHCI1] = RESET(0x2c0, BIT(27)),drivers/clk/sunxi/clk_a64.c +6
-0@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun50i-a64-ccu.h> static const struct ccu_clk_gate a64_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (23 )), [CLK_BUS_EHCI0 ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_EHCI1 ] =GATE (0x060 ,BIT (25 )),@@ -38,6 +41,9 @@ static const struct ccu_reset a64_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_HSIC] = RESET(0x0cc, BIT(2)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), [RST_BUS_OTG] = RESET(0x2c0, BIT(23)), [RST_BUS_EHCI0] = RESET(0x2c0, BIT(24)), [RST_BUS_EHCI1] = RESET(0x2c0, BIT(25)),drivers/clk/sunxi/clk_a83t.c +6
-0@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun8i-a83t-ccu.h> static struct ccu_clk_gate a83t_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_EHCI0 ] =GATE (0x060 ,BIT (26 )), [CLK_BUS_EHCI1 ] =GATE (0x060 ,BIT (27 )),@@ -36,6 +39,9 @@ static struct ccu_reset a83t_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_HSIC] = RESET(0x0cc, BIT(2)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), [RST_BUS_OTG] = RESET(0x2c0, BIT(24)), [RST_BUS_EHCI0] = RESET(0x2c0, BIT(26)), [RST_BUS_EHCI1] = RESET(0x2c0, BIT(27)),drivers/clk/sunxi/clk_h3.c +6
-0@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun8i-h3-ccu.h> static struct ccu_clk_gate h3_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (23 )), [CLK_BUS_EHCI0 ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_EHCI1 ] =GATE (0x060 ,BIT (25 )),@@ -44,6 +47,9 @@ static struct ccu_reset h3_resets[] = { [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), [RST_USB_PHY3] = RESET(0x0cc, BIT(3)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(10)), [RST_BUS_OTG] = RESET(0x2c0, BIT(23)), [RST_BUS_EHCI0] = RESET(0x2c0, BIT(24)), [RST_BUS_EHCI1] = RESET(0x2c0, BIT(25)),drivers/clk/sunxi/clk_h6.c +6
-0@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun50i-h6-ccu.h> static struct ccu_clk_gate h6_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x84c ,BIT (0 )), + [CLK_BUS_MMC1 ] =GATE (0x84c ,BIT (1 )), + [CLK_BUS_MMC2 ] =GATE (0x84c ,BIT (2 )), [CLK_BUS_UART0 ] =GATE (0x90c ,BIT (0 )), [CLK_BUS_UART1 ] =GATE (0x90c ,BIT (1 )), [CLK_BUS_UART2 ] =GATE (0x90c ,BIT (2 )),@@ -20,6 +23,9 @@ static struct ccu_clk_gate h6_gates[] = { };static struct ccu_reset h6_resets[] = { + [RST_BUS_MMC0 ] =RESET (0x84c ,BIT (16 )), + [RST_BUS_MMC1 ] =RESET (0x84c ,BIT (17 )), + [RST_BUS_MMC2 ] =RESET (0x84c ,BIT (18 )), [RST_BUS_UART0 ] =RESET (0x90c ,BIT (16 )), [RST_BUS_UART1 ] =RESET (0x90c ,BIT (17 )), [RST_BUS_UART2 ] =RESET (0x90c ,BIT (18 )),drivers/clk/sunxi/clk_r40.c +8
-0@@ -13,6 +13,10 @@#include <dt-bindings/reset/sun8i-r40-ccu.h> static struct ccu_clk_gate r40_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), + [CLK_BUS_MMC3 ] =GATE (0x060 ,BIT (11 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (25 )), [CLK_BUS_EHCI0 ] =GATE (0x060 ,BIT (26 )), [CLK_BUS_EHCI1 ] =GATE (0x060 ,BIT (27 )),@@ -43,6 +47,10 @@ static struct ccu_reset r40_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), + [RST_BUS_MMC0] = RESET(0x2c0, BIT(8)), + [RST_BUS_MMC1] = RESET(0x2c0, BIT(9)), + [RST_BUS_MMC2] = RESET(0x2c0, BIT(10)), + [RST_BUS_MMC3] = RESET(0x2c0, BIT(11)), [RST_BUS_OTG] = RESET(0x2c0, BIT(25)), [RST_BUS_EHCI0] = RESET(0x2c0, BIT(26)), [RST_BUS_EHCI1] = RESET(0x2c0, BIT(27)),drivers/clk/sunxi/clk_v3s.c +6
-0@@ -13,6 +13,9 @@#include <dt-bindings/reset/sun8i-v3s-ccu.h> static struct ccu_clk_gate v3s_gates[] = { + [CLK_BUS_MMC0 ] =GATE (0x060 ,BIT (8 )), + [CLK_BUS_MMC1 ] =GATE (0x060 ,BIT (9 )), + [CLK_BUS_MMC2 ] =GATE (0x060 ,BIT (10 )), [CLK_BUS_OTG ] =GATE (0x060 ,BIT (24 )), [CLK_BUS_UART0 ] =GATE (0x06c ,BIT (16 )),@@ -25,6 +28,9 @@ static struct ccu_clk_gate v3s_gates[] = {static struct ccu_reset v3s_resets[] = { [RST_USB_PHY0 ] =RESET (0x0cc ,BIT (0 )), + [RST_BUS_MMC0 ] =RESET (0x2c0 ,BIT (8 )), + [RST_BUS_MMC1 ] =RESET (0x2c0 ,BIT (9 )), + [RST_BUS_MMC2 ] =RESET (0x2c0 ,BIT (10 )), [RST_BUS_OTG ] =RESET (0x2c0 ,BIT (24 )), [RST_BUS_UART0 ] =RESET (0x2d8 ,BIT (16 )),
PATCH v3 2/9 sunxi: clk: A80: add MMC clock support
In reply to Jagan TekiFrom: Andre Przywara <[email protected]>
The A80 handles resets and clock gates for the MMC devices differently, outside of the CCU IP block. Consequently we have a separate clock device with a separate binding for that.
Implement that with the respective clock gates and resets to allow the A80 taking part in the DM_MMC game.
--- drivers/clk/sunxi/clk_a80.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/clk/sunxi/clk_a80.c +27 -1
@@ -30,19 +30,45 @@ static const struct ccu_reset a80_resets[] = { [RST_BUS_UART5] = RESET(0x5b4, BIT(21)), }; +static const struct ccu_clk_gate a80_mmc_gates[] = { + [0 ] =GATE (0x0 ,BIT (16 )), + [1 ] =GATE (0x4 ,BIT (16 )), + [2 ] =GATE (0x8 ,BIT (16 )), + [3 ] =GATE (0xc ,BIT (16 )), +}; + +static const struct ccu_reset a80_mmc_resets[] = { + [0 ] =GATE (0x0 ,BIT (18 )), + [1 ] =GATE (0x4 ,BIT (18 )), + [2 ] =GATE (0x8 ,BIT (18 )), + [3 ] =GATE (0xc ,BIT (18 )), +}; +static const struct ccu_desc a80_ccu_desc = { .gates = a80_gates, .resets = a80_resets, }; +static const struct ccu_desc a80_mmc_clk_desc = { + .gates = a80_mmc_gates, + .resets = a80_mmc_resets, +}; +static int a80_clk_bind (struct udevice *dev) { -return sunxi_reset_bind (dev,ARRAY_SIZE (a80_resets)); +ulong count =ARRAY_SIZE (a80_resets); + +if (device_is_compatible (dev,"allwinner,allwinner,sun9i-a80-mmc" )) + count =ARRAY_SIZE (a80_mmc_resets); + +return sunxi_reset_bind (dev, count); }static const struct udevice_id a80_ccu_ids[] = { { .compatible ="allwinner,sun9i-a80-ccu" , .data = (ulong)&a80_ccu_desc }, + { .compatible ="allwinner,sun9i-a80-mmc-config-clk" , + .data = (ulong)&a80_mmc_clk_desc }, { } };
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 3/9 mmc: sunxi: Add A83T emmc compatible
In reply to Jagan TekiAdd emmc compatible for A83T SoC.
--- drivers/mmc/sunxi_mmc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/sunxi_mmc.c +4 -0
@@ -693,6 +693,10 @@ static const struct udevice_id sunxi_mmc_ids[] = { .compatible = "allwinner,sun7i-a20-mmc", .data = (ulong)&sun4i_a10_variant, }, + { + .compatible = "allwinner,sun8i-a83t-emmc", + .data = (ulong)&sun4i_a10_variant, + }, {/* sentinel */ } };
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 3/9 mmc: sunxi: Add A83T emmc compatible
Quoted 1 line · Jagan Teki
Add emmc compatible for A83T SoC.
You could merge this one with the next patch.
Quoted 2 lines
Cc Jaehoon Chung <[email protected]>Signed-off-by Jagan Teki <[email protected]>
Cheers,
Andre.
Quoted 20 lines
--- drivers/mmc/sunxi_mmc.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/sunxi_mmc.c +4
-0@@ -693,6 +693,10 @@ static const struct udevice_id sunxi_mmc_ids[] = { .compatible = "allwinner,sun7i-a20-mmc", .data = (ulong)&sun4i_a10_variant, }, + { + .compatible = "allwinner,sun8i-a83t-emmc", + .data = (ulong)&sun4i_a10_variant, + }, {/* sentinel */ } };
PATCH v3 4/9 mmc: sunxi: Add mmc, emmc H5/A64 compatible
In reply to Jagan TekiAdded H5, A64 compatible for mmc and emmc.
--- drivers/mmc/sunxi_mmc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mmc/sunxi_mmc.c +8 -0
@@ -697,6 +697,14 @@ static const struct udevice_id sunxi_mmc_ids[] = { .compatible = "allwinner,sun8i-a83t-emmc", .data = (ulong)&sun4i_a10_variant, }, + { + .compatible = "allwinner,sun50i-a64-mmc", + .data = (ulong)&sun4i_a10_variant, + }, + { + .compatible = "allwinner,sun50i-a64-emmc", + .data = (ulong)&sun4i_a10_variant, + }, {/* sentinel */ } };
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 4/9 mmc: sunxi: Add mmc, emmc H5/A64 compatible
Quoted 1 line · Jagan Teki
Added H5, A64 compatible for mmc and emmc.
As mentioned, could be merged with the previous patch.
Quoted 2 lines
Cc Jaehoon Chung <[email protected]>Signed-off-by Jagan Teki <[email protected]>
Cheers,
Andre
Quoted 24 lines
--- drivers/mmc/sunxi_mmc.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/mmc/sunxi_mmc.c +8
-0@@ -697,6 +697,14 @@ static const struct udevice_id sunxi_mmc_ids[] = { .compatible = "allwinner,sun8i-a83t-emmc", .data = (ulong)&sun4i_a10_variant, }, + { + .compatible = "allwinner,sun50i-a64-mmc", + .data = (ulong)&sun4i_a10_variant, + }, + { + .compatible = "allwinner,sun50i-a64-emmc", + .data = (ulong)&sun4i_a10_variant, + }, {/* sentinel */ } };
PATCH v3 5/9 mmc: sunxi: Add DM_MMC support for H6
In reply to Jagan TekiUnlike other Allwinner SoC's, H6 comes with different clock and reset control offset values. So support them via driver data.
--- drivers/mmc/sunxi_mmc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/mmc/sunxi_mmc.c +12 -0
@@ -680,6 +680,10 @@ static const struct sunxi_mmc_variant sun4i_a10_variant = { .mclk_offset = 0x88, }; +static const struct sunxi_mmc_variant sun50i_h6_variant = { + .mclk_offset =0x830 , +}; +static const struct udevice_id sunxi_mmc_ids[] = { { .compatible ="allwinner,sun4i-a10-mmc" ,
@@ -705,6 +709,14 @@ static const struct udevice_id sunxi_mmc_ids[] = { .compatible = "allwinner,sun50i-a64-emmc", .data = (ulong)&sun4i_a10_variant, }, + { + .compatible = "allwinner,sun50i-h6-mmc", + .data = (ulong)&sun50i_h6_variant, + }, + { + .compatible = "allwinner,sun50i-h6-emmc", + .data = (ulong)&sun50i_h6_variant, + }, {/* sentinel */ } };
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 5/9 mmc: sunxi: Add DM_MMC support for H6
Quoted 3 lines · Jagan Teki
Unlike other Allwinner SoC's, H6 comes with different clock and reset control offset values. So support them via driver data.
Nit: It's just the mod clock offset we care about here, the rest is already handled by the new clock driver.
Quoted 3 lines
Cc Jaehoon Chung <[email protected]>Signed-off-by Jagan Teki <[email protected]>
Cheers,
Andre.
Quoted 35 lines
--- drivers/mmc/sunxi_mmc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/mmc/sunxi_mmc.c +12
-0@@ -680,6 +680,10 @@ static const struct sunxi_mmc_variant sun4i_a10_variant = { .mclk_offset = 0x88, }; +static const struct sunxi_mmc_variant sun50i_h6_variant = { + .mclk_offset =0x830 , +}; +static const struct udevice_id sunxi_mmc_ids[] = { { .compatible ="allwinner,sun4i-a10-mmc" ,@@ -705,6 +709,14 @@ static const struct udevice_id sunxi_mmc_ids[] = { .compatible = "allwinner,sun50i-a64-emmc", .data = (ulong)&sun4i_a10_variant, }, + { + .compatible = "allwinner,sun50i-h6-mmc", + .data = (ulong)&sun50i_h6_variant, + }, + { + .compatible = "allwinner,sun50i-h6-emmc", + .data = (ulong)&sun50i_h6_variant, + }, {/* sentinel */ } };
PATCH v3 6/9 mmc: sunxi: Add DM_MMC support for A80
In reply to Jagan TekiUnlike other Allwinner SoC's, A80 comes with different ahb gate clock offset values and also has mmc common controller. So support them via driver data.
--- drivers/mmc/sunxi_mmc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mmc/sunxi_mmc.c +8 -0
@@ -680,6 +680,10 @@ static const struct sunxi_mmc_variant sun4i_a10_variant = { .mclk_offset = 0x88, }; +static const struct sunxi_mmc_variant sun9i_a80_variant = { + .mclk_offset =0x410 , +}; +static const struct sunxi_mmc_variant sun50i_h6_variant = { .mclk_offset =0x830 , };
@@ -701,6 +705,10 @@ static const struct udevice_id sunxi_mmc_ids[] = { .compatible = "allwinner,sun8i-a83t-emmc", .data = (ulong)&sun4i_a10_variant, }, + { + .compatible = "allwinner,sun9i-a80-mmc", + .data = (ulong)&sun9i_a80_variant, + }, { .compatible = "allwinner,sun50i-a64-mmc", .data = (ulong)&sun4i_a10_variant,
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 6/9 mmc: sunxi: Add DM_MMC support for A80
Quoted 3 lines · Jagan Teki
Unlike other Allwinner SoC's, A80 comes with different ahb gate clock offset values and also has mmc common controller. So support them via driver data.
As mentioned in the fix I sent, this requires the clock and reset support for CCU devices themselves before it can work.
With that fix applied before that patch in a series:
Quoted 3 lines
Cc Rask Ingemann Lambertsen <[email protected]>Cc Jaehoon Chung <[email protected]>Signed-off-by Jagan Teki <[email protected]>
Cheers,
Andre.
Quoted 31 lines
--- drivers/mmc/sunxi_mmc.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/mmc/sunxi_mmc.c +8
-0@@ -680,6 +680,10 @@ static const struct sunxi_mmc_variant sun4i_a10_variant = { .mclk_offset = 0x88, }; +static const struct sunxi_mmc_variant sun9i_a80_variant = { + .mclk_offset =0x410 , +}; +static const struct sunxi_mmc_variant sun50i_h6_variant = { .mclk_offset =0x830 , };@@ -701,6 +705,10 @@ static const struct udevice_id sunxi_mmc_ids[] = { .compatible = "allwinner,sun8i-a83t-emmc", .data = (ulong)&sun4i_a10_variant, }, + { + .compatible = "allwinner,sun9i-a80-mmc", + .data = (ulong)&sun9i_a80_variant, + }, { .compatible = "allwinner,sun50i-a64-mmc", .data = (ulong)&sun4i_a10_variant,
PATCH v3 7/9 dm: mmc: sunxi: Add CLK and RESET support
In reply to Jagan TekiNow CLK and RESET driver for Allwinner SoC are available, so add the relevant operations on mmc sunxi driver.
---
Changes for v3:
- Grab changes for ML
drivers/mmc/sunxi_mmc.c | 52 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 5 deletions(-)
drivers/mmc/sunxi_mmc.c +47 -5
@@ -8,10 +8,12 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <errno.h> #include <malloc.h> #include <mmc.h> +#include <reset.h> #include <asm/io.h> #include <asm/arch/clock.h> #include <asm/arch/cpu.h>
@@ -21,7 +23,6 @@#ifdef CONFIG_DM_MMC struct sunxi_mmc_variant { -u16 gate_offset;u16 mclk_offset; };#endif
@@ -41,6 +42,8 @@ struct sunxi_mmc_priv {struct mmc_config cfg;#ifdef CONFIG_DM_MMC const struct sunxi_mmc_variant *variant; +struct clk clk_ahb; +struct reset_ctl reset;#endif };
@@ -602,6 +605,32 @@ static const struct dm_mmc_ops sunxi_mmc_ops = { .get_cd = sunxi_mmc_getcd, }; +static int sunxi_mmc_enable (struct udevice *dev) +{ +struct sunxi_mmc_priv *priv =dev_get_priv (dev); +int ret; + + ret =clk_enable (&priv->clk_ahb); +if (ret) { +dev_err (dev,"failed to enable AHB clock\n" ); +return ret; + } + +if (reset_valid (&priv->reset)) { + ret =reset_deassert (&priv->reset); +if (ret) { +dev_err (dev,"failed to deassert reset\n" ); + goto err_clk_ahb; + } + } + +return 0 ; + +err_clk_ahb: +clk_disable (&priv->clk_ahb); +return ret; +} +static int sunxi_mmc_probe (struct udevice *dev) {struct mmc_uclass_priv *upriv =dev_get_uclass_priv (dev);
@@ -609,7 +638,7 @@ static int sunxi_mmc_probe(struct udevice *dev)struct sunxi_mmc_priv *priv =dev_get_priv (dev);struct mmc_config *cfg = &plat->cfg;struct ofnode_phandle_args args; -u32 *gate_reg, *ccu_reg; +u32 *ccu_reg;int bus_width, ret; cfg->name = dev->name;
@@ -641,8 +670,22 @@ static int sunxi_mmc_probe(struct udevice *dev) priv->mmc_no = ((uintptr_t )priv->reg -SUNXI_MMC0_BASE ) /0x1000 ; priv->mclkreg = (void *)ccu_reg + (priv->variant->mclk_offset + (priv->mmc_no *4 )); - gate_reg = (void *)ccu_reg + priv->variant->gate_offset; -setbits_le32 (gate_reg,BIT (AHB_GATE_OFFSET_MMC (priv->mmc_no))); + + ret =clk_get_by_name (dev,"ahb" , &priv->clk_ahb); +if (ret) { +dev_err (dev,"failed to get AHB clock\n" ); +return ret; + } + + ret =reset_get_by_name (dev,"ahb" , &priv->reset); +if (ret && ret != -ENOENT ) { +dev_err (dev,"failed to get reset\n" ); +return ret; + } + + ret =sunxi_mmc_enable (dev); +if (ret) +return ret; ret =mmc_set_mod_clk (priv,24000000 );if (ret)
@@ -676,7 +719,6 @@ static int sunxi_mmc_bind(struct udevice *dev) }static const struct sunxi_mmc_variant sun4i_a10_variant = { - .gate_offset =0x60 , .mclk_offset =0x88 , };
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 7/9 dm: mmc: sunxi: Add CLK and RESET support
Quoted 38 lines · Jagan Teki
Now CLK and RESET driver for Allwinner SoC are available, so add the relevant operations on mmc sunxi driver.
Cc Jaehoon Chung <[email protected]>Signed-off-by Jagan Teki <[email protected]>---
Changes for v3:
- Grab changes for MLdrivers/mmc/sunxi_mmc.c | 52 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 5 deletions(-)drivers/mmc/sunxi_mmc.c +2
-1@@ -8,10 +8,12 @@*/ #include <common.h> +#include <clk.h> #include <dm.h> #include <errno.h> #include <malloc.h> #include <mmc.h> +#include <reset.h> #include <asm/io.h> #include <asm/arch/clock.h> #include <asm/arch/cpu.h> @@ -21,7 +23,6 @@#ifdef CONFIG_DM_MMC struct sunxi_mmc_variant { -u16 gate_offset;u16 mclk_offset; };#endif
drivers/mmc/sunxi_mmc.c struct sunxi_mmc_priv { · line 46
Quoted 5 lines
drivers/mmc/sunxi_mmc.c +2
-0@@ -41,6 +42,8 @@ struct sunxi_mmc_priv {struct mmc_config cfg;#ifdef CONFIG_DM_MMC const struct sunxi_mmc_variant *variant; +struct clk clk_ahb; +struct reset_ctl reset;
Where is that used again outside of the probe() function?
Quoted 23 lines
drivers/mmc/sunxi_mmc.c +16
-0#endif };@@ -602,6 +605,32 @@ static const struct dm_mmc_ops sunxi_mmc_ops = { .get_cd = sunxi_mmc_getcd, }; +static int sunxi_mmc_enable (struct udevice *dev) +{ +struct sunxi_mmc_priv *priv =dev_get_priv (dev); +int ret; + + ret =clk_enable (&priv->clk_ahb); +if (ret) { +dev_err (dev,"failed to enable AHB clock\n" ); +return ret; + } + +if (reset_valid (&priv->reset)) { + ret =reset_deassert (&priv->reset); +if (ret) { +dev_err (dev,"failed to deassert reset\n" ); + goto err_clk_ahb;
drivers/mmc/sunxi_mmc.c static const struct dm_mmc_ops sunxi_mmc_ops = { · line 633
Quoted 10 lines
drivers/mmc/sunxi_mmc.c +10
-0+ } + } + +return 0 ; + +err_clk_ahb: +clk_disable (&priv->clk_ahb); +return ret; +} +
Frankly, that's a lots of lines for very little effect.
Why not just use the much smaller version I had and add an "else dev_err(...)" to it, if you are keen about error reports? Saves you the variables, saves you the reset_valid() call, saves you the extra function. Less code to read, smaller image, less bugs.
Cheers,
Andre.
Quoted 46 lines
drivers/mmc/sunxi_mmc.c +17
-4static int sunxi_mmc_probe (struct udevice *dev) {struct mmc_uclass_priv *upriv =dev_get_uclass_priv (dev);@@ -609,7 +638,7 @@ static int sunxi_mmc_probe(struct udevice *dev)struct sunxi_mmc_priv *priv =dev_get_priv (dev);struct mmc_config *cfg = &plat->cfg;struct ofnode_phandle_args args; -u32 *gate_reg, *ccu_reg; +u32 *ccu_reg;int bus_width, ret; cfg->name = dev->name;@@ -641,8 +670,22 @@ static int sunxi_mmc_probe(struct udevice *dev) priv->mmc_no = ((uintptr_t )priv->reg -SUNXI_MMC0_BASE ) /0x1000 ; priv->mclkreg = (void *)ccu_reg + (priv->variant->mclk_offset + (priv->mmc_no *4 )); - gate_reg = (void *)ccu_reg + priv->variant->gate_offset; -setbits_le32 (gate_reg,BIT (AHB_GATE_OFFSET_MMC (priv->mmc_no))); + + ret =clk_get_by_name (dev,"ahb" , &priv->clk_ahb); +if (ret) { +dev_err (dev,"failed to get AHB clock\n" ); +return ret; + } + + ret =reset_get_by_name (dev,"ahb" , &priv->reset); +if (ret && ret != -ENOENT ) { +dev_err (dev,"failed to get reset\n" ); +return ret; + } + + ret =sunxi_mmc_enable (dev); +if (ret) +return ret; ret =mmc_set_mod_clk (priv,24000000 );if (ret)@@ -676,7 +719,6 @@ static int sunxi_mmc_bind(struct udevice *dev) }static const struct sunxi_mmc_variant sun4i_a10_variant = { - .gate_offset =0x60 , .mclk_offset =0x88 , };
PATCH v3 8/9 arm: sunxi: Enable DM_MMC
In reply to Jagan TekiEnable DM_MMC for all Allwinner SoCs, this will eventually enable BLK.
Also removed DM_MMC enablement in few parts of sunxi configurations.
--- arch/arm/Kconfig | 1 + arch/arm/mach-sunxi/Kconfig | 1 - configs/Linksprite_pcDuino3_defconfig | 1 - 3 files changed, 1 insertion(+), 2 deletions(-)
arch/arm/Kconfig +1 -0
@@ -851,6 +851,7 @@ config ARCH_SUNXI select DM_ETH select DM_GPIO select DM_KEYBOARD + select DM_MMC if MMC select DM_SERIAL select DM_USB if DISTRO_DEFAULTS select OF_BOARD_SETUP
arch/arm/mach-sunxi/Kconfig +0 -1
@@ -154,7 +154,6 @@ config MACH_SUN4I bool "sun4i (Allwinner A10)" select CPU_V7A select ARM_CORTEX_CPU_IS_UP - select DM_MMC if MMC select DM_SCSI if SCSI select PHY_SUN4I_USB select DRAM_SUN4I
configs/Linksprite_pcDuino3_defconfig +0 -1
@@ -14,7 +14,6 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_EFI_PARTITION is not set CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-pcduino3" CONFIG_SCSI_AHCI=y -CONFIG_DM_MMC=y CONFIG_ETH_DESIGNWARE=y CONFIG_MII=y CONFIG_SUN7I_GMAC=y
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 8/9 arm: sunxi: Enable DM_MMC
Quoted 7 lines · Jagan Teki
Enable
DM_MMCfor all Allwinner SoCs, this will eventually enable BLK.Also removed
DM_MMCenablement in few parts of sunxi configurations.Signed-off-by Jagan Teki <[email protected]>
Cheers,
Andre
Quoted 43 lines
--- arch/arm/Kconfig | 1 + arch/arm/mach-sunxi/Kconfig | 1 - configs/Linksprite_pcDuino3_defconfig | 1 - 3 files changed, 1 insertion(+), 2 deletions(-)arch/arm/Kconfig +1
-0@@ -851,6 +851,7 @@ config ARCH_SUNXI select DM_ETH select DM_GPIO select DM_KEYBOARD + select DM_MMC if MMC select DM_SERIAL select DM_USB if DISTRO_DEFAULTS select OF_BOARD_SETUParch/arm/mach-sunxi/Kconfig +0
-1@@ -154,7 +154,6 @@ config MACH_SUN4I bool "sun4i (Allwinner A10)" select CPU_V7A select ARM_CORTEX_CPU_IS_UP - select DM_MMC if MMC select DM_SCSI if SCSI select PHY_SUN4I_USB select DRAM_SUN4Iconfigs/Linksprite_pcDuino3_defconfig +0
-1@@ -14,7 +14,6 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_EFI_PARTITION is not set CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-pcduino3" CONFIG_SCSI_AHCI=y -CONFIG_DM_MMC=y CONFIG_ETH_DESIGNWARE=y CONFIG_MII=y CONFIG_SUN7I_GMAC=y
PATCH v3 9/9 arm: dts: sunxi: Enumerate MMC2 as MMC1
In reply to Jagan TekiEnvironment and fastboot MMC devices are configured based number of mmc slots defined on particular board in sunxi platform.
If number of slots are not more than 1, it assigns 0 which usually mmc device on SD slot. With DM_MMC it is detected as 0 since mmc0 node always be an mmc device.
If number of slots are more than 1, it assigns 1 which assumes 0 is mmc device and 1 is emmc device. But with DM_MMC there is chance of detecting emmc as device 2 since mmc1 is SDIO as per devicetree definition.
So override mmc2 to mmc1 in sunxi dtsi, this will eventually detect mmc2 as mmc 1 device even if the board dts has mmc0, mmc1, mmc2.
Some platforms like A20 has mmc0...mmc3, but there is no usecases now for enabling all mmc controllers in any of A20 board dts files.
--- arch/arm/dts/sunxi-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/dts/sunxi-u-boot.dtsi +4 -0
@@ -1,6 +1,10 @@ #include <config.h> / { + aliases { + mmc1 = &mmc2; + }; + binman { filename = "u-boot-sunxi-with-spl.bin"; pad-byte = <0xff>;
Signature · 1 line
2.18.0.321.gffc6fa0e3
PATCH v3 9/9 arm: dts: sunxi: Enumerate MMC2 as MMC1
Quoted 39 lines · Jagan Teki
Environment and fastboot MMC devices are configured based number of mmc slots defined on particular board in sunxi platform.
If number of slots are not more than 1, it assigns 0 which usually mmc device on SD slot. With
DM_MMCit is detected as 0 since mmc0 node always be an mmc device.If number of slots are more than 1, it assigns 1 which assumes 0 is mmc device and 1 is emmc device. But with
DM_MMCthere is chance of detecting emmc as device 2 since mmc1 is SDIO as per devicetree definition.So override mmc2 to mmc1 in sunxi dtsi, this will eventually detect mmc2 as mmc 1 device even if the board dts has mmc0, mmc1, mmc2.
Some platforms like A20 has mmc0...mmc3, but there is no usecases now for enabling all mmc controllers in any of A20 board dts files.
Signed-off-by Jagan Teki <[email protected]>--- arch/arm/dts/sunxi-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/dts/sunxi-u-boot.dtsi +4
-1@@ -1,6 +1,10 @@ #include <config.h> / { + aliases { + mmc1 = &mmc2; + }; + binman { filename = "u-boot-sunxi-with-spl.bin"; pad-byte = <0xff>; --
Quoted 2 lines
2.18.0.321.gffc6fa0e3
Slightly curious. What happens when mmc1 (the real mmc1) is enabled and probes before mmc2 does? Does it take mmc1? What happens then when mmc2 probes and wants mmc1?
Also, on the A31, we use mmc3 instead of mmc2 for eMMC. Only mmc3 supports DDR transfer modes.
ChenYu
PATCH v3 9/9 arm: dts: sunxi: Enumerate MMC2 as MMC1
Quoted 32 lines · Chen-Yu Tsai
Quoted 30 lines · Jagan Teki
Environment and fastboot MMC devices are configured based number of mmc slots defined on particular board in sunxi platform.
If number of slots are not more than 1, it assigns 0 which usually mmc device on SD slot. With
DM_MMCit is detected as 0 since mmc0 node always be an mmc device.If number of slots are more than 1, it assigns 1 which assumes 0 is mmc device and 1 is emmc device. But with
DM_MMCthere is chance of detecting emmc as device 2 since mmc1 is SDIO as per devicetree definition.So override mmc2 to mmc1 in sunxi dtsi, this will eventually detect mmc2 as mmc 1 device even if the board dts has mmc0, mmc1, mmc2.
Some platforms like A20 has mmc0...mmc3, but there is no usecases now for enabling all mmc controllers in any of A20 board dts files.
Signed-off-by Jagan Teki <[email protected]>--- arch/arm/dts/sunxi-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/dts/sunxi-u-boot.dtsi +0
-0@@ -1,6 +1,10 @@ #include <config.h>
Quoted 15 lines
Quoted 11 lines
arch/arm/dts/sunxi-u-boot.dtsi +4
-1/ { + aliases { + mmc1 = &mmc2; + }; + binman { filename = "u-boot-sunxi-with-spl.bin"; pad-byte = <0xff>; --2.18.0.321.gffc6fa0e3
Slightly curious. What happens when mmc1 (the real mmc1) is enabled and probes before mmc2 does? Does it take mmc1? What happens then when mmc2 probes and wants mmc1?
Existing sunxi code has MMC_SUNXI_SLOT_EXTRA if the board has second MMC device, like eMMC which make default env or fastboot device as 1. But with DT definitions eMMC can be probed as mmc2 which can fail to get env and fastboot setups.
This override mmc2 to as mmc1 can satisfy the existing code identification. I did many code changes to get rid of DT changes but it became hard to get via those[1], patch 27 to 31
Quoted 3 lines
Also, on the A31, we use mmc3 instead of mmc2 for eMMC. Only mmc3 supports DDR transfer modes.
Yes, but as per current usage no board is using all together, if some board is using then, it's their duty to enable the same via defconfig in future.
PATCH v3 9/9 arm: dts: sunxi: Enumerate MMC2 as MMC1
Quoted 50 lines · Jagan Teki
Quoted 32 lines · Chen-Yu Tsai
Quoted 30 lines · Jagan Teki
Environment and fastboot MMC devices are configured based number of mmc slots defined on particular board in sunxi platform.
If number of slots are not more than 1, it assigns 0 which usually mmc device on SD slot. With
DM_MMCit is detected as 0 since mmc0 node always be an mmc device.If number of slots are more than 1, it assigns 1 which assumes 0 is mmc device and 1 is emmc device. But with
DM_MMCthere is chance of detecting emmc as device 2 since mmc1 is SDIO as per devicetree definition.So override mmc2 to mmc1 in sunxi dtsi, this will eventually detect mmc2 as mmc 1 device even if the board dts has mmc0, mmc1, mmc2.
Some platforms like A20 has mmc0...mmc3, but there is no usecases now for enabling all mmc controllers in any of A20 board dts files.
Signed-off-by Jagan Teki <[email protected]>--- arch/arm/dts/sunxi-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/dts/sunxi-u-boot.dtsi +0
-0@@ -1,6 +1,10 @@ #include <config.h>Quoted 15 lines
Quoted 11 lines
arch/arm/dts/sunxi-u-boot.dtsi +4
-1/ { + aliases { + mmc1 = &mmc2; + }; + binman { filename = "u-boot-sunxi-with-spl.bin"; pad-byte = <0xff>; --2.18.0.321.gffc6fa0e3
Slightly curious. What happens when mmc1 (the real mmc1) is enabled and probes before mmc2 does? Does it take mmc1? What happens then when mmc2 probes and wants mmc1?
Quoted 8 lines
Existing sunxi code has
MMC_SUNXI_SLOT_EXTRAif the board has second MMC device, like eMMC which make default env or fastboot device as 1. But with DT definitions eMMC can be probed as mmc2 which can fail to get env and fastboot setups.This override mmc2 to as mmc1 can satisfy the existing code identification. I did many code changes to get rid of DT changes but it became hard to get via those[1], patch 27 to 31
So it looks like aliases take precedence over auto-numbering, even if an auto-numbered device is already probed. See
https://elixir.bootlin.com/u-boot/latest/source/drivers/block/blk-uclass.c#L544
That was the bit of detail that I was asking about. My question was what happens to the original mmc1 when mmc2 probes/binds with the mmc1 alias. So the result should be that mmc0 is still mmc0, mmc2 becomes mmc1, and mmc1 becomes mmc2. It would've been nice to see it in the commit log. It would explain why and how it works, and more importantly, why it doesn't screw up the system.
Quoted 7 lines
Quoted 3 lines
Also, on the A31, we use mmc3 instead of mmc2 for eMMC. Only mmc3 supports DDR transfer modes.
Yes, but as per current usage no board is using all together, if some board is using then, it's their duty to enable the same via defconfig in future.
I see. Looks like we got lucky.
I realize now that everything was explained in the commit log. However it lacks a bit of underlying knowledge or context, as I mentioned above. IMO these details are important, as they are basically your assumptions when doing the changes.
ChenYu
PATCH v3 9/9 arm: dts: sunxi: Enumerate MMC2 as MMC1
In reply to Jagan TekiQuoted 8 lines · Jagan Teki
Environment and fastboot MMC devices are configured based number of mmc slots defined on particular board in sunxi platform.
If number of slots are not more than 1, it assigns 0 which usually mmc device on SD slot. With
DM_MMCit is detected as 0 since mmc0 node always be an mmc device.
Quoted 6 lines
If number of slots are more than 1, it assigns 1 which assumes 0 is mmc device and 1 is emmc device. But with
DM_MMCthere is chance of detecting emmc as device 2 since mmc1 is SDIO as per devicetree definition.So override mmc2 to mmc1 in sunxi dtsi, this will eventually detect mmc2 as mmc 1 device even if the board dts has mmc0, mmc1, mmc2.
It doesn't work on Pinebook - where we have mmc0 (SD card), mmc1 (SDIO), mmc2 (eMMC). It still enumerates mmc2 as mmc2.
Quoted 26 lines
Some platforms like A20 has mmc0...mmc3, but there is no usecases now for enabling all mmc controllers in any of A20 board dts files.
Signed-off-by Jagan Teki <[email protected]>--- arch/arm/dts/sunxi-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/dts/sunxi-u-boot.dtsi +4
-1@@ -1,6 +1,10 @@ #include <config.h> / { + aliases { + mmc1 = &mmc2; + }; + binman { filename = "u-boot-sunxi-with-spl.bin"; pad-byte = <0xff>; --2.18.0.321.gffc6fa0e3
PATCH v3 9/9 arm: dts: sunxi: Enumerate MMC2 as MMC1
Quoted 14 lines · Vasily Khoruzhick
Quoted 12 lines · Jagan Teki
Environment and fastboot MMC devices are configured based number of mmc slots defined on particular board in sunxi platform.
If number of slots are not more than 1, it assigns 0 which usually mmc device on SD slot. With
DM_MMCit is detected as 0 since mmc0 node always be an mmc device.If number of slots are more than 1, it assigns 1 which assumes 0 is mmc device and 1 is emmc device. But with
DM_MMCthere is chance of detecting emmc as device 2 since mmc1 is SDIO as per devicetree definition.
Quoted 5 lines
Quoted 2 lines
So override mmc2 to mmc1 in sunxi dtsi, this will eventually detect mmc2 as mmc 1 device even if the board dts has mmc0, mmc1, mmc2.
It doesn't work on Pinebook - where we have mmc0 (SD card), mmc1 (SDIO), mmc2 (eMMC). It still enumerates mmc2 as mmc2.
BPI-M64 has same, here is log
U-Boot 2019.01-00171-g1fa1610a2a-dirty (Jan 21 2019 - 21:12:21 +0530) Allwinner Technology
CPU: Allwinner A64 (SUN50I) Model: BananaPi-M64 DRAM: 2 GiB MMC: Device 'mmc at 1c11000': seq 1 is in use by 'mmc at 1c10000' mmc at 1c0f000: 0, mmc at 1c10000: 2, mmc at 1c11000: 1 Loading Environment from FAT... OK In: serial Out: serial Err: serial
Allwinner mUSB OTG (Peripheral)
Net: phy interface7
eth0: ethernet at 1c30000, eth1: usb_ether
starting USB...
USB0: USB EHCI 1.00 USB1: USB OHCI 1.0 USB2: USB EHCI 1.00 USB3: USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found scanning bus 1 for devices... 1 USB Device(s) found scanning bus 2 for devices... 2 USB Device(s) found scanning bus 3 for devices... 1 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 0
=>
=>
=> mmc list
mmc at 1c0f000: 0
mmc at 1c10000: 2
mmc at 1c11000: 1 (eMMC)
=> mmc dev 0
switch to partitions #0, OK
mmc0 is current device
=> mmc list
mmc at 1c0f000: 0 (SD)
mmc at 1c10000: 2
mmc at 1c11000: 1 (eMMC)
PATCH v3 9/9 arm: dts: sunxi: Enumerate MMC2 as MMC1
Quoted 17 lines · Jagan Teki
On Mon, Jan 21, 2019 at 9:08 PM Vasily Khoruzhick <[email protected]> wrote:
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 0
=>
=>
=> mmc list
mmc at 1c0f000: 0
mmc at 1c10000: 2
mmc at 1c11000: 1 (eMMC)
=> mmc dev 0
switch to partitions #0, OK
mmc0 is current device
=> mmc list
mmc at 1c0f000: 0 (SD)
mmc at 1c10000: 2
mmc at 1c11000: 1 (eMMC)
For me it shows:
=> mmc list
mmc at 1c0f000: 0 (SD)
mmc at 1c10000: 1
mmc at 1c11000: 2
I'm testing this patches applied onto u-boot-sunxi/master on Pinebook. I tried 'distclean', and it doesn't help.
PATCH v3 9/9 arm: dts: sunxi: Enumerate MMC2 as MMC1
Quoted 10 lines · Vasily Khoruzhick
For me it shows:
=> mmc list
mmc at 1c0f000: 0 (SD)
mmc at 1c10000: 1
mmc at 1c11000: 2I'm testing this patches applied onto u-boot-sunxi/master on Pinebook. I tried 'distclean', and it doesn't help.
Looks like eMMC is here but it doesn't get renumbered:
=> mmc dev 2
switch to partitions #0, OK
mmc2(part 0) is current device
=> mmc info
Device: mmc at 1c11000
Manufacturer ID: 15
OEM: 100
Name: AJTD4
Bus Speed: 52000000
Mode : MMC High Speed (52MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 14.6 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 14.6 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH
=> mmc list
mmc at 1c0f000: 0
mmc at 1c10000: 1
mmc at 1c11000: 2 (eMMC)
PATCH v3 9/9 arm: dts: sunxi: Enumerate MMC2 as MMC1
In reply to Vasily KhoruzhickQuoted 14 lines · Vasily Khoruzhick
Quoted 12 lines · Jagan Teki
Environment and fastboot MMC devices are configured based number of mmc slots defined on particular board in sunxi platform.
If number of slots are not more than 1, it assigns 0 which usually mmc device on SD slot. With
DM_MMCit is detected as 0 since mmc0 node always be an mmc device.If number of slots are more than 1, it assigns 1 which assumes 0 is mmc device and 1 is emmc device. But with
DM_MMCthere is chance of detecting emmc as device 2 since mmc1 is SDIO as per devicetree definition.
Quoted 5 lines
Quoted 2 lines
So override mmc2 to mmc1 in sunxi dtsi, this will eventually detect mmc2 as mmc 1 device even if the board dts has mmc0, mmc1, mmc2.
It doesn't work on Pinebook - where we have mmc0 (SD card), mmc1 (SDIO), mmc2 (eMMC). It still enumerates mmc2 as mmc2.
Try doing a clean build (i.e., do make distclean beforehand)?
It worked for me once I did that.
ChenYu
Quoted 26 lines
Quoted 26 lines
Some platforms like A20 has mmc0...mmc3, but there is no usecases now for enabling all mmc controllers in any of A20 board dts files.
Signed-off-by Jagan Teki <[email protected]>--- arch/arm/dts/sunxi-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/dts/sunxi-u-boot.dtsi +4
-1@@ -1,6 +1,10 @@ #include <config.h> / { + aliases { + mmc1 = &mmc2; + }; + binman { filename = "u-boot-sunxi-with-spl.bin"; pad-byte = <0xff>; --2.18.0.321.gffc6fa0e3
v3 cover mmc: sunxi: Enable DM_MMC
In reply to Jagan TekiQuoted 23 lines · Jagan Teki
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock support
Quoted 8 lines
Jagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: AddDM_MMCsupport for H6
mmc: sunxi: AddDM_MMCsupport for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: EnableDM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1
However, the A80 MMC clock patch is still missing code to toggle the upstream bus clock gate and reset control in the CCU.
Also I had to do a clean build after applying the patches. It might be the config did not get updated properly or there's some missing dependency in the build system.
ChenYu
v3 cover mmc: sunxi: Enable DM_MMC
Quoted 34 lines · Chen-Yu Tsai
Quoted 23 lines · Jagan Teki
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock supportQuoted 8 lines
Jagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: AddDM_MMCsupport for H6
mmc: sunxi: AddDM_MMCsupport for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: EnableDM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1
Quoted 4 lines
However, the A80 MMC clock patch is still missing code to toggle the upstream bus clock gate and reset control in the CCU.
Sent it with original mmc clock and reset patch[1], let me know your comments.
Quoted 4 lines
Also I had to do a clean build after applying the patches. It might be the config did not get updated properly or there's some missing dependency in the build system.
How did you reproduce this?
v3 cover mmc: sunxi: Enable DM_MMC
Quoted 36 lines · Jagan Teki
Quoted 34 lines · Chen-Yu Tsai
Quoted 31 lines · Jagan Teki
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock supportJagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: AddDM_MMCsupport for H6
mmc: sunxi: AddDM_MMCsupport for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: EnableDM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1
Quoted 6 lines
Quoted 4 lines
However, the A80 MMC clock patch is still missing code to toggle the upstream bus clock gate and reset control in the CCU.
Sent it with original mmc clock and reset patch[1], let me know your comments.
Right. The problem is nowhere in this series are those enabled / deasserted. The A80 CCU only has one gate & reset for the whole MMC subsystem, including the MMC config clocks block. Ideally the driver for that block should enable the gate and deassert the reset control.
That is what Andre and I are referring to.
Quoted 6 lines
Quoted 4 lines
Also I had to do a clean build after applying the patches. It might be the config did not get updated properly or there's some missing dependency in the build system.
How did you reproduce this?
Not sure. I suppose it might be that I had an existing build prior to applying the patches. Or it might be that I fat fingered something and didn't actually install the newly built image.
Either way I'll yell if I run into this again.
ChenYu
Quoted 1 line
v3 cover mmc: sunxi: Enable DM_MMC
Quoted 43 lines · Chen-Yu Tsai
Quoted 41 lines · Jagan Teki
Quoted 38 lines · Chen-Yu Tsai
Quoted 23 lines · Jagan Teki
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock supportQuoted 8 lines
Jagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: AddDM_MMCsupport for H6
mmc: sunxi: AddDM_MMCsupport for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: EnableDM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1However, the A80 MMC clock patch is still missing code to toggle the upstream bus clock gate and reset control in the CCU.
Quoted 7 lines
Quoted 1 line
Sent it with original mmc clock and reset patch[1], let me know your comments.
Right. The problem is nowhere in this series are those enabled / deasserted. The A80 CCU only has one gate & reset for the whole MMC subsystem, including the MMC config clocks block. Ideally the driver for that block should enable the gate and deassert the reset control.
Yes, that same has been included with v3.1 patch which I linked above.
Quoted 47 lines · Jagan Teki
Quoted 45 lines · Chen-Yu Tsai
Quoted 42 lines · Jagan Teki
Quoted 34 lines · Chen-Yu Tsai
Quoted 23 lines · Jagan Teki
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock supportQuoted 8 lines
Jagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: AddDM_MMCsupport for H6
mmc: sunxi: AddDM_MMCsupport for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: EnableDM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1Quoted 4 lines
However, the A80 MMC clock patch is still missing code to toggle the upstream bus clock gate and reset control in the CCU.
Sent it with original mmc clock and reset patch[1], let me know your comments.
Quoted 7 lines
Quoted 5 lines
Right. The problem is nowhere in this series are those enabled / deasserted. The A80 CCU only has one gate & reset for the whole MMC subsystem, including the MMC config clocks block. Ideally the driver for that block should enable the gate and deassert the reset control.
Yes, that same has been included with v3.1 patch which I linked above.
The gates/resets are added in that patch. No one is using them. The device tree node for the MMC controllers do _not_ reference this clock and reset, only the individual ones in the MMC config clock block.
Unless you are expecting BROM or SPL to have set that up for you, which IMO is quite fragile. You could very well boot from SPI or even FEL, and it wouldn't be correctly setup, in which case MMC would be completely broken.
FYI the clk-sun9i-mmc driver in Linux deasserts the reset at probe:
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L145
And enables the bus gate when it needs to toggle bits in its register space:
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L53
This is what is missing. Andre's patch doesn't have them. He specifically mentioned this.
Regards
ChenYu
On Fri, 25 Jan 2019 19:01:12 +0800
Chen-Yu Tsai <[email protected]> wrote:
Hi,
Quoted 77 lines
Quoted 53 lines · Jagan Teki
Quoted 50 lines · Chen-Yu Tsai
Quoted 46 lines · Jagan Teki
Quoted 35 lines · Chen-Yu Tsai
Quoted 23 lines · Jagan Teki
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock supportQuoted 8 lines
Jagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: AddDM_MMCsupport for H6
mmc: sunxi: AddDM_MMCsupport for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: EnableDM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1Quoted 5 lines
However, the A80 MMC clock patch is still missing code to toggle the upstream bus clock gate and reset control in the CCU.
Sent it with original mmc clock and reset patch[1], let me know your comments.
Quoted 8 lines
Quoted 5 lines
Right. The problem is nowhere in this series are those enabled / deasserted. The A80 CCU only has one gate & reset for the whole MMC subsystem, including the MMC config clocks block. Ideally the driver for that block should enable the gate and deassert the reset control.
Yes, that same has been included with v3.1 patch which I linked above.
The gates/resets are added in that patch. No one is using them. The device tree node for the MMC controllers do _not_ reference this clock and reset, only the individual ones in the MMC config clock block.
Unless you are expecting BROM or SPL to have set that up for you, which IMO is quite fragile. You could very well boot from SPI or even FEL, and it wouldn't be correctly setup, in which case MMC would be completely broken.
FYI the clk-sun9i-mmc driver in Linux deasserts the reset at probe:
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L145
Quoted 7 lines
And enables the bus gate when it needs to toggle bits in its register space:
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L53
This is what is missing. Andre's patch doesn't have them. He specifically mentioned this.
But this is addressed by this, isn't it?
https://lists.denx.de/pipermail/u-boot/2019-January/355856.html
(combined with Jagan's addition of the shared gates in v3.1)
Btw.: Somehow I managed to send it from the wrong branch (doesn't even compile), will send a fix later.
Jagan, we need this patch for A80, and also the pinmux setup patch (1/2 in this series) for it to work. That together with the H3 reset hiccup should be enough to justify a v4, I believe. Also I had some comments on your v3 (commit messages outdated, 7/9 too complicated), are you going to address them?
Meanwhile I prepared a branch to have everything we need:
https://github.com/apritzel/u-boot/commits/sunxi-dm-gates
Please ignore the top 4 commits for now (adding SPI flash support).
Cheers,
Andre.
Quoted 104 lines · Andre Przywara
On Fri, 25 Jan 2019 19:01:12 +0800
Chen-Yu Tsai <[email protected]> wrote:Hi,
Quoted 77 lines
Quoted 53 lines · Jagan Teki
Quoted 50 lines · Chen-Yu Tsai
Quoted 46 lines · Jagan Teki
Quoted 35 lines · Chen-Yu Tsai
Quoted 23 lines · Jagan Teki
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock supportQuoted 8 lines
Jagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: AddDM_MMCsupport for H6
mmc: sunxi: AddDM_MMCsupport for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: EnableDM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1Quoted 5 lines
However, the A80 MMC clock patch is still missing code to toggle the upstream bus clock gate and reset control in the CCU.
Sent it with original mmc clock and reset patch[1], let me know your comments.
Quoted 8 lines
Quoted 5 lines
Right. The problem is nowhere in this series are those enabled / deasserted. The A80 CCU only has one gate & reset for the whole MMC subsystem, including the MMC config clocks block. Ideally the driver for that block should enable the gate and deassert the reset control.
Yes, that same has been included with v3.1 patch which I linked above.
The gates/resets are added in that patch. No one is using them. The device tree node for the MMC controllers do _not_ reference this clock and reset, only the individual ones in the MMC config clock block.
Unless you are expecting BROM or SPL to have set that up for you, which IMO is quite fragile. You could very well boot from SPI or even FEL, and it wouldn't be correctly setup, in which case MMC would be completely broken.
FYI the clk-sun9i-mmc driver in Linux deasserts the reset at probe:
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L145
Quoted 7 lines
And enables the bus gate when it needs to toggle bits in its register space:
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L53
This is what is missing. Andre's patch doesn't have them. He specifically mentioned this.
But this is addressed by this, isn't it?
https://lists.denx.de/pipermail/u-boot/2019-January/355856.html
(combined with Jagan's addition of the shared gates in v3.1)Btw.: Somehow I managed to send it from the wrong branch (doesn't even compile), will send a fix later.
Jagan, we need this patch for A80, and also the pinmux setup patch (1/2 in this series) for it to work. That together with the H3 reset hiccup should be enough to justify a v4, I believe. Also I had some comments on your v3 (commit messages outdated, 7/9 too complicated), are you going to address them?
Quoted 3 lines
Meanwhile I prepared a branch to have everything we need:
https://github.com/apritzel/u-boot/commits/sunxi-dm-gates
Please ignore the top 4 commits for now (adding SPI flash support).
Add on top of this branch[2], will send all together in next version for final version probably.
[2] https://github.com/amarula/u-boot-amarula/tree/sun-dm-mmc
Quoted 86 lines · Andre Przywara
On Fri, 25 Jan 2019 19:01:12 +0800
Chen-Yu Tsai <[email protected]> wrote:Hi,
Quoted 80 lines
Quoted 53 lines · Jagan Teki
Quoted 50 lines · Chen-Yu Tsai
Quoted 46 lines · Jagan Teki
Quoted 35 lines · Chen-Yu Tsai
Quoted 23 lines · Jagan Teki
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock supportQuoted 8 lines
Jagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: AddDM_MMCsupport for H6
mmc: sunxi: AddDM_MMCsupport for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: EnableDM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1Quoted 5 lines
However, the A80 MMC clock patch is still missing code to toggle the upstream bus clock gate and reset control in the CCU.
Sent it with original mmc clock and reset patch[1], let me know your comments.
Quoted 8 lines
Quoted 5 lines
Right. The problem is nowhere in this series are those enabled / deasserted. The A80 CCU only has one gate & reset for the whole MMC subsystem, including the MMC config clocks block. Ideally the driver for that block should enable the gate and deassert the reset control.
Yes, that same has been included with v3.1 patch which I linked above.
The gates/resets are added in that patch. No one is using them. The device tree node for the MMC controllers do _not_ reference this clock and reset, only the individual ones in the MMC config clock block.
Unless you are expecting BROM or SPL to have set that up for you, which IMO is quite fragile. You could very well boot from SPI or even FEL, and it wouldn't be correctly setup, in which case MMC would be completely broken.
FYI the clk-sun9i-mmc driver in Linux deasserts the reset at probe:
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L145
And enables the bus gate when it needs to toggle bits in its register space:
Quoted 8 lines
Quoted 4 lines
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L53
This is what is missing. Andre's patch doesn't have them. He specifically mentioned this.
But this is addressed by this, isn't it?
https://lists.denx.de/pipermail/u-boot/2019-January/355856.html
(combined with Jagan's addition of the shared gates in v3.1)
Yes it does, however nowhere is it mentioned in the cover letter. That and I managed to purge it from my short term memory.
So with the two series combined it should work properly on the A80.
BTW, Jagan, vN.M patches are very hard to track...
ChenYu
Quoted 15 lines
Btw.: Somehow I managed to send it from the wrong branch (doesn't even compile), will send a fix later.
Jagan, we need this patch for A80, and also the pinmux setup patch (1/2 in this series) for it to work. That together with the H3 reset hiccup should be enough to justify a v4, I believe. Also I had some comments on your v3 (commit messages outdated, 7/9 too complicated), are you going to address them?
Meanwhile I prepared a branch to have everything we need:
https://github.com/apritzel/u-boot/commits/sunxi-dm-gates
Please ignore the top 4 commits for now (adding SPI flash support).Cheers,
Andre.
Quoted 93 lines · On Fri, 25 Jan 2019 19:42:22 +0800 Chen-Yu Tsai <[email protected]> wrote:
Quoted 91 lines · Andre Przywara
On Fri, 25 Jan 2019 19:01:12 +0800
Chen-Yu Tsai <[email protected]> wrote:Hi,
Quoted 85 lines
Quoted 54 lines · Jagan Teki
Quoted 51 lines · Chen-Yu Tsai
Quoted 47 lines · Jagan Teki
Quoted 35 lines · Chen-Yu Tsai
Quoted 23 lines · Jagan Teki
Compared to previous version changes[1] this version do manage ahb clocks/resets via CLK framework.
This version created changes along with Andre patches to support clock/resets[2]
Tested A64, SD, eMMC and respective changes available at u-boot-sunxi/next
Changes for v3:
- Handle clock via CLK framework.
Changes for v2:
- update the 'reset enablement' logic to do
required SoC's[1] https://patchwork.ozlabs.org/cover/1026828/
[2] https://patchwork.ozlabs.org/cover/1027850/Andre Przywara (2):
sunxi: clk: add MMC gates/resets
sunxi: clk: A80: add MMC clock supportQuoted 8 lines
Jagan Teki (7):
mmc: sunxi: Add A83T emmc compatible
mmc: sunxi: Add mmc, emmc H5/A64 compatible
mmc: sunxi: AddDM_MMCsupport for H6
mmc: sunxi: AddDM_MMCsupport for A80
dm: mmc: sunxi: Add CLK and RESET support
arm: sunxi: EnableDM_MMC
arm: dts: sunxi: Enumerate MMC2 as MMC1Quoted 6 lines
M2M
However, the A80 MMC clock patch is still missing code to toggle the upstream bus clock gate and reset control in the CCU.
Sent it with original mmc clock and reset patch[1], let me know your comments.
Quoted 8 lines
Quoted 5 lines
Right. The problem is nowhere in this series are those enabled / deasserted. The A80 CCU only has one gate & reset for the whole MMC subsystem, including the MMC config clocks block. Ideally the driver for that block should enable the gate and deassert the reset control.
Yes, that same has been included with v3.1 patch which I linked above.
The gates/resets are added in that patch. No one is using them. The device tree node for the MMC controllers do _not_ reference this clock and reset, only the individual ones in the MMC config clock block.
Unless you are expecting BROM or SPL to have set that up for you, which IMO is quite fragile. You could very well boot from SPI or even FEL, and it wouldn't be correctly setup, in which case MMC would be completely broken.
FYI the clk-sun9i-mmc driver in Linux deasserts the reset at probe:
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L145
And enables the bus gate when it needs to toggle bits in its register space:
https://elixir.bootlin.com/linux/latest/source/drivers/clk/sunxi/clk-sun9i-mmc.c#L53
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
This is what is missing. Andre's patch doesn't have them. He specifically mentioned this.
But this is addressed by this, isn't it?
https://lists.denx.de/pipermail/u-boot/2019-January/355856.html
(combined with Jagan's addition of the shared gates in v3.1)Yes it does, however nowhere is it mentioned in the cover letter.
True, I realised this myself while searching for it in the archive ;-)
Will fix that in v2.
Quoted 3 lines
That and I managed to purge it from my short term memory.
So with the two series combined it should work properly on the A80.
Cool. We need some serious testing of this, once we have settled on something ;-)
Fortunately we now have more than two months until the release.
Cheers,
Andre.
Quoted 19 lines
BTW, Jagan, vN.M patches are very hard to track...
ChenYu
Quoted 15 lines
Btw.: Somehow I managed to send it from the wrong branch (doesn't even compile), will send a fix later.
Jagan, we need this patch for A80, and also the pinmux setup patch (1/2 in this series) for it to work. That together with the H3 reset hiccup should be enough to justify a v4, I believe. Also I had some comments on your v3 (commit messages outdated, 7/9 too complicated), are you going to address them?
Meanwhile I prepared a branch to have everything we need:
https://github.com/apritzel/u-boot/commits/sunxi-dm-gates
Please ignore the top 4 commits for now (adding SPI flash support).Cheers,
Andre.