* [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration
@ 2026-01-05 13:07 Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 1/9] net: dsa: microchip: Initialize IRQ's mask outside common_setup() Bastien Curutchet (Schneider Electric)
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:07 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
Hi all,
This series aims to make the PTP handling a bit more generic to ease the
addition of PTP support for the KSZ8463 in an upcoming series. It is not
intented to change any behaviour in the driver here.
Patches 1 & 2 focus on IRQ handling.
Patches 3 to 9 focus on register access.
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
---
Bastien Curutchet (Schneider Electric) (9):
net: dsa: microchip: Initialize IRQ's mask outside common_setup()
net: dsa: microchip: Use dynamic irq offset
net: dsa: microchip: Use regs[] to access REG_PTP_CLK_CTRL
net: dsa: microchip: Use regs[] to access REG_PTP_RTC_NANOSEC
net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SEC
net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SUB_NANOSEC
net: dsa: microchip: Use regs[] to access REG_PTP_SUBNANOSEC_RATE
net: dsa: microchip: Use regs[] to access REG_PTP_MSG_CONF1
net: dsa: microchip: Wrap timestamp reading in a function
drivers/net/dsa/microchip/ksz_common.c | 15 +++++++-
drivers/net/dsa/microchip/ksz_common.h | 7 ++++
drivers/net/dsa/microchip/ksz_ptp.c | 63 ++++++++++++++++++++-------------
drivers/net/dsa/microchip/ksz_ptp_reg.h | 16 +++------
4 files changed, 64 insertions(+), 37 deletions(-)
---
base-commit: cb2200c26cb670ce973b084129a5ff0dcb99b3b4
change-id: 20251106-ksz-rework-a3ee57784a73
Best regards,
--
Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH net-next 1/9] net: dsa: microchip: Initialize IRQ's mask outside common_setup()
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
@ 2026-01-05 13:08 ` Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 2/9] net: dsa: microchip: Use dynamic irq offset Bastien Curutchet (Schneider Electric)
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:08 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
The IRQ logic of the KSZ8463 differs from that of other KSZ switches.
It doesn't have a 'mask' register but an 'enable' one instead. The
common IRQ framework can still be used though as soon as we reverse
the logic (using '1' to enable interrupts instead of '0') for KSZ8463
cases.
Move the initialization of the kirq->masked outside of
ksz_irq_common_setup() to keep this function truly common when
IRQ support for the KSZ8463 is added.
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
---
drivers/net/dsa/microchip/ksz_common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 0c10351fe5eb4206210c727ffc2484bfb7168d97..fa392f952f9441cfbeb51498fc9411340b58747a 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -2905,7 +2905,6 @@ static int ksz_irq_common_setup(struct ksz_device *dev, struct ksz_irq *kirq)
int ret, n;
kirq->dev = dev;
- kirq->masked = ~0;
kirq->domain = irq_domain_create_simple(dev_fwnode(dev->dev), kirq->nirqs, 0,
&ksz_irq_domain_ops, kirq);
@@ -2935,6 +2934,7 @@ static int ksz_girq_setup(struct ksz_device *dev)
girq->nirqs = dev->info->port_cnt;
girq->reg_mask = REG_SW_PORT_INT_MASK__1;
girq->reg_status = REG_SW_PORT_INT_STATUS__1;
+ girq->masked = ~0;
snprintf(girq->name, sizeof(girq->name), "global_port_irq");
girq->irq_num = dev->irq;
@@ -2949,6 +2949,7 @@ static int ksz_pirq_setup(struct ksz_device *dev, u8 p)
pirq->nirqs = dev->info->port_nirqs;
pirq->reg_mask = dev->dev_ops->get_port_addr(p, REG_PORT_INT_MASK);
pirq->reg_status = dev->dev_ops->get_port_addr(p, REG_PORT_INT_STATUS);
+ pirq->masked = ~0;
snprintf(pirq->name, sizeof(pirq->name), "port_irq-%d", p);
pirq->irq_num = irq_find_mapping(dev->girq.domain, p);
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 2/9] net: dsa: microchip: Use dynamic irq offset
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 1/9] net: dsa: microchip: Initialize IRQ's mask outside common_setup() Bastien Curutchet (Schneider Electric)
@ 2026-01-05 13:08 ` Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 3/9] net: dsa: microchip: Use regs[] to access REG_PTP_CLK_CTRL Bastien Curutchet (Schneider Electric)
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:08 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
The PTP irq_chip operations use an hardcoded IRQ offset in the bit
logic. This IRQ offset isn't the same on KSZ8463 than on others switches
so it can't use the irq_chip operations.
Convey the interrupt bit offset through a new attribute in struct ksz_irq
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
---
drivers/net/dsa/microchip/ksz_common.h | 1 +
drivers/net/dsa/microchip/ksz_ptp.c | 8 +++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index c65188cd3c0a0ed8dd75ee195cebbe47b3a01ada..3add190e686260bb1807ba03b4b153abeead223e 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -108,6 +108,7 @@ struct ksz_irq {
int irq_num;
char name[16];
struct ksz_device *dev;
+ u16 irq0_offset;
};
struct ksz_ptp_irq {
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index 997e4a76d0a68448b0ebc76169150687bbc79673..0ac2865ba9c000fa58b974647c9c88287164cd1c 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -1008,7 +1008,7 @@ static irqreturn_t ksz_ptp_irq_thread_fn(int irq, void *dev_id)
return IRQ_NONE;
for (n = 0; n < ptpirq->nirqs; ++n) {
- if (data & BIT(n + KSZ_PTP_INT_START)) {
+ if (data & BIT(n + ptpirq->irq0_offset)) {
sub_irq = irq_find_mapping(ptpirq->domain, n);
handle_nested_irq(sub_irq);
++nhandled;
@@ -1023,14 +1023,14 @@ static void ksz_ptp_irq_mask(struct irq_data *d)
{
struct ksz_irq *kirq = irq_data_get_irq_chip_data(d);
- kirq->masked &= ~BIT(d->hwirq + KSZ_PTP_INT_START);
+ kirq->masked &= ~BIT(d->hwirq + kirq->irq0_offset);
}
static void ksz_ptp_irq_unmask(struct irq_data *d)
{
struct ksz_irq *kirq = irq_data_get_irq_chip_data(d);
- kirq->masked |= BIT(d->hwirq + KSZ_PTP_INT_START);
+ kirq->masked |= BIT(d->hwirq + kirq->irq0_offset);
}
static void ksz_ptp_irq_bus_lock(struct irq_data *d)
@@ -1126,6 +1126,8 @@ int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p)
ptpirq->reg_mask = ops->get_port_addr(p, REG_PTP_PORT_TX_INT_ENABLE__2);
ptpirq->reg_status = ops->get_port_addr(p,
REG_PTP_PORT_TX_INT_STATUS__2);
+ ptpirq->irq0_offset = KSZ_PTP_INT_START;
+
snprintf(ptpirq->name, sizeof(ptpirq->name), "ptp-irq-%d", p);
init_completion(&port->tstamp_msg_comp);
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 3/9] net: dsa: microchip: Use regs[] to access REG_PTP_CLK_CTRL
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 1/9] net: dsa: microchip: Initialize IRQ's mask outside common_setup() Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 2/9] net: dsa: microchip: Use dynamic irq offset Bastien Curutchet (Schneider Electric)
@ 2026-01-05 13:08 ` Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 4/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_NANOSEC Bastien Curutchet (Schneider Electric)
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:08 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
Accesses to the PTP_CLK_CTRL register are done through a hardcoded
address which doesn't match with the KSZ8463's register layout.
Add a new entry for the PTP_CLK_CTRL register in the regs[] tables.
Use the regs[] table to retrieve the PTP_CLK_CTRL 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>
---
drivers/net/dsa/microchip/ksz_common.c | 2 ++
drivers/net/dsa/microchip/ksz_common.h | 1 +
drivers/net/dsa/microchip/ksz_ptp.c | 19 ++++++++++++-------
drivers/net/dsa/microchip/ksz_ptp_reg.h | 3 +--
4 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index fa392f952f9441cfbeb51498fc9411340b58747a..d7f407370c1cc59402d444e27ebe44e7a600b441 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -569,6 +569,7 @@ static const u16 ksz8463_regs[] = {
[S_START_CTRL] = 0x01,
[S_BROADCAST_CTRL] = 0x06,
[S_MULTICAST_CTRL] = 0x04,
+ [PTP_CLK_CTRL] = 0x0600,
};
static const u32 ksz8463_masks[] = {
@@ -803,6 +804,7 @@ static const u16 ksz9477_regs[] = {
[REG_SW_PME_CTRL] = 0x0006,
[REG_PORT_PME_STATUS] = 0x0013,
[REG_PORT_PME_CTRL] = 0x0017,
+ [PTP_CLK_CTRL] = 0x0500,
};
static const u32 ksz9477_masks[] = {
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 3add190e686260bb1807ba03b4b153abeead223e..8033cb9d84838705389e6ed52a5a54aaa8b49497 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -271,6 +271,7 @@ enum ksz_regs {
REG_SW_PME_CTRL,
REG_PORT_PME_STATUS,
REG_PORT_PME_CTRL,
+ PTP_CLK_CTRL,
};
enum ksz_masks {
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index 0ac2865ba9c000fa58b974647c9c88287164cd1c..68553d9f1e0e3a3cd6319d73b7f9bf6ee2fce7ce 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -585,13 +585,14 @@ void ksz_port_deferred_xmit(struct kthread_work *work)
static int _ksz_ptp_gettime(struct ksz_device *dev, struct timespec64 *ts)
{
+ const u16 *regs = dev->info->regs;
u32 nanoseconds;
u32 seconds;
u8 phase;
int ret;
/* Copy current PTP clock into shadow registers and read */
- ret = ksz_rmw16(dev, REG_PTP_CLK_CTRL, PTP_READ_TIME, PTP_READ_TIME);
+ ret = ksz_rmw16(dev, regs[PTP_CLK_CTRL], PTP_READ_TIME, PTP_READ_TIME);
if (ret)
return ret;
@@ -676,6 +677,7 @@ static int ksz_ptp_settime(struct ptp_clock_info *ptp,
{
struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
+ const u16 *regs = dev->info->regs;
int ret;
mutex_lock(&ptp_data->lock);
@@ -693,7 +695,7 @@ static int ksz_ptp_settime(struct ptp_clock_info *ptp,
if (ret)
goto unlock;
- ret = ksz_rmw16(dev, REG_PTP_CLK_CTRL, PTP_LOAD_TIME, PTP_LOAD_TIME);
+ ret = ksz_rmw16(dev, regs[PTP_CLK_CTRL], PTP_LOAD_TIME, PTP_LOAD_TIME);
if (ret)
goto unlock;
@@ -723,6 +725,7 @@ static int ksz_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
{
struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
+ const u16 *regs = dev->info->regs;
u64 base, adj;
bool negative;
u32 data32;
@@ -743,12 +746,12 @@ static int ksz_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
if (ret)
goto unlock;
- ret = ksz_rmw16(dev, REG_PTP_CLK_CTRL, PTP_CLK_ADJ_ENABLE,
+ ret = ksz_rmw16(dev, regs[PTP_CLK_CTRL], PTP_CLK_ADJ_ENABLE,
PTP_CLK_ADJ_ENABLE);
if (ret)
goto unlock;
} else {
- ret = ksz_rmw16(dev, REG_PTP_CLK_CTRL, PTP_CLK_ADJ_ENABLE, 0);
+ ret = ksz_rmw16(dev, regs[PTP_CLK_CTRL], PTP_CLK_ADJ_ENABLE, 0);
if (ret)
goto unlock;
}
@@ -763,6 +766,7 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
struct timespec64 delta64 = ns_to_timespec64(delta);
+ const u16 *regs = dev->info->regs;
s32 sec, nsec;
u16 data16;
int ret;
@@ -782,7 +786,7 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
if (ret)
goto unlock;
- ret = ksz_read16(dev, REG_PTP_CLK_CTRL, &data16);
+ ret = ksz_read16(dev, regs[PTP_CLK_CTRL], &data16);
if (ret)
goto unlock;
@@ -794,7 +798,7 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
else
data16 |= PTP_STEP_DIR;
- ret = ksz_write16(dev, REG_PTP_CLK_CTRL, data16);
+ ret = ksz_write16(dev, regs[PTP_CLK_CTRL], data16);
if (ret)
goto unlock;
@@ -882,9 +886,10 @@ static long ksz_ptp_do_aux_work(struct ptp_clock_info *ptp)
static int ksz_ptp_start_clock(struct ksz_device *dev)
{
struct ksz_ptp_data *ptp_data = &dev->ptp_data;
+ const u16 *regs = dev->info->regs;
int ret;
- ret = ksz_rmw16(dev, REG_PTP_CLK_CTRL, PTP_CLK_ENABLE, PTP_CLK_ENABLE);
+ ret = ksz_rmw16(dev, regs[PTP_CLK_CTRL], PTP_CLK_ENABLE, PTP_CLK_ENABLE);
if (ret)
return ret;
diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/microchip/ksz_ptp_reg.h
index d71e85510cda56b6ddfefd4ed65564dfb4be7c88..bf8526390c2a2face12406c575a1ea3e4d42e3e6 100644
--- a/drivers/net/dsa/microchip/ksz_ptp_reg.h
+++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h
@@ -15,8 +15,7 @@
#define LED_SRC_PTP_GPIO_2 BIT(2)
/* 5 - PTP Clock */
-#define REG_PTP_CLK_CTRL 0x0500
-
+/* REG_PTP_CLK_CTRL */
#define PTP_STEP_ADJ BIT(6)
#define PTP_STEP_DIR BIT(5)
#define PTP_READ_TIME BIT(4)
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 4/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_NANOSEC
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
` (2 preceding siblings ...)
2026-01-05 13:08 ` [PATCH net-next 3/9] net: dsa: microchip: Use regs[] to access REG_PTP_CLK_CTRL Bastien Curutchet (Schneider Electric)
@ 2026-01-05 13:08 ` Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 5/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SEC Bastien Curutchet (Schneider Electric)
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:08 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
Accesses to the PTP_RTC_NANOSEC 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_NANOSEC register in the regs[] tables.
Use the regs[] table to retrieve the PTP_RTC_NANOSEC 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>
---
drivers/net/dsa/microchip/ksz_common.c | 2 ++
drivers/net/dsa/microchip/ksz_common.h | 1 +
drivers/net/dsa/microchip/ksz_ptp.c | 6 +++---
drivers/net/dsa/microchip/ksz_ptp_reg.h | 2 --
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index d7f407370c1cc59402d444e27ebe44e7a600b441..d400a4ad57b5691d54bce7680fc831475535a85c 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -570,6 +570,7 @@ static const u16 ksz8463_regs[] = {
[S_BROADCAST_CTRL] = 0x06,
[S_MULTICAST_CTRL] = 0x04,
[PTP_CLK_CTRL] = 0x0600,
+ [PTP_RTC_NANOSEC] = 0x0604,
};
static const u32 ksz8463_masks[] = {
@@ -805,6 +806,7 @@ static const u16 ksz9477_regs[] = {
[REG_PORT_PME_STATUS] = 0x0013,
[REG_PORT_PME_CTRL] = 0x0017,
[PTP_CLK_CTRL] = 0x0500,
+ [PTP_RTC_NANOSEC] = 0x0504,
};
static const u32 ksz9477_masks[] = {
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 8033cb9d84838705389e6ed52a5a54aaa8b49497..6d100f1f5e6efe8b43969845ca517625ea825314 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -272,6 +272,7 @@ enum ksz_regs {
REG_PORT_PME_STATUS,
REG_PORT_PME_CTRL,
PTP_CLK_CTRL,
+ PTP_RTC_NANOSEC,
};
enum ksz_masks {
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index 68553d9f1e0e3a3cd6319d73b7f9bf6ee2fce7ce..226b10d0f89a6d58c9b329a66ee25eabc9d294a9 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -600,7 +600,7 @@ static int _ksz_ptp_gettime(struct ksz_device *dev, struct timespec64 *ts)
if (ret)
return ret;
- ret = ksz_read32(dev, REG_PTP_RTC_NANOSEC, &nanoseconds);
+ ret = ksz_read32(dev, regs[PTP_RTC_NANOSEC], &nanoseconds);
if (ret)
return ret;
@@ -687,7 +687,7 @@ static int ksz_ptp_settime(struct ptp_clock_info *ptp,
if (ret)
goto unlock;
- ret = ksz_write32(dev, REG_PTP_RTC_NANOSEC, ts->tv_nsec);
+ ret = ksz_write32(dev, regs[PTP_RTC_NANOSEC], ts->tv_nsec);
if (ret)
goto unlock;
@@ -778,7 +778,7 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
*/
sec = div_s64_rem(delta, NSEC_PER_SEC, &nsec);
- ret = ksz_write32(dev, REG_PTP_RTC_NANOSEC, abs(nsec));
+ ret = ksz_write32(dev, regs[PTP_RTC_NANOSEC], abs(nsec));
if (ret)
goto unlock;
diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/microchip/ksz_ptp_reg.h
index bf8526390c2a2face12406c575a1ea3e4d42e3e6..9ab918c7af4b46a73e00846950ac09917c65db5a 100644
--- a/drivers/net/dsa/microchip/ksz_ptp_reg.h
+++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h
@@ -29,8 +29,6 @@
#define PTP_RTC_SUB_NANOSEC_M 0x0007
#define PTP_RTC_0NS 0x00
-#define REG_PTP_RTC_NANOSEC 0x0504
-
#define REG_PTP_RTC_SEC 0x0508
#define REG_PTP_SUBNANOSEC_RATE 0x050C
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 5/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SEC
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
` (3 preceding siblings ...)
2026-01-05 13:08 ` [PATCH net-next 4/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_NANOSEC Bastien Curutchet (Schneider Electric)
@ 2026-01-05 13:08 ` Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 6/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SUB_NANOSEC Bastien Curutchet (Schneider Electric)
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:08 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
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>
---
drivers/net/dsa/microchip/ksz_common.c | 2 ++
drivers/net/dsa/microchip/ksz_common.h | 1 +
drivers/net/dsa/microchip/ksz_ptp.c | 6 +++---
drivers/net/dsa/microchip/ksz_ptp_reg.h | 2 --
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index d400a4ad57b5691d54bce7680fc831475535a85c..595438031d316eda96ee7fa781aebdb65575b336 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -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[] = {
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 6d100f1f5e6efe8b43969845ca517625ea825314..b4305bd47fbebfd917fca978a6f916d13b6115ea 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -273,6 +273,7 @@ enum ksz_regs {
REG_PORT_PME_CTRL,
PTP_CLK_CTRL,
PTP_RTC_NANOSEC,
+ PTP_RTC_SEC,
};
enum ksz_masks {
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index 226b10d0f89a6d58c9b329a66ee25eabc9d294a9..5a94beb410df38f5d0465e1cd896039292f9a5ec 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -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;
diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/microchip/ksz_ptp_reg.h
index 9ab918c7af4b46a73e00846950ac09917c65db5a..d1d31514488609df9f5eee4b12bff074965b1c6e 100644
--- a/drivers/net/dsa/microchip/ksz_ptp_reg.h
+++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h
@@ -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
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 6/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SUB_NANOSEC
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
` (4 preceding siblings ...)
2026-01-05 13:08 ` [PATCH net-next 5/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SEC Bastien Curutchet (Schneider Electric)
@ 2026-01-05 13:08 ` Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 7/9] net: dsa: microchip: Use regs[] to access REG_PTP_SUBNANOSEC_RATE Bastien Curutchet (Schneider Electric)
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:08 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
Accesses to the PTP_RTC_SUB_NANOSEC 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_SUB_NANOSEC register in the regs[]
tables.
Use the regs[] table to retrieve the PTP_RTC_SUB_NANOSEC 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>
---
drivers/net/dsa/microchip/ksz_common.c | 2 ++
drivers/net/dsa/microchip/ksz_common.h | 1 +
drivers/net/dsa/microchip/ksz_ptp.c | 4 ++--
drivers/net/dsa/microchip/ksz_ptp_reg.h | 3 +--
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 595438031d316eda96ee7fa781aebdb65575b336..7af008cafccf716c2114f486938cdc25b7daae73 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -572,6 +572,7 @@ static const u16 ksz8463_regs[] = {
[PTP_CLK_CTRL] = 0x0600,
[PTP_RTC_NANOSEC] = 0x0604,
[PTP_RTC_SEC] = 0x0608,
+ [PTP_RTC_SUB_NANOSEC] = 0x060C,
};
static const u32 ksz8463_masks[] = {
@@ -807,6 +808,7 @@ static const u16 ksz9477_regs[] = {
[REG_PORT_PME_STATUS] = 0x0013,
[REG_PORT_PME_CTRL] = 0x0017,
[PTP_CLK_CTRL] = 0x0500,
+ [PTP_RTC_SUB_NANOSEC] = 0x0502,
[PTP_RTC_NANOSEC] = 0x0504,
[PTP_RTC_SEC] = 0x0508,
};
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index b4305bd47fbebfd917fca978a6f916d13b6115ea..d1baa3ce09b5fee8e0984791a730b70b704fcfdd 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -274,6 +274,7 @@ enum ksz_regs {
PTP_CLK_CTRL,
PTP_RTC_NANOSEC,
PTP_RTC_SEC,
+ PTP_RTC_SUB_NANOSEC,
};
enum ksz_masks {
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index 5a94beb410df38f5d0465e1cd896039292f9a5ec..3766d8bde478e6c2cf0ec19e7ac27570c2bb7676 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -596,7 +596,7 @@ static int _ksz_ptp_gettime(struct ksz_device *dev, struct timespec64 *ts)
if (ret)
return ret;
- ret = ksz_read8(dev, REG_PTP_RTC_SUB_NANOSEC__2, &phase);
+ ret = ksz_read8(dev, regs[PTP_RTC_SUB_NANOSEC], &phase);
if (ret)
return ret;
@@ -683,7 +683,7 @@ static int ksz_ptp_settime(struct ptp_clock_info *ptp,
mutex_lock(&ptp_data->lock);
/* Write to shadow registers and Load PTP clock */
- ret = ksz_write16(dev, REG_PTP_RTC_SUB_NANOSEC__2, PTP_RTC_0NS);
+ ret = ksz_write16(dev, regs[PTP_RTC_SUB_NANOSEC], PTP_RTC_0NS);
if (ret)
goto unlock;
diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/microchip/ksz_ptp_reg.h
index d1d31514488609df9f5eee4b12bff074965b1c6e..41891ddadaa30ce2cf3ac41273fd335987258230 100644
--- a/drivers/net/dsa/microchip/ksz_ptp_reg.h
+++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h
@@ -24,8 +24,7 @@
#define PTP_CLK_ENABLE BIT(1)
#define PTP_CLK_RESET BIT(0)
-#define REG_PTP_RTC_SUB_NANOSEC__2 0x0502
-
+/* REG_PTP_RTC_SUB_NANOSEC */
#define PTP_RTC_SUB_NANOSEC_M 0x0007
#define PTP_RTC_0NS 0x00
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 7/9] net: dsa: microchip: Use regs[] to access REG_PTP_SUBNANOSEC_RATE
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
` (5 preceding siblings ...)
2026-01-05 13:08 ` [PATCH net-next 6/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SUB_NANOSEC Bastien Curutchet (Schneider Electric)
@ 2026-01-05 13:08 ` Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 8/9] net: dsa: microchip: Use regs[] to access REG_PTP_MSG_CONF1 Bastien Curutchet (Schneider Electric)
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:08 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
Accesses to the PTP_SUBNANOSEC_RATE register are done through a
hardcoded address which doesn't match with the KSZ8463's register
layout.
Add a new entry for the PTP_SUBNANOSEC_RATE register in the regs[]
tables.
Use the regs[] table to retrieve the PTP_SUBNANOSEC_RATE 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>
---
drivers/net/dsa/microchip/ksz_common.c | 2 ++
drivers/net/dsa/microchip/ksz_common.h | 1 +
drivers/net/dsa/microchip/ksz_ptp.c | 2 +-
drivers/net/dsa/microchip/ksz_ptp_reg.h | 3 +--
4 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 7af008cafccf716c2114f486938cdc25b7daae73..cbd918c0add30da17ea6ebe44ff44b866fcf2a1f 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -573,6 +573,7 @@ static const u16 ksz8463_regs[] = {
[PTP_RTC_NANOSEC] = 0x0604,
[PTP_RTC_SEC] = 0x0608,
[PTP_RTC_SUB_NANOSEC] = 0x060C,
+ [PTP_SUBNANOSEC_RATE] = 0x0610,
};
static const u32 ksz8463_masks[] = {
@@ -811,6 +812,7 @@ static const u16 ksz9477_regs[] = {
[PTP_RTC_SUB_NANOSEC] = 0x0502,
[PTP_RTC_NANOSEC] = 0x0504,
[PTP_RTC_SEC] = 0x0508,
+ [PTP_SUBNANOSEC_RATE] = 0x050C,
};
static const u32 ksz9477_masks[] = {
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index d1baa3ce09b5fee8e0984791a730b70b704fcfdd..16a7600789e3233dab1e1ed5d4599b875aa57aa1 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -275,6 +275,7 @@ enum ksz_regs {
PTP_RTC_NANOSEC,
PTP_RTC_SEC,
PTP_RTC_SUB_NANOSEC,
+ PTP_SUBNANOSEC_RATE,
};
enum ksz_masks {
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index 3766d8bde478e6c2cf0ec19e7ac27570c2bb7676..538162e3e4569483c85c710182cb3918a8713d74 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -742,7 +742,7 @@ static int ksz_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
if (!negative)
data32 |= PTP_RATE_DIR;
- ret = ksz_write32(dev, REG_PTP_SUBNANOSEC_RATE, data32);
+ ret = ksz_write32(dev, regs[PTP_SUBNANOSEC_RATE], data32);
if (ret)
goto unlock;
diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/microchip/ksz_ptp_reg.h
index 41891ddadaa30ce2cf3ac41273fd335987258230..1e823b1a19daa480cccdc0367b436a0940e85093 100644
--- a/drivers/net/dsa/microchip/ksz_ptp_reg.h
+++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h
@@ -28,8 +28,7 @@
#define PTP_RTC_SUB_NANOSEC_M 0x0007
#define PTP_RTC_0NS 0x00
-#define REG_PTP_SUBNANOSEC_RATE 0x050C
-
+/* REG_PTP_SUBNANOSEC_RATE */
#define PTP_SUBNANOSEC_M 0x3FFFFFFF
#define PTP_RATE_DIR BIT(31)
#define PTP_TMP_RATE_ENABLE BIT(30)
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 8/9] net: dsa: microchip: Use regs[] to access REG_PTP_MSG_CONF1
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
` (6 preceding siblings ...)
2026-01-05 13:08 ` [PATCH net-next 7/9] net: dsa: microchip: Use regs[] to access REG_PTP_SUBNANOSEC_RATE Bastien Curutchet (Schneider Electric)
@ 2026-01-05 13:08 ` Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 9/9] net: dsa: microchip: Wrap timestamp reading in a function Bastien Curutchet (Schneider Electric)
2026-01-08 12:10 ` [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration patchwork-bot+netdevbpf
9 siblings, 0 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:08 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
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>
---
drivers/net/dsa/microchip/ksz_common.c | 2 ++
drivers/net/dsa/microchip/ksz_common.h | 1 +
drivers/net/dsa/microchip/ksz_ptp.c | 11 +++++++----
drivers/net/dsa/microchip/ksz_ptp_reg.h | 3 +--
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index cbd918c0add30da17ea6ebe44ff44b866fcf2a1f..e5fa1f5fc09b37c1a9d907175f8cd2cd60aee180 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -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[] = {
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 16a7600789e3233dab1e1ed5d4599b875aa57aa1..929aff4c55de5254defdc1afb52b224b3898233b 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -276,6 +276,7 @@ enum ksz_regs {
PTP_RTC_SEC,
PTP_RTC_SUB_NANOSEC,
PTP_SUBNANOSEC_RATE,
+ PTP_MSG_CONF1,
};
enum ksz_masks {
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index 538162e3e4569483c85c710182cb3918a8713d74..b3fff0643ea7a63aec924ec1cd9b451ecfeeab3d 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -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;
diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/microchip/ksz_ptp_reg.h
index 1e823b1a19daa480cccdc0367b436a0940e85093..eab9aecb7fa8a50323de4140695b2004d1beab8c 100644
--- a/drivers/net/dsa/microchip/ksz_ptp_reg.h
+++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h
@@ -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)
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH net-next 9/9] net: dsa: microchip: Wrap timestamp reading in a function
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
` (7 preceding siblings ...)
2026-01-05 13:08 ` [PATCH net-next 8/9] net: dsa: microchip: Use regs[] to access REG_PTP_MSG_CONF1 Bastien Curutchet (Schneider Electric)
@ 2026-01-05 13:08 ` Bastien Curutchet (Schneider Electric)
2026-01-08 12:10 ` [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration patchwork-bot+netdevbpf
9 siblings, 0 replies; 11+ messages in thread
From: Bastien Curutchet (Schneider Electric) @ 2026-01-05 13:08 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Richard Cochran
Cc: Pascal Eberhard, Miquèl Raynal, Thomas Petazzoni, netdev,
linux-kernel, Bastien Curutchet (Schneider Electric)
Timestamps are directly accessed through a register read in the
interrupt handler. KSZ8463's logic to access it will be a bit more
complex because the same interrupt can be triggered by two different
timestamps being ready.
Wrap the timestamp's reading in a dedicated function to ease the
KSZ8463's integration in upcoming patches.
Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
---
drivers/net/dsa/microchip/ksz_ptp.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index b3fff0643ea7a63aec924ec1cd9b451ecfeeab3d..4a2cc57a628f97bd51fcb11057bc4effda9205dd 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -967,6 +967,11 @@ void ksz_ptp_clock_unregister(struct dsa_switch *ds)
ptp_clock_unregister(ptp_data->clock);
}
+static int ksz_read_ts(struct ksz_port *port, u16 reg, u32 *ts)
+{
+ return ksz_read32(port->ksz_dev, reg, ts);
+}
+
static irqreturn_t ksz_ptp_msg_thread_fn(int irq, void *dev_id)
{
struct ksz_ptp_irq *ptpmsg_irq = dev_id;
@@ -980,7 +985,7 @@ static irqreturn_t ksz_ptp_msg_thread_fn(int irq, void *dev_id)
dev = port->ksz_dev;
if (ptpmsg_irq->ts_en) {
- ret = ksz_read32(dev, ptpmsg_irq->ts_reg, &tstamp_raw);
+ ret = ksz_read_ts(port, ptpmsg_irq->ts_reg, &tstamp_raw);
if (ret)
return IRQ_NONE;
--
2.52.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
` (8 preceding siblings ...)
2026-01-05 13:08 ` [PATCH net-next 9/9] net: dsa: microchip: Wrap timestamp reading in a function Bastien Curutchet (Schneider Electric)
@ 2026-01-08 12:10 ` patchwork-bot+netdevbpf
9 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-08 12:10 UTC (permalink / raw)
To: Bastien Curutchet
Cc: woojung.huh, UNGLinuxDriver, andrew, olteanv, davem, edumazet,
kuba, pabeni, richardcochran, pascal.eberhard, miquel.raynal,
thomas.petazzoni, netdev, linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Mon, 05 Jan 2026 14:07:59 +0100 you wrote:
> Hi all,
>
> This series aims to make the PTP handling a bit more generic to ease the
> addition of PTP support for the KSZ8463 in an upcoming series. It is not
> intented to change any behaviour in the driver here.
>
> Patches 1 & 2 focus on IRQ handling.
> Patches 3 to 9 focus on register access.
>
> [...]
Here is the summary with links:
- [net-next,1/9] net: dsa: microchip: Initialize IRQ's mask outside common_setup()
https://git.kernel.org/netdev/net-next/c/813feab1ac52
- [net-next,2/9] net: dsa: microchip: Use dynamic irq offset
https://git.kernel.org/netdev/net-next/c/22bde912e800
- [net-next,3/9] net: dsa: microchip: Use regs[] to access REG_PTP_CLK_CTRL
https://git.kernel.org/netdev/net-next/c/62382d6ffe59
- [net-next,4/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_NANOSEC
https://git.kernel.org/netdev/net-next/c/0ee0566fc234
- [net-next,5/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SEC
https://git.kernel.org/netdev/net-next/c/776ad30de04e
- [net-next,6/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SUB_NANOSEC
https://git.kernel.org/netdev/net-next/c/5b1fe74facc2
- [net-next,7/9] net: dsa: microchip: Use regs[] to access REG_PTP_SUBNANOSEC_RATE
https://git.kernel.org/netdev/net-next/c/d99c1a01ac8d
- [net-next,8/9] net: dsa: microchip: Use regs[] to access REG_PTP_MSG_CONF1
https://git.kernel.org/netdev/net-next/c/b4df828dfc29
- [net-next,9/9] net: dsa: microchip: Wrap timestamp reading in a function
https://git.kernel.org/netdev/net-next/c/3adff276e751
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-01-08 12:13 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-05 13:07 [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 1/9] net: dsa: microchip: Initialize IRQ's mask outside common_setup() Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 2/9] net: dsa: microchip: Use dynamic irq offset Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 3/9] net: dsa: microchip: Use regs[] to access REG_PTP_CLK_CTRL Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 4/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_NANOSEC Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 5/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SEC Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 6/9] net: dsa: microchip: Use regs[] to access REG_PTP_RTC_SUB_NANOSEC Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 7/9] net: dsa: microchip: Use regs[] to access REG_PTP_SUBNANOSEC_RATE Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 8/9] net: dsa: microchip: Use regs[] to access REG_PTP_MSG_CONF1 Bastien Curutchet (Schneider Electric)
2026-01-05 13:08 ` [PATCH net-next 9/9] net: dsa: microchip: Wrap timestamp reading in a function Bastien Curutchet (Schneider Electric)
2026-01-08 12:10 ` [PATCH net-next 0/9] net: dsa: microchip: Adjust PTP handling to ease KSZ8463 integration patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox