History log of /linux-master/drivers/mfd/kempld-core.c
Revision Date Author Comments
# 87bfb48f 22-Feb-2024 Michael Brunner <michael.brunner@kontron.com>

mfd: kempld-core: Don't replace resources provided by ACPI

The current implementation to retrieve ACPI resources is faulty
and may cause issues that even can lead to non-booting systems.

When adding data from an ACPI device, the resources are already
assigned to the platform device. Therefore there is no need to
retrieve the resource list from ACPI and manually assign it to
the platform device. Also there shouldn't be any BIOS in the wild
anymore, that does not have resources added to the KEMPLD ACPI
data.

In particular this fixes an issue where the retrieval of the
resource list using /proc/ioports is disturbed and does not list
the assigned resource for the kempld device or even no resources
at all.
On some distributions this also leads to problems during system
initialization (e.g. with udev) and causes the system to not
boot at all.

I have reproduced the issue with the following kernel versions:
5.10.209
5.15.148
6.1.25
6.6.17
6.7.5
6.8-rc5

The patch applies to all of those versions and seems to resolve
the issue.

Signed-off-by: Michael Brunner <michael.brunner@kontron.com>
Link: https://lore.kernel.org/r/af8756be81c9062f9543d2e5d9373cf5e7877b1e.camel@kontron.com
Signed-off-by: Lee Jones <lee@kernel.org>


# 0c45dd86 23-Nov-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

mfd: kempld-core: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20231123165627.492259-8-u.kleine-koenig@pengutronix.de
Signed-off-by: Lee Jones <lee@kernel.org>


# 8cc5e62b 02-Dec-2022 ye xingchen <ye.xingchen@zte.com.cn>

mfd: Use sysfs_emit() to instead of scnprintf()

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/202212021528368292334@zte.com.cn


# cd5bde2c 02-Jun-2021 Zhen Lei <thunder.leizhen@huawei.com>

mfd: kempld-core: Use DEVICE_ATTR_RO macro

Use DEVICE_ATTR_RO macro helper instead of plain DEVICE_ATTR, which makes
the code a bit shorter and easier to read.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 0cd3aa99 23-Nov-2020 Michael Brunner <Michael.Brunner@kontron.com>

mfd: kempld-core: Add support for additional devices

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 KEM0000 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 <michael.brunner@kontron.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# f31cc6af 15-Nov-2020 Michael Brunner <Michael.Brunner@kontron.com>

mfd: kempld-core: Check for DMI definition before ACPI

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 <michael.brunner@kontron.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 6d81dc3c 02-Oct-2020 Lee Jones <lee.jones@linaro.org>

mfd: kempld-core: Fix unused variable 'kempld_acpi_table' when !ACPI

drivers/mfd/kempld-core.c:556:36: warning: unused variable 'kempld_acpi_table' [-Wunused-const-variable]

Signed-off-by: Lee Jones <lee.jones@linaro.org>


# e8299c73 20-Aug-2020 Michael Brunner <Michael.Brunner@kontron.com>

mfd: Add ACPI support to Kontron PLD driver

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 <michael.brunner@kontron.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 564de762 16-Jul-2020 Stephen Rothwell <sfr@canb.auug.org.au>

mfd: kempld-core: Fix 'assignment of read-only location' error

drivers/mfd/kempld-core.c: In function 'kempld_register_cells_generic':
drivers/mfd/kempld-core.c:105:13: error: assignment of read-only location 'devs[i++]'
105 | devs[i++] = kempld_devs[KEMPLD_I2C];
| ^
drivers/mfd/kempld-core.c:108:13: error: assignment of read-only location 'devs[i++]'
108 | devs[i++] = kempld_devs[KEMPLD_WDT];
| ^
drivers/mfd/kempld-core.c:111:13: error: assignment of read-only location 'devs[i++]'
111 | devs[i++] = kempld_devs[KEMPLD_GPIO];
| ^
drivers/mfd/kempld-core.c:114:13: error: assignment of read-only location 'devs[i++]'
114 | devs[i++] = kempld_devs[KEMPLD_UART];
| ^

Fixes: e49aa9a9bd22 ("mfd: core: Make a best effort attempt to match devices with the correct of_nodes")
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 9f806850 29-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 294

Based on 2 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license 2 as published
by the free software foundation this program is distributed in the
hope that it will be useful but without any warranty without even
the implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation this program is distributed in the hope
that it [would] be useful but without any warranty without even the
implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 9 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141901.804956444@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# bf1cafa1 12-Jun-2018 Julia Lawall <Julia.Lawall@lip6.fr>

mfd: kempld-core: Constify variables that point to const structure

Add const to the declaration of various local variables of type
kempld_platform_data for which the referenced value is always only
dereferenced or passed to a const parameter, to record the fact that
kempld_platform_data_generic is declared as const.

The semantic match that finds this issue is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
identifier i,j;
@@
const struct i j = { ... };

@ok@
identifier r.i;
position p;
@@
const struct i@p *

@@
identifier r.i;
position p != ok.p;
@@
* struct i@p *
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 263a7c57 20-Nov-2017 Vasyl Gomonovych <gomonovych@gmail.com>

mfd: kempld-core: Use resource_size function on resource object

drivers/mfd/kempld-core.c:461:13-16: WARNING: Suspicious code. resource_size is maybe missing with ioport

