Skip to contentSkip to conversation

Add ASPEED AST2600 I2C new controller driver

PATCH Superseded ryan_chen 3 participants 7 messages Mar 23, 2022 – Mar 25, 2022

Subsystems (3)

v1 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

ryan_chen

author reviewer
#0 lore raw

cover Add ASPEED AST2600 I2C new controller driver

This series add AST2600 i2c new register mode driver. The i2c new register mode have new clock divider option for more flexibale generation. And also have separate i2c master and slave register set for control.

ryan_chen (2):
dt-bindings: i2c-new: Add bindings for AST2600 i2C new controller i2c:aspeed:support ast2600 i2c new register mode driver

 .../bindings/i2c/aspeed,i2c-new.yaml          |   78 +
 drivers/i2c/busses/Kconfig                    |   11 +
 drivers/i2c/busses/Makefile                   |    1 +
 drivers/i2c/busses/aspeed-i2c-new-global.c    |   91 +
 drivers/i2c/busses/aspeed-i2c-new-global.h    |   19 +
 drivers/i2c/busses/i2c-new-aspeed.c           | 1698 +++++++++++++++++
 6 files changed, 1898 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/aspeed,i2c-new.yaml
 create mode 100644 drivers/i2c/busses/aspeed-i2c-new-global.c
 create mode 100644 drivers/i2c/busses/aspeed-i2c-new-global.h
 create mode 100644 drivers/i2c/busses/i2c-new-aspeed.c
Signature · 1 line
2.25.1
author reviewer
#1 lore raw

PATCH 1/2 dt-bindings: i2c-new: Add bindings for AST2600 i2C new controller

AST2600 support new register set for I2C controller, add bindings document to support driver of i2c new controller

---
 .../bindings/i2c/aspeed,i2c-new.yaml          | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/aspeed,i2c-new.yaml
Documentation/devicetree/bindings/i2c/aspeed,i2c-new.yaml new file +78 -0
new file mode 100644
index 000000000000..2e49c5438ad2
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/i2c/aspeed,i2c-new.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASPEED New I2C Controller on the AST26XX SoCs Device Tree Bindings
+
+maintainers:
+  - Ryan Chen <[email protected]>
+
+allOf:
+  - $ref: /schemas/i2c/i2c-controller.yaml#
+
+properties:
+  compatible:
+    enum:
+      - aspeed,ast2600-i2c-bus
+
+  reg:
+    minItems: 1
+    items:
+      - description: address offset and range of bus
+      - description: address offset and range of bus buffer
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+    description:
+      root clock of bus, should reference the APB
+      clock in the second cell
+
+  resets:
+    maxItems: 1
+
+  bus-frequency:
+    minimum: 500
+    maximum: 2000000
+    default: 100000
+    description: frequency of the bus clock in Hz defaults to 100 kHz when not
+      specified
+
+  multi-master:
+    type: boolean
+    description:
+      states that there is another master active on this bus
+
+required:
+  - reg
+  - compatible
+  - clocks
+  - resets
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/ast2600-clock.h>
+
+    i2c_gr: i2c-global-regs at 0 {
+      compatible = "aspeed,ast2600-i2c-global", "syscon";
+      reg = <0x0 0x20>;
+      resets = <&syscon ASPEED_RESET_I2C>;
+    };
+
+    i2c0: i2c-bus at 80 {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      #interrupt-cells = <1>;
+      compatible = "aspeed,ast2600-i2c-bus";
+      reg = <0x80 0x80>, <0xC00 0x20>;
+      clocks = <&syscon ASPEED_CLK_APB2>;
+      resets = <&syscon ASPEED_RESET_I2C>;
+      bus-frequency = <100000>;
+    };
Signature · 1 line
2.25.1
author reviewer
#2 lore raw

PATCH 2/2 i2c:aspeed:support ast2600 i2c new register mode driver

In reply to ryan_chen

Add i2c new register mode driver to support AST2600 i2c new register set. AST2600 i2c controller have legacy and new register mode. The new register mode have global register support 4 base clock for scl clock selection, and new clock divider mode. And i2c new register mode have separate register set to control i2c master and slave.

---
 drivers/i2c/busses/Kconfig                 |   11 +
 drivers/i2c/busses/Makefile                |    1 +
 drivers/i2c/busses/aspeed-i2c-new-global.c |   91 ++
 drivers/i2c/busses/aspeed-i2c-new-global.h |   19 +
 drivers/i2c/busses/i2c-new-aspeed.c        | 1698 ++++++++++++++++++++
 5 files changed, 1820 insertions(+)
 create mode 100644 drivers/i2c/busses/aspeed-i2c-new-global.c
 create mode 100644 drivers/i2c/busses/aspeed-i2c-new-global.h
 create mode 100644 drivers/i2c/busses/i2c-new-aspeed.c
drivers/i2c/busses/Kconfig +11 -0
index 8a6c6ee28556..edad4ed9150d 100644
@@ -378,6 +378,17 @@ config I2C_ALTERA
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-altera.
 
+config I2C_NEW_ASPEED
+	tristate "Aspeed New I2C Controller"
+	depends on ARCH_ASPEED || MACH_ASPEED_G6 || COMPILE_TEST
+	select I2C_SMBUS
+	help
+	  If you say yes to this option, support will be included for the
+	  Aspeed I2C controller with new register set.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called i2c-new-aspeed.
+
 config I2C_ASPEED
 	tristate "Aspeed I2C Controller"
 	depends on ARCH_ASPEED || COMPILE_TEST
drivers/i2c/busses/Makefile +1 -0
index 1d00dce77098..b261f2b29b7c 100644
@@ -35,6 +35,7 @@ obj-$(CONFIG_I2C_POWERMAC)	+= i2c-powermac.o
 obj-$(CONFIG_I2C_ALTERA)	+= i2c-altera.o
 obj-$(CONFIG_I2C_AMD_MP2)	+= i2c-amd-mp2-pci.o i2c-amd-mp2-plat.o
 obj-$(CONFIG_I2C_ASPEED)	+= i2c-aspeed.o
+obj-$(CONFIG_I2C_NEW_ASPEED)	+= aspeed-i2c-new-global.o i2c-new-aspeed.o
 obj-$(CONFIG_I2C_AT91)		+= i2c-at91.o
 i2c-at91-objs			:= i2c-at91-core.o i2c-at91-master.o
 ifeq ($(CONFIG_I2C_AT91_SLAVE_EXPERIMENTAL),y)
drivers/i2c/busses/aspeed-i2c-new-global.c new file +91 -0

91 lines not on this page · raw message

drivers/i2c/busses/aspeed-i2c-new-global.h new file +19 -0
new file mode 100644
index 000000000000..0cc5033f9478
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef AST2600_I2C_NEW_GLOBAL_H
+#define AST2600_I2C_NEW_GLOBAL_H
+
+#include <linux/bits.h>
+
+#define ASPEED_I2CG_ISR			0x00
+#define ASPEED_I2CG_SLAVE_ISR		0x04
+#define ASPEED_I2CG_OWNER		0x08
+#define ASPEED_I2CG_CTRL		0x0C
+#define ASPEED_I2CG_CLK_DIV_CTRL	0x10
+
+#define ASPEED_I2CG_SLAVE_PKT_NAK	BIT(4)
+#define ASPEED_I2CG_M_S_SEPARATE_INTR	BIT(3)
+#define ASPEED_I2CG_CTRL_NEW_REG	BIT(2)
+#define ASPEED_I2CG_CTRL_NEW_CLK_DIV	BIT(1)
+
+#endif /* AST2600_I2C_NEW_GLOBAL_H */
drivers/i2c/busses/i2c-new-aspeed.c new file +1698 -0

1,698 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH 2/2] i2c:aspeed:support ast2600 i2c new register mode driver

Thank you for the patch! Perhaps something to improve:

Hi ryan_chen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on robh/for-next pza/reset/next v5.17 next-20220322] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/ryan_chen/Add-ASPEED-AST2600-I2C-new-controller-driver/20220323-084205
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20220323/202203231247.KCb0uKWD-lkp at intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/4fa1d6c517dfca057852514880a8e52e5da51572
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review ryan_chen/Add-ASPEED-AST2600-I2C-new-controller-driver/20220323-084205 git checkout 4fa1d6c517dfca057852514880a8e52e5da51572
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/i2c/busses/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/i2c/busses/i2c-new-aspeed.c: In function 'aspeed_new_i2c_init':

