[PATCH net-next 3/3] ptp: clockmatrix: Rework clockmatrix version information.

From: vincent . cheng . xh
Date: Tue Dec 17 2019 - 00:12:32 EST


From: Vincent Cheng <vincent.cheng.xh@xxxxxxxxxxx>

Remove pipeline id, bond id, csr id, and irq id.
Changes source register for reading HW rev id.
Add OTP config select.

Signed-off-by: Vincent Cheng <vincent.cheng.xh@xxxxxxxxxxx>
---
drivers/ptp/ptp_clockmatrix.c | 63 ++++++++-----------------------------------
1 file changed, 11 insertions(+), 52 deletions(-)

diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
index 66e3266..4ba5ea48 100644
--- a/drivers/ptp/ptp_clockmatrix.c
+++ b/drivers/ptp/ptp_clockmatrix.c
@@ -597,36 +597,7 @@ static int cm_state_machine_reset(struct cm *cm)

static int cm_read_hw_rev_id(struct cm *cm, u8 *hw_rev_id)
{
- return cm_read(cm, GENERAL_STATUS, HW_REV_ID, hw_rev_id, sizeof(u8));
-}
-
-static int cm_read_bond_id(struct cm *cm, u8 *bond_id)
-{
- return cm_read(cm, GENERAL_STATUS, BOND_ID, bond_id, sizeof(u8));
-}
-
-static int cm_read_hw_csr_id(struct cm *cm, u16 *hw_csr_id)
-{
- int err;
- u8 buf[2] = {0};
-
- err = cm_read(cm, GENERAL_STATUS, HW_CSR_ID, buf, sizeof(buf));
-
- *hw_csr_id = (buf[1] << 8) | buf[0];
-
- return err;
-}
-
-static int cm_read_hw_irq_id(struct cm *cm, u16 *hw_irq_id)
-{
- int err;
- u8 buf[2] = {0};
-
- err = cm_read(cm, GENERAL_STATUS, HW_IRQ_ID, buf, sizeof(buf));
-
- *hw_irq_id = (buf[1] << 8) | buf[0];
-
- return err;
+ return cm_read(cm, HW_REVISION, REV_ID, hw_rev_id, sizeof(u8));
}

static int cm_read_product_id(struct cm *cm, u16 *product_id)
@@ -663,16 +634,10 @@ static int cm_read_hotfix_release(struct cm *cm, u8 *hotfix)
return cm_read(cm, GENERAL_STATUS, HOTFIX_REL, hotfix, sizeof(u8));
}

-static int cm_read_pipeline(struct cm *cm, u32 *pipeline)
+static int cm_read_otp_scsr_config_select(struct cm *cm, u8 *config_select)
{
- int err;
- u8 buf[4] = {0};
-
- err = cm_read(cm, GENERAL_STATUS, PIPELINE_ID, &buf[0], sizeof(buf));
-
- *pipeline = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
-
- return err;
+ return cm_read(cm, GENERAL_STATUS, OTP_SCSR_CONFIG_SELECT,
+ config_select, sizeof(u8));
}

static int process_pll_mask(struct cm *cm, u32 addr, u8 val, u8 *mask)
@@ -1062,28 +1027,22 @@ static void cm_display_version_info(struct cm *cm)
u8 major;
u8 minor;
u8 hotfix;
- u32 pipeline;
u16 product_id;
- u16 csr_id;
- u16 irq_id;
u8 hw_rev_id;
- u8 bond_id;
+ u8 config_select;
+ char *fmt = "%d.%d.%d, Id: 0x%04x HW Rev: %d OTP Config Select: %d\n";

cm_read_major_release(cm, &major);
cm_read_minor_release(cm, &minor);
cm_read_hotfix_release(cm, &hotfix);
- cm_read_pipeline(cm, &pipeline);

cm_read_product_id(cm, &product_id);
cm_read_hw_rev_id(cm, &hw_rev_id);
- cm_read_bond_id(cm, &bond_id);
- cm_read_hw_csr_id(cm, &csr_id);
- cm_read_hw_irq_id(cm, &irq_id);
-
- dev_info(&cm->client->dev, "Version: %d.%d.%d, Pipeline %u\t"
- "0x%04x, Rev %d, Bond %d, CSR %d, IRQ %d\n",
- major, minor, hotfix, pipeline,
- product_id, hw_rev_id, bond_id, csr_id, irq_id);
+
+ cm_read_otp_scsr_config_select(cm, &config_select);
+
+ dev_info(&cm->client->dev, fmt, major, minor, hotfix, product_id,
+ hw_rev_id, config_select);
}

static struct ptp_clock_info cm_caps = {
--
2.7.4