Skip to content

Commit 311499e

Browse files
Ciprian Marian CosteaAndi Shyti
authored andcommitted
i2c: imx: add support for S32G2/S32G3 SoCs
Some S32G2/S32G3 SoC I2C particularities exist such as different <clock divider, register value> pairs. Those are addressed by adding specific S32G2 and S32G3 compatible strings. Co-developed-by: Ionut Vicovan <Ionut.Vicovan@nxp.com> Signed-off-by: Ionut Vicovan <Ionut.Vicovan@nxp.com> Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent f3ed495 commit 311499e

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

drivers/i2c/busses/Kconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,13 +733,14 @@ config I2C_IMG
733733

734734
config I2C_IMX
735735
tristate "IMX I2C interface"
736-
depends on ARCH_MXC || ARCH_LAYERSCAPE || COLDFIRE || COMPILE_TEST
736+
depends on ARCH_MXC || ARCH_LAYERSCAPE || ARCH_S32 || COLDFIRE \
737+
|| COMPILE_TEST
737738
select I2C_SLAVE
738739
help
739740
Say Y here if you want to use the IIC bus controller on
740-
the Freescale i.MX/MXC, Layerscape or ColdFire processors.
741+
the Freescale i.MX/MXC/S32G, Layerscape or ColdFire processors.
741742

742-
This driver can also be built as a module. If so, the module
743+
This driver can also be built as a module. If so, the module
743744
will be called i2c-imx.
744745

745746
config I2C_IMX_LPI2C

drivers/i2c/busses/i2c-imx.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Copyright (C) 2008 Darius Augulis <darius.augulis at teltonika.lt>
1818
*
1919
* Copyright 2013 Freescale Semiconductor, Inc.
20-
* Copyright 2020 NXP
20+
* Copyright 2020, 2024 NXP
2121
*
2222
*/
2323

@@ -84,6 +84,7 @@
8484

8585
#define IMX_I2C_REGSHIFT 2
8686
#define VF610_I2C_REGSHIFT 0
87+
#define S32G_I2C_REGSHIFT 0
8788

8889
/* Bits of IMX I2C registers */
8990
#define I2SR_RXAK 0x01
@@ -165,9 +166,34 @@ static struct imx_i2c_clk_pair vf610_i2c_clk_div[] = {
165166
{ 3840, 0x3F }, { 4096, 0x7B }, { 5120, 0x7D }, { 6144, 0x7E },
166167
};
167168

169+
/* S32G2/S32G3 clock divider, register value pairs */
170+
static struct imx_i2c_clk_pair s32g2_i2c_clk_div[] = {
171+
{ 34, 0x00 }, { 36, 0x01 }, { 38, 0x02 }, { 40, 0x03 },
172+
{ 42, 0x04 }, { 44, 0x05 }, { 46, 0x06 }, { 48, 0x09 },
173+
{ 52, 0x0A }, { 54, 0x07 }, { 56, 0x0B }, { 60, 0x0C },
174+
{ 64, 0x0D }, { 68, 0x40 }, { 72, 0x0E }, { 76, 0x42 },
175+
{ 80, 0x12 }, { 84, 0x0F }, { 88, 0x13 }, { 96, 0x14 },
176+
{ 104, 0x15 }, { 108, 0x47 }, { 112, 0x19 }, { 120, 0x16 },
177+
{ 128, 0x1A }, { 136, 0x80 }, { 144, 0x17 }, { 152, 0x82 },
178+
{ 160, 0x1C }, { 168, 0x84 }, { 176, 0x1D }, { 192, 0x21 },
179+
{ 208, 0x1E }, { 216, 0x87 }, { 224, 0x22 }, { 240, 0x56 },
180+
{ 256, 0x1F }, { 288, 0x24 }, { 320, 0x25 }, { 336, 0x8F },
181+
{ 352, 0x93 }, { 356, 0x5D }, { 358, 0x98 }, { 384, 0x26 },
182+
{ 416, 0x56 }, { 448, 0x2A }, { 480, 0x27 }, { 512, 0x2B },
183+
{ 576, 0x2C }, { 640, 0x2D }, { 704, 0x9D }, { 768, 0x2E },
184+
{ 832, 0x9D }, { 896, 0x32 }, { 960, 0x2F }, { 1024, 0x33 },
185+
{ 1152, 0x34 }, { 1280, 0x35 }, { 1536, 0x36 }, { 1792, 0x3A },
186+
{ 1920, 0x37 }, { 2048, 0x3B }, { 2304, 0x74 }, { 2560, 0x3D },
187+
{ 3072, 0x3E }, { 3584, 0x7A }, { 3840, 0x3F }, { 4096, 0x7B },
188+
{ 4608, 0x7C }, { 5120, 0x7D }, { 6144, 0x7E }, { 7168, 0xBA },
189+
{ 7680, 0x7F }, { 8192, 0xBB }, { 9216, 0xBC }, { 10240, 0xBD },
190+
{ 12288, 0xBE }, { 15360, 0xBF },
191+
};
192+
168193
enum imx_i2c_type {
169194
IMX1_I2C,
170195
IMX21_I2C,
196+
S32G_I2C,
171197
VF610_I2C,
172198
};
173199

@@ -277,7 +303,15 @@ static struct imx_i2c_hwdata vf610_i2c_hwdata = {
277303
.ndivs = ARRAY_SIZE(vf610_i2c_clk_div),
278304
.i2sr_clr_opcode = I2SR_CLR_OPCODE_W1C,
279305
.i2cr_ien_opcode = I2CR_IEN_OPCODE_0,
306+
};
280307

308+
static const struct imx_i2c_hwdata s32g2_i2c_hwdata = {
309+
.devtype = S32G_I2C,
310+
.regshift = S32G_I2C_REGSHIFT,
311+
.clk_div = s32g2_i2c_clk_div,
312+
.ndivs = ARRAY_SIZE(s32g2_i2c_clk_div),
313+
.i2sr_clr_opcode = I2SR_CLR_OPCODE_W1C,
314+
.i2cr_ien_opcode = I2CR_IEN_OPCODE_0,
281315
};
282316

283317
static const struct platform_device_id imx_i2c_devtype[] = {
@@ -307,6 +341,7 @@ static const struct of_device_id i2c_imx_dt_ids[] = {
307341
{ .compatible = "fsl,imx8mp-i2c", .data = &imx6_i2c_hwdata, },
308342
{ .compatible = "fsl,imx8mq-i2c", .data = &imx6_i2c_hwdata, },
309343
{ .compatible = "fsl,vf610-i2c", .data = &vf610_i2c_hwdata, },
344+
{ .compatible = "nxp,s32g2-i2c", .data = &s32g2_i2c_hwdata, },
310345
{ /* sentinel */ }
311346
};
312347
MODULE_DEVICE_TABLE(of, i2c_imx_dt_ids);

0 commit comments

Comments
 (0)