>> drivers/i2c/busses/i2c-new-aspeed.c:1407:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    1407 |         u8 i2c_count = (((u32)(i2c_bus->reg_base) & 0xFFF)/0x80);
         |                          ^

vim +1407 drivers/i2c/busses/i2c-new-aspeed.c

1402
1403 static void aspeed_new_i2c_init(struct aspeed_new_i2c_bus *i2c_bus)
1404 {
1405 struct platform_device *pdev = to_platform_device(i2c_bus->dev);
1406 u32 fun_ctrl = AST_I2CC_BUS_AUTO_RELEASE | AST_I2CC_MASTER_EN;

> 1407		u8 i2c_count = (((u32)(i2c_bus->reg_base) & 0xFFF)/0x80);

1408
1409 /* I2C Reset */
1410 writel(0, i2c_bus->reg_base + AST_I2CC_FUN_CTRL);
1411
1412 if (of_property_read_bool(pdev->dev.of_node, "multi-master"))
1413 i2c_bus->multi_master = true;
1414 else
1415 fun_ctrl |= AST_I2CC_MULTI_MASTER_DIS;
1416
1417 /* AST2600 i2c10 need to overcome sda glich with is flag. */
1418 if (i2c_count == 0xA)
1419 fun_ctrl |= AST_I2CC_SDA_DRIVE_1T_EN;
1420
1421 /* Enable Master Mode */
1422 writel(fun_ctrl, i2c_bus->reg_base + AST_I2CC_FUN_CTRL);
1423 /* disable slave address */
1424 writel(0, i2c_bus->reg_base + AST_I2CS_ADDR_CTRL);
1425
1426 /* Set AC Timing */
1427 writel(aspeed_select_i2c_clock(i2c_bus), i2c_bus->reg_base + AST_I2CC_AC_TIMING);
1428
1429 /* Clear Interrupt */
1430 writel(0xfffffff, i2c_bus->reg_base + AST_I2CM_ISR);
1431

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#4 lore raw

Re: [PATCH 2/2] i2c:aspeed:support ast2600 i2c new register mode driver

In reply to ryan_chen
Quoted 7 lines · ryan_chen

Add i2c new register mode driver to support AST2600 i2c new register set. AST2600 i2c controller have legacy and new register mode. The new register mode have global register support 4 base clock for scl clock selection, and new clock divider mode. And i2c new register mode have separate register set to control i2c master and slave.

Quoted 7 lines
---
 drivers/i2c/busses/Kconfig                 |   11 +
 drivers/i2c/busses/Makefile                |    1 +
 drivers/i2c/busses/aspeed-i2c-new-global.c |   91 ++
 drivers/i2c/busses/aspeed-i2c-new-global.h |   19 +
 drivers/i2c/busses/i2c-new-aspeed.c        | 1698 ++++++++++++++++++++

I always find it funny when somebody uses 'new'. What is the next version going to be called? 'even-newer', and the version after that 'really-really-new'?

drivers/i2c/busses/i2c-new-aspeed.c line 1525

Quoted 4 lines
drivers/i2c/busses/i2c-new-aspeed.c new file +4 -0
+static const struct of_device_id aspeed_new_i2c_bus_of_table[] = {
+	{
+		.compatible = "aspeed,ast2600-i2c-bus",
+	},

Given this compatible string, why not call it i2c-aspeed-2600.c, and remove 'new' everywhere.

Andrew

author reviewer
#5 lore raw

RE: [PATCH 2/2] i2c:aspeed:support ast2600 i2c new register mode driver

Hello,

Quoted 31 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Wednesday, March 23, 2022 8:38 PM
To: Ryan Chen <[email protected]>
Cc: BMC-SW <[email protected]>; Rob Herring <[email protected]>; Joel Stanley <[email protected]>; Andrew Jeffery <[email protected]>; Philipp Zabel <[email protected]>; linux-arm-kernel at lists.infradead.org; linux-aspeed at lists.ozlabs.org; linux-kernel at vger.kernel.org
Subject: Re: [PATCH 2/2] i2c:aspeed:support ast2600 i2c new register mode driver

Quoted 6 lines · ryan_chen

Add i2c new register mode driver to support AST2600 i2c new register set. AST2600 i2c controller have legacy and new register mode. The new register mode have global register support 4 base clock for scl clock selection, and new clock divider mode. And i2c new register mode have separate register set to control i2c master and slave.

Quoted 7 lines
---
 drivers/i2c/busses/Kconfig                 |   11 +
 drivers/i2c/busses/Makefile                |    1 +
 drivers/i2c/busses/aspeed-i2c-new-global.c |   91 ++
 drivers/i2c/busses/aspeed-i2c-new-global.h |   19 +
 drivers/i2c/busses/i2c-new-aspeed.c        | 1698

++++++++++++++++++++

I always find it funny when somebody uses 'new'. What is the next version going to be called? 'even-newer', and the version after that 'really-really-new'?

Quoted 8 lines

drivers/i2c/busses/i2c-new-aspeed.c line 1525

Quoted 4 lines
drivers/i2c/busses/i2c-new-aspeed.c new file +4 -0
+static const struct of_device_id aspeed_new_i2c_bus_of_table[] = {
+	{
+		.compatible = "aspeed,ast2600-i2c-bus",
+	},

Given this compatible string, why not call it i2c-aspeed-2600.c, and remove 'new' everywhere.

Yes, I struggle the naming, but the next generation ast2700 still used. The name "i2c-aspeed-2600.c" may not adaptable.
Or How about name it to i2c-aspeed-package.c due to this is major feature For this new i2c controller design?

Ryan

#6 lore raw

Re: [PATCH 2/2] i2c:aspeed:support ast2600 i2c new register mode driver

In reply to ryan_chen
Thank you for the patch! Perhaps something to improve:

Hi ryan_chen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on robh/for-next pza/reset/next v5.17 next-20220323] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/ryan_chen/Add-ASPEED-AST2600-I2C-new-controller-driver/20220323-084205
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20220324/202203241617.RVjnwFdn-lkp at intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 902f4708fe1d03b0de7e5315ef875006a6adc319)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/4fa1d6c517dfca057852514880a8e52e5da51572
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review ryan_chen/Add-ASPEED-AST2600-I2C-new-controller-driver/20220323-084205 git checkout 4fa1d6c517dfca057852514880a8e52e5da51572
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/i2c/busses/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/i2c/busses/i2c-new-aspeed.c:1407:19: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'void *' [-Wvoid-pointer-to-int-cast]
           u8 i2c_count = (((u32)(i2c_bus->reg_base) & 0xFFF)/0x80);
                            ^~~~~~~~~~~~~~~~~~~~~~~~

1 warning generated.

vim +1407 drivers/i2c/busses/i2c-new-aspeed.c

1402
1403 static void aspeed_new_i2c_init(struct aspeed_new_i2c_bus *i2c_bus)
1404 {
1405 struct platform_device *pdev = to_platform_device(i2c_bus->dev);
1406 u32 fun_ctrl = AST_I2CC_BUS_AUTO_RELEASE | AST_I2CC_MASTER_EN;

> 1407		u8 i2c_count = (((u32)(i2c_bus->reg_base) & 0xFFF)/0x80);

1408
1409 /* I2C Reset */
1410 writel(0, i2c_bus->reg_base + AST_I2CC_FUN_CTRL);
1411
1412 if (of_property_read_bool(pdev->dev.of_node, "multi-master"))
1413 i2c_bus->multi_master = true;
1414 else
1415 fun_ctrl |= AST_I2CC_MULTI_MASTER_DIS;
1416
1417 /* AST2600 i2c10 need to overcome sda glich with is flag. */
1418 if (i2c_count == 0xA)
1419 fun_ctrl |= AST_I2CC_SDA_DRIVE_1T_EN;
1420
1421 /* Enable Master Mode */
1422 writel(fun_ctrl, i2c_bus->reg_base + AST_I2CC_FUN_CTRL);
1423 /* disable slave address */
1424 writel(0, i2c_bus->reg_base + AST_I2CS_ADDR_CTRL);
1425
1426 /* Set AC Timing */
1427 writel(aspeed_select_i2c_clock(i2c_bus), i2c_bus->reg_base + AST_I2CC_AC_TIMING);
1428
1429 /* Clear Interrupt */
1430 writel(0xfffffff, i2c_bus->reg_base + AST_I2CM_ISR);
1431

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp