From: Jonathan Lemon <jonathan.lemon@gmail.com>
To: netdev@vger.kernel.org
Cc: richardcochran@gmail.com, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, edumazet@google.com, kernel-team@fb.com
Subject: [PATCH net-next v3 03/10] ptp: ocp: revise firmware display
Date: Fri, 13 May 2022 15:59:17 -0700 [thread overview]
Message-ID: <20220513225924.1655-4-jonathan.lemon@gmail.com> (raw)
In-Reply-To: <20220513225924.1655-1-jonathan.lemon@gmail.com>
Preparse the firmware image information into loader/tag/version,
and set the fw capabilities based on the tag/version.
Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
---
drivers/ptp/ptp_ocp.c | 64 +++++++++++++++++++++++++++----------------
1 file changed, 41 insertions(+), 23 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index d8d80138c629..aae1d9b0fb89 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -318,7 +318,9 @@ struct ptp_ocp {
int gnss2_port;
int mac_port; /* miniature atomic clock */
int nmea_port;
- u32 fw_version;
+ bool fw_loader;
+ u8 fw_tag;
+ u16 fw_version;
u8 board_id[OCP_BOARD_ID_LEN];
u8 serial[OCP_SERIAL_LEN];
bool has_eeprom_data;
@@ -1369,6 +1371,7 @@ ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
struct netlink_ext_ack *extack)
{
struct ptp_ocp *bp = devlink_priv(devlink);
+ const char *fw_image;
char buf[32];
int err;
@@ -1376,13 +1379,9 @@ ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
if (err)
return err;
- if (bp->fw_version & 0xffff) {
- sprintf(buf, "%d", bp->fw_version);
- err = devlink_info_version_running_put(req, "fw", buf);
- } else {
- sprintf(buf, "%d", bp->fw_version >> 16);
- err = devlink_info_version_running_put(req, "loader", buf);
- }
+ fw_image = bp->fw_loader ? "loader" : "fw";
+ sprintf(buf, "%d.%d", bp->fw_tag, bp->fw_version);
+ err = devlink_info_version_running_put(req, fw_image, buf);
if (err)
return err;
@@ -1905,23 +1904,50 @@ ptp_ocp_fb_set_pins(struct ptp_ocp *bp)
return 0;
}
+static void
+ptp_ocp_fb_set_version(struct ptp_ocp *bp)
+{
+ u64 cap = OCP_CAP_BASIC;
+ u32 version;
+
+ version = ioread32(&bp->image->version);
+
+ /* if lower 16 bits are empty, this is the fw loader. */
+ if ((version & 0xffff) == 0) {
+ version = version >> 16;
+ bp->fw_loader = true;
+ }
+
+ bp->fw_tag = version >> 15;
+ bp->fw_version = version & 0x7fff;
+
+ if (bp->fw_tag) {
+ /* FPGA firmware */
+ if (version >= 5)
+ cap |= OCP_CAP_SIGNAL | OCP_CAP_FREQ;
+ } else {
+ /* SOM firmware */
+ if (version >= 19)
+ cap |= OCP_CAP_SIGNAL;
+ if (version >= 20)
+ cap |= OCP_CAP_FREQ;
+ }
+
+ bp->fw_cap = cap;
+}
+
/* FB specific board initializers; last "resource" registered. */
static int
ptp_ocp_fb_board_init(struct ptp_ocp *bp, struct ocp_resource *r)
{
- int ver, err;
+ int err;
bp->flash_start = 1024 * 4096;
bp->eeprom_map = fb_eeprom_map;
bp->fw_version = ioread32(&bp->image->version);
bp->attr_tbl = fb_timecard_groups;
- bp->fw_cap = OCP_CAP_BASIC;
- ver = bp->fw_version & 0xffff;
- if (ver >= 19)
- bp->fw_cap |= OCP_CAP_SIGNAL;
- if (ver >= 20)
- bp->fw_cap |= OCP_CAP_FREQ;
+ ptp_ocp_fb_set_version(bp);
ptp_ocp_tod_init(bp);
ptp_ocp_nmea_out_init(bp);
@@ -3477,14 +3503,6 @@ ptp_ocp_info(struct ptp_ocp *bp)
ptp_ocp_phc_info(bp);
- dev_info(dev, "version %x\n", bp->fw_version);
- if (bp->fw_version & 0xffff)
- dev_info(dev, "regular image, version %d\n",
- bp->fw_version & 0xffff);
- else
- dev_info(dev, "golden image, version %d\n",
- bp->fw_version >> 16);
-
ptp_ocp_serial_info(dev, "GNSS", bp->gnss_port, 115200);
ptp_ocp_serial_info(dev, "GNSS2", bp->gnss2_port, 115200);
ptp_ocp_serial_info(dev, "MAC", bp->mac_port, 57600);
--
2.31.1
next prev parent reply other threads:[~2022-05-13 22:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 22:59 [PATCH net-next v3 00/10] ptp: ocp: various updates Jonathan Lemon
2022-05-13 22:59 ` [PATCH net-next v3 01/10] ptp: ocp: 32-bit fixups for pci start address Jonathan Lemon
2022-05-13 22:59 ` [PATCH net-next v3 02/10] ptp: ocp: add Celestica timecard PCI ids Jonathan Lemon
2022-05-17 0:43 ` Jakub Kicinski
2022-05-17 1:46 ` Jonathan Lemon
2022-05-17 15:25 ` Jakub Kicinski
2022-05-17 15:45 ` Jonathan Lemon
2022-05-13 22:59 ` Jonathan Lemon [this message]
2022-05-13 22:59 ` [PATCH net-next v3 04/10] ptp: ocp: parameterize input/output sma selectors Jonathan Lemon
2022-05-13 22:59 ` [PATCH net-next v3 05/10] ptp: ocp: constify selectors Jonathan Lemon
2022-05-13 22:59 ` [PATCH net-next v3 06/10] ptp: ocp: vectorize the sma accessor functions Jonathan Lemon
2022-05-13 22:59 ` [PATCH net-next v3 07/10] ptp: ocp: add .init function for sma_op vector Jonathan Lemon
2022-05-13 22:59 ` [PATCH net-next v3 08/10] ptp: ocp: fix PPS source selector reporting Jonathan Lemon
2022-05-17 0:43 ` Jakub Kicinski
2022-05-17 1:54 ` Jonathan Lemon
2022-05-17 15:32 ` Jakub Kicinski
2022-05-17 15:39 ` Jonathan Lemon
2022-05-17 16:19 ` Jakub Kicinski
2022-05-13 22:59 ` [PATCH net-next v3 09/10] ptp: ocp: Add firmware header checks Jonathan Lemon
2022-05-13 22:59 ` [PATCH net-next v3 10/10] ptp: ocp: change sysfs attr group handling Jonathan Lemon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220513225924.1655-4-jonathan.lemon@gmail.com \
--to=jonathan.lemon@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel-team@fb.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).