Commit da948233 authored by Min Li's avatar Min Li Committed by Jakub Kicinski

ptp: clockmatrix: deprecate firmware older than 4.8.7

Add deprecated flag to indicate < v4.8.7.
Fix idtcm_enable_tod() call correct settime().
Signed-off-by: default avatarMin Li <min.li.xe@renesas.com>
Link: https://lore.kernel.org/r/1607442117-13661-4-git-send-email-min.li.xe@renesas.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7260d1c8
...@@ -806,7 +806,7 @@ static int get_output_base_addr(u8 outn) ...@@ -806,7 +806,7 @@ static int get_output_base_addr(u8 outn)
return base; return base;
} }
static int _idtcm_settime(struct idtcm_channel *channel, static int _idtcm_settime_deprecated(struct idtcm_channel *channel,
struct timespec64 const *ts) struct timespec64 const *ts)
{ {
struct idtcm *idtcm = channel->idtcm; struct idtcm *idtcm = channel->idtcm;
...@@ -823,7 +823,7 @@ static int _idtcm_settime(struct idtcm_channel *channel, ...@@ -823,7 +823,7 @@ static int _idtcm_settime(struct idtcm_channel *channel,
return idtcm_sync_pps_output(channel); return idtcm_sync_pps_output(channel);
} }
static int _idtcm_settime_v487(struct idtcm_channel *channel, static int _idtcm_settime(struct idtcm_channel *channel,
struct timespec64 const *ts, struct timespec64 const *ts,
enum scsr_tod_write_type_sel wr_type) enum scsr_tod_write_type_sel wr_type)
{ {
...@@ -967,14 +967,14 @@ static int set_tod_write_overhead(struct idtcm_channel *channel) ...@@ -967,14 +967,14 @@ static int set_tod_write_overhead(struct idtcm_channel *channel)
return err; return err;
} }
static int _idtcm_adjtime(struct idtcm_channel *channel, s64 delta) static int _idtcm_adjtime_deprecated(struct idtcm_channel *channel, s64 delta)
{ {
int err; int err;
struct idtcm *idtcm = channel->idtcm; struct idtcm *idtcm = channel->idtcm;
struct timespec64 ts; struct timespec64 ts;
s64 now; s64 now;
if (abs(delta) < PHASE_PULL_IN_THRESHOLD_NS) { if (abs(delta) < PHASE_PULL_IN_THRESHOLD_NS_DEPRECATED) {
err = idtcm_do_phase_pull_in(channel, delta, 0); err = idtcm_do_phase_pull_in(channel, delta, 0);
} else { } else {
idtcm->calculate_overhead_flag = 1; idtcm->calculate_overhead_flag = 1;
...@@ -994,7 +994,7 @@ static int _idtcm_adjtime(struct idtcm_channel *channel, s64 delta) ...@@ -994,7 +994,7 @@ static int _idtcm_adjtime(struct idtcm_channel *channel, s64 delta)
ts = ns_to_timespec64(now); ts = ns_to_timespec64(now);
err = _idtcm_settime(channel, &ts); err = _idtcm_settime_deprecated(channel, &ts);
} }
return err; return err;
...@@ -1498,7 +1498,7 @@ static int idtcm_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) ...@@ -1498,7 +1498,7 @@ static int idtcm_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
return err; return err;
} }
static int idtcm_settime(struct ptp_clock_info *ptp, static int idtcm_settime_deprecated(struct ptp_clock_info *ptp,
const struct timespec64 *ts) const struct timespec64 *ts)
{ {
struct idtcm_channel *channel = struct idtcm_channel *channel =
...@@ -1508,7 +1508,7 @@ static int idtcm_settime(struct ptp_clock_info *ptp, ...@@ -1508,7 +1508,7 @@ static int idtcm_settime(struct ptp_clock_info *ptp,
mutex_lock(&idtcm->reg_lock); mutex_lock(&idtcm->reg_lock);
err = _idtcm_settime(channel, ts); err = _idtcm_settime_deprecated(channel, ts);
if (err) if (err)
dev_err(&idtcm->client->dev, dev_err(&idtcm->client->dev,
...@@ -1521,7 +1521,7 @@ static int idtcm_settime(struct ptp_clock_info *ptp, ...@@ -1521,7 +1521,7 @@ static int idtcm_settime(struct ptp_clock_info *ptp,
return err; return err;
} }
static int idtcm_settime_v487(struct ptp_clock_info *ptp, static int idtcm_settime(struct ptp_clock_info *ptp,
const struct timespec64 *ts) const struct timespec64 *ts)
{ {
struct idtcm_channel *channel = struct idtcm_channel *channel =
...@@ -1531,7 +1531,7 @@ static int idtcm_settime_v487(struct ptp_clock_info *ptp, ...@@ -1531,7 +1531,7 @@ static int idtcm_settime_v487(struct ptp_clock_info *ptp,
mutex_lock(&idtcm->reg_lock); mutex_lock(&idtcm->reg_lock);
err = _idtcm_settime_v487(channel, ts, SCSR_TOD_WR_TYPE_SEL_ABSOLUTE); err = _idtcm_settime(channel, ts, SCSR_TOD_WR_TYPE_SEL_ABSOLUTE);
if (err) if (err)
dev_err(&idtcm->client->dev, dev_err(&idtcm->client->dev,
...@@ -1544,7 +1544,7 @@ static int idtcm_settime_v487(struct ptp_clock_info *ptp, ...@@ -1544,7 +1544,7 @@ static int idtcm_settime_v487(struct ptp_clock_info *ptp,
return err; return err;
} }
static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta) static int idtcm_adjtime_deprecated(struct ptp_clock_info *ptp, s64 delta)
{ {
struct idtcm_channel *channel = struct idtcm_channel *channel =
container_of(ptp, struct idtcm_channel, caps); container_of(ptp, struct idtcm_channel, caps);
...@@ -1553,7 +1553,7 @@ static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta) ...@@ -1553,7 +1553,7 @@ static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta)
mutex_lock(&idtcm->reg_lock); mutex_lock(&idtcm->reg_lock);
err = _idtcm_adjtime(channel, delta); err = _idtcm_adjtime_deprecated(channel, delta);
if (err) if (err)
dev_err(&idtcm->client->dev, dev_err(&idtcm->client->dev,
...@@ -1566,7 +1566,7 @@ static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta) ...@@ -1566,7 +1566,7 @@ static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta)
return err; return err;
} }
static int idtcm_adjtime_v487(struct ptp_clock_info *ptp, s64 delta) static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta)
{ {
struct idtcm_channel *channel = struct idtcm_channel *channel =
container_of(ptp, struct idtcm_channel, caps); container_of(ptp, struct idtcm_channel, caps);
...@@ -1575,7 +1575,7 @@ static int idtcm_adjtime_v487(struct ptp_clock_info *ptp, s64 delta) ...@@ -1575,7 +1575,7 @@ static int idtcm_adjtime_v487(struct ptp_clock_info *ptp, s64 delta)
enum scsr_tod_write_type_sel type; enum scsr_tod_write_type_sel type;
int err; int err;
if (abs(delta) < PHASE_PULL_IN_THRESHOLD_NS_V487) { if (abs(delta) < PHASE_PULL_IN_THRESHOLD_NS) {
err = idtcm_do_phase_pull_in(channel, delta, 0); err = idtcm_do_phase_pull_in(channel, delta, 0);
if (err) if (err)
dev_err(&idtcm->client->dev, dev_err(&idtcm->client->dev,
...@@ -1595,7 +1595,7 @@ static int idtcm_adjtime_v487(struct ptp_clock_info *ptp, s64 delta) ...@@ -1595,7 +1595,7 @@ static int idtcm_adjtime_v487(struct ptp_clock_info *ptp, s64 delta)
mutex_lock(&idtcm->reg_lock); mutex_lock(&idtcm->reg_lock);
err = _idtcm_settime_v487(channel, &ts, type); err = _idtcm_settime(channel, &ts, type);
if (err) if (err)
dev_err(&idtcm->client->dev, dev_err(&idtcm->client->dev,
...@@ -1939,10 +1939,14 @@ static int idtcm_enable_tod(struct idtcm_channel *channel) ...@@ -1939,10 +1939,14 @@ static int idtcm_enable_tod(struct idtcm_channel *channel)
if (err) if (err)
return err; return err;
return _idtcm_settime(channel, &ts); if (idtcm->deprecated)
return _idtcm_settime_deprecated(channel, &ts);
else
return _idtcm_settime(channel, &ts,
SCSR_TOD_WR_TYPE_SEL_ABSOLUTE);
} }
static void idtcm_display_version_info(struct idtcm *idtcm) static void idtcm_set_version_info(struct idtcm *idtcm)
{ {
u8 major; u8 major;
u8 minor; u8 minor;
...@@ -1964,31 +1968,36 @@ static void idtcm_display_version_info(struct idtcm *idtcm) ...@@ -1964,31 +1968,36 @@ static void idtcm_display_version_info(struct idtcm *idtcm)
snprintf(idtcm->version, sizeof(idtcm->version), "%u.%u.%u", snprintf(idtcm->version, sizeof(idtcm->version), "%u.%u.%u",
major, minor, hotfix); major, minor, hotfix);
if (idtcm_strverscmp(idtcm->version, "4.8.7") >= 0)
idtcm->deprecated = 0;
else
idtcm->deprecated = 1;
dev_info(&idtcm->client->dev, fmt, major, minor, hotfix, dev_info(&idtcm->client->dev, fmt, major, minor, hotfix,
product_id, hw_rev_id, config_select); product_id, hw_rev_id, config_select);
} }
static const struct ptp_clock_info idtcm_caps_v487 = { static const struct ptp_clock_info idtcm_caps = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.max_adj = 244000, .max_adj = 244000,
.n_per_out = 12, .n_per_out = 12,
.adjphase = &idtcm_adjphase, .adjphase = &idtcm_adjphase,
.adjfine = &idtcm_adjfine, .adjfine = &idtcm_adjfine,
.adjtime = &idtcm_adjtime_v487, .adjtime = &idtcm_adjtime,
.gettime64 = &idtcm_gettime, .gettime64 = &idtcm_gettime,
.settime64 = &idtcm_settime_v487, .settime64 = &idtcm_settime,
.enable = &idtcm_enable, .enable = &idtcm_enable,
}; };
static const struct ptp_clock_info idtcm_caps = { static const struct ptp_clock_info idtcm_caps_deprecated = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.max_adj = 244000, .max_adj = 244000,
.n_per_out = 12, .n_per_out = 12,
.adjphase = &idtcm_adjphase, .adjphase = &idtcm_adjphase,
.adjfine = &idtcm_adjfine, .adjfine = &idtcm_adjfine,
.adjtime = &idtcm_adjtime, .adjtime = &idtcm_adjtime_deprecated,
.gettime64 = &idtcm_gettime, .gettime64 = &idtcm_gettime,
.settime64 = &idtcm_settime, .settime64 = &idtcm_settime_deprecated,
.enable = &idtcm_enable, .enable = &idtcm_enable,
}; };
...@@ -2111,15 +2120,15 @@ static int idtcm_enable_channel(struct idtcm *idtcm, u32 index) ...@@ -2111,15 +2120,15 @@ static int idtcm_enable_channel(struct idtcm *idtcm, u32 index)
channel->idtcm = idtcm; channel->idtcm = idtcm;
if (idtcm_strverscmp(idtcm->version, "4.8.7") >= 0) if (idtcm->deprecated)
channel->caps = idtcm_caps_v487; channel->caps = idtcm_caps_deprecated;
else else
channel->caps = idtcm_caps; channel->caps = idtcm_caps;
snprintf(channel->caps.name, sizeof(channel->caps.name), snprintf(channel->caps.name, sizeof(channel->caps.name),
"IDT CM TOD%u", index); "IDT CM TOD%u", index);
if (idtcm_strverscmp(idtcm->version, "4.8.7") >= 0) { if (!idtcm->deprecated) {
err = idtcm_enable_tod_sync(channel); err = idtcm_enable_tod_sync(channel);
if (err) { if (err) {
dev_err(&idtcm->client->dev, dev_err(&idtcm->client->dev,
...@@ -2218,7 +2227,7 @@ static int idtcm_probe(struct i2c_client *client, ...@@ -2218,7 +2227,7 @@ static int idtcm_probe(struct i2c_client *client,
mutex_init(&idtcm->reg_lock); mutex_init(&idtcm->reg_lock);
mutex_lock(&idtcm->reg_lock); mutex_lock(&idtcm->reg_lock);
idtcm_display_version_info(idtcm); idtcm_set_version_info(idtcm);
err = idtcm_load_firmware(idtcm, &client->dev); err = idtcm_load_firmware(idtcm, &client->dev);
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
#define DEFAULT_TOD3_PTP_PLL (3) #define DEFAULT_TOD3_PTP_PLL (3)
#define POST_SM_RESET_DELAY_MS (3000) #define POST_SM_RESET_DELAY_MS (3000)
#define PHASE_PULL_IN_THRESHOLD_NS (150000) #define PHASE_PULL_IN_THRESHOLD_NS_DEPRECATED (150000)
#define PHASE_PULL_IN_THRESHOLD_NS_V487 (15000) #define PHASE_PULL_IN_THRESHOLD_NS (15000)
#define TOD_WRITE_OVERHEAD_COUNT_MAX (2) #define TOD_WRITE_OVERHEAD_COUNT_MAX (2)
#define TOD_BYTE_COUNT (11) #define TOD_BYTE_COUNT (11)
...@@ -132,6 +132,7 @@ struct idtcm { ...@@ -132,6 +132,7 @@ struct idtcm {
u8 page_offset; u8 page_offset;
u8 tod_mask; u8 tod_mask;
char version[16]; char version[16];
u8 deprecated;
/* Overhead calculation for adjtime */ /* Overhead calculation for adjtime */
u8 calculate_overhead_flag; u8 calculate_overhead_flag;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment