All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support
@ 2018-08-19 13:56 Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 01/58] clk: Add Allwinner A64 CLK driver Jagan Teki
                   ` (57 more replies)
  0 siblings, 58 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

This series is refined version of Allwinner CLK, RESET
support for previous RFC[3] which implements CLK and RESET for
- USB
- MMC
- SPI
- UART
- Ethernet

This series depends on 'musb shutdown' series [1] and
Linux dts(i) sync series [2].

Since this series supporting MMC, the previous version[4]
DM_MMC migration changes are squashed and droped reset and
clock ccm hacks.

Tested on A64, H3, H5, H6, R40, A83T, A20.

Changes for v3:
- Added H6 CLK, RESET changes
- Added fastboot mmc device patch
- Added fat env mmc device patch
- Update bootorder to check eMMC as per DT 
- Collect Tested-by
Changes for v2:
- Fixed few warnings and spaces in reset descriptor table.
- Add Ethernet CLK and RESET changes

All these changes available at u-boot-sunxi/clk

Note:
- V3S, A23, A33 still need to test.

Any inputs,
Jagan.

Jagan Teki (58):
  clk: Add Allwinner A64 CLK driver
  reset: Add default request ops
  reset: Add Allwinner RESET driver
  clk: sunxi: Add Allwinner H3/H5 CLK driver
  clk: sunxi: Add Allwinner A10/A20 CLK driver
  clk: sunxi: Add Allwinner A10s/A13 CLK driver
  clk: sunxi: Add Allwinner A31 CLK driver
  clk: sunxi: Add Allwinner A23 CLK driver
  clk: sunxi: a23: Add CLK support for A33
  clk: sunxi: Add Allwinner A83T CLK driver
  clk: sunxi: Add Allwinner R40 CLK driver
  clk: sunxi: Add Allwinner V3S CLK driver
  sunxi: Enable CLK
  musb-new: sunxi: Use CLK and RESET support
  phy: sun4i-usb: Use CLK and RESET support
  sunxi: usb: Switch to Generic host controllers
  usb: host: Drop [e-o]hci-sunxi drivers
  clk: sunxi: Implement AHB bus MMC clocks
  clk: sunxi: Implement direct MMC clocks
  clk: sunxi: Implement AHB bus MMC resets
  reset: Add get reset by name optionally
  reset: Add reset valid
  clk: sunxi: Add Allwinner H6 CLK, RESET driver
  arm64: allwinner: dts: h6: fix Pine H64 MMC bus width
  sunxi: h6: Enable CLK, RESET
  dm: mmc: sunxi: Add CLK and RESET support
  fastboot: sunxi: Update fastboot mmc default device
  env: fat: Add func to get fat device, partition
  sunxi: Get fat device wrt boot device, 'auto' partition
  env: sunxi: Don't update fat dev, part wrt MMC_SUNXI_SLOT_EXTRA
  sunxi: Add mmc 2, 3 bootenv devices
  sunxi: A20: Enable DM_MMC
  mmc: sunxi: Add mmc, emmc H5/A64 compatible
  sunxi: H3_H5: Enable DM_MMC
  sunxi: A64: Enable DM_MMC
  mmc: sunxi: Add A83T emmc compatible
  sunxi: A83T: Enable DM_MMC
  sunxi: V40: Enable DM_MMC
  sunxi: H6: Enable DM_MMC
  sunxi: A13/A31: Enable DM_MMC
  sunxi: A23/A33/V3S: Enable DM_MMC
  clk: sunxi: Implement SPI clocks
  clk: sunxi: Implement SPI resets
  spi: sun4i: Add CLK support
  spi: Add Allwinner A31 SPI driver
  clk: sunxi: Implement UART clocks
  clk: sunxi: Implement UART resets
  clk: sunxi: Implement Ethernet clocks
  clk: sunxi: Implement Ethernet resets
  net: sunxi_emac: Add CLK support
  net: sun8i_emac: Retrieve GMAC clock via 'syscon' phandle
  net: sun8i_emac: Add CLK and RESET support
  clk: Get the CLK by index without device
  clk: Use clk_get_by_index_tail()
  reset: Get the RESET by index without device
  clk: sunxi: h3: Implement EPHY CLK and RESET
  net: sun8i_emac: Add EPHY CLK and RESET support
  board: sunxi: gmac: Remove Ethernet clock and reset

 arch/arm/dts/sun50i-h6-pine-h64.dts           |   2 +
 arch/arm/include/asm/arch-sunxi/ccu.h         |  82 +++
 arch/arm/mach-sunxi/Kconfig                   |  24 +
 arch/arm/mach-sunxi/board.c                   |  50 ++
 board/sunxi/gmac.c                            |   8 -
 configs/A10-OLinuXino-Lime_defconfig          |   1 +
 configs/A10s-OLinuXino-M_defconfig            |   1 +
 configs/A13-OLinuXinoM_defconfig              |   1 +
 configs/A13-OLinuXino_defconfig               |   1 +
 configs/A20-OLinuXino-Lime2-eMMC_defconfig    |   2 +
 configs/A20-OLinuXino-Lime2_defconfig         |   1 +
 configs/A20-OLinuXino-Lime_defconfig          |   1 +
 configs/A20-Olimex-SOM204-EVB-eMMC_defconfig  |   1 +
 configs/A20-Olimex-SOM204-EVB_defconfig       |   2 +
 configs/Auxtek-T003_defconfig                 |   1 +
 configs/Auxtek-T004_defconfig                 |   1 +
 configs/Bananapi_defconfig                    |   1 +
 configs/Bananapi_m2m_defconfig                |   1 +
 configs/Bananapro_defconfig                   |   1 +
 configs/CHIP_defconfig                        |   1 +
 configs/CHIP_pro_defconfig                    |   1 +
 configs/CSQ_CS908_defconfig                   |   1 +
 configs/Colombus_defconfig                    |   1 +
 configs/Cubieboard2_defconfig                 |   1 +
 configs/Cubieboard_defconfig                  |   1 +
 configs/Cubietruck_plus_defconfig             |   1 +
 configs/Hummingbird_A31_defconfig             |   1 +
 configs/Itead_Ibox_A20_defconfig              |   1 +
 configs/Linksprite_pcDuino3_Nano_defconfig    |   1 +
 configs/Linksprite_pcDuino3_defconfig         |   1 +
 configs/Linksprite_pcDuino_defconfig          |   1 +
 configs/MK808C_defconfig                      |   1 +
 configs/Marsboard_A10_defconfig               |   1 +
 configs/Mele_A1000G_quad_defconfig            |   1 +
 configs/Mele_A1000_defconfig                  |   1 +
 configs/Mele_I7_defconfig                     |   1 +
 configs/Mele_M3_defconfig                     |   1 +
 configs/Mele_M5_defconfig                     |   1 +
 configs/Mele_M9_defconfig                     |   1 +
 configs/Mini-X_defconfig                      |   1 +
 configs/Orangepi_defconfig                    |   1 +
 configs/Orangepi_mini_defconfig               |   1 +
 configs/Sinlinx_SinA31s_defconfig             |   1 +
 configs/Sinlinx_SinA33_defconfig              |   2 +
 configs/Sinovoip_BPI_M2_Plus_defconfig        |   1 +
 configs/Sinovoip_BPI_M2_defconfig             |   1 +
 configs/Sinovoip_BPI_M3_defconfig             |   1 +
 configs/Wexler_TAB7200_defconfig              |   1 +
 configs/Wobo_i5_defconfig                     |   1 +
 configs/a64-olinuxino_defconfig               |   1 +
 configs/amarula_a64_relic_defconfig           |   1 +
 configs/ba10_tv_box_defconfig                 |   1 +
 configs/bananapi_m1_plus_defconfig            |   1 +
 configs/bananapi_m64_defconfig                |   1 +
 configs/ga10h_v1_1_defconfig                  |   1 +
 configs/h8_homlet_v2_defconfig                |   1 +
 configs/i12-tvbox_defconfig                   |   1 +
 configs/icnova-a20-swac_defconfig             |   1 +
 configs/inet1_defconfig                       |   1 +
 configs/inet_q972_defconfig                   |   1 +
 configs/jesurun_q5_defconfig                  |   1 +
 configs/libretech_all_h3_cc_h2_plus_defconfig |   1 +
 configs/libretech_all_h3_cc_h3_defconfig      |   1 +
 configs/libretech_all_h3_cc_h5_defconfig      |   1 +
 configs/mixtile_loftq_defconfig               |   1 +
 configs/mk802_a10s_defconfig                  |   1 +
 configs/mk802_defconfig                       |   1 +
 configs/mk802ii_defconfig                     |   1 +
 configs/nanopi_a64_defconfig                  |   1 +
 configs/nanopi_m1_defconfig                   |   1 +
 configs/nanopi_m1_plus_defconfig              |   1 +
 configs/nanopi_neo2_defconfig                 |   1 +
 configs/nanopi_neo_air_defconfig              |   1 +
 configs/nanopi_neo_defconfig                  |   1 +
 configs/nanopi_neo_plus2_defconfig            |   1 +
 configs/orangepi_2_defconfig                  |   1 +
 configs/orangepi_lite_defconfig               |   1 +
 configs/orangepi_one_defconfig                |   1 +
 configs/orangepi_pc2_defconfig                |   1 +
 configs/orangepi_pc_defconfig                 |   1 +
 configs/orangepi_pc_plus_defconfig            |   1 +
 configs/orangepi_plus2e_defconfig             |   1 +
 configs/orangepi_plus_defconfig               |   1 +
 configs/orangepi_prime_defconfig              |   1 +
 configs/orangepi_r1_defconfig                 |   1 +
 configs/orangepi_win_defconfig                |   1 +
 configs/orangepi_zero_defconfig               |   1 +
 configs/orangepi_zero_plus2_defconfig         |   1 +
 configs/orangepi_zero_plus_defconfig          |   1 +
 configs/parrot_r16_defconfig                  |   2 +
 configs/pine64_plus_defconfig                 |   1 +
 configs/r7-tv-dongle_defconfig                |   1 +
 configs/sopine_baseboard_defconfig            |   1 +
 configs/sun8i_a23_evb_defconfig               |   1 +
 configs/sunxi_Gemei_G9_defconfig              |   1 +
 configs/tbs_a711_defconfig                    |   1 +
 drivers/clk/Kconfig                           |   1 +
 drivers/clk/Makefile                          |   1 +
 drivers/clk/clk-uclass.c                      |  84 +++-
 drivers/clk/sunxi/Kconfig                     |  82 +++
 drivers/clk/sunxi/Makefile                    |  18 +
 drivers/clk/sunxi/clk_a10.c                   | 107 ++++
 drivers/clk/sunxi/clk_a10s.c                  |  96 ++++
 drivers/clk/sunxi/clk_a23.c                   | 105 ++++
 drivers/clk/sunxi/clk_a31.c                   | 128 +++++
 drivers/clk/sunxi/clk_a64.c                   | 115 +++++
 drivers/clk/sunxi/clk_a83t.c                  | 105 ++++
 drivers/clk/sunxi/clk_h3.c                    | 130 +++++
 drivers/clk/sunxi/clk_h6.c                    |  73 +++
 drivers/clk/sunxi/clk_r40.c                   | 123 +++++
 drivers/clk/sunxi/clk_sunxi.c                 |  77 +++
 drivers/clk/sunxi/clk_v3s.c                   |  91 ++++
 drivers/fastboot/Kconfig                      |   3 +-
 drivers/mmc/sunxi_mmc.c                       | 121 +++--
 drivers/net/sun8i_emac.c                      | 179 ++++---
 drivers/net/sunxi_emac.c                      |  28 +-
 drivers/phy/allwinner/phy-sun4i-usb.c         |  77 ++-
 drivers/reset/Kconfig                         |   8 +
 drivers/reset/Makefile                        |   1 +
 drivers/reset/reset-sunxi.c                   | 124 +++++
 drivers/reset/reset-uclass.c                  |  81 ++-
 drivers/spi/Kconfig                           |   6 +
 drivers/spi/Makefile                          |   1 +
 drivers/spi/sun4i_spi.c                       |  40 +-
 drivers/spi/sun6i_spi.c                       | 475 ++++++++++++++++++
 drivers/usb/host/Kconfig                      |   2 +
 drivers/usb/host/Makefile                     |   2 -
 drivers/usb/host/ehci-sunxi.c                 | 204 --------
 drivers/usb/host/ohci-sunxi.c                 | 233 ---------
 drivers/usb/musb-new/sunxi.c                  |  82 +--
 env/Kconfig                                   |   3 +-
 env/fat.c                                     |   9 +-
 include/clk.h                                 |  15 +
 include/configs/sun4i.h                       |   4 -
 include/configs/sun50i.h                      |   5 -
 include/configs/sun5i.h                       |   4 -
 include/configs/sun6i.h                       |   4 -
 include/configs/sun7i.h                       |   4 -
 include/configs/sun8i.h                       |   4 -
 include/configs/sunxi-common.h                |   9 +-
 include/fat.h                                 |   1 +
 include/reset.h                               |  52 ++
 scripts/config_whitelist.txt                  |   2 -
 143 files changed, 2695 insertions(+), 685 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-sunxi/ccu.h
 create mode 100644 drivers/clk/sunxi/Kconfig
 create mode 100644 drivers/clk/sunxi/Makefile
 create mode 100644 drivers/clk/sunxi/clk_a10.c
 create mode 100644 drivers/clk/sunxi/clk_a10s.c
 create mode 100644 drivers/clk/sunxi/clk_a23.c
 create mode 100644 drivers/clk/sunxi/clk_a31.c
 create mode 100644 drivers/clk/sunxi/clk_a64.c
 create mode 100644 drivers/clk/sunxi/clk_a83t.c
 create mode 100644 drivers/clk/sunxi/clk_h3.c
 create mode 100644 drivers/clk/sunxi/clk_h6.c
 create mode 100644 drivers/clk/sunxi/clk_r40.c
 create mode 100644 drivers/clk/sunxi/clk_sunxi.c
 create mode 100644 drivers/clk/sunxi/clk_v3s.c
 create mode 100644 drivers/reset/reset-sunxi.c
 create mode 100644 drivers/spi/sun6i_spi.c
 delete mode 100644 drivers/usb/host/ehci-sunxi.c
 delete mode 100644 drivers/usb/host/ohci-sunxi.c

-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 01/58] clk: Add Allwinner A64 CLK driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 02/58] reset: Add default request ops Jagan Teki
                   ` (56 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock driver for Allwinner A64.

Implement USB clock enable and disable functions for
OHCI, EHCI, OTG and USBPHY gate and clock registers.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/include/asm/arch-sunxi/ccu.h | 47 ++++++++++++++++++++
 drivers/clk/Kconfig                   |  1 +
 drivers/clk/Makefile                  |  1 +
 drivers/clk/sunxi/Kconfig             | 18 ++++++++
 drivers/clk/sunxi/Makefile            |  9 ++++
 drivers/clk/sunxi/clk_a64.c           | 62 +++++++++++++++++++++++++++
 drivers/clk/sunxi/clk_sunxi.c         | 58 +++++++++++++++++++++++++
 7 files changed, 196 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-sunxi/ccu.h
 create mode 100644 drivers/clk/sunxi/Kconfig
 create mode 100644 drivers/clk/sunxi/Makefile
 create mode 100644 drivers/clk/sunxi/clk_a64.c
 create mode 100644 drivers/clk/sunxi/clk_sunxi.c

diff --git a/arch/arm/include/asm/arch-sunxi/ccu.h b/arch/arm/include/asm/arch-sunxi/ccu.h
new file mode 100644
index 0000000000..f628c893de
--- /dev/null
+++ b/arch/arm/include/asm/arch-sunxi/ccu.h
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#ifndef _ASM_ARCH_CCU_H
+#define _ASM_ARCH_CCU_H
+
+/**
+ * ccu_clk_map - common clock unit clock map
+ *
+ * @off:		ccu clock offset
+ * @bit:		ccu clock bit value
+ * @ccu_clk_set_rate:	ccu clock set rate func
+ */
+struct ccu_clk_map {
+	u16 off;
+	u32 bit;
+	int (*ccu_clk_set_rate)(void *base, u32 bit, ulong rate);
+};
+
+/**
+ * struct ccu_desc - common clock unit descriptor
+ *
+ * @clks:		mapping clocks descriptor
+ * @num_clks:		number of mapped clocks
+ */
+struct ccu_desc {
+	struct ccu_clk_map *clks;
+	unsigned long num_clks;
+};
+
+/**
+ * struct sunxi_clk_priv - sunxi clock private structure
+ *
+ * @base:	base address
+ * @desc:	ccu descriptor
+ */
+struct sunxi_clk_priv {
+	void *base;
+	const struct ccu_desc *desc;
+};
+
+extern struct clk_ops sunxi_clk_ops;
+
+#endif /* _ASM_ARCH_CCU_H */
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index a99abed9e9..b4992e9ff1 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -88,6 +88,7 @@ source "drivers/clk/exynos/Kconfig"
 source "drivers/clk/mvebu/Kconfig"
 source "drivers/clk/owl/Kconfig"
 source "drivers/clk/renesas/Kconfig"
+source "drivers/clk/sunxi/Kconfig"
 source "drivers/clk/tegra/Kconfig"
 source "drivers/clk/uniphier/Kconfig"
 
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 146283c723..7cefcd99a0 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -11,6 +11,7 @@ obj-y += tegra/
 obj-$(CONFIG_ARCH_ASPEED) += aspeed/
 obj-$(CONFIG_ARCH_MESON) += clk_meson.o
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
+obj-$(CONFIG_ARCH_SUNXI) += sunxi/
 obj-$(CONFIG_CLK_AT91) += at91/
 obj-$(CONFIG_CLK_MVEBU) += mvebu/
 obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o
diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
new file mode 100644
index 0000000000..bf5ecb3801
--- /dev/null
+++ b/drivers/clk/sunxi/Kconfig
@@ -0,0 +1,18 @@
+config CLK_SUNXI
+	bool "Clock support for Allwinner SoCs"
+	depends on CLK && ARCH_SUNXI
+	default y
+	help
+	  This enables support for common clock driver API on Allwinner
+	  SoCs.
+
+if CLK_SUNXI
+
+config CLK_SUN50I_A64
+	bool "Clock driver for Allwinner A64"
+	default MACH_SUN50I
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner A64 SoC.
+
+endif # CLK_SUNXI
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
new file mode 100644
index 0000000000..fb20d28333
--- /dev/null
+++ b/drivers/clk/sunxi/Makefile
@@ -0,0 +1,9 @@
+#
+# Copyright (C) 2018 Amarula Solutions.
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o
+
+obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
new file mode 100644
index 0000000000..9393a01ccf
--- /dev/null
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun50i-a64-ccu.h>
+
+static struct ccu_clk_map a64_clks[] = {
+	[CLK_BUS_OTG]		= { 0x060, BIT(23), NULL },
+	[CLK_BUS_EHCI0]		= { 0x060, BIT(24), NULL },
+	[CLK_BUS_EHCI1]		= { 0x060, BIT(25), NULL },
+	[CLK_BUS_OHCI0]		= { 0x060, BIT(28), NULL },
+	[CLK_BUS_OHCI1]		= { 0x060, BIT(29), NULL },
+
+	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
+	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
+	[CLK_USB_HSIC]		= { 0x0cc, BIT(10), NULL },
+	[CLK_USB_HSIC_12M]	= { 0x0cc, BIT(11), NULL },
+	[CLK_USB_OHCI0]		= { 0x0cc, BIT(16), NULL },
+	[CLK_USB_OHCI1]		= { 0x0cc, BIT(17), NULL },
+};
+
+static const struct ccu_desc sun50i_a64_ccu_desc = {
+	.clks = a64_clks,
+	.num_clks = ARRAY_SIZE(a64_clks),
+};
+
+static int a64_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static const struct udevice_id a64_clk_ids[] = {
+	{ .compatible = "allwinner,sun50i-a64-ccu",
+	  .data = (ulong)&sun50i_a64_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun50i_a64) = {
+	.name		= "sun50i_a64_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= a64_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= a64_clk_probe,
+};
diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c
new file mode 100644
index 0000000000..791b1ac7f2
--- /dev/null
+++ b/drivers/clk/sunxi/clk_sunxi.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/io.h>
+#include <asm/arch/ccu.h>
+#include <linux/log2.h>
+
+static int sunxi_clk_enable(struct clk *clk)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(clk->dev);
+	struct ccu_clk_map *map = &priv->desc->clks[clk->id];
+	u32 reg;
+
+	if (!map->off || !map->bit) {
+		debug("%s (CLK#%ld) unhandled\n", __func__, clk->id);
+		return 0;
+	}
+
+	debug("%s(#%ld) off#0x%x, BIT(%d)\n", __func__,
+	      clk->id, map->off, ilog2(map->bit));
+
+	reg = readl(priv->base + map->off);
+	writel(reg | map->bit, priv->base + map->off);
+
+	return 0;
+}
+
+static int sunxi_clk_disable(struct clk *clk)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(clk->dev);
+	struct ccu_clk_map *map = &priv->desc->clks[clk->id];
+	u32 reg;
+
+	if (!map->off || !map->bit) {
+		debug("%s (CLK#%ld) unhandled\n", __func__, clk->id);
+		return 0;
+	}
+
+	debug("%s(#%ld) off#0x%x, BIT(%d)\n", __func__,
+	      clk->id, map->off, ilog2(map->bit));
+
+	reg = readl(priv->base + map->off);
+	writel(reg & ~map->bit, priv->base + map->off);
+
+	return 0;
+}
+
+struct clk_ops sunxi_clk_ops = {
+	.enable = sunxi_clk_enable,
+	.disable = sunxi_clk_disable,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 02/58] reset: Add default request ops
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 01/58] clk: Add Allwinner A64 CLK driver Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:22   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 03/58] reset: Add Allwinner RESET driver Jagan Teki
                   ` (55 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Missing request ops from respective uclass driver
generating "synchronous abort" in Allwinner platform,
may be in arm. So add default request ops and give a
chance to uclass driver to think whether they really
need request or not.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/reset/reset-uclass.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index 3899537635..99881b8b99 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -14,6 +14,11 @@ static inline struct reset_ops *reset_dev_ops(struct udevice *dev)
 	return (struct reset_ops *)dev->driver->ops;
 }
 
+static int reset_request_default(struct reset_ctl *reset_ctl)
+{
+	return 0;
+}
+
 static int reset_of_xlate_default(struct reset_ctl *reset_ctl,
 				  struct ofnode_phandle_args *args)
 {
@@ -69,7 +74,10 @@ int reset_get_by_index(struct udevice *dev, int index,
 		return ret;
 	}
 
-	ret = ops->request(reset_ctl);
+	if (ops->request)
+		ret = ops->request(reset_ctl);
+	else
+		ret = reset_request_default(reset_ctl);
 	if (ret) {
 		debug("ops->request() failed: %d\n", ret);
 		return ret;
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 03/58] reset: Add Allwinner RESET driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 01/58] clk: Add Allwinner A64 CLK driver Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 02/58] reset: Add default request ops Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 04/58] clk: sunxi: Add Allwinner H3/H5 CLK driver Jagan Teki
                   ` (54 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add common reset driver for all Allwinner SoC's.

Since CLK and RESET share common DT compatible, it is CLK driver
job is to bind the reset driver. So add CLK bind call on respective
SoC driver by passing ccu map descriptor so-that reset deassert,
deassert operations held based on reset register map defined by
CLK driver.

Select DM_RESET via CLK_SUNXI, this make hidden section of RESET
since CLK and RESET share common DT compatible and code.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/include/asm/arch-sunxi/ccu.h |  25 ++++++
 drivers/clk/sunxi/Kconfig             |   1 +
 drivers/clk/sunxi/clk_a64.c           |  22 +++++
 drivers/reset/Kconfig                 |   8 ++
 drivers/reset/Makefile                |   1 +
 drivers/reset/reset-sunxi.c           | 124 ++++++++++++++++++++++++++
 6 files changed, 181 insertions(+)
 create mode 100644 drivers/reset/reset-sunxi.c

diff --git a/arch/arm/include/asm/arch-sunxi/ccu.h b/arch/arm/include/asm/arch-sunxi/ccu.h
index f628c893de..bacd052ef3 100644
--- a/arch/arm/include/asm/arch-sunxi/ccu.h
+++ b/arch/arm/include/asm/arch-sunxi/ccu.h
@@ -20,15 +20,31 @@ struct ccu_clk_map {
 	int (*ccu_clk_set_rate)(void *base, u32 bit, ulong rate);
 };
 
+/**
+ * ccu_reset_map - common clock unit reset map
+ *
+ * @off:	ccu reset offset
+ * @bit:	ccu reset bit value
+ */
+struct ccu_reset_map {
+	u16 off;
+	u32 bit;
+};
+
 /**
  * struct ccu_desc - common clock unit descriptor
  *
  * @clks:		mapping clocks descriptor
  * @num_clks:		number of mapped clocks
+ * @resets:		mapping resets descriptor
+ * @num_resets:		number of mapped resets
  */
 struct ccu_desc {
 	struct ccu_clk_map *clks;
 	unsigned long num_clks;
+
+	struct ccu_reset_map *resets;
+	unsigned long num_resets;
 };
 
 /**
@@ -44,4 +60,13 @@ struct sunxi_clk_priv {
 
 extern struct clk_ops sunxi_clk_ops;
 
+/**
+ * sunxi_reset_bind() - reset binding
+ *
+ * @dev:	reset device
+ * @count:	reset count
+ * @return 0 success, or error value
+ */
+int sunxi_reset_bind(struct udevice *dev, ulong count);
+
 #endif /* _ASM_ARCH_CCU_H */
diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index bf5ecb3801..041d711e58 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -1,6 +1,7 @@
 config CLK_SUNXI
 	bool "Clock support for Allwinner SoCs"
 	depends on CLK && ARCH_SUNXI
+	select DM_RESET
 	default y
 	help
 	  This enables support for common clock driver API on Allwinner
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index 9393a01ccf..e5257b62c7 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -10,6 +10,7 @@
 #include <errno.h>
 #include <asm/arch/ccu.h>
 #include <dt-bindings/clock/sun50i-a64-ccu.h>
+#include <dt-bindings/reset/sun50i-a64-ccu.h>
 
 static struct ccu_clk_map a64_clks[] = {
 	[CLK_BUS_OTG]		= { 0x060, BIT(23), NULL },
@@ -26,9 +27,24 @@ static struct ccu_clk_map a64_clks[] = {
 	[CLK_USB_OHCI1]		= { 0x0cc, BIT(17), NULL },
 };
 
+static struct ccu_reset_map a64_resets[] = {
+	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
+	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
+	[RST_USB_HSIC]		= { 0x0cc, BIT(2) },
+
+	[RST_BUS_OTG]		= { 0x2c0, BIT(23) },
+	[RST_BUS_EHCI0]		= { 0x2c0, BIT(24) },
+	[RST_BUS_EHCI1]		= { 0x2c0, BIT(25) },
+	[RST_BUS_OHCI0]		= { 0x2c0, BIT(28) },
+	[RST_BUS_OHCI1]		= { 0x2c0, BIT(29) },
+};
+
 static const struct ccu_desc sun50i_a64_ccu_desc = {
 	.clks = a64_clks,
 	.num_clks = ARRAY_SIZE(a64_clks),
+
+	.resets = a64_resets,
+	.num_resets =  ARRAY_SIZE(a64_resets),
 };
 
 static int a64_clk_probe(struct udevice *dev)
@@ -46,6 +62,11 @@ static int a64_clk_probe(struct udevice *dev)
 	return 0;
 }
 
+static int a64_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 50);
+}
+
 static const struct udevice_id a64_clk_ids[] = {
 	{ .compatible = "allwinner,sun50i-a64-ccu",
 	  .data = (ulong)&sun50i_a64_ccu_desc },
@@ -59,4 +80,5 @@ U_BOOT_DRIVER(clk_sun50i_a64) = {
 	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
 	.ops		= &sunxi_clk_ops,
 	.probe		= a64_clk_probe,
+	.bind		= a64_clk_bind,
 };
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 33c39b7fb6..bdc06564a0 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -98,4 +98,12 @@ config RESET_SOCFPGA
 	help
 	  Support for reset controller on SoCFPGA platform.
 
+config RESET_SUNXI
+	bool "RESET support for Allwinner SoCs"
+	depends on DM_RESET && ARCH_SUNXI
+	default y
+	help
+	  This enables support for common reset driver for
+	  Allwinner SoCs.
+
 endmenu
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index ad08be4c8c..698d15a0e0 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_AST2500_RESET) += ast2500-reset.o
 obj-$(CONFIG_RESET_ROCKCHIP) += reset-rockchip.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
+obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c
new file mode 100644
index 0000000000..c0abe41bec
--- /dev/null
+++ b/drivers/reset/reset-sunxi.c
@@ -0,0 +1,124 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <reset-uclass.h>
+#include <asm/io.h>
+#include <dm/lists.h>
+#include <linux/log2.h>
+#include <asm/arch/ccu.h>
+
+struct sunxi_reset_priv {
+	void *base;
+	ulong count;
+	const struct ccu_desc *desc;
+};
+
+static int sunxi_reset_request(struct reset_ctl *reset_ctl)
+{
+	struct sunxi_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+
+	debug("%s (RST#%ld)\n", __func__, reset_ctl->id);
+
+	/* check dt-bindings/reset/sun8i-h3-ccu.h for max id */
+	if (reset_ctl->id >= priv->count)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int sunxi_reset_free(struct reset_ctl *reset_ctl)
+{
+	debug("%s (RST#%ld)\n", __func__, reset_ctl->id);
+
+	return 0;
+}
+
+static int sunxi_reset_assert(struct reset_ctl *reset_ctl)
+{
+	struct sunxi_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+	struct ccu_reset_map *map = &priv->desc->resets[reset_ctl->id];
+	u32 reg;
+
+	if (!map->off || !map->bit) {
+		debug("%s (RST#%ld) unhandled\n", __func__, reset_ctl->id);
+		return 0;
+	}
+
+	debug("%s(#%ld) off#0x%x, BIT(%d)\n", __func__,
+	      reset_ctl->id, map->off, ilog2(map->bit));
+
+	reg = readl(priv->base + map->off);
+	writel(reg & ~map->bit, priv->base + map->off);
+
+	return 0;
+}
+
+static int sunxi_reset_deassert(struct reset_ctl *reset_ctl)
+{
+	struct sunxi_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+	struct ccu_reset_map *map = &priv->desc->resets[reset_ctl->id];
+	u32 reg;
+
+	if (!map->off || !map->bit) {
+		debug("%s (RST#%ld) unhandled\n", __func__, reset_ctl->id);
+		return 0;
+	}
+
+	debug("%s(#%ld) off#0x%x, BIT(%d)\n", __func__,
+	      reset_ctl->id, map->off, ilog2(map->bit));
+
+	reg = readl(priv->base + map->off);
+	writel(reg | map->bit, priv->base + map->off);
+
+	return 0;
+}
+
+struct reset_ops sunxi_reset_ops = {
+	.request = sunxi_reset_request,
+	.free = sunxi_reset_free,
+	.rst_assert = sunxi_reset_assert,
+	.rst_deassert = sunxi_reset_deassert,
+};
+
+static int sunxi_reset_probe(struct udevice *dev)
+{
+	struct sunxi_reset_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+
+	return 0;
+}
+
+int sunxi_reset_bind(struct udevice *dev, ulong count)
+{
+	struct udevice *rst_dev;
+	struct sunxi_reset_priv *priv;
+	int ret;
+
+	ret = device_bind_driver_to_node(dev, "sunxi_reset", "reset",
+					 dev_ofnode(dev), &rst_dev);
+	if (ret) {
+		debug("Warning: failed to bind sunxi_reset driver: ret=%d\n", ret);
+		return ret;
+	}
+	priv = malloc(sizeof(struct sunxi_reset_priv));
+	priv->count = count;
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	rst_dev->priv = priv;
+
+	return 0;
+}
+
+U_BOOT_DRIVER(reset_sun8i_h3) = {
+	.name		= "sunxi_reset",
+	.id		= UCLASS_RESET,
+	.ops		= &sunxi_reset_ops,
+	.probe		= sunxi_reset_probe,
+	.priv_auto_alloc_size = sizeof(struct sunxi_reset_priv),
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 04/58] clk: sunxi: Add Allwinner H3/H5 CLK driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (2 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 03/58] reset: Add Allwinner RESET driver Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 05/58] clk: sunxi: Add Allwinner A10/A20 " Jagan Teki
                   ` (53 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock driver for Allwinner H3/H5.

- Implement USB bus and USB clocks via ccu_clk_map descriptor
  for H3/H5, so it can accessed in common clk enable and disable
  functions from clk_sunxi.c
- Implement USB bus and USB resets via ccu_reset_map descriptor
  for H3/H5, so it can accessed in common reset deassert and assert
  functions from reset-sunxi.c

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig  |  7 +++
 drivers/clk/sunxi/Makefile |  1 +
 drivers/clk/sunxi/clk_h3.c | 97 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_h3.c

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index 041d711e58..c3713bbac2 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -9,6 +9,13 @@ config CLK_SUNXI
 
 if CLK_SUNXI
 
+config CLK_SUN8I_H3
+	bool "Clock driver for Allwinner H3/H5"
+	default MACH_SUNXI_H3_H5
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner H3/H5 SoC.
+
 config CLK_SUN50I_A64
 	bool "Clock driver for Allwinner A64"
 	default MACH_SUN50I
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index fb20d28333..dec49f27a1 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -6,4 +6,5 @@
 
 obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o
 
+obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
new file mode 100644
index 0000000000..0b7f4947dd
--- /dev/null
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun8i-h3-ccu.h>
+#include <dt-bindings/reset/sun8i-h3-ccu.h>
+
+static struct ccu_clk_map h3_clks[] = {
+	[CLK_BUS_OTG]		= { 0x060, BIT(23), NULL },
+	[CLK_BUS_EHCI0]		= { 0x060, BIT(24), NULL },
+	[CLK_BUS_EHCI1]		= { 0x060, BIT(25), NULL },
+	[CLK_BUS_EHCI2]		= { 0x060, BIT(26), NULL },
+	[CLK_BUS_EHCI3]		= { 0x060, BIT(27), NULL },
+	[CLK_BUS_OHCI0]		= { 0x060, BIT(28), NULL },
+	[CLK_BUS_OHCI1]		= { 0x060, BIT(29), NULL },
+	[CLK_BUS_OHCI2]		= { 0x060, BIT(30), NULL },
+	[CLK_BUS_OHCI3]		= { 0x060, BIT(31), NULL },
+
+	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
+	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
+	[CLK_USB_PHY2]		= { 0x0cc, BIT(10), NULL },
+	[CLK_USB_PHY3]		= { 0x0cc, BIT(11), NULL },
+	[CLK_USB_OHCI0]		= { 0x0cc, BIT(16), NULL },
+	[CLK_USB_OHCI1]		= { 0x0cc, BIT(17), NULL },
+	[CLK_USB_OHCI2]		= { 0x0cc, BIT(18), NULL },
+	[CLK_USB_OHCI3]		= { 0x0cc, BIT(19), NULL },
+};
+
+static struct ccu_reset_map h3_resets[] = {
+	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
+	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
+	[RST_USB_PHY2]		= { 0x0cc, BIT(2) },
+	[RST_USB_PHY3]		= { 0x0cc, BIT(3) },
+
+	[RST_BUS_OTG]		= { 0x2c0, BIT(23) },
+	[RST_BUS_EHCI0]		= { 0x2c0, BIT(24) },
+	[RST_BUS_EHCI1]		= { 0x2c0, BIT(25) },
+	[RST_BUS_EHCI2]		= { 0x2c0, BIT(26) },
+	[RST_BUS_EHCI3]		= { 0x2c0, BIT(27) },
+	[RST_BUS_OHCI0]		= { 0x2c0, BIT(28) },
+	[RST_BUS_OHCI1]		= { 0x2c0, BIT(29) },
+	[RST_BUS_OHCI2]		= { 0x2c0, BIT(30) },
+	[RST_BUS_OHCI3]		= { 0x2c0, BIT(31) },
+};
+
+static const struct ccu_desc sun8i_h3_ccu_desc = {
+	.clks = h3_clks,
+	.num_clks = ARRAY_SIZE(h3_clks),
+
+	.resets = h3_resets,
+	.num_resets =  ARRAY_SIZE(h3_resets),
+};
+
+static int h3_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int h3_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 53);
+}
+
+static const struct udevice_id h3_clk_ids[] = {
+	{ .compatible = "allwinner,sun8i-h3-ccu",
+	  .data = (ulong)&sun8i_h3_ccu_desc },
+	{ .compatible = "allwinner,sun50i-h5-ccu",
+	  .data = (ulong)&sun8i_h3_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun8i_h3) = {
+	.name		= "sun8i_h3_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= h3_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= h3_clk_probe,
+	.bind		= h3_clk_bind,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 05/58] clk: sunxi: Add Allwinner A10/A20 CLK driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (3 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 04/58] clk: sunxi: Add Allwinner H3/H5 CLK driver Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 06/58] clk: sunxi: Add Allwinner A10s/A13 " Jagan Teki
                   ` (52 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock driver for Allwinner A10/A20.

- Implement USB ahb and USB clocks via ccu_clk_map descriptor
  for A10/A20, so it can accessed in common clk enable and disable
  functions from clk_sunxi.c
- Implement USB resets via ccu_reset_map descriptor for A10/A20,
  so it can accessed in common reset deassert and assert functions
  from reset-sunxi.c

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig   |  7 ++++
 drivers/clk/sunxi/Makefile  |  1 +
 drivers/clk/sunxi/clk_a10.c | 77 +++++++++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_a10.c

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index c3713bbac2..fbbf94ef55 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -9,6 +9,13 @@ config CLK_SUNXI
 
 if CLK_SUNXI
 
+config CLK_SUN4I_A10
+	bool "Clock driver for Allwinner A10/A20"
+	default MACH_SUN4I || MACH_SUN7I
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner A10/A20 SoC.
+
 config CLK_SUN8I_H3
 	bool "Clock driver for Allwinner H3/H5"
 	default MACH_SUNXI_H3_H5
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index dec49f27a1..bba830922f 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -6,5 +6,6 @@
 
 obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o
 
+obj-$(CONFIG_CLK_SUN4I_A10) += clk_a10.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
new file mode 100644
index 0000000000..7492e1367a
--- /dev/null
+++ b/drivers/clk/sunxi/clk_a10.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun4i-a10-ccu.h>
+#include <dt-bindings/reset/sun4i-a10-ccu.h>
+
+static struct ccu_clk_map a10_clks[] = {
+	[CLK_AHB_OTG]		= { 0x060, BIT(0), NULL },
+	[CLK_AHB_EHCI0]		= { 0x060, BIT(1), NULL },
+	[CLK_AHB_OHCI0]		= { 0x060, BIT(2), NULL },
+	[CLK_AHB_EHCI1]		= { 0x060, BIT(3), NULL },
+	[CLK_AHB_OHCI1]		= { 0x060, BIT(4), NULL },
+
+	[CLK_USB_OHCI0]		= { 0x0cc, BIT(6), NULL },
+	[CLK_USB_OHCI1]		= { 0x0cc, BIT(7), NULL },
+	[CLK_USB_PHY]		= { 0x0cc, BIT(8), NULL },
+};
+
+static struct ccu_reset_map a10_resets[] = {
+	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
+	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
+	[RST_USB_PHY2]		= { 0x0cc, BIT(2) },
+};
+
+static const struct ccu_desc sun4i_a10_ccu_desc = {
+	.clks = a10_clks,
+	.num_clks = ARRAY_SIZE(a10_clks),
+
+	.resets = a10_resets,
+	.num_resets =  ARRAY_SIZE(a10_resets),
+};
+
+static int a10_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int a10_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 22);
+}
+
+static const struct udevice_id a10_clk_ids[] = {
+	{ .compatible = "allwinner,sun4i-a10-ccu",
+          .data = (ulong)&sun4i_a10_ccu_desc },
+	{ .compatible = "allwinner,sun7i-a20-ccu",
+          .data = (ulong)&sun4i_a10_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun4i_a10) = {
+	.name		= "sun4i_a10_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= a10_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= a10_clk_probe,
+	.bind		= a10_clk_bind,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 06/58] clk: sunxi: Add Allwinner A10s/A13 CLK driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (4 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 05/58] clk: sunxi: Add Allwinner A10/A20 " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 07/58] clk: sunxi: Add Allwinner A31 " Jagan Teki
                   ` (51 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock driver for Allwinner A10s/A13.

- Implement USB ahb and USB clocks via ccu_clk_map descriptor
  for A10s/A13, so it can accessed in common clk enable and disable
  functions from clk_sunxi.c
- Implement USB resets via ccu_reset_map descriptor for A10s/A13,
  so it can accessed in common reset deassert and assert functions
  from reset-sunxi.c

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig    |  7 ++++
 drivers/clk/sunxi/Makefile   |  1 +
 drivers/clk/sunxi/clk_a10s.c | 74 ++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_a10s.c

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index fbbf94ef55..b228c2fa3a 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -16,6 +16,13 @@ config CLK_SUN4I_A10
 	  This enables common clock driver support for platforms based
 	  on Allwinner A10/A20 SoC.
 
+config CLK_SUN5I_A10S
+	bool "Clock driver for Allwinner A10s/A13"
+	default MACH_SUN5I
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner A10s/A13 SoC.
+
 config CLK_SUN8I_H3
 	bool "Clock driver for Allwinner H3/H5"
 	default MACH_SUNXI_H3_H5
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index bba830922f..466d4b79d6 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -7,5 +7,6 @@
 obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o
 
 obj-$(CONFIG_CLK_SUN4I_A10) += clk_a10.o
+obj-$(CONFIG_CLK_SUN5I_A10S) += clk_a10s.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
new file mode 100644
index 0000000000..976595201f
--- /dev/null
+++ b/drivers/clk/sunxi/clk_a10s.c
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun5i-ccu.h>
+#include <dt-bindings/reset/sun5i-ccu.h>
+
+static struct ccu_clk_map a10s_clks[] = {
+	[CLK_AHB_OTG]		= { 0x060, BIT(0), NULL },
+	[CLK_AHB_EHCI]		= { 0x060, BIT(1), NULL },
+	[CLK_AHB_OHCI]		= { 0x060, BIT(2), NULL },
+
+	[CLK_USB_OHCI]		= { 0x0cc, BIT(6), NULL },
+	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
+	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
+};
+
+static struct ccu_reset_map a10s_resets[] = {
+	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
+	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
+};
+
+static const struct ccu_desc sun5i_a10s_ccu_desc = {
+	.clks = a10s_clks,
+	.num_clks = ARRAY_SIZE(a10s_clks),
+
+	.resets = a10s_resets,
+	.num_resets =  ARRAY_SIZE(a10s_resets),
+};
+
+static int a10s_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int a10s_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 10);
+}
+
+static const struct udevice_id a10s_clk_ids[] = {
+	{ .compatible = "allwinner,sun5i-a10s-ccu",
+          .data = (ulong)&sun5i_a10s_ccu_desc },
+	{ .compatible = "allwinner,sun5i-a13-ccu",
+          .data = (ulong)&sun5i_a10s_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun5i_a10s) = {
+	.name		= "sun5i_a10s_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= a10s_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= a10s_clk_probe,
+	.bind		= a10s_clk_bind,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 07/58] clk: sunxi: Add Allwinner A31 CLK driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (5 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 06/58] clk: sunxi: Add Allwinner A10s/A13 " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 08/58] clk: sunxi: Add Allwinner A23 " Jagan Teki
                   ` (50 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock driver for Allwinner A31.

- Implement USB ahb1 and USB clocks via ccu_clk_map descriptor
  for A31, so it can accessed in common clk enable and disable
  functions from clk_sunxi.c
- Implement USB ahb1 and USB resets via ccu_reset_map descriptor
  for A31, so it can accessed in common reset deassert and assert
  functions from reset-sunxi.c

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig   |  7 +++
 drivers/clk/sunxi/Makefile  |  1 +
 drivers/clk/sunxi/clk_a31.c | 86 +++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_a31.c

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index b228c2fa3a..535b0dc02c 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -23,6 +23,13 @@ config CLK_SUN5I_A10S
 	  This enables common clock driver support for platforms based
 	  on Allwinner A10s/A13 SoC.
 
+config CLK_SUN6I_A31
+	bool "Clock driver for Allwinner A31/A31s"
+	default MACH_SUN6I
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner A31/A31s SoC.
+
 config CLK_SUN8I_H3
 	bool "Clock driver for Allwinner H3/H5"
 	default MACH_SUNXI_H3_H5
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index 466d4b79d6..3cf0071b0c 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -8,5 +8,6 @@ obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o
 
 obj-$(CONFIG_CLK_SUN4I_A10) += clk_a10.o
 obj-$(CONFIG_CLK_SUN5I_A10S) += clk_a10s.o
+obj-$(CONFIG_CLK_SUN6I_A31) += clk_a31.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
new file mode 100644
index 0000000000..c6d82be120
--- /dev/null
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions B.V.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun6i-a31-ccu.h>
+#include <dt-bindings/reset/sun6i-a31-ccu.h>
+
+static struct ccu_clk_map a31_clks[] = {
+	[CLK_AHB1_OTG]		= { 0x060, BIT(24), NULL },
+	[CLK_AHB1_EHCI0]	= { 0x060, BIT(26), NULL },
+	[CLK_AHB1_EHCI1]	= { 0x060, BIT(27), NULL },
+	[CLK_AHB1_OHCI0]	= { 0x060, BIT(29), NULL },
+	[CLK_AHB1_OHCI1]	= { 0x060, BIT(30), NULL },
+	[CLK_AHB1_OHCI2]	= { 0x060, BIT(31), NULL },
+
+	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
+	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
+	[CLK_USB_PHY2]		= { 0x0cc, BIT(10), NULL },
+	[CLK_USB_OHCI0]		= { 0x0cc, BIT(16), NULL },
+	[CLK_USB_OHCI1]		= { 0x0cc, BIT(17), NULL },
+	[CLK_USB_OHCI2]		= { 0x0cc, BIT(18), NULL },
+};
+
+static struct ccu_reset_map a31_resets[] = {
+	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
+	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
+	[RST_USB_PHY2]		= { 0x0cc, BIT(2) },
+
+	[RST_AHB1_OTG]		= { 0x2c0, BIT(24) },
+	[RST_AHB1_EHCI0]	= { 0x2c0, BIT(26) },
+	[RST_AHB1_EHCI1]	= { 0x2c0, BIT(27) },
+	[RST_AHB1_OHCI0]	= { 0x2c0, BIT(29) },
+	[RST_AHB1_OHCI1]	= { 0x2c0, BIT(30) },
+	[RST_AHB1_OHCI2]	= { 0x2c0, BIT(31) },
+};
+
+static const struct ccu_desc sun6i_a31_ccu_desc = {
+	.clks = a31_clks,
+	.num_clks = ARRAY_SIZE(a31_clks),
+
+	.resets = a31_resets,
+	.num_resets =  ARRAY_SIZE(a31_resets),
+};
+
+static int a31_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int a31_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 56);
+}
+
+static const struct udevice_id a31_clk_ids[] = {
+	{ .compatible = "allwinner,sun6i-a31-ccu",
+	  .data = (ulong)&sun6i_a31_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun6i_a31) = {
+	.name		= "sun6i_a31_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= a31_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= a31_clk_probe,
+	.bind		= a31_clk_bind,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 08/58] clk: sunxi: Add Allwinner A23 CLK driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (6 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 07/58] clk: sunxi: Add Allwinner A31 " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 09/58] clk: sunxi: a23: Add CLK support for A33 Jagan Teki
                   ` (49 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock driver for Allwinner A23.

- Implement USB bus and USB clocks via ccu_clk_map descriptor
  for A23, so it can accessed in common clk enable and disable
  functions from clk_sunxi.c
- Implement USB bus and USB resets via ccu_reset_map descriptor
  for A23, so it can accessed in common reset deassert and assert
  functions from reset-sunxi.c

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig   |  7 ++++
 drivers/clk/sunxi/Makefile  |  1 +
 drivers/clk/sunxi/clk_a23.c | 79 +++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_a23.c

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index 535b0dc02c..54600e8e1f 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -30,6 +30,13 @@ config CLK_SUN6I_A31
 	  This enables common clock driver support for platforms based
 	  on Allwinner A31/A31s SoC.
 
+config CLK_SUN8I_A23
+	bool "Clock driver for Allwinner A23"
+	default MACH_SUN8I_A23
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner A23 SoC.
+
 config CLK_SUN8I_H3
 	bool "Clock driver for Allwinner H3/H5"
 	default MACH_SUNXI_H3_H5
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index 3cf0071b0c..6924897036 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -9,5 +9,6 @@ obj-$(CONFIG_CLK_SUNXI) += clk_sunxi.o
 obj-$(CONFIG_CLK_SUN4I_A10) += clk_a10.o
 obj-$(CONFIG_CLK_SUN5I_A10S) += clk_a10s.o
 obj-$(CONFIG_CLK_SUN6I_A31) += clk_a31.o
+obj-$(CONFIG_CLK_SUN8I_A23) += clk_a23.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
new file mode 100644
index 0000000000..799c8ac0aa
--- /dev/null
+++ b/drivers/clk/sunxi/clk_a23.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions B.V.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun8i-a23-a33-ccu.h>
+#include <dt-bindings/reset/sun8i-a23-a33-ccu.h>
+
+static struct ccu_clk_map a23_clks[] = {
+	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
+	[CLK_BUS_EHCI]		= { 0x060, BIT(26), NULL },
+	[CLK_BUS_OHCI]		= { 0x060, BIT(29), NULL },
+
+	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
+	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
+	[CLK_USB_HSIC]		= { 0x0cc, BIT(10), NULL },
+	[CLK_USB_HSIC_12M]	= { 0x0cc, BIT(11), NULL },
+	[CLK_USB_OHCI]		= { 0x0cc, BIT(16), NULL },
+};
+
+static struct ccu_reset_map a23_resets[] = {
+	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
+	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
+	[RST_USB_HSIC]		= { 0x0cc, BIT(2) },
+
+	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
+	[RST_BUS_EHCI]		= { 0x2c0, BIT(26) },
+	[RST_BUS_OHCI]		= { 0x2c0, BIT(29) },
+};
+
+static const struct ccu_desc sun8i_a23_ccu_desc = {
+	.clks = a23_clks,
+	.num_clks = ARRAY_SIZE(a23_clks),
+
+	.resets = a23_resets,
+	.num_resets =  ARRAY_SIZE(a23_resets),
+};
+
+static int a23_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int a23_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 39);
+}
+
+static const struct udevice_id a23_clk_ids[] = {
+	{ .compatible = "allwinner,sun8i-a23-ccu",
+	  .data = (ulong)&sun8i_a23_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun8i_a23) = {
+	.name		= "sun8i_a23_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= a23_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= a23_clk_probe,
+	.bind		= a23_clk_bind,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 09/58] clk: sunxi: a23: Add CLK support for A33
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (7 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 08/58] clk: sunxi: Add Allwinner A23 " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 10/58] clk: sunxi: Add Allwinner A83T CLK driver Jagan Teki
                   ` (48 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

A33 has separate clock driver in Linux because of
few clock differences wrt to A23 like audio etc,.
these may not useful for U-Boot so added a33 ccu
compatible on existing a23 clock driver.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig   | 6 +++---
 drivers/clk/sunxi/clk_a23.c | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index 54600e8e1f..38ff99d345 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -31,11 +31,11 @@ config CLK_SUN6I_A31
 	  on Allwinner A31/A31s SoC.
 
 config CLK_SUN8I_A23
-	bool "Clock driver for Allwinner A23"
-	default MACH_SUN8I_A23
+	bool "Clock driver for Allwinner A23/A33"
+	default MACH_SUN8I_A23 || MACH_SUN8I_A33
 	help
 	  This enables common clock driver support for platforms based
-	  on Allwinner A23 SoC.
+	  on Allwinner A23/A33 SoC.
 
 config CLK_SUN8I_H3
 	bool "Clock driver for Allwinner H3/H5"
diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
index 799c8ac0aa..ec9834e1a8 100644
--- a/drivers/clk/sunxi/clk_a23.c
+++ b/drivers/clk/sunxi/clk_a23.c
@@ -65,6 +65,8 @@ static int a23_clk_bind(struct udevice *dev)
 static const struct udevice_id a23_clk_ids[] = {
 	{ .compatible = "allwinner,sun8i-a23-ccu",
 	  .data = (ulong)&sun8i_a23_ccu_desc },
+	{ .compatible = "allwinner,sun8i-a33-ccu",
+	  .data = (ulong)&sun8i_a23_ccu_desc },
 	{ }
 };
 
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 10/58] clk: sunxi: Add Allwinner A83T CLK driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (8 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 09/58] clk: sunxi: a23: Add CLK support for A33 Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 11/58] clk: sunxi: Add Allwinner R40 " Jagan Teki
                   ` (47 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock driver for Allwinner A83T.

- Implement USB bus and USB clocks via ccu_clk_map descriptor
  for A83T, so it can accessed in common clk enable and disable
  functions from clk_sunxi.c
- Implement USB bus and USB resets via ccu_reset_map descriptor
  for A83T, so it can accessed in common reset deassert and assert
  functions from reset-sunxi.c

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig    |  7 ++++
 drivers/clk/sunxi/Makefile   |  1 +
 drivers/clk/sunxi/clk_a83t.c | 81 ++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_a83t.c

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index 38ff99d345..90af70d171 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -37,6 +37,13 @@ config CLK_SUN8I_A23
 	  This enables common clock driver support for platforms based
 	  on Allwinner A23/A33 SoC.
 
+config CLK_SUN8I_A83T
+	bool "Clock driver for Allwinner A83T"
+	default MACH_SUN8I_A83T
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner A83T SoC.
+
 config CLK_SUN8I_H3
 	bool "Clock driver for Allwinner H3/H5"
 	default MACH_SUNXI_H3_H5
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index 6924897036..4a254c8671 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -10,5 +10,6 @@ obj-$(CONFIG_CLK_SUN4I_A10) += clk_a10.o
 obj-$(CONFIG_CLK_SUN5I_A10S) += clk_a10s.o
 obj-$(CONFIG_CLK_SUN6I_A31) += clk_a31.o
 obj-$(CONFIG_CLK_SUN8I_A23) += clk_a23.o
+obj-$(CONFIG_CLK_SUN8I_A83T) += clk_a83t.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c
new file mode 100644
index 0000000000..58d28eb6ad
--- /dev/null
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun8i-a83t-ccu.h>
+#include <dt-bindings/reset/sun8i-a83t-ccu.h>
+
+static struct ccu_clk_map a83t_clks[] = {
+	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
+	[CLK_BUS_EHCI0]		= { 0x060, BIT(26), NULL },
+	[CLK_BUS_EHCI1]		= { 0x060, BIT(27), NULL },
+	[CLK_BUS_OHCI0]		= { 0x060, BIT(29), NULL },
+
+	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
+	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
+	[CLK_USB_HSIC]		= { 0x0cc, BIT(10), NULL },
+	[CLK_USB_HSIC_12M]	= { 0x0cc, BIT(11), NULL },
+	[CLK_USB_OHCI0]		= { 0x0cc, BIT(16), NULL },
+};
+
+static struct ccu_reset_map a83t_resets[] = {
+	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
+	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
+	[RST_USB_HSIC]		= { 0x0cc, BIT(2) },
+
+	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
+	[RST_BUS_EHCI0]		= { 0x2c0, BIT(26) },
+	[RST_BUS_EHCI1]		= { 0x2c0, BIT(27) },
+	[RST_BUS_OHCI0]		= { 0x2c0, BIT(29) },
+};
+
+static const struct ccu_desc sun8i_a83t_ccu_desc = {
+	.clks = a83t_clks,
+	.num_clks = ARRAY_SIZE(a83t_clks),
+
+	.resets = a83t_resets,
+	.num_resets =  ARRAY_SIZE(a83t_resets),
+};
+
+static int a83t_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int a83t_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 44);
+}
+
+static const struct udevice_id a83t_clk_ids[] = {
+	{ .compatible = "allwinner,sun8i-a83t-ccu",
+	  .data = (ulong)&sun8i_a83t_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun8i_a83t) = {
+	.name		= "sun8i_a83t_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= a83t_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= a83t_clk_probe,
+	.bind		= a83t_clk_bind,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 11/58] clk: sunxi: Add Allwinner R40 CLK driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (9 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 10/58] clk: sunxi: Add Allwinner A83T CLK driver Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 12/58] clk: sunxi: Add Allwinner V3S " Jagan Teki
                   ` (46 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock driver for Allwinner R40.

- Implement USB bus and USB clocks via ccu_clk_map descriptor
  for R40, so it can accessed in common clk enable and disable
  functions from clk_sunxi.c
- Implement USB bus and USB resets via ccu_reset_map descriptor
  for R40, so it can accessed in common reset deassert and assert
  functions from reset-sunxi.c

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig   |  7 +++
 drivers/clk/sunxi/Makefile  |  1 +
 drivers/clk/sunxi/clk_r40.c | 89 +++++++++++++++++++++++++++++++++++++
 3 files changed, 97 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_r40.c

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index 90af70d171..c45a4ba378 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -44,6 +44,13 @@ config CLK_SUN8I_A83T
 	  This enables common clock driver support for platforms based
 	  on Allwinner A83T SoC.
 
+config CLK_SUN8I_R40
+	bool "Clock driver for Allwinner R40"
+	default MACH_SUN8I_R40
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner R40 SoC.
+
 config CLK_SUN8I_H3
 	bool "Clock driver for Allwinner H3/H5"
 	default MACH_SUNXI_H3_H5
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index 4a254c8671..61f8b87396 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -11,5 +11,6 @@ obj-$(CONFIG_CLK_SUN5I_A10S) += clk_a10s.o
 obj-$(CONFIG_CLK_SUN6I_A31) += clk_a31.o
 obj-$(CONFIG_CLK_SUN8I_A23) += clk_a23.o
 obj-$(CONFIG_CLK_SUN8I_A83T) += clk_a83t.o
+obj-$(CONFIG_CLK_SUN8I_R40) += clk_r40.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
new file mode 100644
index 0000000000..746d6734b2
--- /dev/null
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun8i-r40-ccu.h>
+#include <dt-bindings/reset/sun8i-r40-ccu.h>
+
+static struct ccu_clk_map r40_clks[] = {
+	[CLK_BUS_OTG]		= { 0x060, BIT(25), NULL },
+	[CLK_BUS_EHCI0]		= { 0x060, BIT(26), NULL },
+	[CLK_BUS_EHCI1]		= { 0x060, BIT(27), NULL },
+	[CLK_BUS_EHCI2]		= { 0x060, BIT(28), NULL },
+	[CLK_BUS_OHCI0]		= { 0x060, BIT(29), NULL },
+	[CLK_BUS_OHCI1]		= { 0x060, BIT(30), NULL },
+	[CLK_BUS_OHCI2]		= { 0x060, BIT(31), NULL },
+
+
+	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
+	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
+	[CLK_USB_PHY2]		= { 0x0cc, BIT(10), NULL },
+	[CLK_USB_OHCI0]		= { 0x0cc, BIT(16), NULL },
+	[CLK_USB_OHCI1]		= { 0x0cc, BIT(17), NULL },
+	[CLK_USB_OHCI2]		= { 0x0cc, BIT(18), NULL },
+};
+
+static struct ccu_reset_map r40_resets[] = {
+	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
+	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
+	[RST_USB_PHY2]		= { 0x0cc, BIT(2) },
+
+	[RST_BUS_OTG]		= { 0x2c0, BIT(25) },
+	[RST_BUS_EHCI0]		= { 0x2c0, BIT(26) },
+	[RST_BUS_EHCI1]		= { 0x2c0, BIT(27) },
+	[RST_BUS_EHCI2]		= { 0x2c0, BIT(28) },
+	[RST_BUS_OHCI0]		= { 0x2c0, BIT(29) },
+	[RST_BUS_OHCI1]		= { 0x2c0, BIT(30) },
+	[RST_BUS_OHCI2]		= { 0x2c0, BIT(31) },
+};
+
+static const struct ccu_desc sun8i_r40_ccu_desc = {
+	.clks = r40_clks,
+	.num_clks = ARRAY_SIZE(r40_clks),
+
+	.resets = r40_resets,
+	.num_resets =  ARRAY_SIZE(r40_resets),
+};
+
+static int r40_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int r40_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 80);
+}
+
+static const struct udevice_id r40_clk_ids[] = {
+	{ .compatible = "allwinner,sun8i-r40-ccu",
+	  .data = (ulong)&sun8i_r40_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun8i_r40) = {
+	.name		= "sun8i_r40_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= r40_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= r40_clk_probe,
+	.bind		= r40_clk_bind,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 12/58] clk: sunxi: Add Allwinner V3S CLK driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (10 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 11/58] clk: sunxi: Add Allwinner R40 " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 13/58] sunxi: Enable CLK Jagan Teki
                   ` (45 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock driver for Allwinner V3S.

- Implement USB bus and USB clocks via ccu_clk_map descriptor
  for V3S, so it can accessed in common clk enable and disable
  functions from clk_sunxi.c
- Implement USB bus and USB resets via ccu_reset_map descriptor
  for V3S, so it can accessed in common reset deassert and assert
  functions from reset-sunxi.c

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig   |  7 ++++
 drivers/clk/sunxi/Makefile  |  1 +
 drivers/clk/sunxi/clk_v3s.c | 69 +++++++++++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_v3s.c

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index c45a4ba378..a6f84e9e56 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -51,6 +51,13 @@ config CLK_SUN8I_R40
 	  This enables common clock driver support for platforms based
 	  on Allwinner R40 SoC.
 
+config CLK_SUN8I_V3S
+	bool "Clock driver for Allwinner V3S"
+	default MACH_SUN8I_V3S
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner V3S SoC.
+
 config CLK_SUN8I_H3
 	bool "Clock driver for Allwinner H3/H5"
 	default MACH_SUNXI_H3_H5
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index 61f8b87396..fbd43527a6 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -12,5 +12,6 @@ obj-$(CONFIG_CLK_SUN6I_A31) += clk_a31.o
 obj-$(CONFIG_CLK_SUN8I_A23) += clk_a23.o
 obj-$(CONFIG_CLK_SUN8I_A83T) += clk_a83t.o
 obj-$(CONFIG_CLK_SUN8I_R40) += clk_r40.o
+obj-$(CONFIG_CLK_SUN8I_V3S) += clk_v3s.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c
new file mode 100644
index 0000000000..2494518798
--- /dev/null
+++ b/drivers/clk/sunxi/clk_v3s.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun8i-v3s-ccu.h>
+#include <dt-bindings/reset/sun8i-v3s-ccu.h>
+
+static struct ccu_clk_map v3s_clks[] = {
+	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
+
+	[CLK_USB_PHY0]          = { 0x0cc, BIT(8), NULL },
+};
+
+static struct ccu_reset_map v3s_resets[] = {
+	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
+
+	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
+};
+
+static const struct ccu_desc sun8i_v3s_ccu_desc = {
+	.clks = v3s_clks,
+	.num_clks = ARRAY_SIZE(v3s_clks),
+
+	.resets = v3s_resets,
+	.num_resets =  ARRAY_SIZE(v3s_resets),
+};
+
+static int v3s_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int v3s_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 53);
+}
+
+static const struct udevice_id v3s_clk_ids[] = {
+	{ .compatible = "allwinner,sun8i-v3s-ccu",
+	  .data = (ulong)&sun8i_v3s_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun8i_v3s) = {
+	.name		= "sun8i_v3s_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= v3s_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= v3s_clk_probe,
+	.bind		= v3s_clk_bind,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 13/58] sunxi: Enable CLK
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (11 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 12/58] clk: sunxi: Add Allwinner V3S " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 14/58] musb-new: sunxi: Use CLK and RESET support Jagan Teki
                   ` (44 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

CLK and DM_RESET drivers are now available for most
of the Allwinner platforms, so enable in mach-sunxi/Kconfig

Enabling CLK will select DM_RESET by default.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 558363b52d..dce81b7d53 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -132,6 +132,7 @@ endif
 
 config MACH_SUNXI_H3_H5
 	bool
+	select CLK
 	select DM_I2C
 	select PHY_SUN4I_USB
 	select SUNXI_DE2
@@ -147,6 +148,7 @@ choice
 config MACH_SUN4I
 	bool "sun4i (Allwinner A10)"
 	select CPU_V7A
+	select CLK
 	select ARM_CORTEX_CPU_IS_UP
 	select DM_MMC if MMC
 	select DM_SCSI if SCSI
@@ -158,6 +160,7 @@ config MACH_SUN4I
 config MACH_SUN5I
 	bool "sun5i (Allwinner A13)"
 	select CPU_V7A
+	select CLK
 	select ARM_CORTEX_CPU_IS_UP
 	select DRAM_SUN4I
 	select PHY_SUN4I_USB
@@ -171,6 +174,7 @@ config MACH_SUN6I
 	select CPU_V7_HAS_NONSEC
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
+	select CLK
 	select DRAM_SUN6I
 	select PHY_SUN4I_USB
 	select SUN6I_P2WI
@@ -185,6 +189,7 @@ config MACH_SUN7I
 	select CPU_V7_HAS_NONSEC
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
+	select CLK
 	select DRAM_SUN4I
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN4I
@@ -197,6 +202,7 @@ config MACH_SUN8I_A23
 	select CPU_V7_HAS_NONSEC
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
+	select CLK
 	select DRAM_SUN8I_A23
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN6I
@@ -210,6 +216,7 @@ config MACH_SUN8I_A33
 	select CPU_V7_HAS_NONSEC
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
+	select CLK
 	select DRAM_SUN8I_A33
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN6I
@@ -220,6 +227,7 @@ config MACH_SUN8I_A33
 config MACH_SUN8I_A83T
 	bool "sun8i (Allwinner A83T)"
 	select CPU_V7A
+	select CLK
 	select DRAM_SUN8I_A83T
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN6I
@@ -231,6 +239,7 @@ config MACH_SUN8I_H3
 	select CPU_V7A
 	select CPU_V7_HAS_NONSEC
 	select CPU_V7_HAS_VIRT
+	select CLK
 	select ARCH_SUPPORT_PSCI
 	select MACH_SUNXI_H3_H5
 	select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
@@ -241,6 +250,7 @@ config MACH_SUN8I_R40
 	select CPU_V7_HAS_NONSEC
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
+	select CLK
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
 	select SUNXI_DRAM_DW
@@ -252,6 +262,7 @@ config MACH_SUN8I_V3S
 	select CPU_V7_HAS_NONSEC
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
+	select CLK
 	select SUNXI_GEN_SUN6I
 	select SUNXI_DRAM_DW
 	select SUNXI_DRAM_DW_16BIT
@@ -270,6 +281,7 @@ config MACH_SUN9I
 config MACH_SUN50I
 	bool "sun50i (Allwinner A64)"
 	select ARM64
+	select CLK
 	select DM_I2C
 	select PHY_SUN4I_USB
 	select SUNXI_DE2
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 14/58] musb-new: sunxi: Use CLK and RESET support
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (12 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 13/58] sunxi: Enable CLK Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:26   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 15/58] phy: sun4i-usb: " Jagan Teki
                   ` (43 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Now clock and reset drivers are available for respective
SoC's so use clk and reset ops on musb driver.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/usb/musb-new/sunxi.c | 82 +++++++++++++++++++++++-------------
 1 file changed, 53 insertions(+), 29 deletions(-)

diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
index 9f71b84fd1..440be83f4e 100644
--- a/drivers/usb/musb-new/sunxi.c
+++ b/drivers/usb/musb-new/sunxi.c
@@ -16,9 +16,11 @@
  * This file is part of the Inventra Controller Driver for Linux.
  */
 #include <common.h>
+#include <clk.h>
 #include <dm.h>
 #include <generic-phy.h>
 #include <phy-sun4i-usb.h>
+#include <reset.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/gpio.h>
@@ -78,16 +80,15 @@
 
 struct sunxi_musb_config {
 	struct musb_hdrc_config *config;
-	u8 rst_bit;
-	u8 clkgate_bit;
 };
 
 struct sunxi_glue {
 	struct musb_host_data mdata;
-	struct sunxi_ccm_reg *ccm;
 	struct sunxi_musb_config *cfg;
 	struct device dev;
 	struct phy phy;
+	struct clk clocks;
+	struct reset_ctl resets;
 };
 #define to_sunxi_glue(d)	container_of(d, struct sunxi_glue, dev)
 
@@ -291,6 +292,18 @@ static int sunxi_musb_init(struct musb *musb)
 
 	pr_debug("%s():\n", __func__);
 
+	ret = clk_enable(&glue->clocks);
+	if (ret) {
+		dev_err(dev, "failed to enable clock\n");
+		return ret;
+	}
+
+	ret = reset_deassert(&glue->resets);
+	if (ret) {
+		dev_err(dev, "failed to deassert reset\n");
+		return ret;
+	}
+
 	ret = generic_phy_init(&glue->phy);
 	if (ret) {
 		pr_err("failed to init USB PHY\n");
@@ -299,17 +312,6 @@ static int sunxi_musb_init(struct musb *musb)
 
 	musb->isr = sunxi_musb_interrupt;
 
-	setbits_le32(&glue->ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_USB0));
-	if (glue->cfg->clkgate_bit)
-		setbits_le32(&glue->ccm->ahb_gate0,
-			     BIT(glue->cfg->clkgate_bit));
-#ifdef CONFIG_SUNXI_GEN_SUN6I
-	setbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0));
-	if (glue->cfg->rst_bit)
-		setbits_le32(&glue->ccm->ahb_reset0_cfg,
-			     BIT(glue->cfg->rst_bit));
-#endif
-
 	USBC_ConfigFIFO_Base();
 	USBC_EnableDpDmPullUp(musb->mregs);
 	USBC_EnableIdPullUp(musb->mregs);
@@ -339,16 +341,17 @@ static int sunxi_musb_exit(struct musb *musb)
 		}
 	}
 
-#ifdef CONFIG_SUNXI_GEN_SUN6I
-	clrbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0));
-	if (glue->cfg->rst_bit)
-		clrbits_le32(&glue->ccm->ahb_reset0_cfg,
-			     BIT(glue->cfg->rst_bit));
-#endif
-	clrbits_le32(&glue->ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_USB0));
-	if (glue->cfg->clkgate_bit)
-		clrbits_le32(&glue->ccm->ahb_gate0,
-			     BIT(glue->cfg->clkgate_bit));
+	ret = reset_assert(&glue->resets);
+	if (ret) {
+		dev_err(dev, "failed to deassert reset\n");
+		return ret;
+	}
+
+	ret = clk_disable(&glue->clocks);
+	if (ret) {
+		dev_err(dev, "failed to enable clock\n");
+		return ret;
+	}
 
 	return 0;
 }
@@ -433,6 +436,7 @@ static int musb_usb_probe(struct udevice *dev)
 	struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
 	struct musb_hdrc_platform_data pdata;
 	void *base = dev_read_addr_ptr(dev);
+	int clock_nb, reset_nb;
 	int ret;
 
 	if (!base)
@@ -442,9 +446,31 @@ static int musb_usb_probe(struct udevice *dev)
 	if (!glue->cfg)
 		return -EINVAL;
 
-	glue->ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
-	if (IS_ERR(glue->ccm))
-		return PTR_ERR(glue->ccm);
+	clock_nb = ofnode_count_phandle_with_args(dev_ofnode(dev), "clocks",
+						  "#clock-cells");
+	if (clock_nb < 0) {
+		dev_err(dev, "failed to get clock phandle(%d)\n", clock_nb);
+		return clock_nb;
+	}
+
+	ret = clk_get_by_index(dev, 0, &glue->clocks);
+	if (ret) {
+		dev_err(dev, "failed to get clock 0\n");
+		clk_free(&glue->clocks);
+	}
+
+	reset_nb = ofnode_count_phandle_with_args(dev_ofnode(dev), "resets",
+						  "#reset-cells");
+	if (reset_nb < 0) {
+		dev_err(dev, "failed to get reset phandle(%d)\n", clock_nb);
+		return reset_nb;
+	}
+
+	ret = reset_get_by_index(dev, 0, &glue->resets);
+	if (ret) {
+		dev_err(dev, "failed to get reset 0\n");
+		reset_free(&glue->resets);
+	}
 
 	ret = generic_phy_get_by_name(dev, "usb", &glue->phy);
 	if (ret) {
@@ -499,8 +525,6 @@ static const struct sunxi_musb_config sun4i_a10_cfg = {
 
 static const struct sunxi_musb_config sun8i_h3_cfg = {
 	.config = &musb_config_h3,
-	.rst_bit = 23,
-	.clkgate_bit = 23,
 };
 
 static const struct udevice_id sunxi_musb_ids[] = {
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 15/58] phy: sun4i-usb: Use CLK and RESET support
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (13 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 14/58] musb-new: sunxi: Use CLK and RESET support Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 16/58] sunxi: usb: Switch to Generic host controllers Jagan Teki
                   ` (42 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Now clock and reset drivers are available for respective
SoC's so use clk and reset ops on phy driver.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/phy/allwinner/phy-sun4i-usb.c | 77 ++++++++++++++++++++-------
 1 file changed, 57 insertions(+), 20 deletions(-)

diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index a7d7e3f044..f206fa3f5d 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -11,10 +11,12 @@
  */
 
 #include <common.h>
+#include <clk.h>
 #include <dm.h>
 #include <dm/device.h>
 #include <generic-phy.h>
 #include <phy-sun4i-usb.h>
+#include <reset.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
@@ -80,6 +82,7 @@ struct sun4i_usb_phy_cfg {
 	enum sun4i_usb_phy_type type;
 	u32 disc_thresh;
 	u8 phyctl_offset;
+	bool dedicated_clocks;
 	bool enable_pmu_unk1;
 	bool phy0_dual_route;
 };
@@ -88,30 +91,21 @@ struct sun4i_usb_phy_info {
 	const char *gpio_vbus;
 	const char *gpio_vbus_det;
 	const char *gpio_id_det;
-	int rst_mask;
 } phy_info[] = {
 	{
 		.gpio_vbus = CONFIG_USB0_VBUS_PIN,
 		.gpio_vbus_det = CONFIG_USB0_VBUS_DET,
 		.gpio_id_det = CONFIG_USB0_ID_DET,
-		.rst_mask = (CCM_USB_CTRL_PHY0_RST | CCM_USB_CTRL_PHY0_CLK),
 	},
 	{
 		.gpio_vbus = CONFIG_USB1_VBUS_PIN,
 		.gpio_vbus_det = NULL,
 		.gpio_id_det = NULL,
-		.rst_mask = (CCM_USB_CTRL_PHY1_RST | CCM_USB_CTRL_PHY1_CLK),
 	},
 	{
 		.gpio_vbus = CONFIG_USB2_VBUS_PIN,
 		.gpio_vbus_det = NULL,
 		.gpio_id_det = NULL,
-#ifdef CONFIG_MACH_SUN8I_A83T
-		.rst_mask = (CCM_USB_CTRL_HSIC_RST | CCM_USB_CTRL_HSIC_CLK |
-			     CCM_USB_CTRL_12M_CLK),
-#else
-		.rst_mask = (CCM_USB_CTRL_PHY2_RST | CCM_USB_CTRL_PHY2_CLK),
-#endif
 	},
 	{
 		.gpio_vbus = CONFIG_USB3_VBUS_PIN,
@@ -126,13 +120,13 @@ struct sun4i_usb_phy_plat {
 	int gpio_vbus;
 	int gpio_vbus_det;
 	int gpio_id_det;
-	int rst_mask;
+	struct clk clocks;
+	struct reset_ctl resets;
 	int id;
 };
 
 struct sun4i_usb_phy_data {
 	void __iomem *base;
-	struct sunxi_ccm_reg *ccm;
 	const struct sun4i_usb_phy_cfg *cfg;
 	struct sun4i_usb_phy_plat *usb_phy;
 };
@@ -266,8 +260,19 @@ static int sun4i_usb_phy_init(struct phy *phy)
 	struct sun4i_usb_phy_data *data = dev_get_priv(phy->dev);
 	struct sun4i_usb_phy_plat *usb_phy = &data->usb_phy[phy->id];
 	u32 val;
+	int ret;
 
-	setbits_le32(&data->ccm->usb_clk_cfg, usb_phy->rst_mask);
+	ret = clk_enable(&usb_phy->clocks);
+	if (ret) {
+		dev_err(dev, "failed to enable usb_%ldphy clock\n", phy->id);
+		return ret;
+	}
+
+	ret = reset_deassert(&usb_phy->resets);
+	if (ret) {
+		dev_err(dev, "failed to deassert usb_%ldreset reset\n", phy->id);
+		return ret;
+	}
 
 	if (data->cfg->type == sun8i_a83t_phy) {
 		if (phy->id == 0) {
@@ -308,6 +313,7 @@ static int sun4i_usb_phy_exit(struct phy *phy)
 {
 	struct sun4i_usb_phy_data *data = dev_get_priv(phy->dev);
 	struct sun4i_usb_phy_plat *usb_phy = &data->usb_phy[phy->id];
+	int ret;
 
 	if (phy->id == 0) {
 		if (data->cfg->type == sun8i_a83t_phy) {
@@ -320,7 +326,17 @@ static int sun4i_usb_phy_exit(struct phy *phy)
 
 	sun4i_usb_phy_passby(phy, false);
 
-	clrbits_le32(&data->ccm->usb_clk_cfg, usb_phy->rst_mask);
+	ret = clk_disable(&usb_phy->clocks);
+	if (ret) {
+		dev_err(dev, "failed to disable usb_%ldphy clock\n", phy->id);
+		return ret;
+	}
+
+	ret = reset_assert(&usb_phy->resets);
+	if (ret) {
+		dev_err(dev, "failed to assert usb_%ldreset reset\n", phy->id);
+		return ret;
+	}
 
 	return 0;
 }
@@ -407,10 +423,6 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
 	if (IS_ERR(data->base))
 		return PTR_ERR(data->base);
 
-	data->ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
-	if (IS_ERR(data->ccm))
-		return PTR_ERR(data->ccm);
-
 	data->usb_phy = plat;
 	for (i = 0; i < data->cfg->num_phys; i++) {
 		struct sun4i_usb_phy_plat *phy = &plat[i];
@@ -448,6 +460,24 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
 			sunxi_gpio_set_pull(phy->gpio_id_det, SUNXI_GPIO_PULL_UP);
 		}
 
+		if (data->cfg->dedicated_clocks)
+			snprintf(name, sizeof(name), "usb%d_phy", i);
+		else
+			strlcpy(name, "usb_phy", sizeof(name));
+
+		ret = clk_get_by_name(dev, name, &phy->clocks);
+		if (ret) {
+			dev_err(dev, "failed to get usb%d_phy clock phandle\n", i);
+			return ret;
+		}
+
+		snprintf(name, sizeof(name), "usb%d_reset", i);
+		ret = reset_get_by_name(dev, name, &phy->resets);
+		if (ret) {
+			dev_err(dev, "failed to get usb%d_reset reset phandle\n", i);
+			return ret;
+		}
+
 		if (i || data->cfg->phy0_dual_route) {
 			snprintf(name, sizeof(name), "pmu%d", i);
 			phy->pmu = (void __iomem *)devfdt_get_addr_name(dev, name);
@@ -456,9 +486,6 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
 		}
 
 		phy->id = i;
-		phy->rst_mask = info->rst_mask;
-		if ((data->cfg->type == sun8i_h3_phy) && (phy->id == 3))
-			phy->rst_mask = (BIT(3) | BIT(11));
 	};
 
 	debug("Allwinner Sun4I USB PHY driver loaded\n");
@@ -470,6 +497,7 @@ static const struct sun4i_usb_phy_cfg sun4i_a10_cfg = {
 	.type = sun4i_a10_phy,
 	.disc_thresh = 3,
 	.phyctl_offset = REG_PHYCTL_A10,
+	.dedicated_clocks = false,
 	.enable_pmu_unk1 = false,
 };
 
@@ -478,6 +506,7 @@ static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = {
 	.type = sun4i_a10_phy,
 	.disc_thresh = 2,
 	.phyctl_offset = REG_PHYCTL_A10,
+	.dedicated_clocks = false,
 	.enable_pmu_unk1 = false,
 };
 
@@ -486,6 +515,7 @@ static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = {
 	.type = sun6i_a31_phy,
 	.disc_thresh = 3,
 	.phyctl_offset = REG_PHYCTL_A10,
+	.dedicated_clocks = true,
 	.enable_pmu_unk1 = false,
 };
 
@@ -494,6 +524,7 @@ static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = {
 	.type = sun4i_a10_phy,
 	.disc_thresh = 2,
 	.phyctl_offset = REG_PHYCTL_A10,
+	.dedicated_clocks = false,
 	.enable_pmu_unk1 = false,
 };
 
@@ -502,6 +533,7 @@ static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = {
 	.type = sun4i_a10_phy,
 	.disc_thresh = 3,
 	.phyctl_offset = REG_PHYCTL_A10,
+	.dedicated_clocks = true,
 	.enable_pmu_unk1 = false,
 };
 
@@ -510,6 +542,7 @@ static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = {
 	.type = sun8i_a33_phy,
 	.disc_thresh = 3,
 	.phyctl_offset = REG_PHYCTL_A33,
+	.dedicated_clocks = true,
 	.enable_pmu_unk1 = false,
 };
 
@@ -517,6 +550,7 @@ static const struct sun4i_usb_phy_cfg sun8i_a83t_cfg = {
 	.num_phys = 3,
 	.type = sun8i_a83t_phy,
 	.phyctl_offset = REG_PHYCTL_A33,
+	.dedicated_clocks = true,
 };
 
 static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = {
@@ -524,6 +558,7 @@ static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = {
 	.type = sun8i_h3_phy,
 	.disc_thresh = 3,
 	.phyctl_offset = REG_PHYCTL_A33,
+	.dedicated_clocks = true,
 	.enable_pmu_unk1 = true,
 	.phy0_dual_route = true,
 };
@@ -533,6 +568,7 @@ static const struct sun4i_usb_phy_cfg sun8i_v3s_cfg = {
 	.type = sun8i_v3s_phy,
 	.disc_thresh = 3,
 	.phyctl_offset = REG_PHYCTL_A33,
+	.dedicated_clocks = true,
 	.enable_pmu_unk1 = true,
 	.phy0_dual_route = true,
 };
@@ -542,6 +578,7 @@ static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = {
 	.type = sun50i_a64_phy,
 	.disc_thresh = 3,
 	.phyctl_offset = REG_PHYCTL_A33,
+	.dedicated_clocks = true,
 	.enable_pmu_unk1 = true,
 	.phy0_dual_route = true,
 };
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 16/58] sunxi: usb: Switch to Generic host controllers
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (14 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 15/58] phy: sun4i-usb: " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 17/58] usb: host: Drop [e-o]hci-sunxi drivers Jagan Teki
                   ` (41 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Once of key blocker for using USB Generic host controller
drivers in Allwinner are CLK and RESET drivers, now these
available for USB usage. So switch to use EHCI and OHCI
Generic controllers.

Enabling USB is wisely a board choise, so Enable USB_OHCI_HCD
where it already have USB_EHCI_HCD

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 configs/A10-OLinuXino-Lime_defconfig          | 1 +
 configs/A10s-OLinuXino-M_defconfig            | 1 +
 configs/A13-OLinuXinoM_defconfig              | 1 +
 configs/A13-OLinuXino_defconfig               | 1 +
 configs/A20-OLinuXino-Lime2-eMMC_defconfig    | 1 +
 configs/A20-OLinuXino-Lime2_defconfig         | 1 +
 configs/A20-OLinuXino-Lime_defconfig          | 1 +
 configs/A20-Olimex-SOM204-EVB_defconfig       | 2 ++
 configs/Auxtek-T003_defconfig                 | 1 +
 configs/Auxtek-T004_defconfig                 | 1 +
 configs/Bananapi_defconfig                    | 1 +
 configs/Bananapi_m2m_defconfig                | 1 +
 configs/Bananapro_defconfig                   | 1 +
 configs/CHIP_defconfig                        | 1 +
 configs/CHIP_pro_defconfig                    | 1 +
 configs/CSQ_CS908_defconfig                   | 1 +
 configs/Colombus_defconfig                    | 1 +
 configs/Cubieboard2_defconfig                 | 1 +
 configs/Cubieboard_defconfig                  | 1 +
 configs/Cubietruck_plus_defconfig             | 1 +
 configs/Hummingbird_A31_defconfig             | 1 +
 configs/Itead_Ibox_A20_defconfig              | 1 +
 configs/Linksprite_pcDuino3_Nano_defconfig    | 1 +
 configs/Linksprite_pcDuino3_defconfig         | 1 +
 configs/Linksprite_pcDuino_defconfig          | 1 +
 configs/MK808C_defconfig                      | 1 +
 configs/Marsboard_A10_defconfig               | 1 +
 configs/Mele_A1000G_quad_defconfig            | 1 +
 configs/Mele_A1000_defconfig                  | 1 +
 configs/Mele_I7_defconfig                     | 1 +
 configs/Mele_M3_defconfig                     | 1 +
 configs/Mele_M5_defconfig                     | 1 +
 configs/Mele_M9_defconfig                     | 1 +
 configs/Mini-X_defconfig                      | 1 +
 configs/Orangepi_defconfig                    | 1 +
 configs/Orangepi_mini_defconfig               | 1 +
 configs/Sinlinx_SinA31s_defconfig             | 1 +
 configs/Sinlinx_SinA33_defconfig              | 1 +
 configs/Sinovoip_BPI_M2_Plus_defconfig        | 1 +
 configs/Sinovoip_BPI_M2_defconfig             | 1 +
 configs/Sinovoip_BPI_M3_defconfig             | 1 +
 configs/Wexler_TAB7200_defconfig              | 1 +
 configs/Wobo_i5_defconfig                     | 1 +
 configs/a64-olinuxino_defconfig               | 1 +
 configs/ba10_tv_box_defconfig                 | 1 +
 configs/bananapi_m1_plus_defconfig            | 1 +
 configs/bananapi_m64_defconfig                | 1 +
 configs/ga10h_v1_1_defconfig                  | 1 +
 configs/h8_homlet_v2_defconfig                | 1 +
 configs/i12-tvbox_defconfig                   | 1 +
 configs/icnova-a20-swac_defconfig             | 1 +
 configs/inet1_defconfig                       | 1 +
 configs/inet_q972_defconfig                   | 1 +
 configs/jesurun_q5_defconfig                  | 1 +
 configs/libretech_all_h3_cc_h2_plus_defconfig | 1 +
 configs/libretech_all_h3_cc_h3_defconfig      | 1 +
 configs/libretech_all_h3_cc_h5_defconfig      | 1 +
 configs/mixtile_loftq_defconfig               | 1 +
 configs/mk802_a10s_defconfig                  | 1 +
 configs/mk802_defconfig                       | 1 +
 configs/mk802ii_defconfig                     | 1 +
 configs/nanopi_a64_defconfig                  | 1 +
 configs/nanopi_m1_defconfig                   | 1 +
 configs/nanopi_m1_plus_defconfig              | 1 +
 configs/nanopi_neo2_defconfig                 | 1 +
 configs/nanopi_neo_air_defconfig              | 1 +
 configs/nanopi_neo_defconfig                  | 1 +
 configs/nanopi_neo_plus2_defconfig            | 1 +
 configs/orangepi_2_defconfig                  | 1 +
 configs/orangepi_lite_defconfig               | 1 +
 configs/orangepi_one_defconfig                | 1 +
 configs/orangepi_pc2_defconfig                | 1 +
 configs/orangepi_pc_defconfig                 | 1 +
 configs/orangepi_pc_plus_defconfig            | 1 +
 configs/orangepi_plus2e_defconfig             | 1 +
 configs/orangepi_plus_defconfig               | 1 +
 configs/orangepi_prime_defconfig              | 1 +
 configs/orangepi_r1_defconfig                 | 1 +
 configs/orangepi_win_defconfig                | 1 +
 configs/orangepi_zero_defconfig               | 1 +
 configs/orangepi_zero_plus2_defconfig         | 1 +
 configs/orangepi_zero_plus_defconfig          | 1 +
 configs/parrot_r16_defconfig                  | 1 +
 configs/pine64_plus_defconfig                 | 1 +
 configs/r7-tv-dongle_defconfig                | 1 +
 configs/sopine_baseboard_defconfig            | 1 +
 configs/sun8i_a23_evb_defconfig               | 1 +
 configs/sunxi_Gemei_G9_defconfig              | 1 +
 configs/tbs_a711_defconfig                    | 1 +
 drivers/usb/host/Kconfig                      | 2 ++
 include/configs/sun4i.h                       | 4 ----
 include/configs/sun50i.h                      | 5 -----
 include/configs/sun5i.h                       | 4 ----
 include/configs/sun6i.h                       | 4 ----
 include/configs/sun7i.h                       | 4 ----
 include/configs/sun8i.h                       | 4 ----
 include/configs/sunxi-common.h                | 1 -
 97 files changed, 92 insertions(+), 26 deletions(-)

diff --git a/configs/A10-OLinuXino-Lime_defconfig b/configs/A10-OLinuXino-Lime_defconfig
index feb1173c0b..e8fecbe15f 100644
--- a/configs/A10-OLinuXino-Lime_defconfig
+++ b/configs/A10-OLinuXino-Lime_defconfig
@@ -20,5 +20,6 @@ CONFIG_SUN4I_EMAC=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/A10s-OLinuXino-M_defconfig b/configs/A10s-OLinuXino-M_defconfig
index 9498a6d752..bee913cb0b 100644
--- a/configs/A10s-OLinuXino-M_defconfig
+++ b/configs/A10s-OLinuXino-M_defconfig
@@ -16,5 +16,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SUN4I_EMAC=y
 CONFIG_AXP152_POWER=y
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/A13-OLinuXinoM_defconfig b/configs/A13-OLinuXinoM_defconfig
index ed507cdf0b..dd5c25ca9f 100644
--- a/configs/A13-OLinuXinoM_defconfig
+++ b/configs/A13-OLinuXinoM_defconfig
@@ -18,5 +18,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun5i-a13-olinuxino-micro"
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUNXI_NO_PMIC=y
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/A13-OLinuXino_defconfig b/configs/A13-OLinuXino_defconfig
index b8ec1e54db..04682dcac4 100644
--- a/configs/A13-OLinuXino_defconfig
+++ b/configs/A13-OLinuXino_defconfig
@@ -25,6 +25,7 @@ CONFIG_DFU_RAM=y
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_AXP_ALDO3_VOLT=3300
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
index 5657fc2594..2851a461e8 100644
--- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig
+++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
@@ -27,6 +27,7 @@ CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig
index 134d1d3fef..99987a8683 100644
--- a/configs/A20-OLinuXino-Lime2_defconfig
+++ b/configs/A20-OLinuXino-Lime2_defconfig
@@ -26,6 +26,7 @@ CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/A20-OLinuXino-Lime_defconfig b/configs/A20-OLinuXino-Lime_defconfig
index b7c13a6932..1b59174120 100644
--- a/configs/A20-OLinuXino-Lime_defconfig
+++ b/configs/A20-OLinuXino-Lime_defconfig
@@ -19,5 +19,6 @@ CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/A20-Olimex-SOM204-EVB_defconfig b/configs/A20-Olimex-SOM204-EVB_defconfig
index cfb7ffa556..0537378ba1 100644
--- a/configs/A20-Olimex-SOM204-EVB_defconfig
+++ b/configs/A20-Olimex-SOM204-EVB_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_ARCH_SUNXI=y
 CONFIG_SPL=y
 CONFIG_MACH_SUN7I=y
@@ -27,6 +28,7 @@ CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Auxtek-T003_defconfig b/configs/Auxtek-T003_defconfig
index ce4806cf5e..a2bf5037ed 100644
--- a/configs/Auxtek-T003_defconfig
+++ b/configs/Auxtek-T003_defconfig
@@ -14,5 +14,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_AXP152_POWER=y
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Auxtek-T004_defconfig b/configs/Auxtek-T004_defconfig
index 5faf45c3d7..4c1117e4bb 100644
--- a/configs/Auxtek-T004_defconfig
+++ b/configs/Auxtek-T004_defconfig
@@ -12,5 +12,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_AXP152_POWER=y
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Bananapi_defconfig b/configs/Bananapi_defconfig
index 7a9b5fe0e5..53752b2e12 100644
--- a/configs/Bananapi_defconfig
+++ b/configs/Bananapi_defconfig
@@ -19,5 +19,6 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Bananapi_m2m_defconfig b/configs/Bananapi_m2m_defconfig
index 2316437c94..a21796fa67 100644
--- a/configs/Bananapi_m2m_defconfig
+++ b/configs/Bananapi_m2m_defconfig
@@ -14,6 +14,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-r16-bananapi-m2m"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_USB_FUNCTION_MASS_STORAGE=y
diff --git a/configs/Bananapro_defconfig b/configs/Bananapro_defconfig
index 5a8ded0493..ad4ce1f662 100644
--- a/configs/Bananapro_defconfig
+++ b/configs/Bananapro_defconfig
@@ -22,5 +22,6 @@ CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO4_VOLT=2500
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/CHIP_defconfig b/configs/CHIP_defconfig
index c122944881..2dfa5237bc 100644
--- a/configs/CHIP_defconfig
+++ b/configs/CHIP_defconfig
@@ -16,6 +16,7 @@ CONFIG_DFU_RAM=y
 CONFIG_AXP_ALDO3_VOLT=3300
 CONFIG_AXP_ALDO4_VOLT=3300
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/CHIP_pro_defconfig b/configs/CHIP_pro_defconfig
index 5d63fadef5..1333877957 100644
--- a/configs/CHIP_pro_defconfig
+++ b/configs/CHIP_pro_defconfig
@@ -20,6 +20,7 @@ CONFIG_SYS_NAND_OOBSIZE=0x100
 CONFIG_AXP_ALDO3_VOLT=3300
 CONFIG_AXP_ALDO4_VOLT=3300
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/CSQ_CS908_defconfig b/configs/CSQ_CS908_defconfig
index b103e7e00d..7612cc8989 100644
--- a/configs/CSQ_CS908_defconfig
+++ b/configs/CSQ_CS908_defconfig
@@ -14,6 +14,7 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_AXP_DLDO1_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Colombus_defconfig b/configs/Colombus_defconfig
index c85e47cb11..6310420c29 100644
--- a/configs/Colombus_defconfig
+++ b/configs/Colombus_defconfig
@@ -24,5 +24,6 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO1_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Cubieboard2_defconfig b/configs/Cubieboard2_defconfig
index 418da63ba8..6e883155b9 100644
--- a/configs/Cubieboard2_defconfig
+++ b/configs/Cubieboard2_defconfig
@@ -16,5 +16,6 @@ CONFIG_SCSI_AHCI=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Cubieboard_defconfig b/configs/Cubieboard_defconfig
index 27223d201e..dbeda7370d 100644
--- a/configs/Cubieboard_defconfig
+++ b/configs/Cubieboard_defconfig
@@ -15,5 +15,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SCSI_AHCI=y
 CONFIG_SUN4I_EMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Cubietruck_plus_defconfig b/configs/Cubietruck_plus_defconfig
index d76bc6748b..6a0e4c5836 100644
--- a/configs/Cubietruck_plus_defconfig
+++ b/configs/Cubietruck_plus_defconfig
@@ -22,6 +22,7 @@ CONFIG_CONSOLE_MUX=y
 CONFIG_AXP_DLDO3_VOLT=2500
 CONFIG_AXP_DLDO4_VOLT=3300
 CONFIG_AXP_FLDO1_VOLT=1200
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Hummingbird_A31_defconfig b/configs/Hummingbird_A31_defconfig
index 24126fde28..81eb59ebd1 100644
--- a/configs/Hummingbird_A31_defconfig
+++ b/configs/Hummingbird_A31_defconfig
@@ -16,5 +16,6 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO1_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Itead_Ibox_A20_defconfig b/configs/Itead_Ibox_A20_defconfig
index dfef071476..93c89890a7 100644
--- a/configs/Itead_Ibox_A20_defconfig
+++ b/configs/Itead_Ibox_A20_defconfig
@@ -16,5 +16,6 @@ CONFIG_SCSI_AHCI=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Linksprite_pcDuino3_Nano_defconfig b/configs/Linksprite_pcDuino3_Nano_defconfig
index 2df6761455..8487263fd8 100644
--- a/configs/Linksprite_pcDuino3_Nano_defconfig
+++ b/configs/Linksprite_pcDuino3_Nano_defconfig
@@ -19,5 +19,6 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Linksprite_pcDuino3_defconfig b/configs/Linksprite_pcDuino3_defconfig
index d7e9c26cbf..7a1fc26434 100644
--- a/configs/Linksprite_pcDuino3_defconfig
+++ b/configs/Linksprite_pcDuino3_defconfig
@@ -18,5 +18,6 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
 CONFIG_DM_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Linksprite_pcDuino_defconfig b/configs/Linksprite_pcDuino_defconfig
index 500f885599..b18b02307f 100644
--- a/configs/Linksprite_pcDuino_defconfig
+++ b/configs/Linksprite_pcDuino_defconfig
@@ -11,5 +11,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN4I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/MK808C_defconfig b/configs/MK808C_defconfig
index 62768b8656..c3d914efe3 100644
--- a/configs/MK808C_defconfig
+++ b/configs/MK808C_defconfig
@@ -9,5 +9,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Marsboard_A10_defconfig b/configs/Marsboard_A10_defconfig
index 55c27b8435..37bdeb0c37 100644
--- a/configs/Marsboard_A10_defconfig
+++ b/configs/Marsboard_A10_defconfig
@@ -12,5 +12,6 @@ CONFIG_SCSI_AHCI=y
 CONFIG_SUN4I_EMAC=y
 CONFIG_SUNXI_NO_PMIC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Mele_A1000G_quad_defconfig b/configs/Mele_A1000G_quad_defconfig
index e084454293..b3a05f2c0d 100644
--- a/configs/Mele_A1000G_quad_defconfig
+++ b/configs/Mele_A1000G_quad_defconfig
@@ -17,6 +17,7 @@ CONFIG_AXP_DCDC1_VOLT=3300
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_AXP_DLDO1_VOLT=3300
 CONFIG_AXP_DLDO4_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Mele_A1000_defconfig b/configs/Mele_A1000_defconfig
index 367f2aaf7a..021753c221 100644
--- a/configs/Mele_A1000_defconfig
+++ b/configs/Mele_A1000_defconfig
@@ -15,5 +15,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SCSI_AHCI=y
 CONFIG_SUN4I_EMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Mele_I7_defconfig b/configs/Mele_I7_defconfig
index 4fa61d311f..c9398676e2 100644
--- a/configs/Mele_I7_defconfig
+++ b/configs/Mele_I7_defconfig
@@ -16,5 +16,6 @@ CONFIG_AXP_DCDC1_VOLT=3300
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_AXP_DLDO1_VOLT=3300
 CONFIG_AXP_DLDO4_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Mele_M3_defconfig b/configs/Mele_M3_defconfig
index 9f48bd91e0..22497aaeb4 100644
--- a/configs/Mele_M3_defconfig
+++ b/configs/Mele_M3_defconfig
@@ -15,5 +15,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Mele_M5_defconfig b/configs/Mele_M5_defconfig
index 6b198be6f6..37e90e1eaf 100644
--- a/configs/Mele_M5_defconfig
+++ b/configs/Mele_M5_defconfig
@@ -17,5 +17,6 @@ CONFIG_SCSI_AHCI=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Mele_M9_defconfig b/configs/Mele_M9_defconfig
index af89c50ee1..94190499bf 100644
--- a/configs/Mele_M9_defconfig
+++ b/configs/Mele_M9_defconfig
@@ -16,5 +16,6 @@ CONFIG_AXP_DCDC1_VOLT=3300
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_AXP_DLDO1_VOLT=3300
 CONFIG_AXP_DLDO4_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Mini-X_defconfig b/configs/Mini-X_defconfig
index e32935e132..dfaa649e95 100644
--- a/configs/Mini-X_defconfig
+++ b/configs/Mini-X_defconfig
@@ -10,6 +10,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Orangepi_defconfig b/configs/Orangepi_defconfig
index 88e55495d5..c347e32927 100644
--- a/configs/Orangepi_defconfig
+++ b/configs/Orangepi_defconfig
@@ -21,5 +21,6 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Orangepi_mini_defconfig b/configs/Orangepi_mini_defconfig
index 46f27be254..7eeae25010 100644
--- a/configs/Orangepi_mini_defconfig
+++ b/configs/Orangepi_mini_defconfig
@@ -23,5 +23,6 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Sinlinx_SinA31s_defconfig b/configs/Sinlinx_SinA31s_defconfig
index 9744aef096..0aa02d687c 100644
--- a/configs/Sinlinx_SinA31s_defconfig
+++ b/configs/Sinlinx_SinA31s_defconfig
@@ -17,5 +17,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31s-sina31s"
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_DLDO1_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Sinlinx_SinA33_defconfig b/configs/Sinlinx_SinA33_defconfig
index 394534b8b5..7f5aaab5fb 100644
--- a/configs/Sinlinx_SinA33_defconfig
+++ b/configs/Sinlinx_SinA33_defconfig
@@ -19,6 +19,7 @@ CONFIG_CMD_DFU=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_DFU_RAM=y
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Sinovoip_BPI_M2_Plus_defconfig b/configs/Sinovoip_BPI_M2_Plus_defconfig
index a325e9f806..b01aa560d2 100644
--- a/configs/Sinovoip_BPI_M2_Plus_defconfig
+++ b/configs/Sinovoip_BPI_M2_Plus_defconfig
@@ -13,6 +13,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-bananapi-m2-plus"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Sinovoip_BPI_M2_defconfig b/configs/Sinovoip_BPI_M2_defconfig
index 65d81a5284..fa42670355 100644
--- a/configs/Sinovoip_BPI_M2_defconfig
+++ b/configs/Sinovoip_BPI_M2_defconfig
@@ -16,5 +16,6 @@ CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_AXP_ALDO2_VOLT=1800
 CONFIG_AXP_DLDO1_VOLT=3000
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Sinovoip_BPI_M3_defconfig b/configs/Sinovoip_BPI_M3_defconfig
index 479dd05dfb..91a3621d77 100644
--- a/configs/Sinovoip_BPI_M3_defconfig
+++ b/configs/Sinovoip_BPI_M3_defconfig
@@ -23,6 +23,7 @@ CONFIG_CONSOLE_MUX=y
 CONFIG_AXP_DCDC5_VOLT=1200
 CONFIG_AXP_DLDO3_VOLT=2500
 CONFIG_AXP_SW_ON=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Wexler_TAB7200_defconfig b/configs/Wexler_TAB7200_defconfig
index 9a431ee4cd..d031b05f1a 100644
--- a/configs/Wexler_TAB7200_defconfig
+++ b/configs/Wexler_TAB7200_defconfig
@@ -17,6 +17,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Wobo_i5_defconfig b/configs/Wobo_i5_defconfig
index 88ccfd406e..8ae00abcff 100644
--- a/configs/Wobo_i5_defconfig
+++ b/configs/Wobo_i5_defconfig
@@ -14,5 +14,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_AXP_ALDO3_VOLT=3300
 CONFIG_AXP_ALDO4_VOLT=3300
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/a64-olinuxino_defconfig b/configs/a64-olinuxino_defconfig
index b32df990a0..54f6a98472 100644
--- a/configs/a64-olinuxino_defconfig
+++ b/configs/a64-olinuxino_defconfig
@@ -10,5 +10,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-olinuxino"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/ba10_tv_box_defconfig b/configs/ba10_tv_box_defconfig
index 88199c8e78..b6776e3cb9 100644
--- a/configs/ba10_tv_box_defconfig
+++ b/configs/ba10_tv_box_defconfig
@@ -14,6 +14,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN4I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/bananapi_m1_plus_defconfig b/configs/bananapi_m1_plus_defconfig
index 539ed73495..dde7b17229 100644
--- a/configs/bananapi_m1_plus_defconfig
+++ b/configs/bananapi_m1_plus_defconfig
@@ -19,4 +19,5 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_SCSI=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/bananapi_m64_defconfig b/configs/bananapi_m64_defconfig
index 40c1c18aca..df0bbb4db5 100644
--- a/configs/bananapi_m64_defconfig
+++ b/configs/bananapi_m64_defconfig
@@ -11,6 +11,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-bananapi-m64"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/ga10h_v1_1_defconfig b/configs/ga10h_v1_1_defconfig
index 02cc9677aa..4196ad6863 100644
--- a/configs/ga10h_v1_1_defconfig
+++ b/configs/ga10h_v1_1_defconfig
@@ -22,6 +22,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-a33-ga10h-v1.1"
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_AXP_DLDO1_VOLT=3300
 CONFIG_CONS_INDEX=5
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/h8_homlet_v2_defconfig b/configs/h8_homlet_v2_defconfig
index 80bdb20e8a..380949b1c2 100644
--- a/configs/h8_homlet_v2_defconfig
+++ b/configs/h8_homlet_v2_defconfig
@@ -15,6 +15,7 @@ CONFIG_CONSOLE_MUX=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_AXP_DLDO4_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/i12-tvbox_defconfig b/configs/i12-tvbox_defconfig
index a3c4b0e76c..983627afbb 100644
--- a/configs/i12-tvbox_defconfig
+++ b/configs/i12-tvbox_defconfig
@@ -13,5 +13,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/icnova-a20-swac_defconfig b/configs/icnova-a20-swac_defconfig
index 8fca6e81ed..6d6792553e 100644
--- a/configs/icnova-a20-swac_defconfig
+++ b/configs/icnova-a20-swac_defconfig
@@ -20,5 +20,6 @@ CONFIG_CMD_UNZIP=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_SUN7I_GMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/inet1_defconfig b/configs/inet1_defconfig
index 100d075960..46f8f3c095 100644
--- a/configs/inet1_defconfig
+++ b/configs/inet1_defconfig
@@ -18,6 +18,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/inet_q972_defconfig b/configs/inet_q972_defconfig
index b928622813..9a22499b23 100644
--- a/configs/inet_q972_defconfig
+++ b/configs/inet_q972_defconfig
@@ -19,6 +19,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31s-inet-q972"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_AXP_DLDO1_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/jesurun_q5_defconfig b/configs/jesurun_q5_defconfig
index 00bb745be2..c0c46a1d4e 100644
--- a/configs/jesurun_q5_defconfig
+++ b/configs/jesurun_q5_defconfig
@@ -13,6 +13,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN4I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_HOST=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/libretech_all_h3_cc_h2_plus_defconfig b/configs/libretech_all_h3_cc_h2_plus_defconfig
index 071be93697..ccf0b73ffd 100644
--- a/configs/libretech_all_h3_cc_h2_plus_defconfig
+++ b/configs/libretech_all_h3_cc_h2_plus_defconfig
@@ -12,5 +12,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-libretech-all-h3-cc"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/libretech_all_h3_cc_h3_defconfig b/configs/libretech_all_h3_cc_h3_defconfig
index c20ad9f3a2..159b00ea91 100644
--- a/configs/libretech_all_h3_cc_h3_defconfig
+++ b/configs/libretech_all_h3_cc_h3_defconfig
@@ -12,5 +12,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-libretech-all-h3-cc"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/libretech_all_h3_cc_h5_defconfig b/configs/libretech_all_h3_cc_h5_defconfig
index 5db8dfcd4f..003e2dc0f3 100644
--- a/configs/libretech_all_h3_cc_h5_defconfig
+++ b/configs/libretech_all_h3_cc_h5_defconfig
@@ -12,5 +12,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-libretech-all-h3-cc"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/mixtile_loftq_defconfig b/configs/mixtile_loftq_defconfig
index 79d984ba7b..59321b108d 100644
--- a/configs/mixtile_loftq_defconfig
+++ b/configs/mixtile_loftq_defconfig
@@ -16,5 +16,6 @@ CONFIG_ETH_DESIGNWARE=y
 CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO1_VOLT=3300
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/mk802_a10s_defconfig b/configs/mk802_a10s_defconfig
index 5129b49506..233925ee6e 100644
--- a/configs/mk802_a10s_defconfig
+++ b/configs/mk802_a10s_defconfig
@@ -13,5 +13,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_AXP152_POWER=y
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/mk802_defconfig b/configs/mk802_defconfig
index 81d121fb84..454339a7cf 100644
--- a/configs/mk802_defconfig
+++ b/configs/mk802_defconfig
@@ -9,5 +9,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-mk802"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUNXI_NO_PMIC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/mk802ii_defconfig b/configs/mk802ii_defconfig
index 84ae234fdc..2ce58ca64d 100644
--- a/configs/mk802ii_defconfig
+++ b/configs/mk802ii_defconfig
@@ -8,5 +8,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/nanopi_a64_defconfig b/configs/nanopi_a64_defconfig
index 0a04911c81..091f395db3 100644
--- a/configs/nanopi_a64_defconfig
+++ b/configs/nanopi_a64_defconfig
@@ -9,5 +9,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-nanopi-a64"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/nanopi_m1_defconfig b/configs/nanopi_m1_defconfig
index e0ae3c7c60..8440bd28c9 100644
--- a/configs/nanopi_m1_defconfig
+++ b/configs/nanopi_m1_defconfig
@@ -10,5 +10,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-nanopi-m1"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/nanopi_m1_plus_defconfig b/configs/nanopi_m1_plus_defconfig
index ee22364760..3918b7e21e 100644
--- a/configs/nanopi_m1_plus_defconfig
+++ b/configs/nanopi_m1_plus_defconfig
@@ -12,5 +12,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-nanopi-m1-plus"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/nanopi_neo2_defconfig b/configs/nanopi_neo2_defconfig
index 35058186f5..100f144ed0 100644
--- a/configs/nanopi_neo2_defconfig
+++ b/configs/nanopi_neo2_defconfig
@@ -10,5 +10,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-nanopi-neo2"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/nanopi_neo_air_defconfig b/configs/nanopi_neo_air_defconfig
index f953b71f03..c2659627bc 100644
--- a/configs/nanopi_neo_air_defconfig
+++ b/configs/nanopi_neo_air_defconfig
@@ -12,5 +12,6 @@ CONFIG_CONSOLE_MUX=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/nanopi_neo_defconfig b/configs/nanopi_neo_defconfig
index 66919e5a2b..44cd1036dd 100644
--- a/configs/nanopi_neo_defconfig
+++ b/configs/nanopi_neo_defconfig
@@ -13,5 +13,6 @@ CONFIG_CONSOLE_MUX=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/nanopi_neo_plus2_defconfig b/configs/nanopi_neo_plus2_defconfig
index 70798a8e9f..bcaf2e5068 100644
--- a/configs/nanopi_neo_plus2_defconfig
+++ b/configs/nanopi_neo_plus2_defconfig
@@ -12,4 +12,5 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-nanopi-neo-plus2"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/orangepi_2_defconfig b/configs/orangepi_2_defconfig
index 577a32255b..e88615c8c6 100644
--- a/configs/orangepi_2_defconfig
+++ b/configs/orangepi_2_defconfig
@@ -15,5 +15,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
 CONFIG_SY8106A_POWER=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_lite_defconfig b/configs/orangepi_lite_defconfig
index f3fd864a6d..21b05daf45 100644
--- a/configs/orangepi_lite_defconfig
+++ b/configs/orangepi_lite_defconfig
@@ -10,5 +10,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-orangepi-lite"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_one_defconfig b/configs/orangepi_one_defconfig
index 23f4973e5b..4c7f6027ac 100644
--- a/configs/orangepi_one_defconfig
+++ b/configs/orangepi_one_defconfig
@@ -11,5 +11,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-orangepi-one"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_pc2_defconfig b/configs/orangepi_pc2_defconfig
index ca1e586e89..3dabfeb300 100644
--- a/configs/orangepi_pc2_defconfig
+++ b/configs/orangepi_pc2_defconfig
@@ -12,6 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-orangepi-pc2"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_pc_defconfig b/configs/orangepi_pc_defconfig
index 134db79e72..083e0eba9b 100644
--- a/configs/orangepi_pc_defconfig
+++ b/configs/orangepi_pc_defconfig
@@ -13,5 +13,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
 CONFIG_SY8106A_POWER=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_pc_plus_defconfig b/configs/orangepi_pc_plus_defconfig
index 01c1cd7736..4068afb20e 100644
--- a/configs/orangepi_pc_plus_defconfig
+++ b/configs/orangepi_pc_plus_defconfig
@@ -14,5 +14,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
 CONFIG_SY8106A_POWER=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_plus2e_defconfig b/configs/orangepi_plus2e_defconfig
index a6e61a5065..f049d3f8b9 100644
--- a/configs/orangepi_plus2e_defconfig
+++ b/configs/orangepi_plus2e_defconfig
@@ -15,5 +15,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
 CONFIG_SY8106A_POWER=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_plus_defconfig b/configs/orangepi_plus_defconfig
index 8e32b0af32..4c1d609760 100644
--- a/configs/orangepi_plus_defconfig
+++ b/configs/orangepi_plus_defconfig
@@ -17,5 +17,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
 CONFIG_SY8106A_POWER=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_prime_defconfig b/configs/orangepi_prime_defconfig
index 6161863258..b20835b0d7 100644
--- a/configs/orangepi_prime_defconfig
+++ b/configs/orangepi_prime_defconfig
@@ -10,6 +10,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-orangepi-prime"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_r1_defconfig b/configs/orangepi_r1_defconfig
index 8e6ee7b2db..289f8d7650 100644
--- a/configs/orangepi_r1_defconfig
+++ b/configs/orangepi_r1_defconfig
@@ -12,5 +12,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-orangepi-r1"
 CONFIG_CONSOLE_MUX=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_win_defconfig b/configs/orangepi_win_defconfig
index d7211b5823..e14faacfaf 100644
--- a/configs/orangepi_win_defconfig
+++ b/configs/orangepi_win_defconfig
@@ -10,5 +10,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-orangepi-win"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_zero_defconfig b/configs/orangepi_zero_defconfig
index 6afd4a3bfa..6f2a64002f 100644
--- a/configs/orangepi_zero_defconfig
+++ b/configs/orangepi_zero_defconfig
@@ -12,5 +12,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-orangepi-zero"
 CONFIG_CONSOLE_MUX=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_zero_plus2_defconfig b/configs/orangepi_zero_plus2_defconfig
index fdb6bb4ed9..95c3d29b85 100644
--- a/configs/orangepi_zero_plus2_defconfig
+++ b/configs/orangepi_zero_plus2_defconfig
@@ -12,5 +12,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-orangepi-zero-plus2"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/orangepi_zero_plus_defconfig b/configs/orangepi_zero_plus_defconfig
index fc656ce733..cd61b17cd4 100644
--- a/configs/orangepi_zero_plus_defconfig
+++ b/configs/orangepi_zero_plus_defconfig
@@ -12,5 +12,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-orangepi-zero-plus"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/parrot_r16_defconfig b/configs/parrot_r16_defconfig
index 553a8d6572..936f08185f 100644
--- a/configs/parrot_r16_defconfig
+++ b/configs/parrot_r16_defconfig
@@ -17,6 +17,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-r16-parrot"
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_CONS_INDEX=5
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/pine64_plus_defconfig b/configs/pine64_plus_defconfig
index 21ce06f370..c632d24456 100644
--- a/configs/pine64_plus_defconfig
+++ b/configs/pine64_plus_defconfig
@@ -12,5 +12,6 @@ CONFIG_OF_LIST="sun50i-a64-pine64 sun50i-a64-pine64-plus"
 CONFIG_PHY_REALTEK=y
 CONFIG_RTL8211E_PINE64_GIGABIT_FIX=y
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/r7-tv-dongle_defconfig b/configs/r7-tv-dongle_defconfig
index 9a66ee90f9..eaf7f4816a 100644
--- a/configs/r7-tv-dongle_defconfig
+++ b/configs/r7-tv-dongle_defconfig
@@ -12,5 +12,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_AXP152_POWER=y
 CONFIG_CONS_INDEX=2
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/sopine_baseboard_defconfig b/configs/sopine_baseboard_defconfig
index c79c111b5d..0da899c155 100644
--- a/configs/sopine_baseboard_defconfig
+++ b/configs/sopine_baseboard_defconfig
@@ -16,5 +16,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-sopine-baseboard"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN8I_EMAC=y
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/sun8i_a23_evb_defconfig b/configs/sun8i_a23_evb_defconfig
index 4cb2798ce7..c32f024cd2 100644
--- a/configs/sun8i_a23_evb_defconfig
+++ b/configs/sun8i_a23_evb_defconfig
@@ -13,5 +13,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-a23-evb"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_CONS_INDEX=5
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/sunxi_Gemei_G9_defconfig b/configs/sunxi_Gemei_G9_defconfig
index d88dd4ebad..c42074c0d8 100644
--- a/configs/sunxi_Gemei_G9_defconfig
+++ b/configs/sunxi_Gemei_G9_defconfig
@@ -15,5 +15,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/tbs_a711_defconfig b/configs/tbs_a711_defconfig
index 5d58f5ceb4..d7d99c4dba 100644
--- a/configs/tbs_a711_defconfig
+++ b/configs/tbs_a711_defconfig
@@ -18,6 +18,7 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-a83t-tbs-a711"
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_AXP_DCDC5_VOLT=1200
+CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
 CONFIG_USB_FUNCTION_MASS_STORAGE=y
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index b4dd005651..60a152704a 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -191,6 +191,7 @@ config USB_EHCI_GENERIC
 	bool "Support for generic EHCI USB controller"
 	depends on OF_CONTROL
 	depends on DM_USB
+	default ARCH_SUNXI
 	default n
 	---help---
 	  Enables support for generic EHCI controller.
@@ -221,6 +222,7 @@ config USB_OHCI_GENERIC
 	bool "Support for generic OHCI USB controller"
 	depends on OF_CONTROL
 	depends on DM_USB
+	default ARCH_SUNXI
 	select USB_HOST
 	---help---
 	  Enables support for generic OHCI controller.
diff --git a/include/configs/sun4i.h b/include/configs/sun4i.h
index af079a71ee..6033760583 100644
--- a/include/configs/sun4i.h
+++ b/include/configs/sun4i.h
@@ -11,10 +11,6 @@
  * A10 specific configuration
  */
 
-#ifdef CONFIG_USB_EHCI_HCD
-#define CONFIG_USB_EHCI_SUNXI
-#endif
-
 /*
  * Include common sunxi configuration where most the settings are
  */
diff --git a/include/configs/sun50i.h b/include/configs/sun50i.h
index 2d73c75b8c..e050a5299f 100644
--- a/include/configs/sun50i.h
+++ b/include/configs/sun50i.h
@@ -10,11 +10,6 @@
  * A64 specific configuration
  */
 
-#ifdef CONFIG_USB_EHCI_HCD
-#define CONFIG_USB_EHCI_SUNXI
-#define CONFIG_USB_MAX_CONTROLLER_COUNT 1
-#endif
-
 #ifndef CONFIG_MACH_SUN50I_H6
 #define GICD_BASE		0x1c81000
 #define GICC_BASE		0x1c82000
diff --git a/include/configs/sun5i.h b/include/configs/sun5i.h
index c3692caa73..ee42af80d4 100644
--- a/include/configs/sun5i.h
+++ b/include/configs/sun5i.h
@@ -11,10 +11,6 @@
  * High Level Configuration Options
  */
 
-#ifdef CONFIG_USB_EHCI_HCD
-#define CONFIG_USB_EHCI_SUNXI
-#endif
-
 /*
  * Include common sunxi configuration where most the settings are
  */
diff --git a/include/configs/sun6i.h b/include/configs/sun6i.h
index 1523684fad..1e490daac1 100644
--- a/include/configs/sun6i.h
+++ b/include/configs/sun6i.h
@@ -14,10 +14,6 @@
  * A31 specific configuration
  */
 
-#ifdef CONFIG_USB_EHCI_HCD
-#define CONFIG_USB_EHCI_SUNXI
-#endif
-
 #define CONFIG_ARMV7_SECURE_BASE	SUNXI_SRAM_B_BASE
 #define CONFIG_ARMV7_SECURE_MAX_SIZE    (64 * 1024) /* 64 KB */
 
diff --git a/include/configs/sun7i.h b/include/configs/sun7i.h
index bb8f217b25..d2fd586672 100644
--- a/include/configs/sun7i.h
+++ b/include/configs/sun7i.h
@@ -12,10 +12,6 @@
  * A20 specific configuration
  */
 
-#ifdef CONFIG_USB_EHCI_HCD
-#define CONFIG_USB_EHCI_SUNXI
-#endif
-
 #define CONFIG_ARMV7_SECURE_BASE	SUNXI_SRAM_B_BASE
 #define CONFIG_ARMV7_SECURE_MAX_SIZE	(64 * 1024) /* 64 KB */
 
diff --git a/include/configs/sun8i.h b/include/configs/sun8i.h
index 7dc8693b76..9b4675e4c3 100644
--- a/include/configs/sun8i.h
+++ b/include/configs/sun8i.h
@@ -12,10 +12,6 @@
  * A23 specific configuration
  */
 
-#ifdef CONFIG_USB_EHCI_HCD
-#define CONFIG_USB_EHCI_SUNXI
-#endif
-
 /*
  * Include common sunxi configuration where most the settings are
  */
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 93690481a1..f1578d3754 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -302,7 +302,6 @@ extern int soft_i2c_gpio_scl;
 
 #ifdef CONFIG_USB_EHCI_HCD
 #define CONFIG_USB_OHCI_NEW
-#define CONFIG_USB_OHCI_SUNXI
 #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1
 #endif
 
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 17/58] usb: host: Drop [e-o]hci-sunxi drivers
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (15 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 16/58] sunxi: usb: Switch to Generic host controllers Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 18/58] clk: sunxi: Implement AHB bus MMC clocks Jagan Teki
                   ` (40 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Now Allwinner platform is all set to use Generic USB
controller drivers, so remove the legacy sunxi drivers.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/usb/host/Makefile     |   2 -
 drivers/usb/host/ehci-sunxi.c | 204 -----------------------------
 drivers/usb/host/ohci-sunxi.c | 233 ----------------------------------
 scripts/config_whitelist.txt  |   2 -
 4 files changed, 441 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-sunxi.c
 delete mode 100644 drivers/usb/host/ohci-sunxi.c

diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index cb8c315a15..b62fdbb1d2 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -15,7 +15,6 @@ obj-$(CONFIG_USB_OHCI_DA8XX) += ohci-da8xx.o
 obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o
 obj-$(CONFIG_USB_SL811HS) += sl811-hcd.o
 obj-$(CONFIG_USB_OHCI_EP93XX) += ohci-ep93xx.o
-obj-$(CONFIG_USB_OHCI_SUNXI) += ohci-sunxi.o
 obj-$(CONFIG_USB_OHCI_LPC32XX) += ohci-lpc32xx.o
 obj-$(CONFIG_USB_OHCI_GENERIC) += ohci-generic.o
 
@@ -37,7 +36,6 @@ obj-$(CONFIG_USB_EHCI_MARVELL) += ehci-marvell.o
 obj-$(CONFIG_USB_EHCI_MSM) += ehci-msm.o
 obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
 obj-$(CONFIG_USB_EHCI_SPEAR) += ehci-spear.o
-obj-$(CONFIG_USB_EHCI_SUNXI) += ehci-sunxi.o
 obj-$(CONFIG_USB_EHCI_TEGRA) += ehci-tegra.o
 obj-$(CONFIG_USB_EHCI_VCT) += ehci-vct.o
 obj-$(CONFIG_USB_EHCI_VF) += ehci-vf.o
diff --git a/drivers/usb/host/ehci-sunxi.c b/drivers/usb/host/ehci-sunxi.c
deleted file mode 100644
index 7a79931a97..0000000000
--- a/drivers/usb/host/ehci-sunxi.c
+++ /dev/null
@@ -1,204 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Sunxi ehci glue
- *
- * Copyright (C) 2015 Hans de Goede <hdegoede@redhat.com>
- * Copyright (C) 2014 Roman Byshko <rbyshko@gmail.com>
- *
- * Based on code from
- * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
- */
-
-#include <common.h>
-#include <asm/arch/clock.h>
-#include <asm/io.h>
-#include <dm.h>
-#include "ehci.h"
-#include <generic-phy.h>
-
-#ifdef CONFIG_SUNXI_GEN_SUN4I
-#define BASE_DIST		0x8000
-#define AHB_CLK_DIST		2
-#else
-#define BASE_DIST		0x1000
-#define AHB_CLK_DIST		1
-#endif
-
-#define SUN6I_AHB_RESET0_CFG_OFFSET 0x2c0
-#define SUN9I_AHB_RESET0_CFG_OFFSET 0x5a0
-
-struct ehci_sunxi_cfg {
-	bool has_reset;
-	u32 extra_ahb_gate_mask;
-	u32 reset0_cfg_offset;
-};
-
-struct ehci_sunxi_priv {
-	struct ehci_ctrl ehci;
-	struct sunxi_ccm_reg *ccm;
-	u32 *reset0_cfg;
-	int ahb_gate_mask; /* Mask of ahb_gate0 clk gate bits for this hcd */
-	struct phy phy;
-	const struct ehci_sunxi_cfg *cfg;
-};
-
-static int ehci_usb_probe(struct udevice *dev)
-{
-	struct usb_platdata *plat = dev_get_platdata(dev);
-	struct ehci_sunxi_priv *priv = dev_get_priv(dev);
-	struct ehci_hccr *hccr = (struct ehci_hccr *)devfdt_get_addr(dev);
-	struct ehci_hcor *hcor;
-	int extra_ahb_gate_mask = 0;
-	u8 reg_mask = 0;
-	int phys, ret;
-
-	priv->cfg = (const struct ehci_sunxi_cfg *)dev_get_driver_data(dev);
-	priv->ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
-	if (IS_ERR(priv->ccm))
-		return PTR_ERR(priv->ccm);
-
-	priv->reset0_cfg = (void *)priv->ccm +
-				   priv->cfg->reset0_cfg_offset;
-
-	phys = dev_count_phandle_with_args(dev, "phys", "#phy-cells");
-	if (phys < 0) {
-		phys = 0;
-		goto no_phy;
-	}
-
-	ret = generic_phy_get_by_name(dev, "usb", &priv->phy);
-	if (ret) {
-		pr_err("failed to get %s usb PHY\n", dev->name);
-		return ret;
-	}
-
-	ret = generic_phy_init(&priv->phy);
-	if (ret) {
-		pr_err("failed to init %s USB PHY\n", dev->name);
-		return ret;
-	}
-
-	ret = generic_phy_power_on(&priv->phy);
-	if (ret) {
-		pr_err("failed to power on %s USB PHY\n", dev->name);
-		return ret;
-	}
-
-no_phy:
-	/*
-	 * This should go away once we've moved to the driver model for
-	 * clocks resp. phys.
-	 */
-	reg_mask = ((uintptr_t)hccr - SUNXI_USB1_BASE) / BASE_DIST;
-	priv->ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_EHCI0;
-	extra_ahb_gate_mask = priv->cfg->extra_ahb_gate_mask;
-	priv->ahb_gate_mask <<= reg_mask * AHB_CLK_DIST;
-	extra_ahb_gate_mask <<= reg_mask * AHB_CLK_DIST;
-
-	setbits_le32(&priv->ccm->ahb_gate0,
-		     priv->ahb_gate_mask | extra_ahb_gate_mask);
-	if (priv->cfg->has_reset)
-		setbits_le32(priv->reset0_cfg,
-			     priv->ahb_gate_mask | extra_ahb_gate_mask);
-
-	hcor = (struct ehci_hcor *)((uintptr_t)hccr +
-				    HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
-
-	return ehci_register(dev, hccr, hcor, NULL, 0, plat->init_type);
-}
-
-static int ehci_usb_remove(struct udevice *dev)
-{
-	struct ehci_sunxi_priv *priv = dev_get_priv(dev);
-	int ret;
-
-	if (generic_phy_valid(&priv->phy)) {
-		ret = generic_phy_exit(&priv->phy);
-		if (ret) {
-			pr_err("failed to exit %s USB PHY\n", dev->name);
-			return ret;
-		}
-	}
-
-	ret = ehci_deregister(dev);
-	if (ret)
-		return ret;
-
-	if (priv->cfg->has_reset)
-		clrbits_le32(priv->reset0_cfg, priv->ahb_gate_mask);
-	clrbits_le32(&priv->ccm->ahb_gate0, priv->ahb_gate_mask);
-
-	return 0;
-}
-
-static const struct ehci_sunxi_cfg sun4i_a10_cfg = {
-	.has_reset = false,
-};
-
-static const struct ehci_sunxi_cfg sun6i_a31_cfg = {
-	.has_reset = true,
-	.reset0_cfg_offset = SUN6I_AHB_RESET0_CFG_OFFSET,
-};
-
-static const struct ehci_sunxi_cfg sun8i_h3_cfg = {
-	.has_reset = true,
-	.extra_ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_OHCI0,
-	.reset0_cfg_offset = SUN6I_AHB_RESET0_CFG_OFFSET,
-};
-
-static const struct ehci_sunxi_cfg sun9i_a80_cfg = {
-	.has_reset = true,
-	.reset0_cfg_offset = SUN9I_AHB_RESET0_CFG_OFFSET,
-};
-
-static const struct udevice_id ehci_usb_ids[] = {
-	{
-		.compatible = "allwinner,sun4i-a10-ehci",
-		.data = (ulong)&sun4i_a10_cfg,
-	},
-	{
-		.compatible = "allwinner,sun5i-a13-ehci",
-		.data = (ulong)&sun4i_a10_cfg,
-	},
-	{
-		.compatible = "allwinner,sun6i-a31-ehci",
-		.data = (ulong)&sun6i_a31_cfg,
-	},
-	{
-		.compatible = "allwinner,sun7i-a20-ehci",
-		.data = (ulong)&sun4i_a10_cfg,
-	},
-	{
-		.compatible = "allwinner,sun8i-a23-ehci",
-		.data = (ulong)&sun6i_a31_cfg,
-	},
-	{
-		.compatible = "allwinner,sun8i-a83t-ehci",
-		.data = (ulong)&sun6i_a31_cfg,
-	},
-	{
-		.compatible = "allwinner,sun8i-h3-ehci",
-		.data = (ulong)&sun8i_h3_cfg,
-	},
-	{
-		.compatible = "allwinner,sun9i-a80-ehci",
-		.data = (ulong)&sun9i_a80_cfg,
-	},
-	{
-		.compatible = "allwinner,sun50i-a64-ehci",
-		.data = (ulong)&sun8i_h3_cfg,
-	},
-	{ /* sentinel */ }
-};
-
-U_BOOT_DRIVER(ehci_sunxi) = {
-	.name	= "ehci_sunxi",
-	.id	= UCLASS_USB,
-	.of_match = ehci_usb_ids,
-	.probe = ehci_usb_probe,
-	.remove = ehci_usb_remove,
-	.ops	= &ehci_usb_ops,
-	.platdata_auto_alloc_size = sizeof(struct usb_platdata),
-	.priv_auto_alloc_size = sizeof(struct ehci_sunxi_priv),
-	.flags	= DM_FLAG_ALLOC_PRIV_DMA,
-};
diff --git a/drivers/usb/host/ohci-sunxi.c b/drivers/usb/host/ohci-sunxi.c
deleted file mode 100644
index bb3c2475df..0000000000
--- a/drivers/usb/host/ohci-sunxi.c
+++ /dev/null
@@ -1,233 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Sunxi ohci glue
- *
- * Copyright (C) 2015 Hans de Goede <hdegoede@redhat.com>
- *
- * Based on code from
- * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
- */
-
-#include <common.h>
-#include <asm/arch/clock.h>
-#include <asm/io.h>
-#include <dm.h>
-#include <usb.h>
-#include "ohci.h"
-#include <generic-phy.h>
-
-#ifdef CONFIG_SUNXI_GEN_SUN4I
-#define BASE_DIST		0x8000
-#define AHB_CLK_DIST		2
-#else
-#define BASE_DIST		0x1000
-#define AHB_CLK_DIST		1
-#endif
-
-#define SUN6I_AHB_RESET0_CFG_OFFSET 0x2c0
-#define SUN9I_AHB_RESET0_CFG_OFFSET 0x5a0
-
-struct ohci_sunxi_cfg {
-	bool has_reset;
-	u32 extra_ahb_gate_mask;
-	u32 extra_usb_gate_mask;
-	u32 reset0_cfg_offset;
-};
-
-struct ohci_sunxi_priv {
-	ohci_t ohci;
-	struct sunxi_ccm_reg *ccm;
-	u32 *reset0_cfg;
-	int ahb_gate_mask; /* Mask of ahb_gate0 clk gate bits for this hcd */
-	int usb_gate_mask; /* Mask of usb_clk_cfg clk gate bits for this hcd */
-	struct phy phy;
-	const struct ohci_sunxi_cfg *cfg;
-};
-
-static fdt_addr_t last_ohci_addr = 0;
-
-static int ohci_usb_probe(struct udevice *dev)
-{
-	struct usb_bus_priv *bus_priv = dev_get_uclass_priv(dev);
-	struct ohci_sunxi_priv *priv = dev_get_priv(dev);
-	struct ohci_regs *regs = (struct ohci_regs *)devfdt_get_addr(dev);
-	int extra_ahb_gate_mask = 0;
-	u8 reg_mask = 0;
-	int phys, ret;
-
-	if ((fdt_addr_t)regs > last_ohci_addr)
-		last_ohci_addr = (fdt_addr_t)regs;
-
-	priv->cfg = (const struct ohci_sunxi_cfg *)dev_get_driver_data(dev);
-	priv->ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
-	if (IS_ERR(priv->ccm))
-		return PTR_ERR(priv->ccm);
-
-	priv->reset0_cfg = (void *)priv->ccm +
-				   priv->cfg->reset0_cfg_offset;
-
-	phys = dev_count_phandle_with_args(dev, "phys", "#phy-cells");
-	if (phys < 0) {
-		phys = 0;
-		goto no_phy;
-	}
-
-	ret = generic_phy_get_by_name(dev, "usb", &priv->phy);
-	if (ret) {
-		pr_err("failed to get %s usb PHY\n", dev->name);
-		return ret;
-	}
-
-	ret = generic_phy_init(&priv->phy);
-	if (ret) {
-		pr_err("failed to init %s USB PHY\n", dev->name);
-		return ret;
-	}
-
-	ret = generic_phy_power_on(&priv->phy);
-	if (ret) {
-		pr_err("failed to power on %s USB PHY\n", dev->name);
-		return ret;
-	}
-
-no_phy:
-	bus_priv->companion = true;
-
-	/*
-	 * This should go away once we've moved to the driver model for
-	 * clocks resp. phys.
-	 */
-	reg_mask = ((uintptr_t)regs - (SUNXI_USB1_BASE + 0x400)) / BASE_DIST;
-	priv->ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_OHCI0;
-	extra_ahb_gate_mask = priv->cfg->extra_ahb_gate_mask;
-	priv->usb_gate_mask = CCM_USB_CTRL_OHCI0_CLK;
-	priv->ahb_gate_mask <<= reg_mask * AHB_CLK_DIST;
-	extra_ahb_gate_mask <<= reg_mask * AHB_CLK_DIST;
-	priv->usb_gate_mask <<= reg_mask;
-
-	setbits_le32(&priv->ccm->ahb_gate0,
-		     priv->ahb_gate_mask | extra_ahb_gate_mask);
-	setbits_le32(&priv->ccm->usb_clk_cfg,
-		     priv->usb_gate_mask | priv->cfg->extra_usb_gate_mask);
-	if (priv->cfg->has_reset)
-		setbits_le32(priv->reset0_cfg,
-			     priv->ahb_gate_mask | extra_ahb_gate_mask);
-
-	return ohci_register(dev, regs);
-}
-
-static int ohci_usb_remove(struct udevice *dev)
-{
-	struct ohci_sunxi_priv *priv = dev_get_priv(dev);
-	fdt_addr_t base_addr = devfdt_get_addr(dev);
-	int ret;
-
-	if (generic_phy_valid(&priv->phy)) {
-		ret = generic_phy_exit(&priv->phy);
-		if (ret) {
-			pr_err("failed to exit %s USB PHY\n", dev->name);
-			return ret;
-		}
-	}
-
-	ret = ohci_deregister(dev);
-	if (ret)
-		return ret;
-
-	if (priv->cfg->has_reset)
-		clrbits_le32(priv->reset0_cfg, priv->ahb_gate_mask);
-	/*
-	 * On the A64 CLK_USB_OHCI0 is the parent of CLK_USB_OHCI1, so
-	 * we have to wait with bringing down any clock until the last
-	 * OHCI controller is removed.
-	 */
-	if (!priv->cfg->extra_usb_gate_mask || base_addr == last_ohci_addr) {
-		u32 usb_gate_mask = priv->usb_gate_mask;
-
-		usb_gate_mask |= priv->cfg->extra_usb_gate_mask;
-		clrbits_le32(&priv->ccm->usb_clk_cfg, usb_gate_mask);
-	}
-
-	clrbits_le32(&priv->ccm->ahb_gate0, priv->ahb_gate_mask);
-
-	return 0;
-}
-
-static const struct ohci_sunxi_cfg sun4i_a10_cfg = {
-	.has_reset = false,
-};
-
-static const struct ohci_sunxi_cfg sun6i_a31_cfg = {
-	.has_reset = true,
-	.reset0_cfg_offset = SUN6I_AHB_RESET0_CFG_OFFSET,
-};
-
-static const struct ohci_sunxi_cfg sun8i_h3_cfg = {
-	.has_reset = true,
-	.extra_ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_EHCI0,
-	.reset0_cfg_offset = SUN6I_AHB_RESET0_CFG_OFFSET,
-};
-
-static const struct ohci_sunxi_cfg sun9i_a80_cfg = {
-	.has_reset = true,
-	.reset0_cfg_offset = SUN9I_AHB_RESET0_CFG_OFFSET,
-};
-
-static const struct ohci_sunxi_cfg sun50i_a64_cfg = {
-	.has_reset = true,
-	.extra_ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_EHCI0,
-	.extra_usb_gate_mask = CCM_USB_CTRL_OHCI0_CLK,
-	.reset0_cfg_offset = SUN6I_AHB_RESET0_CFG_OFFSET,
-};
-
-static const struct udevice_id ohci_usb_ids[] = {
-	{
-		.compatible = "allwinner,sun4i-a10-ohci",
-		.data = (ulong)&sun4i_a10_cfg,
-	},
-	{
-		.compatible = "allwinner,sun5i-a13-ohci",
-		.data = (ulong)&sun4i_a10_cfg,
-	},
-	{
-		.compatible = "allwinner,sun6i-a31-ohci",
-		.data = (ulong)&sun6i_a31_cfg,
-	},
-	{
-		.compatible = "allwinner,sun7i-a20-ohci",
-		.data = (ulong)&sun4i_a10_cfg,
-	},
-	{
-		.compatible = "allwinner,sun8i-a23-ohci",
-		.data = (ulong)&sun6i_a31_cfg,
-	},
-	{
-		.compatible = "allwinner,sun8i-a83t-ohci",
-		.data = (ulong)&sun6i_a31_cfg,
-	},
-	{
-		.compatible = "allwinner,sun8i-h3-ohci",
-		.data = (ulong)&sun8i_h3_cfg,
-	},
-	{
-		.compatible = "allwinner,sun9i-a80-ohci",
-		.data = (ulong)&sun9i_a80_cfg,
-	},
-	{
-		.compatible = "allwinner,sun50i-a64-ohci",
-		.data = (ulong)&sun50i_a64_cfg,
-	},
-	{ /* sentinel */ }
-};
-
-U_BOOT_DRIVER(usb_ohci) = {
-	.name	= "ohci_sunxi",
-	.id	= UCLASS_USB,
-	.of_match = ohci_usb_ids,
-	.probe = ohci_usb_probe,
-	.remove = ohci_usb_remove,
-	.ops	= &ohci_usb_ops,
-	.platdata_auto_alloc_size = sizeof(struct usb_platdata),
-	.priv_auto_alloc_size = sizeof(struct ohci_sunxi_priv),
-	.flags	= DM_FLAG_ALLOC_PRIV_DMA,
-};
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 0d60da3f28..4cca3d1c73 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -4611,7 +4611,6 @@ CONFIG_USB_EHCI_MX5
 CONFIG_USB_EHCI_MXC
 CONFIG_USB_EHCI_MXS
 CONFIG_USB_EHCI_SPEAR
-CONFIG_USB_EHCI_SUNXI
 CONFIG_USB_EHCI_TEGRA
 CONFIG_USB_EHCI_TXFIFO_THRESH
 CONFIG_USB_EHCI_VCT
@@ -4653,7 +4652,6 @@ CONFIG_USB_OHCI
 CONFIG_USB_OHCI_EP93XX
 CONFIG_USB_OHCI_LPC32XX
 CONFIG_USB_OHCI_NEW
-CONFIG_USB_OHCI_SUNXI
 CONFIG_USB_OTG
 CONFIG_USB_OTG_BLACKLIST_HUB
 CONFIG_USB_PHY_CFG_BASE
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 18/58] clk: sunxi: Implement AHB bus MMC clocks
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (16 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 17/58] usb: host: Drop [e-o]hci-sunxi drivers Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:28   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 19/58] clk: sunxi: Implement direct " Jagan Teki
                   ` (39 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Implement AHB bus MMC clocks for all Allwinner SoC
clock drivers via clock map descriptor table.

Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/clk_a10.c  | 4 ++++
 drivers/clk/sunxi/clk_a10s.c | 3 +++
 drivers/clk/sunxi/clk_a23.c  | 3 +++
 drivers/clk/sunxi/clk_a31.c  | 4 ++++
 drivers/clk/sunxi/clk_a64.c  | 3 +++
 drivers/clk/sunxi/clk_a83t.c | 3 +++
 drivers/clk/sunxi/clk_h3.c   | 3 +++
 drivers/clk/sunxi/clk_r40.c  | 4 ++++
 drivers/clk/sunxi/clk_v3s.c  | 3 +++
 9 files changed, 30 insertions(+)

diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
index 7492e1367a..fb11231dd1 100644
--- a/drivers/clk/sunxi/clk_a10.c
+++ b/drivers/clk/sunxi/clk_a10.c
@@ -18,6 +18,10 @@ static struct ccu_clk_map a10_clks[] = {
 	[CLK_AHB_OHCI0]		= { 0x060, BIT(2), NULL },
 	[CLK_AHB_EHCI1]		= { 0x060, BIT(3), NULL },
 	[CLK_AHB_OHCI1]		= { 0x060, BIT(4), NULL },
+	[CLK_AHB_MMC0]		= { 0x060, BIT(8), NULL },
+	[CLK_AHB_MMC1]		= { 0x060, BIT(9), NULL },
+	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_AHB_MMC3]		= { 0x060, BIT(11), NULL },
 
 	[CLK_USB_OHCI0]		= { 0x0cc, BIT(6), NULL },
 	[CLK_USB_OHCI1]		= { 0x0cc, BIT(7), NULL },
diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
index 976595201f..bc4ae7352b 100644
--- a/drivers/clk/sunxi/clk_a10s.c
+++ b/drivers/clk/sunxi/clk_a10s.c
@@ -16,6 +16,9 @@ static struct ccu_clk_map a10s_clks[] = {
 	[CLK_AHB_OTG]		= { 0x060, BIT(0), NULL },
 	[CLK_AHB_EHCI]		= { 0x060, BIT(1), NULL },
 	[CLK_AHB_OHCI]		= { 0x060, BIT(2), NULL },
+	[CLK_AHB_MMC0]		= { 0x060, BIT(8), NULL },
+	[CLK_AHB_MMC1]		= { 0x060, BIT(9), NULL },
+	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
 
 	[CLK_USB_OHCI]		= { 0x0cc, BIT(6), NULL },
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
index ec9834e1a8..62770a58fe 100644
--- a/drivers/clk/sunxi/clk_a23.c
+++ b/drivers/clk/sunxi/clk_a23.c
@@ -13,6 +13,9 @@
 #include <dt-bindings/reset/sun8i-a23-a33-ccu.h>
 
 static struct ccu_clk_map a23_clks[] = {
+	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
+	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
+	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
 	[CLK_BUS_EHCI]		= { 0x060, BIT(26), NULL },
 	[CLK_BUS_OHCI]		= { 0x060, BIT(29), NULL },
diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index c6d82be120..f314feff69 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -13,6 +13,10 @@
 #include <dt-bindings/reset/sun6i-a31-ccu.h>
 
 static struct ccu_clk_map a31_clks[] = {
+	[CLK_AHB1_MMC0]		= { 0x060, BIT(8), NULL },
+	[CLK_AHB1_MMC1]		= { 0x060, BIT(9), NULL },
+	[CLK_AHB1_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_AHB1_MMC3]		= { 0x060, BIT(12), NULL },
 	[CLK_AHB1_OTG]		= { 0x060, BIT(24), NULL },
 	[CLK_AHB1_EHCI0]	= { 0x060, BIT(26), NULL },
 	[CLK_AHB1_EHCI1]	= { 0x060, BIT(27), NULL },
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index e5257b62c7..71f3510c74 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -13,6 +13,9 @@
 #include <dt-bindings/reset/sun50i-a64-ccu.h>
 
 static struct ccu_clk_map a64_clks[] = {
+	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
+	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
+	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(23), NULL },
 	[CLK_BUS_EHCI0]		= { 0x060, BIT(24), NULL },
 	[CLK_BUS_EHCI1]		= { 0x060, BIT(25), NULL },
diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c
index 58d28eb6ad..cc18975a06 100644
--- a/drivers/clk/sunxi/clk_a83t.c
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -13,6 +13,9 @@
 #include <dt-bindings/reset/sun8i-a83t-ccu.h>
 
 static struct ccu_clk_map a83t_clks[] = {
+	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
+	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
+	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
 	[CLK_BUS_EHCI0]		= { 0x060, BIT(26), NULL },
 	[CLK_BUS_EHCI1]		= { 0x060, BIT(27), NULL },
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index 0b7f4947dd..85dd06ee2d 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -13,6 +13,9 @@
 #include <dt-bindings/reset/sun8i-h3-ccu.h>
 
 static struct ccu_clk_map h3_clks[] = {
+	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
+	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
+	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(23), NULL },
 	[CLK_BUS_EHCI0]		= { 0x060, BIT(24), NULL },
 	[CLK_BUS_EHCI1]		= { 0x060, BIT(25), NULL },
diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
index 746d6734b2..006aa138b6 100644
--- a/drivers/clk/sunxi/clk_r40.c
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -13,6 +13,10 @@
 #include <dt-bindings/reset/sun8i-r40-ccu.h>
 
 static struct ccu_clk_map r40_clks[] = {
+	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
+	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
+	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_BUS_MMC3]		= { 0x060, BIT(11), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(25), NULL },
 	[CLK_BUS_EHCI0]		= { 0x060, BIT(26), NULL },
 	[CLK_BUS_EHCI1]		= { 0x060, BIT(27), NULL },
diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c
index 2494518798..ab2cc45640 100644
--- a/drivers/clk/sunxi/clk_v3s.c
+++ b/drivers/clk/sunxi/clk_v3s.c
@@ -13,6 +13,9 @@
 #include <dt-bindings/reset/sun8i-v3s-ccu.h>
 
 static struct ccu_clk_map v3s_clks[] = {
+	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
+	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
+	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
 
 	[CLK_USB_PHY0]          = { 0x0cc, BIT(8), NULL },
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 19/58] clk: sunxi: Implement direct MMC clocks
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (17 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 18/58] clk: sunxi: Implement AHB bus MMC clocks Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:33   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 20/58] clk: sunxi: Implement AHB bus MMC resets Jagan Teki
                   ` (38 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Implement direct MMC clocks for all Allwinner SoC
clock drivers via clock map descriptor table.

This includes adding ccu_clk_set_rate function pointer,
which indeed support CLK set_rate API, so update clock
handling in sunxi_mmc driver to support both no-dm and dm code.

Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/include/asm/arch-sunxi/ccu.h | 10 +++++
 drivers/clk/sunxi/clk_a10.c           |  5 +++
 drivers/clk/sunxi/clk_a10s.c          |  6 +++
 drivers/clk/sunxi/clk_a23.c           |  6 +++
 drivers/clk/sunxi/clk_a31.c           |  5 +++
 drivers/clk/sunxi/clk_a64.c           |  4 ++
 drivers/clk/sunxi/clk_a83t.c          |  4 ++
 drivers/clk/sunxi/clk_h3.c            |  4 ++
 drivers/clk/sunxi/clk_r40.c           |  4 ++
 drivers/clk/sunxi/clk_sunxi.c         | 19 +++++++++
 drivers/clk/sunxi/clk_v3s.c           |  4 ++
 drivers/mmc/sunxi_mmc.c               | 58 +++++++++++++++++----------
 12 files changed, 107 insertions(+), 22 deletions(-)

diff --git a/arch/arm/include/asm/arch-sunxi/ccu.h b/arch/arm/include/asm/arch-sunxi/ccu.h
index bacd052ef3..4e30ab330c 100644
--- a/arch/arm/include/asm/arch-sunxi/ccu.h
+++ b/arch/arm/include/asm/arch-sunxi/ccu.h
@@ -60,6 +60,16 @@ struct sunxi_clk_priv {
 
 extern struct clk_ops sunxi_clk_ops;
 
+/**
+ * mmc_clk_set_rate - mmc clock set rate
+ *
+ * @base:	clock register base address
+ * @bit:	clock bit value
+ * @rate:	clock input rate in Hz
+ * @return 0, or -ve error code.
+ */
+int mmc_clk_set_rate(void *base, u32 bit, ulong rate);
+
 /**
  * sunxi_reset_bind() - reset binding
  *
diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
index fb11231dd1..55176bc174 100644
--- a/drivers/clk/sunxi/clk_a10.c
+++ b/drivers/clk/sunxi/clk_a10.c
@@ -23,6 +23,11 @@ static struct ccu_clk_map a10_clks[] = {
 	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_AHB_MMC3]		= { 0x060, BIT(11), NULL },
 
+	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC3]		= { 0x094, BIT(31), &mmc_clk_set_rate },
+
 	[CLK_USB_OHCI0]		= { 0x0cc, BIT(6), NULL },
 	[CLK_USB_OHCI1]		= { 0x0cc, BIT(7), NULL },
 	[CLK_USB_PHY]		= { 0x0cc, BIT(8), NULL },
diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
index bc4ae7352b..fbac0ad751 100644
--- a/drivers/clk/sunxi/clk_a10s.c
+++ b/drivers/clk/sunxi/clk_a10s.c
@@ -20,6 +20,12 @@ static struct ccu_clk_map a10s_clks[] = {
 	[CLK_AHB_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
 
+#ifdef CONFIG_MMC
+	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
+#endif
+
 	[CLK_USB_OHCI]		= { 0x0cc, BIT(6), NULL },
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
index 62770a58fe..0b5406c5b3 100644
--- a/drivers/clk/sunxi/clk_a23.c
+++ b/drivers/clk/sunxi/clk_a23.c
@@ -20,6 +20,12 @@ static struct ccu_clk_map a23_clks[] = {
 	[CLK_BUS_EHCI]		= { 0x060, BIT(26), NULL },
 	[CLK_BUS_OHCI]		= { 0x060, BIT(29), NULL },
 
+#ifdef CONFIG_MMC
+	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
+#endif
+
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
 	[CLK_USB_HSIC]		= { 0x0cc, BIT(10), NULL },
diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index f314feff69..3c807bde77 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -24,6 +24,11 @@ static struct ccu_clk_map a31_clks[] = {
 	[CLK_AHB1_OHCI1]	= { 0x060, BIT(30), NULL },
 	[CLK_AHB1_OHCI2]	= { 0x060, BIT(31), NULL },
 
+	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC3]		= { 0x094, BIT(31), &mmc_clk_set_rate },
+
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
 	[CLK_USB_PHY2]		= { 0x0cc, BIT(10), NULL },
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index 71f3510c74..62cd6d6464 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -22,6 +22,10 @@ static struct ccu_clk_map a64_clks[] = {
 	[CLK_BUS_OHCI0]		= { 0x060, BIT(28), NULL },
 	[CLK_BUS_OHCI1]		= { 0x060, BIT(29), NULL },
 
+	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
+
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
 	[CLK_USB_HSIC]		= { 0x0cc, BIT(10), NULL },
diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c
index cc18975a06..a2e0ac7a26 100644
--- a/drivers/clk/sunxi/clk_a83t.c
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -21,6 +21,10 @@ static struct ccu_clk_map a83t_clks[] = {
 	[CLK_BUS_EHCI1]		= { 0x060, BIT(27), NULL },
 	[CLK_BUS_OHCI0]		= { 0x060, BIT(29), NULL },
 
+	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
+
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
 	[CLK_USB_HSIC]		= { 0x0cc, BIT(10), NULL },
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index 85dd06ee2d..f467187c01 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -26,6 +26,10 @@ static struct ccu_clk_map h3_clks[] = {
 	[CLK_BUS_OHCI2]		= { 0x060, BIT(30), NULL },
 	[CLK_BUS_OHCI3]		= { 0x060, BIT(31), NULL },
 
+	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
+
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
 	[CLK_USB_PHY2]		= { 0x0cc, BIT(10), NULL },
diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
index 006aa138b6..9273f3b7ea 100644
--- a/drivers/clk/sunxi/clk_r40.c
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -25,6 +25,10 @@ static struct ccu_clk_map r40_clks[] = {
 	[CLK_BUS_OHCI1]		= { 0x060, BIT(30), NULL },
 	[CLK_BUS_OHCI2]		= { 0x060, BIT(31), NULL },
 
+	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC3]		= { 0x094, BIT(31), &mmc_clk_set_rate },
 
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c
index 791b1ac7f2..ca147ec9cc 100644
--- a/drivers/clk/sunxi/clk_sunxi.c
+++ b/drivers/clk/sunxi/clk_sunxi.c
@@ -12,6 +12,24 @@
 #include <asm/arch/ccu.h>
 #include <linux/log2.h>
 
+static ulong sunxi_clk_set_rate(struct clk *clk, ulong rate)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(clk->dev);
+	struct ccu_clk_map *map = &priv->desc->clks[clk->id];
+	u32 *base;
+
+	if (!map->ccu_clk_set_rate) {
+		debug("%s (CLK#%ld) unhandled\n", __func__, clk->id);
+		return 0;
+	}
+
+	debug("%s(#%ld) off#0x%x, BIT(%d)\n", __func__,
+	      clk->id, map->off, ilog2(map->bit));
+
+	base = priv->base + map->off;
+	return map->ccu_clk_set_rate(base, map->bit, rate);
+}
+
 static int sunxi_clk_enable(struct clk *clk)
 {
 	struct sunxi_clk_priv *priv = dev_get_priv(clk->dev);
@@ -55,4 +73,5 @@ static int sunxi_clk_disable(struct clk *clk)
 struct clk_ops sunxi_clk_ops = {
 	.enable = sunxi_clk_enable,
 	.disable = sunxi_clk_disable,
+	.set_rate = sunxi_clk_set_rate,
 };
diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c
index ab2cc45640..e0d757debe 100644
--- a/drivers/clk/sunxi/clk_v3s.c
+++ b/drivers/clk/sunxi/clk_v3s.c
@@ -18,6 +18,10 @@ static struct ccu_clk_map v3s_clks[] = {
 	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
 
+	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
+
 	[CLK_USB_PHY0]          = { 0x0cc, BIT(8), NULL },
 };
 
diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index 39f15eb423..bf82014a64 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -13,6 +13,7 @@
 #include <malloc.h>
 #include <mmc.h>
 #include <asm/io.h>
+#include <asm/arch/ccu.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/gpio.h>
@@ -34,6 +35,8 @@ struct sunxi_mmc_priv {
 	struct mmc_config cfg;
 };
 
+bool new_mode;
+
 #if !CONFIG_IS_ENABLED(DM_MMC)
 /* support 4 mmc hosts */
 struct sunxi_mmc_priv mmc_host[4];
@@ -95,23 +98,19 @@ static int mmc_resource_init(int sdc_no)
 }
 #endif
 
-static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
+int mmc_clk_set_rate(void *base, u32 bit, ulong rate)
 {
 	unsigned int pll, pll_hz, div, n, oclk_dly, sclk_dly;
-	bool new_mode = false;
 	u32 val = 0;
 
-	if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
-		new_mode = true;
-
 	/*
 	 * The MMC clock has an extra /2 post-divider when operating in the new
 	 * mode.
 	 */
 	if (new_mode)
-		hz = hz * 2;
+		rate = rate * 2;
 
-	if (hz <= 24000000) {
+	if (rate <= 24000000) {
 		pll = CCM_MMC_CTRL_OSCM24;
 		pll_hz = 24000000;
 	} else {
@@ -127,8 +126,8 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 #endif
 	}
 
-	div = pll_hz / hz;
-	if (pll_hz % hz)
+	div = pll_hz / rate;
+	if (pll_hz % rate)
 		div++;
 
 	n = 0;
@@ -138,32 +137,31 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 	}
 
 	if (n > 3) {
-		printf("mmc %u error cannot set clock to %u\n", priv->mmc_no,
-		       hz);
+		printf("mmc error cannot set clock to %ld\n", rate);
 		return -1;
 	}
 
 	/* determine delays */
-	if (hz <= 400000) {
+	if (rate <= 400000) {
 		oclk_dly = 0;
 		sclk_dly = 0;
-	} else if (hz <= 25000000) {
+	} else if (rate <= 25000000) {
 		oclk_dly = 0;
 		sclk_dly = 5;
 #ifdef CONFIG_MACH_SUN9I
-	} else if (hz <= 52000000) {
+	} else if (rate <= 52000000) {
 		oclk_dly = 5;
 		sclk_dly = 4;
 	} else {
-		/* hz > 52000000 */
+		/* rate > 52000000 */
 		oclk_dly = 2;
 		sclk_dly = 4;
 #else
-	} else if (hz <= 52000000) {
+	} else if (rate <= 52000000) {
 		oclk_dly = 3;
 		sclk_dly = 4;
 	} else {
-		/* hz > 52000000 */
+		/* rate > 52000000 */
 		oclk_dly = 1;
 		sclk_dly = 4;
 #endif
@@ -172,22 +170,35 @@ static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 	if (new_mode) {
 #ifdef CONFIG_MMC_SUNXI_HAS_NEW_MODE
 		val = CCM_MMC_CTRL_MODE_SEL_NEW;
-		setbits_le32(&priv->reg->ntsr, SUNXI_MMC_NTSR_MODE_SEL_NEW);
 #endif
 	} else {
 		val = CCM_MMC_CTRL_OCLK_DLY(oclk_dly) |
 			CCM_MMC_CTRL_SCLK_DLY(sclk_dly);
 	}
 
-	writel(CCM_MMC_CTRL_ENABLE| pll | CCM_MMC_CTRL_N(n) |
-	       CCM_MMC_CTRL_M(div) | val, priv->mclkreg);
+	writel(bit | pll | CCM_MMC_CTRL_N(n) |
+	       CCM_MMC_CTRL_M(div) | val, base);
 
-	debug("mmc %u set mod-clk req %u parent %u n %u m %u rate %u\n",
-	      priv->mmc_no, hz, pll_hz, 1u << n, div, pll_hz / (1u << n) / div);
+	debug("mmc set mod-clk req %ld parent %u n %u m %u rate %u\n",
+	      rate, pll_hz, 1u << n, div, pll_hz / (1u << n) / div);
 
 	return 0;
 }
 
+static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
+{
+#if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(CLK)
+#else
+	if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
+		new_mode = true;
+
+	if (new_mode)
+		setbits_le32(&priv->reg->ntsr, SUNXI_MMC_NTSR_MODE_SEL_NEW);
+
+	return mmc_clk_set_rate(priv->mclkreg, CCM_MMC_CTRL_ENABLE, hz);
+#endif
+}
+
 static int mmc_update_clk(struct sunxi_mmc_priv *priv)
 {
 	unsigned int cmd;
@@ -599,6 +610,9 @@ static int sunxi_mmc_probe(struct udevice *dev)
 	cfg->f_min = 400000;
 	cfg->f_max = 52000000;
 
+	if (device_is_compatible(dev, "allwinner,sun8i-a83t-emmc"))
+		new_mode = true;
+
 	priv->reg = (void *)dev_read_addr(dev);
 
 	/* We don't have a sunxi clock driver so find the clock address here */
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 20/58] clk: sunxi: Implement AHB bus MMC resets
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (18 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 19/58] clk: sunxi: Implement direct " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:28   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 21/58] reset: Add get reset by name optionally Jagan Teki
                   ` (37 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Implement AHB bus MMC resets for all Allwinner SoC
clock drivers via reset map descriptor table.

Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/clk_a23.c  | 3 +++
 drivers/clk/sunxi/clk_a31.c  | 4 ++++
 drivers/clk/sunxi/clk_a64.c  | 3 +++
 drivers/clk/sunxi/clk_a83t.c | 3 +++
 drivers/clk/sunxi/clk_h3.c   | 3 +++
 drivers/clk/sunxi/clk_r40.c  | 4 ++++
 drivers/clk/sunxi/clk_v3s.c  | 3 +++
 7 files changed, 23 insertions(+)

diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
index 0b5406c5b3..183c6275f3 100644
--- a/drivers/clk/sunxi/clk_a23.c
+++ b/drivers/clk/sunxi/clk_a23.c
@@ -38,6 +38,9 @@ static struct ccu_reset_map a23_resets[] = {
 	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
 	[RST_USB_HSIC]		= { 0x0cc, BIT(2) },
 
+	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
+	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
+	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
 	[RST_BUS_EHCI]		= { 0x2c0, BIT(26) },
 	[RST_BUS_OHCI]		= { 0x2c0, BIT(29) },
diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index 3c807bde77..15076d0e72 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -42,6 +42,10 @@ static struct ccu_reset_map a31_resets[] = {
 	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
 	[RST_USB_PHY2]		= { 0x0cc, BIT(2) },
 
+	[RST_AHB1_MMC0]		= { 0x2c0, BIT(8) },
+	[RST_AHB1_MMC1]		= { 0x2c0, BIT(9) },
+	[RST_AHB1_MMC2]		= { 0x2c0, BIT(10) },
+	[RST_AHB1_MMC3]		= { 0x2c0, BIT(11) },
 	[RST_AHB1_OTG]		= { 0x2c0, BIT(24) },
 	[RST_AHB1_EHCI0]	= { 0x2c0, BIT(26) },
 	[RST_AHB1_EHCI1]	= { 0x2c0, BIT(27) },
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index 62cd6d6464..9ef9b606d2 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -39,6 +39,9 @@ static struct ccu_reset_map a64_resets[] = {
 	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
 	[RST_USB_HSIC]		= { 0x0cc, BIT(2) },
 
+	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
+	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
+	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(23) },
 	[RST_BUS_EHCI0]		= { 0x2c0, BIT(24) },
 	[RST_BUS_EHCI1]		= { 0x2c0, BIT(25) },
diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c
index a2e0ac7a26..47b7672e7f 100644
--- a/drivers/clk/sunxi/clk_a83t.c
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -37,6 +37,9 @@ static struct ccu_reset_map a83t_resets[] = {
 	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
 	[RST_USB_HSIC]		= { 0x0cc, BIT(2) },
 
+	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
+	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
+	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
 	[RST_BUS_EHCI0]		= { 0x2c0, BIT(26) },
 	[RST_BUS_EHCI1]		= { 0x2c0, BIT(27) },
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index f467187c01..ad15aaae67 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -46,6 +46,9 @@ static struct ccu_reset_map h3_resets[] = {
 	[RST_USB_PHY2]		= { 0x0cc, BIT(2) },
 	[RST_USB_PHY3]		= { 0x0cc, BIT(3) },
 
+	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
+	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
+	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(23) },
 	[RST_BUS_EHCI0]		= { 0x2c0, BIT(24) },
 	[RST_BUS_EHCI1]		= { 0x2c0, BIT(25) },
diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
index 9273f3b7ea..24c26ad3be 100644
--- a/drivers/clk/sunxi/clk_r40.c
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -43,6 +43,10 @@ static struct ccu_reset_map r40_resets[] = {
 	[RST_USB_PHY1]		= { 0x0cc, BIT(1) },
 	[RST_USB_PHY2]		= { 0x0cc, BIT(2) },
 
+	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
+	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
+	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
+	[RST_BUS_MMC3]		= { 0x2c0, BIT(11) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(25) },
 	[RST_BUS_EHCI0]		= { 0x2c0, BIT(26) },
 	[RST_BUS_EHCI1]		= { 0x2c0, BIT(27) },
diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c
index e0d757debe..6eeec201a2 100644
--- a/drivers/clk/sunxi/clk_v3s.c
+++ b/drivers/clk/sunxi/clk_v3s.c
@@ -28,6 +28,9 @@ static struct ccu_clk_map v3s_clks[] = {
 static struct ccu_reset_map v3s_resets[] = {
 	[RST_USB_PHY0]		= { 0x0cc, BIT(0) },
 
+	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
+	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
+	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
 };
 
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 21/58] reset: Add get reset by name optionally
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (19 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 20/58] clk: sunxi: Implement AHB bus MMC resets Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:34   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 22/58] reset: Add reset valid Jagan Teki
                   ` (36 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Reset is an optional for some controllers with some families
of CPU's with same SoC where the common IP driver can handle
to drive the entire SoC families. optional reset get by name
is useful for those drivers to make common way of reset handling.

Example, In Allwinner SoC with MMC controllers has no reset
for Sun4i, 5i, 7i but reset have reset.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/reset/reset-uclass.c | 18 ++++++++++++++++++
 include/reset.h              | 25 +++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index 99881b8b99..6320efcb49 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -138,6 +138,24 @@ int reset_get_by_name(struct udevice *dev, const char *name,
 	return reset_get_by_index(dev, index, reset_ctl);
 }
 
+int reset_get_by_name_optional(struct udevice *dev, const char *name,
+			       struct reset_ctl *reset_ctl, bool optional)
+{
+	int index;
+
+	debug("%s(dev=%p, name=%s, reset_ctl=%p)\n", __func__, dev, name,
+	      reset_ctl);
+	reset_ctl->dev = NULL;
+
+	index = dev_read_stringlist_search(dev, "reset-names", name);
+	if (index < 0) {
+		debug("fdt_stringlist_search() failed: %d\n", index);
+		return optional ? 0 : index;
+	}
+
+	return reset_get_by_index(dev, index, reset_ctl);
+}
+
 int reset_request(struct reset_ctl *reset_ctl)
 {
 	struct reset_ops *ops = reset_dev_ops(reset_ctl->dev);
diff --git a/include/reset.h b/include/reset.h
index a7bbc1c331..a5af31f549 100644
--- a/include/reset.h
+++ b/include/reset.h
@@ -132,6 +132,23 @@ int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk);
 int reset_get_by_name(struct udevice *dev, const char *name,
 		      struct reset_ctl *reset_ctl);
 
+/**
+ * reset_get_by_name_optional - Get/request a reset signal by name optionally.
+ *
+ * This look up and requests a reset signal similar to reset_get_by_name()
+ * but with optional flag.
+ *
+ * @dev:	The client device.
+ * @name:	The name of the reset signal to request, within the client's
+ *		list of reset signals.
+ * @reset_ctl:	A pointer to a reset control struct to initialize.
+ * @optional:	Optional flag, true if reset is optional, false if reset is
+ *		necessary which is same as reset_get_by_name()
+ * @return 0 if OK, or a negative error code.
+ */
+int reset_get_by_name_optional(struct udevice *dev, const char *name,
+			       struct reset_ctl *reset_ctl, bool optional);
+
 /**
  * reset_request - Request a reset signal.
  *
@@ -254,6 +271,14 @@ static inline int reset_get_by_name(struct udevice *dev, const char *name,
 	return -ENOTSUPP;
 }
 
+static inline int reset_get_by_name_optional(struct udevice *dev,
+					     const char *name,
+					     struct reset_ctl *reset_ctl,
+					     bool optional)
+{
+	return -ENOTSUPP;
+}
+
 static inline int reset_free(struct reset_ctl *reset_ctl)
 {
 	return 0;
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 22/58] reset: Add reset valid
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (20 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 21/58] reset: Add get reset by name optionally Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-23 10:44   ` Simon Glass
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 23/58] clk: sunxi: Add Allwinner H6 CLK, RESET driver Jagan Teki
                   ` (35 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add reset_valid to check whether given reset is valid
or not.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 include/reset.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/reset.h b/include/reset.h
index a5af31f549..70130bb886 100644
--- a/include/reset.h
+++ b/include/reset.h
@@ -315,4 +315,15 @@ static inline int reset_release_bulk(struct reset_ctl_bulk *bulk)
 }
 #endif
 
+/**
+ * reset_valid() - check if reset is valid
+ *
+ * @reset_ctl:		the reset to check
+ * @return TRUE if valid, or FALSE
+ */
+static inline bool reset_valid(struct reset_ctl *reset_ctl)
+{
+	return !!reset_ctl->dev;
+}
+
 #endif
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 23/58] clk: sunxi: Add Allwinner H6 CLK, RESET driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (21 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 22/58] reset: Add reset valid Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 24/58] arm64: allwinner: dts: h6: fix Pine H64 MMC bus width Jagan Teki
                   ` (34 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add initial clock, reset driver for Allwinner H6.

- Implement MMC clocking like AHB bus, MMC clocks
  via clock map descriptor table.
- Implement AHB bus MMC resets via reset map
  descriptor table.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/Kconfig  |  7 ++++
 drivers/clk/sunxi/Makefile |  1 +
 drivers/clk/sunxi/clk_h6.c | 73 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_h6.c

diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index a6f84e9e56..736a61fbc0 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -72,4 +72,11 @@ config CLK_SUN50I_A64
 	  This enables common clock driver support for platforms based
 	  on Allwinner A64 SoC.
 
+config CLK_SUN50I_H6
+	bool "Clock driver for Allwinner H6"
+	default MACH_SUN50I_H6
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner H6 SoC.
+
 endif # CLK_SUNXI
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index fbd43527a6..7f8af8f36b 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_CLK_SUN8I_R40) += clk_r40.o
 obj-$(CONFIG_CLK_SUN8I_V3S) += clk_v3s.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
+obj-$(CONFIG_CLK_SUN50I_H6) += clk_h6.o
diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c
new file mode 100644
index 0000000000..1df6aba124
--- /dev/null
+++ b/drivers/clk/sunxi/clk_h6.c
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>
+#include <dt-bindings/clock/sun50i-h6-ccu.h>
+#include <dt-bindings/reset/sun50i-h6-ccu.h>
+
+static struct ccu_clk_map h6_clks[] = {
+	[CLK_MMC0]		= { 0x830, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC1]		= { 0x834, BIT(31), &mmc_clk_set_rate },
+	[CLK_MMC2]		= { 0x834, BIT(31), &mmc_clk_set_rate },
+
+	[CLK_BUS_MMC0]		= { 0x84c, BIT(0), NULL },
+	[CLK_BUS_MMC1]		= { 0x84c, BIT(1), NULL },
+	[CLK_BUS_MMC2]		= { 0x84c, BIT(2), NULL },
+};
+
+static struct ccu_reset_map h6_resets[] = {
+	[CLK_BUS_MMC0]		= { 0x84c, BIT(16) },
+	[CLK_BUS_MMC1]		= { 0x84c, BIT(17) },
+	[CLK_BUS_MMC2]		= { 0x84c, BIT(18) },
+};
+
+static const struct ccu_desc sun50i_h6_ccu_desc = {
+	.clks = h6_clks,
+	.num_clks = ARRAY_SIZE(h6_clks),
+
+	.resets = h6_resets,
+	.num_resets =  ARRAY_SIZE(h6_resets),
+};
+
+static int h6_clk_probe(struct udevice *dev)
+{
+	struct sunxi_clk_priv *priv = dev_get_priv(dev);
+
+	priv->base = dev_read_addr_ptr(dev);
+	if (!priv->base)
+		return -ENOMEM;
+
+	priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
+	if (!priv->desc)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int h6_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, 62);
+}
+
+static const struct udevice_id h6_clk_ids[] = {
+	{ .compatible = "allwinner,sun50i-h6-ccu",
+	  .data = (ulong)&sun50i_h6_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun50i_h6) = {
+	.name		= "sun50i_h6_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= h6_clk_ids,
+	.priv_auto_alloc_size	= sizeof(struct sunxi_clk_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= h6_clk_probe,
+	.bind		= h6_clk_bind,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 24/58] arm64: allwinner: dts: h6: fix Pine H64 MMC bus width
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (22 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 23/58] clk: sunxi: Add Allwinner H6 CLK, RESET driver Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:35   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 25/58] sunxi: h6: Enable CLK, RESET Jagan Teki
                   ` (33 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Currently the enabled MMC controllers on Pine H64 do not have bus-width
set, which make them fall back to 1-bit mode and become quite slow.

Fix this by add the corresponding bus-width properties.

Same commit is there in mailing-list, but yet to merge,
commit fb8971bea0910a3172cd8ce75ccc01b50104ebf7
Author: Icenowy Zheng <icenowy@aosc.io>
Date:   Thu Jul 26 12:41:27 2018 +0800

    arm64: allwinner: dts: h6: fix Pine H64 MMC bus width

Cc: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/dts/sun50i-h6-pine-h64.dts | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/dts/sun50i-h6-pine-h64.dts b/arch/arm/dts/sun50i-h6-pine-h64.dts
index ceffc40810..48daec7f78 100644
--- a/arch/arm/dts/sun50i-h6-pine-h64.dts
+++ b/arch/arm/dts/sun50i-h6-pine-h64.dts
@@ -46,6 +46,7 @@
 	pinctrl-0 = <&mmc0_pins>;
 	vmmc-supply = <&reg_cldo1>;
 	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
+	bus-width = <4>;
 	status = "okay";
 };
 
@@ -56,6 +57,7 @@
 	vqmmc-supply = <&reg_bldo2>;
 	non-removable;
 	cap-mmc-hw-reset;
+	bus-width = <8>;
 	status = "okay";
 };
 
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 25/58] sunxi: h6: Enable CLK, RESET
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (23 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 24/58] arm64: allwinner: dts: h6: fix Pine H64 MMC bus width Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 26/58] dm: mmc: sunxi: Add CLK and RESET support Jagan Teki
                   ` (32 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Enable clock and reset drivers for Allwinner H6 SoC.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index dce81b7d53..da7f6b1e95 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -303,6 +303,7 @@ config MACH_SUN50I_H5
 config MACH_SUN50I_H6
 	bool "sun50i (Allwinner H6)"
 	select ARM64
+	select CLK
 	select SUPPORT_SPL
 	select FIT
 	select SPL_LOAD_FIT
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 26/58] dm: mmc: sunxi: Add CLK and RESET support
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (24 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 25/58] sunxi: h6: Enable CLK, RESET Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:36   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device Jagan Teki
                   ` (31 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Now CLK and RESET driver for Allwinner SoC are available,
so add the relevant operations on mmc sunxi driver.

Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/mmc/sunxi_mmc.c | 60 +++++++++++++++++++++++++++++++----------
 1 file changed, 46 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index bf82014a64..3011ec9498 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -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/ccu.h>
 #include <asm/arch/clock.h>
@@ -26,8 +28,12 @@ struct sunxi_mmc_plat {
 };
 
 struct sunxi_mmc_priv {
+#if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(CLK)
+	struct clk mmc_clk;
+#else
 	unsigned mmc_no;
 	uint32_t *mclkreg;
+#endif
 	unsigned fatal_err;
 	struct gpio_desc cd_gpio;	/* Change Detect GPIO */
 	int cd_inverted;		/* Inverted Card Detect */
@@ -188,6 +194,15 @@ int mmc_clk_set_rate(void *base, u32 bit, ulong rate)
 static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
 {
 #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(CLK)
+	int ret;
+
+	ret = clk_set_rate(&priv->mmc_clk, hz);
+	if (ret) {
+		dev_err(dev, "failed to set rate for mmc_clk\n");
+		return ret;
+	}
+
+	return ret;
 #else
 	if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
 		new_mode = true;
@@ -379,7 +394,7 @@ static int sunxi_mmc_send_cmd_common(struct sunxi_mmc_priv *priv,
 		writel(data->blocks * data->blocksize, &priv->reg->bytecnt);
 	}
 
-	debug("mmc %d, cmd %d(0x%08x), arg 0x%08x\n", priv->mmc_no,
+	debug("mmc cmd %d(0x%08x), arg 0x%08x\n",
 	      cmd->cmdidx, cmdval | cmd->cmdidx, cmd->cmdarg);
 	writel(cmd->cmdarg, &priv->reg->arg);
 
@@ -591,8 +606,8 @@ static int sunxi_mmc_probe(struct udevice *dev)
 	struct sunxi_mmc_plat *plat = dev_get_platdata(dev);
 	struct sunxi_mmc_priv *priv = dev_get_priv(dev);
 	struct mmc_config *cfg = &plat->cfg;
-	struct ofnode_phandle_args args;
-	u32 *gate_reg;
+	struct clk ahb_clk;
+	struct reset_ctl reset;
 	int bus_width, ret;
 
 	cfg->name = dev->name;
@@ -615,20 +630,37 @@ static int sunxi_mmc_probe(struct udevice *dev)
 
 	priv->reg = (void *)dev_read_addr(dev);
 
-	/* We don't have a sunxi clock driver so find the clock address here */
-	ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0,
-					  1, &args);
-	if (ret)
+	ret = clk_get_by_name(dev, "ahb", &ahb_clk);
+	if (ret) {
+		dev_err(dev, "falied to get ahb clock\n");
 		return ret;
-	priv->mclkreg = (u32 *)ofnode_get_addr(args.node);
+	}
 
-	ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0,
-					  0, &args);
-	if (ret)
+	ret = clk_get_by_name(dev, "mmc", &priv->mmc_clk);
+	if (ret) {
+		dev_err(dev, "falied to get mmc clock\n");
 		return ret;
-	gate_reg = (u32 *)ofnode_get_addr(args.node);
-	setbits_le32(gate_reg, 1 << args.args[0]);
-	priv->mmc_no = args.args[0] - 8;
+	}
+
+	ret = reset_get_by_name_optional(dev, "ahb", &reset, true);
+	if (ret) {
+		dev_err(dev, "falied to get ahb reset\n");
+		return ret;
+	}
+
+	ret = clk_enable(&ahb_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable ahb clock\n");
+		return ret;
+	}
+
+	if (reset_valid(&reset)) {
+		ret = reset_deassert(&reset);
+		if (ret) {
+			dev_err(dev, "failed to deassert ahb reset\n");
+			return ret;
+		}
+	}
 
 	ret = mmc_set_mod_clk(priv, 24000000);
 	if (ret)
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (25 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 26/58] dm: mmc: sunxi: Add CLK and RESET support Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:44   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 28/58] env: fat: Add func to get fat device, partition Jagan Teki
                   ` (30 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Usually eMMC is default mmc device for fastboot.

By enabling DM_MMC, the mmc devices are probed as per
DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
U-Boot proper.

Allwinner SoC has maximum of 4 mmc controllers start from
mmc0...mmc3 on which mmc2 can be used an eMMC controller
eventhough mmc3 some boards used as eMMC.

So, update the default fastboot device as 2 to make the
standard usage irrespective of DT node status.

Other corner cases like different device usage, or specific
mmc node status is not enabled in order in DTS must explicitly
add config on the specific defconfig file.

Cc: Olliver Schinagl <oliver@schinagl.nl>
Cc: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 configs/A20-OLinuXino-Lime2-eMMC_defconfig   | 1 +
 configs/A20-Olimex-SOM204-EVB-eMMC_defconfig | 1 +
 configs/Sinlinx_SinA33_defconfig             | 1 +
 configs/amarula_a64_relic_defconfig          | 1 +
 configs/parrot_r16_defconfig                 | 1 +
 drivers/fastboot/Kconfig                     | 3 +--
 6 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
index 2851a461e8..8cedf9cf24 100644
--- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig
+++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
@@ -30,4 +30,5 @@ CONFIG_SCSI=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig b/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
index 3bb8c4c7e6..c96d7ada7c 100644
--- a/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
+++ b/configs/A20-Olimex-SOM204-EVB-eMMC_defconfig
@@ -30,4 +30,5 @@ CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_SCSI=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/Sinlinx_SinA33_defconfig b/configs/Sinlinx_SinA33_defconfig
index 7f5aaab5fb..80741b58f9 100644
--- a/configs/Sinlinx_SinA33_defconfig
+++ b/configs/Sinlinx_SinA33_defconfig
@@ -22,5 +22,6 @@ CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
 CONFIG_USB_FUNCTION_MASS_STORAGE=y
diff --git a/configs/amarula_a64_relic_defconfig b/configs/amarula_a64_relic_defconfig
index b72cbfabc6..caeb3f6008 100644
--- a/configs/amarula_a64_relic_defconfig
+++ b/configs/amarula_a64_relic_defconfig
@@ -12,4 +12,5 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-amarula-relic"
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=0
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
diff --git a/configs/parrot_r16_defconfig b/configs/parrot_r16_defconfig
index 936f08185f..242886f78e 100644
--- a/configs/parrot_r16_defconfig
+++ b/configs/parrot_r16_defconfig
@@ -20,5 +20,6 @@ CONFIG_CONS_INDEX=5
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
+CONFIG_FASTBOOT_FLASH_MMC_DEV=1
 CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
 CONFIG_USB_FUNCTION_MASS_STORAGE=y
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index bc25ea1d9c..0e4b50e1cf 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -87,8 +87,7 @@ endchoice
 config FASTBOOT_FLASH_MMC_DEV
 	int "Define FASTBOOT MMC FLASH default device"
 	depends on FASTBOOT_FLASH_MMC
-	default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
-	default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
+	default 2 if ARCH_SUNXI
 	help
 	  The fastboot "flash" command requires additional information
 	  regarding the non-volatile storage device. Define this to
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 28/58] env: fat: Add func to get fat device, partition
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (26 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 29/58] sunxi: Get fat device wrt boot device, 'auto' partition Jagan Teki
                   ` (29 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Get a fat device and partition for multiple families
of same SoC type can be difficult to handle with static
CONFIG_ENV_FAT_DEVICE_AND_PART via Kconfig.

So, add a generic weak function to get the device, partition
and give relevant users to define their own logic to setup
fat device and partition.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 env/fat.c     | 9 +++++++--
 include/fat.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/env/fat.c b/env/fat.c
index 7f74c64dfe..2147cc0326 100644
--- a/env/fat.c
+++ b/env/fat.c
@@ -30,6 +30,11 @@
 # endif
 #endif
 
+__weak char *get_env_fat_dev_part(void)
+{
+	return CONFIG_ENV_FAT_DEVICE_AND_PART;
+}
+
 #ifdef CMD_SAVEENV
 static int env_fat_save(void)
 {
@@ -45,7 +50,7 @@ static int env_fat_save(void)
 		return err;
 
 	part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
-					CONFIG_ENV_FAT_DEVICE_AND_PART,
+					get_env_fat_dev_part(),
 					&dev_desc, &info, 1);
 	if (part < 0)
 		return 1;
@@ -92,7 +97,7 @@ static int env_fat_load(void)
 #endif
 
 	part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
-					CONFIG_ENV_FAT_DEVICE_AND_PART,
+					get_env_fat_dev_part(),
 					&dev_desc, &info, 1);
 	if (part < 0)
 		goto err_env_relocate;
diff --git a/include/fat.h b/include/fat.h
index 09e1423685..0552fa54b5 100644
--- a/include/fat.h
+++ b/include/fat.h
@@ -185,6 +185,7 @@ static inline u32 sect_to_clust(fsdata *fsdata, int sect)
 	return (sect - fsdata->data_begin) / fsdata->clust_size;
 }
 
+char *get_env_fat_dev_part(void);
 int file_fat_detectfs(void);
 int fat_exists(const char *filename);
 int fat_size(const char *filename, loff_t *size);
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 29/58] sunxi: Get fat device wrt boot device, 'auto' partition
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (27 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 28/58] env: fat: Add func to get fat device, partition Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-20 11:45   ` Maxime Ripard
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 30/58] env: sunxi: Don't update fat dev, part wrt MMC_SUNXI_SLOT_EXTRA Jagan Teki
                   ` (28 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Setting fat device, partition using CONFIG_ENV_FAT_DEVICE_AND_PART
via Kconfig option is difficult to maintain since Allwinner
support more than one mmc controllers with SD and eMMC.

So, add dynamic function to get the device based on the
boot device source with 'auto' partition.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/board.c | 50 +++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index d22a84ea6b..cf174bd0a3 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <fat.h>
 #include <mmc.h>
 #include <i2c.h>
 #include <serial.h>
@@ -253,6 +254,55 @@ uint32_t sunxi_get_boot_device(void)
 	return -1;		/* Never reached */
 }
 
+#if CONFIG_IS_ENABLED(ENV_IS_IN_FAT)
+static int find_first_sd_device(void)
+{
+	struct mmc *mmc;
+	int i;
+
+	for (i = 0; (mmc = find_mmc_device(i)); i++) {
+		if (!mmc_init(mmc) && IS_SD(mmc))
+			return i;
+	}
+
+	return -ENODEV;
+}
+
+static int find_first_mmc_device(void)
+{
+	struct mmc *mmc;
+	int i;
+
+	for (i = 0; (mmc = find_mmc_device(i)); i++) {
+		if (!mmc_init(mmc) && IS_MMC(mmc))
+			return i;
+	}
+
+	return -ENODEV;
+}
+
+char *get_env_fat_dev_part(void)
+{
+	int devno, boot_source;
+	static char dev_part[10];
+
+	boot_source = readb(SPL_ADDR + 0x28);
+	switch (boot_source) {
+	case SUNXI_BOOTED_FROM_MMC0:
+		devno = find_first_sd_device();
+		break;
+	case SUNXI_BOOTED_FROM_MMC2:
+		devno = find_first_mmc_device();
+		break;
+	default:
+		return CONFIG_ENV_FAT_DEVICE_AND_PART;
+        }
+
+	snprintf(dev_part, sizeof(dev_part), "%d:auto", devno);
+	return dev_part;
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 u32 spl_boot_device(void)
 {
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 30/58] env: sunxi: Don't update fat dev, part wrt MMC_SUNXI_SLOT_EXTRA
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (28 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 29/58] sunxi: Get fat device wrt boot device, 'auto' partition Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 31/58] sunxi: Add mmc 2, 3 bootenv devices Jagan Teki
                   ` (27 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

By enabling DM_MMC, the mmc devices are probed as per
DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
U-Boot proper.

Allwinner now support runtime relevant fat device via
get_env_fat_dev_part, so add 0:auto as a default dev, part
for sunxi platform and drop unneeded MMC_SUNXI_SLOT_EXTRA
conditions.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 env/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/env/Kconfig b/env/Kconfig
index be99efb937..2bbb02e3bb 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -373,8 +373,7 @@ config ENV_FAT_DEVICE_AND_PART
 	depends on ENV_IS_IN_FAT
 	default "0:1" if TI_COMMON_CMD_OPTIONS
 	default "0:auto" if ARCH_ZYNQMP
-	default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
-	default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
+	default "0:auto" if ARCH_SUNXI
 	default "0" if ARCH_AT91
 	help
 	  Define this to a string to specify the partition of the device. It can
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 31/58] sunxi: Add mmc 2, 3 bootenv devices
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (29 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 30/58] env: sunxi: Don't update fat dev, part wrt MMC_SUNXI_SLOT_EXTRA Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 32/58] sunxi: A20: Enable DM_MMC Jagan Teki
                   ` (26 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

By enabling DM_MMC, the mmc devices are probed as per
DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
U-Boot proper and eMMC can probed maximum device of 3,
if all nodes mmc0, mmc1, mmc2 and mmc3 status's are 'okay'

This patch create bootcmd env for mmc2, mmc3 and start boot
priority with mmc3...mmc0

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 include/configs/sunxi-common.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index f1578d3754..176ee06036 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -373,12 +373,15 @@ extern int soft_i2c_gpio_scl;
 	"ramdisk ram " RAMDISK_ADDR_R " 0x4000000\0"
 
 #ifdef CONFIG_MMC
-#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
 #define BOOTENV_DEV_MMC_AUTO(devtypeu, devtypel, instance)		\
 	BOOTENV_DEV_MMC(MMC, mmc, 0)					\
 	BOOTENV_DEV_MMC(MMC, mmc, 1)					\
+	BOOTENV_DEV_MMC(MMC, mmc, 2)					\
+	BOOTENV_DEV_MMC(MMC, mmc, 3)					\
 	"bootcmd_mmc_auto="						\
 		"if test ${mmc_bootdev} -eq 1; then "			\
+			"run bootcmd_mmc3; "				\
+			"run bootcmd_mmc2; "				\
 			"run bootcmd_mmc1; "				\
 			"run bootcmd_mmc0; "				\
 		"elif test ${mmc_bootdev} -eq 0; then "			\
@@ -391,9 +394,6 @@ extern int soft_i2c_gpio_scl;
 
 #define BOOT_TARGET_DEVICES_MMC(func) func(MMC_AUTO, mmc_auto, na)
 #else
-#define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
-#endif
-#else
 #define BOOT_TARGET_DEVICES_MMC(func)
 #endif
 
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 32/58] sunxi: A20: Enable DM_MMC
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (30 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 31/58] sunxi: Add mmc 2, 3 bootenv devices Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 33/58] mmc: sunxi: Add mmc, emmc H5/A64 compatible Jagan Teki
                   ` (25 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Enable DM_MMC for Allwinner A20 SoC.

Tested on A20-OLinuXino-LIME2.

Cc: Stefan Mavrodiev <stefan@olimex.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index da7f6b1e95..cac6ed9503 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -191,6 +191,7 @@ config MACH_SUN7I
 	select ARCH_SUPPORT_PSCI
 	select CLK
 	select DRAM_SUN4I
+	select DM_MMC if MMC
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN4I
 	select SUPPORT_SPL
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 33/58] mmc: sunxi: Add mmc, emmc H5/A64 compatible
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (31 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 32/58] sunxi: A20: Enable DM_MMC Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 34/58] sunxi: H3_H5: Enable DM_MMC Jagan Teki
                   ` (24 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Added H5, A64 compatible for mmc and emmc.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/mmc/sunxi_mmc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index 3011ec9498..5191a3e3dd 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -697,6 +697,8 @@ static const struct udevice_id sunxi_mmc_ids[] = {
 	{ .compatible = "allwinner,sun4i-a10-mmc" },
 	{ .compatible = "allwinner,sun5i-a13-mmc" },
 	{ .compatible = "allwinner,sun7i-a20-mmc" },
+	{ .compatible = "allwinner,sun50i-a64-mmc" },
+	{ .compatible = "allwinner,sun50i-a64-emmc" },
 	{ }
 };
 
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 34/58] sunxi: H3_H5: Enable DM_MMC
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (32 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 33/58] mmc: sunxi: Add mmc, emmc H5/A64 compatible Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 35/58] sunxi: A64: " Jagan Teki
                   ` (23 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Enable DM_MMC for Allwinner H3/H5 SoCs.

Tested on
H3: BPI-M2+
H5: Orangepi pc2, prime, zero+2

Tested-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index cac6ed9503..2388718209 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -134,6 +134,7 @@ config MACH_SUNXI_H3_H5
 	bool
 	select CLK
 	select DM_I2C
+	select DM_MMC if MMC
 	select PHY_SUN4I_USB
 	select SUNXI_DE2
 	select SUNXI_DRAM_DW
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 35/58] sunxi: A64: Enable DM_MMC
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (33 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 34/58] sunxi: H3_H5: Enable DM_MMC Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 36/58] mmc: sunxi: Add A83T emmc compatible Jagan Teki
                   ` (22 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Enable DM_MMC for Allwinner A64 SoCs.

Tested on BPI-M64, Amarula A64-Relic

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 2388718209..14cbc51040 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -285,6 +285,7 @@ config MACH_SUN50I
 	select ARM64
 	select CLK
 	select DM_I2C
+	select DM_MMC if MMC
 	select PHY_SUN4I_USB
 	select SUNXI_DE2
 	select SUNXI_GEN_SUN6I
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 36/58] mmc: sunxi: Add A83T emmc compatible
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (34 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 35/58] sunxi: A64: " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 37/58] sunxi: A83T: Enable DM_MMC Jagan Teki
                   ` (21 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Add emmc compatible for A83T SoC.

Cc: VishnuPatekar <vishnupatekar0510@gmail.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/mmc/sunxi_mmc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
index 5191a3e3dd..229a7b2811 100644
--- a/drivers/mmc/sunxi_mmc.c
+++ b/drivers/mmc/sunxi_mmc.c
@@ -697,6 +697,7 @@ static const struct udevice_id sunxi_mmc_ids[] = {
 	{ .compatible = "allwinner,sun4i-a10-mmc" },
 	{ .compatible = "allwinner,sun5i-a13-mmc" },
 	{ .compatible = "allwinner,sun7i-a20-mmc" },
+	{ .compatible = "allwinner,sun8i-a83t-emmc" },
 	{ .compatible = "allwinner,sun50i-a64-mmc" },
 	{ .compatible = "allwinner,sun50i-a64-emmc" },
 	{ }
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 37/58] sunxi: A83T: Enable DM_MMC
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (35 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 36/58] mmc: sunxi: Add A83T emmc compatible Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 38/58] sunxi: V40: " Jagan Teki
                   ` (20 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Enable DM_MMC for Allwinner A83T SoC.

Tested on BPI-M3.

Cc: VishnuPatekar <vishnupatekar0510@gmail.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 14cbc51040..b6287fc00e 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -230,6 +230,7 @@ config MACH_SUN8I_A83T
 	bool "sun8i (Allwinner A83T)"
 	select CPU_V7A
 	select CLK
+	select DM_MMC if MMC
 	select DRAM_SUN8I_A83T
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN6I
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 38/58] sunxi: V40: Enable DM_MMC
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (36 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 37/58] sunxi: A83T: Enable DM_MMC Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 39/58] sunxi: H6: " Jagan Teki
                   ` (19 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Enable DM_MMC for Allwinner V40 SoC.

Tested on BPI-M2 Ultra, BPI-M2 Berry.

Cc: Lothar Felten <lothar.felten@gmail.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index b6287fc00e..2828a33572 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -254,6 +254,7 @@ config MACH_SUN8I_R40
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
 	select CLK
+	select DM_MMC if MMC
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
 	select SUNXI_DRAM_DW
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 39/58] sunxi: H6: Enable DM_MMC
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (37 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 38/58] sunxi: V40: " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 40/58] sunxi: A13/A31: " Jagan Teki
                   ` (18 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Enable DM_MMC for Allwinner H6 SoC.

Tested-by: Jagan Teki <jagan@amarulasolutions.com> # Opi-1+
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 2828a33572..dd973cc821 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -309,6 +309,7 @@ config MACH_SUN50I_H6
 	bool "sun50i (Allwinner H6)"
 	select ARM64
 	select CLK
+	select DM_MMC if MMC
 	select SUPPORT_SPL
 	select FIT
 	select SPL_LOAD_FIT
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 40/58] sunxi: A13/A31: Enable DM_MMC
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (38 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 39/58] sunxi: H6: " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 41/58] sunxi: A23/A33/V3S: " Jagan Teki
                   ` (17 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Enable DM_MMC for Allwinner A13/A31 SoC.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index dd973cc821..593999391a 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -164,6 +164,7 @@ config MACH_SUN5I
 	select CLK
 	select ARM_CORTEX_CPU_IS_UP
 	select DRAM_SUN4I
+	select DM_MMC if MMC
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN4I
 	select SUPPORT_SPL
@@ -177,6 +178,7 @@ config MACH_SUN6I
 	select ARCH_SUPPORT_PSCI
 	select CLK
 	select DRAM_SUN6I
+	select DM_MMC if MMC
 	select PHY_SUN4I_USB
 	select SUN6I_P2WI
 	select SUN6I_PRCM
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 41/58] sunxi: A23/A33/V3S: Enable DM_MMC
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (39 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 40/58] sunxi: A13/A31: " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 42/58] clk: sunxi: Implement SPI clocks Jagan Teki
                   ` (16 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Enable DM_MMC for Allwinner A23/A33/V3S SoC.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 arch/arm/mach-sunxi/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 593999391a..14d80d19c8 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -207,6 +207,7 @@ config MACH_SUN8I_A23
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
 	select CLK
+	select DM_MMC if MMC
 	select DRAM_SUN8I_A23
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN6I
@@ -221,6 +222,7 @@ config MACH_SUN8I_A33
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
 	select CLK
+	select DM_MMC if MMC
 	select DRAM_SUN8I_A33
 	select PHY_SUN4I_USB
 	select SUNXI_GEN_SUN6I
@@ -269,6 +271,7 @@ config MACH_SUN8I_V3S
 	select CPU_V7_HAS_VIRT
 	select ARCH_SUPPORT_PSCI
 	select CLK
+	select DM_MMC if MMC
 	select SUNXI_GEN_SUN6I
 	select SUNXI_DRAM_DW
 	select SUNXI_DRAM_DW_16BIT
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 42/58] clk: sunxi: Implement SPI clocks
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (40 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 41/58] sunxi: A23/A33/V3S: " Jagan Teki
@ 2018-08-19 13:56 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 43/58] clk: sunxi: Implement SPI resets Jagan Teki
                   ` (15 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:56 UTC (permalink / raw)
  To: u-boot

Implement SPI AHB and MOD clocks for all Allwinner SoC
clock drivers via clock map descriptor table.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/clk_a10.c  | 9 +++++++++
 drivers/clk/sunxi/clk_a10s.c | 7 +++++++
 drivers/clk/sunxi/clk_a31.c  | 9 +++++++++
 drivers/clk/sunxi/clk_a64.c  | 5 +++++
 drivers/clk/sunxi/clk_h3.c   | 5 +++++
 drivers/clk/sunxi/clk_v3s.c  | 3 +++
 6 files changed, 38 insertions(+)

diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
index 55176bc174..ee499c402a 100644
--- a/drivers/clk/sunxi/clk_a10.c
+++ b/drivers/clk/sunxi/clk_a10.c
@@ -22,12 +22,21 @@ static struct ccu_clk_map a10_clks[] = {
 	[CLK_AHB_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_AHB_MMC3]		= { 0x060, BIT(11), NULL },
+	[CLK_AHB_SPI0]		= { 0x060, BIT(20), NULL },
+	[CLK_AHB_SPI1]		= { 0x060, BIT(21), NULL },
+	[CLK_AHB_SPI2]		= { 0x060, BIT(22), NULL },
+	[CLK_AHB_SPI3]		= { 0x060, BIT(23), NULL },
 
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC3]		= { 0x094, BIT(31), &mmc_clk_set_rate },
 
+	[CLK_SPI0]		= { 0x0a0, BIT(31), NULL },
+	[CLK_SPI1]		= { 0x0a4, BIT(31), NULL },
+	[CLK_SPI2]		= { 0x0a8, BIT(31), NULL },
+	[CLK_SPI3]		= { 0x0d4, BIT(31), NULL },
+
 	[CLK_USB_OHCI0]		= { 0x0cc, BIT(6), NULL },
 	[CLK_USB_OHCI1]		= { 0x0cc, BIT(7), NULL },
 	[CLK_USB_PHY]		= { 0x0cc, BIT(8), NULL },
diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
index fbac0ad751..bca248f59f 100644
--- a/drivers/clk/sunxi/clk_a10s.c
+++ b/drivers/clk/sunxi/clk_a10s.c
@@ -19,6 +19,9 @@ static struct ccu_clk_map a10s_clks[] = {
 	[CLK_AHB_MMC0]		= { 0x060, BIT(8), NULL },
 	[CLK_AHB_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_AHB_SPI0]		= { 0x060, BIT(20), NULL },
+	[CLK_AHB_SPI1]		= { 0x060, BIT(21), NULL },
+	[CLK_AHB_SPI2]		= { 0x060, BIT(22), NULL },
 
 #ifdef CONFIG_MMC
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
@@ -26,6 +29,10 @@ static struct ccu_clk_map a10s_clks[] = {
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
 #endif
 
+	[CLK_SPI0]		= { 0x0a0, BIT(31), NULL },
+	[CLK_SPI1]		= { 0x0a4, BIT(31), NULL },
+	[CLK_SPI2]		= { 0x0a8, BIT(31), NULL },
+
 	[CLK_USB_OHCI]		= { 0x0cc, BIT(6), NULL },
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index 15076d0e72..1fa77e1272 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -17,6 +17,10 @@ static struct ccu_clk_map a31_clks[] = {
 	[CLK_AHB1_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_AHB1_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_AHB1_MMC3]		= { 0x060, BIT(12), NULL },
+	[CLK_AHB1_SPI0]		= { 0x060, BIT(20), NULL },
+	[CLK_AHB1_SPI1]		= { 0x060, BIT(21), NULL },
+	[CLK_AHB1_SPI2]		= { 0x060, BIT(22), NULL },
+	[CLK_AHB1_SPI3]		= { 0x060, BIT(23), NULL },
 	[CLK_AHB1_OTG]		= { 0x060, BIT(24), NULL },
 	[CLK_AHB1_EHCI0]	= { 0x060, BIT(26), NULL },
 	[CLK_AHB1_EHCI1]	= { 0x060, BIT(27), NULL },
@@ -29,6 +33,11 @@ static struct ccu_clk_map a31_clks[] = {
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC3]		= { 0x094, BIT(31), &mmc_clk_set_rate },
 
+	[CLK_SPI0]		= { 0x0a0, BIT(31), NULL },
+	[CLK_SPI1]		= { 0x0a4, BIT(31), NULL },
+	[CLK_SPI2]		= { 0x0a8, BIT(31), NULL },
+	[CLK_SPI3]		= { 0x0ac, BIT(31), NULL },
+
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
 	[CLK_USB_PHY2]		= { 0x0cc, BIT(10), NULL },
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index 9ef9b606d2..aa2e69d0a3 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -16,6 +16,8 @@ static struct ccu_clk_map a64_clks[] = {
 	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
 	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_BUS_SPI0]		= { 0x060, BIT(20), NULL },
+	[CLK_BUS_SPI1]		= { 0x060, BIT(21), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(23), NULL },
 	[CLK_BUS_EHCI0]		= { 0x060, BIT(24), NULL },
 	[CLK_BUS_EHCI1]		= { 0x060, BIT(25), NULL },
@@ -26,6 +28,9 @@ static struct ccu_clk_map a64_clks[] = {
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
 
+	[CLK_SPI0]		= { 0x0a0, BIT(31), NULL },
+	[CLK_SPI1]		= { 0x0a4, BIT(31), NULL },
+
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
 	[CLK_USB_HSIC]		= { 0x0cc, BIT(10), NULL },
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index ad15aaae67..386289b654 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -16,6 +16,8 @@ static struct ccu_clk_map h3_clks[] = {
 	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
 	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_BUS_SPI0]		= { 0x060, BIT(20), NULL },
+	[CLK_BUS_SPI1]		= { 0x060, BIT(21), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(23), NULL },
 	[CLK_BUS_EHCI0]		= { 0x060, BIT(24), NULL },
 	[CLK_BUS_EHCI1]		= { 0x060, BIT(25), NULL },
@@ -30,6 +32,9 @@ static struct ccu_clk_map h3_clks[] = {
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
 
+	[CLK_SPI0]		= { 0x0a0, BIT(31), NULL },
+	[CLK_SPI1]		= { 0x0a4, BIT(31), NULL },
+
 	[CLK_USB_PHY0]		= { 0x0cc, BIT(8), NULL },
 	[CLK_USB_PHY1]		= { 0x0cc, BIT(9), NULL },
 	[CLK_USB_PHY2]		= { 0x0cc, BIT(10), NULL },
diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c
index 6eeec201a2..1cca57e065 100644
--- a/drivers/clk/sunxi/clk_v3s.c
+++ b/drivers/clk/sunxi/clk_v3s.c
@@ -16,12 +16,15 @@ static struct ccu_clk_map v3s_clks[] = {
 	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
 	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_BUS_SPI0]		= { 0x060, BIT(20), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
 
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
 
+	[CLK_SPI0]		= { 0x0a0, BIT(31), NULL },
+
 	[CLK_USB_PHY0]          = { 0x0cc, BIT(8), NULL },
 };
 
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 43/58] clk: sunxi: Implement SPI resets
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (41 preceding siblings ...)
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 42/58] clk: sunxi: Implement SPI clocks Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 44/58] spi: sun4i: Add CLK support Jagan Teki
                   ` (14 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Implement SPI resets for all relevant Allwinner SoC
clock drivers via reset map descriptor table.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/clk_a31.c | 4 ++++
 drivers/clk/sunxi/clk_a64.c | 2 ++
 drivers/clk/sunxi/clk_h3.c  | 2 ++
 drivers/clk/sunxi/clk_v3s.c | 1 +
 4 files changed, 9 insertions(+)

diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index 1fa77e1272..a5c6628c63 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -55,6 +55,10 @@ static struct ccu_reset_map a31_resets[] = {
 	[RST_AHB1_MMC1]		= { 0x2c0, BIT(9) },
 	[RST_AHB1_MMC2]		= { 0x2c0, BIT(10) },
 	[RST_AHB1_MMC3]		= { 0x2c0, BIT(11) },
+	[RST_AHB1_SPI0]		= { 0x2c0, BIT(20) },
+	[RST_AHB1_SPI1]		= { 0x2c0, BIT(21) },
+	[RST_AHB1_SPI2]		= { 0x2c0, BIT(22) },
+	[RST_AHB1_SPI3]		= { 0x2c0, BIT(23) },
 	[RST_AHB1_OTG]		= { 0x2c0, BIT(24) },
 	[RST_AHB1_EHCI0]	= { 0x2c0, BIT(26) },
 	[RST_AHB1_EHCI1]	= { 0x2c0, BIT(27) },
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index aa2e69d0a3..218d4f09ea 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -47,6 +47,8 @@ static struct ccu_reset_map a64_resets[] = {
 	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
 	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
 	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
+	[RST_BUS_SPI0]		= { 0x2c0, BIT(20) },
+	[RST_BUS_SPI1]		= { 0x2c0, BIT(21) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(23) },
 	[RST_BUS_EHCI0]		= { 0x2c0, BIT(24) },
 	[RST_BUS_EHCI1]		= { 0x2c0, BIT(25) },
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index 386289b654..f610cee745 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -54,6 +54,8 @@ static struct ccu_reset_map h3_resets[] = {
 	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
 	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
 	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
+	[RST_BUS_SPI0]		= { 0x2c0, BIT(20) },
+	[RST_BUS_SPI1]		= { 0x2c0, BIT(21) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(23) },
 	[RST_BUS_EHCI0]		= { 0x2c0, BIT(24) },
 	[RST_BUS_EHCI1]		= { 0x2c0, BIT(25) },
diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c
index 1cca57e065..ae4f6ee066 100644
--- a/drivers/clk/sunxi/clk_v3s.c
+++ b/drivers/clk/sunxi/clk_v3s.c
@@ -34,6 +34,7 @@ static struct ccu_reset_map v3s_resets[] = {
 	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
 	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
 	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
+	[RST_BUS_SPI0]		= { 0x2c0, BIT(20) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
 };
 
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 44/58] spi: sun4i: Add CLK support
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (42 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 43/58] clk: sunxi: Implement SPI resets Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 45/58] spi: Add Allwinner A31 SPI driver Jagan Teki
                   ` (13 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Add CLK support to enable AHB and MOD SPI clocks
on sun4i_spi driver.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/spi/sun4i_spi.c | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/sun4i_spi.c b/drivers/spi/sun4i_spi.c
index b86b5a00ad..3be80bb39f 100644
--- a/drivers/spi/sun4i_spi.c
+++ b/drivers/spi/sun4i_spi.c
@@ -19,6 +19,7 @@
  */
 
 #include <common.h>
+#include <clk.h>
 #include <dm.h>
 #include <spi.h>
 #include <errno.h>
@@ -238,13 +239,36 @@ static int sun4i_spi_parse_pins(struct udevice *dev)
 	return 0;
 }
 
-static inline void sun4i_spi_enable_clock(void)
+static inline int sun4i_spi_enable_clock(struct udevice *dev)
 {
-	struct sunxi_ccm_reg *const ccm =
-		(struct sunxi_ccm_reg *const)SUNXI_CCM_BASE;
+	struct clk ahb_clk, mod_clk;
+	int ret;
+
+	ret = clk_get_by_name(dev, "ahb", &ahb_clk);
+	if (ret) {
+		dev_err(dev, "falied to get ahb clock\n");
+		return ret;
+	}
+
+	ret = clk_get_by_name(dev, "mod", &mod_clk);
+	if (ret) {
+		dev_err(dev, "falied to get mod clock\n");
+		return ret;
+	}
+
+	ret = clk_enable(&ahb_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable ahb clock\n");
+		return ret;
+	}
+
+	ret = clk_enable(&mod_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable mod clock\n");
+		return ret;
+	}
 
-	setbits_le32(&ccm->ahb_gate0, (1 << AHB_GATE_OFFSET_SPI0));
-	writel((1 << 31), &ccm->spi0_clk_cfg);
+	return 0;
 }
 
 static int sun4i_spi_ofdata_to_platdata(struct udevice *bus)
@@ -267,8 +291,12 @@ static int sun4i_spi_probe(struct udevice *bus)
 {
 	struct sun4i_spi_platdata *plat = dev_get_platdata(bus);
 	struct sun4i_spi_priv *priv = dev_get_priv(bus);
+	int ret;
+
+	ret = sun4i_spi_enable_clock(bus);
+	if (ret)
+		return ret;
 
-	sun4i_spi_enable_clock();
 	sun4i_spi_parse_pins(bus);
 
 	priv->regs = (struct sun4i_spi_regs *)(uintptr_t)plat->base_addr;
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 45/58] spi: Add Allwinner A31 SPI driver
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (43 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 44/58] spi: sun4i: Add CLK support Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-20 11:18   ` Maxime Ripard
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 46/58] clk: sunxi: Implement UART clocks Jagan Teki
                   ` (12 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Add Allwinner sun6i SPI driver for A31, H3/H5 an A64.

Tested-by: Fahad Sadah <fahad@sadah.uk>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/spi/Kconfig     |   6 +
 drivers/spi/Makefile    |   1 +
 drivers/spi/sun6i_spi.c | 475 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 482 insertions(+)
 create mode 100644 drivers/spi/sun6i_spi.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index dcd719ff0a..671658dddc 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -179,6 +179,12 @@ config SUN4I_SPI
 	help
 	  SPI driver for Allwinner sun4i, sun5i and sun7i SoCs
 
+config SUN6I_SPI
+	bool "Allwinner A31 SPI controller"
+	depends on ARCH_SUNXI
+	help
+	  This enables using the SPI controller on the Allwinner A31 SoCs.
+
 config TEGRA114_SPI
 	bool "nVidia Tegra114 SPI driver"
 	help
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 728e30c538..6e60091bc1 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_SH_SPI) += sh_spi.o
 obj-$(CONFIG_SH_QSPI) += sh_qspi.o
 obj-$(CONFIG_STM32_QSPI) += stm32_qspi.o
 obj-$(CONFIG_SUN4I_SPI) += sun4i_spi.o
+obj-$(CONFIG_SUN6I_SPI) += sun6i_spi.o
 obj-$(CONFIG_TEGRA114_SPI) += tegra114_spi.o
 obj-$(CONFIG_TEGRA20_SFLASH) += tegra20_sflash.o
 obj-$(CONFIG_TEGRA20_SLINK) += tegra20_slink.o
diff --git a/drivers/spi/sun6i_spi.c b/drivers/spi/sun6i_spi.c
new file mode 100644
index 0000000000..236ed86a25
--- /dev/null
+++ b/drivers/spi/sun6i_spi.c
@@ -0,0 +1,475 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <spi.h>
+#include <errno.h>
+#include <fdt_support.h>
+#include <reset.h>
+#include <wait_bit.h>
+
+#include <asm/bitops.h>
+#include <asm/gpio.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define SUN6I_FIFO_DEPTH			128
+#define SUN8I_FIFO_DEPTH			64
+
+#define SUN6I_GBL_CTL_BUS_ENABLE		BIT(0)
+#define SUN6I_GBL_CTL_MASTER			BIT(1)
+#define SUN6I_GBL_CTL_TP			BIT(7)
+#define SUN6I_GBL_CTL_RST			BIT(31)
+
+#define SUN6I_TFR_CTL_CPHA			BIT(0)
+#define SUN6I_TFR_CTL_CPOL			BIT(1)
+#define SUN6I_TFR_CTL_SPOL			BIT(2)
+#define SUN6I_TFR_CTL_CS_MASK			0x30
+#define SUN6I_TFR_CTL_CS(cs)			(((cs) << 4) & SUN6I_TFR_CTL_CS_MASK)
+#define SUN6I_TFR_CTL_CS_MANUAL			BIT(6)
+#define SUN6I_TFR_CTL_CS_LEVEL			BIT(7)
+#define SUN6I_TFR_CTL_DHB			BIT(8)
+#define SUN6I_TFR_CTL_FBS			BIT(12)
+#define SUN6I_TFR_CTL_XCH_MASK			0x80000000
+#define SUN6I_TFR_CTL_XCH			BIT(31)
+
+#define SUN6I_FIFO_CTL_RF_RDY_TRIG_LEVEL_MASK	0xff
+#define SUN6I_FIFO_CTL_RF_RDY_TRIG_LEVEL_BITS	0
+#define SUN6I_FIFO_CTL_RF_RST			BIT(15)
+#define SUN6I_FIFO_CTL_TF_ERQ_TRIG_LEVEL_MASK	0xff
+#define SUN6I_FIFO_CTL_TF_ERQ_TRIG_LEVEL_BITS	16
+#define SUN6I_FIFO_CTL_TF_RST			BIT(31)
+
+#define SUN6I_CLK_CTL_CDR2_MASK			0xff
+#define SUN6I_CLK_CTL_CDR2(div)			(((div) & SUN6I_CLK_CTL_CDR2_MASK) << 0)
+#define SUN6I_CLK_CTL_CDR1_MASK			0xf
+#define SUN6I_CLK_CTL_CDR1(div)			(((div) & SUN6I_CLK_CTL_CDR1_MASK) << 8)
+#define SUN6I_CLK_CTL_DRS			BIT(12)
+
+#define SUN6I_MAX_XFER_SIZE			0xffffff
+#define SUN6I_BURST_CNT(cnt)			((cnt) & SUN6I_MAX_XFER_SIZE)
+#define SUN6I_XMIT_CNT(cnt)			((cnt) & SUN6I_MAX_XFER_SIZE)
+#define SUN6I_BURST_CTL_CNT_STC(cnt)		((cnt) & SUN6I_MAX_XFER_SIZE)
+
+#define SUN6I_SPI_MAX_RATE	24000000
+#define SUN6I_SPI_MIN_RATE	3000
+#define SUN6I_SPI_DEFAULT_RATE	1000000
+#define SUN6I_SPI_TIMEOUT_US	1000000
+
+/* sun6i spi register set */
+struct sun6i_spi_regs {
+	u32 res1;	/* 0x00 */
+	u32 gblctl;	/* 0x04 */
+	u32 tfrctl;	/* 0x08 */
+	u32 res2;	/* 0x0c */
+	u32 intctl;	/* 0x10 */
+	u32 intsta;	/* 0x14 */
+	u32 fifoctl;	/* 0x18 */
+	u32 fifosta;	/* 0x1c */
+	u32 res3;	/* 0x20 */
+	u32 clkctl;	/* 0x24 */
+	u32 res4[2];	/* 0x28 */
+	u32 bc;		/* 0x30 */
+	u32 tc;		/* 0x34 */
+	u32 bctlc;	/* 0x38 */
+	u32 res5[113];	/* 0x3c */
+	u32 txdata;	/* 0x200 */
+	u32 res6[63];	/* 0x204 */
+	u32 rxdata;	/* 0x300 */
+};
+
+struct sun6i_spi_platdata {
+	u32 base_addr;
+	u32 max_hz;
+};
+
+struct sun6i_spi_priv {
+	struct sun6i_spi_regs *regs;
+	u32 freq;
+	u32 mode;
+	u32 fifo_depth;
+
+	const u8 *tx_buf;
+	u8 *rx_buf;
+};
+
+static inline void sun6i_spi_drain_fifo(struct sun6i_spi_priv *priv, int len)
+{
+	u8 byte;
+
+	while (len--) {
+		byte = readb(&priv->regs->rxdata);
+		*priv->rx_buf++ = byte;
+	}
+}
+
+static inline void sun6i_spi_fill_fifo(struct sun6i_spi_priv *priv, int len)
+{
+	u8 byte;
+
+	while (len--) {
+		byte = priv->tx_buf ? *priv->tx_buf++ : 0;
+		writeb(byte, &priv->regs->txdata);
+	}
+}
+
+static void sun6i_spi_set_cs(struct udevice *bus, u8 cs, bool enable)
+{
+	struct sun6i_spi_priv *priv = dev_get_priv(bus);
+	u32 reg;
+
+	reg = readl(&priv->regs->tfrctl);
+	reg &= ~SUN6I_TFR_CTL_CS_MASK;
+	reg |= SUN6I_TFR_CTL_CS(cs);
+
+	if (enable)
+		reg &= ~SUN6I_TFR_CTL_CS_LEVEL;
+	else
+		reg |= SUN6I_TFR_CTL_CS_LEVEL;
+
+	writel(reg, &priv->regs->tfrctl);
+}
+
+static int sun6i_spi_parse_pins(struct udevice *dev)
+{
+	const void *fdt = gd->fdt_blob;
+	const char *pin_name;
+	const fdt32_t *list;
+	u32 phandle;
+	int drive, pull = 0, pin, i;
+	int offset;
+	int size;
+
+	list = fdt_getprop(fdt, dev_of_offset(dev), "pinctrl-0", &size);
+	if (!list) {
+		printf("WARNING: sun6i_spi: cannot find pinctrl-0 node\n");
+		return -EINVAL;
+	}
+
+	while (size) {
+		phandle = fdt32_to_cpu(*list++);
+		size -= sizeof(*list);
+
+		offset = fdt_node_offset_by_phandle(fdt, phandle);
+		if (offset < 0)
+			return offset;
+
+		drive = fdt_getprop_u32_default_node(fdt, offset, 0,
+						     "drive-strength", 0);
+		if (drive) {
+			if (drive <= 10)
+				drive = 0;
+			else if (drive <= 20)
+				drive = 1;
+			else if (drive <= 30)
+				drive = 2;
+			else
+				drive = 3;
+		} else {
+			drive = fdt_getprop_u32_default_node(fdt, offset, 0,
+							     "allwinner,drive",
+							      0);
+			drive = min(drive, 3);
+		}
+
+		if (fdt_get_property(fdt, offset, "bias-disable", NULL))
+			pull = 0;
+		else if (fdt_get_property(fdt, offset, "bias-pull-up", NULL))
+			pull = 1;
+		else if (fdt_get_property(fdt, offset, "bias-pull-down", NULL))
+			pull = 2;
+		else
+			pull = fdt_getprop_u32_default_node(fdt, offset, 0,
+							    "allwinner,pull",
+							     0);
+		pull = min(pull, 2);
+
+		for (i = 0; ; i++) {
+			pin_name = fdt_stringlist_get(fdt, offset,
+						      "pins", i, NULL);
+			if (!pin_name) {
+				pin_name = fdt_stringlist_get(fdt, offset,
+							      "allwinner,pins",
+							       i, NULL);
+				if (!pin_name)
+					break;
+			}
+
+			pin = name_to_gpio(pin_name);
+			if (pin < 0)
+				break;
+
+			sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SPI0);
+			sunxi_gpio_set_drv(pin, drive);
+			sunxi_gpio_set_pull(pin, pull);
+		}
+	}
+	return 0;
+}
+
+static inline int sun6i_spi_enable_ccu(struct udevice *dev)
+{
+	struct clk ahb_clk, mod_clk;
+	struct reset_ctl reset;
+	int ret;
+
+	ret = clk_get_by_name(dev, "ahb", &ahb_clk);
+	if (ret) {
+		dev_err(dev, "failed to get ahb clock\n");
+		return ret;
+	}
+
+	ret = clk_get_by_name(dev, "mod", &mod_clk);
+	if (ret) {
+		dev_err(dev, "failed to get mod clock\n");
+		return ret;
+	}
+
+	ret = reset_get_by_index(dev, 0, &reset);
+	if (ret) {
+		dev_err(dev, "failed to get reset\n");
+		return ret;
+	}
+
+	ret = clk_enable(&ahb_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable ahb clock\n");
+		return ret;
+	}
+
+	ret = clk_enable(&mod_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable mod clock\n");
+		return ret;
+	}
+
+	ret = reset_deassert(&reset);
+	if (ret) {
+		dev_err(dev, "failed to deassert reset\n");
+		return ret;
+	}
+
+	return 0;
+}
+
+static int sun6i_spi_ofdata_to_platdata(struct udevice *bus)
+{
+	struct sun6i_spi_platdata *plat = dev_get_platdata(bus);
+	int node = dev_of_offset(bus);
+
+	plat->base_addr = devfdt_get_addr(bus);
+	plat->max_hz = fdtdec_get_int(gd->fdt_blob, node,
+				      "spi-max-frequency",
+				      SUN6I_SPI_DEFAULT_RATE);
+
+	if (plat->max_hz > SUN6I_SPI_MAX_RATE)
+		plat->max_hz = SUN6I_SPI_MAX_RATE;
+
+	return 0;
+}
+
+static int sun6i_spi_probe(struct udevice *bus)
+{
+	struct sun6i_spi_platdata *plat = dev_get_platdata(bus);
+	struct sun6i_spi_priv *priv = dev_get_priv(bus);
+	int ret;
+
+	ret = sun6i_spi_enable_ccu(bus);
+	if (ret)
+		return ret;
+
+	sun6i_spi_parse_pins(bus);
+
+	priv->regs = (struct sun6i_spi_regs *)(uintptr_t)plat->base_addr;
+	priv->freq = plat->max_hz;
+	priv->fifo_depth = dev_get_driver_data(bus);
+
+	return 0;
+}
+
+static int sun6i_spi_claim_bus(struct udevice *dev)
+{
+	struct sun6i_spi_priv *priv = dev_get_priv(dev->parent);
+
+	writel(SUN6I_GBL_CTL_BUS_ENABLE | SUN6I_GBL_CTL_MASTER |
+	       SUN6I_GBL_CTL_TP, &priv->regs->gblctl);
+	writel(SUN6I_TFR_CTL_CS_MANUAL, &priv->regs->tfrctl);
+
+	return 0;
+}
+
+static int sun6i_spi_release_bus(struct udevice *dev)
+{
+	struct sun6i_spi_priv *priv = dev_get_priv(dev->parent);
+	u32 reg;
+
+	reg = readl(&priv->regs->gblctl);
+	reg &= ~SUN6I_GBL_CTL_BUS_ENABLE;
+	writel(reg, &priv->regs->gblctl);
+
+	return 0;
+}
+
+static int sun6i_spi_xfer(struct udevice *dev, unsigned int bitlen,
+			  const void *dout, void *din, unsigned long flags)
+{
+	struct udevice *bus = dev->parent;
+	struct sun6i_spi_priv *priv = dev_get_priv(bus);
+	struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);
+
+	u32 len = bitlen / 8;
+	u32 reg;
+	u8 nbytes;
+	int ret;
+
+	priv->tx_buf = dout;
+	priv->rx_buf = din;
+
+	if (bitlen % 8) {
+		debug("%s: non byte-aligned SPI transfer.\n", __func__);
+		return -ENAVAIL;
+	}
+
+	if (flags & SPI_XFER_BEGIN)
+		sun6i_spi_set_cs(bus, slave_plat->cs, true);
+
+	/* Reset FIFOs */
+	writel(SUN6I_FIFO_CTL_RF_RST | SUN6I_FIFO_CTL_TF_RST,
+	       &priv->regs->fifoctl);
+
+	while (len) {
+		/* Setup the transfer now... */
+		nbytes = min(len, priv->fifo_depth);
+
+		/* Setup the counters */
+		writel(SUN6I_BURST_CNT(nbytes), &priv->regs->bc);
+		writel(SUN6I_XMIT_CNT(nbytes), &priv->regs->tc);
+		writel(SUN6I_BURST_CTL_CNT_STC(nbytes), &priv->regs->bctlc);
+
+		/* Fill the TX FIFO */
+		sun6i_spi_fill_fifo(priv, nbytes);
+
+		/* Start the transfer */
+		reg = readl(&priv->regs->tfrctl);
+		writel(reg | SUN6I_TFR_CTL_XCH, &priv->regs->tfrctl);
+
+		/* Wait transfer to complete */
+		ret = wait_for_bit_le32(&priv->regs->tfrctl,
+					SUN6I_TFR_CTL_XCH_MASK, false,
+					SUN6I_SPI_TIMEOUT_US, false);
+		if (ret) {
+			printf("ERROR: sun6i_spi: Timeout transferring data\n");
+			sun6i_spi_set_cs(bus, slave_plat->cs, false);
+			return ret;
+		}
+
+		/* Drain the RX FIFO */
+		sun6i_spi_drain_fifo(priv, nbytes);
+
+		len -= nbytes;
+	}
+
+	if (flags & SPI_XFER_END)
+		sun6i_spi_set_cs(bus, slave_plat->cs, false);
+
+	return 0;
+}
+
+static int sun6i_spi_set_speed(struct udevice *dev, uint speed)
+{
+	struct sun6i_spi_platdata *plat = dev_get_platdata(dev);
+	struct sun6i_spi_priv *priv = dev_get_priv(dev);
+	unsigned int div;
+	u32 reg;
+
+	if (speed > plat->max_hz)
+		speed = plat->max_hz;
+
+	if (speed < SUN6I_SPI_MIN_RATE)
+		speed = SUN6I_SPI_MIN_RATE;
+
+	/*
+	 * Setup clock divider.
+	 *
+	 * We have two choices there. Either we can use the clock
+	 * divide rate 1, which is calculated thanks to this formula:
+	 * SPI_CLK = MOD_CLK / (2 ^ cdr)
+	 * Or we can use CDR2, which is calculated with the formula:
+	 * SPI_CLK = MOD_CLK / (2 * (cdr + 1))
+	 * Whether we use the former or the latter is set through the
+	 * DRS bit.
+	 *
+	 * First try CDR2, and if we can't reach the expected
+	 * frequency, fall back to CDR1.
+	 */
+	reg = readl(&priv->regs->clkctl);
+	div = SUN6I_SPI_MAX_RATE / (2 * speed);
+	if (div <= (SUN6I_CLK_CTL_CDR2_MASK + 1)) {
+		if (div > 0)
+			div--;
+
+		reg |= SUN6I_CLK_CTL_CDR2(div) | SUN6I_CLK_CTL_DRS;
+	} else {
+		div = __ilog2(SUN6I_SPI_MAX_RATE) - __ilog2(speed);
+		reg |= SUN6I_CLK_CTL_CDR1(div);
+	}
+
+	writel(reg, &priv->regs->clkctl);
+	priv->freq = speed;
+
+	return 0;
+}
+
+static int sun6i_spi_set_mode(struct udevice *dev, uint mode)
+{
+	struct sun6i_spi_priv *priv = dev_get_priv(dev);
+	u32 reg;
+
+	reg = readl(&priv->regs->tfrctl);
+	reg &= ~(SUN6I_TFR_CTL_CPOL | SUN6I_TFR_CTL_CPHA);
+
+	if (mode & SPI_CPOL)
+		reg |= SUN6I_TFR_CTL_CPOL;
+
+	if (mode & SPI_CPHA)
+		reg |= SUN6I_TFR_CTL_CPHA;
+
+	priv->mode = mode;
+	writel(reg, &priv->regs->tfrctl);
+
+	return 0;
+}
+
+static const struct dm_spi_ops sun6i_spi_ops = {
+	.claim_bus		= sun6i_spi_claim_bus,
+	.release_bus		= sun6i_spi_release_bus,
+	.xfer			= sun6i_spi_xfer,
+	.set_speed		= sun6i_spi_set_speed,
+	.set_mode		= sun6i_spi_set_mode,
+};
+
+static const struct udevice_id sun6i_spi_ids[] = {
+	{ .compatible = "allwinner,sun6i-a31-spi",
+	  .data = SUN6I_FIFO_DEPTH },
+	{ .compatible = "allwinner,sun8i-h3-spi",
+	  .data = SUN8I_FIFO_DEPTH },
+	{ }
+};
+
+U_BOOT_DRIVER(sun6i_spi) = {
+	.name	= "sun6i_spi",
+	.id	= UCLASS_SPI,
+	.of_match	= sun6i_spi_ids,
+	.ops	= &sun6i_spi_ops,
+	.ofdata_to_platdata	= sun6i_spi_ofdata_to_platdata,
+	.platdata_auto_alloc_size	= sizeof(struct sun6i_spi_platdata),
+	.priv_auto_alloc_size	= sizeof(struct sun6i_spi_priv),
+	.probe	= sun6i_spi_probe,
+};
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 46/58] clk: sunxi: Implement UART clocks
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (44 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 45/58] spi: Add Allwinner A31 SPI driver Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 47/58] clk: sunxi: Implement UART resets Jagan Teki
                   ` (11 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Implement UART clocks for all Allwinner SoC
clock drivers via clock map descriptor table.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/clk_a10.c  | 9 +++++++++
 drivers/clk/sunxi/clk_a10s.c | 5 +++++
 drivers/clk/sunxi/clk_a23.c  | 6 ++++++
 drivers/clk/sunxi/clk_a31.c  | 7 +++++++
 drivers/clk/sunxi/clk_a64.c  | 6 ++++++
 drivers/clk/sunxi/clk_a83t.c | 6 ++++++
 drivers/clk/sunxi/clk_h3.c   | 5 +++++
 drivers/clk/sunxi/clk_r40.c  | 9 +++++++++
 drivers/clk/sunxi/clk_v3s.c  | 4 ++++
 9 files changed, 57 insertions(+)

diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
index ee499c402a..d145d37217 100644
--- a/drivers/clk/sunxi/clk_a10.c
+++ b/drivers/clk/sunxi/clk_a10.c
@@ -27,6 +27,15 @@ static struct ccu_clk_map a10_clks[] = {
 	[CLK_AHB_SPI2]		= { 0x060, BIT(22), NULL },
 	[CLK_AHB_SPI3]		= { 0x060, BIT(23), NULL },
 
+	[CLK_APB1_UART0]	= { 0x06c, BIT(16), NULL },
+	[CLK_APB1_UART1]	= { 0x06c, BIT(17), NULL },
+	[CLK_APB1_UART2]	= { 0x06c, BIT(18), NULL },
+	[CLK_APB1_UART3]	= { 0x06c, BIT(19), NULL },
+	[CLK_APB1_UART4]	= { 0x06c, BIT(20), NULL },
+	[CLK_APB1_UART5]	= { 0x06c, BIT(21), NULL },
+	[CLK_APB1_UART6]	= { 0x06c, BIT(22), NULL },
+	[CLK_APB1_UART7]	= { 0x06c, BIT(23), NULL },
+
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
index bca248f59f..5912043f19 100644
--- a/drivers/clk/sunxi/clk_a10s.c
+++ b/drivers/clk/sunxi/clk_a10s.c
@@ -23,6 +23,11 @@ static struct ccu_clk_map a10s_clks[] = {
 	[CLK_AHB_SPI1]		= { 0x060, BIT(21), NULL },
 	[CLK_AHB_SPI2]		= { 0x060, BIT(22), NULL },
 
+	[CLK_APB1_UART0]	= { 0x06c, BIT(16), NULL },
+	[CLK_APB1_UART1]	= { 0x06c, BIT(17), NULL },
+	[CLK_APB1_UART2]	= { 0x06c, BIT(18), NULL },
+	[CLK_APB1_UART3]	= { 0x06c, BIT(19), NULL },
+
 #ifdef CONFIG_MMC
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
index 183c6275f3..331c79af81 100644
--- a/drivers/clk/sunxi/clk_a23.c
+++ b/drivers/clk/sunxi/clk_a23.c
@@ -20,6 +20,12 @@ static struct ccu_clk_map a23_clks[] = {
 	[CLK_BUS_EHCI]		= { 0x060, BIT(26), NULL },
 	[CLK_BUS_OHCI]		= { 0x060, BIT(29), NULL },
 
+	[CLK_BUS_UART0]		= { 0x06c, BIT(16), NULL },
+	[CLK_BUS_UART1]		= { 0x06c, BIT(17), NULL },
+	[CLK_BUS_UART2]		= { 0x06c, BIT(18), NULL },
+	[CLK_BUS_UART3]		= { 0x06c, BIT(19), NULL },
+	[CLK_BUS_UART4]		= { 0x06c, BIT(20), NULL },
+
 #ifdef CONFIG_MMC
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index a5c6628c63..40803a1d64 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -28,6 +28,13 @@ static struct ccu_clk_map a31_clks[] = {
 	[CLK_AHB1_OHCI1]	= { 0x060, BIT(30), NULL },
 	[CLK_AHB1_OHCI2]	= { 0x060, BIT(31), NULL },
 
+	[CLK_APB2_UART0]	= { 0x06c, BIT(16), NULL },
+	[CLK_APB2_UART1]	= { 0x06c, BIT(17), NULL },
+	[CLK_APB2_UART2]	= { 0x06c, BIT(18), NULL },
+	[CLK_APB2_UART3]	= { 0x06c, BIT(19), NULL },
+	[CLK_APB2_UART4]	= { 0x06c, BIT(20), NULL },
+	[CLK_APB2_UART5]	= { 0x06c, BIT(21), NULL },
+
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index 218d4f09ea..13b506f983 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -24,6 +24,12 @@ static struct ccu_clk_map a64_clks[] = {
 	[CLK_BUS_OHCI0]		= { 0x060, BIT(28), NULL },
 	[CLK_BUS_OHCI1]		= { 0x060, BIT(29), NULL },
 
+	[CLK_BUS_UART0]		= { 0x06c, BIT(16), NULL },
+	[CLK_BUS_UART1]		= { 0x06c, BIT(17), NULL },
+	[CLK_BUS_UART2]		= { 0x06c, BIT(18), NULL },
+	[CLK_BUS_UART3]		= { 0x06c, BIT(19), NULL },
+	[CLK_BUS_UART4]		= { 0x06c, BIT(20), NULL },
+
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c
index 47b7672e7f..5c1235fa7b 100644
--- a/drivers/clk/sunxi/clk_a83t.c
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -21,6 +21,12 @@ static struct ccu_clk_map a83t_clks[] = {
 	[CLK_BUS_EHCI1]		= { 0x060, BIT(27), NULL },
 	[CLK_BUS_OHCI0]		= { 0x060, BIT(29), NULL },
 
+	[CLK_BUS_UART0]		= { 0x06c, BIT(16), NULL },
+	[CLK_BUS_UART1]		= { 0x06c, BIT(17), NULL },
+	[CLK_BUS_UART2]		= { 0x06c, BIT(18), NULL },
+	[CLK_BUS_UART3]		= { 0x06c, BIT(19), NULL },
+	[CLK_BUS_UART4]		= { 0x06c, BIT(20), NULL },
+
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index f610cee745..b132ae0a0d 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -28,6 +28,11 @@ static struct ccu_clk_map h3_clks[] = {
 	[CLK_BUS_OHCI2]		= { 0x060, BIT(30), NULL },
 	[CLK_BUS_OHCI3]		= { 0x060, BIT(31), NULL },
 
+	[CLK_BUS_UART0]		= { 0x06c, BIT(16), NULL },
+	[CLK_BUS_UART1]		= { 0x06c, BIT(17), NULL },
+	[CLK_BUS_UART2]		= { 0x06c, BIT(18), NULL },
+	[CLK_BUS_UART3]		= { 0x06c, BIT(19), NULL },
+
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
index 24c26ad3be..1e5b1d10f7 100644
--- a/drivers/clk/sunxi/clk_r40.c
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -25,6 +25,15 @@ static struct ccu_clk_map r40_clks[] = {
 	[CLK_BUS_OHCI1]		= { 0x060, BIT(30), NULL },
 	[CLK_BUS_OHCI2]		= { 0x060, BIT(31), NULL },
 
+	[CLK_BUS_UART0]		= { 0x06c, BIT(16), NULL },
+	[CLK_BUS_UART1]		= { 0x06c, BIT(17), NULL },
+	[CLK_BUS_UART2]		= { 0x06c, BIT(18), NULL },
+	[CLK_BUS_UART3]		= { 0x06c, BIT(19), NULL },
+	[CLK_BUS_UART4]		= { 0x06c, BIT(20), NULL },
+	[CLK_BUS_UART5]		= { 0x06c, BIT(21), NULL },
+	[CLK_BUS_UART6]		= { 0x06c, BIT(22), NULL },
+	[CLK_BUS_UART7]		= { 0x06c, BIT(23), NULL },
+
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c
index ae4f6ee066..c6e57147ee 100644
--- a/drivers/clk/sunxi/clk_v3s.c
+++ b/drivers/clk/sunxi/clk_v3s.c
@@ -19,6 +19,10 @@ static struct ccu_clk_map v3s_clks[] = {
 	[CLK_BUS_SPI0]		= { 0x060, BIT(20), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
 
+	[CLK_BUS_UART0]		= { 0x06c, BIT(16), NULL },
+	[CLK_BUS_UART1]		= { 0x06c, BIT(17), NULL },
+	[CLK_BUS_UART2]		= { 0x06c, BIT(18), NULL },
+
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 47/58] clk: sunxi: Implement UART resets
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (45 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 46/58] clk: sunxi: Implement UART clocks Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 48/58] clk: sunxi: Implement Ethernet clocks Jagan Teki
                   ` (10 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Implement UART resets for all relevant Allwinner SoC
clock drivers via reset map descriptor table.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/clk_a23.c  | 6 ++++++
 drivers/clk/sunxi/clk_a31.c  | 7 +++++++
 drivers/clk/sunxi/clk_a64.c  | 6 ++++++
 drivers/clk/sunxi/clk_a83t.c | 6 ++++++
 drivers/clk/sunxi/clk_h3.c   | 5 +++++
 drivers/clk/sunxi/clk_r40.c  | 9 +++++++++
 drivers/clk/sunxi/clk_v3s.c  | 4 ++++
 7 files changed, 43 insertions(+)

diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
index 331c79af81..268148002b 100644
--- a/drivers/clk/sunxi/clk_a23.c
+++ b/drivers/clk/sunxi/clk_a23.c
@@ -50,6 +50,12 @@ static struct ccu_reset_map a23_resets[] = {
 	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
 	[RST_BUS_EHCI]		= { 0x2c0, BIT(26) },
 	[RST_BUS_OHCI]		= { 0x2c0, BIT(29) },
+
+	[RST_BUS_UART0]		= { 0x2d8, BIT(16) },
+	[RST_BUS_UART1]		= { 0x2d8, BIT(17) },
+	[RST_BUS_UART2]		= { 0x2d8, BIT(18) },
+	[RST_BUS_UART3]		= { 0x2d8, BIT(19) },
+	[RST_BUS_UART4]		= { 0x2d8, BIT(20) },
 };
 
 static const struct ccu_desc sun8i_a23_ccu_desc = {
diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index 40803a1d64..288979a18f 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -72,6 +72,13 @@ static struct ccu_reset_map a31_resets[] = {
 	[RST_AHB1_OHCI0]	= { 0x2c0, BIT(29) },
 	[RST_AHB1_OHCI1]	= { 0x2c0, BIT(30) },
 	[RST_AHB1_OHCI2]	= { 0x2c0, BIT(31) },
+
+	[RST_APB2_UART0]	= { 0x2d8, BIT(16) },
+	[RST_APB2_UART1]	= { 0x2d8, BIT(17) },
+	[RST_APB2_UART2]	= { 0x2d8, BIT(18) },
+	[RST_APB2_UART3]	= { 0x2d8, BIT(19) },
+	[RST_APB2_UART4]	= { 0x2d8, BIT(20) },
+	[RST_APB2_UART5]	= { 0x2d8, BIT(21) },
 };
 
 static const struct ccu_desc sun6i_a31_ccu_desc = {
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index 13b506f983..344cfb59aa 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -60,6 +60,12 @@ static struct ccu_reset_map a64_resets[] = {
 	[RST_BUS_EHCI1]		= { 0x2c0, BIT(25) },
 	[RST_BUS_OHCI0]		= { 0x2c0, BIT(28) },
 	[RST_BUS_OHCI1]		= { 0x2c0, BIT(29) },
+
+	[RST_BUS_UART0]		= { 0x2d8, BIT(16) },
+	[RST_BUS_UART1]		= { 0x2d8, BIT(17) },
+	[RST_BUS_UART2]		= { 0x2d8, BIT(18) },
+	[RST_BUS_UART3]		= { 0x2d8, BIT(19) },
+	[RST_BUS_UART4]		= { 0x2d8, BIT(20) },
 };
 
 static const struct ccu_desc sun50i_a64_ccu_desc = {
diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c
index 5c1235fa7b..cf9455da97 100644
--- a/drivers/clk/sunxi/clk_a83t.c
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -50,6 +50,12 @@ static struct ccu_reset_map a83t_resets[] = {
 	[RST_BUS_EHCI0]		= { 0x2c0, BIT(26) },
 	[RST_BUS_EHCI1]		= { 0x2c0, BIT(27) },
 	[RST_BUS_OHCI0]		= { 0x2c0, BIT(29) },
+
+	[RST_BUS_UART0]		= { 0x2d8, BIT(16) },
+	[RST_BUS_UART1]		= { 0x2d8, BIT(17) },
+	[RST_BUS_UART2]		= { 0x2d8, BIT(18) },
+	[RST_BUS_UART3]		= { 0x2d8, BIT(19) },
+	[RST_BUS_UART4]		= { 0x2d8, BIT(20) },
 };
 
 static const struct ccu_desc sun8i_a83t_ccu_desc = {
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index b132ae0a0d..15d933a6c5 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -70,6 +70,11 @@ static struct ccu_reset_map h3_resets[] = {
 	[RST_BUS_OHCI1]		= { 0x2c0, BIT(29) },
 	[RST_BUS_OHCI2]		= { 0x2c0, BIT(30) },
 	[RST_BUS_OHCI3]		= { 0x2c0, BIT(31) },
+
+	[RST_BUS_UART0]		= { 0x2d8, BIT(16) },
+	[RST_BUS_UART1]		= { 0x2d8, BIT(17) },
+	[RST_BUS_UART2]		= { 0x2d8, BIT(18) },
+	[RST_BUS_UART3]		= { 0x2d8, BIT(19) },
 };
 
 static const struct ccu_desc sun8i_h3_ccu_desc = {
diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
index 1e5b1d10f7..ee699d26ee 100644
--- a/drivers/clk/sunxi/clk_r40.c
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -63,6 +63,15 @@ static struct ccu_reset_map r40_resets[] = {
 	[RST_BUS_OHCI0]		= { 0x2c0, BIT(29) },
 	[RST_BUS_OHCI1]		= { 0x2c0, BIT(30) },
 	[RST_BUS_OHCI2]		= { 0x2c0, BIT(31) },
+
+	[RST_BUS_UART0]		= { 0x2d8, BIT(16) },
+	[RST_BUS_UART1]		= { 0x2d8, BIT(17) },
+	[RST_BUS_UART2]		= { 0x2d8, BIT(18) },
+	[RST_BUS_UART3]		= { 0x2d8, BIT(19) },
+	[RST_BUS_UART4]		= { 0x2d8, BIT(20) },
+	[RST_BUS_UART5]		= { 0x2d8, BIT(21) },
+	[RST_BUS_UART6]		= { 0x2d8, BIT(22) },
+	[RST_BUS_UART7]		= { 0x2d8, BIT(23) },
 };
 
 static const struct ccu_desc sun8i_r40_ccu_desc = {
diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c
index c6e57147ee..87ca0350d8 100644
--- a/drivers/clk/sunxi/clk_v3s.c
+++ b/drivers/clk/sunxi/clk_v3s.c
@@ -40,6 +40,10 @@ static struct ccu_reset_map v3s_resets[] = {
 	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
 	[RST_BUS_SPI0]		= { 0x2c0, BIT(20) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
+
+	[RST_BUS_UART0]		= { 0x2d8, BIT(16) },
+	[RST_BUS_UART1]		= { 0x2d8, BIT(17) },
+	[RST_BUS_UART2]		= { 0x2d8, BIT(18) },
 };
 
 static const struct ccu_desc sun8i_v3s_ccu_desc = {
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 48/58] clk: sunxi: Implement Ethernet clocks
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (46 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 47/58] clk: sunxi: Implement UART resets Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 49/58] clk: sunxi: Implement Ethernet resets Jagan Teki
                   ` (9 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Implement Ethernet clocks for all Allwinner SoCs
clock drivers via clock map descriptor table.

Cc: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/clk_a10.c  | 3 +++
 drivers/clk/sunxi/clk_a10s.c | 1 +
 drivers/clk/sunxi/clk_a31.c  | 1 +
 drivers/clk/sunxi/clk_a64.c  | 1 +
 drivers/clk/sunxi/clk_a83t.c | 1 +
 drivers/clk/sunxi/clk_h3.c   | 1 +
 drivers/clk/sunxi/clk_r40.c  | 2 ++
 7 files changed, 10 insertions(+)

diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
index d145d37217..fc939a313d 100644
--- a/drivers/clk/sunxi/clk_a10.c
+++ b/drivers/clk/sunxi/clk_a10.c
@@ -22,11 +22,14 @@ static struct ccu_clk_map a10_clks[] = {
 	[CLK_AHB_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_AHB_MMC3]		= { 0x060, BIT(11), NULL },
+	[CLK_AHB_EMAC]		= { 0x060, BIT(17), NULL },
 	[CLK_AHB_SPI0]		= { 0x060, BIT(20), NULL },
 	[CLK_AHB_SPI1]		= { 0x060, BIT(21), NULL },
 	[CLK_AHB_SPI2]		= { 0x060, BIT(22), NULL },
 	[CLK_AHB_SPI3]		= { 0x060, BIT(23), NULL },
 
+	[CLK_AHB_GMAC]		= { 0x064, BIT(17), NULL },
+
 	[CLK_APB1_UART0]	= { 0x06c, BIT(16), NULL },
 	[CLK_APB1_UART1]	= { 0x06c, BIT(17), NULL },
 	[CLK_APB1_UART2]	= { 0x06c, BIT(18), NULL },
diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
index 5912043f19..6ce53dc27d 100644
--- a/drivers/clk/sunxi/clk_a10s.c
+++ b/drivers/clk/sunxi/clk_a10s.c
@@ -19,6 +19,7 @@ static struct ccu_clk_map a10s_clks[] = {
 	[CLK_AHB_MMC0]		= { 0x060, BIT(8), NULL },
 	[CLK_AHB_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_AHB_EMAC]		= { 0x060, BIT(17), NULL },
 	[CLK_AHB_SPI0]		= { 0x060, BIT(20), NULL },
 	[CLK_AHB_SPI1]		= { 0x060, BIT(21), NULL },
 	[CLK_AHB_SPI2]		= { 0x060, BIT(22), NULL },
diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index 288979a18f..d7a6b2421f 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -17,6 +17,7 @@ static struct ccu_clk_map a31_clks[] = {
 	[CLK_AHB1_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_AHB1_MMC2]		= { 0x060, BIT(10), NULL },
 	[CLK_AHB1_MMC3]		= { 0x060, BIT(12), NULL },
+	[CLK_AHB1_EMAC]		= { 0x060, BIT(17), NULL },
 	[CLK_AHB1_SPI0]		= { 0x060, BIT(20), NULL },
 	[CLK_AHB1_SPI1]		= { 0x060, BIT(21), NULL },
 	[CLK_AHB1_SPI2]		= { 0x060, BIT(22), NULL },
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index 344cfb59aa..546ddcffa2 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -16,6 +16,7 @@ static struct ccu_clk_map a64_clks[] = {
 	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
 	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_BUS_EMAC]		= { 0x060, BIT(17), NULL },
 	[CLK_BUS_SPI0]		= { 0x060, BIT(20), NULL },
 	[CLK_BUS_SPI1]		= { 0x060, BIT(21), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(23), NULL },
diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c
index cf9455da97..593ce1ac1b 100644
--- a/drivers/clk/sunxi/clk_a83t.c
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -16,6 +16,7 @@ static struct ccu_clk_map a83t_clks[] = {
 	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
 	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_BUS_EMAC]		= { 0x060, BIT(17), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(24), NULL },
 	[CLK_BUS_EHCI0]		= { 0x060, BIT(26), NULL },
 	[CLK_BUS_EHCI1]		= { 0x060, BIT(27), NULL },
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index 15d933a6c5..ff9f294097 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -16,6 +16,7 @@ static struct ccu_clk_map h3_clks[] = {
 	[CLK_BUS_MMC0]		= { 0x060, BIT(8), NULL },
 	[CLK_BUS_MMC1]		= { 0x060, BIT(9), NULL },
 	[CLK_BUS_MMC2]		= { 0x060, BIT(10), NULL },
+	[CLK_BUS_EMAC]		= { 0x060, BIT(17), NULL },
 	[CLK_BUS_SPI0]		= { 0x060, BIT(20), NULL },
 	[CLK_BUS_SPI1]		= { 0x060, BIT(21), NULL },
 	[CLK_BUS_OTG]		= { 0x060, BIT(23), NULL },
diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
index ee699d26ee..e5bddc77ee 100644
--- a/drivers/clk/sunxi/clk_r40.c
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -25,6 +25,8 @@ static struct ccu_clk_map r40_clks[] = {
 	[CLK_BUS_OHCI1]		= { 0x060, BIT(30), NULL },
 	[CLK_BUS_OHCI2]		= { 0x060, BIT(31), NULL },
 
+	[CLK_BUS_GMAC]		= { 0x064, BIT(17), NULL },
+
 	[CLK_BUS_UART0]		= { 0x06c, BIT(16), NULL },
 	[CLK_BUS_UART1]		= { 0x06c, BIT(17), NULL },
 	[CLK_BUS_UART2]		= { 0x06c, BIT(18), NULL },
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 49/58] clk: sunxi: Implement Ethernet resets
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (47 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 48/58] clk: sunxi: Implement Ethernet clocks Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 50/58] net: sunxi_emac: Add CLK support Jagan Teki
                   ` (8 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Implement Ethernet resets for all relevant Allwinner SoC
clock drivers via reset map descriptor table.

Cc: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/clk_a31.c  | 1 +
 drivers/clk/sunxi/clk_a64.c  | 1 +
 drivers/clk/sunxi/clk_a83t.c | 1 +
 drivers/clk/sunxi/clk_h3.c   | 1 +
 drivers/clk/sunxi/clk_r40.c  | 2 ++
 5 files changed, 6 insertions(+)

diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index d7a6b2421f..9023640913 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -63,6 +63,7 @@ static struct ccu_reset_map a31_resets[] = {
 	[RST_AHB1_MMC1]		= { 0x2c0, BIT(9) },
 	[RST_AHB1_MMC2]		= { 0x2c0, BIT(10) },
 	[RST_AHB1_MMC3]		= { 0x2c0, BIT(11) },
+	[RST_AHB1_EMAC]		= { 0x2c0, BIT(17) },
 	[RST_AHB1_SPI0]		= { 0x2c0, BIT(20) },
 	[RST_AHB1_SPI1]		= { 0x2c0, BIT(21) },
 	[RST_AHB1_SPI2]		= { 0x2c0, BIT(22) },
diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c
index 546ddcffa2..b2df499a24 100644
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -54,6 +54,7 @@ static struct ccu_reset_map a64_resets[] = {
 	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
 	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
 	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
+	[RST_BUS_EMAC]		= { 0x2c0, BIT(17) },
 	[RST_BUS_SPI0]		= { 0x2c0, BIT(20) },
 	[RST_BUS_SPI1]		= { 0x2c0, BIT(21) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(23) },
diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c
index 593ce1ac1b..e1780d6729 100644
--- a/drivers/clk/sunxi/clk_a83t.c
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -47,6 +47,7 @@ static struct ccu_reset_map a83t_resets[] = {
 	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
 	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
 	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
+	[RST_BUS_EMAC]		= { 0x2c0, BIT(17) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(24) },
 	[RST_BUS_EHCI0]		= { 0x2c0, BIT(26) },
 	[RST_BUS_EHCI1]		= { 0x2c0, BIT(27) },
diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index ff9f294097..88086580f4 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -60,6 +60,7 @@ static struct ccu_reset_map h3_resets[] = {
 	[RST_BUS_MMC0]		= { 0x2c0, BIT(8) },
 	[RST_BUS_MMC1]		= { 0x2c0, BIT(9) },
 	[RST_BUS_MMC2]		= { 0x2c0, BIT(10) },
+	[RST_BUS_EMAC]		= { 0x2c0, BIT(17) },
 	[RST_BUS_SPI0]		= { 0x2c0, BIT(20) },
 	[RST_BUS_SPI1]		= { 0x2c0, BIT(21) },
 	[RST_BUS_OTG]		= { 0x2c0, BIT(23) },
diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
index e5bddc77ee..cf00cf1011 100644
--- a/drivers/clk/sunxi/clk_r40.c
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -66,6 +66,8 @@ static struct ccu_reset_map r40_resets[] = {
 	[RST_BUS_OHCI1]		= { 0x2c0, BIT(30) },
 	[RST_BUS_OHCI2]		= { 0x2c0, BIT(31) },
 
+	[RST_BUS_GMAC]		= { 0x2c0, BIT(17) },
+
 	[RST_BUS_UART0]		= { 0x2d8, BIT(16) },
 	[RST_BUS_UART1]		= { 0x2d8, BIT(17) },
 	[RST_BUS_UART2]		= { 0x2d8, BIT(18) },
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 50/58] net: sunxi_emac: Add CLK support
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (48 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 49/58] clk: sunxi: Implement Ethernet resets Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 51/58] net: sun8i_emac: Retrieve GMAC clock via 'syscon' phandle Jagan Teki
                   ` (7 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Add CLk support for sunxi_emac to enable AHB_EMAC clock
via CLK framework.

Cc: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/net/sunxi_emac.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
index 8dbd3c50c1..4d152b0ca0 100644
--- a/drivers/net/sunxi_emac.c
+++ b/drivers/net/sunxi_emac.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <clk.h>
 #include <dm.h>
 #include <linux/err.h>
 #include <malloc.h>
@@ -157,6 +158,7 @@ struct sunxi_sramc_regs {
 
 struct emac_eth_dev {
 	struct emac_regs *regs;
+	struct clk clk;
 	struct mii_dev *bus;
 	struct phy_device *phydev;
 	int link_printed;
@@ -500,14 +502,12 @@ static int _sunxi_emac_eth_send(struct emac_eth_dev *priv, void *packet,
 	return 0;
 }
 
-static void sunxi_emac_board_setup(struct emac_eth_dev *priv)
+static int sunxi_emac_board_setup(struct emac_eth_dev *priv)
 {
-	struct sunxi_ccm_reg *const ccm =
-		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
 	struct sunxi_sramc_regs *sram =
 		(struct sunxi_sramc_regs *)SUNXI_SRAMC_BASE;
 	struct emac_regs *regs = priv->regs;
-	int pin;
+	int pin, ret;
 
 	/* Map SRAM to EMAC */
 	setbits_le32(&sram->ctrl1, 0x5 << 2);
@@ -517,10 +517,16 @@ static void sunxi_emac_board_setup(struct emac_eth_dev *priv)
 		sunxi_gpio_set_cfgpin(pin, SUNXI_GPA_EMAC);
 
 	/* Set up clock gating */
-	setbits_le32(&ccm->ahb_gate0, 0x1 << AHB_GATE_OFFSET_EMAC);
+	ret = clk_enable(&priv->clk);
+	if (ret) {
+		dev_err(dev, "failed to enable emac clock\n");
+		return ret;
+	}
 
 	/* Set MII clock */
 	clrsetbits_le32(&regs->mac_mcfg, 0xf << 2, 0xd << 2);
+
+	return 0;
 }
 
 static int sunxi_emac_eth_start(struct udevice *dev)
@@ -557,9 +563,19 @@ static int sunxi_emac_eth_probe(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct emac_eth_dev *priv = dev_get_priv(dev);
+	int ret;
 
 	priv->regs = (struct emac_regs *)pdata->iobase;
-	sunxi_emac_board_setup(priv);
+
+	ret = clk_get_by_index(dev, 0, &priv->clk);
+	if (ret) {
+		dev_err(dev, "falied to get emac clock\n");
+		return ret;
+	}
+
+	ret = sunxi_emac_board_setup(priv);
+	if (ret)
+		return ret;
 
 	return sunxi_emac_init_phy(priv, dev);
 }
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 51/58] net: sun8i_emac: Retrieve GMAC clock via 'syscon' phandle
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (49 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 50/58] net: sunxi_emac: Add CLK support Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 52/58] net: sun8i_emac: Add CLK and RESET support Jagan Teki
                   ` (6 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Unlike other Allwinner SoC's R40 GMAC clock control register
is locate in CCU, but rest located via syscon itself. Since
the phandle property for current code look for 'syscon' and
it will grab the respective ccu or syscon base address based
on DT property defined in respective SoC dtsi.

So, use the existing 'syscon' code even for R40 for retrieving
GMAC clock via CCU and update the register directly in
sun8i_emac_set_syscon instead of writing it separately using
ccm base.

Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Lothar Felten <lothar.felten@gmail.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/net/sun8i_emac.c | 55 ++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 28 deletions(-)

diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index 3ba3a1ff8b..5ee4c2f993 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -278,10 +278,18 @@ static int sun8i_emac_set_syscon(struct emac_eth_dev *priv)
 	int ret;
 	u32 reg;
 
-	reg = readl(priv->sysctl_reg + 0x30);
+	if (priv->variant == R40_GMAC) {
+		/* Select RGMII for R40 */
+		reg = readl(priv->sysctl_reg + 0x164);
+		reg |= CCM_GMAC_CTRL_TX_CLK_SRC_INT_RGMII |
+		       CCM_GMAC_CTRL_GPIT_RGMII |
+		       CCM_GMAC_CTRL_TX_CLK_DELAY(CONFIG_GMAC_TX_DELAY);
 
-	if (priv->variant == R40_GMAC)
+		writel(reg, priv->sysctl_reg + 0x164);
 		return 0;
+	}
+
+	reg = readl(priv->sysctl_reg + 0x30);
 
 	if (priv->variant == H3_EMAC) {
 		ret = sun8i_emac_set_syscon_ephy(priv, &reg);
@@ -647,13 +655,6 @@ static void sun8i_emac_board_setup(struct emac_eth_dev *priv)
 
 		/* De-assert EMAC */
 		setbits_le32(&ccm->ahb_gate1, BIT(AHB_GATE_OFFSET_GMAC));
-
-		/* Select RGMII for R40 */
-		setbits_le32(&ccm->gmac_clk_cfg,
-			     CCM_GMAC_CTRL_TX_CLK_SRC_INT_RGMII |
-			     CCM_GMAC_CTRL_GPIT_RGMII);
-		setbits_le32(&ccm->gmac_clk_cfg,
-			     CCM_GMAC_CTRL_TX_CLK_DELAY(CONFIG_GMAC_TX_DELAY));
 	} else {
 		/* Set clock gating for emac */
 		setbits_le32(&ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_GMAC));
@@ -834,25 +835,23 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
 		return -EINVAL;
 	}
 
-	if (priv->variant != R40_GMAC) {
-		offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "syscon");
-		if (offset < 0) {
-			debug("%s: cannot find syscon node\n", __func__);
-			return -EINVAL;
-		}
-		reg = fdt_getprop(gd->fdt_blob, offset, "reg", NULL);
-		if (!reg) {
-			debug("%s: cannot find reg property in syscon node\n",
-			      __func__);
-			return -EINVAL;
-		}
-		priv->sysctl_reg = fdt_translate_address((void *)gd->fdt_blob,
-							 offset, reg);
-		if (priv->sysctl_reg == FDT_ADDR_T_NONE) {
-			debug("%s: Cannot find syscon base address\n",
-			      __func__);
-			return -EINVAL;
-		}
+	offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "syscon");
+	if (offset < 0) {
+		debug("%s: cannot find syscon node\n", __func__);
+		return -EINVAL;
+	}
+
+	reg = fdt_getprop(gd->fdt_blob, offset, "reg", NULL);
+	if (!reg) {
+		debug("%s: cannot find reg property in syscon node\n",
+		      __func__);
+		return -EINVAL;
+	}
+	priv->sysctl_reg = fdt_translate_address((void *)gd->fdt_blob,
+						 offset, reg);
+	if (priv->sysctl_reg == FDT_ADDR_T_NONE) {
+		debug("%s: Cannot find syscon base address\n", __func__);
+		return -EINVAL;
 	}
 
 	pdata->phy_interface = -1;
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 52/58] net: sun8i_emac: Add CLK and RESET support
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (50 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 51/58] net: sun8i_emac: Retrieve GMAC clock via 'syscon' phandle Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 53/58] clk: Get the CLK by index without device Jagan Teki
                   ` (5 subsequent siblings)
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Add CLK and RESET support for sun8i_emac driver to
enable TX clock and reset pins via CLK and RESET
framework.

Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Lothar Felten <lothar.felten@gmail.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/net/sun8i_emac.c | 56 ++++++++++++++++++++++++++++------------
 1 file changed, 40 insertions(+), 16 deletions(-)

diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index 5ee4c2f993..ad2d390f4e 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -10,6 +10,7 @@
  *
 */
 
+#include <clk.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/gpio.h>
@@ -20,6 +21,7 @@
 #include <malloc.h>
 #include <miiphy.h>
 #include <net.h>
+#include <reset.h>
 #include <dt-bindings/pinctrl/sun4i-a10.h>
 #ifdef CONFIG_DM_GPIO
 #include <asm-generic/gpio.h>
@@ -131,6 +133,8 @@ struct emac_eth_dev {
 	phys_addr_t sysctl_reg;
 	struct phy_device *phydev;
 	struct mii_dev *bus;
+	struct clk tx_clk;
+	struct reset_ctl tx_rst;
 #ifdef CONFIG_DM_GPIO
 	struct gpio_desc reset_gpio;
 #endif
@@ -632,9 +636,24 @@ static int sun8i_eth_write_hwaddr(struct udevice *dev)
 	return _sun8i_write_hwaddr(priv, pdata->enetaddr);
 }
 
-static void sun8i_emac_board_setup(struct emac_eth_dev *priv)
+static int sun8i_emac_board_setup(struct emac_eth_dev *priv)
 {
 	struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+	int ret;
+
+	ret = clk_enable(&priv->tx_clk);
+	if (ret) {
+		dev_err(dev, "failed to enable TX clock\n");
+		return ret;
+	}
+
+	if (reset_valid(&priv->tx_rst)) {
+		ret = reset_deassert(&priv->tx_rst);
+		if (ret) {
+			dev_err(dev, "failed to deassert TX reset\n");
+			return ret;
+		}
+	}
 
 	if (priv->variant == H3_EMAC) {
 		/* Only H3/H5 have clock controls for internal EPHY */
@@ -649,19 +668,7 @@ static void sun8i_emac_board_setup(struct emac_eth_dev *priv)
 		}
 	}
 
-	if (priv->variant == R40_GMAC) {
-		/* Set clock gating for emac */
-		setbits_le32(&ccm->ahb_reset1_cfg, BIT(AHB_RESET_OFFSET_GMAC));
-
-		/* De-assert EMAC */
-		setbits_le32(&ccm->ahb_gate1, BIT(AHB_GATE_OFFSET_GMAC));
-	} else {
-		/* Set clock gating for emac */
-		setbits_le32(&ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_GMAC));
-
-		/* De-assert EMAC */
-		setbits_le32(&ccm->ahb_reset0_cfg, BIT(AHB_RESET_OFFSET_GMAC));
-	}
+	return 0;
 }
 
 #if defined(CONFIG_DM_GPIO)
@@ -787,10 +794,14 @@ static int sun8i_emac_eth_probe(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct emac_eth_dev *priv = dev_get_priv(dev);
+	int ret;
 
 	priv->mac_reg = (void *)pdata->iobase;
 
-	sun8i_emac_board_setup(priv);
+	ret = sun8i_emac_board_setup(priv);
+	if (ret)
+		return ret;
+
 	sun8i_emac_set_syscon(priv);
 
 	sun8i_mdio_init(dev->name, dev);
@@ -819,8 +830,8 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
 	int offset = 0;
 #ifdef CONFIG_DM_GPIO
 	int reset_flags = GPIOD_IS_OUT;
-	int ret = 0;
 #endif
+	int ret;
 
 	pdata->iobase = devfdt_get_addr(dev);
 	if (pdata->iobase == FDT_ADDR_T_NONE) {
@@ -835,6 +846,19 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
 		return -EINVAL;
 	}
 
+	ret = clk_get_by_name(dev, "stmmaceth", &priv->tx_clk);
+	if (ret) {
+		dev_err(dev, "failed to get TX clock\n");
+		return ret;
+	}
+
+	ret = reset_get_by_name_optional(dev, "stmmaceth",
+					 &priv->tx_rst, true);
+	if (ret) {
+		dev_err(dev, "failed to get TX reset\n");
+		return ret;
+	}
+
 	offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "syscon");
 	if (offset < 0) {
 		debug("%s: cannot find syscon node\n", __func__);
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 53/58] clk: Get the CLK by index without device
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (51 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 52/58] net: sun8i_emac: Add CLK and RESET support Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-23 10:45   ` Simon Glass
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 54/58] clk: Use clk_get_by_index_tail() Jagan Teki
                   ` (4 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Getting a CLK by index with device is not straight forward
for some use-cases like handling clock operations for child
node in parent driver. So we need to process the child node
in parent probe via ofnode and process CLK operation for child
without udevice but with ofnode.

So add clk_get_by_index_nodev() and move the common code
in clk_get_by_index_tail() to use for clk_get_by_index()

Cc: Simon Glass <sjg@chromium.org>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/clk-uclass.c | 61 +++++++++++++++++++++++++++++++++++++++-
 include/clk.h            | 15 ++++++++++
 2 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 2b15978e14..8bb41a4de5 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -98,9 +98,68 @@ static int clk_get_by_indexed_prop(struct udevice *dev, const char *prop_name,
 	return clk_request(dev_clk, clk);
 }
 
+static int clk_get_by_index_tail(int ret, ofnode node,
+				 struct ofnode_phandle_args *args,
+				 const char *list_name, int index,
+				 struct clk *clk)
+{
+	struct udevice *dev_clk;
+	const struct clk_ops *ops;
+
+	assert(clk);
+	clk->dev = NULL;
+	if (ret)
+		goto err;
+
+	ret = uclass_get_device_by_ofnode(UCLASS_CLK, args->node, &dev_clk);
+	if (ret) {
+		debug("%s: uclass_get_device_by_of_offset failed: err=%d\n",
+		      __func__, ret);
+		return ret;
+	}
+
+	clk->dev = dev_clk;
+
+	ops = clk_dev_ops(dev_clk);
+
+	if (ops->of_xlate)
+		ret = ops->of_xlate(clk, args);
+	else
+		ret = clk_of_xlate_default(clk, args);
+	if (ret) {
+		debug("of_xlate() failed: %d\n", ret);
+		return ret;
+	}
+
+	return clk_request(dev_clk, clk);
+err:
+	debug("%s: Node '%s', property '%s', failed to request CLK index %d: %d\n",
+	       __func__, ofnode_get_name(node), list_name, index, ret);
+	return ret;
+}
+
 int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
 {
-	return clk_get_by_indexed_prop(dev, "clocks", index, clk);
+	struct ofnode_phandle_args args;
+	int ret;
+
+	ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0,
+					 index, &args);
+
+	return clk_get_by_index_tail(ret, dev_ofnode(dev), &args, "clocks",
+				     index > 0, clk);
+}
+
+int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk)
+{
+	struct ofnode_phandle_args args;
+	int ret;
+
+	ret = ofnode_parse_phandle_with_args(node, "clocks", "#clock-cells", 0,
+					     index > 0, &args);
+
+	return clk_get_by_index_tail(ret, node, &args, "clocks",
+				     index > 0, clk);
 }
 
 int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk)
diff --git a/include/clk.h b/include/clk.h
index f6d1cc53a1..1d8478f061 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -8,6 +8,7 @@
 #ifndef _CLK_H_
 #define _CLK_H_
 
+#include <dm/ofnode.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 
@@ -98,6 +99,20 @@ int clk_get_by_index_platdata(struct udevice *dev, int index,
  */
 int clk_get_by_index(struct udevice *dev, int index, struct clk *clk);
 
+/**
+ * clock_get_by_index_nodev - Get/request a clock by integer index
+ * without a device.
+ *
+ * This is a version of clk_get_by_index() that does not use a device.
+ *
+ * @node:	The client ofnode.
+ * @index:	The index of the clock to request, within the client's list of
+ *		clocks.
+ * @clock	A pointer to a clock struct to initialize.
+ * @return 0 if OK, or a negative error code.
+ */
+int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk);
+
 /**
  * clock_get_bulk - Get/request all clocks of a device.
  *
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 54/58] clk: Use clk_get_by_index_tail()
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (52 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 53/58] clk: Get the CLK by index without device Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-23 10:45   ` Simon Glass
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 55/58] reset: Get the RESET by index without device Jagan Teki
                   ` (3 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

clk_get_by_index_tail() now handle common clk get by index
code so use it in relevant places.

Cc: Simon Glass <sjg@chromium.org>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/clk-uclass.c | 77 +++++++++++++---------------------------
 1 file changed, 25 insertions(+), 52 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 8bb41a4de5..d439d216f2 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -54,50 +54,6 @@ static int clk_of_xlate_default(struct clk *clk,
 	return 0;
 }
 
-static int clk_get_by_indexed_prop(struct udevice *dev, const char *prop_name,
-				   int index, struct clk *clk)
-{
-	int ret;
-	struct ofnode_phandle_args args;
-	struct udevice *dev_clk;
-	const struct clk_ops *ops;
-
-	debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk);
-
-	assert(clk);
-	clk->dev = NULL;
-
-	ret = dev_read_phandle_with_args(dev, prop_name, "#clock-cells", 0,
-					 index, &args);
-	if (ret) {
-		debug("%s: fdtdec_parse_phandle_with_args failed: err=%d\n",
-		      __func__, ret);
-		return ret;
-	}
-
-	ret = uclass_get_device_by_ofnode(UCLASS_CLK, args.node, &dev_clk);
-	if (ret) {
-		debug("%s: uclass_get_device_by_of_offset failed: err=%d\n",
-		      __func__, ret);
-		return ret;
-	}
-
-	clk->dev = dev_clk;
-
-	ops = clk_dev_ops(dev_clk);
-
-	if (ops->of_xlate)
-		ret = ops->of_xlate(clk, &args);
-	else
-		ret = clk_of_xlate_default(clk, &args);
-	if (ret) {
-		debug("of_xlate() failed: %d\n", ret);
-		return ret;
-	}
-
-	return clk_request(dev_clk, clk);
-}
-
 static int clk_get_by_index_tail(int ret, ofnode node,
 				 struct ofnode_phandle_args *args,
 				 const char *list_name, int index,
@@ -197,10 +153,11 @@ bulk_get_err:
 
 static int clk_set_default_parents(struct udevice *dev)
 {
+	struct ofnode_phandle_args args;
 	struct clk clk, parent_clk;
 	int index;
 	int num_parents;
-	int ret;
+	int ret, err;
 
 	num_parents = dev_count_phandle_with_args(dev, "assigned-clock-parents",
 						  "#clock-cells");
@@ -211,8 +168,13 @@ static int clk_set_default_parents(struct udevice *dev)
 	}
 
 	for (index = 0; index < num_parents; index++) {
-		ret = clk_get_by_indexed_prop(dev, "assigned-clock-parents",
-					      index, &parent_clk);
+		err = dev_read_phandle_with_args(dev, "assigned-clock-parents",
+						 "#clock-cells", 0,
+						 index, &args);
+
+		ret = clk_get_by_index_tail(err, dev_ofnode(dev), &args,
+					    "assigned-clock-parents",
+					    index > 0, &parent_clk);
 		/* If -ENOENT, this is a no-op entry */
 		if (ret == -ENOENT)
 			continue;
@@ -223,8 +185,13 @@ static int clk_set_default_parents(struct udevice *dev)
 			return ret;
 		}
 
-		ret = clk_get_by_indexed_prop(dev, "assigned-clocks",
-					      index, &clk);
+		err = dev_read_phandle_with_args(dev, "assigned-clocks",
+						 "#clock-cells", 0,
+						 index, &args);
+
+		ret = clk_get_by_index_tail(err, dev_ofnode(dev), &args,
+					    "assigned-clocks",
+					    index > 0, &clk);
 		if (ret) {
 			debug("%s: could not get assigned clock %d for %s\n",
 			      __func__, index, dev_read_name(dev));
@@ -252,11 +219,12 @@ static int clk_set_default_parents(struct udevice *dev)
 
 static int clk_set_default_rates(struct udevice *dev)
 {
+	struct ofnode_phandle_args args;
 	struct clk clk;
 	int index;
 	int num_rates;
 	int size;
-	int ret = 0;
+	int err, ret = 0;
 	u32 *rates = NULL;
 
 	size = dev_read_size(dev, "assigned-clock-rates");
@@ -277,8 +245,13 @@ static int clk_set_default_rates(struct udevice *dev)
 		if (!rates[index])
 			continue;
 
-		ret = clk_get_by_indexed_prop(dev, "assigned-clocks",
-					      index, &clk);
+		err = dev_read_phandle_with_args(dev, "assigned-clocks",
+						 "#clock-cells", 0,
+						 index, &args);
+
+		ret = clk_get_by_index_tail(err, dev_ofnode(dev), &args,
+					    "assigned-clocks",
+					    index > 0, &clk);
 		if (ret) {
 			debug("%s: could not get assigned clock %d for %s\n",
 			      __func__, index, dev_read_name(dev));
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 55/58] reset: Get the RESET by index without device
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (53 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 54/58] clk: Use clk_get_by_index_tail() Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-23 10:45   ` Simon Glass
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 56/58] clk: sunxi: h3: Implement EPHY CLK and RESET Jagan Teki
                   ` (2 subsequent siblings)
  57 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Getting a RESET by index with device is not straight forward
for some use-cases like handling clock operations for child
node in parent driver. So we need to process the child node
in parent probe via ofnode and process RESET operation for child
without udevice but with ofnode.

So add reset_get_by_index_nodev() and move the common code
in reset_get_by_index_tail() to use for reset_get_by_index()

Cc: Simon Glass <sjg@chromium.org>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/reset/reset-uclass.c | 53 ++++++++++++++++++++++++------------
 include/reset.h              | 16 +++++++++++
 2 files changed, 52 insertions(+), 17 deletions(-)

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index 6320efcb49..755bbf7a5e 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -34,41 +34,34 @@ static int reset_of_xlate_default(struct reset_ctl *reset_ctl,
 	return 0;
 }
 
-int reset_get_by_index(struct udevice *dev, int index,
-		       struct reset_ctl *reset_ctl)
+static int reset_get_by_index_tail(int ret, ofnode node,
+				   struct ofnode_phandle_args *args,
+				   const char *list_name, int index,
+				   struct reset_ctl *reset_ctl)
 {
-	struct ofnode_phandle_args args;
-	int ret;
 	struct udevice *dev_reset;
 	struct reset_ops *ops;
 
-	debug("%s(dev=%p, index=%d, reset_ctl=%p)\n", __func__, dev, index,
-	      reset_ctl);
+	assert(reset_ctl);
 	reset_ctl->dev = NULL;
-
-	ret = dev_read_phandle_with_args(dev, "resets", "#reset-cells", 0,
-					  index, &args);
-	if (ret) {
-		debug("%s: fdtdec_parse_phandle_with_args() failed: %d\n",
-		      __func__, ret);
+	if (ret)
 		return ret;
-	}
 
-	ret = uclass_get_device_by_ofnode(UCLASS_RESET, args.node,
+	ret = uclass_get_device_by_ofnode(UCLASS_RESET, args->node,
 					  &dev_reset);
 	if (ret) {
 		debug("%s: uclass_get_device_by_ofnode() failed: %d\n",
 		      __func__, ret);
-		debug("%s %d\n", ofnode_get_name(args.node), args.args[0]);
+		debug("%s %d\n", ofnode_get_name(args->node), args->args[0]);
 		return ret;
 	}
 	ops = reset_dev_ops(dev_reset);
 
 	reset_ctl->dev = dev_reset;
 	if (ops->of_xlate)
-		ret = ops->of_xlate(reset_ctl, &args);
+		ret = ops->of_xlate(reset_ctl, args);
 	else
-		ret = reset_of_xlate_default(reset_ctl, &args);
+		ret = reset_of_xlate_default(reset_ctl, args);
 	if (ret) {
 		debug("of_xlate() failed: %d\n", ret);
 		return ret;
@@ -86,6 +79,32 @@ int reset_get_by_index(struct udevice *dev, int index,
 	return 0;
 }
 
+int reset_get_by_index(struct udevice *dev, int index,
+		       struct reset_ctl *reset_ctl)
+{
+	struct ofnode_phandle_args args;
+	int ret;
+
+	ret = dev_read_phandle_with_args(dev, "resets", "#reset-cells", 0,
+					 index, &args);
+
+	return reset_get_by_index_tail(ret, dev_ofnode(dev), &args, "resets",
+				       index > 0, reset_ctl);
+}
+
+int reset_get_by_index_nodev(ofnode node, int index,
+			     struct reset_ctl *reset_ctl)
+{
+	struct ofnode_phandle_args args;
+	int ret;
+
+	ret = ofnode_parse_phandle_with_args(node, "resets", "#reset-cells", 0,
+					     index > 0, &args);
+
+	return reset_get_by_index_tail(ret, node, &args, "resets",
+				       index > 0, reset_ctl);
+}
+
 int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk)
 {
 	int i, ret, err, count;
diff --git a/include/reset.h b/include/reset.h
index 70130bb886..581cc2579b 100644
--- a/include/reset.h
+++ b/include/reset.h
@@ -6,6 +6,7 @@
 #ifndef _RESET_H
 #define _RESET_H
 
+#include <dm/ofnode.h>
 #include <linux/errno.h>
 
 /**
@@ -97,6 +98,21 @@ struct reset_ctl_bulk {
 int reset_get_by_index(struct udevice *dev, int index,
 		       struct reset_ctl *reset_ctl);
 
+/**
+ * reset_get_by_index_nodev - Get/request a reset signal by integer index
+ * without a device.
+ *
+ * This is a version of reset_get_by_index() that does not use a device.
+ *
+ * @node:	The client ofnode.
+ * @index:	The index of the reset signal to request, within the client's
+ *		list of reset signals.
+ * @reset_ctl	A pointer to a reset control struct to initialize.
+ * @return 0 if OK, or a negative error code.
+ */
+int reset_get_by_index_nodev(ofnode node, int index,
+			     struct reset_ctl *reset_ctl);
+
 /**
  * reset_get_bulk - Get/request all reset signals of a device.
  *
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 56/58] clk: sunxi: h3: Implement EPHY CLK and RESET
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (54 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 55/58] reset: Get the RESET by index without device Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 57/58] net: sun8i_emac: Add EPHY CLK and RESET support Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 58/58] board: sunxi: gmac: Remove Ethernet clock and reset Jagan Teki
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

EPHY CLK and RESET is availble in Allwinner H3 EMAC
via mdio-mux node of internal PHY. Add the respetive
clock and reset reg and bits.

Cc: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/sunxi/clk_h3.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index 88086580f4..3d5dc2cbed 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -34,6 +34,8 @@ static struct ccu_clk_map h3_clks[] = {
 	[CLK_BUS_UART2]		= { 0x06c, BIT(18), NULL },
 	[CLK_BUS_UART3]		= { 0x06c, BIT(19), NULL },
 
+	[CLK_BUS_EPHY]		= { 0x070, BIT(0), NULL },
+
 	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
 	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
@@ -73,6 +75,8 @@ static struct ccu_reset_map h3_resets[] = {
 	[RST_BUS_OHCI2]		= { 0x2c0, BIT(30) },
 	[RST_BUS_OHCI3]		= { 0x2c0, BIT(31) },
 
+	[RST_BUS_EPHY]		= { 0x2c8, BIT(2) },
+
 	[RST_BUS_UART0]		= { 0x2d8, BIT(16) },
 	[RST_BUS_UART1]		= { 0x2d8, BIT(17) },
 	[RST_BUS_UART2]		= { 0x2d8, BIT(18) },
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 57/58] net: sun8i_emac: Add EPHY CLK and RESET support
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (55 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 56/58] clk: sunxi: h3: Implement EPHY CLK and RESET Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 58/58] board: sunxi: gmac: Remove Ethernet clock and reset Jagan Teki
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Add EPHY CLK and RESET support for sun8i_emac driver to
enable EPHY TX clock and EPHY reset pins via CLK and RESET
framework.

Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Lothar Felten <lothar.felten@gmail.com>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/net/sun8i_emac.c | 72 ++++++++++++++++++++++++++++++----------
 1 file changed, 55 insertions(+), 17 deletions(-)

diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index ad2d390f4e..bb97e6d7e9 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -134,7 +134,9 @@ struct emac_eth_dev {
 	struct phy_device *phydev;
 	struct mii_dev *bus;
 	struct clk tx_clk;
+	struct clk ephy_clk;
 	struct reset_ctl tx_rst;
+	struct reset_ctl ephy_rst;
 #ifdef CONFIG_DM_GPIO
 	struct gpio_desc reset_gpio;
 #endif
@@ -638,7 +640,6 @@ static int sun8i_eth_write_hwaddr(struct udevice *dev)
 
 static int sun8i_emac_board_setup(struct emac_eth_dev *priv)
 {
-	struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
 	int ret;
 
 	ret = clk_enable(&priv->tx_clk);
@@ -655,16 +656,20 @@ static int sun8i_emac_board_setup(struct emac_eth_dev *priv)
 		}
 	}
 
-	if (priv->variant == H3_EMAC) {
-		/* Only H3/H5 have clock controls for internal EPHY */
-		if (priv->use_internal_phy) {
-			/* Set clock gating for ephy */
-			setbits_le32(&ccm->bus_gate4,
-				     BIT(AHB_GATE_OFFSET_EPHY));
-
-			/* Deassert EPHY */
-			setbits_le32(&ccm->ahb_reset2_cfg,
-				     BIT(AHB_RESET_OFFSET_EPHY));
+	/* Only H3/H5 have clock controls for internal EPHY */
+	if (clk_valid(&priv->ephy_clk)) {
+		ret = clk_enable(&priv->ephy_clk);
+		if (ret) {
+			dev_err(dev, "failed to enable EPHY TX clock\n");
+			return ret;
+		}
+	}
+
+	if (reset_valid(&priv->ephy_rst)) {
+		ret = reset_deassert(&priv->ephy_rst);
+		if (ret) {
+			dev_err(dev, "failed to deassert EPHY TX clock\n");
+			return ret;
 		}
 	}
 
@@ -819,6 +824,42 @@ static const struct eth_ops sun8i_emac_eth_ops = {
 	.stop                   = sun8i_emac_eth_stop,
 };
 
+static int sun8i_get_ephy_nodes(struct emac_eth_dev *priv)
+{
+	int node, ret;
+
+	/* look for mdio-mux node for internal PHY node */
+	node = fdt_path_offset(gd->fdt_blob,
+			"/soc/ethernet at 1c30000/mdio-mux/mdio at 1/ethernet-phy at 1");
+	if (node < 0) {
+		debug("failed to get mdio-mux with internal PHY\n");
+		return node;
+	}
+
+	ret = fdt_node_check_compatible(gd->fdt_blob, node,
+					"allwinner,sun8i-h3-mdio-internal");
+	if (ret < 0) {
+		debug("failed to find mdio-internal node\n");
+		return ret;
+	}
+
+	ret = clk_get_by_index_nodev(offset_to_ofnode(node), 0, &priv->ephy_clk);
+	if (ret) {
+		dev_err(dev, "failed to get EPHY TX clock\n");
+		return ret;
+	}
+
+	ret = reset_get_by_index_nodev(offset_to_ofnode(node), 0, &priv->ephy_rst);
+	if (ret) {
+		dev_err(dev, "failed to get EPHY TX reset\n");
+		return ret;
+	}
+
+	priv->use_internal_phy = true;
+
+	return 0;
+}
+
 static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
 {
 	struct sun8i_eth_pdata *sun8i_pdata = dev_get_platdata(dev);
@@ -901,12 +942,9 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
 	}
 
 	if (priv->variant == H3_EMAC) {
-		int parent = fdt_parent_offset(gd->fdt_blob, offset);
-
-		if (parent >= 0 &&
-		    !fdt_node_check_compatible(gd->fdt_blob, parent,
-				"allwinner,sun8i-h3-mdio-internal"))
-			priv->use_internal_phy = true;
+		ret = sun8i_get_ephy_nodes(priv);
+		if (ret)
+			return ret;
 	}
 
 	priv->interface = pdata->phy_interface;
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 58/58] board: sunxi: gmac: Remove Ethernet clock and reset
  2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
                   ` (56 preceding siblings ...)
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 57/58] net: sun8i_emac: Add EPHY CLK and RESET support Jagan Teki
@ 2018-08-19 13:57 ` Jagan Teki
  57 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-19 13:57 UTC (permalink / raw)
  To: u-boot

Since Ethernet clock and reset is now handling via
CLK and RESET frameworks via driver API's remove
explicit ccm writes.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 board/sunxi/gmac.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c
index 826650c89b..d8fdf7728e 100644
--- a/board/sunxi/gmac.c
+++ b/board/sunxi/gmac.c
@@ -12,14 +12,6 @@ void eth_init_board(void)
 	struct sunxi_ccm_reg *const ccm =
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
 
-	/* Set up clock gating */
-#ifdef CONFIG_SUNXI_GEN_SUN6I
-	setbits_le32(&ccm->ahb_reset0_cfg, 0x1 << AHB_RESET_OFFSET_GMAC);
-	setbits_le32(&ccm->ahb_gate0, 0x1 << AHB_GATE_OFFSET_GMAC);
-#else
-	setbits_le32(&ccm->ahb_gate1, 0x1 << AHB_GATE_OFFSET_GMAC);
-#endif
-
 	/* Set MII clock */
 #ifdef CONFIG_RGMII
 	setbits_le32(&ccm->gmac_clk_cfg, CCM_GMAC_CTRL_TX_CLK_SRC_INT_RGMII |
-- 
2.18.0.321.gffc6fa0e3

^ permalink raw reply related	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 45/58] spi: Add Allwinner A31 SPI driver
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 45/58] spi: Add Allwinner A31 SPI driver Jagan Teki
@ 2018-08-20 11:18   ` Maxime Ripard
  2018-08-20 11:42     ` Jagan Teki
  0 siblings, 1 reply; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:18 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:27:02PM +0530, Jagan Teki wrote:
> Add Allwinner sun6i SPI driver for A31, H3/H5 an A64.
> 
> Tested-by: Fahad Sadah <fahad@sadah.uk>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>

This has nothing to do in this serie.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/48ca174e/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 02/58] reset: Add default request ops
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 02/58] reset: Add default request ops Jagan Teki
@ 2018-08-20 11:22   ` Maxime Ripard
  0 siblings, 0 replies; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:22 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:19PM +0530, Jagan Teki wrote:
> Missing request ops from respective uclass driver
> generating "synchronous abort" in Allwinner platform,
> may be in arm. So add default request ops and give a
> chance to uclass driver to think whether they really
> need request or not.

I'm not sure why anyone would not want a request operation for a reset
line.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/697f026a/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 14/58] musb-new: sunxi: Use CLK and RESET support
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 14/58] musb-new: sunxi: Use CLK and RESET support Jagan Teki
@ 2018-08-20 11:26   ` Maxime Ripard
  0 siblings, 0 replies; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:26 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:31PM +0530, Jagan Teki wrote:
> Now clock and reset drivers are available for respective
> SoC's so use clk and reset ops on musb driver.
> 
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  drivers/usb/musb-new/sunxi.c | 82 +++++++++++++++++++++++-------------
>  1 file changed, 53 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
> index 9f71b84fd1..440be83f4e 100644
> --- a/drivers/usb/musb-new/sunxi.c
> +++ b/drivers/usb/musb-new/sunxi.c
> @@ -16,9 +16,11 @@
>   * This file is part of the Inventra Controller Driver for Linux.
>   */
>  #include <common.h>
> +#include <clk.h>
>  #include <dm.h>
>  #include <generic-phy.h>
>  #include <phy-sun4i-usb.h>
> +#include <reset.h>
>  #include <asm/arch/cpu.h>
>  #include <asm/arch/clock.h>
>  #include <asm/arch/gpio.h>
> @@ -78,16 +80,15 @@
>  
>  struct sunxi_musb_config {
>  	struct musb_hdrc_config *config;
> -	u8 rst_bit;
> -	u8 clkgate_bit;
>  };
>  
>  struct sunxi_glue {
>  	struct musb_host_data mdata;
> -	struct sunxi_ccm_reg *ccm;
>  	struct sunxi_musb_config *cfg;
>  	struct device dev;
>  	struct phy phy;
> +	struct clk clocks;
> +	struct reset_ctl resets;
>  };
>  #define to_sunxi_glue(d)	container_of(d, struct sunxi_glue, dev)
>  
> @@ -291,6 +292,18 @@ static int sunxi_musb_init(struct musb *musb)
>  
>  	pr_debug("%s():\n", __func__);
>  
> +	ret = clk_enable(&glue->clocks);
> +	if (ret) {
> +		dev_err(dev, "failed to enable clock\n");
> +		return ret;
> +	}
> +
> +	ret = reset_deassert(&glue->resets);
> +	if (ret) {
> +		dev_err(dev, "failed to deassert reset\n");
> +		return ret;
> +	}
> +
>  	ret = generic_phy_init(&glue->phy);
>  	if (ret) {
>  		pr_err("failed to init USB PHY\n");
> @@ -299,17 +312,6 @@ static int sunxi_musb_init(struct musb *musb)
>  
>  	musb->isr = sunxi_musb_interrupt;
>  
> -	setbits_le32(&glue->ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_USB0));
> -	if (glue->cfg->clkgate_bit)
> -		setbits_le32(&glue->ccm->ahb_gate0,
> -			     BIT(glue->cfg->clkgate_bit));
> -#ifdef CONFIG_SUNXI_GEN_SUN6I
> -	setbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0));
> -	if (glue->cfg->rst_bit)
> -		setbits_le32(&glue->ccm->ahb_reset0_cfg,
> -			     BIT(glue->cfg->rst_bit));
> -#endif
> -
>  	USBC_ConfigFIFO_Base();
>  	USBC_EnableDpDmPullUp(musb->mregs);
>  	USBC_EnableIdPullUp(musb->mregs);
> @@ -339,16 +341,17 @@ static int sunxi_musb_exit(struct musb *musb)
>  		}
>  	}
>  
> -#ifdef CONFIG_SUNXI_GEN_SUN6I
> -	clrbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0));
> -	if (glue->cfg->rst_bit)
> -		clrbits_le32(&glue->ccm->ahb_reset0_cfg,
> -			     BIT(glue->cfg->rst_bit));
> -#endif
> -	clrbits_le32(&glue->ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_USB0));
> -	if (glue->cfg->clkgate_bit)
> -		clrbits_le32(&glue->ccm->ahb_gate0,
> -			     BIT(glue->cfg->clkgate_bit));
> +	ret = reset_assert(&glue->resets);
> +	if (ret) {
> +		dev_err(dev, "failed to deassert reset\n");
> +		return ret;
> +	}
> +
> +	ret = clk_disable(&glue->clocks);
> +	if (ret) {
> +		dev_err(dev, "failed to enable clock\n");
> +		return ret;
> +	}
>  
>  	return 0;
>  }
> @@ -433,6 +436,7 @@ static int musb_usb_probe(struct udevice *dev)
>  	struct usb_bus_priv *priv = dev_get_uclass_priv(dev);
>  	struct musb_hdrc_platform_data pdata;
>  	void *base = dev_read_addr_ptr(dev);
> +	int clock_nb, reset_nb;
>  	int ret;
>  
>  	if (!base)
> @@ -442,9 +446,31 @@ static int musb_usb_probe(struct udevice *dev)
>  	if (!glue->cfg)
>  		return -EINVAL;
>  
> -	glue->ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
> -	if (IS_ERR(glue->ccm))
> -		return PTR_ERR(glue->ccm);
> +	clock_nb = ofnode_count_phandle_with_args(dev_ofnode(dev), "clocks",
> +						  "#clock-cells");
> +	if (clock_nb < 0) {
> +		dev_err(dev, "failed to get clock phandle(%d)\n", clock_nb);
> +		return clock_nb;
> +	}

What are you using that variable for?

> +	ret = clk_get_by_index(dev, 0, &glue->clocks);
> +	if (ret) {
> +		dev_err(dev, "failed to get clock 0\n");
> +		clk_free(&glue->clocks);
> +	}
> +
> +	reset_nb = ofnode_count_phandle_with_args(dev_ofnode(dev), "resets",
> +						  "#reset-cells");
> +	if (reset_nb < 0) {
> +		dev_err(dev, "failed to get reset phandle(%d)\n", clock_nb);
> +		return reset_nb;
> +	}

Ditto.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/8362b946/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 18/58] clk: sunxi: Implement AHB bus MMC clocks
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 18/58] clk: sunxi: Implement AHB bus MMC clocks Jagan Teki
@ 2018-08-20 11:28   ` Maxime Ripard
  0 siblings, 0 replies; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:28 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:35PM +0530, Jagan Teki wrote:
> Implement AHB bus MMC clocks for all Allwinner SoC
> clock drivers via clock map descriptor table.
> 
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>

That should be merged in the clock driver patches.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/133c0716/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 20/58] clk: sunxi: Implement AHB bus MMC resets
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 20/58] clk: sunxi: Implement AHB bus MMC resets Jagan Teki
@ 2018-08-20 11:28   ` Maxime Ripard
  0 siblings, 0 replies; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:28 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:37PM +0530, Jagan Teki wrote:
> Implement AHB bus MMC resets for all Allwinner SoC
> clock drivers via reset map descriptor table.
> 
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>

That should be merged in the reset driver patches.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/14a43552/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 19/58] clk: sunxi: Implement direct MMC clocks
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 19/58] clk: sunxi: Implement direct " Jagan Teki
@ 2018-08-20 11:33   ` Maxime Ripard
  2018-08-27 10:04     ` Jagan Teki
  0 siblings, 1 reply; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:33 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:36PM +0530, Jagan Teki wrote:
> Implement direct MMC clocks for all Allwinner SoC
> clock drivers via clock map descriptor table.
> 
> This includes adding ccu_clk_set_rate function pointer,
> which indeed support CLK set_rate API, so update clock
> handling in sunxi_mmc driver to support both no-dm and dm code.
> 
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  arch/arm/include/asm/arch-sunxi/ccu.h | 10 +++++
>  drivers/clk/sunxi/clk_a10.c           |  5 +++
>  drivers/clk/sunxi/clk_a10s.c          |  6 +++
>  drivers/clk/sunxi/clk_a23.c           |  6 +++
>  drivers/clk/sunxi/clk_a31.c           |  5 +++
>  drivers/clk/sunxi/clk_a64.c           |  4 ++
>  drivers/clk/sunxi/clk_a83t.c          |  4 ++
>  drivers/clk/sunxi/clk_h3.c            |  4 ++
>  drivers/clk/sunxi/clk_r40.c           |  4 ++
>  drivers/clk/sunxi/clk_sunxi.c         | 19 +++++++++
>  drivers/clk/sunxi/clk_v3s.c           |  4 ++
>  drivers/mmc/sunxi_mmc.c               | 58 +++++++++++++++++----------
>  12 files changed, 107 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch-sunxi/ccu.h b/arch/arm/include/asm/arch-sunxi/ccu.h
> index bacd052ef3..4e30ab330c 100644
> --- a/arch/arm/include/asm/arch-sunxi/ccu.h
> +++ b/arch/arm/include/asm/arch-sunxi/ccu.h
> @@ -60,6 +60,16 @@ struct sunxi_clk_priv {
>  
>  extern struct clk_ops sunxi_clk_ops;
>  
> +/**
> + * mmc_clk_set_rate - mmc clock set rate
> + *
> + * @base:	clock register base address
> + * @bit:	clock bit value
> + * @rate:	clock input rate in Hz
> + * @return 0, or -ve error code.
> + */
> +int mmc_clk_set_rate(void *base, u32 bit, ulong rate);
> +
>  /**
>   * sunxi_reset_bind() - reset binding
>   *
> diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
> index fb11231dd1..55176bc174 100644
> --- a/drivers/clk/sunxi/clk_a10.c
> +++ b/drivers/clk/sunxi/clk_a10.c
> @@ -23,6 +23,11 @@ static struct ccu_clk_map a10_clks[] = {
>  	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
>  	[CLK_AHB_MMC3]		= { 0x060, BIT(11), NULL },
>  
> +	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
> +	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
> +	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
> +	[CLK_MMC3]		= { 0x094, BIT(31), &mmc_clk_set_rate },
> +
>  	[CLK_USB_OHCI0]		= { 0x0cc, BIT(6), NULL },
>  	[CLK_USB_OHCI1]		= { 0x0cc, BIT(7), NULL },
>  	[CLK_USB_PHY]		= { 0x0cc, BIT(8), NULL },
> diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
> index bc4ae7352b..fbac0ad751 100644
> --- a/drivers/clk/sunxi/clk_a10s.c
> +++ b/drivers/clk/sunxi/clk_a10s.c
> @@ -20,6 +20,12 @@ static struct ccu_clk_map a10s_clks[] = {
>  	[CLK_AHB_MMC1]		= { 0x060, BIT(9), NULL },
>  	[CLK_AHB_MMC2]		= { 0x060, BIT(10), NULL },
>  
> +#ifdef CONFIG_MMC
> +	[CLK_MMC0]		= { 0x088, BIT(31), &mmc_clk_set_rate },
> +	[CLK_MMC1]		= { 0x08c, BIT(31), &mmc_clk_set_rate },
> +	[CLK_MMC2]		= { 0x090, BIT(31), &mmc_clk_set_rate },
> +#endif
> +

I'm not too sure about the ifdef here. Or at least, we should be
consistent, and if we do it for the MMC, we should do it for all the
SoCs (including the A10), and for all the controllers (including USB,
for example).

> diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
> index 39f15eb423..bf82014a64 100644
> --- a/drivers/mmc/sunxi_mmc.c
> +++ b/drivers/mmc/sunxi_mmc.c
> @@ -13,6 +13,7 @@
>  #include <malloc.h>
>  #include <mmc.h>
>  #include <asm/io.h>
> +#include <asm/arch/ccu.h>
>  #include <asm/arch/clock.h>
>  #include <asm/arch/cpu.h>
>  #include <asm/arch/gpio.h>
> @@ -34,6 +35,8 @@ struct sunxi_mmc_priv {
>  	struct mmc_config cfg;
>  };
>  
> +bool new_mode;
> +
>  #if !CONFIG_IS_ENABLED(DM_MMC)
>  /* support 4 mmc hosts */
>  struct sunxi_mmc_priv mmc_host[4];
> @@ -95,23 +98,19 @@ static int mmc_resource_init(int sdc_no)
>  }
>  #endif
>  
> -static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
> +int mmc_clk_set_rate(void *base, u32 bit, ulong rate)
>  {
>  	unsigned int pll, pll_hz, div, n, oclk_dly, sclk_dly;
> -	bool new_mode = false;
>  	u32 val = 0;
>  
> -	if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
> -		new_mode = true;
> -

[..]

> +static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
> +{
> +#if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(CLK)
> +#else
> +	if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
> +		new_mode = true;
> +

I'm not sure why you need the global variable.

The A83t emmc case you have below is caught in this condition, and
therefore, the scope doesn't need to be global.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/55a1c7e9/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 21/58] reset: Add get reset by name optionally
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 21/58] reset: Add get reset by name optionally Jagan Teki
@ 2018-08-20 11:34   ` Maxime Ripard
  0 siblings, 0 replies; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:34 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:38PM +0530, Jagan Teki wrote:
> Reset is an optional for some controllers with some families
> of CPU's with same SoC where the common IP driver can handle
> to drive the entire SoC families. optional reset get by name
> is useful for those drivers to make common way of reset handling.
> 
> Example, In Allwinner SoC with MMC controllers has no reset
> for Sun4i, 5i, 7i but reset have reset.

So, in other words, it's not needed for the A10, A20 and A13, but
needed for all the others. It's not optional then, it's useless in one
case, and mandatory in the other.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/e99ceb74/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 24/58] arm64: allwinner: dts: h6: fix Pine H64 MMC bus width
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 24/58] arm64: allwinner: dts: h6: fix Pine H64 MMC bus width Jagan Teki
@ 2018-08-20 11:35   ` Maxime Ripard
  2018-08-20 11:39     ` Jagan Teki
  0 siblings, 1 reply; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:35 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:41PM +0530, Jagan Teki wrote:
> Currently the enabled MMC controllers on Pine H64 do not have bus-width
> set, which make them fall back to 1-bit mode and become quite slow.
> 
> Fix this by add the corresponding bus-width properties.
> 
> Same commit is there in mailing-list, but yet to merge,
> commit fb8971bea0910a3172cd8ce75ccc01b50104ebf7
> Author: Icenowy Zheng <icenowy@aosc.io>
> Date:   Thu Jul 26 12:41:27 2018 +0800
> 
>     arm64: allwinner: dts: h6: fix Pine H64 MMC bus width
> 
> Cc: Icenowy Zheng <icenowy@aosc.io>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>

That also has nothing to do with this serie. Please send independant
patches independantly.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/e4d6da0e/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 26/58] dm: mmc: sunxi: Add CLK and RESET support
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 26/58] dm: mmc: sunxi: Add CLK and RESET support Jagan Teki
@ 2018-08-20 11:36   ` Maxime Ripard
  0 siblings, 0 replies; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:36 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:43PM +0530, Jagan Teki wrote:
> -	debug("mmc %d, cmd %d(0x%08x), arg 0x%08x\n", priv->mmc_no,
> +	debug("mmc cmd %d(0x%08x), arg 0x%08x\n",
>  	      cmd->cmdidx, cmdval | cmd->cmdidx, cmd->cmdarg);

Why is priv->mmc_no removed?

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/238df179/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 24/58] arm64: allwinner: dts: h6: fix Pine H64 MMC bus width
  2018-08-20 11:35   ` Maxime Ripard
@ 2018-08-20 11:39     ` Jagan Teki
  2018-08-20 14:16       ` Maxime Ripard
  0 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-20 11:39 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 20, 2018 at 5:05 PM, Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
> On Sun, Aug 19, 2018 at 07:26:41PM +0530, Jagan Teki wrote:
>> Currently the enabled MMC controllers on Pine H64 do not have bus-width
>> set, which make them fall back to 1-bit mode and become quite slow.
>>
>> Fix this by add the corresponding bus-width properties.
>>
>> Same commit is there in mailing-list, but yet to merge,
>> commit fb8971bea0910a3172cd8ce75ccc01b50104ebf7
>> Author: Icenowy Zheng <icenowy@aosc.io>
>> Date:   Thu Jul 26 12:41:27 2018 +0800
>>
>>     arm64: allwinner: dts: h6: fix Pine H64 MMC bus width
>>
>> Cc: Icenowy Zheng <icenowy@aosc.io>
>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>
> That also has nothing to do with this serie. Please send independant
> patches independantly.

This change required for U-Boot proper to detect mmc0, mmc2 with new
CLK, RESET and DM_MMC

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 45/58] spi: Add Allwinner A31 SPI driver
  2018-08-20 11:18   ` Maxime Ripard
@ 2018-08-20 11:42     ` Jagan Teki
  2018-08-20 14:19       ` Maxime Ripard
  0 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-20 11:42 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 20, 2018 at 4:48 PM, Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
> On Sun, Aug 19, 2018 at 07:27:02PM +0530, Jagan Teki wrote:
>> Add Allwinner sun6i SPI driver for A31, H3/H5 an A64.
>>
>> Tested-by: Fahad Sadah <fahad@sadah.uk>
>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>
> This has nothing to do in this serie.

Driver require CLK, RESET changes, so added on top of it.

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device Jagan Teki
@ 2018-08-20 11:44   ` Maxime Ripard
  2018-08-21 16:57     ` Jagan Teki
  0 siblings, 1 reply; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:44 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
> Usually eMMC is default mmc device for fastboot.
> 
> By enabling DM_MMC, the mmc devices are probed as per
> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
> U-Boot proper.
> 
> Allwinner SoC has maximum of 4 mmc controllers start from
> mmc0...mmc3 on which mmc2 can be used an eMMC controller
> eventhough mmc3 some boards used as eMMC.
> 
> So, update the default fastboot device as 2 to make the
> standard usage irrespective of DT node status.
> 
> Other corner cases like different device usage, or specific
> mmc node status is not enabled in order in DTS must explicitly
> add config on the specific defconfig file.
> 
> Cc: Olliver Schinagl <oliver@schinagl.nl>
> Cc: Chen-Yu Tsai <wens@csie.org>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>

This breaks all existing users, since if DM_MMC isn't set (and it
isn't at the moment), the MMC IDs won't change, and you're changing it
from either 0 or 1 to 2.

Can't we have a DT property instead? It looks much better than having
to deal with a non stable ID in Kconfig.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/c25950c0/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 29/58] sunxi: Get fat device wrt boot device, 'auto' partition
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 29/58] sunxi: Get fat device wrt boot device, 'auto' partition Jagan Teki
@ 2018-08-20 11:45   ` Maxime Ripard
  0 siblings, 0 replies; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 11:45 UTC (permalink / raw)
  To: u-boot

On Sun, Aug 19, 2018 at 07:26:46PM +0530, Jagan Teki wrote:
> Setting fat device, partition using CONFIG_ENV_FAT_DEVICE_AND_PART
> via Kconfig option is difficult to maintain since Allwinner
> support more than one mmc controllers with SD and eMMC.
> 
> So, add dynamic function to get the device based on the
> boot device source with 'auto' partition.
> 
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  arch/arm/mach-sunxi/board.c | 50 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
> index d22a84ea6b..cf174bd0a3 100644
> --- a/arch/arm/mach-sunxi/board.c
> +++ b/arch/arm/mach-sunxi/board.c
> @@ -10,6 +10,7 @@
>   */
>  
>  #include <common.h>
> +#include <fat.h>
>  #include <mmc.h>
>  #include <i2c.h>
>  #include <serial.h>
> @@ -253,6 +254,55 @@ uint32_t sunxi_get_boot_device(void)
>  	return -1;		/* Never reached */
>  }
>  
> +#if CONFIG_IS_ENABLED(ENV_IS_IN_FAT)
> +static int find_first_sd_device(void)
> +{
> +	struct mmc *mmc;
> +	int i;
> +
> +	for (i = 0; (mmc = find_mmc_device(i)); i++) {
> +		if (!mmc_init(mmc) && IS_SD(mmc))
> +			return i;
> +	}
> +
> +	return -ENODEV;
> +}
> +
> +static int find_first_mmc_device(void)
> +{
> +	struct mmc *mmc;
> +	int i;
> +
> +	for (i = 0; (mmc = find_mmc_device(i)); i++) {
> +		if (!mmc_init(mmc) && IS_MMC(mmc))
> +			return i;
> +	}
> +
> +	return -ENODEV;
> +}
> +
> +char *get_env_fat_dev_part(void)
> +{
> +	int devno, boot_source;
> +	static char dev_part[10];
> +
> +	boot_source = readb(SPL_ADDR + 0x28);
> +	switch (boot_source) {
> +	case SUNXI_BOOTED_FROM_MMC0:
> +		devno = find_first_sd_device();
> +		break;
> +	case SUNXI_BOOTED_FROM_MMC2:
> +		devno = find_first_mmc_device();
> +		break;

You're changing the behaviour from having the environment fixed in a
particular device to detecting that device at runtime.

Again, can't we use a DT property for this instead?

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/6a377049/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 24/58] arm64: allwinner: dts: h6: fix Pine H64 MMC bus width
  2018-08-20 11:39     ` Jagan Teki
@ 2018-08-20 14:16       ` Maxime Ripard
  0 siblings, 0 replies; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 14:16 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 20, 2018 at 05:09:54PM +0530, Jagan Teki wrote:
> On Mon, Aug 20, 2018 at 5:05 PM, Maxime Ripard
> <maxime.ripard@bootlin.com> wrote:
> > On Sun, Aug 19, 2018 at 07:26:41PM +0530, Jagan Teki wrote:
> >> Currently the enabled MMC controllers on Pine H64 do not have bus-width
> >> set, which make them fall back to 1-bit mode and become quite slow.
> >>
> >> Fix this by add the corresponding bus-width properties.
> >>
> >> Same commit is there in mailing-list, but yet to merge,
> >> commit fb8971bea0910a3172cd8ce75ccc01b50104ebf7
> >> Author: Icenowy Zheng <icenowy@aosc.io>
> >> Date:   Thu Jul 26 12:41:27 2018 +0800
> >>
> >>     arm64: allwinner: dts: h6: fix Pine H64 MMC bus width
> >>
> >> Cc: Icenowy Zheng <icenowy@aosc.io>
> >> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> >
> > That also has nothing to do with this serie. Please send independant
> > patches independantly.
> 
> This change required for U-Boot proper to detect mmc0, mmc2 with new
> CLK, RESET and DM_MMC

No, it will work just fine without that patch, no matter if we're
having DM_MMC, RESET or CLK. What we won't have is optimal data rates,
but this doesn't really have anything to do with it.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/3a04b9fa/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 45/58] spi: Add Allwinner A31 SPI driver
  2018-08-20 11:42     ` Jagan Teki
@ 2018-08-20 14:19       ` Maxime Ripard
  2018-08-20 15:25         ` Jagan Teki
  0 siblings, 1 reply; 87+ messages in thread
From: Maxime Ripard @ 2018-08-20 14:19 UTC (permalink / raw)
  To: u-boot

1;5202;0c
On Mon, Aug 20, 2018 at 05:12:20PM +0530, Jagan Teki wrote:
> On Mon, Aug 20, 2018 at 4:48 PM, Maxime Ripard
> <maxime.ripard@bootlin.com> wrote:
> > On Sun, Aug 19, 2018 at 07:27:02PM +0530, Jagan Teki wrote:
> >> Add Allwinner sun6i SPI driver for A31, H3/H5 an A64.
> >>
> >> Tested-by: Fahad Sadah <fahad@sadah.uk>
> >> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> >
> > This has nothing to do in this serie.
> 
> Driver require CLK, RESET changes, so added on top of it.

I understand why it has a dependency on this serie, but it doesn't
belong in it. It's far too big to review already to not have an
unrelated patch in the middle of the serie.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/a512d15e/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 45/58] spi: Add Allwinner A31 SPI driver
  2018-08-20 14:19       ` Maxime Ripard
@ 2018-08-20 15:25         ` Jagan Teki
  0 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-20 15:25 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 20, 2018 at 7:49 PM, Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
> 1;5202;0c
> On Mon, Aug 20, 2018 at 05:12:20PM +0530, Jagan Teki wrote:
>> On Mon, Aug 20, 2018 at 4:48 PM, Maxime Ripard
>> <maxime.ripard@bootlin.com> wrote:
>> > On Sun, Aug 19, 2018 at 07:27:02PM +0530, Jagan Teki wrote:
>> >> Add Allwinner sun6i SPI driver for A31, H3/H5 an A64.
>> >>
>> >> Tested-by: Fahad Sadah <fahad@sadah.uk>
>> >> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>> >
>> > This has nothing to do in this serie.
>>
>> Driver require CLK, RESET changes, so added on top of it.
>
> I understand why it has a dependency on this serie, but it doesn't
> belong in it. It's far too big to review already to not have an
> unrelated patch in the middle of the serie.

OK, then I break the series with CLK and DM_MMC separately which I did
initially, that look easy for review.

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device
  2018-08-20 11:44   ` Maxime Ripard
@ 2018-08-21 16:57     ` Jagan Teki
  2018-08-22 16:43       ` Maxime Ripard
  2018-08-22 18:56       ` Olliver Schinagl
  0 siblings, 2 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-21 16:57 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
> On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
>> Usually eMMC is default mmc device for fastboot.
>>
>> By enabling DM_MMC, the mmc devices are probed as per
>> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
>> U-Boot proper.
>>
>> Allwinner SoC has maximum of 4 mmc controllers start from
>> mmc0...mmc3 on which mmc2 can be used an eMMC controller
>> eventhough mmc3 some boards used as eMMC.
>>
>> So, update the default fastboot device as 2 to make the
>> standard usage irrespective of DT node status.
>>
>> Other corner cases like different device usage, or specific
>> mmc node status is not enabled in order in DTS must explicitly
>> add config on the specific defconfig file.
>>
>> Cc: Olliver Schinagl <oliver@schinagl.nl>
>> Cc: Chen-Yu Tsai <wens@csie.org>
>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>
> This breaks all existing users, since if DM_MMC isn't set (and it
> isn't at the moment), the MMC IDs won't change, and you're changing it
> from either 0 or 1 to 2.

True, bisectable issue. will take care on next version.

>
> Can't we have a DT property instead? It looks much better than having
> to deal with a non stable ID in Kconfig.

What do you mean by DT property handle? mmc2 is eMMC in all sunXi
isn't? ie reason I make it default.

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device
  2018-08-21 16:57     ` Jagan Teki
@ 2018-08-22 16:43       ` Maxime Ripard
  2018-08-27  9:20         ` Jagan Teki
  2018-08-22 18:56       ` Olliver Schinagl
  1 sibling, 1 reply; 87+ messages in thread
From: Maxime Ripard @ 2018-08-22 16:43 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 21, 2018 at 10:27:38PM +0530, Jagan Teki wrote:
> On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
> <maxime.ripard@bootlin.com> wrote:
> > On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
> >> Usually eMMC is default mmc device for fastboot.
> >>
> >> By enabling DM_MMC, the mmc devices are probed as per
> >> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
> >> U-Boot proper.
> >>
> >> Allwinner SoC has maximum of 4 mmc controllers start from
> >> mmc0...mmc3 on which mmc2 can be used an eMMC controller
> >> eventhough mmc3 some boards used as eMMC.
> >>
> >> So, update the default fastboot device as 2 to make the
> >> standard usage irrespective of DT node status.
> >>
> >> Other corner cases like different device usage, or specific
> >> mmc node status is not enabled in order in DTS must explicitly
> >> add config on the specific defconfig file.
> >>
> >> Cc: Olliver Schinagl <oliver@schinagl.nl>
> >> Cc: Chen-Yu Tsai <wens@csie.org>
> >> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> >
> > This breaks all existing users, since if DM_MMC isn't set (and it
> > isn't at the moment), the MMC IDs won't change, and you're changing it
> > from either 0 or 1 to 2.
> 
> True, bisectable issue. will take care on next version.
> 
> >
> > Can't we have a DT property instead? It looks much better than having
> > to deal with a non stable ID in Kconfig.
> 
> What do you mean by DT property handle? mmc2 is eMMC in all sunXi
> isn't? ie reason I make it default.

I meant to select the fastboot and environment devices. That way, each
board can select the one it wants in a truly deterministic way.

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180822/1c9709f2/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device
  2018-08-21 16:57     ` Jagan Teki
  2018-08-22 16:43       ` Maxime Ripard
@ 2018-08-22 18:56       ` Olliver Schinagl
  1 sibling, 0 replies; 87+ messages in thread
From: Olliver Schinagl @ 2018-08-22 18:56 UTC (permalink / raw)
  To: u-boot

On 21-08-18 18:57, Jagan Teki wrote:
> On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
> <maxime.ripard@bootlin.com> wrote:
>> On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
>>> Usually eMMC is default mmc device for fastboot.
>>>
>>> By enabling DM_MMC, the mmc devices are probed as per
>>> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
>>> U-Boot proper.
>>>
>>> Allwinner SoC has maximum of 4 mmc controllers start from
>>> mmc0...mmc3 on which mmc2 can be used an eMMC controller
>>> eventhough mmc3 some boards used as eMMC.
>>>
>>> So, update the default fastboot device as 2 to make the
>>> standard usage irrespective of DT node status.
>>>
>>> Other corner cases like different device usage, or specific
>>> mmc node status is not enabled in order in DTS must explicitly
>>> add config on the specific defconfig file.
>>>
>>> Cc: Olliver Schinagl <oliver@schinagl.nl>
>>> Cc: Chen-Yu Tsai <wens@csie.org>
>>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>> This breaks all existing users, since if DM_MMC isn't set (and it
>> isn't at the moment), the MMC IDs won't change, and you're changing it
>> from either 0 or 1 to 2.
> True, bisectable issue. will take care on next version.
>
>> Can't we have a DT property instead? It looks much better than having
>> to deal with a non stable ID in Kconfig.
> What do you mean by DT property handle? mmc2 is eMMC in all sunXi
> isn't? ie reason I make it default.
That's absurdly naive :)

eMMC is whatever the board designer decides to hook it up to (and one
can even argue that there could be vendor trees that also have strange
designs)

While from a 'hacker' standpoint mmc0 SD, mmc2 eMMC makes tons of sense,
as those are the allwinner default bootable mmc interfaces, a proper
product may opt to put eMMC on mmc0 for 'security reasons'. E.g. secure
boot and what not. (Lets not get into discussions about how to secure
our platform or how secure it really is)

Further more, a designed board may use an SPI to boot, and end up with
eMMC on mmc3 due to the fact all other pins are in use.

Making this assumption that mmc2 is always eMMC (if mmc is used) is very
naive in my opinion and may bite us in the ass eventually.

Having a default, and letting it be overridable, is not a big issue of
course :)

Olliver

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 22/58] reset: Add reset valid
  2018-08-19 13:56 ` [U-Boot] [PATCH v3 22/58] reset: Add reset valid Jagan Teki
@ 2018-08-23 10:44   ` Simon Glass
  0 siblings, 0 replies; 87+ messages in thread
From: Simon Glass @ 2018-08-23 10:44 UTC (permalink / raw)
  To: u-boot

On 19 August 2018 at 07:56, Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> Add reset_valid to check whether given reset is valid
> or not.
>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  include/reset.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 54/58] clk: Use clk_get_by_index_tail()
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 54/58] clk: Use clk_get_by_index_tail() Jagan Teki
@ 2018-08-23 10:45   ` Simon Glass
  0 siblings, 0 replies; 87+ messages in thread
From: Simon Glass @ 2018-08-23 10:45 UTC (permalink / raw)
  To: u-boot

+Stephen

On 19 August 2018 at 07:57, Jagan Teki <jagan@amarulasolutions.com> wrote:
> clk_get_by_index_tail() now handle common clk get by index
> code so use it in relevant places.
>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  drivers/clk/clk-uclass.c | 77 +++++++++++++---------------------------
>  1 file changed, 25 insertions(+), 52 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 55/58] reset: Get the RESET by index without device
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 55/58] reset: Get the RESET by index without device Jagan Teki
@ 2018-08-23 10:45   ` Simon Glass
  0 siblings, 0 replies; 87+ messages in thread
From: Simon Glass @ 2018-08-23 10:45 UTC (permalink / raw)
  To: u-boot

Hi Jagan,

On 19 August 2018 at 07:57, Jagan Teki <jagan@amarulasolutions.com> wrote:
> Getting a RESET by index with device is not straight forward
> for some use-cases like handling clock operations for child
> node in parent driver. So we need to process the child node
> in parent probe via ofnode and process RESET operation for child
> without udevice but with ofnode.
>
> So add reset_get_by_index_nodev() and move the common code
> in reset_get_by_index_tail() to use for reset_get_by_index()
>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  drivers/reset/reset-uclass.c | 53 ++++++++++++++++++++++++------------
>  include/reset.h              | 16 +++++++++++
>  2 files changed, 52 insertions(+), 17 deletions(-)
>

Please add a test for the new function you add.

Regards,
Simon

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 53/58] clk: Get the CLK by index without device
  2018-08-19 13:57 ` [U-Boot] [PATCH v3 53/58] clk: Get the CLK by index without device Jagan Teki
@ 2018-08-23 10:45   ` Simon Glass
  0 siblings, 0 replies; 87+ messages in thread
From: Simon Glass @ 2018-08-23 10:45 UTC (permalink / raw)
  To: u-boot

+Stephen

On 19 August 2018 at 07:57, Jagan Teki <jagan@amarulasolutions.com> wrote:
> Getting a CLK by index with device is not straight forward
> for some use-cases like handling clock operations for child
> node in parent driver. So we need to process the child node
> in parent probe via ofnode and process CLK operation for child
> without udevice but with ofnode.
>
> So add clk_get_by_index_nodev() and move the common code
> in clk_get_by_index_tail() to use for clk_get_by_index()
>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  drivers/clk/clk-uclass.c | 61 +++++++++++++++++++++++++++++++++++++++-
>  include/clk.h            | 15 ++++++++++
>  2 files changed, 75 insertions(+), 1 deletion(-)

Can you please add a test for the new function you add?

Regards,
Simon

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device
  2018-08-22 16:43       ` Maxime Ripard
@ 2018-08-27  9:20         ` Jagan Teki
  2018-08-31 10:14           ` Maxime Ripard
  0 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-27  9:20 UTC (permalink / raw)
  To: u-boot

On Wed, Aug 22, 2018 at 10:13 PM, Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
> On Tue, Aug 21, 2018 at 10:27:38PM +0530, Jagan Teki wrote:
>> On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
>> <maxime.ripard@bootlin.com> wrote:
>> > On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
>> >> Usually eMMC is default mmc device for fastboot.
>> >>
>> >> By enabling DM_MMC, the mmc devices are probed as per
>> >> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
>> >> U-Boot proper.
>> >>
>> >> Allwinner SoC has maximum of 4 mmc controllers start from
>> >> mmc0...mmc3 on which mmc2 can be used an eMMC controller
>> >> eventhough mmc3 some boards used as eMMC.
>> >>
>> >> So, update the default fastboot device as 2 to make the
>> >> standard usage irrespective of DT node status.
>> >>
>> >> Other corner cases like different device usage, or specific
>> >> mmc node status is not enabled in order in DTS must explicitly
>> >> add config on the specific defconfig file.
>> >>
>> >> Cc: Olliver Schinagl <oliver@schinagl.nl>
>> >> Cc: Chen-Yu Tsai <wens@csie.org>
>> >> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>> >
>> > This breaks all existing users, since if DM_MMC isn't set (and it
>> > isn't at the moment), the MMC IDs won't change, and you're changing it
>> > from either 0 or 1 to 2.
>>
>> True, bisectable issue. will take care on next version.
>>
>> >
>> > Can't we have a DT property instead? It looks much better than having
>> > to deal with a non stable ID in Kconfig.
>>
>> What do you mean by DT property handle? mmc2 is eMMC in all sunXi
>> isn't? ie reason I make it default.
>
> I meant to select the fastboot and environment devices. That way, each
> board can select the one it wants in a truly deterministic way.

ie what get_env_fat_dev_part is doing. Identify the dev no.of
initialized mmc or emmc. are you referring something like this?

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 19/58] clk: sunxi: Implement direct MMC clocks
  2018-08-20 11:33   ` Maxime Ripard
@ 2018-08-27 10:04     ` Jagan Teki
  2018-08-28  9:51       ` Maxime Ripard
  0 siblings, 1 reply; 87+ messages in thread
From: Jagan Teki @ 2018-08-27 10:04 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 20, 2018 at 5:03 PM, Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
> On Sun, Aug 19, 2018 at 07:26:36PM +0530, Jagan Teki wrote:
>> Implement direct MMC clocks for all Allwinner SoC
>> clock drivers via clock map descriptor table.
>>
>> This includes adding ccu_clk_set_rate function pointer,
>> which indeed support CLK set_rate API, so update clock
>> handling in sunxi_mmc driver to support both no-dm and dm code.
>>
>> Cc: Jaehoon Chung <jh80.chung@samsung.com>
>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
>> ---
>>  arch/arm/include/asm/arch-sunxi/ccu.h | 10 +++++
>>  drivers/clk/sunxi/clk_a10.c           |  5 +++
>>  drivers/clk/sunxi/clk_a10s.c          |  6 +++
>>  drivers/clk/sunxi/clk_a23.c           |  6 +++
>>  drivers/clk/sunxi/clk_a31.c           |  5 +++
>>  drivers/clk/sunxi/clk_a64.c           |  4 ++
>>  drivers/clk/sunxi/clk_a83t.c          |  4 ++
>>  drivers/clk/sunxi/clk_h3.c            |  4 ++
>>  drivers/clk/sunxi/clk_r40.c           |  4 ++
>>  drivers/clk/sunxi/clk_sunxi.c         | 19 +++++++++
>>  drivers/clk/sunxi/clk_v3s.c           |  4 ++
>>  drivers/mmc/sunxi_mmc.c               | 58 +++++++++++++++++----------
>>  12 files changed, 107 insertions(+), 22 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/arch-sunxi/ccu.h b/arch/arm/include/asm/arch-sunxi/ccu.h
>> index bacd052ef3..4e30ab330c 100644
>> --- a/arch/arm/include/asm/arch-sunxi/ccu.h
>> +++ b/arch/arm/include/asm/arch-sunxi/ccu.h
>> @@ -60,6 +60,16 @@ struct sunxi_clk_priv {
>>
>>  extern struct clk_ops sunxi_clk_ops;
>>
>> +/**
>> + * mmc_clk_set_rate - mmc clock set rate
>> + *
>> + * @base:    clock register base address
>> + * @bit:     clock bit value
>> + * @rate:    clock input rate in Hz
>> + * @return 0, or -ve error code.
>> + */
>> +int mmc_clk_set_rate(void *base, u32 bit, ulong rate);
>> +
>>  /**
>>   * sunxi_reset_bind() - reset binding
>>   *
>> diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
>> index fb11231dd1..55176bc174 100644
>> --- a/drivers/clk/sunxi/clk_a10.c
>> +++ b/drivers/clk/sunxi/clk_a10.c
>> @@ -23,6 +23,11 @@ static struct ccu_clk_map a10_clks[] = {
>>       [CLK_AHB_MMC2]          = { 0x060, BIT(10), NULL },
>>       [CLK_AHB_MMC3]          = { 0x060, BIT(11), NULL },
>>
>> +     [CLK_MMC0]              = { 0x088, BIT(31), &mmc_clk_set_rate },
>> +     [CLK_MMC1]              = { 0x08c, BIT(31), &mmc_clk_set_rate },
>> +     [CLK_MMC2]              = { 0x090, BIT(31), &mmc_clk_set_rate },
>> +     [CLK_MMC3]              = { 0x094, BIT(31), &mmc_clk_set_rate },
>> +
>>       [CLK_USB_OHCI0]         = { 0x0cc, BIT(6), NULL },
>>       [CLK_USB_OHCI1]         = { 0x0cc, BIT(7), NULL },
>>       [CLK_USB_PHY]           = { 0x0cc, BIT(8), NULL },
>> diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
>> index bc4ae7352b..fbac0ad751 100644
>> --- a/drivers/clk/sunxi/clk_a10s.c
>> +++ b/drivers/clk/sunxi/clk_a10s.c
>> @@ -20,6 +20,12 @@ static struct ccu_clk_map a10s_clks[] = {
>>       [CLK_AHB_MMC1]          = { 0x060, BIT(9), NULL },
>>       [CLK_AHB_MMC2]          = { 0x060, BIT(10), NULL },
>>
>> +#ifdef CONFIG_MMC
>> +     [CLK_MMC0]              = { 0x088, BIT(31), &mmc_clk_set_rate },
>> +     [CLK_MMC1]              = { 0x08c, BIT(31), &mmc_clk_set_rate },
>> +     [CLK_MMC2]              = { 0x090, BIT(31), &mmc_clk_set_rate },
>> +#endif
>> +
>
> I'm not too sure about the ifdef here. Or at least, we should be
> consistent, and if we do it for the MMC, we should do it for all the
> SoCs (including the A10), and for all the controllers (including USB,
> for example).

because few of sun5i boards not using MMC, example CHIP and CHIP_pro
otherwise we need to use intermediate wrapper to call
mmc_clk_set_rate.

>
>> diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
>> index 39f15eb423..bf82014a64 100644
>> --- a/drivers/mmc/sunxi_mmc.c
>> +++ b/drivers/mmc/sunxi_mmc.c
>> @@ -13,6 +13,7 @@
>>  #include <malloc.h>
>>  #include <mmc.h>
>>  #include <asm/io.h>
>> +#include <asm/arch/ccu.h>
>>  #include <asm/arch/clock.h>
>>  #include <asm/arch/cpu.h>
>>  #include <asm/arch/gpio.h>
>> @@ -34,6 +35,8 @@ struct sunxi_mmc_priv {
>>       struct mmc_config cfg;
>>  };
>>
>> +bool new_mode;
>> +
>>  #if !CONFIG_IS_ENABLED(DM_MMC)
>>  /* support 4 mmc hosts */
>>  struct sunxi_mmc_priv mmc_host[4];
>> @@ -95,23 +98,19 @@ static int mmc_resource_init(int sdc_no)
>>  }
>>  #endif
>>
>> -static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
>> +int mmc_clk_set_rate(void *base, u32 bit, ulong rate)
>>  {
>>       unsigned int pll, pll_hz, div, n, oclk_dly, sclk_dly;
>> -     bool new_mode = false;
>>       u32 val = 0;
>>
>> -     if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
>> -             new_mode = true;
>> -
>
> [..]
>
>> +static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
>> +{
>> +#if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(CLK)
>> +#else
>> +     if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
>> +             new_mode = true;
>> +
>
> I'm not sure why you need the global variable.
>
> The A83t emmc case you have below is caught in this condition, and
> therefore, the scope doesn't need to be global.

Since mmc_set_rate calling with base and reg bits, which doesn't have
any possibility know private data of driver we need a global to check
to update the same in dm and non-dm.

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 19/58] clk: sunxi: Implement direct MMC clocks
  2018-08-27 10:04     ` Jagan Teki
@ 2018-08-28  9:51       ` Maxime Ripard
  2018-08-28 16:46         ` Jagan Teki
  0 siblings, 1 reply; 87+ messages in thread
From: Maxime Ripard @ 2018-08-28  9:51 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 27, 2018 at 03:34:20PM +0530, Jagan Teki wrote:
> >> diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
> >> index fb11231dd1..55176bc174 100644
> >> --- a/drivers/clk/sunxi/clk_a10.c
> >> +++ b/drivers/clk/sunxi/clk_a10.c
> >> @@ -23,6 +23,11 @@ static struct ccu_clk_map a10_clks[] = {
> >>       [CLK_AHB_MMC2]          = { 0x060, BIT(10), NULL },
> >>       [CLK_AHB_MMC3]          = { 0x060, BIT(11), NULL },
> >>
> >> +     [CLK_MMC0]              = { 0x088, BIT(31), &mmc_clk_set_rate },
> >> +     [CLK_MMC1]              = { 0x08c, BIT(31), &mmc_clk_set_rate },
> >> +     [CLK_MMC2]              = { 0x090, BIT(31), &mmc_clk_set_rate },
> >> +     [CLK_MMC3]              = { 0x094, BIT(31), &mmc_clk_set_rate },
> >> +
> >>       [CLK_USB_OHCI0]         = { 0x0cc, BIT(6), NULL },
> >>       [CLK_USB_OHCI1]         = { 0x0cc, BIT(7), NULL },
> >>       [CLK_USB_PHY]           = { 0x0cc, BIT(8), NULL },
> >> diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
> >> index bc4ae7352b..fbac0ad751 100644
> >> --- a/drivers/clk/sunxi/clk_a10s.c
> >> +++ b/drivers/clk/sunxi/clk_a10s.c
> >> @@ -20,6 +20,12 @@ static struct ccu_clk_map a10s_clks[] = {
> >>       [CLK_AHB_MMC1]          = { 0x060, BIT(9), NULL },
> >>       [CLK_AHB_MMC2]          = { 0x060, BIT(10), NULL },
> >>
> >> +#ifdef CONFIG_MMC
> >> +     [CLK_MMC0]              = { 0x088, BIT(31), &mmc_clk_set_rate },
> >> +     [CLK_MMC1]              = { 0x08c, BIT(31), &mmc_clk_set_rate },
> >> +     [CLK_MMC2]              = { 0x090, BIT(31), &mmc_clk_set_rate },
> >> +#endif
> >> +
> >
> > I'm not too sure about the ifdef here. Or at least, we should be
> > consistent, and if we do it for the MMC, we should do it for all the
> > SoCs (including the A10), and for all the controllers (including USB,
> > for example).
> 
> because few of sun5i boards not using MMC, example CHIP and CHIP_pro
> otherwise we need to use intermediate wrapper to call
> mmc_clk_set_rate.

Well, yes, but you can make the same argument for other SoCs, and
other features. So really, I think this is a good idea, but if we
remain consistent between SoCs and features.

> >
> >> diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
> >> index 39f15eb423..bf82014a64 100644
> >> --- a/drivers/mmc/sunxi_mmc.c
> >> +++ b/drivers/mmc/sunxi_mmc.c
> >> @@ -13,6 +13,7 @@
> >>  #include <malloc.h>
> >>  #include <mmc.h>
> >>  #include <asm/io.h>
> >> +#include <asm/arch/ccu.h>
> >>  #include <asm/arch/clock.h>
> >>  #include <asm/arch/cpu.h>
> >>  #include <asm/arch/gpio.h>
> >> @@ -34,6 +35,8 @@ struct sunxi_mmc_priv {
> >>       struct mmc_config cfg;
> >>  };
> >>
> >> +bool new_mode;
> >> +
> >>  #if !CONFIG_IS_ENABLED(DM_MMC)
> >>  /* support 4 mmc hosts */
> >>  struct sunxi_mmc_priv mmc_host[4];
> >> @@ -95,23 +98,19 @@ static int mmc_resource_init(int sdc_no)
> >>  }
> >>  #endif
> >>
> >> -static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
> >> +int mmc_clk_set_rate(void *base, u32 bit, ulong rate)
> >>  {
> >>       unsigned int pll, pll_hz, div, n, oclk_dly, sclk_dly;
> >> -     bool new_mode = false;
> >>       u32 val = 0;
> >>
> >> -     if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
> >> -             new_mode = true;
> >> -
> >
> > [..]
> >
> >> +static int mmc_set_mod_clk(struct sunxi_mmc_priv *priv, unsigned int hz)
> >> +{
> >> +#if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(CLK)
> >> +#else
> >> +     if (IS_ENABLED(CONFIG_MMC_SUNXI_HAS_NEW_MODE) && (priv->mmc_no == 2))
> >> +             new_mode = true;
> >> +
> >
> > I'm not sure why you need the global variable.
> >
> > The A83t emmc case you have below is caught in this condition, and
> > therefore, the scope doesn't need to be global.
> 
> Since mmc_set_rate calling with base and reg bits, which doesn't have
> any possibility know private data of driver we need a global to check
> to update the same in dm and non-dm.

Wouldn't that lead to issues if we have two controllers being active,
one with the new mode enabled, the other without, and you call
mmc_set_rate on the one without?

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180828/f6b82b74/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 19/58] clk: sunxi: Implement direct MMC clocks
  2018-08-28  9:51       ` Maxime Ripard
@ 2018-08-28 16:46         ` Jagan Teki
  0 siblings, 0 replies; 87+ messages in thread
From: Jagan Teki @ 2018-08-28 16:46 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 28, 2018 at 3:21 PM, Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
> On Mon, Aug 27, 2018 at 03:34:20PM +0530, Jagan Teki wrote:
>> >> diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
>> >> index fb11231dd1..55176bc174 100644
>> >> --- a/drivers/clk/sunxi/clk_a10.c
>> >> +++ b/drivers/clk/sunxi/clk_a10.c
>> >> @@ -23,6 +23,11 @@ static struct ccu_clk_map a10_clks[] = {
>> >>       [CLK_AHB_MMC2]          = { 0x060, BIT(10), NULL },
>> >>       [CLK_AHB_MMC3]          = { 0x060, BIT(11), NULL },
>> >>
>> >> +     [CLK_MMC0]              = { 0x088, BIT(31), &mmc_clk_set_rate },
>> >> +     [CLK_MMC1]              = { 0x08c, BIT(31), &mmc_clk_set_rate },
>> >> +     [CLK_MMC2]              = { 0x090, BIT(31), &mmc_clk_set_rate },
>> >> +     [CLK_MMC3]              = { 0x094, BIT(31), &mmc_clk_set_rate },
>> >> +
>> >>       [CLK_USB_OHCI0]         = { 0x0cc, BIT(6), NULL },
>> >>       [CLK_USB_OHCI1]         = { 0x0cc, BIT(7), NULL },
>> >>       [CLK_USB_PHY]           = { 0x0cc, BIT(8), NULL },
>> >> diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
>> >> index bc4ae7352b..fbac0ad751 100644
>> >> --- a/drivers/clk/sunxi/clk_a10s.c
>> >> +++ b/drivers/clk/sunxi/clk_a10s.c
>> >> @@ -20,6 +20,12 @@ static struct ccu_clk_map a10s_clks[] = {
>> >>       [CLK_AHB_MMC1]          = { 0x060, BIT(9), NULL },
>> >>       [CLK_AHB_MMC2]          = { 0x060, BIT(10), NULL },
>> >>
>> >> +#ifdef CONFIG_MMC
>> >> +     [CLK_MMC0]              = { 0x088, BIT(31), &mmc_clk_set_rate },
>> >> +     [CLK_MMC1]              = { 0x08c, BIT(31), &mmc_clk_set_rate },
>> >> +     [CLK_MMC2]              = { 0x090, BIT(31), &mmc_clk_set_rate },
>> >> +#endif
>> >> +
>> >
>> > I'm not too sure about the ifdef here. Or at least, we should be
>> > consistent, and if we do it for the MMC, we should do it for all the
>> > SoCs (including the A10), and for all the controllers (including USB,
>> > for example).
>>
>> because few of sun5i boards not using MMC, example CHIP and CHIP_pro
>> otherwise we need to use intermediate wrapper to call
>> mmc_clk_set_rate.
>
> Well, yes, but you can make the same argument for other SoCs, and
> other features. So really, I think this is a good idea, but if we
> remain consistent between SoCs and features.

True, I see adding wrapper make consistent on these descriptor table,
so the wrapper will call the actual set_rate, of course we need to add
ifdef in wrapper for non-MMC targets or __weak function.

^ permalink raw reply	[flat|nested] 87+ messages in thread

* [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device
  2018-08-27  9:20         ` Jagan Teki
@ 2018-08-31 10:14           ` Maxime Ripard
  0 siblings, 0 replies; 87+ messages in thread
From: Maxime Ripard @ 2018-08-31 10:14 UTC (permalink / raw)
  To: u-boot

On Mon, Aug 27, 2018 at 02:50:32PM +0530, Jagan Teki wrote:
> On Wed, Aug 22, 2018 at 10:13 PM, Maxime Ripard
> <maxime.ripard@bootlin.com> wrote:
> > On Tue, Aug 21, 2018 at 10:27:38PM +0530, Jagan Teki wrote:
> >> On Mon, Aug 20, 2018 at 5:14 PM, Maxime Ripard
> >> <maxime.ripard@bootlin.com> wrote:
> >> > On Sun, Aug 19, 2018 at 07:26:44PM +0530, Jagan Teki wrote:
> >> >> Usually eMMC is default mmc device for fastboot.
> >> >>
> >> >> By enabling DM_MMC, the mmc devices are probed as per
> >> >> DT status not with respect to MMC_SUNXI_SLOT_EXTRA in
> >> >> U-Boot proper.
> >> >>
> >> >> Allwinner SoC has maximum of 4 mmc controllers start from
> >> >> mmc0...mmc3 on which mmc2 can be used an eMMC controller
> >> >> eventhough mmc3 some boards used as eMMC.
> >> >>
> >> >> So, update the default fastboot device as 2 to make the
> >> >> standard usage irrespective of DT node status.
> >> >>
> >> >> Other corner cases like different device usage, or specific
> >> >> mmc node status is not enabled in order in DTS must explicitly
> >> >> add config on the specific defconfig file.
> >> >>
> >> >> Cc: Olliver Schinagl <oliver@schinagl.nl>
> >> >> Cc: Chen-Yu Tsai <wens@csie.org>
> >> >> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> >> >
> >> > This breaks all existing users, since if DM_MMC isn't set (and it
> >> > isn't at the moment), the MMC IDs won't change, and you're changing it
> >> > from either 0 or 1 to 2.
> >>
> >> True, bisectable issue. will take care on next version.
> >>
> >> >
> >> > Can't we have a DT property instead? It looks much better than having
> >> > to deal with a non stable ID in Kconfig.
> >>
> >> What do you mean by DT property handle? mmc2 is eMMC in all sunXi
> >> isn't? ie reason I make it default.
> >
> > I meant to select the fastboot and environment devices. That way, each
> > board can select the one it wants in a truly deterministic way.
> 
> ie what get_env_fat_dev_part is doing. Identify the dev no.of
> initialized mmc or emmc. are you referring something like this?

Yep, but through a DT property instead of some code.

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180831/5a9d75be/attachment.sig>

^ permalink raw reply	[flat|nested] 87+ messages in thread

end of thread, other threads:[~2018-08-31 10:14 UTC | newest]

Thread overview: 87+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-19 13:56 [U-Boot] [PATCH v3 00/58] clk: Add Allwinner CLK, RESET support Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 01/58] clk: Add Allwinner A64 CLK driver Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 02/58] reset: Add default request ops Jagan Teki
2018-08-20 11:22   ` Maxime Ripard
2018-08-19 13:56 ` [U-Boot] [PATCH v3 03/58] reset: Add Allwinner RESET driver Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 04/58] clk: sunxi: Add Allwinner H3/H5 CLK driver Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 05/58] clk: sunxi: Add Allwinner A10/A20 " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 06/58] clk: sunxi: Add Allwinner A10s/A13 " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 07/58] clk: sunxi: Add Allwinner A31 " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 08/58] clk: sunxi: Add Allwinner A23 " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 09/58] clk: sunxi: a23: Add CLK support for A33 Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 10/58] clk: sunxi: Add Allwinner A83T CLK driver Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 11/58] clk: sunxi: Add Allwinner R40 " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 12/58] clk: sunxi: Add Allwinner V3S " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 13/58] sunxi: Enable CLK Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 14/58] musb-new: sunxi: Use CLK and RESET support Jagan Teki
2018-08-20 11:26   ` Maxime Ripard
2018-08-19 13:56 ` [U-Boot] [PATCH v3 15/58] phy: sun4i-usb: " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 16/58] sunxi: usb: Switch to Generic host controllers Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 17/58] usb: host: Drop [e-o]hci-sunxi drivers Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 18/58] clk: sunxi: Implement AHB bus MMC clocks Jagan Teki
2018-08-20 11:28   ` Maxime Ripard
2018-08-19 13:56 ` [U-Boot] [PATCH v3 19/58] clk: sunxi: Implement direct " Jagan Teki
2018-08-20 11:33   ` Maxime Ripard
2018-08-27 10:04     ` Jagan Teki
2018-08-28  9:51       ` Maxime Ripard
2018-08-28 16:46         ` Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 20/58] clk: sunxi: Implement AHB bus MMC resets Jagan Teki
2018-08-20 11:28   ` Maxime Ripard
2018-08-19 13:56 ` [U-Boot] [PATCH v3 21/58] reset: Add get reset by name optionally Jagan Teki
2018-08-20 11:34   ` Maxime Ripard
2018-08-19 13:56 ` [U-Boot] [PATCH v3 22/58] reset: Add reset valid Jagan Teki
2018-08-23 10:44   ` Simon Glass
2018-08-19 13:56 ` [U-Boot] [PATCH v3 23/58] clk: sunxi: Add Allwinner H6 CLK, RESET driver Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 24/58] arm64: allwinner: dts: h6: fix Pine H64 MMC bus width Jagan Teki
2018-08-20 11:35   ` Maxime Ripard
2018-08-20 11:39     ` Jagan Teki
2018-08-20 14:16       ` Maxime Ripard
2018-08-19 13:56 ` [U-Boot] [PATCH v3 25/58] sunxi: h6: Enable CLK, RESET Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 26/58] dm: mmc: sunxi: Add CLK and RESET support Jagan Teki
2018-08-20 11:36   ` Maxime Ripard
2018-08-19 13:56 ` [U-Boot] [PATCH v3 27/58] fastboot: sunxi: Update fastboot mmc default device Jagan Teki
2018-08-20 11:44   ` Maxime Ripard
2018-08-21 16:57     ` Jagan Teki
2018-08-22 16:43       ` Maxime Ripard
2018-08-27  9:20         ` Jagan Teki
2018-08-31 10:14           ` Maxime Ripard
2018-08-22 18:56       ` Olliver Schinagl
2018-08-19 13:56 ` [U-Boot] [PATCH v3 28/58] env: fat: Add func to get fat device, partition Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 29/58] sunxi: Get fat device wrt boot device, 'auto' partition Jagan Teki
2018-08-20 11:45   ` Maxime Ripard
2018-08-19 13:56 ` [U-Boot] [PATCH v3 30/58] env: sunxi: Don't update fat dev, part wrt MMC_SUNXI_SLOT_EXTRA Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 31/58] sunxi: Add mmc 2, 3 bootenv devices Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 32/58] sunxi: A20: Enable DM_MMC Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 33/58] mmc: sunxi: Add mmc, emmc H5/A64 compatible Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 34/58] sunxi: H3_H5: Enable DM_MMC Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 35/58] sunxi: A64: " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 36/58] mmc: sunxi: Add A83T emmc compatible Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 37/58] sunxi: A83T: Enable DM_MMC Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 38/58] sunxi: V40: " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 39/58] sunxi: H6: " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 40/58] sunxi: A13/A31: " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 41/58] sunxi: A23/A33/V3S: " Jagan Teki
2018-08-19 13:56 ` [U-Boot] [PATCH v3 42/58] clk: sunxi: Implement SPI clocks Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 43/58] clk: sunxi: Implement SPI resets Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 44/58] spi: sun4i: Add CLK support Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 45/58] spi: Add Allwinner A31 SPI driver Jagan Teki
2018-08-20 11:18   ` Maxime Ripard
2018-08-20 11:42     ` Jagan Teki
2018-08-20 14:19       ` Maxime Ripard
2018-08-20 15:25         ` Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 46/58] clk: sunxi: Implement UART clocks Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 47/58] clk: sunxi: Implement UART resets Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 48/58] clk: sunxi: Implement Ethernet clocks Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 49/58] clk: sunxi: Implement Ethernet resets Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 50/58] net: sunxi_emac: Add CLK support Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 51/58] net: sun8i_emac: Retrieve GMAC clock via 'syscon' phandle Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 52/58] net: sun8i_emac: Add CLK and RESET support Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 53/58] clk: Get the CLK by index without device Jagan Teki
2018-08-23 10:45   ` Simon Glass
2018-08-19 13:57 ` [U-Boot] [PATCH v3 54/58] clk: Use clk_get_by_index_tail() Jagan Teki
2018-08-23 10:45   ` Simon Glass
2018-08-19 13:57 ` [U-Boot] [PATCH v3 55/58] reset: Get the RESET by index without device Jagan Teki
2018-08-23 10:45   ` Simon Glass
2018-08-19 13:57 ` [U-Boot] [PATCH v3 56/58] clk: sunxi: h3: Implement EPHY CLK and RESET Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 57/58] net: sun8i_emac: Add EPHY CLK and RESET support Jagan Teki
2018-08-19 13:57 ` [U-Boot] [PATCH v3 58/58] board: sunxi: gmac: Remove Ethernet clock and reset Jagan Teki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.