[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <zhuujdhxrquhi4u6n25rryx3yw3lm2ceuijcwjmnrr4awt4ys4@53wh2fqxnd6w>
Date: Sun, 8 Dec 2024 17:44:49 +0100
From: Jörg Sommer <joerg@...so.de>
To: Christian Eggers <ceggers@...i.de>
Cc: Andrew Lunn <andrew@...n.ch>, netdev@...r.kernel.org
Subject: Re: KSZ8795 not detected at start to boot from NFS
Hi Christian,
Christian Eggers schrieb am Sa 07. Dez, 23:44 (+0100):
> On Saturday, 7 December 2024, 21:47:31 CET, Andrew Lunn wrote:
> > What i don't understand from your description is why:
> >
> > > + /* setup spi */
> > > + spi->mode = SPI_MODE_3;
> > > + ret = spi_setup(spi);
> > > + if (ret)
> > > + return ret;
> > > +
> >
> > is causing this issue. Is spi_setup() failing?
>
> On Saturday, 7 December 2024, 22:07:23 CET, Jörg Sommer wrote:
>
> > I've added another dev_err() after the spi_setup:
> >
> > [ 1.680516] ksz8795-switch spi0.1: ksz8795_spi_probe:55: ret of spi_setup=0
> > [ 1.819194] ksz8795-switch spi0.1: ksz8795_spi_probe:61: ret=-22#
>
> It doesn't look so.
>
> @Jörg. You didn't explicitly mention which kernel version you are trying to run.
I've checked out 8c4599f49841dd663402ec52325dc2233add1d32. But I also have
to apply the commits 1aa4ee0ec7fe929bd46ae20d9457f0a242115643
ba6e5af621ab2fb4cd4acb37d4914c832991689c
f19d8dfad67b641af274a9a317a12f31c430e254, because 5.10 doesn't work without
them, too, and they where added somewhere in 5.10.223.
From 5.10 with these additionally changes I started and found 8c4599.
> Maybe the -EINVAL comes from line 414:
>
> if (dev->dev_ops->detect(dev))
> return -EINVAL;
>
> But this is only a guess.
You're right.
[ 1.678236] ksz8795-switch spi0.1: ksz8795_spi_probe:53: spi->mode=0 before SPI_MODE_3=3
[ 1.686754] ksz8795-switch spi0.1: ksz8795_spi_probe:56: spi_setup()=0
[ 1.817017] ksz8795-switch spi0.1: ksz8795_switch_detect:1151: id1=0 <> FAMILY_ID=135, id2=0 <> CHIP_ID_94=96 && CHIP_ID_95=144
[ 1.828812] ksz8795-switch spi0.1: ksz_switch_register:415: dev->dev_ops->detect()c037e47c=-19
[ 1.837609] ksz8795-switch spi0.1: ksz8795_spi_probe:62: ksz8795_switch_register()=-22
[ 1.845909] spi_davinci 1f0e000.spi: Controller at 0x(ptrval)
…
[ 1.969734] ksz8795-switch spi0.1: ksz8795_spi_probe:53: spi->mode=3 before SPI_MODE_3=3
[ 1.978309] ksz8795-switch spi0.1: ksz8795_spi_probe:56: spi_setup()=0
[ 2.117906] ksz8795-switch spi0.1: ksz8795_spi_probe:62: ksz8795_switch_register()=-517
[ 2.127235] ksz8795-switch spi0.1: ksz8795_spi_probe:53: spi->mode=3 before SPI_MODE_3=3
[ 2.135427] ksz8795-switch spi0.1: ksz8795_spi_probe:56: spi_setup()=0
[ 2.267825] ksz8795-switch spi0.1: ksz8795_spi_probe:62: ksz8795_switch_register()=-517
[ 2.281336] davinci_emac 1e20000.ethernet: incompatible machine/device type for reading mac address
[ 2.294928] ksz8795-switch spi0.1: ksz8795_spi_probe:53: spi->mode=3 before SPI_MODE_3=3
[ 2.305365] ksz8795-switch spi0.1: ksz8795_spi_probe:56: spi_setup()=0
[ 2.954286] random: crng init done
[ 3.174408] libphy: dsa slave smi: probed
[ 3.180666] ksz8795-switch spi0.1 lan-x1 (uninitialized): PHY [dsa-0.0:00] driver [Generic PHY] (irq=POLL)
This is my setting:
git reset --hard 8c4599f49841dd663402ec52325dc2233add1d32
git cherry-pick -n \
1aa4ee0ec7fe929bd46ae20d9457f0a242115643 \
f365d53c868725c472d515fa1ce4f57d0eaff5ae \
ba6e5af621ab2fb4cd4acb37d4914c832991689c \
f19d8dfad67b641af274a9a317a12f31c430e254
git apply -p0 --ignore-whitespace <<__EOF
diff --git drivers/net/dsa/microchip/ksz8795.c drivers/net/dsa/microchip/ksz8795.c
index 1e101ab56cea..4c9f27a061c1 100644
--- drivers/net/dsa/microchip/ksz8795.c
+++ drivers/net/dsa/microchip/ksz8795.c
@@ -1147,8 +1147,11 @@ static int ksz8795_switch_detect(struct ksz_device *dev)
id1 = id16 >> 8;
id2 = id16 & SW_CHIP_ID_M;
if (id1 != FAMILY_ID ||
- (id2 != CHIP_ID_94 && id2 != CHIP_ID_95))
+ (id2 != CHIP_ID_94 && id2 != CHIP_ID_95)) {
+dev_err(dev->dev, "%s:%d: id1=%d <> FAMILY_ID=%d, id2=%d <> CHIP_ID_94=%d && CHIP_ID_95=%d \n",
+ __func__, __LINE__, id1, FAMILY_ID, id2, CHIP_ID_94, CHIP_ID_95);
return -ENODEV;
+ }
dev->mib_port_cnt = TOTAL_PORT_NUM;
dev->phy_port_cnt = SWITCH_PORT_NUM;
diff --git drivers/net/dsa/microchip/ksz8795_spi.c drivers/net/dsa/microchip/ksz8795_spi.c
index 5dab5d36c675..cb812538ec5b 100644
--- drivers/net/dsa/microchip/ksz8795_spi.c
+++ drivers/net/dsa/microchip/ksz8795_spi.c
@@ -50,13 +50,19 @@ static int ksz8795_spi_probe(struct spi_device *spi)
dev->pdata = spi->dev.platform_data;
/* setup spi */
+ dev_err(&spi->dev, "%s:%d: spi->mode=%d before SPI_MODE_3=%d\n", __func__, __LINE__, spi->mode, SPI_MODE_3);
spi->mode = SPI_MODE_3;
ret = spi_setup(spi);
+ dev_err(&spi->dev, "%s:%d: spi_setup()=%d\n", __func__, __LINE__, ret);
if (ret)
return ret;
ret = ksz8795_switch_register(dev);
+ dev_err(&spi->dev, "%s:%d: ksz8795_switch_register()=%d\n", __func__, __LINE__, ret);
+ if (ret == -EINVAL || ret == -ENODEV)
+ ret = -EPROBE_DEFER;
+
/* Main DSA driver may not be started yet. */
if (ret)
return ret;
diff --git drivers/net/dsa/microchip/ksz_common.c drivers/net/dsa/microchip/ksz_common.c
index 32836450d62c..44b66951c633 100644
--- drivers/net/dsa/microchip/ksz_common.c
+++ drivers/net/dsa/microchip/ksz_common.c
@@ -410,8 +410,11 @@ int ksz_switch_register(struct ksz_device *dev,
dev->dev_ops = ops;
- if (dev->dev_ops->detect(dev))
+ret = dev->dev_ops->detect(dev);
+ if (ret) {
+dev_err(dev->dev, "%s:%d: dev->dev_ops->detect()%lx=%d\n", __func__, __LINE__, dev->dev_ops->detect, ret);
return -EINVAL;
+ }
ret = dev->dev_ops->init(dev);
if (ret)
> > Andrew Lunn schrieb am Sa 07. Dez, 21:47 (+0100):
> > >
> > > What i don't understand from your description is why:
> > >
> > > > + /* setup spi */
> > > > + spi->mode = SPI_MODE_3;
> > > > + ret = spi_setup(spi);
> > > > + if (ret)
> > > > + return ret;
> > > > +
> > >
> > > is causing this issue. Is spi_setup() failing?
>
> Maybe that the configured SPI mode does somehow not work for Jörg's setup.
> Perhaps SPI mode 3 on his controller is not the same as for my one (NXP i.MX6).
> This could then cause a mismatch when reading the chip id in ksz8795_switch_detect().
Or am I missing something in my devicetree to set the SPI to mode 3?
> @Jörg: Can you please check this? If possible, a measurement of the SPI
> lines (with an oscilloscope or logic analyzer) would be interesting.
I can check this in the next days. I only have remote access to the device.
Thanks for helping me.
Jörg
--
Ein Mensch sieht ein und das ist wichtig,
nichts ist ganz falsch und nichts ganz richtig.
(Eugen Roth)
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists