2023-09-14 00:06:54

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 0/2] i2c: rcar: add support for Gen4 devices

The newest generation of Renesas R-Car SoCs support FastMode+. This
series enables the driver to use it. It is based on the series "i2c:
clock calculation cleanups for Renesas devices" and "i2c: rcar: improve
Gen3 support". A branch for testing can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/i2c/fmplus-experimental

Shimoda-san: Maybe the BSP team and/or the test team might want to try
this branch?

Looking forward to comments and test reports etc.

Happy hacking!


Wolfram Sang (2):
i2c: rcar: introduce Gen4 devices
i2c: rcar: add FastMode+ support for Gen4

drivers/i2c/busses/i2c-rcar.c | 67 ++++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 24 deletions(-)

--
2.35.1


2023-09-14 07:26:39

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 2/2] i2c: rcar: add FastMode+ support for Gen4

To support FM+, we mainly need to turn the SMD constant into a parameter
and set it accordingly. Then, activating the enable bit for FM+ is all
we need to do. Tested with a Renesas Falcon board using R-Car V3U.

Signed-off-by: Wolfram Sang <[email protected]>
---
drivers/i2c/busses/i2c-rcar.c | 52 +++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 18 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 5aa6fd777276..9cc8d6ba0c78 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -89,6 +89,7 @@
#define TMDMAE BIT(0) /* DMA Master Transmitted Enable */

/* ICCCR2 */
+#define FMPE BIT(7) /* Fast Mode Plus Enable */
#define CDFD BIT(2) /* CDF Disable */
#define HLSE BIT(1) /* HIGH/LOW Separate Control Enable */
#define SME BIT(0) /* SCL Mask Enable */
@@ -122,11 +123,12 @@
#define ID_NACK BIT(4)
#define ID_EPROTO BIT(5)
/* persistent flags */
+#define ID_P_FMPLUS BIT(27)
#define ID_P_NOT_ATOMIC BIT(28)
#define ID_P_HOST_NOTIFY BIT(29)
#define ID_P_NO_RXDMA BIT(30) /* HW forbids RXDMA sometimes */
#define ID_P_PM_BLOCKED BIT(31)
-#define ID_P_MASK GENMASK(31, 28)
+#define ID_P_MASK GENMASK(31, 27)

