Re: [PATCH v3] mfd: kempld-core: Check for DMI definition before ACPI

2020-11-30 Thread Michael Brunner
On Fri, 2020-11-27 at 07:53 +, Lee Jones wrote:
> On Mon, 16 Nov 2020, Michael Brunner wrote:
> 
> > Change the detection order to priorize DMI table entries over
> > available
> > ACPI entries.
> > 
> > This makes it more easy for product developers to patch product
> > specific
> > handling into the driver.
> > Furthermore it allows to simplify the implementation a bit and
> > especially to remove the need to force synchronous probing.
> > 
> > Signed-off-by: Michael Brunner 
> > Reviewed-by: Guenter Roeck 
> > ---
> > 
> > v3: Cleaned up comment, added Reviewed-by
> > 
> >  drivers/mfd/kempld-core.c | 24 +++-
> >  1 file changed, 3 insertions(+), 21 deletions(-)
> 
> Nit: Just letting you know that checkpatch.pl complains about your
> patches, since your From: address does not match your SoB one.
> 
> Patch applied though, thanks.

Thanks!

Regarding the From - I guess it is because the upper-case letters. I
will check how to fix this for the next time. In the worst case I guess
I have to adapt the SoB.


[PATCH v2] mfd: kempld-core: Add support for additional devices

2020-11-23 Thread Michael Brunner
This update includes DMI IDs for the following Kontron modules and
systems:
COMe-bDV7, COMe-cDV7, COMe-m4AL, COMe-mCT10, SMARC-sXAL, SMARC-sXA4,
Qseven-Q7AL, mITX-APL, pITX-APL and KBox A-203

Furthermore the ACPI HID KEM is added, as it is also reserved for
kempld devices.

Instead of also adding the newly supported devices to the Kconfig
description this patch removes the lengthy list. With future usage of
the ACPI HIDs it will not be necessary to explicitly add support for
each individual device to the driver and therefore the list would
become incomplete anyway.

Signed-off-by: Michael Brunner 
---

 v2: Corrected a board name, only use 4 digits for IDs

 drivers/mfd/Kconfig   | 30 ++--
 drivers/mfd/kempld-core.c | 76 +--
 2 files changed, 77 insertions(+), 29 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 8b99a13669bf..befd19da8562 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -720,33 +720,9 @@ config MFD_KEMPLD
select MFD_CORE
help
  This is the core driver for the PLD (Programmable Logic Device) found
- on some Kontron ETX and COMexpress (ETXexpress) modules. The PLD
- device may provide functions like watchdog, GPIO, UART and I2C bus.
-
- The following modules are supported:
-   * COMe-bBD#
-   * COMe-bBL6
-   * COMe-bHL6
-   * COMe-bSL6
-   * COMe-bIP#
-   * COMe-bKL6
-   * COMe-bPC2 (ETXexpress-PC)
-   * COMe-bSC# (ETXexpress-SC T#)
-   * COMe-cAL6
-   * COMe-cBL6
-   * COMe-cBT6
-   * COMe-cBW6
-   * COMe-cCT6
-   * COMe-cDC2 (microETXexpress-DC)
-   * COMe-cHL6
-   * COMe-cKL6
-   * COMe-cPC2 (microETXexpress-PC)
-   * COMe-cSL6
-   * COMe-mAL10
-   * COMe-mBT10
-   * COMe-mCT10
-   * COMe-mTT10 (nanoETXexpress-TT)
-   * ETX-OH
+ on some Kontron ETX and nearly all COMexpress (ETXexpress) modules as
+ well as on some other Kontron products. The PLD device may provide
+ functions like watchdog, GPIO, UART and I2C bus.
 
  This driver can also be built as a module. If so, the module
  will be called kempld-core.
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index ecd26271b9a4..9166075c1f32 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -552,6 +552,7 @@ static int kempld_remove(struct platform_device *pdev)
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id kempld_acpi_table[] = {
+   { "KEM", (kernel_ulong_t)_platform_data_generic },
{ "KEM0001", (kernel_ulong_t)_platform_data_generic },
{}
 };
