Skip to content

Commit 45bce17

Browse files
atenartdavem330
authored andcommitted
net: mscc: describe the PTP register range
This patch adds support for using the PTP register range, and adds a description of its registers. This bank is used when configuring PTP. Signed-off-by: Antoine Tenart <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 744350b commit 45bce17

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

drivers/net/ethernet/mscc/ocelot.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "ocelot_sys.h"
2424
#include "ocelot_qs.h"
2525
#include "ocelot_tc.h"
26+
#include "ocelot_ptp.h"
2627

2728
#define PGID_AGGR 64
2829
#define PGID_SRC 80
@@ -71,6 +72,7 @@ enum ocelot_target {
7172
SYS,
7273
S2,
7374
HSIO,
75+
PTP,
7476
TARGET_MAX,
7577
};
7678

@@ -343,6 +345,13 @@ enum ocelot_reg {
343345
S2_CACHE_ACTION_DAT,
344346
S2_CACHE_CNT_DAT,
345347
S2_CACHE_TG_DAT,
348+
PTP_PIN_CFG = PTP << TARGET_OFFSET,
349+
PTP_PIN_TOD_SEC_MSB,
350+
PTP_PIN_TOD_SEC_LSB,
351+
PTP_PIN_TOD_NSEC,
352+
PTP_CFG_MISC,
353+
PTP_CLK_CFG_ADJ_CFG,
354+
PTP_CLK_CFG_ADJ_FREQ,
346355
};
347356

348357
enum ocelot_regfield {

drivers/net/ethernet/mscc/ocelot_board.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,15 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
182182
struct {
183183
enum ocelot_target id;
184184
char *name;
185+
u8 optional:1;
185186
} res[] = {
186187
{ SYS, "sys" },
187188
{ REW, "rew" },
188189
{ QSYS, "qsys" },
189190
{ ANA, "ana" },
190191
{ QS, "qs" },
191192
{ S2, "s2" },
193+
{ PTP, "ptp", 1 },
192194
};
193195

194196
if (!np && !pdev->dev.platform_data)
@@ -205,8 +207,14 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
205207
struct regmap *target;
206208

207209
target = ocelot_io_platform_init(ocelot, pdev, res[i].name);
208-
if (IS_ERR(target))
210+
if (IS_ERR(target)) {
211+
if (res[i].optional) {
212+
ocelot->targets[res[i].id] = NULL;
213+
continue;
214+
}
215+
209216
return PTR_ERR(target);
217+
}
210218

211219
ocelot->targets[res[i].id] = target;
212220
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2+
/*
3+
* Microsemi Ocelot Switch driver
4+
*
5+
* License: Dual MIT/GPL
6+
* Copyright (c) 2017 Microsemi Corporation
7+
*/
8+
9+
#ifndef _MSCC_OCELOT_PTP_H_
10+
#define _MSCC_OCELOT_PTP_H_
11+
12+
#define PTP_PIN_CFG_RSZ 0x20
13+
#define PTP_PIN_TOD_SEC_MSB_RSZ PTP_PIN_CFG_RSZ
14+
#define PTP_PIN_TOD_SEC_LSB_RSZ PTP_PIN_CFG_RSZ
15+
#define PTP_PIN_TOD_NSEC_RSZ PTP_PIN_CFG_RSZ
16+
17+
#define PTP_PIN_CFG_DOM BIT(0)
18+
#define PTP_PIN_CFG_SYNC BIT(2)
19+
#define PTP_PIN_CFG_ACTION(x) ((x) << 3)
20+
#define PTP_PIN_CFG_ACTION_MASK PTP_PIN_CFG_ACTION(0x7)
21+
22+
enum {
23+
PTP_PIN_ACTION_IDLE = 0,
24+
PTP_PIN_ACTION_LOAD,
25+
PTP_PIN_ACTION_SAVE,
26+
PTP_PIN_ACTION_CLOCK,
27+
PTP_PIN_ACTION_DELTA,
28+
PTP_PIN_ACTION_NOSYNC,
29+
PTP_PIN_ACTION_SYNC,
30+
};
31+
32+
#define PTP_CFG_MISC_PTP_EN BIT(2)
33+
34+
#define PSEC_PER_SEC 1000000000000LL
35+
36+
#define PTP_CFG_CLK_ADJ_CFG_ENA BIT(0)
37+
#define PTP_CFG_CLK_ADJ_CFG_DIR BIT(1)
38+
39+
#define PTP_CFG_CLK_ADJ_FREQ_NS BIT(30)
40+
41+
#endif

drivers/net/ethernet/mscc/ocelot_regs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,24 @@ static const u32 ocelot_s2_regmap[] = {
234234
REG(S2_CACHE_TG_DAT, 0x000388),
235235
};
236236

237+
static const u32 ocelot_ptp_regmap[] = {
238+
REG(PTP_PIN_CFG, 0x000000),
239+
REG(PTP_PIN_TOD_SEC_MSB, 0x000004),
240+
REG(PTP_PIN_TOD_SEC_LSB, 0x000008),
241+
REG(PTP_PIN_TOD_NSEC, 0x00000c),
242+
REG(PTP_CFG_MISC, 0x0000a0),
243+
REG(PTP_CLK_CFG_ADJ_CFG, 0x0000a4),
244+
REG(PTP_CLK_CFG_ADJ_FREQ, 0x0000a8),
245+
};
246+
237247
static const u32 *ocelot_regmap[] = {
238248
[ANA] = ocelot_ana_regmap,
239249
[QS] = ocelot_qs_regmap,
240250
[QSYS] = ocelot_qsys_regmap,
241251
[REW] = ocelot_rew_regmap,
242252
[SYS] = ocelot_sys_regmap,
243253
[S2] = ocelot_s2_regmap,
254+
[PTP] = ocelot_ptp_regmap,
244255
};
245256

246257
static const struct reg_field ocelot_regfields[] = {

0 commit comments

Comments
 (0)