enum rcar_i2c_type {
I2C_RCAR_GEN1,
@@ -148,6 +150,7 @@ struct rcar_i2c_priv {
int pos;
u32 icccr;
u32 scl_gran;
+ u8 smd;
u8 recovery_icmcr; /* protected by adapter lock */
enum rcar_i2c_type devtype;
struct i2c_client *slave;
@@ -239,9 +242,14 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
if (priv->devtype < I2C_RCAR_GEN3) {
rcar_i2c_write(priv, ICCCR, priv->icccr);
} else {
- rcar_i2c_write(priv, ICCCR2, CDFD | HLSE | SME);
+ u32 icccr2 = CDFD | HLSE | SME;
+
+ if (priv->flags & ID_P_FMPLUS)
+ icccr2 |= FMPE;
+
+ rcar_i2c_write(priv, ICCCR2, icccr2);
rcar_i2c_write(priv, ICCCR, priv->icccr);
- rcar_i2c_write(priv, ICMPR, RCAR_DEFAULT_SMD);
+ rcar_i2c_write(priv, ICMPR, priv->smd);
rcar_i2c_write(priv, ICHPR, RCAR_SCHD_RATIO * priv->scl_gran);
rcar_i2c_write(priv, ICLPR, RCAR_SCLD_RATIO * priv->scl_gran);
rcar_i2c_write(priv, ICFBSCR, TCYC17);
@@ -278,6 +286,8 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)

/* Fall back to previously used values if not supplied */
i2c_parse_fw_timings(dev, &t, false);
+ priv->smd = RCAR_DEFAULT_SMD;
+ rate = clk_get_rate(priv->clk);

/*
* calculate SCL clock
@@ -297,11 +307,18 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
* clkp : peripheral_clk
* F[] : integer up-valuation
*/
- rate = clk_get_rate(priv->clk);
- cdf = rate / 20000000;
- cdf_width = (priv->devtype == I2C_RCAR_GEN1) ? 2 : 3;
- if (cdf >= 1U << cdf_width)
- goto err_no_val;
+ if (t.bus_freq_hz > I2C_MAX_FAST_MODE_FREQ && priv->devtype >= I2C_RCAR_GEN4) {
+ priv->flags |= ID_P_FMPLUS;
+ /* FM+ needs lower SMD and no filters */
+ priv->smd /= 2;
+ cdf = 0;
+ } else {
+ priv->flags &= ~ID_P_FMPLUS;
+ cdf = rate / 20000000;
+ cdf_width = (priv->devtype == I2C_RCAR_GEN1) ? 2 : 3;
+ if (cdf >= 1U << cdf_width)
+ goto err_no_val;
+ }

/* On Gen3+, we use cdf only for the filters, not as a SCL divider */
ick = rate / (priv->devtype < I2C_RCAR_GEN3 ? (cdf + 1) : 1);
@@ -344,26 +361,25 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
* x as a base value for the SCLD/SCHD ratio:
*
* SCL = clkp / (8 + 2 * SMD + SCLD + SCHD + F[(ticf + tr + intd) * clkp])
- * SCL = clkp / (8 + 2 * RCAR_DEFAULT_SMD + RCAR_SCLD_RATIO * x
+ * SCL = clkp / (8 + 2 * SMD + RCAR_SCLD_RATIO * x
* + RCAR_SCHD_RATIO * x + F[...])
*
* with: sum_ratio = RCAR_SCLD_RATIO + RCAR_SCHD_RATIO
- * and: smd = 2 * RCAR_DEFAULT_SMD
*
- * SCL = clkp / (8 + smd + sum_ratio * x + F[...])
- * 8 + smd + sum_ratio * x + F[...] = SCL / clkp
- * x = ((SCL / clkp) - 8 - smd - F[...]) / sum_ratio
+ * SCL = clkp / (8 + 2 * smd + sum_ratio * x + F[...])
+ * 8 + 2 * smd + sum_ratio * x + F[...] = clkp / SCL
+ * x = ((clkp / SCL) - 8 - 2 * smd - F[...]) / sum_ratio
*/
x = DIV_ROUND_UP(rate, t.bus_freq_hz ?: 1);
- x = DIV_ROUND_UP(x - 8 - 2 * RCAR_DEFAULT_SMD - round, sum_ratio);
- scl = rate / (8 + 2 * RCAR_DEFAULT_SMD + sum_ratio * x + round);
+ x = DIV_ROUND_UP(x - 8 - 2 * priv->smd - round, sum_ratio);
+ scl = rate / (8 + 2 * priv->smd + sum_ratio * x + round);

/* Bail out if values don't fit into 16 bit or SMD became too large */
- if (x * RCAR_SCLD_RATIO > 0xffff || RCAR_DEFAULT_SMD > x * RCAR_SCHD_RATIO)
+ if (x * RCAR_SCLD_RATIO > 0xffff || priv->smd > x * RCAR_SCHD_RATIO)
goto err_no_val;

- dev_dbg(dev, "clk %u/%u(%lu), round %u, CDF: %u SCL gran %u\n",
- scl, t.bus_freq_hz, rate, round, cdf, x);
+ dev_dbg(dev, "clk %u/%u(%lu), round %u, CDF: %u SMD %u SCL gran %u\n",
+ scl, t.bus_freq_hz, rate, round, cdf, priv->smd, x);

priv->icccr = cdf;
priv->scl_gran = x;
--
2.35.1

2023-09-14 14:13:25

by Yoshihiro Shimoda

[permalink] [raw]
Subject: RE: [PATCH 0/2] i2c: rcar: add support for Gen4 devices

Hello Wolfram-san,

> From: Wolfram Sang, Sent: Thursday, September 14, 2023 5:33 AM
>
> The newest generation of Renesas R-Car SoCs support FastMode+. This
> series enables the driver to use it. It is based on the series "i2c:
> clock calculation cleanups for Renesas devices" and "i2c: rcar: improve
> Gen3 support". A branch for testing can be found here:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/i2c/fmplus-experimental
>
> Shimoda-san: Maybe the BSP team and/or the test team might want to try
> this branch?

I tested the branch on the Spider, and then the i2c cannot be probed with the following errors:
-----
# dmesg | grep i2c
[ 1.528773] i2c_dev: i2c /dev entries driver
[ 1.533572] i2c-rcar e6500000.i2c: clk 395647/400000(133333333), round 46, CDF: 6 SMD 20 SCL gran 27
[ 1.554646] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 1.561487] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 1.568133] i2c-rcar e6500000.i2c: request_channel failed for rx (-517)
[ 1.575263] i2c-rcar e6500000.i2c: probed
[ 1.579706] i2c-rcar e66d8000.i2c: clk 395647/400000(133333333), round 46, CDF: 6 SMD 20 SCL gran 27
[ 1.590018] i2c-rcar e66d8000.i2c: probed
[ 1.757721] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 1.764429] i2c-rcar e6500000.i2c: request_channel failed for rx (-517)
[ 1.771395] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 1.778425] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 5.963936] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 5.984025] i2c-rcar e6500000.i2c: request_channel failed for rx (-517)
-----

I checked that the v6.6-rc1 (commit 0bb80ecc33a8) could worked correctly.
JFYI, I pasted whole log at the end of this email. Should I do git bisect to find
a bad commit on the branch?

-----
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
[ 0.000000] Linux version 6.6.0-rc1-arm64-renesas+ (shimoda@mzsrz-15sj) (aarch64-linux-gcc (GCC) 11.1.0, GNU ld (GNU Binutils) 2.36.1) #49 SMP PREEMPT Thu Sep 14 21:52:15 JST 2023
[ 0.000000] Machine model: Renesas Spider CPU and Breakout boards based on r8a779f0
[ 0.000000] printk: debug: ignoring loglevel setting.
[ 0.000000] efi: UEFI not found.
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000048000000-0x00000000ffffffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal [mem 0x0000000100000000-0x00000004ffffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000048000000-0x000000009fffffff]
[ 0.000000] node 0: [mem 0x0000000480000000-0x00000004ffffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000048000000-0x00000004ffffffff]
[ 0.000000] cma: Reserved 128 MiB at 0x0000000098000000 on node -1
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: PSCIv1.1 detected in firmware.
[ 0.000000] psci: Using standard PSCI v0.2 function IDs
[ 0.000000] psci: Trusted OS resident on physical CPU 0x0
[ 0.000000] psci: SMC Calling Convention v1.2
[ 0.000000] percpu: Embedded 28 pages/cpu s77800 r8192 d28696 u114688
[ 0.000000] pcpu-alloc: s77800 r8192 d28696 u114688 alloc=28*4096
[ 0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 [0] 4 [0] 5 [0] 6 [0] 7
[ 0.000000] Detected VIPT I-cache on CPU0
[ 0.000000] CPU features: detected: GIC system register CPU interface
[ 0.000000] CPU features: detected: Qualcomm erratum 1009, or ARM erratum 1286807, 2441009
[ 0.000000] CPU features: detected: ARM errata 1165522, 1319367, or 1530923
[ 0.000000] alternatives: applying boot alternatives
[ 0.000000] Kernel command line: ignore_loglevel consoleblank=0 rw root=/dev/nfs nfsroot=192.168.5.15:/home/shimoda/development/rootfs/rootfs/yocto-sdk-3-11,vers=3 ip=192.168.5.5::192.168.5.15:::tsn0 pci=pcie_bus_perf
[ 0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 870912
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] software IO TLB: area num 8.
[ 0.000000] software IO TLB: mapped [mem 0x0000000094000000-0x0000000098000000] (64MB)
[ 0.000000] Memory: 3243064K/3538944K available (14336K kernel code, 2318K rwdata, 5808K rodata, 5952K init, 460K bss, 164808K reserved, 131072K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=8, Nodes=1
[ 0.000000] ftrace: allocating 50375 entries in 197 pages
[ 0.000000] ftrace: allocated 197 pages with 4 groups
[ 0.000000] trace event string verifier disabled
[ 0.000000] rcu: Preemptible hierarchical RCU implementation.
[ 0.000000] rcu: RCU event tracing is enabled.
[ 0.000000] Trampoline variant of Tasks RCU enabled.
[ 0.000000] Rude variant of Tasks RCU enabled.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] GICv3: 960 SPIs implemented
[ 0.000000] GICv3: 0 Extended SPIs implemented
[ 0.000000] Root IRQ handler: gic_handle_irq
[ 0.000000] GICv3: GICv3 features: 16 PPIs
[ 0.000000] GICv3: CPU0: found redistributor 0 region 0:0x00000000f1060000
[ 0.000000] ITS: No ITS available, not enabling LPIs
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 0.000000] arch_timer: cp15 timer(s) running at 16.66MHz (virt).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x3d80623e0, max_idle_ns: 440795202120 ns
[ 0.000001] sched_clock: 56 bits at 17MHz, resolution 60ns, wraps every 2199023255541ns
[ 0.000296] Console: colour dummy device 80x25
[ 0.000312] printk: console [tty0] enabled
[ 0.000820] Calibrating delay loop (skipped), value calculated using timer frequency.. 33.33 BogoMIPS (lpj=66666)
[ 0.000848] pid_max: default: 32768 minimum: 301
[ 0.001067] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[ 0.001103] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[ 0.003459] RCU Tasks: Setting shift to 3 and lim to 1 rcu_task_cb_adjust=1.
[ 0.003587] RCU Tasks Rude: Setting shift to 3 and lim to 1 rcu_task_cb_adjust=1.
[ 0.003861] rcu: Hierarchical SRCU implementation.
[ 0.003881] rcu: Max phase no-delay instances is 1000.
[ 0.004711] Detected Renesas R-Car Gen4 r8a779f0 ES1.2
[ 0.005337] EFI services will not be available.
[ 0.005930] smp: Bringing up secondary CPUs ...
[ 0.006660] Detected VIPT I-cache on CPU1
[ 0.006793] GICv3: CPU1: found redistributor 100 region 0:0x00000000f1080000
[ 0.006855] CPU1: Booted secondary processor 0x0000000100 [0x412fd050]
[ 0.007770] Detected VIPT I-cache on CPU2
[ 0.007895] GICv3: CPU2: found redistributor 10000 region 0:0x00000000f10a0000
[ 0.007954] CPU2: Booted secondary processor 0x0000010000 [0x412fd050]
[ 0.008762] Detected VIPT I-cache on CPU3
[ 0.008805] GICv3: CPU3: found redistributor 10100 region 0:0x00000000f10c0000
[ 0.008829] CPU3: Booted secondary processor 0x0000010100 [0x412fd050]
[ 0.009485] Detected VIPT I-cache on CPU4
[ 0.009558] GICv3: CPU4: found redistributor 20000 region 0:0x00000000f10e0000
[ 0.009594] CPU4: Booted secondary processor 0x0000020000 [0x412fd050]
[ 0.010264] Detected VIPT I-cache on CPU5
[ 0.010311] GICv3: CPU5: found redistributor 20100 region 0:0x00000000f1100000
[ 0.010335] CPU5: Booted secondary processor 0x0000020100 [0x412fd050]
[ 0.011010] Detected VIPT I-cache on CPU6
[ 0.011088] GICv3: CPU6: found redistributor 30000 region 0:0x00000000f1120000
[ 0.011124] CPU6: Booted secondary processor 0x0000030000 [0x412fd050]
[ 0.011778] Detected VIPT I-cache on CPU7
[ 0.011828] GICv3: CPU7: found redistributor 30100 region 0:0x00000000f1140000
[ 0.011852] CPU7: Booted secondary processor 0x0000030100 [0x412fd050]
[ 0.011969] smp: Brought up 1 node, 8 CPUs
[ 0.012235] SMP: Total of 8 processors activated.
[ 0.012249] CPU features: detected: 32-bit EL0 Support
[ 0.012260] CPU features: detected: 32-bit EL1 Support
[ 0.012273] CPU features: detected: Data cache clean to the PoU not required for I/D coherence
[ 0.012289] CPU features: detected: Common not Private translations
[ 0.012301] CPU features: detected: CRC32 instructions
[ 0.012313] CPU features: detected: RCpc load-acquire (LDAPR)
[ 0.012326] CPU features: detected: Privileged Access Never
[ 0.012337] CPU features: detected: RAS Extension Support
[ 0.012351] CPU features: detected: Speculative Store Bypassing Safe (SSBS)
[ 0.012472] CPU: All CPU(s) started at EL1
[ 0.012500] alternatives: applying system-wide alternatives
[ 0.015615] devtmpfs: initialized
[ 0.019691] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.019756] futex hash table entries: 2048 (order: 5, 131072 bytes, linear)
[ 0.022839] pinctrl core: initialized pinctrl subsystem
[ 0.023610] DMI not present or invalid.
[ 0.024224] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.025533] DMA: preallocated 512 KiB GFP_KERNEL pool for atomic allocations
[ 0.025944] DMA: preallocated 512 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[ 0.026185] DMA: preallocated 512 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[ 0.026315] audit: initializing netlink subsys (disabled)
[ 0.026563] audit: type=2000 audit(0.024:1): state=initialized audit_enabled=0 res=1
[ 0.027122] thermal_sys: Registered thermal governor 'step_wise'
[ 0.027196] cpuidle: using governor menu
[ 0.027414] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[ 0.027648] ASID allocator initialised with 65536 entries
[ 0.030184] platform soc: Fixed dependency cycle(s) with /soc/interrupt-controller@f1000000
[ 0.030623] platform e6050000.pinctrl: Fixed dependency cycle(s) with /soc/pinctrl@e6050000/scif_clk
[ 0.031014] sh-pfc e6050000.pinctrl: r8a779f0_pfc support registered
[ 0.036223] Modules: 25504 pages in range for non-PLT usage
[ 0.036235] Modules: 517024 pages in range for PLT usage
[ 0.038288] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages
[ 0.038335] HugeTLB: 0 KiB vmemmap can be freed for a 1.00 GiB page
[ 0.038350] HugeTLB: registered 32.0 MiB page size, pre-allocated 0 pages
[ 0.038362] HugeTLB: 0 KiB vmemmap can be freed for a 32.0 MiB page
[ 0.038375] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages
[ 0.038388] HugeTLB: 0 KiB vmemmap can be freed for a 2.00 MiB page
[ 0.038401] HugeTLB: registered 64.0 KiB page size, pre-allocated 0 pages
[ 0.038413] HugeTLB: 0 KiB vmemmap can be freed for a 64.0 KiB page
[ 0.041957] iommu: Default domain type: Translated
[ 0.042002] iommu: DMA domain TLB invalidation policy: strict mode
[ 0.042359] SCSI subsystem initialized
[ 0.042558] libata version 3.00 loaded.
[ 0.042762] usbcore: registered new interface driver usbfs
[ 0.042812] usbcore: registered new interface driver hub
[ 0.042870] usbcore: registered new device driver usb
[ 0.043572] mc: Linux media interface: v0.10
[ 0.043650] videodev: Linux video capture interface: v2.00
[ 0.043716] pps_core: LinuxPPS API ver. 1 registered
[ 0.043730] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
[ 0.043755] PTP clock support registered
[ 0.044585] Advanced Linux Sound Architecture Driver Initialized.
[ 0.045216] Bluetooth: Core ver 2.22
[ 0.045275] NET: Registered PF_BLUETOOTH protocol family
[ 0.045289] Bluetooth: HCI device and connection manager initialized
[ 0.045314] Bluetooth: HCI socket layer initialized
[ 0.045330] Bluetooth: L2CAP socket layer initialized
[ 0.045354] Bluetooth: SCO socket layer initialized
[ 0.045724] vgaarb: loaded
[ 0.046172] clocksource: Switched to clocksource arch_sys_counter
[ 0.046626] VFS: Disk quotas dquot_6.6.0
[ 0.046701] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[ 0.054138] NET: Registered PF_INET protocol family
[ 0.054462] IP idents hash table entries: 65536 (order: 7, 524288 bytes, linear)
[ 0.057481] tcp_listen_portaddr_hash hash table entries: 2048 (order: 3, 32768 bytes, linear)
[ 0.057583] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.057626] TCP established hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.057836] TCP bind hash table entries: 32768 (order: 8, 1048576 bytes, linear)
[ 0.058973] TCP: Hash tables configured (established 32768 bind 32768)
[ 0.059188] UDP hash table entries: 2048 (order: 4, 65536 bytes, linear)
[ 0.059281] UDP-Lite hash table entries: 2048 (order: 4, 65536 bytes, linear)
[ 0.059573] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 0.060093] RPC: Registered named UNIX socket transport module.
[ 0.060119] RPC: Registered udp transport module.
[ 0.060130] RPC: Registered tcp transport module.
[ 0.060141] RPC: Registered tcp-with-tls transport module.
[ 0.060153] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.061240] PCI: CLS 0 bytes, default 64
[ 0.062172] kvm [1]: HYP mode not available
[ 0.063619] Initialise system trusted keyrings
[ 0.063845] workingset: timestamp_bits=46 max_order=20 bucket_order=0
[ 0.064272] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.064605] NFS: Registering the id_resolver key type
[ 0.064656] Key type id_resolver registered
[ 0.064670] Key type id_legacy registered
[ 0.064704] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 0.064722] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[ 0.095716] Key type asymmetric registered
[ 0.095749] Asymmetric key parser 'x509' registered
[ 0.095836] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 245)
[ 0.095857] io scheduler mq-deadline registered
[ 0.095871] io scheduler kyber registered
[ 0.101646] gpio_rcar e6050180.gpio: driving 21 GPIOs
[ 0.102497] gpio_rcar e6050980.gpio: driving 25 GPIOs
[ 0.103252] gpio_rcar e6051180.gpio: driving 17 GPIOs
[ 0.103961] gpio_rcar e6051980.gpio: driving 19 GPIOs
[ 0.149766] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[ 0.151287] SuperH (H)SCI(F) driver initialized
[ 0.152106] e6540000.serial: ttySC0 at MMIO 0xe6540000 (irq = 17, base_baud = 0) is a hscif
[ 0.152223] printk: console [ttySC0] enabled
[ 1.295958] e6e60000.serial: ttySC1 at MMIO 0xe6e60000 (irq = 18, base_baud = 0) is a scif
[ 1.316431] brd: module loaded
[ 1.326212] loop: module loaded
[ 1.333068] tun: Universal TUN/TAP device driver, 1.6
[ 1.338471] CAN device driver interface
[ 1.352846] mv88e2110 etha0:01: Firmware version 8.3.0.0
[ 1.358520] hwmon hwmon0: temp1_input not attached to any thermal zone
[ 1.365336] mv88e2110 etha0:01: Changing MACTYPE to 4
[ 1.382299] mv88e2110 etha0:01: attached PHY driver (mii_bus:phy_addr=etha0:01, irq=POLL)
[ 1.392698] mv88e2110 etha1:02: Firmware version 8.3.0.0
[ 1.398384] hwmon hwmon1: temp1_input not attached to any thermal zone
[ 1.405198] mv88e2110 etha1:02: Changing MACTYPE to 4
[ 1.423310] mv88e2110 etha1:02: attached PHY driver (mii_bus:phy_addr=etha1:02, irq=POLL)
[ 1.433689] mv88e2110 etha2:03: Firmware version 8.3.0.0
[ 1.439365] hwmon hwmon2: temp1_input not attached to any thermal zone
[ 1.446188] mv88e2110 etha2:03: Changing MACTYPE to 4
[ 1.461497] mv88e2110 etha2:03: attached PHY driver (mii_bus:phy_addr=etha2:03, irq=POLL)
[ 1.492688] renesas_eth_sw e6880000.ethernet tsn0: MAC address 2e:09:0a:06:ef:11
[ 1.500163] renesas_eth_sw e6880000.ethernet tsn1: MAC address 82:e2:11:96:d7:bf
[ 1.507577] renesas_eth_sw e6880000.ethernet tsn2: MAC address 3e:35:a1:35:82:58
[ 1.515904] VFIO - User Level meta-driver version: 0.3
[ 1.522118] usbcore: registered new interface driver usb-storage
[ 1.528773] i2c_dev: i2c /dev entries driver
[ 1.533572] i2c-rcar e6500000.i2c: clk 395647/400000(133333333), round 46, CDF: 6 SMD 20 SCL gran 27
[ 1.543788] pca953x 0-0020: supply vcc not found, using dummy regulator
[ 1.550656] pca953x 0-0020: using no AI
[ 1.554646] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 1.561487] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 1.568133] i2c-rcar e6500000.i2c: request_channel failed for rx (-517)
[ 1.575263] i2c-rcar e6500000.i2c: probed
[ 1.579706] i2c-rcar e66d8000.i2c: clk 395647/400000(133333333), round 46, CDF: 6 SMD 20 SCL gran 27
[ 1.590018] i2c-rcar e66d8000.i2c: probed
[ 1.600572] rcar_gen3_thermal e6198000.thermal: Sensor 0: Loaded 1 trip points
[ 1.612185] rcar_gen3_thermal e6198000.thermal: Sensor 1: Loaded 1 trip points
[ 1.623719] rcar_gen3_thermal e6198000.thermal: Sensor 2: Loaded 1 trip points
[ 1.632622] Bluetooth: HCI UART driver ver 2.3
[ 1.637151] Bluetooth: HCI UART protocol H4 registered
[ 1.642334] Bluetooth: HCI UART protocol LL registered
[ 1.653682] ledtrig-cpu: registered to indicate activity on CPUs
[ 1.660193] SMCCC: SOC_ID: ARCH_SOC_ID not implemented, skipping ....
[ 1.667418] usbcore: registered new interface driver usbhid
[ 1.673036] usbhid: USB HID core driver
[ 1.678994] hw perfevents: enabled with armv8_cortex_a55 PMU driver, 7 counters available
[ 1.690369] NET: Registered PF_PACKET protocol family
[ 1.695502] can: controller area network core
[ 1.699935] NET: Registered PF_CAN protocol family
[ 1.704753] can: raw protocol
[ 1.707741] can: broadcast manager protocol
[ 1.711946] can: netlink gateway - max_hops=1
[ 1.716470] Key type dns_resolver registered
[ 1.728354] registered taskstats version 1
[ 1.732542] Loading compiled-in X.509 certificates
[ 1.750407] renesas_irqc e61c0000.interrupt-controller: driving 6 irqs
[ 1.757721] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 1.764429] i2c-rcar e6500000.i2c: request_channel failed for rx (-517)
[ 1.771395] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 1.778425] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 5.886418] renesas_eth_sw e6880000.ethernet tsn0: Link is Up - 1Gbps/Full - flow control off
[ 5.910222] IP-Config: Guessing netmask 255.255.255.0
[ 5.915351] IP-Config: Complete:
[ 5.918619] device=tsn0, hwaddr=2e:09:0a:06:ef:11, ipaddr=192.168.5.5, mask=255.255.255.0, gw=192.168.5.15
[ 5.928751] host=192.168.5.5, domain=, nis-domain=(none)
[ 5.934656] bootserver=255.255.255.255, rootserver=192.168.5.15, rootpath=
[ 5.935056] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 5.953547] Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 5.959479] clk: Disabling unused clocks
[ 5.963716] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[ 5.963936] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
[ 5.972403] cfg80211: failed to load regulatory.db
[ 5.984025] i2c-rcar e6500000.i2c: request_channel failed for rx (-517)
[ 5.991169] ALSA device list:
[ 5.994196] No soundcards found.
[ 8.045274] VFS: Mounted root (nfs filesystem) on device 0:21.
[ 8.052007] devtmpfs: mounted
[ 8.059706] Freeing unused kernel memory: 5952K
[ 8.070386] Run /sbin/init as init process
[ 8.074542] with arguments:
[ 8.077515] /sbin/init
[ 8.080257] with environment:
[ 8.083413] HOME=/
[ 8.085775] TERM=linux
[ 8.286897] systemd[1]: System time before build time, advancing clock.
[ 8.326988] systemd[1]: systemd 244 running in system mode. (-PAM -AUDIT -SELINUX +IMA -APPARMOR -SMACK +SYSVINIT +UTMP -LIBCRYPTSETUP -GCRYPT -GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID -ELFUTILS +KMOD -IDN2 -IDN -PCRE2 default-hierarchy=hybrid)
[ 8.349316] systemd[1]: Detected architecture arm64.
[ 8.429251] systemd[1]: Set hostname to <spider>.
[ 10.618189] random: crng init done
[ 10.622107] systemd[1]: system-getty.slice: unit configures an IP firewall, but the local system does not support BPF/cgroup firewalling.
[ 10.634572] systemd[1]: (This warning is only shown for the first unit using IP firewalling.)
[ 10.646922] systemd[1]: Created slice system-getty.slice.
[ 10.664217] systemd[1]: Created slice system-serial\x2dgetty.slice.
[ 10.684061] systemd[1]: Created slice User and Session Slice.
[ 10.702969] systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[ 10.722890] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[ 10.742703] systemd[1]: Reached target Paths.
[ 10.758524] systemd[1]: Reached target Remote File Systems.
[ 10.774516] systemd[1]: Reached target Slices.
[ 10.790563] systemd[1]: Reached target Swap.
[ 10.812082] systemd[1]: Listening on Syslog Socket.
[ 10.827154] systemd[1]: Listening on initctl Compatibility Named Pipe.
[ 10.849166] systemd[1]: Listening on Journal Audit Socket.
[ 10.867796] systemd[1]: Listening on Journal Socket (/dev/log).
[ 10.887855] systemd[1]: Listening on Journal Socket.
[ 10.905270] systemd[1]: Listening on Network Service Netlink Socket.
[ 10.925452] systemd[1]: Listening on udev Control Socket.
[ 10.943520] systemd[1]: Listening on udev Kernel Socket.
[ 10.983373] systemd[1]: Mounting Huge Pages File System...
[ 11.007919] systemd[1]: Mounting POSIX Message Queue File System...
[ 11.035684] systemd[1]: Mounting Kernel Debug File System...
[ 11.067102] systemd[1]: Mounting Temporary Directory (/tmp)...
[ 11.087014] systemd[1]: Condition check resulted in Create list of static device nodes for the current kernel being skipped.
[ 11.112394] systemd[1]: Started Hardware RNG Entropy Gatherer Daemon.
[ 11.131344] systemd[1]: Condition check resulted in File System Check on Root Device being skipped.
[ 11.148933] systemd[1]: Starting Journal Service...
[ 11.177613] systemd[1]: Starting Load Kernel Modules...
[ 11.199741] systemd[1]: Starting Remount Root and Kernel File Systems...
[ 11.224480] systemd[1]: Starting udev Coldplug all Devices...
[ 11.247811] systemd[1]: Mounted Huge Pages File System.
[ 11.273336] systemd[1]: Mounted POSIX Message Queue File System.
[ 11.292984] systemd[1]: Started Journal Service.
[ 11.495047] systemd-journald[148]: Received client request to flush runtime journal.
[ 16.094947] rcar-dmac e7350000.dma-controller: deferred probe timeout, ignoring dependency
[ 16.111627] rcar-dmac e7351000.dma-controller: deferred probe timeout, ignoring dependency
[ 16.132034] renesas_sdhi_internal_dmac ee140000.mmc: deferred probe timeout, ignoring dependency
[ 16.190295] renesas_sdhi_internal_dmac ee140000.mmc: mmc0 base at 0x00000000ee140000, max clock rate 200 MHz
[ 16.274509] mmc0: new HS400 MMC card at address 0001
[ 16.281365] mmcblk0: mmc0:0001 G1M15L 29.6 GiB
[ 16.290001] mmcblk0boot0: mmc0:0001 G1M15L 31.5 MiB
[ 16.297392] mmcblk0boot1: mmc0:0001 G1M15L 31.5 MiB
[ 16.305787] mmcblk0rpmb: mmc0:0001 G1M15L 4.00 MiB, chardev (241:0)
-----