@@ -584,6 +585,14 @@ static const struct dmi_system_id kempld_dmi_table[] 
__initconst = {
},
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
+   }, {
+   .ident = "BDV7",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bDV7"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
}, {
.ident = "BHL6",
.matches = {
@@ -648,6 +657,14 @@ static const struct dmi_system_id kempld_dmi_table[] 
__initconst = {
},
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
+   }, {
+   .ident = "CDV7",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cDV7"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
}, {
.ident = "CHL6",
.matches = {
@@ -767,6 +784,22 @@ static const struct dmi_system_id kempld_dmi_table[] 
__initconst = {
},
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
+   }, {
+   .ident = "A203",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "KBox A-203"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
+   .ident = "M4A1",
+

[PATCH] mfd: kempld-core: Add support for additional devices

2020-11-17 Thread Michael Brunner
This update includes DMI IDs for the following Kontron modules and
systems:
COMe-bDV7, COMe-cDV7, COMe-m4AL, COMe-mCT10, SMARC-sXAL, SMARC-sXA4,
Qseven-Q7AL, mITX-APL, pITX-APL and KBox A-203

Furthermore the ACPI HID KEM is added, as it is also reserved for
kempld devices.

Instead of also adding the newly supported devices to the Kconfig
description this patch removes the lengthy list. With future usage of
the ACPI HIDs it will not be necessary to explicitly add support for
each individual device to the driver and therefore the list would
become incomplete anyway.

Signed-off-by: Michael Brunner 
---
 drivers/mfd/Kconfig   | 30 ++--
 drivers/mfd/kempld-core.c | 76 +--
 2 files changed, 77 insertions(+), 29 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 8b99a13669bf..befd19da8562 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -720,33 +720,9 @@ config MFD_KEMPLD
select MFD_CORE
help
  This is the core driver for the PLD (Programmable Logic Device) found
- on some Kontron ETX and COMexpress (ETXexpress) modules. The PLD
- device may provide functions like watchdog, GPIO, UART and I2C bus.
-
- The following modules are supported:
-   * COMe-bBD#
-   * COMe-bBL6
-   * COMe-bHL6
-   * COMe-bSL6
-   * COMe-bIP#
-   * COMe-bKL6
-   * COMe-bPC2 (ETXexpress-PC)
-   * COMe-bSC# (ETXexpress-SC T#)
-   * COMe-cAL6
-   * COMe-cBL6
-   * COMe-cBT6
-   * COMe-cBW6
-   * COMe-cCT6
-   * COMe-cDC2 (microETXexpress-DC)
-   * COMe-cHL6
-   * COMe-cKL6
-   * COMe-cPC2 (microETXexpress-PC)
-   * COMe-cSL6
-   * COMe-mAL10
-   * COMe-mBT10
-   * COMe-mCT10
-   * COMe-mTT10 (nanoETXexpress-TT)
-   * ETX-OH
+ on some Kontron ETX and nearly all COMexpress (ETXexpress) modules as
+ well as on some other Kontron products. The PLD device may provide
+ functions like watchdog, GPIO, UART and I2C bus.
 
  This driver can also be built as a module. If so, the module
  will be called kempld-core.
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index ecd26271b9a4..4ea0ecd45324 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -552,6 +552,7 @@ static int kempld_remove(struct platform_device *pdev)
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id kempld_acpi_table[] = {
+   { "KEM", (kernel_ulong_t)_platform_data_generic },
{ "KEM0001", (kernel_ulong_t)_platform_data_generic },
{}
 };
@@ -584,6 +585,14 @@ static const struct dmi_system_id kempld_dmi_table[] 
__initconst = {
},
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
+   }, {
+   .ident = "BDV7",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bDV7"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
}, {
.ident = "BHL6",
.matches = {
@@ -648,6 +657,14 @@ static const struct dmi_system_id kempld_dmi_table[] 
__initconst = {
},
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
+   }, {
+   .ident = "CDV7",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cDV7"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
}, {
.ident = "CHL6",
.matches = {
@@ -767,6 +784,22 @@ static const struct dmi_system_id kempld_dmi_table[] 
__initconst = {
},
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
+   }, {
+   .ident = "KBOXA203",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "KBox A-203"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
+   .ident = "M4A1",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron&qu

Re: [PATCH v2] mfd: kempld-core: Check for DMI definition before ACPI

2020-11-15 Thread Michael Brunner
On Fri, 2020-11-13 at 10:16 +, Lee Jones wrote:
> On Tue, 10 Nov 2020, Michael Brunner wrote:
> 
> > Change the detection order to priorize DMI table entries over
> > available
> > ACPI entries.
> > 
> > This makes it more easy for product developers to patch product
> > specific
> > handling into the driver.
> > Furthermore it allows to simplify the implementation a bit and
> > especially to remove the need to force synchronous probing.
> > Based on the following commit introduced with v5.10-rc1:
> > commit e8299c7313af ("mfd: Add ACPI support to Kontron PLD driver")
> 
> This section should also be removed from the change log.

No problem, just sent v3.

Thanks,
  Michael


[PATCH v3] mfd: kempld-core: Check for DMI definition before ACPI

2020-11-15 Thread Michael Brunner
Change the detection order to priorize DMI table entries over available
ACPI entries.

This makes it more easy for product developers to patch product specific
handling into the driver.
Furthermore it allows to simplify the implementation a bit and
especially to remove the need to force synchronous probing.

Signed-off-by: Michael Brunner 
Reviewed-by: Guenter Roeck 
---

v3: Cleaned up comment, added Reviewed-by

 drivers/mfd/kempld-core.c | 24 +++-
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 2c9295953c11..ecd26271b9a4 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -125,7 +125,6 @@ static const struct kempld_platform_data 
kempld_platform_data_generic = {
 };
 
 static struct platform_device *kempld_pdev;
-static bool kempld_acpi_mode;
 
 static int kempld_create_platform_device(const struct dmi_system_id *id)
 {
@@ -501,8 +500,6 @@ static int kempld_probe(struct platform_device *pdev)
ret = kempld_get_acpi_data(pdev);
if (ret)
return ret;
-
-   kempld_acpi_mode = true;
} else if (kempld_pdev != pdev) {
/*
 * The platform device we are probing is not the one we
@@ -565,7 +562,6 @@ static struct platform_driver kempld_driver = {
.driver = {
.name   = "kempld",
.acpi_match_table = ACPI_PTR(kempld_acpi_table),
-   .probe_type = PROBE_FORCE_SYNCHRONOUS,
},
.probe  = kempld_probe,
.remove = kempld_remove,
@@ -884,7 +880,6 @@ MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
 static int __init kempld_init(void)
 {
const struct dmi_system_id *id;
-   int ret;
 
if (force_device_id[0]) {
for (id = kempld_dmi_table;
@@ -894,24 +889,11 @@ static int __init kempld_init(void)
break;
if (id->matches[0].slot == DMI_NONE)
return -ENODEV;
-   }
-
-   ret = platform_driver_register(_driver);
-   if (ret)
-   return ret;
-
-   /*
-* With synchronous probing the device should already be probed now.
-* If no device id is forced and also no ACPI definition for the
-* device was found, scan DMI table as fallback.
-*
-* If drivers_autoprobing is disabled and the device is found here,
-* only that device can be bound manually later.
-*/
-   if (!kempld_pdev && !kempld_acpi_mode)
+   } else {
dmi_check_system(kempld_dmi_table);
+   }
 
-   return 0;
+   return platform_driver_register(_driver);
 }
 
 static void __exit kempld_exit(void)
-- 
2.25.1



Re: [PATCH] mfd: kempld-core: Check for DMI definition before ACPI

2020-11-10 Thread Michael Brunner
Hi Guenter,

thank you for the feedback! checkpatch didn't catch this.
I sent v2 of the patch.

Best regards,
  Michael

On Tue, 2020-11-10 at 06:39 -0800, Guenter Roeck wrote:
> On 11/9/20 11:46 PM, Michael Brunner wrote:
> > Change the detection order to priorize DMI table entries over
> > available
> > ACPI entries.
> > 
> > This makes it more easy for product developers to patch product
> > specific
> > handling into the driver.
> > Furthermore it allows to simplify the implementation a bit and
> > especially to remove the need to force synchronous probing.
> > 
> > Based on the following commit introduced with v5.10-rc1:
> > commit e8299c7313af ("mfd: Add ACPI support to Kontron PLD driver")
> > 
> > Signed-off-by: Michael Brunner 
> > ---
> >  drivers/mfd/kempld-core.c | 23 ++-
> >  1 file changed, 2 insertions(+), 21 deletions(-)
> > 
> > diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
> > index 2c9295953c11..aa7f386646a1 100644
> > --- a/drivers/mfd/kempld-core.c
> > +++ b/drivers/mfd/kempld-core.c
> > @@ -125,7 +125,6 @@ static const struct kempld_platform_data
> > kempld_platform_data_generic = {
> >  };
> >  
> >  static struct platform_device *kempld_pdev;
> > -static bool kempld_acpi_mode;
> >  
> >  static int kempld_create_platform_device(const struct
> > dmi_system_id *id)
> >  {
> > @@ -501,8 +500,6 @@ static int kempld_probe(struct platform_device
> > *pdev)
> > ret = kempld_get_acpi_data(pdev);
> > if (ret)
> > return ret;
> > -
> > -   kempld_acpi_mode = true;
> > } else if (kempld_pdev != pdev) {
> > /*
> >  * The platform device we are probing is not the one we
> > @@ -565,7 +562,6 @@ static struct platform_driver kempld_driver = {
> > .driver = {
> > .name   = "kempld",
> > .acpi_match_table = ACPI_PTR(kempld_acpi_table),
> > -   .probe_type = PROBE_FORCE_SYNCHRONOUS,
> > },
> > .probe  = kempld_probe,
> > .remove = kempld_remove,
> > @@ -884,7 +880,6 @@ MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
> >  static int __init kempld_init(void)
> >  {
> > const struct dmi_system_id *id;
> > -   int ret;
> >  
> > if (force_device_id[0]) {
> > for (id = kempld_dmi_table;
> > @@ -894,24 +889,10 @@ static int __init kempld_init(void)
> > break;
> > if (id->matches[0].slot == DMI_NONE)
> > return -ENODEV;
> > -   }
> > -
> > -   ret = platform_driver_register(_driver);
> > -   if (ret)
> > -   return ret;
> > -
> > -   /*
> > -* With synchronous probing the device should already be probed
> > now.
> > -* If no device id is forced and also no ACPI definition for
> > the
> > -* device was found, scan DMI table as fallback.
> > -*
> > -* If drivers_autoprobing is disabled and the device is found
> > here,
> > -* only that device can be bound manually later.
> > -*/
> > -   if (!kempld_pdev && !kempld_acpi_mode)
> > +   } else
> 
>   } else {
> > dmi_check_system(kempld_dmi_table);
>   }
> 
> Guenter
> 
> >  
> > -   return 0;
> > +   return platform_driver_register(_driver);
> >  }
> >  
> >  static void __exit kempld_exit(void)
> > 


[PATCH v2] mfd: kempld-core: Check for DMI definition before ACPI

2020-11-10 Thread Michael Brunner
Change the detection order to priorize DMI table entries over available
ACPI entries.

This makes it more easy for product developers to patch product specific
handling into the driver.
Furthermore it allows to simplify the implementation a bit and
especially to remove the need to force synchronous probing.

Based on the following commit introduced with v5.10-rc1:
commit e8299c7313af ("mfd: Add ACPI support to Kontron PLD driver")

v2: Fixed coding style as suggested by Guenther Roeck

Signed-off-by: Michael Brunner 
---
 drivers/mfd/kempld-core.c | 24 +++-
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 2c9295953c11..ecd26271b9a4 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -125,7 +125,6 @@ static const struct kempld_platform_data 
kempld_platform_data_generic = {
 };
 
 static struct platform_device *kempld_pdev;
-static bool kempld_acpi_mode;
 
 static int kempld_create_platform_device(const struct dmi_system_id *id)
 {
@@ -501,8 +500,6 @@ static int kempld_probe(struct platform_device *pdev)
ret = kempld_get_acpi_data(pdev);
if (ret)
return ret;
-
-   kempld_acpi_mode = true;
} else if (kempld_pdev != pdev) {
/*
 * The platform device we are probing is not the one we
@@ -565,7 +562,6 @@ static struct platform_driver kempld_driver = {
.driver = {
.name   = "kempld",
.acpi_match_table = ACPI_PTR(kempld_acpi_table),
-   .probe_type = PROBE_FORCE_SYNCHRONOUS,
},
.probe  = kempld_probe,
.remove = kempld_remove,
@@ -884,7 +880,6 @@ MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
 static int __init kempld_init(void)
 {
const struct dmi_system_id *id;
-   int ret;
 
if (force_device_id[0]) {
for (id = kempld_dmi_table;
@@ -894,24 +889,11 @@ static int __init kempld_init(void)
break;
if (id->matches[0].slot == DMI_NONE)
return -ENODEV;
-   }
-
-   ret = platform_driver_register(_driver);
-   if (ret)
-   return ret;
-
-   /*
-* With synchronous probing the device should already be probed now.
-* If no device id is forced and also no ACPI definition for the
-* device was found, scan DMI table as fallback.
-*
-* If drivers_autoprobing is disabled and the device is found here,
-* only that device can be bound manually later.
-*/
-   if (!kempld_pdev && !kempld_acpi_mode)
+   } else {
dmi_check_system(kempld_dmi_table);
+   }
 
-   return 0;
+   return platform_driver_register(_driver);
 }
 
 static void __exit kempld_exit(void)
-- 
2.25.1



[PATCH] mfd: kempld-core: Check for DMI definition before ACPI

2020-11-09 Thread Michael Brunner
Change the detection order to priorize DMI table entries over available
ACPI entries.

This makes it more easy for product developers to patch product specific
handling into the driver.
Furthermore it allows to simplify the implementation a bit and
especially to remove the need to force synchronous probing.

Based on the following commit introduced with v5.10-rc1:
commit e8299c7313af ("mfd: Add ACPI support to Kontron PLD driver")

Signed-off-by: Michael Brunner 
---
 drivers/mfd/kempld-core.c | 23 ++-
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 2c9295953c11..aa7f386646a1 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -125,7 +125,6 @@ static const struct kempld_platform_data 
kempld_platform_data_generic = {
 };
 
 static struct platform_device *kempld_pdev;
-static bool kempld_acpi_mode;
 
 static int kempld_create_platform_device(const struct dmi_system_id *id)
 {
@@ -501,8 +500,6 @@ static int kempld_probe(struct platform_device *pdev)
ret = kempld_get_acpi_data(pdev);
if (ret)
return ret;
-
-   kempld_acpi_mode = true;
} else if (kempld_pdev != pdev) {
/*
 * The platform device we are probing is not the one we
@@ -565,7 +562,6 @@ static struct platform_driver kempld_driver = {
.driver = {
.name   = "kempld",
.acpi_match_table = ACPI_PTR(kempld_acpi_table),
-   .probe_type = PROBE_FORCE_SYNCHRONOUS,
},
.probe  = kempld_probe,
.remove = kempld_remove,
@@ -884,7 +880,6 @@ MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
 static int __init kempld_init(void)
 {
const struct dmi_system_id *id;
-   int ret;
 
if (force_device_id[0]) {
for (id = kempld_dmi_table;
@@ -894,24 +889,10 @@ static int __init kempld_init(void)
break;
if (id->matches[0].slot == DMI_NONE)
return -ENODEV;
-   }
-
-   ret = platform_driver_register(_driver);
-   if (ret)
-   return ret;
-
-   /*
-* With synchronous probing the device should already be probed now.
-* If no device id is forced and also no ACPI definition for the
-* device was found, scan DMI table as fallback.
-*
-* If drivers_autoprobing is disabled and the device is found here,
-* only that device can be bound manually later.
-*/
-   if (!kempld_pdev && !kempld_acpi_mode)
+   } else
dmi_check_system(kempld_dmi_table);
 
-   return 0;
+   return platform_driver_register(_driver);
 }
 
 static void __exit kempld_exit(void)
-- 
2.25.1



