i3c: ast2600: Add MCTP-over-I3C support
Subsystems (5)
cover i3c: ast2600: Add MCTP-over-I3C support
Add Aspeed AST2600 I3C controllers and add minimal changes to validate the functionality for MCTP-over-I3C.
Dylan Hung (2):
[RFC] ARM: dts: aspeed-g6: Add AST2600 I3Cs [RFC] i3c: ast2600: Validate AST2600 I3C for MCTP-over-I3C
arch/arm/boot/dts/aspeed/aspeed-g6.dtsi | 137 +++++++ drivers/i3c/master/ast2600-i3c-master.c | 137 +++++++ drivers/i3c/master/dw-i3c-master.c | 513 ++++++++++++++++++++---- drivers/i3c/master/dw-i3c-master.h | 12 + 4 files changed, 718 insertions(+), 81 deletions(-)
Signature · 1 line
2.25.1
RFC PATCH 1/2 ARM: dts: aspeed-g6: Add AST2600 I3Cs
The AST2600 has 6 I3Cs which are based on dw-i3c along with Aspeed proprietary enhancements.
--- arch/arm/boot/dts/aspeed/aspeed-g6.dtsi | 137 ++++++++++++++++++++++++ 1 file changed, 137 insertions(+)
arch/arm/boot/dts/aspeed/aspeed-g6.dtsi +137 -0
@@ -13,6 +13,12 @@ / { interrupt-parent = <&gic>; aliases { + i3c0 = &i3c0; + i3c1 = &i3c1; + i3c2 = &i3c2; + i3c3 = &i3c3; + i3c4 = &i3c4; + i3c5 = &i3c5; i2c0 = &i2c0; i2c1 = &i2c1; i2c2 = &i2c2;
@@ -579,6 +585,13 @@ wdt4: watchdog at 1e7850c0 { status = "disabled"; }; + i3c: bus at 1e7a0000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x1e7a0000 0x8000>; + }; + peci0: peci-controller at 1e78b000 { compatible = "aspeed,ast2600-peci"; reg = <0x1e78b000 0x100>;
@@ -1125,3 +1138,127 @@ i2c15: i2c-bus at 800 { status = "disabled"; }; }; + +&i3c { + i3c_global: i3c-global { + compatible = "aspeed,ast2600-i3c-global", "simple-mfd", "syscon"; + resets = <&syscon ASPEED_RESET_I3C>; + reg = <0x0 0x1000>; + }; + + i3c0: i3c at 2000 { + compatible = "aspeed,ast2600-i3c"; + reg = <0x2000 0x1000>; + clocks = <&syscon ASPEED_CLK_GATE_I3C0CLK>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i3c1_default>; + interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>; + aspeed,global-regs = <&i3c_global 0>; + status = "disabled"; + + i2c-scl-hz = <1000000>; + i3c-scl-hz = <2000000>; + i3c-od-scl-hi-period-ns = <380>; + i3c-od-scl-lo-period-ns = <620>; + i3c-pp-scl-hi-period-ns = <250>; + i3c-pp-scl-lo-period-ns = <250>; + sda-tx-hold-ns = <70>; + sda-pullup-ohms = <2000>; + }; + + i3c1: i3c at 3000 { + compatible = "aspeed,ast2600-i3c"; + reg = <0x3000 0x1000>; + clocks = <&syscon ASPEED_CLK_GATE_I3C1CLK>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i3c2_default>; + interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; + aspeed,global-regs = <&i3c_global 1>; + status = "disabled"; + + i2c-scl-hz = <1000000>; + i3c-scl-hz = <2000000>; + i3c-od-scl-hi-period-ns = <380>; + i3c-od-scl-lo-period-ns = <620>; + i3c-pp-scl-hi-period-ns = <250>; + i3c-pp-scl-lo-period-ns = <250>; + sda-tx-hold-ns = <70>; + sda-pullup-ohms = <2000>; + }; + + i3c2: i3c at 4000 { + compatible = "aspeed,ast2600-i3c"; + reg = <0x4000 0x1000>; + clocks = <&syscon ASPEED_CLK_GATE_I3C2CLK>; + interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>; + aspeed,global-regs = <&i3c_global 2>; + status = "disabled"; + + i2c-scl-hz = <1000000>; + i3c-scl-hz = <2000000>; + i3c-od-scl-hi-period-ns = <380>; + i3c-od-scl-lo-period-ns = <620>; + i3c-pp-scl-hi-period-ns = <250>; + i3c-pp-scl-lo-period-ns = <250>; + sda-tx-hold-ns = <70>; + sda-pullup-ohms = <2000>; + }; + + i3c3: i3c at 5000 { + compatible = "aspeed,ast2600-i3c"; + reg = <0x5000 0x1000>; + clocks = <&syscon ASPEED_CLK_GATE_I3C3CLK>; + interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>; + aspeed,global-regs = <&i3c_global 3>; + status = "disabled"; + + i2c-scl-hz = <1000000>; + i3c-scl-hz = <2000000>; + i3c-od-scl-hi-period-ns = <380>; + i3c-od-scl-lo-period-ns = <620>; + i3c-pp-scl-hi-period-ns = <250>; + i3c-pp-scl-lo-period-ns = <250>; + sda-tx-hold-ns = <70>; + sda-pullup-ohms = <2000>; + }; + + i3c4: i3c at 6000 { + compatible = "aspeed,ast2600-i3c"; + reg = <0x6000 0x1000>; + clocks = <&syscon ASPEED_CLK_GATE_I3C4CLK>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i3c5_default>; + interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + aspeed,global-regs = <&i3c_global 4>; + status = "disabled"; + + i2c-scl-hz = <1000000>; + i3c-scl-hz = <2000000>; + i3c-od-scl-hi-period-ns = <380>; + i3c-od-scl-lo-period-ns = <620>; + i3c-pp-scl-hi-period-ns = <250>; + i3c-pp-scl-lo-period-ns = <250>; + sda-tx-hold-ns = <70>; + sda-pullup-ohms = <2000>; + }; + + i3c5: i3c at 7000 { + compatible = "aspeed,ast2600-i3c"; + reg = <0x7000 0x1000>; + clocks = <&syscon ASPEED_CLK_GATE_I3C5CLK>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i3c6_default>; + interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>; + aspeed,global-regs = <&i3c_global 5>; + status = "disabled"; + + i2c-scl-hz = <1000000>; + i3c-scl-hz = <2000000>; + i3c-od-scl-hi-period-ns = <380>; + i3c-od-scl-lo-period-ns = <620>; + i3c-pp-scl-hi-period-ns = <250>; + i3c-pp-scl-lo-period-ns = <250>; + sda-tx-hold-ns = <70>; + sda-pullup-ohms = <2000>; + }; +};
Signature · 1 line
2.25.1
RFC PATCH 2/2 i3c: ast2600: Validate AST2600 I3C for MCTP-over-I3C
In reply to Dylan HungThis patch introduces minimal changes to validate the functionality of Aspeed AST2600 I3C controllers for MCTP-over-I3C.
--- drivers/i3c/master/ast2600-i3c-master.c | 137 +++++++ drivers/i3c/master/dw-i3c-master.c | 513 ++++++++++++++++++++---- drivers/i3c/master/dw-i3c-master.h | 12 + 3 files changed, 581 insertions(+), 81 deletions(-)
drivers/i3c/master/ast2600-i3c-master.c +137 -0
@@ -10,6 +10,7 @@#include <linux/of.h> #include <linux/platform_device.h> #include <linux/regmap.h> +#include <linux/bitfield.h> #include "dw-i3c-master.h"
@@ -33,9 +34,29 @@#define AST2600_I3CG_REG1_SA_EN BIT(15)#define AST2600_I3CG_REG1_INST_ID_MASK GENMASK(19, 16)#define AST2600_I3CG_REG1_INST_ID (x) (((x) << 16) & AST2600_I3CG_REG1_INST_ID_MASK) +#define SCL_SW_MODE_OE BIT(20) +#define SCL_OUT_SW_MODE_VAL BIT(21) +#define SCL_IN_SW_MODE_VAL BIT(23) +#define SDA_SW_MODE_OE BIT(24) +#define SDA_OUT_SW_MODE_VAL BIT(25) +#define SDA_IN_SW_MODE_VAL BIT(27) +#define SCL_IN_SW_MODE_EN BIT(28) +#define SDA_IN_SW_MODE_EN BIT(29) +#define SCL_OUT_SW_MODE_EN BIT(30) +#define SDA_OUT_SW_MODE_EN BIT(31)#define AST2600_DEFAULT_SDA_PULLUP_OHMS 2000 +/* dw-i3c registers */ +#define IBI_QUEUE_STATUS 0x18 + +#define PRESENT_STATE 0x54 +#define CM_TFR_STS GENMASK(13, 8) +#define CM_TFR_STS_MASTER_SERV_IBI 0xe +#define SDA_LINE_SIGNAL_LEVEL BIT(1) +#define SCL_LINE_SIGNAL_LEVEL BIT(0) + +/* DAT */ #define DEV_ADDR_TABLE_IBI_PEC BIT(11)struct ast2600_i3c {
@@ -117,9 +138,125 @@ static void ast2600_i3c_set_dat_ibi(struct dw_i3c_master *i3c, } } +static int aspeed_i3c_bus_recovery (struct dw_i3c_master *dw) +{ +struct ast2600_i3c *i3c =to_ast2600_i3c (dw); +int i, ret =-1 ; + +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SCL_OUT_SW_MODE_VAL ,SCL_OUT_SW_MODE_VAL ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SCL_SW_MODE_OE ,SCL_SW_MODE_OE ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SCL_OUT_SW_MODE_EN ,SCL_OUT_SW_MODE_EN ); + +for (i =0 ; i <19 ; i++) { +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SCL_OUT_SW_MODE_VAL ,0 ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SCL_OUT_SW_MODE_VAL ,SCL_OUT_SW_MODE_VAL ); +if (readl (dw->regs +PRESENT_STATE ) &SDA_LINE_SIGNAL_LEVEL ) { + ret =0 ; +break ; + } + } + +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SCL_OUT_SW_MODE_EN ,0 ); +if (ret) +dev_err (&dw->base.dev,"Failed to recover the bus\n" ); + +return ret; +} + +static void ast2600_i3c_gen_target_reset_pattern (struct dw_i3c_master *dw) +{ +struct ast2600_i3c *i3c =to_ast2600_i3c (dw); +int i; + +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_OUT_SW_MODE_VAL |SCL_OUT_SW_MODE_VAL , +SDA_OUT_SW_MODE_VAL |SCL_OUT_SW_MODE_VAL ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_SW_MODE_OE |SCL_SW_MODE_OE , +SDA_SW_MODE_OE |SCL_SW_MODE_OE ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_OUT_SW_MODE_EN |SCL_OUT_SW_MODE_EN , +SDA_OUT_SW_MODE_EN |SCL_OUT_SW_MODE_EN ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_IN_SW_MODE_VAL |SCL_IN_SW_MODE_VAL , +SDA_IN_SW_MODE_VAL |SCL_IN_SW_MODE_VAL ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_IN_SW_MODE_EN |SCL_IN_SW_MODE_EN , +SDA_IN_SW_MODE_EN |SCL_IN_SW_MODE_EN ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SCL_OUT_SW_MODE_VAL ,0 ); +for (i =0 ; i <7 ; i++) { +regmap_write_bits (i3c->global_regs, +AST2600_I3CG_REG1 (i3c->global_idx), +SDA_OUT_SW_MODE_VAL ,0 ); +regmap_write_bits (i3c->global_regs, +AST2600_I3CG_REG1 (i3c->global_idx), +SDA_OUT_SW_MODE_VAL ,SDA_OUT_SW_MODE_VAL ); + } +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SCL_OUT_SW_MODE_VAL ,SCL_OUT_SW_MODE_VAL ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_OUT_SW_MODE_VAL ,0 ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_OUT_SW_MODE_VAL ,SDA_OUT_SW_MODE_VAL ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_OUT_SW_MODE_EN |SCL_OUT_SW_MODE_EN ,0 ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_IN_SW_MODE_EN |SCL_IN_SW_MODE_EN ,0 ); +} + +static bool ast2600_i3c_fsm_exit_serv_ibi (struct dw_i3c_master *dw) +{ +u32 state; + +/* +* Clear the IBI queue to enable the hardware to generate SCL and +* begin detecting the T-bit low to stop reading IBI data. +*/ +readl (dw->regs +IBI_QUEUE_STATUS ); + state =FIELD_GET (CM_TFR_STS ,readl (dw->regs +PRESENT_STATE )); +if (state ==CM_TFR_STS_MASTER_SERV_IBI ) +return false; + +return true; +} + +static void ast2600_i3c_gen_tbits_in (struct dw_i3c_master *dw) +{ +struct ast2600_i3c *i3c =to_ast2600_i3c (dw); +bool is_idle; +int ret; + +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_IN_SW_MODE_VAL ,SDA_IN_SW_MODE_VAL ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_IN_SW_MODE_EN ,SDA_IN_SW_MODE_EN ); + +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_IN_SW_MODE_VAL ,0 ); + ret =readx_poll_timeout_atomic (ast2600_i3c_fsm_exit_serv_ibi, dw, + is_idle, is_idle,0 ,2000000 ); +regmap_write_bits (i3c->global_regs,AST2600_I3CG_REG1 (i3c->global_idx), +SDA_IN_SW_MODE_EN ,0 ); +if (ret) +dev_err (&dw->base.dev, +"Failed to exit the I3C fsm from %lx(MASTER_SERV_IBI): %d" , +FIELD_GET (CM_TFR_STS ,readl (dw->regs +PRESENT_STATE )), + ret); +} +static const struct dw_i3c_platform_ops ast2600_i3c_ops = { .init = ast2600_i3c_init, .set_dat_ibi = ast2600_i3c_set_dat_ibi, + .gen_target_reset_pattern = ast2600_i3c_gen_target_reset_pattern, + .gen_tbits_in = ast2600_i3c_gen_tbits_in, + .bus_recovery = aspeed_i3c_bus_recovery, };static int ast2600_i3c_probe (struct platform_device *pdev)
drivers/i3c/master/dw-i3c-master.c +432 -81
806 lines not on this page · raw message
drivers/i3c/master/dw-i3c-master.h +12 -0
@@ -58,6 +58,15 @@ struct dw_i3c_master {/* platform-specific data */ const struct dw_i3c_platform_ops *platform_ops; +struct { +unsigned long core_rate; +unsigned long core_period; +u32 i3c_od_scl_low; +u32 i3c_od_scl_high; +u32 i3c_pp_scl_low; +u32 i3c_pp_scl_high; +u32 timed_reset_scl_low_ns; + } timing;struct work_struct hj_work; };
@@ -78,6 +87,9 @@ struct dw_i3c_platform_ops {*/ void (*set_dat_ibi)(struct dw_i3c_master *i3c,struct i3c_dev_desc *dev,bool enable,u32 *reg); +void (*gen_target_reset_pattern)(struct dw_i3c_master *i3c); +void (*gen_tbits_in)(struct dw_i3c_master *i3c); +int (*bus_recovery)(struct dw_i3c_master *i3c); }; extern int dw_i3c_common_probe(struct dw_i3c_master *master,
Signature · 1 line
2.25.1
Jeremy Kerr
maintainerHi Dylan,
Quoted 6 lines
Add Aspeed AST2600 I3C controllers and add minimal changes to validate
the functionality for MCTP-over-I3C.Dylan Hung (2):
? [RFC] ARM: dts: aspeed-g6: Add AST2600 I3Cs
I'd sent a similar patch earlier:
https://lists.ozlabs.org/pipermail/linux-aspeed/2024-May/012193.html
And a v2 to account for some feedback on the dts layout:
https://lists.ozlabs.org/pipermail/linux-aspeed/2024-May/012213.html
Quoted 1 line
? [RFC] i3c: ast2600: Validate AST2600 I3C for MCTP-over-I3C
Looks interesting, I'll check this out soon.
Cheers,
Jeremy