Generated by: scripts/coccinelle/api/resource_size.cocci

Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 6faadbbb 14-Sep-2017 Christoph Hellwig <hch@lst.de>

dmi: Mark all struct dmi_system_id instances const

... and __initconst if applicable.

Based on similar work for an older kernel in the Grsecurity patch.

[JD: fix toshiba-wmi build]
[JD: add htcpen]
[JD: move __initconst where checkscript wants it]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jean Delvare <jdelvare@suse.de>


# e33ad65a 26-Jan-2017 Michael Brunner <mibru@gmx.de>

mfd: Add support for several boards to Kontron PLD driver

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.brunner@kontron.com>
Acked-by: Christian Rauch <christian.rauch@kontron.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 1db3ba28 19-Jun-2016 Michael Brunner <mibru@gmx.de>

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

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.brunner@kontron.com>
Acked-by: Christian Rauch <christian.rauch@kontron.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# d8498df1 29-Sep-2015 Javier Martinez Canillas <javier@osg.samsung.com>

mfd: kempld-core: Simplify function return logic

The invoked functions already return zero on success or a negative
errno code so there is no need to open code the logic in the caller.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 18ca2ba5 14-Jul-2015 Michael Brunner <mibru@gmx.de>

mfd: kempld-core: Add support for COMe-bBL6 and COMe-cBW6 to Kontron PLD driver

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.brunner@kontron.com>
Acked-by: Christian Rauch <christian.rauch@kontron.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# c8648508 26-Feb-2015 Ameya Palande <2ameya@gmail.com>

mfd: kempld-core: Fix callback return value check

On success, callback function returns 0. So invert the if condition
check so that we can break out of loop.

Cc: stable@vger.kernel.org
Signed-off-by: Ameya Palande <2ameya@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# fb358e43 27-Jan-2015 Michael Brunner <mibru@gmx.de>

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

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.brunner@kontron.com>
Acked-by: Christian Rauch <christian.rauch@kontron.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 78a83541 20-Oct-2014 Wolfram Sang <wsa@kernel.org>

mfd: drop owner assignment from platform_drivers

A platform_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 9ef4e935 21-Jul-2014 Lee Jones <lee.jones@linaro.org>

mfd: kempld-core: Correct a variety of checkpatch warnings

WARNING: line over 80 characters
+module_param_string(force_device_id, force_device_id, sizeof(force_device_id), 0);

WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt
+ msleep(1);

WARNING: __initdata should be placed after kempld_dmi_table[]
+static struct dmi_system_id __initdata kempld_dmi_table[] = {

WARNING: line over 80 characters
+ for (id = kempld_dmi_table; id->matches[0].slot != DMI_NONE; id++)

total: 0 errors, 4 warnings, 771 lines checked

This is part of an effort to clean-up the MFD subsystem.

Signed-off-by: Lee Jones <lee.jones@linaro.org>


# bd6d35a6 12-May-2014 Krzysztof Kozlowski <krzk@kernel.org>

mfd: kempld-core: Make mfd_cell array const

The kempld_devs (array of mfd_cells) can be safely made const.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Kevin Strasser <kevin.strasser@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 58a9e5b9 08-Apr-2014 Michael Brunner <mibru@gmx.de>

mfd: Add sysfs attributes for Kontron PLD firmware revision

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.brunner@kontron.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 204747c9 20-Mar-2014 Guenter Roeck <linux@roeck-us.net>

mfd: kempld-core: Fix potential hang-up during boot

On PXT and COMe-cPC2 boards it is observed that the hardware
mutex is acquired but not being released during initialization.
This can result in a hang-up during boot if the driver is built
into the kernel.

Releasing the mutex twice if it was acquired fixes the problem.
Subsequent request/release cycles work as expected, so the fix is
only needed during initialization.

Cc: <stable@vger.kernel.org>
Reviewed-by: Michael Brunner <michael.brunner@kontron.com>
Tested-by: Michael Brunner <michael.brunner@kontron.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# a3ee7509 24-Feb-2014 Michael Brunner <mibru@gmx.de>

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

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.brunner@kontron.com>
Acked-by: Christian Rauch <christian.rauch@kontron.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# c1d33b1b 09-Aug-2013 Michael Brunner <BrunnerMichael@t-online.de>

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

This patch adds DMI system IDs for the new Kontron modules COMe-bHL6 and
COMe-cTH6 to the Kontron PLD driver.

Acked-by: Kevin Strasser <strassek@engr.orst.edu>
Signed-off-by: Michael Brunner <michael.brunner@kontron.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 334a41ce 30-Jul-2013 Jingoo Han <jg1.han@samsung.com>

mfd: Use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# 43620a17 23-Jun-2013 Kevin Strasser <kevin.strasser@linux.intel.com>

mfd: Kontron PLD mfd driver

Add core MFD driver for the on-board PLD found on some Kontron embedded
modules. The PLD device may provide functions like watchdog, GPIO, UART
and I2C bus.

The following modules are supported:
* COMe-bIP#
* COMe-bPC2 (ETXexpress-PC)
* COMe-bSC# (ETXexpress-SC T#)
* COMe-cCT6
* COMe-cDC2 (microETXexpress-DC)
* COMe-cPC2 (microETXexpress-PC)
* COMe-mCT10
* ETX-OH

Originally-From: Michael Brunner <michael.brunner@kontron.com>
Signed-off-by: Kevin Strasser <kevin.strasser@linux.intel.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>