Best regards,
Yoshihiro Shimoda

> Looking forward to comments and test reports etc.
>
> Happy hacking!
>
>
> Wolfram Sang (2):
> i2c: rcar: introduce Gen4 devices
> i2c: rcar: add FastMode+ support for Gen4
>
> drivers/i2c/busses/i2c-rcar.c | 67 ++++++++++++++++++++++-------------
> 1 file changed, 43 insertions(+), 24 deletions(-)
>
> --
> 2.35.1

2023-09-16 11:10:35

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH 0/2] i2c: rcar: add support for Gen4 devices

Hi Shimoda-san,

> I tested the branch on the Spider, and then the i2c cannot be probed with the following errors:
> -----
> # dmesg | grep i2c
> [ 1.528773] i2c_dev: i2c /dev entries driver
> [ 1.533572] i2c-rcar e6500000.i2c: clk 395647/400000(133333333), round 46, CDF: 6 SMD 20 SCL gran 27

These values look good and match the values from Falcon.

> [ 1.554646] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
> [ 1.561487] i2c-rcar e6500000.i2c: request_channel failed for tx (-517)
> [ 1.568133] i2c-rcar e6500000.i2c: request_channel failed for rx (-517)

-EPROBE_DEFER when requesting the DMA channel? This is weird, at first
glimpse this seems unrelated to my series. But you say v6.6-rc1 works
fine. Strange.

> I checked that the v6.6-rc1 (commit 0bb80ecc33a8) could worked correctly.
> JFYI, I pasted whole log at the end of this email. Should I do git bisect to find
> a bad commit on the branch?

Very kind of you but I think this is not needed. There is a Spider in
Kieran's lab and I will try to reproduce the issue there myself. If that
doesn't work, I'll come back to you.

Thank you for the report!

All the best,

Wolfram


Attachments:
(No filename) (1.18 kB)
signature.asc (849.00 B)
Download all attachments

2023-09-16 20:25:53

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH 0/2] i2c: rcar: add support for Gen4 devices

Hi Shimoda-san,

I had a look now with Kieran's Spider and could reproduce your findings.
It is not a problem, though, because the system behaves the same with
plain v6.6-rc1. The only difference with my branch is that DEBUG is
enabled for the I2C driver, so we see all the messages regarding
EPROBE_DEFER with DMA. If you add DEBUG to plain v6.6-rc1, then you see
the same messages. But still, the busses get probed and they also get
DMA channels after some time when the DMA driver is finally loaded. So,
this really has nothing to do with the patches themselves, only with the
additions for debugging. Phew!

Thank you for reporting and testing, still!

Wolfram


Attachments:
(No filename) (685.00 B)
signature.asc (849.00 B)
Download all attachments

2023-09-19 10:07:16

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 2/2] i2c: rcar: add FastMode+ support for Gen4

Hi Wolfram,

On Thu, Sep 14, 2023 at 1:16 AM Wolfram Sang
<[email protected]> wrote:
> To support FM+, we mainly need to turn the SMD constant into a parameter
> and set it accordingly. Then, activating the enable bit for FM+ is all
> we need to do. Tested with a Renesas Falcon board using R-Car V3U.
>
> Signed-off-by: Wolfram Sang <[email protected]>

Thanks for your patch!

> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c
> @@ -297,11 +307,18 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
> * clkp : peripheral_clk
> * F[] : integer up-valuation
> */
> - rate = clk_get_rate(priv->clk);
> - cdf = rate / 20000000;
> - cdf_width = (priv->devtype == I2C_RCAR_GEN1) ? 2 : 3;
> - if (cdf >= 1U << cdf_width)
> - goto err_no_val;
> + if (t.bus_freq_hz > I2C_MAX_FAST_MODE_FREQ && priv->devtype >= I2C_RCAR_GEN4) {
> + priv->flags |= ID_P_FMPLUS;
> + /* FM+ needs lower SMD and no filters */
> + priv->smd /= 2;
> + cdf = 0;

Is this documented somewhere in the R-Car Gen4 docs?
Assumed this is true, the rest LGTM, modulo the few fixes that should be
moved to "[PATCH RFT 2/2] i2c: rcar: improve accuracy for R-Car Gen3+".

> + } else {
> + priv->flags &= ~ID_P_FMPLUS;
> + cdf = rate / 20000000;
> + cdf_width = (priv->devtype == I2C_RCAR_GEN1) ? 2 : 3;
> + if (cdf >= 1U << cdf_width)
> + goto err_no_val;
> + }
>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2023-09-19 16:40:54

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH 2/2] i2c: rcar: add FastMode+ support for Gen4


> > + /* FM+ needs lower SMD and no filters */
> > + priv->smd /= 2;
> > + cdf = 0;
>
> Is this documented somewhere in the R-Car Gen4 docs?

Sadly, there are no recommended values for FM+ in the docs. With cdf=6,
I got speeds around 800kHz. After seeing the BSP also uses cdf=0, I got
speeds close to 1MHz. There is a note in Gen3 and later docs for ICCCR2
saying that cdf=0 is recommended for devices with a data hold time less
than 100ns. I don't have the PMIC docs here to verify if that is the
case here.

However, I recalled there are some generic filter bindings for I2C. I
will check if we can make use of them here.


Attachments:
(No filename) (687.00 B)
signature.asc (849.00 B)
Download all attachments

2023-09-19 19:29:05

by Yoshihiro Shimoda

[permalink] [raw]
Subject: RE: [PATCH 0/2] i2c: rcar: add support for Gen4 devices

Hi Wolfram-san,

> From: Wolfram Sang, Sent: Saturday, September 16, 2023 8:41 PM
>
> Hi Shimoda-san,
>
> I had a look now with Kieran's Spider and could reproduce your findings.
> It is not a problem, though, because the system behaves the same with
> plain v6.6-rc1. The only difference with my branch is that DEBUG is
> enabled for the I2C driver, so we see all the messages regarding
> EPROBE_DEFER with DMA. If you add DEBUG to plain v6.6-rc1, then you see
> the same messages. But still, the busses get probed and they also get
> DMA channels after some time when the DMA driver is finally loaded. So,
> this really has nothing to do with the patches themselves, only with the
> additions for debugging. Phew!

Thank you for the investigation! I also confirmed that reverting the "DEBUG"
commit resolved the issue about the EPROBE_DEFER.

> Thank you for reporting and testing, still!

You're welcome!

Best regards,
Yoshihiro Shimoda

> Wolfram