Skip to content

Commit

Permalink
hw/npu2, platform: Restructure OpenCAPI i2c reset/presence pins
Browse files Browse the repository at this point in the history
In platform_ocapi, we define i2c_{reset,presence}_odl{0,1} to specify the
appropriate reset/presence GPIO pins for devices connected to ODL0 and ODL1
respectively.

This is obviously wrong, because a device connected to brick 2 and a device
connected to brick 4 are going to be different devices connected to
different I2C pins, but rather conveniently we haven't had to deal with
systems that can use the full 4 bricks as yet. Now that we're adding
OpenCAPI support for Witherspoon, we should change this to specify pins
separately for all 4 bricks.

Replace i2c_{reset,presence}_odl{0,1} with
i2c_{reset,presence}_brick{2,3,4,5} and update the presence detection code,
device reset code, and existing platforms accordingly.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Reviewed-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
ajdlinux authored and stewartsmith committed Sep 18, 2018
1 parent b6cc82c commit 6a728af
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 38 deletions.
24 changes: 14 additions & 10 deletions core/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,25 @@ static int generic_start_preload_resource(enum resource_id id, uint32_t subid,

/* These values will work for a ZZ booted using BML */
const struct platform_ocapi generic_ocapi = {
.i2c_engine = 1,
.i2c_port = 4,
.i2c_reset_addr = 0x20,
.i2c_reset_odl0 = (1 << 1),
.i2c_reset_odl1 = (1 << 6),
.i2c_presence_addr = 0x20,
.i2c_presence_odl0 = (1 << 2), /* bottom connector */
.i2c_presence_odl1 = (1 << 7), /* top connector */
.i2c_engine = 1,
.i2c_port = 4,
.i2c_reset_addr = 0x20,
.i2c_reset_brick2 = (1 << 1),
.i2c_reset_brick3 = (1 << 6),
.i2c_reset_brick4 = 0, /* unused */
.i2c_reset_brick5 = 0, /* unused */
.i2c_presence_addr = 0x20,
.i2c_presence_brick2 = (1 << 2), /* bottom connector */
.i2c_presence_brick3 = (1 << 7), /* top connector */
.i2c_presence_brick4 = 0, /* unused */
.i2c_presence_brick5 = 0, /* unused */
/*
* The ZZs we typically use for BML/generic platform tend to
* have old planars and presence detection is broken there, so
* force presence.
*/
.force_presence = true,
.odl_phy_swap = true,
.force_presence = true,
.odl_phy_swap = true,
};

static struct bmc_platform generic_bmc = {
Expand Down
10 changes: 8 additions & 2 deletions hw/npu2-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,16 @@ static bool _i2c_presence_detect(struct npu2_dev *dev)

switch (dev->link_index) {
case 2:
data = platform.ocapi->i2c_presence_odl0;
data = platform.ocapi->i2c_presence_brick2;
break;
case 3:
data = platform.ocapi->i2c_presence_odl1;
data = platform.ocapi->i2c_presence_brick3;
break;
case 4:
data = platform.ocapi->i2c_presence_brick4;
break;
case 5:
data = platform.ocapi->i2c_presence_brick5;
break;
default:
OCAPIERR(dev, "presence detection on invalid link\n");
Expand Down
10 changes: 7 additions & 3 deletions hw/npu2-opencapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,12 +816,16 @@ static void assert_reset(struct npu2_dev *dev)

switch (dev->brick_index) {
case 2:
case 4:
pin = platform.ocapi->i2c_reset_odl0;
pin = platform.ocapi->i2c_reset_brick2;
break;
case 3:
pin = platform.ocapi->i2c_reset_brick3;
break;
case 4:
pin = platform.ocapi->i2c_reset_brick4;
break;
case 5:
pin = platform.ocapi->i2c_reset_odl1;
pin = platform.ocapi->i2c_reset_brick5;
break;
default:
assert(false);
Expand Down
12 changes: 8 additions & 4 deletions include/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ struct platform_ocapi {
uint8_t i2c_engine; /* I2C engine number */
uint8_t i2c_port; /* I2C port number */
uint8_t i2c_reset_addr; /* I2C address for reset */
uint8_t i2c_reset_odl0; /* I2C pin to write to reset ODL0 */
uint8_t i2c_reset_odl1; /* I2C pin to write to reset ODL1 */
uint8_t i2c_reset_brick2; /* I2C pin to write to reset brick 2 */
uint8_t i2c_reset_brick3; /* I2C pin to write to reset brick 3 */
uint8_t i2c_reset_brick4; /* I2C pin to write to reset brick 4 */
uint8_t i2c_reset_brick5; /* I2C pin to write to reset brick 5 */
uint8_t i2c_presence_addr; /* I2C address for presence detection */
uint8_t i2c_presence_odl0; /* I2C mask for detection on ODL0 */
uint8_t i2c_presence_odl1; /* I2C mask for detection on ODL1 */
uint8_t i2c_presence_brick2; /* I2C pin to read for presence on brick 2 */
uint8_t i2c_presence_brick3; /* I2C pin to read for presence on brick 3 */
uint8_t i2c_presence_brick4; /* I2C pin to read for presence on brick 4 */
uint8_t i2c_presence_brick5; /* I2C pin to read for presence on brick 5 */
bool force_presence; /* don't use i2c detection */
bool odl_phy_swap; /* Swap ODL1 to use brick 2 rather than
* brick 1 lanes */
Expand Down
22 changes: 13 additions & 9 deletions platforms/astbmc/zaius.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,19 @@ static void zaius_get_slot_info(struct phb *phb, struct pci_device *pd)
}

const struct platform_ocapi zaius_ocapi = {
.i2c_engine = 1,
.i2c_port = 4,
.i2c_reset_addr = 0x20,
.i2c_reset_odl0 = (1 << 1),
.i2c_reset_odl1 = (1 << 6),
.i2c_presence_addr = 0x20,
.i2c_presence_odl0 = (1 << 2), /* bottom connector */
.i2c_presence_odl1 = (1 << 7), /* top connector */
.odl_phy_swap = true,
.i2c_engine = 1,
.i2c_port = 4,
.i2c_reset_addr = 0x20,
.i2c_reset_brick2 = (1 << 1),
.i2c_reset_brick3 = (1 << 6),
.i2c_reset_brick4 = 0, /* unused */
.i2c_reset_brick5 = 0, /* unused */
.i2c_presence_addr = 0x20,
.i2c_presence_brick2 = (1 << 2), /* bottom connector */
.i2c_presence_brick3 = (1 << 7), /* top connector */
.i2c_presence_brick4 = 0, /* unused */
.i2c_presence_brick5 = 0, /* unused */
.odl_phy_swap = true,
};

ST_PLUGGABLE(pe0_slot, "PE0");
Expand Down
24 changes: 14 additions & 10 deletions platforms/ibm-fsp/zz.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,24 @@

/* We don't yet create NPU device nodes on ZZ, but these values are correct */
const struct platform_ocapi zz_ocapi = {
.i2c_engine = 1,
.i2c_port = 4,
.i2c_reset_addr = 0x20,
.i2c_reset_odl0 = (1 << 1),
.i2c_reset_odl1 = (1 << 6),
.i2c_presence_addr = 0x20,
.i2c_presence_odl0 = (1 << 2), /* bottom connector */
.i2c_presence_odl1 = (1 << 7), /* top connector */
.i2c_engine = 1,
.i2c_port = 4,
.i2c_reset_addr = 0x20,
.i2c_reset_brick2 = (1 << 1),
.i2c_reset_brick3 = (1 << 6),
.i2c_reset_brick4 = 0, /* unused */
.i2c_reset_brick5 = 0, /* unused */
.i2c_presence_addr = 0x20,
.i2c_presence_brick2 = (1 << 2), /* bottom connector */
.i2c_presence_brick3 = (1 << 7), /* top connector */
.i2c_presence_brick4 = 0, /* unused */
.i2c_presence_brick5 = 0, /* unused */
/*
* i2c presence detection is broken on ZZ planar < v4 so we
* force the presence until all our systems are upgraded
*/
.force_presence = true,
.odl_phy_swap = true,
.force_presence = true,
.odl_phy_swap = true,
};

static bool zz_probe(void)
Expand Down

0 comments on commit 6a728af

Please sign in to comment.