[Skiboot] [PATCH v3 5/6] hw/npu2, platform: Restructure OpenCAPI i2c reset/presence pins

Frederic Barrat fbarrat at linux.ibm.com
Sat Sep 1 00:36:55 AEST 2018



Le 31/08/2018 à 06:16, Andrew Donnellan a écrit :
> 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 at au1.ibm.com>
> Reviewed-by: Frederic Barrat <fbarrat at linux.vnet.ibm.com>
> Reviewed-by: Oliver O'Halloran <oohall at gmail.com>
> 
> ---
> v1->v2:
> - rename the i2c fields from pin* to brick* to be clearer (Oliver)
> 
> v2->v3:
> - rename the i2c fields in the commit message... (Oliver)
> ---
>   core/platform.c          | 24 ++++++++++++++----------
>   hw/npu2-common.c         |  9 +++++++--
>   hw/npu2-opencapi.c       | 10 +++++++---
>   include/platform.h       | 12 ++++++++----
>   platforms/astbmc/zaius.c | 22 +++++++++++++---------
>   platforms/ibm-fsp/zz.c   | 24 ++++++++++++++----------
>   6 files changed, 63 insertions(+), 38 deletions(-)
> 
> diff --git a/core/platform.c b/core/platform.c
> index 4b3eaa4bd1d1..7985ce564509 100644
> --- a/core/platform.c
> +++ b/core/platform.c
> @@ -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 = {
> diff --git a/hw/npu2-common.c b/hw/npu2-common.c
> index 15da3d316c24..82c4c1773203 100644
> --- a/hw/npu2-common.c
> +++ b/hw/npu2-common.c
> @@ -115,11 +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;
>   	default:


Well, nothing like a compiler to catch what reviewers don't! We're 
missing a 'break' here.

   Fred

>   		OCAPIERR(dev, "presence detection on invalid link\n");
>   		return true;
> diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c
> index b5a32dd32244..5e258e1aff07 100644
> --- a/hw/npu2-opencapi.c
> +++ b/hw/npu2-opencapi.c
> @@ -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);
> diff --git a/include/platform.h b/include/platform.h
> index efafbd2239b9..fee5a76cf9e8 100644
> --- a/include/platform.h
> +++ b/include/platform.h
> @@ -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 */
> diff --git a/platforms/astbmc/zaius.c b/platforms/astbmc/zaius.c
> index 267e6578bbe7..0eed10c706d0 100644
> --- a/platforms/astbmc/zaius.c
> +++ b/platforms/astbmc/zaius.c
> @@ -26,15 +26,19 @@
>   #include "astbmc.h"
> 
>   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,
>   };
> 
>   #define NPU_BASE 0x5011000
> diff --git a/platforms/ibm-fsp/zz.c b/platforms/ibm-fsp/zz.c
> index 7c717d3c7087..e54472699c59 100644
> --- a/platforms/ibm-fsp/zz.c
> +++ b/platforms/ibm-fsp/zz.c
> @@ -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)
> 



More information about the Skiboot mailing list