mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-22 08:53:44 -05:00
net: dsa: microchip: Use regs[] to access REG_PTP_MSG_CONF1
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>
This commit is contained in:
committed by
Paolo Abeni
parent
d99c1a01ac
commit
b4df828dfc
@@ -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[] = {
|
||||
|
||||
@@ -276,6 +276,7 @@ enum ksz_regs {
|
||||
PTP_RTC_SEC,
|
||||
PTP_RTC_SUB_NANOSEC,
|
||||
PTP_SUBNANOSEC_RATE,
|
||||
PTP_MSG_CONF1,
|
||||
};
|
||||
|
||||
enum ksz_masks {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user