mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0
@ 2026-10-03  8:28 Karl Mehltretter
  2026-10-03  8:53 ` John Paul Adrian Glaubitz
  2026-10-03  9:07 ` John Paul Adrian Glaubitz
  0 siblings, 2 replies; 8+ messages in thread
From: Karl Mehltretter @ 2026-10-03  8:28 UTC (permalink / raw)
  To: Yoshinori Sato, Rich Felker
  Cc: Karl Mehltretter, John Paul Adrian Glaubitz, linux-sh, linux-kernel

The R2025S/D board information is registered on I2C bus 0. Commit
44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly
specified") changed the PCA9564 platform driver to pass negative platform
device IDs to the I2C core. The SH7785LCR device uses ID -1, so the core
assigns it a dynamic bus number. Reserving bus 0 for the board information
makes i2c-1 the first dynamic bus, and the RTC is never instantiated.

Set the platform device ID to 0 so the adapter is registered as i2c-0 and
the RTC board information matches it.

Fixes: 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified")
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---

Tested with 29-bit and 32-bit kernels on a custom QEMU model of the
SH7785LCR. Both registered the controller as i2c-0 and the R2025S/D as
rtc0.
Testing on real hardware is welcome.

 arch/sh/boards/board-sh7785lcr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c
index 25c4968f0d8b..b93423df582f 100644
--- a/arch/sh/boards/board-sh7785lcr.c
+++ b/arch/sh/boards/board-sh7785lcr.c
@@ -256,7 +256,7 @@ static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
 
 static struct platform_device i2c_device = {
 	.name		= "i2c-pca-platform",
-	.id		= -1,
+	.id		= 0,
 	.dev		= {
 		.platform_data	= &i2c_platform_data,
 	},
-- 
2.53.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0
  2026-10-03  8:28 [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0 Karl Mehltretter
@ 2026-10-03  8:53 ` John Paul Adrian Glaubitz
  2026-10-03  9:07 ` John Paul Adrian Glaubitz
  1 sibling, 0 replies; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2026-10-03  8:53 UTC (permalink / raw)
  To: Karl Mehltretter, Yoshinori Sato, Rich Felker; +Cc: linux-sh, linux-kernel

Hello Karl,

On Sat, 2026-10-03 at 10:28 +0200, Karl Mehltretter wrote:
> The R2025S/D board information is registered on I2C bus 0. Commit
> 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly
> specified") changed the PCA9564 platform driver to pass negative platform
> device IDs to the I2C core. The SH7785LCR device uses ID -1, so the core
> assigns it a dynamic bus number. Reserving bus 0 for the board information
> makes i2c-1 the first dynamic bus, and the RTC is never instantiated.
> 
> Set the platform device ID to 0 so the adapter is registered as i2c-0 and
> the RTC board information matches it.
> 
> Fixes: 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified")
> Assisted-by: LLM
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
> ---
> 
> Tested with 29-bit and 32-bit kernels on a custom QEMU model of the
> SH7785LCR. Both registered the controller as i2c-0 and the R2025S/D as
> rtc0.
> Testing on real hardware is welcome.
> 
>  arch/sh/boards/board-sh7785lcr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c
> index 25c4968f0d8b..b93423df582f 100644
> --- a/arch/sh/boards/board-sh7785lcr.c
> +++ b/arch/sh/boards/board-sh7785lcr.c
> @@ -256,7 +256,7 @@ static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
>  
>  static struct platform_device i2c_device = {
>  	.name		= "i2c-pca-platform",
> -	.id		= -1,
> +	.id		= 0,
>  	.dev		= {
>  		.platform_data	= &i2c_platform_data,
>  	},

Without the patch, the rtc is not detected during boot and trying to read it out
with the hwclock utility fails:

root@tirpitz:~> hwclock
hwclock: Cannot access the Hardware Clock via any known method.
hwclock: Use the --verbose option to see the details of our search for an access method.
root@tirpitz:~> hwclock --verbose
hwclock from util-linux 2.41.3
System Time: 1791016681.183560
Trying to open: /dev/rtc0
Trying to open: /dev/rtc
Trying to open: /dev/misc/rtc
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.
root@tirpitz:~>

With the patch, the rtc is detected during boot:

[    4.048000] rtc-rs5c372 0-0032: r2025sd found, 24hr
[    4.056000] rtc-rs5c372 0-0032: rtc oscillator interruption detected. Please reset the rtc clock.
[    4.072000] rtc-rs5c372 0-0032: registered as rtc0
[    4.080000] rtc-rs5c372 0-0032: rtc oscillator interruption detected. Please reset the rtc clock.
[    4.088000] rtc-rs5c372 0-0032: hctosys: unable to read the hardware clock

And can be read out with hwclock:

root@tirpitz:~> hwclock --verbose
hwclock from util-linux 2.41.3
System Time: 1791017592.121448
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 0 seconds after 1969
Last calibration done at 0 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
ioctl(4, RTC_UIE_ON, 0): Invalid argument
Waiting in loop for time from /dev/rtc0 to change
...got clock tick
Time read from Hardware Clock: 2026/10/03 08:53:13
Hw clock time : 2026/10/03 08:53:13 = 1791017593 seconds since 1969
Time since last adjustment is 1791017593 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2026-10-03 10:53:12.109057+02:00
root@tirpitz:~>

Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0
  2026-10-03  8:28 [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0 Karl Mehltretter
  2026-10-03  8:53 ` John Paul Adrian Glaubitz
@ 2026-10-03  9:07 ` John Paul Adrian Glaubitz
  2026-10-03  9:38   ` John Paul Adrian Glaubitz
  1 sibling, 1 reply; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2026-10-03  9:07 UTC (permalink / raw)
  To: Karl Mehltretter, Yoshinori Sato, Rich Felker; +Cc: linux-sh, linux-kernel

On Sat, 2026-10-03 at 10:28 +0200, Karl Mehltretter wrote:
> The R2025S/D board information is registered on I2C bus 0. Commit
> 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly
> specified") changed the PCA9564 platform driver to pass negative platform
> device IDs to the I2C core. The SH7785LCR device uses ID -1, so the core
> assigns it a dynamic bus number. Reserving bus 0 for the board information
> makes i2c-1 the first dynamic bus, and the RTC is never instantiated.
> 
> Set the platform device ID to 0 so the adapter is registered as i2c-0 and
> the RTC board information matches it.
> 
> Fixes: 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified")
> Assisted-by: LLM
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
> ---
> 
> Tested with 29-bit and 32-bit kernels on a custom QEMU model of the
> SH7785LCR. Both registered the controller as i2c-0 and the R2025S/D as
> rtc0.
> Testing on real hardware is welcome.
> 
>  arch/sh/boards/board-sh7785lcr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c
> index 25c4968f0d8b..b93423df582f 100644
> --- a/arch/sh/boards/board-sh7785lcr.c
> +++ b/arch/sh/boards/board-sh7785lcr.c
> @@ -256,7 +256,7 @@ static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
>  
>  static struct platform_device i2c_device = {
>  	.name		= "i2c-pca-platform",
> -	.id		= -1,
> +	.id		= 0,
>  	.dev		= {
>  		.platform_data	= &i2c_platform_data,
>  	},

Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0
  2026-10-03  9:07 ` John Paul Adrian Glaubitz
@ 2026-10-03  9:38   ` John Paul Adrian Glaubitz
  2026-10-03  9:51     ` Karl Mehltretter
  0 siblings, 1 reply; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2026-10-03  9:38 UTC (permalink / raw)
  To: Karl Mehltretter, Yoshinori Sato, Rich Felker; +Cc: linux-sh, linux-kernel

On Sat, 2026-10-03 at 11:07 +0200, John Paul Adrian Glaubitz wrote:
> On Sat, 2026-10-03 at 10:28 +0200, Karl Mehltretter wrote:
> > The R2025S/D board information is registered on I2C bus 0. Commit
> > 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly
> > specified") changed the PCA9564 platform driver to pass negative platform
> > device IDs to the I2C core. The SH7785LCR device uses ID -1, so the core
> > assigns it a dynamic bus number. Reserving bus 0 for the board information
> > makes i2c-1 the first dynamic bus, and the RTC is never instantiated.
> > 
> > Set the platform device ID to 0 so the adapter is registered as i2c-0 and
> > the RTC board information matches it.
> > 
> > Fixes: 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified")
> > Assisted-by: LLM
> > Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
> > ---
> > 
> > Tested with 29-bit and 32-bit kernels on a custom QEMU model of the
> > SH7785LCR. Both registered the controller as i2c-0 and the R2025S/D as
> > rtc0.
> > Testing on real hardware is welcome.
> > 
> >  arch/sh/boards/board-sh7785lcr.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c
> > index 25c4968f0d8b..b93423df582f 100644
> > --- a/arch/sh/boards/board-sh7785lcr.c
> > +++ b/arch/sh/boards/board-sh7785lcr.c
> > @@ -256,7 +256,7 @@ static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
> >  
> >  static struct platform_device i2c_device = {
> >  	.name		= "i2c-pca-platform",
> > -	.id		= -1,
> > +	.id		= 0,
> >  	.dev		= {
> >  		.platform_data	= &i2c_platform_data,
> >  	},
> 
> Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

I have to admit though I don't fully understand the description of this
patch. Either I don't have enough coffee or it's not precise enough.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0
  2026-10-03  9:38   ` John Paul Adrian Glaubitz
@ 2026-10-03  9:51     ` Karl Mehltretter
  2026-10-03  9:57       ` John Paul Adrian Glaubitz
  2026-10-03 12:52       ` Geert Uytterhoeven
  0 siblings, 2 replies; 8+ messages in thread
From: Karl Mehltretter @ 2026-10-03  9:51 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Yoshinori Sato, Rich Felker, linux-sh, linux-kernel

On Sat, Oct 03, 2026 at 11:38:43AM +0100, John Paul Adrian Glaubitz wrote:
> > Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> 
> I have to admit though I don't fully understand the description of this
> patch. Either I don't have enough coffee or it's not precise enough.
> 

Thanks for testing and reviewing! I agree the changelog doesn't explain
why -1 is wrong and 0 is right for this board very clearly. I'll give it
a day or so to step back and submit a v2 with your tags and a better
changelog.

Karl

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0
  2026-10-03  9:51     ` Karl Mehltretter
@ 2026-10-03  9:57       ` John Paul Adrian Glaubitz
  2026-10-03 12:52       ` Geert Uytterhoeven
  1 sibling, 0 replies; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2026-10-03  9:57 UTC (permalink / raw)
  To: Karl Mehltretter; +Cc: Yoshinori Sato, Rich Felker, linux-sh, linux-kernel

On Sat, 2026-10-03 at 11:51 +0200, Karl Mehltretter wrote:
> On Sat, Oct 03, 2026 at 11:38:43AM +0100, John Paul Adrian Glaubitz wrote:
> > > Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> > 
> > I have to admit though I don't fully understand the description of this
> > patch. Either I don't have enough coffee or it's not precise enough.
> > 
> 
> Thanks for testing and reviewing! I agree the changelog doesn't explain
> why -1 is wrong and 0 is right for this board very clearly. I'll give it
> a day or so to step back and submit a v2 with your tags and a better
> changelog.

Thanks a lot! I'm glad it's not just that I had only one coffee today! ;-)

I will try to start looking at a few other patches this weekend. I'm not
sure if I will be able to pick up all at once for v7.4, so some of them
might end up in v7.5.

Either way, thanks for all these fixes! I didn't even notice that accessing
the hardware clock didn't work.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0
  2026-10-03  9:51     ` Karl Mehltretter
  2026-10-03  9:57       ` John Paul Adrian Glaubitz
@ 2026-10-03 12:52       ` Geert Uytterhoeven
  2026-10-03 18:17         ` John Paul Adrian Glaubitz
  1 sibling, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2026-10-03 12:52 UTC (permalink / raw)
  To: Karl Mehltretter
  Cc: John Paul Adrian Glaubitz, Yoshinori Sato, Rich Felker, linux-sh,
	linux-kernel

Hi Karl,

On Sat, 3 Oct 2026 at 11:51, Karl Mehltretter <kmehltretter@gmail.com> wrote:
> On Sat, Oct 03, 2026 at 11:38:43AM +0100, John Paul Adrian Glaubitz wrote:
> > > Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> >
> > I have to admit though I don't fully understand the description of this
> > patch. Either I don't have enough coffee or it's not precise enough.
>
> Thanks for testing and reviewing! I agree the changelog doesn't explain
> why -1 is wrong and 0 is right for this board very clearly. I'll give it
> a day or so to step back and submit a v2 with your tags and a better
> changelog.

Perhaps something like:

Before commit 44454baa7ca7bb57 ("i2c: Dynamically assign adapter id if
it wasn't explictly specified"), a negative ID was replaced by zero,
and I2C bus zero was instantiated.  Since that commit, a negative ID
is passed verbatim, instantiating an I2C bus with a dynamic number.
As SH boards still use i2c_register_board_info(0, ...) to register I2C
devices, they rely on the I2C bus being bus zero, causing registration to fail.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0
  2026-10-03 12:52       ` Geert Uytterhoeven
@ 2026-10-03 18:17         ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2026-10-03 18:17 UTC (permalink / raw)
  To: Geert Uytterhoeven, Karl Mehltretter
  Cc: Yoshinori Sato, Rich Felker, linux-sh, linux-kernel

Hi Geert,

On Sat, 2026-10-03 at 14:52 +0200, Geert Uytterhoeven wrote:
> Hi Karl,
> 
> On Sat, 3 Oct 2026 at 11:51, Karl Mehltretter <kmehltretter@gmail.com> wrote:
> > On Sat, Oct 03, 2026 at 11:38:43AM +0100, John Paul Adrian Glaubitz wrote:
> > > > Reviewed-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> > > 
> > > I have to admit though I don't fully understand the description of this
> > > patch. Either I don't have enough coffee or it's not precise enough.
> > 
> > Thanks for testing and reviewing! I agree the changelog doesn't explain
> > why -1 is wrong and 0 is right for this board very clearly. I'll give it
> > a day or so to step back and submit a v2 with your tags and a better
> > changelog.
> 
> Perhaps something like:
> 
> Before commit 44454baa7ca7bb57 ("i2c: Dynamically assign adapter id if
> it wasn't explictly specified"), a negative ID was replaced by zero,
> and I2C bus zero was instantiated.  Since that commit, a negative ID
> is passed verbatim, instantiating an I2C bus with a dynamic number.
> As SH boards still use i2c_register_board_info(0, ...) to register I2C
> devices, they rely on the I2C bus being bus zero, causing registration to fail.

Yeah, that makes a whole lot of more sense to me. Thanks for the clarification!

If Karl agrees, we can go with that one and he can send a v2.

Adrian

> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> Gr{oetje,eeting}s,
> 
>                         Geert

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-10-03 18:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-03  8:28 [PATCH] sh: sh7785lcr: register the PCA9564 as I2C bus 0 Karl Mehltretter
2026-10-03  8:53 ` John Paul Adrian Glaubitz
2026-10-03  9:07 ` John Paul Adrian Glaubitz
2026-10-03  9:38   ` John Paul Adrian Glaubitz
2026-10-03  9:51     ` Karl Mehltretter
2026-10-03  9:57       ` John Paul Adrian Glaubitz
2026-10-03 12:52       ` Geert Uytterhoeven
2026-10-03 18:17         ` John Paul Adrian Glaubitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®