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

Add a new entry for the PTP_MSG_CONF1 register in the regs[] tables.
Use the regs[] table to retrieve the PTP_MSG_CONF1 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-8-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 cbd918c0add30da17ea6ebe44ff44b866fcf2a1f..e5fa1f5fc09b37c1a9d907175f8cd2cd60aee180 100644 (file)
@@ -574,6 +574,7 @@ static const u16 ksz8463_regs[] = {
        [PTP_RTC_SEC]                   = 0x0608,
        [PTP_RTC_SUB_NANOSEC]           = 0x060C,
        [PTP_SUBNANOSEC_RATE]           = 0x0610,
+       [PTP_MSG_CONF1]                 = 0x0620,
 };
 
 static const u32 ksz8463_masks[] = {
@@ -813,6 +814,7 @@ static const u16 ksz9477_regs[] = {
        [PTP_RTC_NANOSEC]               = 0x0504,
        [PTP_RTC_SEC]                   = 0x0508,
        [PTP_SUBNANOSEC_RATE]           = 0x050C,
+       [PTP_MSG_CONF1]                 = 0x0514,
 };
 
 static const u32 ksz9477_masks[] = {
index 16a7600789e3233dab1e1ed5d4599b875aa57aa1..929aff4c55de5254defdc1afb52b224b3898233b 100644 (file)
@@ -276,6 +276,7 @@ enum ksz_regs {
        PTP_RTC_SEC,
        PTP_RTC_SUB_NANOSEC,
        PTP_SUBNANOSEC_RATE,
+       PTP_MSG_CONF1,
 };
 
 enum ksz_masks {
index 538162e3e4569483c85c710182cb3918a8713d74..b3fff0643ea7a63aec924ec1cd9b451ecfeeab3d 100644 (file)
@@ -263,6 +263,7 @@ static int ksz_ptp_enable_mode(struct ksz_device *dev)
 {
        struct ksz_tagger_data *tagger_data = ksz_tagger_data(dev->ds);
        struct ksz_ptp_data *ptp_data = &dev->ptp_data;
+       const u16 *regs = dev->info->regs;
        struct ksz_port *prt;
        struct dsa_port *dp;
        bool tag_en = false;
@@ -283,7 +284,7 @@ static int ksz_ptp_enable_mode(struct ksz_device *dev)
 
        tagger_data->hwtstamp_set_state(dev->ds, tag_en);
 
-       return ksz_rmw16(dev, REG_PTP_MSG_CONF1, PTP_ENABLE,
+       return ksz_rmw16(dev, regs[PTP_MSG_CONF1], PTP_ENABLE,
                         tag_en ? PTP_ENABLE : 0);
 }
 
@@ -335,6 +336,7 @@ static int ksz_set_hwtstamp_config(struct ksz_device *dev,
                                   struct ksz_port *prt,
                                   struct kernel_hwtstamp_config *config)
 {
+       const u16 *regs = dev->info->regs;
        int ret;
 
        if (config->flags)
@@ -353,7 +355,7 @@ static int ksz_set_hwtstamp_config(struct ksz_device *dev,
                prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en = false;
                prt->hwts_tx_en = true;
 
-               ret = ksz_rmw16(dev, REG_PTP_MSG_CONF1, PTP_1STEP, PTP_1STEP);
+               ret = ksz_rmw16(dev, regs[PTP_MSG_CONF1], PTP_1STEP, PTP_1STEP);
                if (ret)
                        return ret;
 
@@ -367,7 +369,7 @@ static int ksz_set_hwtstamp_config(struct ksz_device *dev,
                prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en = true;
                prt->hwts_tx_en = true;
 
-               ret = ksz_rmw16(dev, REG_PTP_MSG_CONF1, PTP_1STEP, 0);
+               ret = ksz_rmw16(dev, regs[PTP_MSG_CONF1], PTP_1STEP, 0);
                if (ret)
                        return ret;
 
@@ -902,6 +904,7 @@ static int ksz_ptp_start_clock(struct ksz_device *dev)
 int ksz_ptp_clock_register(struct dsa_switch *ds)
 {
        struct ksz_device *dev = ds->priv;
+       const u16 *regs = dev->info->regs;
        struct ksz_ptp_data *ptp_data;
        int ret;
        u8 i;
@@ -941,7 +944,7 @@ int ksz_ptp_clock_register(struct dsa_switch *ds)
        /* Currently only P2P mode is supported. When 802_1AS bit is set, it
         * forwards all PTP packets to host port and none to other ports.
         */
-       ret = ksz_rmw16(dev, REG_PTP_MSG_CONF1, PTP_TC_P2P | PTP_802_1AS,
+       ret = ksz_rmw16(dev, regs[PTP_MSG_CONF1], PTP_TC_P2P | PTP_802_1AS,
                        PTP_TC_P2P | PTP_802_1AS);
        if (ret)
                return ret;
index 1e823b1a19daa480cccdc0367b436a0940e85093..eab9aecb7fa8a50323de4140695b2004d1beab8c 100644 (file)
@@ -39,8 +39,7 @@
 #define REG_PTP_RATE_DURATION_H                0x0510
 #define REG_PTP_RATE_DURATION_L                0x0512
 
-#define REG_PTP_MSG_CONF1              0x0514
-
+/* REG_PTP_MSG_CONF1 */
 #define PTP_802_1AS                    BIT(7)
 #define PTP_ENABLE                     BIT(6)
 #define PTP_ETH_ENABLE                 BIT(5)