]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SEC
authorBastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Mon, 5 Jan 2026 13:08:04 +0000 (14:08 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 8 Jan 2026 12:01:16 +0000 (13:01 +0100)
Accesses to the PTP_RTC_SEC register are done through a hardcoded
address which doesn't match with the KSZ8463's register layout.

Add a new entry for the PTP_RTC_SEC register in the regs[] tables.
Use the regs[] table to retrieve the PTP_RTC_SEC register address
when accessing it.
Remove the macro defining the address to prevent further use.

Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Link: https://patch.msgid.link/20260105-ksz-rework-v1-5-a68df7f57375@bootlin.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.h
drivers/net/dsa/microchip/ksz_ptp.c
drivers/net/dsa/microchip/ksz_ptp_reg.h

index d400a4ad57b5691d54bce7680fc831475535a85c..595438031d316eda96ee7fa781aebdb65575b336 100644 (file)
@@ -571,6 +571,7 @@ static const u16 ksz8463_regs[] = {
        [S_MULTICAST_CTRL]              = 0x04,
        [PTP_CLK_CTRL]                  = 0x0600,
        [PTP_RTC_NANOSEC]               = 0x0604,
+       [PTP_RTC_SEC]                   = 0x0608,
 };
 
 static const u32 ksz8463_masks[] = {
@@ -807,6 +808,7 @@ static const u16 ksz9477_regs[] = {
        [REG_PORT_PME_CTRL]             = 0x0017,
        [PTP_CLK_CTRL]                  = 0x0500,
        [PTP_RTC_NANOSEC]               = 0x0504,
+       [PTP_RTC_SEC]                   = 0x0508,
 };
 
 static const u32 ksz9477_masks[] = {
index 6d100f1f5e6efe8b43969845ca517625ea825314..b4305bd47fbebfd917fca978a6f916d13b6115ea 100644 (file)
@@ -273,6 +273,7 @@ enum ksz_regs {
        REG_PORT_PME_CTRL,
        PTP_CLK_CTRL,
        PTP_RTC_NANOSEC,
+       PTP_RTC_SEC,
 };
 
 enum ksz_masks {
index 226b10d0f89a6d58c9b329a66ee25eabc9d294a9..5a94beb410df38f5d0465e1cd896039292f9a5ec 100644 (file)
@@ -604,7 +604,7 @@ static int _ksz_ptp_gettime(struct ksz_device *dev, struct timespec64 *ts)
        if (ret)
                return ret;
 
-       ret = ksz_read32(dev, REG_PTP_RTC_SEC, &seconds);
+       ret = ksz_read32(dev, regs[PTP_RTC_SEC], &seconds);
        if (ret)
                return ret;
 
@@ -691,7 +691,7 @@ static int ksz_ptp_settime(struct ptp_clock_info *ptp,
        if (ret)
                goto unlock;
 
-       ret = ksz_write32(dev, REG_PTP_RTC_SEC, ts->tv_sec);
+       ret = ksz_write32(dev, regs[PTP_RTC_SEC], ts->tv_sec);
        if (ret)
                goto unlock;
 
@@ -782,7 +782,7 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
        if (ret)
                goto unlock;
 
-       ret = ksz_write32(dev, REG_PTP_RTC_SEC, abs(sec));
+       ret = ksz_write32(dev, regs[PTP_RTC_SEC], abs(sec));
        if (ret)
                goto unlock;
 
index 9ab918c7af4b46a73e00846950ac09917c65db5a..d1d31514488609df9f5eee4b12bff074965b1c6e 100644 (file)
@@ -29,8 +29,6 @@
 #define PTP_RTC_SUB_NANOSEC_M          0x0007
 #define PTP_RTC_0NS                    0x00
 
-#define REG_PTP_RTC_SEC                        0x0508
-
 #define REG_PTP_SUBNANOSEC_RATE                0x050C
 
 #define PTP_SUBNANOSEC_M               0x3FFFFFFF