Re: [PATCH] aspeed: AST2600 Pinctrl Driver

2021-11-18 Thread Tom Rini
On Tue, Nov 02, 2021 at 10:17:52AM +0800, Dylan Hung wrote:

> From: Ryan Chen 
> 
> This driver uses Pinctrl framework and is compatible with the Linux
> driver for AST2600.
> 
> Signed-off-by: Ryan Chen 
> Signed-off-by: Dylan Hung 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] aspeed: AST2600 Pinctrl Driver

2021-11-01 Thread Dylan Hung
From: Ryan Chen 

This driver uses Pinctrl framework and is compatible with the Linux
driver for AST2600.

Signed-off-by: Ryan Chen 
Signed-off-by: Dylan Hung 
---
 drivers/pinctrl/Kconfig  |   9 +
 drivers/pinctrl/aspeed/Makefile  |   1 +
 drivers/pinctrl/aspeed/pinctrl_ast2600.c | 459 +++
 3 files changed, 469 insertions(+)
 create mode 100644 drivers/pinctrl/aspeed/pinctrl_ast2600.c

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 30eaa376c8..42f25e24fb 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -291,6 +291,15 @@ config ASPEED_AST2500_PINCTRL
  uses Generic Pinctrl framework and is compatible with the Linux
  driver, i.e. it uses the same device tree configuration.
 
+config ASPEED_AST2600_PINCTRL
+   bool "Aspeed AST2600 pin control driver"
+   depends on DM && PINCTRL_GENERIC && ASPEED_AST2600
+   default y
+   help
+ Support pin multiplexing control on Aspeed ast2600 SoC. The driver
+ uses Generic Pinctrl framework and is compatible with the Linux
+ driver, i.e. it uses the same device tree configuration.
+
 config PINCTRL_K210
bool "Kendryte K210 Fully-Programmable Input/Output Array driver"
depends on DM && PINCTRL_GENERIC
diff --git a/drivers/pinctrl/aspeed/Makefile b/drivers/pinctrl/aspeed/Makefile
index 2e6ed604c8..a3e01ed1ca 100644
--- a/drivers/pinctrl/aspeed/Makefile
+++ b/drivers/pinctrl/aspeed/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_ASPEED_AST2500_PINCTRL) += pinctrl_ast2500.o
+obj-$(CONFIG_ASPEED_AST2600_PINCTRL) += pinctrl_ast2600.o
diff --git a/drivers/pinctrl/aspeed/pinctrl_ast2600.c 
b/drivers/pinctrl/aspeed/pinctrl_ast2600.c
new file mode 100644
index 00..12cba83f6c
--- /dev/null
+++ b/drivers/pinctrl/aspeed/pinctrl_ast2600.c
@@ -0,0 +1,459 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) ASPEED Technology Inc.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * This driver works with very simple configuration that has the same name
+ * for group and function. This way it is compatible with the Linux Kernel
+ * driver.
+ */
+struct aspeed_sig_desc {
+   u32 offset;
+   u32 reg_set;
+   int clr;
+};
+
+struct aspeed_group_config {
+   char *group_name;
+   int ndescs;
+   struct aspeed_sig_desc *descs;
+};
+
+struct ast2600_pinctrl_priv {
+   struct ast2600_scu *scu;
+};
+
+static int ast2600_pinctrl_probe(struct udevice *dev)
+{
+   struct ast2600_pinctrl_priv *priv = dev_get_priv(dev);
+   struct udevice *clk_dev;
+   int ret = 0;
+
+   /* find SCU base address from clock device */
+   uclass_get_device_by_driver(UCLASS_CLK, 
DM_DRIVER_GET(aspeed_ast2600_scu), _dev);
+
+   if (ret)
+   return ret;
+
+   priv->scu = dev_read_addr_ptr(clk_dev);
+   if (IS_ERR(priv->scu))
+   return PTR_ERR(priv->scu);
+
+   return 0;
+}
+
+static struct aspeed_sig_desc i2c1_link[] = {
+   { 0x418, GENMASK(9, 8), 1 },
+   { 0x4B8, GENMASK(9, 8), 0 },
+};
+
+static struct aspeed_sig_desc i2c2_link[] = {
+   { 0x418, GENMASK(11, 10), 1 },
+   { 0x4B8, GENMASK(11, 10), 0 },
+};
+
+static struct aspeed_sig_desc i2c3_link[] = {
+   { 0x418, GENMASK(13, 12), 1 },
+   { 0x4B8, GENMASK(13, 12), 0 },
+};
+
+static struct aspeed_sig_desc i2c4_link[] = {
+   { 0x418, GENMASK(15, 14), 1 },
+   { 0x4B8, GENMASK(15, 14), 0 },
+};
+
+static struct aspeed_sig_desc i2c5_link[] = {
+   { 0x418, GENMASK(17, 16), 0 },
+};
+
+static struct aspeed_sig_desc i2c6_link[] = {
+   { 0x418, GENMASK(19, 18), 0 },
+};
+
+static struct aspeed_sig_desc i2c7_link[] = {
+   { 0x418, GENMASK(21, 20), 0 },
+};
+
+static struct aspeed_sig_desc i2c8_link[] = {
+   { 0x418, GENMASK(23, 22), 0 },
+};
+
+static struct aspeed_sig_desc i2c9_link[] = {
+   { 0x418, GENMASK(25, 24), 0 },
+};
+
+static struct aspeed_sig_desc i2c10_link[] = {
+   { 0x418, GENMASK(27, 26), 0 },
+};
+
+static struct aspeed_sig_desc i2c11_link[] = {
+   { 0x410, GENMASK(1, 0), 1 },
+   { 0x4B0, GENMASK(1, 0), 0 },
+};
+
+static struct aspeed_sig_desc i2c12_link[] = {
+   { 0x410, GENMASK(3, 2), 1 },
+   { 0x4B0, GENMASK(3, 2), 0 },
+};
+
+static struct aspeed_sig_desc i2c13_link[] = {
+   { 0x410, GENMASK(5, 4), 1 },
+   { 0x4B0, GENMASK(5, 4), 0 },
+};
+
+static struct aspeed_sig_desc i2c14_link[] = {
+   { 0x410, GENMASK(7, 6), 1 },
+   { 0x4B0, GENMASK(7, 6), 0 },
+};
+
+static struct aspeed_sig_desc i2c15_link[] = {
+   { 0x414, GENMASK(29, 28), 1 },
+   { 0x4B4, GENMASK(29, 28), 0 },
+};
+
+static struct aspeed_sig_desc i2c16_link[] = {
+   { 0x414, GENMASK(31, 30), 1 },
+   { 0x4B4, GENMASK(31, 30), 0 },
+};
+
+static struct aspeed_sig_desc mac1_link[] = {
+   { 0x410, BIT(4), 0 },
+   { 0x470, BIT(4), 1 },
+};
+
+static