Skip to contentSkip to conversation

drivers/fsi: Adjust slave ID based on address in command send

PATCH Superseded Christopher Bostic 3 participants 5 messages Feb 8, 2017 – Feb 9, 2017 FSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/fsi: Adjust slave ID based on address in command send

In order to access slave address ranges > 0x1FFFFF the slave ID must be adjusted accordingly in the command encoding:

ID 0: 0x00000000 - 0x001FFFFF
ID 1: 0x00200000 - 0x003FFFFF
ID 2: 0x00400000 - 0x005FFFFF
ID 3: 0x00600000 - 0x007FFFFF

---
 drivers/fsi/fsi-master-gpio.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/fsi/fsi-master-gpio.c +16 -4
index 73d9985..428f3db 100644
@@ -30,7 +30,9 @@
 #define	FSI_GPIO_CMD_READ	0x0400000000000000ULL
 #define	FSI_GPIO_CMD_SLAVE_MASK	0xC000000000000000ULL
 #define	FSI_GPIO_CMD_ADDR_SHIFT	37
-#define	FSI_GPIO_CMD_ADDR_MASK	0x001FFFFF
+#define	FSI_GPIO_CMD_ADR8_MASK	0x001FFFFF
+#define	FSI_GPIO_CMD_ADR16_MASK	0x001FFFFE
+#define	FSI_GPIO_CMD_ADR32_MASK	0x001FFFFC
 #define	FSI_GPIO_CMD_SLV_SHIFT	62
 #define	FSI_GPIO_CMD_SIZE_16	0x0000001000000000ULL
 #define	FSI_GPIO_CMD_SIZE_32	0x0000003000000000ULL
@@ -40,6 +42,9 @@
 #define	FSI_GPIO_CMD_DFLT_LEN	28
 #define	FSI_GPIO_CMD_CRC_SHIFT	60
 
+#define	FSI_SLAVE_SHIFT		21
+#define	FSI_SLAVE_MASK		0x3
+
 /* Bus errors */
 #define	FSI_GPIO_ERR_BUSY	1	/* Slave stuck in busy state */
 #define	FSI_GPIO_RESP_ERRA	2	/* Any (misc) Error */
