Skip to contentSkip to conversation

i2c: xgene-slimpro: Support v2

PATCH Applied Hoan Tran 3 participants 4 messages Oct 30, 2017 – Nov 1, 2017 I2C subsystem host drivers

lore
Share & tools
lore

Hoan Tran

author
#0 lore raw

PATCH v2 1/1 i2c: xgene-slimpro: Support v2

This patch supports xgene-slimpro-i2c v2 which uses the non-cachable memory as the PCC shared memory.

---
v2:
- Remove un-necessary ifdef CONFIG_ACPI
- Use acpi_match_table pointer from pdev
- Use MEMREMAP_WT for non-cachable memory

 drivers/i2c/busses/i2c-xgene-slimpro.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-xgene-slimpro.c +26 -4
index 7e89ba6..a7ac746 100644
@@ -129,6 +129,11 @@ struct slimpro_i2c_dev {
 #define to_slimpro_i2c_dev(cl)	\
 		container_of(cl, struct slimpro_i2c_dev, mbox_client)
 
+enum slimpro_i2c_version {
+	XGENE_SLIMPRO_I2C_V1 = 0,
+	XGENE_SLIMPRO_I2C_V2 = 1,
+};
+
 /*
  * This function tests and clears a bitmask then returns its old value
  */
@@ -476,6 +481,15 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev)
 		}
 	} else {
 		struct acpi_pcct_hw_reduced *cppc_ss;
+		const struct acpi_device_id *acpi_id;
+		int version = XGENE_SLIMPRO_I2C_V1;
+
+		acpi_id = acpi_match_device(pdev->dev.driver->acpi_match_table,
+					    &pdev->dev);
+		if (!acpi_id)
+			return -EINVAL;
+
+		version = (int)acpi_id->driver_data;
 
 		if (device_property_read_u32(&pdev->dev, "pcc-channel",
 					     &ctx->mbox_idx))
@@ -514,9 +528,16 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev)
 		 */
 		ctx->comm_base_addr = cppc_ss->base_address;
 		if (ctx->comm_base_addr) {
-			ctx->pcc_comm_addr = memremap(ctx->comm_base_addr,
-						      cppc_ss->length,
-						      MEMREMAP_WB);
+			if (version == XGENE_SLIMPRO_I2C_V2)
+				ctx->pcc_comm_addr = memremap(
+							ctx->comm_base_addr,
+							cppc_ss->length,
+							MEMREMAP_WT);
+			else
+				ctx->pcc_comm_addr = memremap(
+							ctx->comm_base_addr,
+							cppc_ss->length,
+							MEMREMAP_WB);
 		} else {
 			dev_err(&pdev->dev, "Failed to get PCC comm region\n");
 			rc = -ENOENT;
@@ -581,7 +602,8 @@ MODULE_DEVICE_TABLE(of, xgene_slimpro_i2c_dt_ids);
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id xgene_slimpro_i2c_acpi_ids[] = {
-	{"APMC0D40", 0},
+	{"APMC0D40", XGENE_SLIMPRO_I2C_V1},
+	{"APMC0D8B", XGENE_SLIMPRO_I2C_V2},
 	{}
 };
 MODULE_DEVICE_TABLE(acpi, xgene_slimpro_i2c_acpi_ids);
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 4 lines · Hoan Tran

This patch supports xgene-slimpro-i2c v2 which uses the non-cachable memory
as the PCC shared memory.

(I'm totally fine with ACPI bits here, for the rest I hope it had been tested and works as expected)

Quoted 86 lines

---
v2:
- Remove un-necessary ifdef CONFIG_ACPI
- Use acpi_match_table pointer from pdev
- Use MEMREMAP_WT for non-cachable memory

 drivers/i2c/busses/i2c-xgene-slimpro.c | 30
++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-xgene-slimpro.c +5 -0
index 7e89ba6..a7ac746 100644
@@ -129,6 +129,11 @@ struct slimpro_i2c_dev {
 #define to_slimpro_i2c_dev(cl)	\
 		container_of(cl, struct slimpro_i2c_dev, mbox_client)
 
+enum slimpro_i2c_version {
+	XGENE_SLIMPRO_I2C_V1 = 0,
+	XGENE_SLIMPRO_I2C_V2 = 1,
+};
+
 /*
  * This function tests and clears a bitmask then returns its old

value
*/

drivers/i2c/busses/i2c-xgene-slimpro.c +9 -0
@@ -476,6 +481,15 @@ static int xgene_slimpro_i2c_probe(struct
 platform_device *pdev)
 		}
 	} else {
 		struct acpi_pcct_hw_reduced *cppc_ss;
+		const struct acpi_device_id *acpi_id;
+		int version = XGENE_SLIMPRO_I2C_V1;
+
+		acpi_id = acpi_match_device(pdev->dev.driver-
 >acpi_match_table,
+					    &pdev->dev);
+		if (!acpi_id)
+			return -EINVAL;
+
+		version = (int)acpi_id->driver_data;
 

if (device_property_read_u32(&pdev->dev, "pcc-
channel",

drivers/i2c/busses/i2c-xgene-slimpro.c +3 -3
 					     &ctx->mbox_idx))
@@ -514,9 +528,16 @@ static int xgene_slimpro_i2c_probe(struct
 platform_device *pdev)
 		 */
 		ctx->comm_base_addr = cppc_ss->base_address;
 		if (ctx->comm_base_addr) {
-			ctx->pcc_comm_addr = memremap(ctx-
 >comm_base_addr,
-						      cppc_ss-
 >length,
-						      MEMREMAP_WB);
+			if (version == XGENE_SLIMPRO_I2C_V2)
+				ctx->pcc_comm_addr = memremap(
+							ctx-
Quoted 1 line

comm_base_addr,

drivers/i2c/busses/i2c-xgene-slimpro.c +1 -0
+							cppc_ss-
Quoted 1 line

length,

drivers/i2c/busses/i2c-xgene-slimpro.c +4 -0
+							MEMREMAP_WT);
+			else
+				ctx->pcc_comm_addr = memremap(
+							ctx-
Quoted 1 line

comm_base_addr,

drivers/i2c/busses/i2c-xgene-slimpro.c +1 -0
+							cppc_ss-
Quoted 1 line

length,

drivers/i2c/busses/i2c-xgene-slimpro.c +1 -0
+							MEMREMAP_WB);
 		} else {
 			dev_err(&pdev->dev, "Failed to get PCC comm

region\n");

drivers/i2c/busses/i2c-xgene-slimpro.c +2 -1
 			rc = -ENOENT;
@@ -581,7 +602,8 @@ MODULE_DEVICE_TABLE(of, xgene_slimpro_i2c_dt_ids);
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id xgene_slimpro_i2c_acpi_ids[] = {
-	{"APMC0D40", 0},
+	{"APMC0D40", XGENE_SLIMPRO_I2C_V1},
+	{"APMC0D8B", XGENE_SLIMPRO_I2C_V2},
 	{}
 };
 MODULE_DEVICE_TABLE(acpi, xgene_slimpro_i2c_acpi_ids);
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
author
#2 lore raw

Hi Andy,

Quoted 10 lines · Andy Shevchenko
Quoted 4 lines · Hoan Tran

This patch supports xgene-slimpro-i2c v2 which uses the non-cachable memory
as the PCC shared memory.

(I'm totally fine with ACPI bits here, for the rest I hope it had been tested and works as expected)

Yes, it had been tested.

Thanks
Hoan

Quoted 91 lines
Quoted 78 lines

---
v2:
- Remove un-necessary ifdef CONFIG_ACPI
- Use acpi_match_table pointer from pdev
- Use MEMREMAP_WT for non-cachable memory

 drivers/i2c/busses/i2c-xgene-slimpro.c | 30
++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-xgene-slimpro.c +5 -0
index 7e89ba6..a7ac746 100644
@@ -129,6 +129,11 @@ struct slimpro_i2c_dev {
 #define to_slimpro_i2c_dev(cl)       \
              container_of(cl, struct slimpro_i2c_dev, mbox_client)
 
+enum slimpro_i2c_version {
+     XGENE_SLIMPRO_I2C_V1 = 0,
+     XGENE_SLIMPRO_I2C_V2 = 1,
+};
+
 /*
  * This function tests and clears a bitmask then returns its old

value
*/

drivers/i2c/busses/i2c-xgene-slimpro.c +9 -0
@@ -476,6 +481,15 @@ static int xgene_slimpro_i2c_probe(struct
 platform_device *pdev)
              }
      } else {
              struct acpi_pcct_hw_reduced *cppc_ss;
+             const struct acpi_device_id *acpi_id;
+             int version = XGENE_SLIMPRO_I2C_V1;
+
+             acpi_id = acpi_match_device(pdev->dev.driver-
 >acpi_match_table,
+                                         &pdev->dev);
+             if (!acpi_id)
+                     return -EINVAL;
+
+             version = (int)acpi_id->driver_data;
 
              if (device_property_read_u32(&pdev->dev, "pcc-
channel",
                                           &ctx->mbox_idx))
drivers/i2c/busses/i2c-xgene-slimpro.c +3 -3
@@ -514,9 +528,16 @@ static int xgene_slimpro_i2c_probe(struct
 platform_device *pdev)
               */
              ctx->comm_base_addr = cppc_ss->base_address;
              if (ctx->comm_base_addr) {
-                     ctx->pcc_comm_addr = memremap(ctx-
 >comm_base_addr,
-                                                   cppc_ss-
 >length,
-                                                   MEMREMAP_WB);
+                     if (version == XGENE_SLIMPRO_I2C_V2)
+                             ctx->pcc_comm_addr = memremap(
+                                                     ctx-
Quoted 1 line

comm_base_addr,

+ cppc_ss-

Quoted 1 line

length,

drivers/i2c/busses/i2c-xgene-slimpro.c +4 -0
+                                                     MEMREMAP_WT);
+                     else
+                             ctx->pcc_comm_addr = memremap(
+                                                     ctx-
Quoted 1 line

comm_base_addr,

+ cppc_ss-

Quoted 1 line

length,

+                                                     MEMREMAP_WB);
              } else {
                      dev_err(&pdev->dev, "Failed to get PCC comm
region\n");
                      rc = -ENOENT;

drivers/i2c/busses/i2c-xgene-slimpro.c MODULE_DEVICE_TABLE(of, xgene_slimpro_i2c_dt_ids); · line 609

Quoted 9 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +2 -1
@@ -581,7 +602,8 @@ MODULE_DEVICE_TABLE(of, xgene_slimpro_i2c_dt_ids);
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id xgene_slimpro_i2c_acpi_ids[] = {
-     {"APMC0D40", 0},
+     {"APMC0D40", XGENE_SLIMPRO_I2C_V1},
+     {"APMC0D8B", XGENE_SLIMPRO_I2C_V2},
      {}
 };
 MODULE_DEVICE_TABLE(acpi, xgene_slimpro_i2c_acpi_ids);

--
Andy Shevchenko <[email protected]> Intel Finland Oy