[U-Boot] [RFC 29/35] clk: sunxi: Add initial CLK driver for A83T
Jagan Teki
jagan at amarulasolutions.com
Mon Jul 16 11:28:44 UTC 2018
Add initial clock driver Allwinner A83T.
Implemented clock enable and disable functions for
USB OHCI, EHCI, OTG and PHY gate and clock registers.
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
drivers/clk/sunxi/Kconfig | 7 ++
drivers/clk/sunxi/Makefile | 1 +
drivers/clk/sunxi/clk_a83t.c | 120 +++++++++++++++++++++++++++++++++++
3 files changed, 128 insertions(+)
create mode 100644 drivers/clk/sunxi/clk_a83t.c
diff --git a/drivers/clk/sunxi/Kconfig b/drivers/clk/sunxi/Kconfig
index 40c6f999ca..2378fb2992 100644
--- a/drivers/clk/sunxi/Kconfig
+++ b/drivers/clk/sunxi/Kconfig
@@ -36,6 +36,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 8390602746..90013c5b25 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..524e8a0d33
--- /dev/null
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Amarula Solutions B.V.
+ * Author: Jagan Teki <jagan at amarulasolutions.com>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <dt-bindings/clock/sun8i-a83t-ccu.h>
+
+struct a83t_clk_priv {
+ void *base;
+};
+
+static int a83t_clk_enable(struct clk *clk)
+{
+ struct a83t_clk_priv *priv = dev_get_priv(clk->dev);
+
+ debug("%s(#%ld)\n", __func__, clk->id);
+
+ switch (clk->id) {
+ case CLK_BUS_OTG:
+ setbits_le32(priv->base + 0x60, BIT(24));
+ return 0;
+ case CLK_BUS_EHCI0:
+ case CLK_BUS_EHCI1:
+ setbits_le32(priv->base + 0x60,
+ BIT(26 + (clk->id - CLK_BUS_EHCI0)));
+ return 0;
+ case CLK_BUS_OHCI0:
+ setbits_le32(priv->base + 0x60, BIT(29));
+ return 0;
+ case CLK_USB_PHY0:
+ case CLK_USB_PHY1:
+ case CLK_USB_HSIC:
+ case CLK_USB_HSIC_12M:
+ setbits_le32(priv->base + 0xcc,
+ BIT(8 + (clk->id - CLK_USB_PHY0)));
+ return 0;
+ case CLK_USB_OHCI0:
+ setbits_le32(priv->base + 0xcc, BIT(16));
+ return 0;
+ default:
+ debug("%s (CLK#%ld) unhandled\n", __func__, clk->id);
+ return -ENODEV;
+ }
+}
+
+static int a83t_clk_disable(struct clk *clk)
+{
+ struct a83t_clk_priv *priv = dev_get_priv(clk->dev);
+
+ debug("%s(#%ld)\n", __func__, clk->id);
+
+ switch (clk->id) {
+ case CLK_BUS_OTG:
+ clrbits_le32(priv->base + 0x60, BIT(24));
+ return 0;
+ case CLK_BUS_EHCI0:
+ case CLK_BUS_EHCI1:
+ clrbits_le32(priv->base + 0x60,
+ BIT(26 + (clk->id - CLK_BUS_EHCI0)));
+ return 0;
+ case CLK_BUS_OHCI0:
+ clrbits_le32(priv->base + 0x60, BIT(29));
+ return 0;
+ case CLK_USB_PHY0:
+ case CLK_USB_PHY1:
+ case CLK_USB_HSIC:
+ case CLK_USB_HSIC_12M:
+ clrbits_le32(priv->base + 0xcc,
+ BIT(8 + (clk->id - CLK_USB_PHY0)));
+ return 0;
+ case CLK_USB_OHCI0:
+ clrbits_le32(priv->base + 0xcc, BIT(16));
+ return 0;
+ default:
+ debug("%s (CLK#%ld) unhandled\n", __func__, clk->id);
+ return -ENODEV;
+ }
+}
+
+static struct clk_ops a83t_clk_ops = {
+ .enable = a83t_clk_enable,
+ .disable = a83t_clk_disable,
+};
+
+static int a83t_clk_probe(struct udevice *dev)
+{
+ return 0;
+}
+
+static int a83t_clk_ofdata_to_platdata(struct udevice *dev)
+{
+ struct a83t_clk_priv *priv = dev_get_priv(dev);
+
+ priv->base = dev_read_addr_ptr(dev);
+
+ return 0;
+}
+
+static const struct udevice_id a83t_clk_ids[] = {
+ { .compatible = "allwinner,sun8i-a83t-ccu" },
+ { }
+};
+
+U_BOOT_DRIVER(clk_sun8i_a83t) = {
+ .name = "sun8i_a83t_ccu",
+ .id = UCLASS_CLK,
+ .of_match = a83t_clk_ids,
+ .priv_auto_alloc_size = sizeof(struct a83t_clk_priv),
+ .ofdata_to_platdata = a83t_clk_ofdata_to_platdata,
+ .ops = &a83t_clk_ops,
+ .probe = a83t_clk_probe,
+ .bind = sunxi_clk_bind,
+};
--
2.17.1
More information about the U-Boot
mailing list