@@ -301,15 +306,17 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
 		const void *data)
 {
 	uint8_t crc;
+	uint32_t addr_mask;
 
 	cmd->bits = FSI_GPIO_CMD_DFLT_LEN;
 	cmd->msg = FSI_GPIO_CMD_DEFAULT;
 	cmd->msg |= mode;
-	cmd->msg &= ~FSI_GPIO_CMD_SLAVE_MASK;
+	if (!slave)
+		slave = (addr >> FSI_SLAVE_SHIFT) & FSI_SLAVE_MASK;
 	cmd->msg |= (((uint64_t)slave) << FSI_GPIO_CMD_SLV_SHIFT);
-	addr &= FSI_GPIO_CMD_ADDR_MASK;
-	cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
 	if (size == sizeof(uint8_t)) {
+		addr_mask = FSI_GPIO_CMD_ADR8_MASK;
 		if (data) {
 			uint8_t cmd_data = *((uint8_t *)data);
 
@@ -317,6 +324,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
 				((uint64_t)cmd_data) << FSI_GPIO_CMD_DT8_SHIFT;
 		}
 	} else if (size == sizeof(uint16_t)) {
+		addr_mask = FSI_GPIO_CMD_ADR16_MASK;
 		cmd->msg |= FSI_GPIO_CMD_SIZE_16;
 		if (data) {
 			uint16_t cmd_data;
@@ -326,6 +334,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
 				((uint64_t)cmd_data) << FSI_GPIO_CMD_DT16_SHIFT;
 		}
 	} else {
+		addr_mask = FSI_GPIO_CMD_ADR32_MASK;
 		cmd->msg |= FSI_GPIO_CMD_SIZE_32;
 		if (data) {
 			uint32_t cmd_data;
@@ -336,6 +345,9 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
 		}
 	}
 
+	addr &= addr_mask;
+	cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
 	if (mode == FSI_GPIO_CMD_WRITE)
 		cmd->bits += (8 * size);
 
Signature · 1 line
1.8.2.2
#1 lore raw
Quoted 7 lines · Christopher Bostic

In order to access slave address ranges > 0x1FFFFF the slave ID must be adjusted accordingly in the command encoding:

ID 0: 0x00000000 - 0x001FFFFF
ID 1: 0x00200000 - 0x003FFFFF
ID 2: 0x00400000 - 0x005FFFFF
ID 3: 0x00600000 - 0x007FFFFF

Alistair and Eddie, can I please get an ack from both of you on this?

Quoted 81 lines
---
 drivers/fsi/fsi-master-gpio.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/fsi/fsi-master-gpio.c +16 -5
index 73d9985..428f3db 100644
@@ -30,7 +30,9 @@
 #define        FSI_GPIO_CMD_READ       0x0400000000000000ULL
 #define        FSI_GPIO_CMD_SLAVE_MASK 0xC000000000000000ULL
 #define        FSI_GPIO_CMD_ADDR_SHIFT 37
-#define        FSI_GPIO_CMD_ADDR_MASK  0x001FFFFF
+#define        FSI_GPIO_CMD_ADR8_MASK  0x001FFFFF
+#define        FSI_GPIO_CMD_ADR16_MASK 0x001FFFFE
+#define        FSI_GPIO_CMD_ADR32_MASK 0x001FFFFC
 #define        FSI_GPIO_CMD_SLV_SHIFT  62
 #define        FSI_GPIO_CMD_SIZE_16    0x0000001000000000ULL
 #define        FSI_GPIO_CMD_SIZE_32    0x0000003000000000ULL
@@ -40,6 +42,9 @@
 #define        FSI_GPIO_CMD_DFLT_LEN   28
 #define        FSI_GPIO_CMD_CRC_SHIFT  60
 
+#define        FSI_SLAVE_SHIFT         21
+#define        FSI_SLAVE_MASK          0x3
+
 /* Bus errors */
 #define        FSI_GPIO_ERR_BUSY       1       /* Slave stuck in busy state */
 #define        FSI_GPIO_RESP_ERRA      2       /* Any (misc) Error */
@@ -301,15 +306,17 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                const void *data)
 {
        uint8_t crc;
+       uint32_t addr_mask;
 
        cmd->bits = FSI_GPIO_CMD_DFLT_LEN;
        cmd->msg = FSI_GPIO_CMD_DEFAULT;
        cmd->msg |= mode;
-       cmd->msg &= ~FSI_GPIO_CMD_SLAVE_MASK;
+       if (!slave)
+               slave = (addr >> FSI_SLAVE_SHIFT) & FSI_SLAVE_MASK;
        cmd->msg |= (((uint64_t)slave) << FSI_GPIO_CMD_SLV_SHIFT);
-       addr &= FSI_GPIO_CMD_ADDR_MASK;
-       cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
        if (size == sizeof(uint8_t)) {
+               addr_mask = FSI_GPIO_CMD_ADR8_MASK;
                if (data) {
                        uint8_t cmd_data = *((uint8_t *)data);
 
@@ -317,6 +324,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                                ((uint64_t)cmd_data) << FSI_GPIO_CMD_DT8_SHIFT;
                }
        } else if (size == sizeof(uint16_t)) {
+               addr_mask = FSI_GPIO_CMD_ADR16_MASK;
                cmd->msg |= FSI_GPIO_CMD_SIZE_16;
                if (data) {
                        uint16_t cmd_data;
@@ -326,6 +334,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                                ((uint64_t)cmd_data) << FSI_GPIO_CMD_DT16_SHIFT;
                }
        } else {
+               addr_mask = FSI_GPIO_CMD_ADR32_MASK;
                cmd->msg |= FSI_GPIO_CMD_SIZE_32;
                if (data) {
                        uint32_t cmd_data;
@@ -336,6 +345,9 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                }
        }
 
+       addr &= addr_mask;
+       cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
        if (mode == FSI_GPIO_CMD_WRITE)
                cmd->bits += (8 * size);
 
--

1.8.2.2

#2 lore raw
Quoted 37 lines · Joel Stanley
Quoted 7 lines · Christopher Bostic

In order to access slave address ranges > 0x1FFFFF the slave ID must be adjusted accordingly in the command encoding:

ID 0: 0x00000000 - 0x001FFFFF
ID 1: 0x00200000 - 0x003FFFFF
ID 2: 0x00400000 - 0x005FFFFF
ID 3: 0x00600000 - 0x007FFFFF

Alistair and Eddie, can I please get an ack from both of you on this?

Quoted 25 lines
---
 drivers/fsi/fsi-master-gpio.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/fsi/fsi-master-gpio.c +3 -1
index 73d9985..428f3db 100644
@@ -30,7 +30,9 @@
 #define        FSI_GPIO_CMD_READ       0x0400000000000000ULL
 #define        FSI_GPIO_CMD_SLAVE_MASK 0xC000000000000000ULL
 #define        FSI_GPIO_CMD_ADDR_SHIFT 37
-#define        FSI_GPIO_CMD_ADDR_MASK  0x001FFFFF
+#define        FSI_GPIO_CMD_ADR8_MASK  0x001FFFFF
+#define        FSI_GPIO_CMD_ADR16_MASK 0x001FFFFE
+#define        FSI_GPIO_CMD_ADR32_MASK 0x001FFFFC
 #define        FSI_GPIO_CMD_SLV_SHIFT  62
 #define        FSI_GPIO_CMD_SIZE_16    0x0000001000000000ULL
 #define        FSI_GPIO_CMD_SIZE_32    0x0000003000000000ULL
@@ -40,6 +42,9 @@
 #define        FSI_GPIO_CMD_DFLT_LEN   28
 #define        FSI_GPIO_CMD_CRC_SHIFT  60
 
Quoted 7 lines

drivers/fsi/fsi-master-gpio.c static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,

Quoted 7 lines
drivers/fsi/fsi-master-gpio.c +3 -0
+#define        FSI_SLAVE_SHIFT         21
+#define        FSI_SLAVE_MASK          0x3
+
 /* Bus errors */
 #define        FSI_GPIO_ERR_BUSY       1       /* Slave stuck in busy state */
 #define        FSI_GPIO_RESP_ERRA      2       /* Any (misc) Error */
@@ -301,15 +306,17 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,

Do we need to expose the slave-id outside of this function? Ie. does anything currently (or is expected to in future) pass anything other than slave=0 to this function? If not we should drop slave-id from the function parameters imho.

Quoted 40 lines
Quoted 40 lines
drivers/fsi/fsi-master-gpio.c +7 -3
                const void *data)
 {
        uint8_t crc;
+       uint32_t addr_mask;
 
        cmd->bits = FSI_GPIO_CMD_DFLT_LEN;
        cmd->msg = FSI_GPIO_CMD_DEFAULT;
        cmd->msg |= mode;
-       cmd->msg &= ~FSI_GPIO_CMD_SLAVE_MASK;
+       if (!slave)
+               slave = (addr >> FSI_SLAVE_SHIFT) & FSI_SLAVE_MASK;
        cmd->msg |= (((uint64_t)slave) << FSI_GPIO_CMD_SLV_SHIFT);
-       addr &= FSI_GPIO_CMD_ADDR_MASK;
-       cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
        if (size == sizeof(uint8_t)) {
+               addr_mask = FSI_GPIO_CMD_ADR8_MASK;
                if (data) {
                        uint8_t cmd_data = *((uint8_t *)data);
 
@@ -317,6 +324,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                                ((uint64_t)cmd_data) << FSI_GPIO_CMD_DT8_SHIFT;
                }
        } else if (size == sizeof(uint16_t)) {
+               addr_mask = FSI_GPIO_CMD_ADR16_MASK;
                cmd->msg |= FSI_GPIO_CMD_SIZE_16;
                if (data) {
                        uint16_t cmd_data;
@@ -326,6 +334,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                                ((uint64_t)cmd_data) << FSI_GPIO_CMD_DT16_SHIFT;
                }
        } else {
+               addr_mask = FSI_GPIO_CMD_ADR32_MASK;
                cmd->msg |= FSI_GPIO_CMD_SIZE_32;
                if (data) {
                        uint32_t cmd_data;
@@ -336,6 +345,9 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                }
        }
 
Quoted 1 line

drivers/fsi/fsi-master-gpio.c static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode, · line 348

Quoted 1 line
drivers/fsi/fsi-master-gpio.c +1 -0
+       addr &= addr_mask;

How is the masking of the address different now that you are setting the slave-id? Ie. this change looks more general than just setting the slave-id so is it fixing a different probelm? Or is somehow related to setting the slave-id?

Regards,

Alistair

Quoted 8 lines
Quoted 8 lines
drivers/fsi/fsi-master-gpio.c +2 -1
+       cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
        if (mode == FSI_GPIO_CMD_WRITE)
                cmd->bits += (8 * size);
 
--

1.8.2.2

#3 lore raw
Quoted 36 lines · Alistair Popple
Quoted 35 lines · Joel Stanley
Quoted 7 lines · Christopher Bostic

In order to access slave address ranges > 0x1FFFFF the slave ID must be adjusted accordingly in the command encoding:

ID 0: 0x00000000 - 0x001FFFFF
ID 1: 0x00200000 - 0x003FFFFF
ID 2: 0x00400000 - 0x005FFFFF
ID 3: 0x00600000 - 0x007FFFFF

Alistair and Eddie, can I please get an ack from both of you on this?

Quoted 24 lines
---
  drivers/fsi/fsi-master-gpio.c | 20 ++++++++++++++++----
  1 file changed, 16 insertions(+), 4 deletions(-)
drivers/fsi/fsi-master-gpio.c +3 -1
index 73d9985..428f3db 100644
@@ -30,7 +30,9 @@
  #define        FSI_GPIO_CMD_READ       0x0400000000000000ULL
  #define        FSI_GPIO_CMD_SLAVE_MASK 0xC000000000000000ULL
  #define        FSI_GPIO_CMD_ADDR_SHIFT 37
-#define        FSI_GPIO_CMD_ADDR_MASK  0x001FFFFF
+#define        FSI_GPIO_CMD_ADR8_MASK  0x001FFFFF
+#define        FSI_GPIO_CMD_ADR16_MASK 0x001FFFFE
+#define        FSI_GPIO_CMD_ADR32_MASK 0x001FFFFC
  #define        FSI_GPIO_CMD_SLV_SHIFT  62
  #define        FSI_GPIO_CMD_SIZE_16    0x0000001000000000ULL
  #define        FSI_GPIO_CMD_SIZE_32    0x0000003000000000ULL
@@ -40,6 +42,9 @@
  #define        FSI_GPIO_CMD_DFLT_LEN   28
  #define        FSI_GPIO_CMD_CRC_SHIFT  60
 
Quoted 12 lines
Quoted 7 lines

drivers/fsi/fsi-master-gpio.c static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,

Quoted 7 lines
drivers/fsi/fsi-master-gpio.c +3 -0
+#define        FSI_SLAVE_SHIFT         21
+#define        FSI_SLAVE_MASK          0x3
+
  /* Bus errors */
  #define        FSI_GPIO_ERR_BUSY       1       /* Slave stuck in busy state */
  #define        FSI_GPIO_RESP_ERRA      2       /* Any (misc) Error */
@@ -301,15 +306,17 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,

Do we need to expose the slave-id outside of this function? Ie. does anything currently (or is expected to in future) pass anything other than slave=0 to this function? If not we should drop slave-id from the function parameters imho.

There are cases where the core scan code will need to pass in slave-id 3 during link initialization. Also the core is structured to deal with the eventual case where we may have multiple CFAMs per link so I think it makes sense to keep it as a parameter.

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
drivers/fsi/fsi-master-gpio.c +7 -3
                 const void *data)
  {
         uint8_t crc;
+       uint32_t addr_mask;
 
         cmd->bits = FSI_GPIO_CMD_DFLT_LEN;
         cmd->msg = FSI_GPIO_CMD_DEFAULT;
         cmd->msg |= mode;
-       cmd->msg &= ~FSI_GPIO_CMD_SLAVE_MASK;
+       if (!slave)
+               slave = (addr >> FSI_SLAVE_SHIFT) & FSI_SLAVE_MASK;
         cmd->msg |= (((uint64_t)slave) << FSI_GPIO_CMD_SLV_SHIFT);
-       addr &= FSI_GPIO_CMD_ADDR_MASK;
-       cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
         if (size == sizeof(uint8_t)) {
+               addr_mask = FSI_GPIO_CMD_ADR8_MASK;
                 if (data) {
                         uint8_t cmd_data = *((uint8_t *)data);
 
@@ -317,6 +324,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                                 ((uint64_t)cmd_data) << FSI_GPIO_CMD_DT8_SHIFT;
                 }
         } else if (size == sizeof(uint16_t)) {
+               addr_mask = FSI_GPIO_CMD_ADR16_MASK;
                 cmd->msg |= FSI_GPIO_CMD_SIZE_16;
                 if (data) {
                         uint16_t cmd_data;
@@ -326,6 +334,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                                 ((uint64_t)cmd_data) << FSI_GPIO_CMD_DT16_SHIFT;
                 }
         } else {
+               addr_mask = FSI_GPIO_CMD_ADR32_MASK;
                 cmd->msg |= FSI_GPIO_CMD_SIZE_32;
                 if (data) {
                         uint32_t cmd_data;
@@ -336,6 +345,9 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                 }
         }
 
Quoted 6 lines
Quoted 1 line

drivers/fsi/fsi-master-gpio.c static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode, · line 348

Quoted 1 line
drivers/fsi/fsi-master-gpio.c +1 -0
+       addr &= addr_mask;

How is the masking of the address different now that you are setting the slave-id? Ie. this change looks more general than just setting the slave-id so is it fixing a different probelm? Or is somehow related to setting the slave-id?

Its not directly related to the slave ID. I added this to ensure that any callers that request odd alignments, i.e. 32 bit write aligned on address 0xFFFF is properly masked.

Since it is separate conceptually I'll break this part out into a separate patch.

Thanks,
Chris

Quoted 12 lines

Regards,

Alistair

Quoted 8 lines
Quoted 8 lines
drivers/fsi/fsi-master-gpio.c +2 -1
+       cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
         if (mode == FSI_GPIO_CMD_WRITE)
                 cmd->bits += (8 * size);
 
--

1.8.2.2

#4 lore raw
Quoted 50 lines · Christopher Bostic
Quoted 36 lines · Alistair Popple
Quoted 35 lines · Joel Stanley
Quoted 7 lines · Christopher Bostic

In order to access slave address ranges > 0x1FFFFF the slave ID must be adjusted accordingly in the command encoding:

ID 0: 0x00000000 - 0x001FFFFF
ID 1: 0x00200000 - 0x003FFFFF
ID 2: 0x00400000 - 0x005FFFFF
ID 3: 0x00600000 - 0x007FFFFF

Alistair and Eddie, can I please get an ack from both of you on this?

Quoted 24 lines
---
  drivers/fsi/fsi-master-gpio.c | 20 ++++++++++++++++----
  1 file changed, 16 insertions(+), 4 deletions(-)
drivers/fsi/fsi-master-gpio.c +3 -1
index 73d9985..428f3db 100644
@@ -30,7 +30,9 @@
  #define        FSI_GPIO_CMD_READ       0x0400000000000000ULL
  #define        FSI_GPIO_CMD_SLAVE_MASK 0xC000000000000000ULL
  #define        FSI_GPIO_CMD_ADDR_SHIFT 37
-#define        FSI_GPIO_CMD_ADDR_MASK  0x001FFFFF
+#define        FSI_GPIO_CMD_ADR8_MASK  0x001FFFFF
+#define        FSI_GPIO_CMD_ADR16_MASK 0x001FFFFE
+#define        FSI_GPIO_CMD_ADR32_MASK 0x001FFFFC
  #define        FSI_GPIO_CMD_SLV_SHIFT  62
  #define        FSI_GPIO_CMD_SIZE_16    0x0000001000000000ULL
  #define        FSI_GPIO_CMD_SIZE_32    0x0000003000000000ULL
@@ -40,6 +42,9 @@
  #define        FSI_GPIO_CMD_DFLT_LEN   28
  #define        FSI_GPIO_CMD_CRC_SHIFT  60
 
Quoted 12 lines
Quoted 7 lines

drivers/fsi/fsi-master-gpio.c static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,

Quoted 7 lines
drivers/fsi/fsi-master-gpio.c +3 -0
+#define        FSI_SLAVE_SHIFT         21
+#define        FSI_SLAVE_MASK          0x3
+
  /* Bus errors */
  #define        FSI_GPIO_ERR_BUSY       1       /* Slave stuck in busy state */
  #define        FSI_GPIO_RESP_ERRA      2       /* Any (misc) Error */
@@ -301,15 +306,17 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,

Do we need to expose the slave-id outside of this function? Ie. does anything currently (or is expected to in future) pass anything other than slave=0 to this function? If not we should drop slave-id from the function parameters imho.

Quoted 6 lines

There are cases where the core scan code will need to pass in slave-id 3 during
link initialization. Also the core is structured to deal with the eventual case
where we may have multiple CFAMs per link so I think it makes sense to keep it as a parameter.

Ok, I wasn't sure but given that it makes sense to keep it. The code looks good otherwise.

Quoted 46 lines
Quoted 40 lines
Quoted 40 lines
Quoted 40 lines
drivers/fsi/fsi-master-gpio.c +7 -3
                 const void *data)
  {
         uint8_t crc;
+       uint32_t addr_mask;
 
         cmd->bits = FSI_GPIO_CMD_DFLT_LEN;
         cmd->msg = FSI_GPIO_CMD_DEFAULT;
         cmd->msg |= mode;
-       cmd->msg &= ~FSI_GPIO_CMD_SLAVE_MASK;
+       if (!slave)
+               slave = (addr >> FSI_SLAVE_SHIFT) & FSI_SLAVE_MASK;
         cmd->msg |= (((uint64_t)slave) << FSI_GPIO_CMD_SLV_SHIFT);
-       addr &= FSI_GPIO_CMD_ADDR_MASK;
-       cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
         if (size == sizeof(uint8_t)) {
+               addr_mask = FSI_GPIO_CMD_ADR8_MASK;
                 if (data) {
                         uint8_t cmd_data = *((uint8_t *)data);
 
@@ -317,6 +324,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                                 ((uint64_t)cmd_data) << FSI_GPIO_CMD_DT8_SHIFT;
                 }
         } else if (size == sizeof(uint16_t)) {
+               addr_mask = FSI_GPIO_CMD_ADR16_MASK;
                 cmd->msg |= FSI_GPIO_CMD_SIZE_16;
                 if (data) {
                         uint16_t cmd_data;
@@ -326,6 +334,7 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                                 ((uint64_t)cmd_data) << FSI_GPIO_CMD_DT16_SHIFT;
                 }
         } else {
+               addr_mask = FSI_GPIO_CMD_ADR32_MASK;
                 cmd->msg |= FSI_GPIO_CMD_SIZE_32;
                 if (data) {
                         uint32_t cmd_data;
@@ -336,6 +345,9 @@ static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode,
                 }
         }
 
Quoted 6 lines
Quoted 1 line

drivers/fsi/fsi-master-gpio.c static void build_abs_ar_command(struct fsi_gpio_msg *cmd, uint64_t mode, · line 348

Quoted 1 line
drivers/fsi/fsi-master-gpio.c +1 -0
+       addr &= addr_mask;

How is the masking of the address different now that you are setting the slave-id? Ie. this change looks more general than just setting the slave-id so is it fixing a different probelm? Or is somehow related to setting the slave-id?

Quoted 4 lines

Its not directly related to the slave ID. I added this to ensure that any callers
that request odd alignments, i.e. 32 bit write aligned on address 0xFFFF is properly masked.

Unless we expect odd alignments for some reason I think it would be best to return an error (eg. -EINVAL) when an incorrect alignment is passed. It's not always obvious that fixing alignment is the correct behaviour in these cases - callers may expect something different and returning an error forces them to work out what that is.

Quoted 2 lines

Since it is separate conceptually I'll break this part out into a separate patch.

Please do, thanks!

Quoted 16 lines

Thanks,
Chris

Quoted 12 lines

Regards,

Alistair

Quoted 8 lines
Quoted 8 lines
drivers/fsi/fsi-master-gpio.c +2 -1
+       cmd->msg |= (((uint64_t)addr) << FSI_GPIO_CMD_ADDR_SHIFT);
+
         if (mode == FSI_GPIO_CMD_WRITE)
                 cmd->bits += (8 * size);
 
--

1.8.2.2