i2c: xgene-slimpro: Support v2
PATCH 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.
--- drivers/i2c/busses/i2c-xgene-slimpro.c | 45 +++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-xgene-slimpro.c +34 -11
@@ -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 */
@@ -446,6 +451,15 @@ static u32 xgene_slimpro_i2c_func(struct i2c_adapter *adapter) .functionality = xgene_slimpro_i2c_func, }; +#ifdef CONFIG_ACPI +static const struct acpi_device_id xgene_slimpro_i2c_acpi_ids[] = { + {"APMC0D40" ,XGENE_SLIMPRO_I2C_V1 }, + {"APMC0D8B" ,XGENE_SLIMPRO_I2C_V2 }, + {} +}; +MODULE_DEVICE_TABLE (acpi, xgene_slimpro_i2c_acpi_ids); +#endif +static int xgene_slimpro_i2c_probe (struct platform_device *pdev) {struct slimpro_i2c_dev *ctx;
@@ -476,6 +490,17 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) } }else {struct acpi_pcct_hw_reduced *cppc_ss; +int version =XGENE_SLIMPRO_I2C_V1 ; +#ifdef CONFIG_ACPI +const struct acpi_device_id *acpi_id; + + acpi_id =acpi_match_device (xgene_slimpro_i2c_acpi_ids, + &pdev->dev); +if (!acpi_id) +return -EINVAL ; + + version = (int )acpi_id->driver_data; +#endif if (device_property_read_u32 (&pdev->dev,"pcc-channel" , &ctx->mbox_idx))
@@ -514,9 +539,15 @@ 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 = (void __force *)ioremap ( + ctx->comm_base_addr, + cppc_ss->length); +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 ;
@@ -579,14 +610,6 @@ static int xgene_slimpro_i2c_remove(struct platform_device *pdev) };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 }, - {} -}; -MODULE_DEVICE_TABLE (acpi, xgene_slimpro_i2c_acpi_ids); -#endif -static struct platform_driver xgene_slimpro_i2c_driver = { .probe = xgene_slimpro_i2c_probe, .remove = xgene_slimpro_i2c_remove,
Signature · 1 line
1.9.1
Thanks for the patch!
Quoted 4 lines · Hoan Tran
This patch supports xgene-slimpro-i2c v2 which uses the non-cachable memory as the PCC shared memory.
Signed-off-by Hoan Tran <[email protected]>
I can't tell if __force is justified here but I don't know much about ACPI... Andy, can you have a look?
Quoted 91 lines
--- drivers/i2c/busses/i2c-xgene-slimpro.c | 45 +++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 11 deletions(-)drivers/i2c/busses/i2c-xgene-slimpro.c +34
-11@@ -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 */ @@ -446,6 +451,15 @@ static u32 xgene_slimpro_i2c_func(struct i2c_adapter *adapter) .functionality = xgene_slimpro_i2c_func, }; +#ifdef CONFIG_ACPI +static const struct acpi_device_id xgene_slimpro_i2c_acpi_ids[] = { + {"APMC0D40" ,XGENE_SLIMPRO_I2C_V1 }, + {"APMC0D8B" ,XGENE_SLIMPRO_I2C_V2 }, + {} +}; +MODULE_DEVICE_TABLE (acpi, xgene_slimpro_i2c_acpi_ids); +#endif +static int xgene_slimpro_i2c_probe (struct platform_device *pdev) {struct slimpro_i2c_dev *ctx;@@ -476,6 +490,17 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) } }else {struct acpi_pcct_hw_reduced *cppc_ss; +int version =XGENE_SLIMPRO_I2C_V1 ; +#ifdef CONFIG_ACPI +const struct acpi_device_id *acpi_id; + + acpi_id =acpi_match_device (xgene_slimpro_i2c_acpi_ids, + &pdev->dev); +if (!acpi_id) +return -EINVAL ; + + version = (int )acpi_id->driver_data; +#endif if (device_property_read_u32 (&pdev->dev,"pcc-channel" , &ctx->mbox_idx))@@ -514,9 +539,15 @@ 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 = (void __force *)ioremap ( + ctx->comm_base_addr, + cppc_ss->length); +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 ;@@ -579,14 +610,6 @@ static int xgene_slimpro_i2c_remove(struct platform_device *pdev) };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 }, - {} -}; -MODULE_DEVICE_TABLE (acpi, xgene_slimpro_i2c_acpi_ids); -#endif -static struct platform_driver xgene_slimpro_i2c_driver = { .probe = xgene_slimpro_i2c_probe, .remove = xgene_slimpro_i2c_remove,Signature · 1 line
1.9.1
Quoted 11 lines · Wolfram Sang
Thanks for the patch!
Quoted 5 lines · Hoan Tran
This patch supports xgene-slimpro-i2c v2 which uses the non-cachable memory
as the PCC shared memory.Signed-off-by Hoan Tran <[email protected]>I can't tell if
__forceis justified here but I don't know much about ACPI... Andy, can you have a look?
Few comments to the patch as well.
Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c static u32 xgene_slimpro_i2c_func(struct i2c_adapter *adapter) · line 461
Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +8
-0+#ifdef CONFIG_ACPI +static const struct acpi_device_id xgene_slimpro_i2c_acpi_ids[] = { + {"APMC0D40" ,XGENE_SLIMPRO_I2C_V1 }, + {"APMC0D8B" ,XGENE_SLIMPRO_I2C_V2 }, + {} +}; +MODULE_DEVICE_TABLE (acpi, xgene_slimpro_i2c_acpi_ids); +#endif
No need to move this here...
Quoted 11 lines
drivers/i2c/busses/i2c-xgene-slimpro.c static int xgene_slimpro_i2c_probe(struct · line 495
Quoted 11 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +3
-0+static int xgene_slimpro_i2c_probe (struct platform_device *pdev) {struct slimpro_i2c_dev *ctx;@@ -476,6 +490,17 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) } }else {struct acpi_pcct_hw_reduced *cppc_ss; +int version =XGENE_SLIMPRO_I2C_V1 ; +#ifdef CONFIG_ACPI
Do you really need this ifdef?
Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c static int xgene_slimpro_i2c_probe(struct platform_device *pdev)
Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +3
-0+const struct acpi_device_id *acpi_id; + + acpi_id = acpi_match_device(xgene_slimpro_i2c_acpi_ids,
... you may get pointer to id table via pdev.
Quoted 12 lines
Quoted 12 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +6
-0+ &pdev->dev); +if (!acpi_id) +return -EINVAL ; + + version = (int )acpi_id->driver_data; +#endif (quoted diff) +0
-1if (ctx->comm_base_addr) { - ctx->pcc_comm_addr = memremap(ctx-Quoted 1 line
comm_base_addr,(quoted diff) +0
-1- cppc_ss-Quoted 1 line
length,
Quoted 8 lines
Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +2
-1- MEMREMAP_WB); +if (version ==XGENE_SLIMPRO_I2C_V2 ) + ctx->pcc_comm_addr = (void __force*)ioremap(
(quoted diff) +1
-0+ ctx-Quoted 1 line
comm_base_addr,(quoted diff) +1
-0+ cppc_ss-Quoted 1 line
length);
Commit message actually doesn't explain why we switch to iomap over memmap.
(__force here is obviously to suppress __iomap annotation for mapped memory)
If you need non-cacheable MEMREMAP_WT I guess will do a job.
Quoted 8 lines
Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +3
-0+else + ctx->pcc_comm_addr = memremap( + ctx-Quoted 1 line
comm_base_addr,(quoted diff) +1
-0+ cppc_ss-Quoted 1 line
length,
(quoted diff) +1
-0+ MEMREMAP_WB);
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 5 lines
Quoted 3 lines
I can't tell if
__forceis justified here but I don't know much about ACPI... Andy, can you have a look?Few comments to the patch as well.
Thanks, Andy! And was nice to finally meet you in Prague :)
Hi Andy,
Quoted 68 lines · Andy Shevchenko
Quoted 11 lines · Wolfram Sang
Thanks for the patch!
Quoted 5 lines · Hoan Tran
This patch supports xgene-slimpro-i2c v2 which uses the non-cachable memory
as the PCC shared memory.Signed-off-by Hoan Tran <[email protected]>I can't tell if
__forceis justified here but I don't know much about ACPI... Andy, can you have a look?Few comments to the patch as well.
Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c static u32 xgene_slimpro_i2c_func(struct i2c_adapter *adapter) · line 461
Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +8
-0+#ifdef CONFIG_ACPI +static const struct acpi_device_id xgene_slimpro_i2c_acpi_ids[] = { + {"APMC0D40" ,XGENE_SLIMPRO_I2C_V1 }, + {"APMC0D8B" ,XGENE_SLIMPRO_I2C_V2 }, + {} +}; +MODULE_DEVICE_TABLE (acpi, xgene_slimpro_i2c_acpi_ids); +#endif No need to move this here...
Quoted 11 lines
drivers/i2c/busses/i2c-xgene-slimpro.c static int xgene_slimpro_i2c_probe(struct · line 495
Quoted 11 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +3
-0+static int xgene_slimpro_i2c_probe (struct platform_device *pdev) {struct slimpro_i2c_dev *ctx;@@ -476,6 +490,17 @@ static int xgene_slimpro_i2c_probe(struct platform_device *pdev) } }else {struct acpi_pcct_hw_reduced *cppc_ss; +int version =XGENE_SLIMPRO_I2C_V1 ; +#ifdef CONFIG_ACPI Do you really need this ifdef?
Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c static int xgene_slimpro_i2c_probe(struct platform_device *pdev)
Quoted 4 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +3
-0+const struct acpi_device_id *acpi_id; + + acpi_id = acpi_match_device(xgene_slimpro_i2c_acpi_ids,... you may get pointer to id table via pdev.
Quoted 12 lines
Quoted 12 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +6
-0+ &pdev->dev); +if (!acpi_id) +return -EINVAL ; + + version = (int )acpi_id->driver_data; +#endif if (ctx->comm_base_addr) {-
ctx->pcc_comm_addr= memremap(ctx-Quoted 1 line
comm_base_addr,- cppc_ss-
Quoted 1 line
length,
Quoted 8 lines
Quoted 8 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +2
-1- MEMREMAP_WB); +if (version ==XGENE_SLIMPRO_I2C_V2 ) + ctx->pcc_comm_addr = (void __force*)ioremap(
+ ctx-Quoted 1 line
comm_base_addr,+ cppc_ss-
Quoted 1 line
length);
Quoted 7 lines
Commit message actually doesn't explain why we switch to iomap over memmap.
(
__forcehere is obviously to suppress__iomapannotation for mapped memory)If you need non-cacheable
MEMREMAP_WTI guess will do a job.
Yes, I can switch to MEMREMAP_WT.
I'm going to send out another patch soon.
Thanks
Hoan
Quoted 13 lines
Quoted 9 lines
Quoted 9 lines
drivers/i2c/busses/i2c-xgene-slimpro.c +3
-0+else + ctx->pcc_comm_addr = memremap( + ctx-Quoted 1 line
comm_base_addr,+ cppc_ss-
Quoted 1 line
length,
+
MEMREMAP_WB
);--
Andy Shevchenko <[email protected]> Intel Finland Oy