Re: [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused

2020-10-06 Thread Michael Brunner
On Tue, 2020-10-06 at 07:53 +0100, Lee Jones wrote:
> On Mon, 05 Oct 2020, Michael Brunner wrote:
> 
> > On Fri, 2020-10-02 at 08:01 +0100, Lee Jones wrote:
> > > On Thu, 01 Oct 2020, Michael Brunner wrote:
> > > 
> > > > The Intel 0-DAY CI Kernel Test Service reports an unused variable
> > > > warning when compiling with clang for PowerPC:
> > > > 
> > > > > > drivers/mfd/kempld-core.c:556:36: warning: unused variable
> > > > > > 'kempld_acpi_table' [-Wunused-const-variable]
> > > >static const struct acpi_device_id kempld_acpi_table[] = {
> > > > 
> > > > The issue can be fixed by marking kempld_acpi_table as
> > > > __maybe_unused.
> > > > 
> > > > Fixes: e8299c7313af ("[PATCH] mfd: Add ACPI support to Kontron PLD
> > > > driver")
> > > > 
> > > > Reported-by: kernel test robot 
> > > > Signed-off-by: Michael Brunner 
> > > > ---
> > > >  drivers/mfd/kempld-core.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
> > > > index 1dfe556df038..273481dfaad4 100644
> > > > --- a/drivers/mfd/kempld-core.c
> > > > +++ b/drivers/mfd/kempld-core.c
> > > > @@ -553,7 +553,7 @@ static int kempld_remove(struct platform_device
> > > > *pdev)
> > > > return 0;
> > > >  }
> > > >  
> > > > -static const struct acpi_device_id kempld_acpi_table[] = {
> > > > +static const struct acpi_device_id __maybe_unused
> > > > kempld_acpi_table[] = {
> > > > { "KEM0001", (kernel_ulong_t)_platform_data_generic },
> > > > {}
> > > >  };
> > > 
> > > This is not the right fix.  Better just to compile it out completely
> > > in these circumstances.  I already have a fix for this in soak.
> > 
> > Ok - thank you for the other fix you submitted!
> > 
> > But just out of curiosity - in process/coding-style.rst is written that
> > __maybe_unused should be preferred over wrapping in preprocessor
> > conditionals, if a function or variable may potentially go unused in a
> > particular configuration. So why is my patch not the right one here? At
> > least in my tests it seemed to solve the issue.
> 
> It's a bone of contention for sure.  In these kinds of scenarios
> (i.e. ACPI and OF tables) it is way more common to wrap them:
> 
> $ git grep -B3 'acpi_device_id\|of_device_id' | grep 'CONFIG_ACPI\|CONFIG_OF' 
> | wc -l
> 596
> $ git grep -B3 'acpi_device_id\|of_device_id' | grep __maybe_unused | wc -l
> 63
> 
> Parsing them out completely, also has the benefit of saving space,
> reducing the size of the finalised binary.

Doesn't the compiler remove it anyway? At least in my test I didn't see
a difference in the resulting object files.
Doing a crosscheck, by adding __attribute__((used)) to the definition
of kempld_acpi_table, the object file size increased and
kempld_acpi_table showed up in the symbol table.

Nevertheless, I don't want to start a discussion. I am fine with using
the preprocessor. Just wanted to make sure I understand the technical
implications of both solutions.
Thank you for your time!

Best regards,
  Michael





Re: [PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused

2020-10-05 Thread Michael Brunner
On Fri, 2020-10-02 at 08:01 +0100, Lee Jones wrote:
> On Thu, 01 Oct 2020, Michael Brunner wrote:
> 
> > The Intel 0-DAY CI Kernel Test Service reports an unused variable
> > warning when compiling with clang for PowerPC:
> > 
> > > > drivers/mfd/kempld-core.c:556:36: warning: unused variable
> > > > 'kempld_acpi_table' [-Wunused-const-variable]
> >static const struct acpi_device_id kempld_acpi_table[] = {
> > 
> > The issue can be fixed by marking kempld_acpi_table as
> > __maybe_unused.
> > 
> > Fixes: e8299c7313af ("[PATCH] mfd: Add ACPI support to Kontron PLD
> > driver")
> > 
> > Reported-by: kernel test robot 
> > Signed-off-by: Michael Brunner 
> > ---
> >  drivers/mfd/kempld-core.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
> > index 1dfe556df038..273481dfaad4 100644
> > --- a/drivers/mfd/kempld-core.c
> > +++ b/drivers/mfd/kempld-core.c
> > @@ -553,7 +553,7 @@ static int kempld_remove(struct platform_device
> > *pdev)
> > return 0;
> >  }
> >  
> > -static const struct acpi_device_id kempld_acpi_table[] = {
> > +static const struct acpi_device_id __maybe_unused
> > kempld_acpi_table[] = {
> > { "KEM0001", (kernel_ulong_t)_platform_data_generic },
> > {}
> >  };
> 
> This is not the right fix.  Better just to compile it out completely
> in these circumstances.  I already have a fix for this in soak.

Ok - thank you for the other fix you submitted!

But just out of curiosity - in process/coding-style.rst is written that
__maybe_unused should be preferred over wrapping in preprocessor
conditionals, if a function or variable may potentially go unused in a
particular configuration. So why is my patch not the right one here? At
least in my tests it seemed to solve the issue.

Thanks,
  Michael


[PATCH] mfd: kempld-core: Mark kempld-acpi_table as __maybe_unused

2020-10-01 Thread Michael Brunner
The Intel 0-DAY CI Kernel Test Service reports an unused variable
warning when compiling with clang for PowerPC:

>> drivers/mfd/kempld-core.c:556:36: warning: unused variable 
>> 'kempld_acpi_table' [-Wunused-const-variable]
   static const struct acpi_device_id kempld_acpi_table[] = {

The issue can be fixed by marking kempld_acpi_table as __maybe_unused.

Fixes: e8299c7313af ("[PATCH] mfd: Add ACPI support to Kontron PLD driver")

Reported-by: kernel test robot 
Signed-off-by: Michael Brunner 
---
 drivers/mfd/kempld-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 1dfe556df038..273481dfaad4 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -553,7 +553,7 @@ static int kempld_remove(struct platform_device *pdev)
return 0;
 }
 
-static const struct acpi_device_id kempld_acpi_table[] = {
+static const struct acpi_device_id __maybe_unused kempld_acpi_table[] = {
{ "KEM0001", (kernel_ulong_t)_platform_data_generic },
{}
 };
-- 
2.25.1



[PATCH v2] mfd: Add ACPI support to Kontron PLD driver

2020-08-20 Thread Michael Brunner
Recent Kontron COMe modules identify the PLD device using the hardware
id KEM0001 in the ACPI table.
This patch adds support for probing the device using the HID and also
retrieving the resources.

As this is not available for all products, the DMI based detection still
needs to be around for older systems. It is executed if no matching ACPI
HID is found during registering the platform driver or no specific
device id is forced.
If a device is detected using ACPI and no resource information is
available, the default io resource is used.

Forcing a device id with the force_device_id parameter and therefore
manually generating a platform device takes precedence over ACPI during
probing.

v2: - Implemented code changes suggested by Lee Jones
- Added comments explaining some critical code
- Driver is no longer unregistered if probing is skipped during
  platform_driver_register and device is not found in DMI table
- Set probe type to PROBE_FORCE_SYNCHRONOUS to make clear this is
  the expected behaviour for this code to work as expected

Signed-off-by: Michael Brunner 
---
 drivers/mfd/kempld-core.c | 115 --
 1 file changed, 109 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index f48e21d8b97c..0bb6d621112c 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MAX_ID_LEN 4
 static char force_device_id[MAX_ID_LEN + 1] = "";
@@ -132,6 +133,7 @@ static const struct kempld_platform_data 
kempld_platform_data_generic = {
 };
 
 static struct platform_device *kempld_pdev;
+static bool kempld_acpi_mode;
 
 static int kempld_create_platform_device(const struct dmi_system_id *id)
 {
@@ -434,13 +436,93 @@ static int kempld_detect_device(struct kempld_device_data 
*pld)
return ret;
 }
 
+#ifdef CONFIG_ACPI
+static int kempld_get_acpi_data(struct platform_device *pdev)
+{
+   struct list_head resource_list;
+   struct resource *resources;
+   struct resource_entry *rentry;
+   struct device *dev = >dev;
+   struct acpi_device *acpi_dev = ACPI_COMPANION(dev);
+   const struct kempld_platform_data *pdata;
+   int ret;
+   int count;
+
+   pdata = acpi_device_get_match_data(dev);
+   ret = platform_device_add_data(pdev, pdata,
+  sizeof(struct kempld_platform_data));
+   if (ret)
+   return ret;
+
+   INIT_LIST_HEAD(_list);
+   ret = acpi_dev_get_resources(acpi_dev, _list, NULL, NULL);
+   if (ret < 0)
+   goto out;
+
+   count = ret;
+
+   if (count == 0) {
+   ret = platform_device_add_resources(pdev, pdata->ioresource, 1);
+   goto out;
+   }
+
+   resources = devm_kcalloc(_dev->dev, count, sizeof(*resources),
+GFP_KERNEL);
+   if (!resources) {
+   ret = -ENOMEM;
+   goto out;
+   }
+
+   count = 0;
+   list_for_each_entry(rentry, _list, node) {
+   memcpy([count], rentry->res,
+  sizeof(*resources));
+   count++;
+   }
+   ret = platform_device_add_resources(pdev, resources, count);
+
+out:
+   acpi_dev_free_resource_list(_list);
+
+   return ret;
+}
+#else
+static int kempld_get_acpi_data(struct platform_device *pdev)
+{
+   return -ENODEV;
+}
+#endif /* CONFIG_ACPI */
+
 static int kempld_probe(struct platform_device *pdev)
 {
-   const struct kempld_platform_data *pdata =
-   dev_get_platdata(>dev);
+   const struct kempld_platform_data *pdata;
struct device *dev = >dev;
struct kempld_device_data *pld;
struct resource *ioport;
+   int ret;
+
+   if (kempld_pdev == NULL) {
+   /*
+* No kempld_pdev device has been registered in kempld_init,
+* so we seem to be probing an ACPI platform device.
+*/
+   ret = kempld_get_acpi_data(pdev);
+   if (ret)
+   return ret;
+
+   kempld_acpi_mode = true;
+   } else if (kempld_pdev != pdev) {
+   /*
+* The platform device we are probing is not the one we
+* registered in kempld_init using the DMI table, so this one
+* comes from ACPI.
+* As we can only probe one - abort here and use the DMI
+* based one instead.
+*/
+   dev_notice(dev, "platform device exists - not using ACPI\n");
+   return -ENODEV;
+   }
+   pdata = dev_get_platdata(dev);
 
pld = devm_kzalloc(dev, sizeof(*pld), GFP_KERNEL);
if (!pld)
@@ -479,9 +561,17 @@ static int kempld_remove(struct platform_device *pdev)
return 0;
 }
 
+static cons

Re: [PATCH] mfd: Add ACPI support to Kontron PLD driver

2020-08-20 Thread Michael Brunner
Thank you for taking the time to review the patch!
Additional comments below, patch v2 will follow.

On Wed, 2020-08-19 at 11:15 +0100, Lee Jones wrote:
> On Wed, 12 Aug 2020, Michael Brunner wrote:
... 
> > +#ifdef CONFIG_ACPI
> 
> Not keen on #ifdefery if at all avoidable.
> 
> Can you use if (IS_ENABLED(CONFIG_ACPI)) at the call-site instead?
> 
> The compiler should take care of the rest, no?

Unfortunately acpi_dev_get_resources is not defined when compiling with
CONFIG_ACPI disabled, therefore #ifdef seems to be the only choice.

> > +static const struct acpi_device_id kempld_acpi_table[] = {
> > +   { "KEM0001", (kernel_ulong_t)_platform_data_generic },
> > +   {}
> > +};
> > +MODULE_DEVICE_TABLE(acpi, kempld_acpi_table);
>
> I'd prefer if this was moved down to just above where it's used
> i.e. where we usually place the of_device_id tables.

No problem, will update this.

...
> > +   INIT_LIST_HEAD(_list);
> > +   ret = acpi_dev_get_resources(acpi_dev, _list, NULL,
> > NULL);
> > +   if (ret < 0)
> > +   goto out;
> > +
> > +   count = ret;
> 
>   if (count == 0) {
>   ret = platform_device_add_resources(pdev, pdata-
> >ioresource, 1);
>   goto out;
>   }
> 
> Then drop the next check and pull the indented code back:

Agreed, looks better.

> > +   if (count > 0) {
> > +   resources = devm_kcalloc(_dev->dev, count,
> > + sizeof(struct resource),
> > GFP_KERNEL);
> 
> sizeof(*resources) is preferred.

Ok

...
> >  static int kempld_probe(struct platform_device *pdev)
> >  {
> > -   const struct kempld_platform_data *pdata =
> > -   dev_get_platdata(>dev);
> > +   const struct kempld_platform_data *pdata;
> > struct device *dev = >dev;
> > struct kempld_device_data *pld;
> > struct resource *ioport;
> > +   int ret;
> > +
> > +   if (kempld_pdev == NULL) {
> 
> Comment please.  What does !kempld_pdev actually imply?

If kempld_pdev is not defined, this means no platform device has been
created using the DMI id table and we are currently probing the ACPI
based platform device.
Will add a comment to the code.

> > +   ret = kempld_get_acpi_data(pdev);
> > +   if (ret < 0)
> > +   return ret;
> 
> Is 'ret > 0' valid?
> 
> If not, then just 'if (ret)'.

Ok

> > +   kempld_acpi_mode = true;
> > +   } else if (kempld_pdev != pdev) {
> > +   dev_notice(dev, "platform device exists - not using
> > ACPI\n");
> 
> Why dev_notice() and not dev_err()?
> 
> Is that what 'kempld_pdev != pdev' means?
> 
> Could you explain this to me in more depth please?

kempld_pdev is the DMI based platform device created in kempld_init
(through force_device_id or dmi_check_system). pdev is the one passed
by the probe function. (kempdl_pdev != pdev) means pdev is the device
created using the ACPI table. As there is only one physical device and
the DMI based version should have priority, the probe is aborted at
this point. As it is not an error condition, only a notice is created
to indicate that ACPI is not used for probing the device.

> > ...
> > @@ -809,12 +887,19 @@ static int __init kempld_init(void)
> > break;
> > if (id->matches[0].slot == DMI_NONE)
> > return -ENODEV;
> > -   } else {
> > -   if (!dmi_check_system(kempld_dmi_table))
> > -   return -ENODEV;
> > }
> >  
> > -   return platform_driver_register(_driver);
> > +   ret = platform_driver_register(_driver);
> > +   if (ret)
> > +   return ret;
>
> Is it guaranteed that the child device has probed at this point?

To my understanding, with synchronous probing it should. According to
the definition of the probe_type enum this is still the default for all
drivers.
I guess it would make sense to enforce this for the case the default is
changed in the future.
Added this to v2:
.probe_type = PROBE_FORCE_SYNCHRONOUS,

Only exception, to my knowledge, is if drivers_autoprobe is disabled
for platform drivers during kempld_init. As DMI has priority, the
driver will later only allow to manually bind the DMI platform device,
if ACPI and DMI are both supported on a platform.

> > +   if (!kempld_pdev && !kempld_acpi_mode)
> 
> Again, comment please.  What has gone on to get to this point?

At this point it is checked if the kempld_pdev has been already created
(force_device_id parameter) and if the ACPI based probe has been
already successfull. If not, the

[PATCH] mfd: Add ACPI support to Kontron PLD driver

2020-08-12 Thread Michael Brunner
Recent Kontron COMe modules identify the PLD device using the hardware
id KEM0001 in the ACPI table.
This patch adds support for probing the device using the HID and also
retrieving the resources.

As this is not available for all products, the DMI based detection still
needs to be around for older systems. It is executed if no matching ACPI
HID is found during registering the platform driver or no specific
device id is forced.
If a device is detected using ACPI and no resource information is
available, the default io resource is used.

Forcing a device id with the force_device_id parameter and therefore
manually generating a platform device takes precedence over ACPI during
probing.

Signed-off-by: Michael Brunner 
---
 drivers/mfd/kempld-core.c | 97 ---
 1 file changed, 91 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index f48e21d8b97c..408cad1958d9 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MAX_ID_LEN 4
 static char force_device_id[MAX_ID_LEN + 1] = "";
@@ -132,6 +133,7 @@ static const struct kempld_platform_data 
kempld_platform_data_generic = {
 };
 
 static struct platform_device *kempld_pdev;
+static bool kempld_acpi_mode;
 
 static int kempld_create_platform_device(const struct dmi_system_id *id)
 {
@@ -434,13 +436,87 @@ static int kempld_detect_device(struct kempld_device_data 
*pld)
return ret;
 }
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id kempld_acpi_table[] = {
+   { "KEM0001", (kernel_ulong_t)_platform_data_generic },
+   {}
+};
+MODULE_DEVICE_TABLE(acpi, kempld_acpi_table);
+
+static int kempld_get_acpi_data(struct platform_device *pdev)
+{
+   struct list_head resource_list;
+   struct resource *resources;
+   struct resource_entry *rentry;
+   struct device *dev = >dev;
+   struct acpi_device *acpi_dev = ACPI_COMPANION(dev);
+   const struct kempld_platform_data *pdata;
+   int ret;
+   int count;
+
+   pdata = acpi_device_get_match_data(dev);
+   ret = platform_device_add_data(pdev, pdata,
+  sizeof(struct kempld_platform_data));
+   if (ret)
+   return ret;
+
+   INIT_LIST_HEAD(_list);
+   ret = acpi_dev_get_resources(acpi_dev, _list, NULL, NULL);
+   if (ret < 0)
+   goto out;
+
+   count = ret;
+
+   if (count > 0) {
+   resources = devm_kcalloc(_dev->dev, count,
+ sizeof(struct resource), GFP_KERNEL);
+   if (!resources) {
+   ret = -ENOMEM;
+   goto out;
+   }
+
+   count = 0;
+   list_for_each_entry(rentry, _list, node) {
+   memcpy([count], rentry->res,
+  sizeof(*resources));
+   count++;
+   }
+   ret = platform_device_add_resources(pdev, resources, count);
+   if (ret)
+   goto out;
+   } else
+   ret = platform_device_add_resources(pdev, pdata->ioresource, 1);
+
+out:
+   acpi_dev_free_resource_list(_list);
+
+   return ret;
+}
+#else
+static int kempld_get_acpi_data(struct platform_device *pdev)
+{
+   return -ENODEV;
+}
+#endif /* CONFIG_ACPI */
+
 static int kempld_probe(struct platform_device *pdev)
 {
-   const struct kempld_platform_data *pdata =
-   dev_get_platdata(>dev);
+   const struct kempld_platform_data *pdata;
struct device *dev = >dev;
struct kempld_device_data *pld;
struct resource *ioport;
+   int ret;
+
+   if (kempld_pdev == NULL) {
+   ret = kempld_get_acpi_data(pdev);
+   if (ret < 0)
+   return ret;
+   kempld_acpi_mode = true;
+   } else if (kempld_pdev != pdev) {
+   dev_notice(dev, "platform device exists - not using ACPI\n");
+   return -ENODEV;
+   }
+   pdata = dev_get_platdata(dev);
 
pld = devm_kzalloc(dev, sizeof(*pld), GFP_KERNEL);
if (!pld)
@@ -482,6 +558,7 @@ static int kempld_remove(struct platform_device *pdev)
 static struct platform_driver kempld_driver = {
.driver = {
.name   = "kempld",
+   .acpi_match_table = ACPI_PTR(kempld_acpi_table),
},
.probe  = kempld_probe,
.remove = kempld_remove,
@@ -800,6 +877,7 @@ MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
 static int __init kempld_init(void)
 {
const struct dmi_system_id *id;
+   int ret;
 
if (force_device_id[0]) {
for (id = kempld_dmi_table;
@@ -809,12 +887,19 @@ static int __init kempld_init(void)
   

[PATCH] mfd: Add support for several boards to Kontron PLD driver

2017-01-26 Thread Michael Brunner
This patch adds the DMI system ID of the Kontron COMe-bBD#, COMe-bKL6,
COMe-cKL6, COMe-bSL6 and COMe-cAL6 boards to the Kontron PLD driver. The
list of supported products in the module description is also updated.

Signed-off-by: Michael Brunner <michael.brun...@kontron.com>
Acked-by: Christian Rauch <christian.ra...@kontron.com>
---
 drivers/mfd/Kconfig   |  5 +
 drivers/mfd/kempld-core.c | 40 
 2 files changed, 45 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 4ce3b6f..5394125 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -506,17 +506,22 @@ config MFD_KEMPLD
  device may provide functions like watchdog, GPIO, UART and I2C bus.
 
  The following modules are supported:
+   * COMe-bBD#
* COMe-bBL6
* COMe-bHL6
+   * COMe-bSL6
* COMe-bIP#
+   * COMe-bKL6
* COMe-bPC2 (ETXexpress-PC)
* COMe-bSC# (ETXexpress-SC T#)
+   * COMe-cAL6
* COMe-cBL6
* COMe-cBT6
* COMe-cBW6
* COMe-cCT6
* COMe-cDC2 (microETXexpress-DC)
* COMe-cHL6
+   * COMe-cKL6
* COMe-cPC2 (microETXexpress-PC)
* COMe-cSL6
* COMe-mAL10
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index da5722d..895f655 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -496,6 +496,14 @@ static struct platform_driver kempld_driver = {
 
 static struct dmi_system_id kempld_dmi_table[] __initdata = {
{
+   .ident = "BBD6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bBD"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "BBL6",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -512,6 +520,30 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "BKL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bKL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
+   .ident = "BSL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bSL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
+   .ident = "CAL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cAL"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CBL6",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -600,6 +632,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "CKL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cKL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CNTG",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
-- 
2.7.4


[PATCH] mfd: Add support for several boards to Kontron PLD driver

2017-01-26 Thread Michael Brunner
This patch adds the DMI system ID of the Kontron COMe-bBD#, COMe-bKL6,
COMe-cKL6, COMe-bSL6 and COMe-cAL6 boards to the Kontron PLD driver. The
list of supported products in the module description is also updated.

Signed-off-by: Michael Brunner 
Acked-by: Christian Rauch 
---
 drivers/mfd/Kconfig   |  5 +
 drivers/mfd/kempld-core.c | 40 
 2 files changed, 45 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 4ce3b6f..5394125 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -506,17 +506,22 @@ config MFD_KEMPLD
  device may provide functions like watchdog, GPIO, UART and I2C bus.
 
  The following modules are supported:
+   * COMe-bBD#
* COMe-bBL6
* COMe-bHL6
+   * COMe-bSL6
* COMe-bIP#
+   * COMe-bKL6
* COMe-bPC2 (ETXexpress-PC)
* COMe-bSC# (ETXexpress-SC T#)
+   * COMe-cAL6
* COMe-cBL6
* COMe-cBT6
* COMe-cBW6
* COMe-cCT6
* COMe-cDC2 (microETXexpress-DC)
* COMe-cHL6
+   * COMe-cKL6
* COMe-cPC2 (microETXexpress-PC)
* COMe-cSL6
* COMe-mAL10
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index da5722d..895f655 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -496,6 +496,14 @@ static struct platform_driver kempld_driver = {
 
 static struct dmi_system_id kempld_dmi_table[] __initdata = {
{
+   .ident = "BBD6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bBD"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "BBL6",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -512,6 +520,30 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "BKL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bKL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
+   .ident = "BSL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bSL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
+   .ident = "CAL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cAL"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CBL6",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -600,6 +632,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "CKL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cKL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CNTG",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
-- 
2.7.4


[RESEND][PATCH] mfd: Add support for COMe-cSL6 and COMe-mAL10 to Kontron PLD driver

2016-06-19 Thread Michael Brunner
This is an unmodified resend of the patch already been sent on
February 17 as it seems to have fallen through the net.

This patch adds the DMI system ID of the Kontron COMe-cSL6 and
COME-mAL10 boards to the Kontron PLD driver. The list of supported
products in the module description is also updated.

Signed-off-by: Michael Brunner <michael.brun...@kontron.com>
Acked-by: Christian Rauch <christian.ra...@kontron.com>
Acked-by: Guenter Roeck <li...@roeck-us.net>
Reviewed-by: Darren Hart <dvh...@linux.intel.com>
---
 drivers/mfd/Kconfig   |  2 ++
 drivers/mfd/kempld-core.c | 16 
 2 files changed, 18 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 9ca66de..aab58b6 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -435,6 +435,8 @@ config MFD_KEMPLD
* COMe-cDC2 (microETXexpress-DC)
* COMe-cHL6
* COMe-cPC2 (microETXexpress-PC)
+   * COMe-cSL6
+   * COMe-mAL10
* COMe-mBT10
* COMe-mCT10
* COMe-mTT10 (nanoETXexpress-TT)
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 05b9245..da5722d 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -624,6 +624,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "CSL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cSL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CVV6",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -647,6 +655,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "MAL1",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-mAL10"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "MBR1",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
-- 
2.5.0


[RESEND][PATCH] mfd: Add support for COMe-cSL6 and COMe-mAL10 to Kontron PLD driver

2016-06-19 Thread Michael Brunner
This is an unmodified resend of the patch already been sent on
February 17 as it seems to have fallen through the net.

This patch adds the DMI system ID of the Kontron COMe-cSL6 and
COME-mAL10 boards to the Kontron PLD driver. The list of supported
products in the module description is also updated.

Signed-off-by: Michael Brunner 
Acked-by: Christian Rauch 
Acked-by: Guenter Roeck 
Reviewed-by: Darren Hart 
---
 drivers/mfd/Kconfig   |  2 ++
 drivers/mfd/kempld-core.c | 16 
 2 files changed, 18 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 9ca66de..aab58b6 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -435,6 +435,8 @@ config MFD_KEMPLD
* COMe-cDC2 (microETXexpress-DC)
* COMe-cHL6
* COMe-cPC2 (microETXexpress-PC)
+   * COMe-cSL6
+   * COMe-mAL10
* COMe-mBT10
* COMe-mCT10
* COMe-mTT10 (nanoETXexpress-TT)
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 05b9245..da5722d 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -624,6 +624,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "CSL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cSL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CVV6",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -647,6 +655,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "MAL1",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-mAL10"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "MBR1",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
-- 
2.5.0


[PATCH] mfd: Add support for COMe-cSL6 and COMe-mAL10 to Kontron PLD driver

2016-02-17 Thread Michael Brunner
This patch adds the DMI system ID of the Kontron COMe-cSL6 and
COME-mAL10 boards to the Kontron PLD driver. The list of supported
products in the module description is also updated.

Signed-off-by: Michael Brunner <michael.brun...@kontron.com>
Acked-by: Christian Rauch <christian.ra...@kontron.com>
---
 drivers/mfd/Kconfig   |  2 ++
 drivers/mfd/kempld-core.c | 16 
 2 files changed, 18 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 9ca66de..aab58b6 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -435,6 +435,8 @@ config MFD_KEMPLD
* COMe-cDC2 (microETXexpress-DC)
* COMe-cHL6
* COMe-cPC2 (microETXexpress-PC)
+   * COMe-cSL6
+   * COMe-mAL10
* COMe-mBT10
* COMe-mCT10
* COMe-mTT10 (nanoETXexpress-TT)
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 05b9245..da5722d 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -624,6 +624,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "CSL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cSL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CVV6",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -647,6 +655,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "MAL1",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-mAL10"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "MBR1",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
-- 
2.5.0


[PATCH] mfd: Add support for COMe-cSL6 and COMe-mAL10 to Kontron PLD driver

2016-02-17 Thread Michael Brunner
This patch adds the DMI system ID of the Kontron COMe-cSL6 and
COME-mAL10 boards to the Kontron PLD driver. The list of supported
products in the module description is also updated.

Signed-off-by: Michael Brunner 
Acked-by: Christian Rauch 
---
 drivers/mfd/Kconfig   |  2 ++
 drivers/mfd/kempld-core.c | 16 
 2 files changed, 18 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 9ca66de..aab58b6 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -435,6 +435,8 @@ config MFD_KEMPLD
* COMe-cDC2 (microETXexpress-DC)
* COMe-cHL6
* COMe-cPC2 (microETXexpress-PC)
+   * COMe-cSL6
+   * COMe-mAL10
* COMe-mBT10
* COMe-mCT10
* COMe-mTT10 (nanoETXexpress-TT)
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 05b9245..da5722d 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -624,6 +624,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "CSL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cSL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CVV6",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -647,6 +655,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "MAL1",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-mAL10"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "MBR1",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
-- 
2.5.0


[PATCH] mfd: Add support for COMe-bBL6 and COMe-cBW6 to Kontron PLD driver

2015-07-14 Thread Michael Brunner
This patch adds the DMI system ID of the Kontron COMe-bBL6 and COME-cBW6
boards to the Kontron PLD driver. The list of supported products in the
module description is also updated.

Signed-off-by: Michael Brunner 
Acked-by: Christian Rauch  
---
 drivers/mfd/Kconfig   |  2 ++
 drivers/mfd/kempld-core.c | 16 
 2 files changed, 18 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 6538159..51809e2 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -375,12 +375,14 @@ config MFD_KEMPLD
  device may provide functions like watchdog, GPIO, UART and I2C bus.
 
  The following modules are supported:
+   * COMe-bBL6
* COMe-bHL6
* COMe-bIP#
* COMe-bPC2 (ETXexpress-PC)
* COMe-bSC# (ETXexpress-SC T#)
* COMe-cBL6
* COMe-cBT6
+   * COMe-cBW6
* COMe-cCT6
* COMe-cDC2 (microETXexpress-DC)
* COMe-cHL6
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 8057849..463f4ea 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -501,6 +501,14 @@ static struct platform_driver kempld_driver = {
 
 static struct dmi_system_id kempld_dmi_table[] __initdata = {
{
+   .ident = "BBL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bBL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "BHL6",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -517,6 +525,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "CBW6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cBW6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CCR2",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
-- 
1.8.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mfd: Add support for COMe-bBL6 and COMe-cBW6 to Kontron PLD driver

2015-07-14 Thread Michael Brunner
This patch adds the DMI system ID of the Kontron COMe-bBL6 and COME-cBW6
boards to the Kontron PLD driver. The list of supported products in the
module description is also updated.

Signed-off-by: Michael Brunner michael.brun...@kontron.com
Acked-by: Christian Rauch christian.ra...@kontron.com 
---
 drivers/mfd/Kconfig   |  2 ++
 drivers/mfd/kempld-core.c | 16 
 2 files changed, 18 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 6538159..51809e2 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -375,12 +375,14 @@ config MFD_KEMPLD
  device may provide functions like watchdog, GPIO, UART and I2C bus.
 
  The following modules are supported:
+   * COMe-bBL6
* COMe-bHL6
* COMe-bIP#
* COMe-bPC2 (ETXexpress-PC)
* COMe-bSC# (ETXexpress-SC T#)
* COMe-cBL6
* COMe-cBT6
+   * COMe-cBW6
* COMe-cCT6
* COMe-cDC2 (microETXexpress-DC)
* COMe-cHL6
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 8057849..463f4ea 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -501,6 +501,14 @@ static struct platform_driver kempld_driver = {
 
 static struct dmi_system_id kempld_dmi_table[] __initdata = {
{
+   .ident = BBL6,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
+   DMI_MATCH(DMI_BOARD_NAME, COMe-bBL6),
+   },
+   .driver_data = (void *)kempld_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = BHL6,
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
@@ -517,6 +525,14 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
.driver_data = (void *)kempld_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = CBW6,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
+   DMI_MATCH(DMI_BOARD_NAME, COMe-cBW6),
+   },
+   .driver_data = (void *)kempld_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = CCR2,
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
-- 
1.8.5.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] gpio: gpio-kempld: Fix get_direction return value

2015-05-11 Thread Michael Brunner
This patch fixes an inverted return value of the gpio get_direction
function.

The wrong value causes the direction sysfs entry and GPIO debugfs file
to indicate incorrect GPIO direction settings. In some cases it also
prevents setting GPIO output values.

The problem is also present in all other stable kernel versions since
linux-3.12.

Reported-by: Jochen Henneberg 
Signed-off-by: Michael Brunner 
---
 drivers/gpio/gpio-kempld.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index 6b8115f..83f281d 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -117,7 +117,7 @@ static int kempld_gpio_get_direction(struct gpio_chip 
*chip, unsigned offset)
= container_of(chip, struct kempld_gpio_data, chip);
struct kempld_device_data *pld = gpio->pld;
 
-   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
+   return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
 }
 
 static int kempld_gpio_pincount(struct kempld_device_data *pld)
-- 
1.8.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] gpio: gpio-kempld: Fix get_direction return value

2015-05-11 Thread Michael Brunner
This patch fixes an inverted return value of the gpio get_direction
function.

The wrong value causes the direction sysfs entry and GPIO debugfs file
to indicate incorrect GPIO direction settings. In some cases it also
prevents setting GPIO output values.

The problem is also present in all other stable kernel versions since
linux-3.12.

Reported-by: Jochen Henneberg j...@henneberg-systemdesign.com
Signed-off-by: Michael Brunner michael.brun...@kontron.com
---
 drivers/gpio/gpio-kempld.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index 6b8115f..83f281d 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -117,7 +117,7 @@ static int kempld_gpio_get_direction(struct gpio_chip 
*chip, unsigned offset)
= container_of(chip, struct kempld_gpio_data, chip);
struct kempld_device_data *pld = gpio-pld;
 
-   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
+   return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
 }
 
 static int kempld_gpio_pincount(struct kempld_device_data *pld)
-- 
1.8.5.1
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mfd: Add support for COMe-cBL6 to Kontron PLD driver

2015-01-27 Thread Michael Brunner
This patch adds the DMI system ID of the Kontron COMe-cBL6 board to
the Kontron PLD driver. The list of supported products in the module
description is also updated.

Signed-off-by: Michael Brunner 
Acked-by: Christian Rauch 
---
 drivers/mfd/Kconfig   |  1 +
 drivers/mfd/kempld-core.c | 11 +--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2e6b731..0c066b9 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -352,6 +352,7 @@ config MFD_KEMPLD
* COMe-bIP#
* COMe-bPC2 (ETXexpress-PC)
* COMe-bSC# (ETXexpress-SC T#)
+   * COMe-cBL6
* COMe-cBT6
* COMe-cCT6
* COMe-cDC2 (microETXexpress-DC)
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index f38ec42..61a1f9b 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -508,8 +508,15 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
},
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
-   },
-   {
+   }, {
+   .ident = "CBL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cBL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CCR2",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
-- 
1.8.5.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mfd: Add support for COMe-cBL6 to Kontron PLD driver

2015-01-27 Thread Michael Brunner
This patch adds the DMI system ID of the Kontron COMe-cBL6 board to
the Kontron PLD driver. The list of supported products in the module
description is also updated.

Signed-off-by: Michael Brunner michael.brun...@kontron.com
Acked-by: Christian Rauch christian.ra...@kontron.com
---
 drivers/mfd/Kconfig   |  1 +
 drivers/mfd/kempld-core.c | 11 +--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2e6b731..0c066b9 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -352,6 +352,7 @@ config MFD_KEMPLD
* COMe-bIP#
* COMe-bPC2 (ETXexpress-PC)
* COMe-bSC# (ETXexpress-SC T#)
+   * COMe-cBL6
* COMe-cBT6
* COMe-cCT6
* COMe-cDC2 (microETXexpress-DC)
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index f38ec42..61a1f9b 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -508,8 +508,15 @@ static struct dmi_system_id kempld_dmi_table[] __initdata 
= {
},
.driver_data = (void *)kempld_platform_data_generic,
.callback = kempld_create_platform_device,
-   },
-   {
+   }, {
+   .ident = CBL6,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
+   DMI_MATCH(DMI_BOARD_NAME, COMe-cBL6),
+   },
+   .driver_data = (void *)kempld_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = CCR2,
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
-- 
1.8.5.1


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] watchdog: kempld-wdt: Use the correct value when configuring the prescaler with the watchdog

2014-05-07 Thread Michael Brunner
On Thu, 24 Apr 2014 08:15:40 -0700, Guenter Roeck 
wrote:
> On Thu, Apr 24, 2014 at 03:49:19PM +0200, gundberg wrote:
> > Use the prescaler index, rather than its value, to configure the
> > watchdog. This will prevent a mismatch with the prescaler used to
> > calculate the cycles.
> > 
> > Signed-off-by: Per Gundberg 
> 
> Good catch. Looks correct to me. Michael, any comments ?
> 
> Reviewed-by: Guenter Roeck 

Setting the prescaler incorrectly this way can cause the system to
reboot nearly immediately when activating the watchdog - not good.
This should also be applied to the stable revisions as this code is
included since 3.11.

Reviewed-by: Michael Brunner 
Tested-by: Michael Brunner 

Thanks,
Michael
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] watchdog: kempld-wdt: Use the correct value when configuring the prescaler with the watchdog

2014-05-07 Thread Michael Brunner
On Thu, 24 Apr 2014 08:15:40 -0700, Guenter Roeck li...@roeck-us.net
wrote:
 On Thu, Apr 24, 2014 at 03:49:19PM +0200, gundberg wrote:
  Use the prescaler index, rather than its value, to configure the
  watchdog. This will prevent a mismatch with the prescaler used to
  calculate the cycles.
  
  Signed-off-by: Per Gundberg per.gundb...@icomera.com
 
 Good catch. Looks correct to me. Michael, any comments ?
 
 Reviewed-by: Guenter Roeck li...@roeck-us.net

Setting the prescaler incorrectly this way can cause the system to
reboot nearly immediately when activating the watchdog - not good.
This should also be applied to the stable revisions as this code is
included since 3.11.

Reviewed-by: Michael Brunner michael.brun...@kontron.com
Tested-by: Michael Brunner michael.brun...@kontron.com

Thanks,
Michael
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mfd: Add sysfs attributes for Kontron PLD firmware revision

2014-04-08 Thread Michael Brunner
This patch adds attributes to the Kontron PLD driver to allow
applications to retrieve firmware information.
Additionally the format has been changed to conform with the
representation in other Kontron software.

Signed-off-by: Michael Brunner 
Reviewed-by: Guenter Roeck 
---
 drivers/mfd/kempld-core.c  | 127 +
 include/linux/mfd/kempld.h |   4 ++
 2 files changed, 110 insertions(+), 21 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index d3e2327..f8c965b 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -288,9 +288,38 @@ EXPORT_SYMBOL_GPL(kempld_release_mutex);
  */
 static int kempld_get_info(struct kempld_device_data *pld)
 {
+   int ret;
struct kempld_platform_data *pdata = dev_get_platdata(pld->dev);
+   char major, minor;
+
+   ret = pdata->get_info(pld);
+   if (ret)
+   return ret;
+
+   /* The Kontron PLD firmware version string has the following format:
+* Pwxy.
+*   P:Fixed
+*   w:PLD number- 1 hex digit
+*   x:Major version - 1 alphanumerical digit (0-9A-V)
+*   y:Minor version - 1 alphanumerical digit (0-9A-V)
+*   : Build number  - 4 zero padded hex digits */
 
-   return pdata->get_info(pld);
+   if (pld->info.major < 10)
+   major = pld->info.major + '0';
+   else
+   major = (pld->info.major - 10) + 'A';
+   if (pld->info.minor < 10)
+   minor = pld->info.minor + '0';
+   else
+   minor = (pld->info.minor - 10) + 'A';
+
+   ret = scnprintf(pld->info.version, sizeof(pld->info.version),
+   "P%X%c%c.%04X", pld->info.number, major, minor,
+   pld->info.buildnr);
+   if (ret < 0)
+   return ret;
+
+   return 0;
 }
 
 /*
@@ -307,9 +336,71 @@ static int kempld_register_cells(struct kempld_device_data 
*pld)
return pdata->register_cells(pld);
 }
 
+static const char *kempld_get_type_string(struct kempld_device_data *pld)
+{
+   const char *version_type;
+
+   switch (pld->info.type) {
+   case 0:
+   version_type = "release";
+   break;
+   case 1:
+   version_type = "debug";
+   break;
+   case 2:
+   version_type = "custom";
+   break;
+   default:
+   version_type = "unspecified";
+   break;
+   }
+
+   return version_type;
+}
+
+static ssize_t kempld_version_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct kempld_device_data *pld = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%s\n", pld->info.version);
+}
+
+static ssize_t kempld_specification_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct kempld_device_data *pld = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%d.%d\n", pld->info.spec_major,
+  pld->info.spec_minor);
+}
+
+static ssize_t kempld_type_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct kempld_device_data *pld = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, "%s\n", kempld_get_type_string(pld));
+}
+
+static DEVICE_ATTR(pld_version, S_IRUGO, kempld_version_show, NULL);
+static DEVICE_ATTR(pld_specification, S_IRUGO, kempld_specification_show,
+  NULL);
+static DEVICE_ATTR(pld_type, S_IRUGO, kempld_type_show, NULL);
+
+static struct attribute *pld_attributes[] = {
+   _attr_pld_version.attr,
+   _attr_pld_specification.attr,
+   _attr_pld_type.attr,
+   NULL
+};
+
+static const struct attribute_group pld_attr_group = {
+   .attrs = pld_attributes,
+};
+
 static int kempld_detect_device(struct kempld_device_data *pld)
 {
-   char *version_type;
u8 index_reg;
int ret;
 
@@ -332,27 +423,19 @@ static int kempld_detect_device(struct kempld_device_data 
*pld)
if (ret)
return ret;
 
-   switch (pld->info.type) {
-   case 0:
-   version_type = "release";
-   break;
-   case 1:
-   version_type = "debug";
-   break;
-   case 2:
-   version_type = "custom";
-   break;
-   default:
-   version_type = "unspecified";
-   }
+   dev_info(pld->dev, "Found Kontron PLD - %s (%s), spec %d.%d\n",
+pld->info.version, kempld_get_type_string(pld),
+pld->info.spec_major, pld->info.spec_minor);
+
+   ret = sysfs_create_group(>dev->kobj, _attr_group);
+   if (r

[PATCH] mfd: Add sysfs attributes for Kontron PLD firmware revision

2014-04-08 Thread Michael Brunner
This patch adds attributes to the Kontron PLD driver to allow
applications to retrieve firmware information.
Additionally the format has been changed to conform with the
representation in other Kontron software.

Signed-off-by: Michael Brunner michael.brun...@kontron.com
Reviewed-by: Guenter Roeck li...@roeck-us.net
---
 drivers/mfd/kempld-core.c  | 127 +
 include/linux/mfd/kempld.h |   4 ++
 2 files changed, 110 insertions(+), 21 deletions(-)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index d3e2327..f8c965b 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -288,9 +288,38 @@ EXPORT_SYMBOL_GPL(kempld_release_mutex);
  */
 static int kempld_get_info(struct kempld_device_data *pld)
 {
+   int ret;
struct kempld_platform_data *pdata = dev_get_platdata(pld-dev);
+   char major, minor;
+
+   ret = pdata-get_info(pld);
+   if (ret)
+   return ret;
+
+   /* The Kontron PLD firmware version string has the following format:
+* Pwxy.
+*   P:Fixed
+*   w:PLD number- 1 hex digit
+*   x:Major version - 1 alphanumerical digit (0-9A-V)
+*   y:Minor version - 1 alphanumerical digit (0-9A-V)
+*   : Build number  - 4 zero padded hex digits */
 
-   return pdata-get_info(pld);
+   if (pld-info.major  10)
+   major = pld-info.major + '0';
+   else
+   major = (pld-info.major - 10) + 'A';
+   if (pld-info.minor  10)
+   minor = pld-info.minor + '0';
+   else
+   minor = (pld-info.minor - 10) + 'A';
+
+   ret = scnprintf(pld-info.version, sizeof(pld-info.version),
+   P%X%c%c.%04X, pld-info.number, major, minor,
+   pld-info.buildnr);
+   if (ret  0)
+   return ret;
+
+   return 0;
 }
 
 /*
@@ -307,9 +336,71 @@ static int kempld_register_cells(struct kempld_device_data 
*pld)
return pdata-register_cells(pld);
 }
 
+static const char *kempld_get_type_string(struct kempld_device_data *pld)
+{
+   const char *version_type;
+
+   switch (pld-info.type) {
+   case 0:
+   version_type = release;
+   break;
+   case 1:
+   version_type = debug;
+   break;
+   case 2:
+   version_type = custom;
+   break;
+   default:
+   version_type = unspecified;
+   break;
+   }
+
+   return version_type;
+}
+
+static ssize_t kempld_version_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct kempld_device_data *pld = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, %s\n, pld-info.version);
+}
+
+static ssize_t kempld_specification_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct kempld_device_data *pld = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, %d.%d\n, pld-info.spec_major,
+  pld-info.spec_minor);
+}
+
+static ssize_t kempld_type_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct kempld_device_data *pld = dev_get_drvdata(dev);
+
+   return scnprintf(buf, PAGE_SIZE, %s\n, kempld_get_type_string(pld));
+}
+
+static DEVICE_ATTR(pld_version, S_IRUGO, kempld_version_show, NULL);
+static DEVICE_ATTR(pld_specification, S_IRUGO, kempld_specification_show,
+  NULL);
+static DEVICE_ATTR(pld_type, S_IRUGO, kempld_type_show, NULL);
+
+static struct attribute *pld_attributes[] = {
+   dev_attr_pld_version.attr,
+   dev_attr_pld_specification.attr,
+   dev_attr_pld_type.attr,
+   NULL
+};
+
+static const struct attribute_group pld_attr_group = {
+   .attrs = pld_attributes,
+};
+
 static int kempld_detect_device(struct kempld_device_data *pld)
 {
-   char *version_type;
u8 index_reg;
int ret;
 
@@ -332,27 +423,19 @@ static int kempld_detect_device(struct kempld_device_data 
*pld)
if (ret)
return ret;
 
-   switch (pld-info.type) {
-   case 0:
-   version_type = release;
-   break;
-   case 1:
-   version_type = debug;
-   break;
-   case 2:
-   version_type = custom;
-   break;
-   default:
-   version_type = unspecified;
-   }
+   dev_info(pld-dev, Found Kontron PLD - %s (%s), spec %d.%d\n,
+pld-info.version, kempld_get_type_string(pld),
+pld-info.spec_major, pld-info.spec_minor);
+
+   ret = sysfs_create_group(pld-dev-kobj, pld_attr_group);
+   if (ret)
+   return ret;
 
-   dev_info(pld-dev, Found Kontron PLD %d\n, pld-info.number);
-   dev_info(pld-dev, %s version %d.%d build %d, specification %d.%d\n,
-version_type

[PATCH] mfd: Add support for COMe-mBT10, COMe-cBT6 and COMe-cHL6 to Kontron PLD driver

2014-02-23 Thread Michael Brunner
This patch adds DMI system IDs for the Kontron modules COMe-mBT10, COMe-cBT6
and COMe-cHL6 to the Kontron PLD driver. The list of supported products in
the module description is also updated.

Signed-off-by: Michael Brunner 
Acked-by: Christian Rauch 
---
 drivers/mfd/Kconfig   |  5 +
 drivers/mfd/kempld-core.c | 24 
 2 files changed, 29 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 49bb445..f093401 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -270,13 +270,18 @@ config MFD_KEMPLD
  device may provide functions like watchdog, GPIO, UART and I2C bus.
 
  The following modules are supported:
+   * COMe-bHL6
* COMe-bIP#
* COMe-bPC2 (ETXexpress-PC)
* COMe-bSC# (ETXexpress-SC T#)
+   * COMe-cBT6
* COMe-cCT6
* COMe-cDC2 (microETXexpress-DC)
+   * COMe-cHL6
* COMe-cPC2 (microETXexpress-PC)
+   * COMe-mBT10
* COMe-mCT10
+   * COMe-mTT10 (nanoETXexpress-TT)
* ETX-OH
 
  This driver can also be built as a module. If so, the module
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index d3e2327..20a6afc 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -438,6 +438,14 @@ static struct dmi_system_id __initdata kempld_dmi_table[] 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "CHL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cHL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "CHR2",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -510,6 +518,14 @@ static struct dmi_system_id __initdata kempld_dmi_table[] 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "CVV6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cBT"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "FRI2",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -533,6 +549,14 @@ static struct dmi_system_id __initdata kempld_dmi_table[] 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = "MVV1",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-mBT"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = "NTC1",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
-- 
1.8.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mfd: Add support for COMe-mBT10, COMe-cBT6 and COMe-cHL6 to Kontron PLD driver

2014-02-23 Thread Michael Brunner
This patch adds DMI system IDs for the Kontron modules COMe-mBT10, COMe-cBT6
and COMe-cHL6 to the Kontron PLD driver. The list of supported products in
the module description is also updated.

Signed-off-by: Michael Brunner michael.brun...@kontron.com
Acked-by: Christian Rauch christian.ra...@kontron.com
---
 drivers/mfd/Kconfig   |  5 +
 drivers/mfd/kempld-core.c | 24 
 2 files changed, 29 insertions(+)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 49bb445..f093401 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -270,13 +270,18 @@ config MFD_KEMPLD
  device may provide functions like watchdog, GPIO, UART and I2C bus.
 
  The following modules are supported:
+   * COMe-bHL6
* COMe-bIP#
* COMe-bPC2 (ETXexpress-PC)
* COMe-bSC# (ETXexpress-SC T#)
+   * COMe-cBT6
* COMe-cCT6
* COMe-cDC2 (microETXexpress-DC)
+   * COMe-cHL6
* COMe-cPC2 (microETXexpress-PC)
+   * COMe-mBT10
* COMe-mCT10
+   * COMe-mTT10 (nanoETXexpress-TT)
* ETX-OH
 
  This driver can also be built as a module. If so, the module
diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index d3e2327..20a6afc 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -438,6 +438,14 @@ static struct dmi_system_id __initdata kempld_dmi_table[] 
= {
.driver_data = (void *)kempld_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = CHL6,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
+   DMI_MATCH(DMI_BOARD_NAME, COMe-cHL6),
+   },
+   .driver_data = (void *)kempld_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = CHR2,
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
@@ -510,6 +518,14 @@ static struct dmi_system_id __initdata kempld_dmi_table[] 
= {
.driver_data = (void *)kempld_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = CVV6,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
+   DMI_MATCH(DMI_BOARD_NAME, COMe-cBT),
+   },
+   .driver_data = (void *)kempld_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = FRI2,
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
@@ -533,6 +549,14 @@ static struct dmi_system_id __initdata kempld_dmi_table[] 
= {
.driver_data = (void *)kempld_platform_data_generic,
.callback = kempld_create_platform_device,
}, {
+   .ident = MVV1,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
+   DMI_MATCH(DMI_BOARD_NAME, COMe-mBT),
+   },
+   .driver_data = (void *)kempld_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   }, {
.ident = NTC1,
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
-- 
1.8.5.1
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mfd: Add support for COMe-bHL6 and COMe-cTH6 to Kontron PLD driver

2013-08-09 Thread Michael Brunner
This patch adds DMI system IDs for the new Kontron modules COMe-bHL6 and
COMe-cTH6 to the Kontron PLD driver.

Signed-off-by: Michael Brunner 
---
 drivers/mfd/kempld-core.c |   18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 686a456..ee28e76 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -413,6 +413,15 @@ static struct platform_driver kempld_driver = {
 
 static struct dmi_system_id __initdata kempld_dmi_table[] = {
{
+   .ident = "BHL6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-bHL6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   },
+   {
.ident = "CCR2",
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
@@ -596,6 +605,15 @@ static struct dmi_system_id __initdata kempld_dmi_table[] 
= {
.driver_data = (void *)_platform_data_generic,
.callback = kempld_create_platform_device,
},
+   {
+   .ident = "UTH6",
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"),
+   DMI_MATCH(DMI_BOARD_NAME, "COMe-cTH6"),
+   },
+   .driver_data = (void *)_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   },
{}
 };
 MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] gpio: Fix bit masking in Kontron PLD GPIO driver

2013-08-09 Thread Michael Brunner
This patch fixes the bit masking within the GPIO driver. The masking is
basically done twice which causes the wrong GPIOs to be addressed.

Signed-off-by: Michael Brunner 
---
 drivers/gpio/gpio-kempld.c |   24 +---
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index d3ed563..6118b66 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -46,9 +46,9 @@ static void kempld_gpio_bitop(struct kempld_device_data *pld,
 
status = kempld_read8(pld, reg);
if (val)
-   status |= (1 << bit);
+   status |= KEMPLD_GPIO_MASK(bit);
else
-   status &= ~(1 << bit);
+   status &= ~KEMPLD_GPIO_MASK(bit);
kempld_write8(pld, reg, status);
 }
 
@@ -60,7 +60,7 @@ static int kempld_gpio_get_bit(struct kempld_device_data 
*pld, u8 reg, u8 bit)
status = kempld_read8(pld, reg);
kempld_release_mutex(pld);
 
-   return !!(status & (1 << bit));
+   return !!(status & KEMPLD_GPIO_MASK(bit));
 }
 
 static int kempld_gpio_get(struct gpio_chip *chip, unsigned offset)
@@ -69,8 +69,7 @@ static int kempld_gpio_get(struct gpio_chip *chip, unsigned 
offset)
= container_of(chip, struct kempld_gpio_data, chip);
struct kempld_device_data *pld = gpio->pld;
 
-   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset),
-  KEMPLD_GPIO_MASK(offset));
+   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset), offset);
 }
 
 static void kempld_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
@@ -80,8 +79,7 @@ static void kempld_gpio_set(struct gpio_chip *chip, unsigned 
offset, int value)
struct kempld_device_data *pld = gpio->pld;
 
kempld_get_mutex(pld);
-   kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset),
- KEMPLD_GPIO_MASK(offset), value);
+   kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value);
kempld_release_mutex(pld);
 }
 
@@ -92,8 +90,7 @@ static int kempld_gpio_direction_input(struct gpio_chip 
*chip, unsigned offset)
struct kempld_device_data *pld = gpio->pld;
 
kempld_get_mutex(pld);
-   kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset),
- KEMPLD_GPIO_MASK(offset), 0);
+   kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 0);
kempld_release_mutex(pld);
 
return 0;
@@ -107,10 +104,8 @@ static int kempld_gpio_direction_output(struct gpio_chip 
*chip, unsigned offset,
struct kempld_device_data *pld = gpio->pld;
 
kempld_get_mutex(pld);
-   kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset),
- KEMPLD_GPIO_MASK(offset), value);
-   kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset),
- KEMPLD_GPIO_MASK(offset), 1);
+   kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value);
+   kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 1);
kempld_release_mutex(pld);
 
return 0;
@@ -122,8 +117,7 @@ static int kempld_gpio_get_direction(struct gpio_chip 
*chip, unsigned offset)
= container_of(chip, struct kempld_gpio_data, chip);
struct kempld_device_data *pld = gpio->pld;
 
-   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset),
-  KEMPLD_GPIO_MASK(offset));
+   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
 }
 
 static int kempld_gpio_pincount(struct kempld_device_data *pld)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] gpio: Fix platform driver name in Kontron PLD GPIO driver

2013-08-09 Thread Michael Brunner
This patch changes the driver name to be consistent with the name that
is registered as cell name in the MFD driver. Otherwise the driver won't
load.

Signed-off-by: Michael Brunner 
---
 drivers/gpio/gpio-kempld.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index 1bdc3a2..d3ed563 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -210,7 +210,7 @@ static int kempld_gpio_remove(struct
platform_device *pdev) 
 static struct platform_driver kempld_gpio_driver = {
.driver = {
-   .name = "gpio-kempld",
+   .name = "kempld-gpio",
.owner = THIS_MODULE,
},
.probe  = kempld_gpio_probe,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] gpio: Fix platform driver name in Kontron PLD GPIO driver

2013-08-09 Thread Michael Brunner
This patch changes the driver name to be consistent with the name that
is registered as cell name in the MFD driver. Otherwise the driver won't
load.

Signed-off-by: Michael Brunner michael.brun...@kontron.com
---
 drivers/gpio/gpio-kempld.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index 1bdc3a2..d3ed563 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -210,7 +210,7 @@ static int kempld_gpio_remove(struct
platform_device *pdev) 
 static struct platform_driver kempld_gpio_driver = {
.driver = {
-   .name = gpio-kempld,
+   .name = kempld-gpio,
.owner = THIS_MODULE,
},
.probe  = kempld_gpio_probe,
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] gpio: Fix bit masking in Kontron PLD GPIO driver

2013-08-09 Thread Michael Brunner
This patch fixes the bit masking within the GPIO driver. The masking is
basically done twice which causes the wrong GPIOs to be addressed.

Signed-off-by: Michael Brunner michael.brun...@kontron.com
---
 drivers/gpio/gpio-kempld.c |   24 +---
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index d3ed563..6118b66 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -46,9 +46,9 @@ static void kempld_gpio_bitop(struct kempld_device_data *pld,
 
status = kempld_read8(pld, reg);
if (val)
-   status |= (1  bit);
+   status |= KEMPLD_GPIO_MASK(bit);
else
-   status = ~(1  bit);
+   status = ~KEMPLD_GPIO_MASK(bit);
kempld_write8(pld, reg, status);
 }
 
@@ -60,7 +60,7 @@ static int kempld_gpio_get_bit(struct kempld_device_data 
*pld, u8 reg, u8 bit)
status = kempld_read8(pld, reg);
kempld_release_mutex(pld);
 
-   return !!(status  (1  bit));
+   return !!(status  KEMPLD_GPIO_MASK(bit));
 }
 
 static int kempld_gpio_get(struct gpio_chip *chip, unsigned offset)
@@ -69,8 +69,7 @@ static int kempld_gpio_get(struct gpio_chip *chip, unsigned 
offset)
= container_of(chip, struct kempld_gpio_data, chip);
struct kempld_device_data *pld = gpio-pld;
 
-   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset),
-  KEMPLD_GPIO_MASK(offset));
+   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset), offset);
 }
 
 static void kempld_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
@@ -80,8 +79,7 @@ static void kempld_gpio_set(struct gpio_chip *chip, unsigned 
offset, int value)
struct kempld_device_data *pld = gpio-pld;
 
kempld_get_mutex(pld);
-   kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset),
- KEMPLD_GPIO_MASK(offset), value);
+   kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value);
kempld_release_mutex(pld);
 }
 
@@ -92,8 +90,7 @@ static int kempld_gpio_direction_input(struct gpio_chip 
*chip, unsigned offset)
struct kempld_device_data *pld = gpio-pld;
 
kempld_get_mutex(pld);
-   kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset),
- KEMPLD_GPIO_MASK(offset), 0);
+   kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 0);
kempld_release_mutex(pld);
 
return 0;
@@ -107,10 +104,8 @@ static int kempld_gpio_direction_output(struct gpio_chip 
*chip, unsigned offset,
struct kempld_device_data *pld = gpio-pld;
 
kempld_get_mutex(pld);
-   kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset),
- KEMPLD_GPIO_MASK(offset), value);
-   kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset),
- KEMPLD_GPIO_MASK(offset), 1);
+   kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value);
+   kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 1);
kempld_release_mutex(pld);
 
return 0;
@@ -122,8 +117,7 @@ static int kempld_gpio_get_direction(struct gpio_chip 
*chip, unsigned offset)
= container_of(chip, struct kempld_gpio_data, chip);
struct kempld_device_data *pld = gpio-pld;
 
-   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset),
-  KEMPLD_GPIO_MASK(offset));
+   return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset);
 }
 
 static int kempld_gpio_pincount(struct kempld_device_data *pld)
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mfd: Add support for COMe-bHL6 and COMe-cTH6 to Kontron PLD driver

2013-08-09 Thread Michael Brunner
This patch adds DMI system IDs for the new Kontron modules COMe-bHL6 and
COMe-cTH6 to the Kontron PLD driver.

Signed-off-by: Michael Brunner michael.brun...@kontron.com
---
 drivers/mfd/kempld-core.c |   18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mfd/kempld-core.c b/drivers/mfd/kempld-core.c
index 686a456..ee28e76 100644
--- a/drivers/mfd/kempld-core.c
+++ b/drivers/mfd/kempld-core.c
@@ -413,6 +413,15 @@ static struct platform_driver kempld_driver = {
 
 static struct dmi_system_id __initdata kempld_dmi_table[] = {
{
+   .ident = BHL6,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
+   DMI_MATCH(DMI_BOARD_NAME, COMe-bHL6),
+   },
+   .driver_data = (void *)kempld_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   },
+   {
.ident = CCR2,
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
@@ -596,6 +605,15 @@ static struct dmi_system_id __initdata kempld_dmi_table[] 
= {
.driver_data = (void *)kempld_platform_data_generic,
.callback = kempld_create_platform_device,
},
+   {
+   .ident = UTH6,
+   .matches = {
+   DMI_MATCH(DMI_BOARD_VENDOR, Kontron),
+   DMI_MATCH(DMI_BOARD_NAME, COMe-cTH6),
+   },
+   .driver_data = (void *)kempld_platform_data_generic,
+   .callback = kempld_create_platform_device,
+   },
{}
 };
 MODULE_DEVICE_TABLE(dmi, kempld_dmi_table);
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] i2c: Fix Kontron PLD prescaler calculation

2013-07-26 Thread Michael Brunner
Add some necessary braces that have been removed during driver cleanup.
This fixes the I2C prescaler calculation.

Signed-off-by: Michael Brunner 
---
 drivers/i2c/busses/i2c-kempld.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-kempld.c b/drivers/i2c/busses/i2c-kempld.c
index ccec916..af8f65f 100644
--- a/drivers/i2c/busses/i2c-kempld.c
+++ b/drivers/i2c/busses/i2c-kempld.c
@@ -246,9 +246,9 @@ static void kempld_i2c_device_init(struct kempld_i2c_data 
*i2c)
bus_frequency = KEMPLD_I2C_FREQ_MAX;
 
if (pld->info.spec_major == 1)
-   prescale = pld->pld_clock / bus_frequency * 5 - 1000;
+   prescale = pld->pld_clock / (bus_frequency * 5) - 1000;
else
-   prescale = pld->pld_clock / bus_frequency * 4 - 3000;
+   prescale = pld->pld_clock / (bus_frequency * 4) - 3000;
 
if (prescale < 0)
prescale = 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] i2c: Fix Kontron PLD prescaler calculation

2013-07-26 Thread Michael Brunner
Add some necessary braces that have been removed during driver cleanup.
This fixes the I2C prescaler calculation.

Signed-off-by: Michael Brunner michael.brun...@kontron.com
---
 drivers/i2c/busses/i2c-kempld.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-kempld.c b/drivers/i2c/busses/i2c-kempld.c
index ccec916..af8f65f 100644
--- a/drivers/i2c/busses/i2c-kempld.c
+++ b/drivers/i2c/busses/i2c-kempld.c
@@ -246,9 +246,9 @@ static void kempld_i2c_device_init(struct kempld_i2c_data 
*i2c)
bus_frequency = KEMPLD_I2C_FREQ_MAX;
 
if (pld-info.spec_major == 1)
-   prescale = pld-pld_clock / bus_frequency * 5 - 1000;
+   prescale = pld-pld_clock / (bus_frequency * 5) - 1000;
else
-   prescale = pld-pld_clock / bus_frequency * 4 - 3000;
+   prescale = pld-pld_clock / (bus_frequency * 4) - 3000;
 
if (prescale  0)
prescale = 0;
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/4] gpio: Kontron PLD gpio driver

2013-04-12 Thread Michael Brunner
Hi Linus,

As this code is from me I will comment on your review.

On Wed, 10 Apr 2013 22:45:51 +0200
Linus Walleij  wrote:
(...)
> Trying to do some real review...
> 
> (...)  
> > +++ b/drivers/gpio/gpio-kempld.c
> > +#include   
> 
> Is this used?  

Actually not, this can be removed.

> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "gpio-kempld.h"
> > +
> > +static int gpiobase = -1;
> > +static int gpioien = 0x00;
> > +static int gpioevt_lvl_edge = -1;
> > +static int gpioevt_low_high = -1;
> > +static int gpionmien = 0x00;  
> 
> (...)
> 
> +static int kempld_gpio_to_irq(struct gpio_chip *chip, unsigned
> offset) +{
> +   struct kempld_gpio_data *gpio
> +   = container_of(chip, struct kempld_gpio_data, chip);
> +   return gpio->irq;
> +}
> 
> I don't understand this *at all* so help me out here.
> 
> .gpio_to_irq() should return a *Linux* IRQ number, usually we take
> the event offset (in this case) and map to a Linux IRQ using the
> irqdomain helper library. Can you explain how we can be sure that
> this number (apparently just a read from a register on the device)
> can be made to correspond to a Linux IRQ?
> 
> Also if this thing can generate IRQs, are these one line to the CPU
> per IRQ really? Don't you need to demux the status register and
> create a cascades irqchip?
> 
> Maybe it's just me not understanding x86 & ACPI so bear with me...  

The chip is connected to the CPU through a serial IRQ line and IRQs
are managed through the (A)PIC which is configured by the
firmware. I never saw a difference between Linux and HW IRQ numbers
for the legacy IRQs (0-15) this chip generates. But I will take
another look at the IRQ handling of this driver.

> > +static int kempld_gpio_setup_event(struct kempld_gpio_data *gpio)
> > +{
> > +   struct kempld_device_data *pld = gpio->pld;
> > +   struct gpio_chip *chip = >chip;
> > +   int irq;
> > +
> > +   irq = gpio->irq;
> > +
> > +   kempld_get_mutex_set_index(pld, KEMPLD_IRQ_GPIO);
> > +   irq = kempld_read8(pld, KEMPLD_IRQ_GPIO);
> > +
> > +   /* Leave if interrupts are not supported by the GPIO core */
> > +   if ((irq & 0xf0) == 0xf0)
> > +   return 0;
> > +
> > +   gpio->irq = irq & 0x0f;  
> 
> So you read the IRQ from some plug-n-play here, and it's some
> system-wide IRQ number?  

Correct.

> (...)  
> > +   if (gpio->irq)
> > +   chip->to_irq =  kempld_gpio_to_irq;  
> 
> So that is this mystery with the IRQs and how they turn into
> Linux IRQs.
>   
> > +module_param(gpiobase, int, 0444);  
> 
> Why do you need to be able to configure this?
> It must be a real usecase, debugging can be done by patching
> the code.  

This was intended to help developing userspace applications or scripts.
For this parameter I had in mind that one configures a static
GPIO base and then maps the GPIOs with the help of the sysfs interface
without the need to first find out which is the actual GPIO base. If you think 
this shouldn't be done this way I won't insist
to keep this parameter.

> > +module_param(gpioien, int, 0444);
> > +module_param(gpioevt_lvl_edge, int, 0444);
> > +module_param(gpioevt_low_high, int, 0444);
> > +module_param(gpionmien, int, 0444);  
> 
> Argh how can anyone possibly make this out ... do you really
> need them or can we get rid of some and rely on autodetect?  

As the chip sits on a computer module that is usually only configured
generically, it is not possible to auto detect the needed configuration.
Those parameters are intended to let the developer configure the chip
without having to touch the driver code.
You are right anyway, doing it this way might not be the best way. So if
there is a good way to configure this stuff at runtime by using a
generic interface I would also prefer this.

> > +MODULE_DESCRIPTION("KEM PLD GPIO Driver");
> > +MODULE_AUTHOR("Michael Brunner ");
> > +MODULE_LICENSE("GPL");
> > +MODULE_ALIAS("platform:kempld_gpio");
> > +MODULE_PARM_DESC(gpiobase, "Set GPIO base (default -1=dynamic)");
> > +MODULE_PARM_DESC(gpioien, "Set GPIO IEN register (default 0x00)");
> > +MODULE_PARM_DESC(gpioevt_lvl_edge,
> > +   "Set GPIO EVT_LVL_EDGE register (default
> > -1=no change)"); +MODULE_PARM_DESC(gpioevt_low_high,
> > +   "Set GPIO EVT_LOW_HIGH register (default
> > -1=no change)"); +MODULE_PARM_DESC(gpionmien, "Set GPIO 

Re: [PATCH 3/4] gpio: Kontron PLD gpio driver

2013-04-12 Thread Michael Brunner
Hi Linus,

As this code is from me I will comment on your review.

On Wed, 10 Apr 2013 22:45:51 +0200
Linus Walleij linus.wall...@linaro.org wrote:
(...)
 Trying to do some real review...
 
 (...)  
  +++ b/drivers/gpio/gpio-kempld.c
  +#include linux/acpi.h  
 
 Is this used?  

Actually not, this can be removed.

  +#include linux/platform_device.h
  +#include linux/gpio.h
  +#include linux/mfd/kempld.h
  +#include linux/seq_file.h
  +
  +#include gpio-kempld.h
  +
  +static int gpiobase = -1;
  +static int gpioien = 0x00;
  +static int gpioevt_lvl_edge = -1;
  +static int gpioevt_low_high = -1;
  +static int gpionmien = 0x00;  
 
 (...)
 
 +static int kempld_gpio_to_irq(struct gpio_chip *chip, unsigned
 offset) +{
 +   struct kempld_gpio_data *gpio
 +   = container_of(chip, struct kempld_gpio_data, chip);
 +   return gpio-irq;
 +}
 
 I don't understand this *at all* so help me out here.
 
 .gpio_to_irq() should return a *Linux* IRQ number, usually we take
 the event offset (in this case) and map to a Linux IRQ using the
 irqdomain helper library. Can you explain how we can be sure that
 this number (apparently just a read from a register on the device)
 can be made to correspond to a Linux IRQ?
 
 Also if this thing can generate IRQs, are these one line to the CPU
 per IRQ really? Don't you need to demux the status register and
 create a cascades irqchip?
 
 Maybe it's just me not understanding x86  ACPI so bear with me...  

The chip is connected to the CPU through a serial IRQ line and IRQs
are managed through the (A)PIC which is configured by the
firmware. I never saw a difference between Linux and HW IRQ numbers
for the legacy IRQs (0-15) this chip generates. But I will take
another look at the IRQ handling of this driver.

  +static int kempld_gpio_setup_event(struct kempld_gpio_data *gpio)
  +{
  +   struct kempld_device_data *pld = gpio-pld;
  +   struct gpio_chip *chip = gpio-chip;
  +   int irq;
  +
  +   irq = gpio-irq;
  +
  +   kempld_get_mutex_set_index(pld, KEMPLD_IRQ_GPIO);
  +   irq = kempld_read8(pld, KEMPLD_IRQ_GPIO);
  +
  +   /* Leave if interrupts are not supported by the GPIO core */
  +   if ((irq  0xf0) == 0xf0)
  +   return 0;
  +
  +   gpio-irq = irq  0x0f;  
 
 So you read the IRQ from some plug-n-play here, and it's some
 system-wide IRQ number?  

Correct.

 (...)  
  +   if (gpio-irq)
  +   chip-to_irq =  kempld_gpio_to_irq;  
 
 So that is this mystery with the IRQs and how they turn into
 Linux IRQs.
   
  +module_param(gpiobase, int, 0444);  
 
 Why do you need to be able to configure this?
 It must be a real usecase, debugging can be done by patching
 the code.  

This was intended to help developing userspace applications or scripts.
For this parameter I had in mind that one configures a static
GPIO base and then maps the GPIOs with the help of the sysfs interface
without the need to first find out which is the actual GPIO base. If you think 
this shouldn't be done this way I won't insist
to keep this parameter.

  +module_param(gpioien, int, 0444);
  +module_param(gpioevt_lvl_edge, int, 0444);
  +module_param(gpioevt_low_high, int, 0444);
  +module_param(gpionmien, int, 0444);  
 
 Argh how can anyone possibly make this out ... do you really
 need them or can we get rid of some and rely on autodetect?  

As the chip sits on a computer module that is usually only configured
generically, it is not possible to auto detect the needed configuration.
Those parameters are intended to let the developer configure the chip
without having to touch the driver code.
You are right anyway, doing it this way might not be the best way. So if
there is a good way to configure this stuff at runtime by using a
generic interface I would also prefer this.

  +MODULE_DESCRIPTION(KEM PLD GPIO Driver);
  +MODULE_AUTHOR(Michael Brunner michael.brun...@kontron.com);
  +MODULE_LICENSE(GPL);
  +MODULE_ALIAS(platform:kempld_gpio);
  +MODULE_PARM_DESC(gpiobase, Set GPIO base (default -1=dynamic));
  +MODULE_PARM_DESC(gpioien, Set GPIO IEN register (default 0x00));
  +MODULE_PARM_DESC(gpioevt_lvl_edge,
  +   Set GPIO EVT_LVL_EDGE register (default
  -1=no change)); +MODULE_PARM_DESC(gpioevt_low_high,
  +   Set GPIO EVT_LOW_HIGH register (default
  -1=no change)); +MODULE_PARM_DESC(gpionmien, Set GPIO NMIEN
  register (default 0x00));  
 
 
 So I don't really like that interrupt enablement and edge and low/high
 is done with module parameters instead of just creating an irqchip and
 have it implement the operations to do exactly these things at runtime
 instead.
 
 Again maybe some x86 thing I don't get...  

Possibly not. I am not very familiar with irqchip so far, therefore I
will have a look at it and check if the whole IRQ handling can be
ported to this framework.

  diff --git a/drivers/gpio/gpio-kempld.h
  b/drivers/gpio/gpio-kempld.h  
 (...)  
  +struct