* [PATCH] i2c: xgene-slimpro: Support v2
@ 2017-10-23 22:12 Hoan Tran
2017-10-28 12:11 ` Wolfram Sang
0 siblings, 1 reply; 5+ messages in thread
From: Hoan Tran @ 2017-10-23 22:12 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-i2c, linux-kernel, Loc Ho, patches, 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 <hotran@apm.com>
---
drivers/i2c/busses/i2c-xgene-slimpro.c | 45 +++++++++++++++++++++++++---------
1 file changed, 34 insertions(+), 11 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c b/drivers/i2c/busses/i2c-xgene-slimpro.c
index 7e89ba6..31314d8 100644
--- a/drivers/i2c/busses/i2c-xgene-slimpro.c
+++ b/drivers/i2c/busses/i2c-xgene-slimpro.c
@@ -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,
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: xgene-slimpro: Support v2
2017-10-23 22:12 [PATCH] i2c: xgene-slimpro: Support v2 Hoan Tran
@ 2017-10-28 12:11 ` Wolfram Sang
2017-10-28 19:37 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2017-10-28 12:11 UTC (permalink / raw)
To: Hoan Tran, Andy Shevchenko; +Cc: linux-i2c, linux-kernel, Loc Ho, patches
[-- Attachment #1: Type: text/plain, Size: 3377 bytes --]
Thanks for the patch!
On Mon, Oct 23, 2017 at 03:12:20PM -0700, Hoan Tran wrote:
> This patch supports xgene-slimpro-i2c v2 which uses the non-cachable memory
> as the PCC shared memory.
>
> Signed-off-by: Hoan Tran <hotran@apm.com>
I can't tell if __force is justified here but I don't know much about
ACPI... Andy, can you have a look?
> ---
> drivers/i2c/busses/i2c-xgene-slimpro.c | 45 +++++++++++++++++++++++++---------
> 1 file changed, 34 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c b/drivers/i2c/busses/i2c-xgene-slimpro.c
> index 7e89ba6..31314d8 100644
> --- a/drivers/i2c/busses/i2c-xgene-slimpro.c
> +++ b/drivers/i2c/busses/i2c-xgene-slimpro.c
> @@ -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,
> --
> 1.9.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: xgene-slimpro: Support v2
2017-10-28 12:11 ` Wolfram Sang
@ 2017-10-28 19:37 ` Andy Shevchenko
2017-10-28 19:56 ` Wolfram Sang
2017-10-30 21:33 ` Hoan Tran
0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2017-10-28 19:37 UTC (permalink / raw)
To: Wolfram Sang, Hoan Tran; +Cc: linux-i2c, linux-kernel, Loc Ho, patches
On Sat, 2017-10-28 at 14:11 +0200, Wolfram Sang wrote:
> Thanks for the patch!
>
> On Mon, Oct 23, 2017 at 03:12:20PM -0700, Hoan Tran wrote:
> > This patch supports xgene-slimpro-i2c v2 which uses the non-cachable
> > memory
> > as the PCC shared memory.
> >
> > Signed-off-by: Hoan Tran <hotran@apm.com>
>
> I can't tell if __force is justified here but I don't know much about
> ACPI... Andy, can you have a look?
Few comments to the patch as well.
> > +#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...
> > +
> > 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?
> > + 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.
> > + &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-
> > >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);
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.
> > + else
> > + ctx->pcc_comm_addr = memremap(
> > + ctx-
> > >comm_base_addr,
> > + cppc_ss-
> > >length,
> > + MEMREMAP_WB
> > );
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: xgene-slimpro: Support v2
2017-10-28 19:37 ` Andy Shevchenko
@ 2017-10-28 19:56 ` Wolfram Sang
2017-10-30 21:33 ` Hoan Tran
1 sibling, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2017-10-28 19:56 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Hoan Tran, linux-i2c, linux-kernel, Loc Ho, patches
[-- Attachment #1: Type: text/plain, Size: 224 bytes --]
> > I can't tell if __force is 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 :)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: xgene-slimpro: Support v2
2017-10-28 19:37 ` Andy Shevchenko
2017-10-28 19:56 ` Wolfram Sang
@ 2017-10-30 21:33 ` Hoan Tran
1 sibling, 0 replies; 5+ messages in thread
From: Hoan Tran @ 2017-10-30 21:33 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Wolfram Sang, linux-i2c, lkml, Loc Ho, patches
Hi Andy,
On Sat, Oct 28, 2017 at 12:37 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Sat, 2017-10-28 at 14:11 +0200, Wolfram Sang wrote:
>> Thanks for the patch!
>>
>> On Mon, Oct 23, 2017 at 03:12:20PM -0700, Hoan Tran wrote:
>> > This patch supports xgene-slimpro-i2c v2 which uses the non-cachable
>> > memory
>> > as the PCC shared memory.
>> >
>> > Signed-off-by: Hoan Tran <hotran@apm.com>
>>
>> I can't tell if __force is justified here but I don't know much about
>> ACPI... Andy, can you have a look?
>
> Few comments to the patch as well.
>
>> > +#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...
>
>> > +
>> > 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?
>
>> > + 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.
>
>> > + &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-
>> > >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);
>
> 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.
Yes, I can switch to MEMREMAP_WT.
I'm going to send out another patch soon.
Thanks
Hoan
>
>> > + else
>> > + ctx->pcc_comm_addr = memremap(
>> > + ctx-
>> > >comm_base_addr,
>> > + cppc_ss-
>> > >length,
>> > + MEMREMAP_WB
>> > );
>
> --
> Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Intel Finland Oy
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-30 21:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-23 22:12 [PATCH] i2c: xgene-slimpro: Support v2 Hoan Tran
2017-10-28 12:11 ` Wolfram Sang
2017-10-28 19:37 ` Andy Shevchenko
2017-10-28 19:56 ` Wolfram Sang
2017-10-30 21:33 ` Hoan Tran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).