Skip to content

Commit

Permalink
Enable A2h access for optoe2 even when DDM is unsupported (sonic-net#246
Browse files Browse the repository at this point in the history
)

Enable 0x51 (A2h) access for optoe2 even when DDM is unsupported, for
accessing vendor specific fields. Some SFP optics that do not support DDM
can have vendor specific implementation via 0x51 in A2h register space
(eg. Mailbox Registers).

Removed the DDM support check for optoe2 (TWO_ADDR) and now its EEPROM
size is 512 bytes minimum. Return error when accessing beyond 256 bytes
for optics that do not support I2C address 0x51.
  • Loading branch information
Jemston Fernando authored Dec 3, 2021
1 parent 6aa8d00 commit 292b353
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
70 changes: 70 additions & 0 deletions patch/driver-support-optoe-twoaddr-a2h-access.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From 23a58d78c8c12b0092e1dfded96e6d648bffe1de Mon Sep 17 00:00:00 2001
From: Jemston Fernando <[email protected]>
Date: Thu, 25 Nov 2021 04:30:04 -0800
Subject: [PATCH] A2h access for optoe2 even when DDM is unsupported

Enable 0x51 (A2h) access for optoe2 even when DDM is unsupported, for
accessing vendor specific fields. Some SFP optics that do not support DDM
can have vendor specific implementation via 0x51 in A2h register space
(eg. Mailbox Registers).

Removed the DDM support check for optoe2 (TWO_ADDR) and now its EEPROM
size is 512 bytes minimum. Return error when accessing beyond 256 bytes
for optics that do not support I2C address 0x51.

Signed-off-by: Jemston Fernando <[email protected]>
---
drivers/misc/eeprom/optoe.c | 23 +++--------------------
1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c
index a7554e9..6229439 100644
--- a/drivers/misc/eeprom/optoe.c
+++ b/drivers/misc/eeprom/optoe.c
@@ -174,8 +174,6 @@ struct optoe_platform_data {
#define CMIS_NOT_PAGEABLE (1<<7)
#define TWO_ADDR_PAGEABLE_REG 0x40
#define TWO_ADDR_PAGEABLE (1<<4)
-#define TWO_ADDR_0X51_REG 92
-#define TWO_ADDR_0X51_SUPP (1<<6)
#define OPTOE_ID_REG 0
#define OPTOE_READ_OP 0
#define OPTOE_WRITE_OP 1
@@ -593,8 +591,8 @@ static ssize_t optoe_page_legal(struct optoe_data *optoe,
return -EINVAL;
if (optoe->dev_class == TWO_ADDR) {
/* SFP case */
- /* if only using addr 0x50 (first 256 bytes) we're good */
- if ((off + len) <= TWO_ADDR_NO_0X51_SIZE)
+ /* if access is within addr 0x50 or first page of 0x51 (first 512 bytes) we're good */
+ if ((off + len) <= TWO_ADDR_EEPROM_UNPAGED_SIZE)
return len;
/* if offset exceeds possible pages, we're not good */
if (off >= TWO_ADDR_EEPROM_SIZE)
@@ -611,22 +609,7 @@ static ssize_t optoe_page_legal(struct optoe_data *optoe,
/* pages not supported, trim len to unpaged size */
if (off >= TWO_ADDR_EEPROM_UNPAGED_SIZE)
return OPTOE_EOF;
-
- /* will be accessing addr 0x51, is that supported? */
- /* byte 92, bit 6 implies DDM support, 0x51 support */
- status = optoe_eeprom_read(optoe, client, &regval,
- TWO_ADDR_0X51_REG, 1);
- if (status < 0)
- return status;
- if (regval & TWO_ADDR_0X51_SUPP) {
- /* addr 0x51 is OK */
- maxlen = TWO_ADDR_EEPROM_UNPAGED_SIZE - off;
- } else {
- /* addr 0x51 NOT supported, trim to 256 max */
- if (off >= TWO_ADDR_NO_0X51_SIZE)
- return OPTOE_EOF;
- maxlen = TWO_ADDR_NO_0X51_SIZE - off;
- }
+ maxlen = TWO_ADDR_EEPROM_UNPAGED_SIZE - off;
}
len = (len > maxlen) ? maxlen : len;
dev_dbg(&client->dev,
--
2.7.4

1 change: 1 addition & 0 deletions patch/series
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ driver-support-optoe-EOF_fix.patch
driver-support-optoe-chunk-offset-fix.patch
driver-support-optoe-QSFP_DD.patch
driver-support-optoe-write-max.patch
driver-support-optoe-twoaddr-a2h-access.patch
driver-net-tg3-add-param-short-preamble-and-reset.patch
0004-dt-bindings-hwmon-Add-missing-documentation-for-lm75.patch
0005-dt-bindings-hwmon-Add-tmp75b-to-lm75.txt.patch
Expand Down

0 comments on commit 292b353

Please sign in to comment.