Skip to content

Commit 3e3c9be

Browse files
claudiubezneaAndi Shyti
authored andcommitted
i2c: riic: Add support for fast mode plus
Fast mode plus is available on most of the IP variants that RIIC driver is working with. The exception is (according to HW manuals of the SoCs where this IP is available) the Renesas RZ/A1H. For this, patch introduces the struct riic_of_data::fast_mode_plus. Fast mode plus was tested on RZ/G3S, RZ/G2{L,UL,LC}, RZ/Five by instantiating the RIIC frequency to 1MHz and issuing i2c reads on the fast mode plus capable devices (and the i2c clock frequency was checked on RZ/G3S). Signed-off-by: Claudiu Beznea <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent caad888 commit 3e3c9be

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

drivers/i2c/busses/i2c-riic.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
#define ICMR3_ACKWP 0x10
6464
#define ICMR3_ACKBT 0x08
6565

66+
#define ICFER_FMPE 0x80
67+
6668
#define ICIER_TIE 0x80
6769
#define ICIER_TEIE 0x40
6870
#define ICIER_RIE 0x20
@@ -80,6 +82,7 @@ enum riic_reg_list {
8082
RIIC_ICCR2,
8183
RIIC_ICMR1,
8284
RIIC_ICMR3,
85+
RIIC_ICFER,
8386
RIIC_ICSER,
8487
RIIC_ICIER,
8588
RIIC_ICSR2,
@@ -92,6 +95,7 @@ enum riic_reg_list {
9295

9396
struct riic_of_data {
9497
const u8 *regs;
98+
bool fast_mode_plus;
9599
};
96100

97101
struct riic_dev {
@@ -311,11 +315,15 @@ static int riic_init_hw(struct riic_dev *riic)
311315
int total_ticks, cks, brl, brh;
312316
struct i2c_timings *t = &riic->i2c_t;
313317
struct device *dev = riic->adapter.dev.parent;
318+
bool fast_mode_plus = riic->info->fast_mode_plus;
314319

315-
if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) {
320+
if ((!fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) ||
321+
(fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_PLUS_FREQ)) {
316322
dev_err(&riic->adapter.dev,
317323
"unsupported bus speed (%dHz). %d max\n",
318-
t->bus_freq_hz, I2C_MAX_FAST_MODE_FREQ);
324+
t->bus_freq_hz,
325+
fast_mode_plus ? I2C_MAX_FAST_MODE_PLUS_FREQ :
326+
I2C_MAX_FAST_MODE_FREQ);
319327
return -EINVAL;
320328
}
321329

@@ -401,6 +409,9 @@ static int riic_init_hw(struct riic_dev *riic)
401409
riic_writeb(riic, 0, RIIC_ICSER);
402410
riic_writeb(riic, ICMR3_ACKWP | ICMR3_RDRFS, RIIC_ICMR3);
403411

412+
if (fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ)
413+
riic_clear_set_bit(riic, 0, ICFER_FMPE, RIIC_ICFER);
414+
404415
riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1);
405416

406417
pm_runtime_mark_last_busy(dev);
@@ -527,6 +538,7 @@ static const u8 riic_rz_a_regs[RIIC_REG_END] = {
527538
[RIIC_ICCR2] = 0x04,
528539
[RIIC_ICMR1] = 0x08,
529540
[RIIC_ICMR3] = 0x10,
541+
[RIIC_ICFER] = 0x14,
530542
[RIIC_ICSER] = 0x18,
531543
[RIIC_ICIER] = 0x1c,
532544
[RIIC_ICSR2] = 0x24,
@@ -538,13 +550,19 @@ static const u8 riic_rz_a_regs[RIIC_REG_END] = {
538550

539551
static const struct riic_of_data riic_rz_a_info = {
540552
.regs = riic_rz_a_regs,
553+
.fast_mode_plus = true,
554+
};
555+
556+
static const struct riic_of_data riic_rz_a1h_info = {
557+
.regs = riic_rz_a_regs,
541558
};
542559

543560
static const u8 riic_rz_v2h_regs[RIIC_REG_END] = {
544561
[RIIC_ICCR1] = 0x00,
545562
[RIIC_ICCR2] = 0x01,
546563
[RIIC_ICMR1] = 0x02,
547564
[RIIC_ICMR3] = 0x04,
565+
[RIIC_ICFER] = 0x05,
548566
[RIIC_ICSER] = 0x06,
549567
[RIIC_ICIER] = 0x07,
550568
[RIIC_ICSR2] = 0x09,
@@ -556,6 +574,7 @@ static const u8 riic_rz_v2h_regs[RIIC_REG_END] = {
556574

557575
static const struct riic_of_data riic_rz_v2h_info = {
558576
.regs = riic_rz_v2h_regs,
577+
.fast_mode_plus = true,
559578
};
560579

561580
static int riic_i2c_suspend(struct device *dev)
@@ -609,6 +628,7 @@ static const struct dev_pm_ops riic_i2c_pm_ops = {
609628

610629
static const struct of_device_id riic_i2c_dt_ids[] = {
611630
{ .compatible = "renesas,riic-rz", .data = &riic_rz_a_info },
631+
{ .compatible = "renesas,riic-r7s72100", .data = &riic_rz_a1h_info, },
612632
{ .compatible = "renesas,riic-r9a09g057", .data = &riic_rz_v2h_info },
613633
{ /* Sentinel */ },
614634
};

0 commit comments

Comments
 (0)