Commit Graph

5343 Commits

Author SHA1 Message Date
Nathan Chancellor d0583229bc i2c: designware: Mark dw_i2c_plat_{suspend,resume}() as __maybe_unused
When CONFIG_PM is set but CONFIG_PM_SLEEP is not, two compiler warnings
appear:

  drivers/i2c/busses/i2c-designware-platdrv.c:444:12: error: unused function 'dw_i2c_plat_suspend' [-Werror,-Wunused-function]
  static int dw_i2c_plat_suspend(struct device *dev)
             ^
  drivers/i2c/busses/i2c-designware-platdrv.c:465:12: error: unused function 'dw_i2c_plat_resume' [-Werror,-Wunused-function]
  static int dw_i2c_plat_resume(struct device *dev)
             ^
  2 errors generated.

These functions are only used in SET_LATE_SYSTEM_SLEEP_PM_OPS(), which
is defined as empty when CONFIG_PM_SLEEP is not defined. Mark the
functions as __maybe_unused to make it clear that these functions might
be unused in this configuration.

Fixes: c57813b8b2 ("i2c: designware: Lock the adapter while setting the suspended flag")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-11 21:54:21 +01:00
Kewei Xu 1bff55b57e i2c: mediatek: Add i2c compatible for Mediatek MT8168
Add i2c compatible for MT8168. Compare to MT2712 i2c controller,
MT8168 need to synchronize signal with dma.

Signed-off-by: Kewei Xu <kewei.xu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-11 21:54:21 +01:00
AngeloGioacchino Del Regno 0016a32f75 i2c: mt65xx: Simplify with clk-bulk
Since depending on the SoC or specific bus functionality some clocks
may be optional, we cannot get the benefit of using devm_clk_bulk_get()
but, by migrating to clk-bulk, we are able to remove the custom functions
mtk_i2c_clock_enable() and mtk_i2c_clock_disable(), increasing common
APIs usage, hence (lightly) decreasing kernel footprint.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-11 21:54:07 +01:00
Jean Delvare 52c74d17d8 i2c: i801: Drop two outdated comments
* Timeouts are reported even in interrupt mode since commit
  b3b8df9772 ("i2c: i801: Use wait_event_timeout to wait for
  interrupts") so drop the comment which claims this only happens in
  polled mode.
* xact does not include the PEC bit, as the driver does not support
  software PEC.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-11 21:33:08 +01:00
Robert Hancock 1d366c2f9d i2c: xiic: Make bus names unique
This driver is for an FPGA logic core, so there can be arbitrarily many
instances of the bus on a given system. Previously all of the I2C bus
names were "xiic-i2c" which caused issues with lm_sensors when trying to
map human-readable names to sensor inputs because it could not properly
distinguish the busses, for example. Append the platform device name to
the I2C bus name so it is unique between different instances.

Fixes: e1d5b6598c ("i2c: Add support for Xilinx XPS IIC Bus Interface")
Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Tested-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-02 22:26:41 +01:00
Jean Delvare 55b6f82e94 i2c: i801: Add support for the Process Call command
The Process Call command is implemented by the hardware since the very
first Intel 82801 chipset, and trivial to support. Oscar Romero
Matamala from the Georgia Institute of Technology told me it is needed
for an experiment his team is working on at the moment, so let's just
add support for it.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-02 22:12:01 +01:00
Jean Delvare 9c02c6391c i2c: i801: Drop useless masking in i801_access
I went all the way back to kernel 2.6.12 and that masking was never
needed. I suppose it was there in anticipation of software PEC
support, but that was never added to the driver (and never will be,
as this is made obsolete by hardware PEC).

I'm also removing initialization to 0, which is not needed either,
and would prevent the compiler from reporting an actual usage of
uninitialized variables.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-02 22:11:42 +01:00
Akhil R d7583c8a57 i2c: tegra: Add SMBus block read function
Emulate SMBus block read using ContinueXfer to read the length byte

Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 20:34:00 +01:00
Hans de Goede 80704a84a9 i2c: designware: Use the i2c_mark_adapter_suspended/resumed() helpers
Use the i2c_mark_adapter_suspended/resumed() i2c-core helpers and rely
on the i2c-core's suspended checking instead of using DIY code.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 16:31:39 +01:00
Hans de Goede c57813b8b2 i2c: designware: Lock the adapter while setting the suspended flag
Lock the adapter while setting the suspended flag, to ensure that other
locked code always sees the change immediately, rather then possibly using
a stale value.

This involves splitting the suspend/resume callbacks into separate runtime
and normal suspend/resume calls. This is necessary because i2c_dw_xfer()
will get called by the i2c-core with the adapter locked and it in turn
calls the runtime-resume callback through pm_runtime_get_sync().

So the runtime versions of the suspend/resume callbacks cannot take
the adapter-lock. Note this patch simply makes the runtime suspend/resume
callbacks not deal with the suspended flag at all. During runtime the
pm_runtime_get_sync() from i2c_dw_xfer() will always ensure that the
adapter is resumed when necessary.

The suspended flag check is only necessary to check proper suspend/resume
ordering during normal suspend/resume which makes the pm_runtime_get_sync()
call a no-op.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 16:30:53 +01:00
Xu Wang 5b9df0acd2 i2c: mediatek: remove redundant null check
Because clk_disable_unprepare already checked NULL clock parameter,
so the additional checks are unnecessary, just remove it

Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 16:22:23 +01:00
Kewei Xu b5a796c6a8 i2c: mediatek: modify bus speed calculation formula
When clock-div is 0 or greater than 1, the bus speed
calculated by the old speed calculation formula will be
larger than the target speed. So we update the formula.

Signed-off-by: Kewei Xu <kewei.xu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 16:16:38 +01:00
Jan Dabros 17ba1e87fc i2c: designware: Fix improper usage of readl
Kernel test robot reported incorrect type in argument 1 of readl(), but
more importantly it brought attention that MMIO accessor shouldn't be
used in this case, since req->hdr.status is part of a command-response
buffer in system memory.

Since its value may be altered by PSP outside of the scope of current
thread (somehow similar to IRQ handler case), we need to use
READ_ONCE() to ensure compiler won't optimize this call.

Fix also 'status' variable type to reflect that corresponding field in
command-response buffer is platform-independent u32.

Fixes: 78d5e9e299 ("i2c: designware: Add AMD PSP I2C bus support")
Signed-off-by: Jan Dabros <jsd@semihalf.com>
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 16:12:42 +01:00
Vinod Koul d8703554f4 i2c: qcom-geni: Add support for GPI DMA
QUP Serial engines supports data transfers thru FIFO mode, SE DMA mode
and lastly GPI DMA mode. Former two are already supported and this adds
supports for the last mode.

In GPI DMA mode, the firmware is issued commands by driver to perform
DMA and setup the serial port.

Signed-off-by: Vinod Koul <vkoul@kernel.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 16:08:59 +01:00
Lad Prabhakar da2e86c0bd i2c: riic: Simplify reset handling
Read reset phandle as optional instead of exclusive so that all the DT's
passing the reset phandle can be used to assert/deassert the reset line.
With this change we don't have to differentiate the RZ/G2L SoC.

With the above changes we no longer need the "renesas,riic-r9a07g044"
compatible string, so drop it from riic_i2c_dt_ids[]. No changes are
required to the r9a07g044.dtsi as we already have "renesas,riic-rz" as a
fallback compatible string.

While at it, check the return code of reset_control_deassert() as it might
fail and also add a devres action to assert the reset line.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 16:05:01 +01:00
Sebastian Andrzej Siewior a5ea32579f i2c: cht-wc: Use generic_handle_irq_safe().
Instead of manually disabling interrupts before invoking use
generic_handle_irq_safe() which can be invoked with enabled and disabled
interrupts.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 15:58:57 +01:00
Sebastian Andrzej Siewior 68ea1b2c33 i2c: core: Use generic_handle_irq_safe() in i2c_handle_smbus_host_notify().
The i2c-i801 driver invokes i2c_handle_smbus_host_notify() from his
interrupt service routine. On PREEMPT_RT i2c-i801's handler is forced
threaded with enabled interrupts which leads to a warning by
handle_irq_event_percpu() assuming that irq_default_primary_handler()
enabled interrupts.

i2c-i801's interrupt handler can't be made non-threaded because the
interrupt line is shared with other devices.

Use generic_handle_irq_safe() which can invoked with disabled and enabled
interrupts.

Reported-by: Michael Below <below@judiz.de>
Link: https://bugs.debian.org/1002537
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-03-01 15:58:41 +01:00
Wolfram Sang 24e3bb7429 Merge tag 'irq-api-2022-02-21' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into i2c/for-mergewindow
Provide a tag for maintainers to pull the generic_handle_irq_safe() API.
2022-02-23 14:14:15 +01:00
Andy Shevchenko 8302532f47 i2c: smbus: Check for parent device before dereference
An I²C adapter might be instantiated without parent. In such case
there is no property can be retrieved. Skip SMBus alert setup when
this happens.

Fixes: a263a84088 ("i2c: smbus: Use device_*() functions instead of of_*()")
Reported-by: syzbot+0591ccf54ee05344e4eb@syzkaller.appspotmail.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-19 12:37:20 +01:00
Rafał Miłecki 834cea3a25 i2c: brcmstb: fix support for DSL and CM variants
DSL and CM (Cable Modem) support 8 B max transfer size and have a custom
DT binding for that reason. This driver was checking for a wrong
"compatible" however which resulted in an incorrect setup.

Fixes: e2e5a2c618 ("i2c: brcmstb: Adding support for CM and DSL SoCs")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-18 10:37:33 +01:00
Vladimir Zapolskiy 017b32e6da i2c: qcom-cci: add sm8450 compatible
Add QCOM SM8450 specific compatible for CCI controller, which is
equal to CCI controllers found on QCOM SDM845 and QCOM SM8250 SoCs.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-18 10:01:24 +01:00
Martin Povišer 19e138e43a i2c: pasemi: Drop I2C classes from platform driver variant
Drop I2C device-probing classes from platform variant of the PASemi
controller as it is only used on platforms where I2C devices should
be instantiated in devicetree. (The I2C_CLASS_DEPRECATED flag is not
raised as up to this point no devices relied on the old behavior.)

Fixes: d88ae2932d ("i2c: pasemi: Add Apple platform driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 10:28:34 +01:00
Wolfram Sang 5de7179740 i2c: qup: allow COMPILE_TEST
Driver builds fine with COMPILE_TEST. Enable it for wider test coverage
and easier maintenance.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 10:13:52 +01:00
Wolfram Sang 2ce4462f27 i2c: imx: allow COMPILE_TEST
Driver builds fine with COMPILE_TEST. Enable it for wider test coverage
and easier maintenance.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
2022-02-15 10:13:49 +01:00
Wolfram Sang 0b0dcb3882 i2c: cadence: allow COMPILE_TEST
Driver builds fine with COMPILE_TEST. Enable it for wider test coverage
and easier maintenance.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
Acked-by: Michal Simek <michal.simek@xilinx.com>
2022-02-15 10:13:44 +01:00
Yang Li 1e4fe5430b i2c: designware: remove unneeded semicolon
Eliminate the following coccicheck warnings:
./drivers/i2c/busses/i2c-designware-amdpsp.c:172:2-3: Unneeded semicolon
./drivers/i2c/busses/i2c-designware-amdpsp.c:245:2-3: Unneeded semicolon

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Jan Dabros <jsd@semihalf.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 10:11:33 +01:00
Andy Shevchenko 531310dd5d i2c: designware-pci: Switch to use i2c_new_ccgx_ucsi()
Instead of open coded variant switch to use i2c_new_ccgx_ucsi().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 10:05:07 +01:00
Andy Shevchenko c74a30ce13 i2c: nvidia-gpu: Convert to use dev_err_probe()
It's fine to call dev_err_probe() in ->probe() when error code is known.
Convert the driver to use dev_err_probe().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 10:05:02 +01:00
Andy Shevchenko c2c25be6dc i2c: nvidia-gpu: Use temporary variable for struct device
Use temporary variable for struct device to make code neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 10:05:00 +01:00
Andy Shevchenko 2079563d6f i2c: nvidia-gpu: Switch to use i2c_new_ccgx_ucsi()
Instead of open coded variant switch to use i2c_new_ccgx_ucsi().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 10:04:57 +01:00
Andy Shevchenko 4ebf4987c0 i2c: Introduce common module to instantiate CCGx UCSI
Introduce a common module to provide an API to instantiate UCSI device
for Cypress CCGx Type-C controller. Individual bus drivers need to select
this one on demand.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 10:04:53 +01:00
Jarkko Nikula 9c02d4011e i2c: i801: Add support for Intel Raptor Lake PCH-S
Add SMBus PCI ID on Intel Raptor Lake PCH-S.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 10:03:40 +01:00
Wolfram Sang 481153991c i2c: don't expose function which is only used internally
i2c_setup_smbus_alert() is only needed within the I2C core, so no need
to expose it to other modules.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-15 09:58:57 +01:00
Vladimir Zapolskiy 02a4a69667 i2c: qcom-cci: don't put a device tree node before i2c_add_adapter()
There is a minor chance for a race, if a pointer to an i2c-bus subnode
is stored and then reused after releasing its reference, and it would
be sufficient to get one more reference under a loop over children
subnodes.

Fixes: e517526195 ("i2c: Add Qualcomm CCI I2C driver")
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 18:43:08 +01:00
Vladimir Zapolskiy a0d48505a1 i2c: qcom-cci: don't delete an unregistered adapter
If i2c_add_adapter() fails to add an I2C adapter found on QCOM CCI
controller, on error path i2c_del_adapter() is still called.

Fortunately there is a sanity check in the I2C core, so the only
visible implication is a printed debug level message:

    i2c-core: attempting to delete unregistered adapter [Qualcomm-CCI]

Nevertheless it would be reasonable to correct the probe error path.

Fixes: e517526195 ("i2c: Add Qualcomm CCI I2C driver")
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 18:42:33 +01:00
Rafał Miłecki d0aee048d6 i2c: brcmstb: allow compiling on BCM4908
BCM4908 SoCs use the same I2C hardware block as STB and BCM63xx devices.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 18:34:38 +01:00
Geert Uytterhoeven ea01b71b07 i2c: rcar: Add R-Car Gen4 support
Add support for the I2C Bus Interface on R-Car Gen4 SoCs (e.g. R-Car
S4-8) by matching on a family-specific compatible value.

While I2C on R-Car Gen4 does support some extra features (Slave Clock
Stretch Select), for now it is treated the same as I2C on R-Car Gen3.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
[wsa: removed incorrect "FM+" from commit message]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 18:32:02 +01:00
Jan Dabros 78d5e9e299 i2c: designware: Add AMD PSP I2C bus support
Implement an I2C controller sharing mechanism between the host (kernel)
and PSP co-processor on some platforms equipped with AMD Cezanne SoC.

On these platforms we need to implement "software" i2c arbitration.
Default arbitration owner is PSP and kernel asks for acquire as well
as inform about release of the i2c bus via mailbox mechanism.

            +---------+
 <- ACQUIRE |         |
  +---------|   CPU   |\
  |         |         | \      +----------+  SDA
  |         +---------+  \     |          |-------
MAILBOX                   +--> |  I2C-DW  |  SCL
  |         +---------+        |          |-------
  |         |         |        +----------+
  +---------|   PSP   |
   <- ACK   |         |
            +---------+

            +---------+
 <- RELEASE |         |
  +---------|   CPU   |
  |         |         |        +----------+  SDA
  |         +---------+        |          |-------
MAILBOX                   +--> |  I2C-DW  |  SCL
  |         +---------+  /     |          |-------
  |         |         | /      +----------+
  +---------|   PSP   |/
   <- ACK   |         |
            +---------+

The solution is similar to i2c-designware-baytrail.c implementation, where
we are using a generic i2c-designware-* driver with a small "wrapper".

In contrary to baytrail semaphore implementation, beside internal
acquire_lock() and release_lock() methods we are also applying quirks to
lock_bus() and unlock_bus() global adapter methods. With this in place
all i2c clients drivers may lock i2c bus for a desired number of i2c
transactions (e.g. write-wait-read) without being aware of that such bus
is shared with another entity.

Modify i2c_dw_probe_lock_support() to select correct semaphore
implementation at runtime, since now we have more than one available.

Configure new matching ACPI ID "AMDI0019" and register
ARBITRATION_SEMAPHORE flag in order to distinguish setup with PSP
arbitration.

Add myself as a reviewer for I2C DesignWare in order to help with reviewing
and testing possible changes touching new i2c-designware-amdpsp.c module.

Signed-off-by: Jan Dabros <jsd@semihalf.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
[wsa: removed unneeded blank line and curly braces]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 15:38:23 +01:00
Jan Dabros 6960331dee i2c: designware: Add missing locks
All accesses to controller's registers should be protected on
probe, disable and xfer paths. This is needed for i2c bus controllers
that are shared with but not controller by kernel.

Signed-off-by: Jan Dabros <jsd@semihalf.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 15:38:23 +01:00
Terry Bowman 6cf72f4180 i2c: piix4: Enable EFCH MMIO for Family 17h+
Enable EFCH MMIO using check for SMBus PCI revision ID value 0x51 or
greater. This PCI revision ID check will enable family 17h and future
AMD processors with the same EFCH SMBus controller HW.

Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 15:38:23 +01:00
Terry Bowman 381a3083c6 i2c: piix4: Add EFCH MMIO support for SMBus port select
AMD processors include registers capable of selecting between 2 SMBus
ports. Port selection is made during each user access by writing to
FCH::PM::DECODEEN[smbus0sel]. Change the driver to use MMIO during
SMBus port selection because cd6h/cd7h port I/O is not available on
later AMD processors.

Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 15:38:22 +01:00
Terry Bowman 46967bc1ee i2c: piix4: Add EFCH MMIO support to SMBus base address detect
The EFCH SMBus controller's base address is determined using details in
FCH::PM::DECODEEN[smbusasfiobase] and FCH::PM::DECODEEN[smbusasfioen].These
register fields were accessed using cd6h/cd7h port I/O. cd6h/cd7h port I/O
is no longer available in later AMD processors. Change base address
detection to use MMIO instead of port I/O cd6h/cd7h.

Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 15:38:22 +01:00
Terry Bowman 7c148722d0 i2c: piix4: Add EFCH MMIO support to region request and release
EFCH cd6h/cd7h port I/O may no longer be available on later AMD
processors and it is recommended to use MMIO instead. Update the
request and release functions to support MMIO.

MMIO request/release and mmapping require details during cleanup.
Add a MMIO configuration structure containing resource and vaddress
details for mapping the region, accessing the region, and releasing
the region.

Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
[wsa: rebased after fixup in previous patch]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 15:38:03 +01:00
Terry Bowman fbafbd51bf i2c: piix4: Move SMBus port selection into function
Move port selection code into a separate function. Refactor is in
preparation for following MMIO changes.

Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 15:34:50 +01:00
Terry Bowman 0a59a24e14 i2c: piix4: Move SMBus controller base address detect into function
Move SMBus controller base address detection into function. Refactor
is in preparation for following MMIO changes.

Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 15:34:49 +01:00
Terry Bowman a3325d225b i2c: piix4: Move port I/O region request/release code into functions
Move duplicated region request and release code into a function. Move is
in preparation for following MMIO changes.

Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
[wsa: added missing curly brace]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-11 15:33:58 +01:00
Terry Bowman 93102cb449 i2c: piix4: Replace hardcoded memory map size with a #define
Replace number constant with #define to improve readability and
maintainability.

Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-10 22:45:41 +01:00
Jonathan Neuschäfer 0c47dd7d09 i2c: npcm7xx: Fix typos
The comments in this driver have a few typos. Let's fix them.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: tali.perry@nuvoton.com
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-07 17:03:36 +01:00
Rafael J. Wysocki 0bc4978a67 i2c: ACPI: Replace acpi_bus_get_device()
Replace acpi_bus_get_device() that is going to be dropped with
acpi_fetch_acpi_dev().

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-07 17:00:08 +01:00
Eric Anholt 9495b9b31a i2c: bcm2835: Avoid clock stretching timeouts
The CLKT register contains at poweron 0x40, which at our typical 100kHz
bus rate means .64ms. But there is no specified limit to how long devices
should be able to stretch the clocks, so just disable the timeout. We
still have a timeout wrapping the entire transfer.

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
BugLink: https://github.com/raspberrypi/linux/issues/3064
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-07 16:09:48 +01:00
Christophe JAILLET b205f58502 i2c: bcm2835: Fix the error handling in 'bcm2835_i2c_probe()'
Some resource should be released if an error occurs in
'bcm2835_i2c_probe()'.
Add an error handling path and the needed 'clk_disable_unprepare()' and
'clk_rate_exclusive_put()' calls.

While at it, rework the bottom of the function to use this newly added
error handling path and have an explicit and more standard "return 0;" at
the end of the normal path.

Fixes: bebff81fb8 ("i2c: bcm2835: Model Divider in CCF")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
[wsa: rebased]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-07 15:52:41 +01:00
Christophe JAILLET 951285e59e i2c: amd-mp2: Remove useless DMA-32 fallback configuration
As stated in [1], dma_set_mask() with a 64-bit mask never fails if
dev->dma_mask is non-NULL. So, if it fails, the 32 bits case will also
fail for the same reason.

Simplify code and remove some dead code accordingly.

[1]: https://lkml.org/lkml/2021/6/7/398

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Nehal Bakulchandra Shah <Nehal-bakulchandra.Shah@amd.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-02-07 15:32:14 +01:00
Hans de Goede 4b32649140 i2c: cht-wc: Make charger i2c-client instantiation board/device-model specific
The i2c-controller on the Cherry Trail - Whiskey Cove PMIC is special
in that it is always connected to the I2C charger IC of the board on
which the PMIC is used; and the charger IC is not described in ACPI,
so the i2c-cht-wc code needs to instantiate an i2c-client for it itself.

So far this was hardcoded to instantiate an i2c-client for the
bq24292i, with all properties, etc. set to match how this charger
is used on the GPD win and GPD pocket devices.

There is a rudimentary check to make sure the ACPI tables are at least
somewhat as expected, but this is far from accurate, leading to
a wrong i2c-client being instantiated for the charger on some boards.

Switch to the new DMI based intel_cht_wc_get_model() helper which is
exported by the MFD driver for the CHT Whiskey Cove PMIC to help PMIC
cell drivers like the i2c-cht-wc code reliably detect which board
they are running on.

And add board_info for the charger ICs as found on the other 2 known
boards with a Whisky Cove PMIC.

This has been tested on all 3 known boards.

Acked-by: Wolfram Sang <wsa@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
2022-02-01 14:55:12 +01:00
Kewei Xu 934705316f i2c: mediatek: Add i2c compatible for Mediatek MT8186
Add i2c compatible for MT8186. Compare to MT8192 i2c controller,
MT8186 doesn't need handshake signal witch apdma.

Signed-off-by: Kewei Xu <kewei.xu@mediatek.com>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-01-28 22:48:06 +01:00
Akhil R a263a84088 i2c: smbus: Use device_*() functions instead of of_*()
Change of_*() functions to device_*() for firmware agnostic usage.
This allows to have the smbus_alert interrupt without any changes
in the controller drivers using the ACPI table.

Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-01-28 21:56:34 +01:00
Linus Torvalds 3bf6a9e36e virtio,vdpa,qemu_fw_cfg: features, cleanups, fixes
partial support for < MAX_ORDER - 1 granularity for virtio-mem
 driver_override for vdpa
 sysfs ABI documentation for vdpa
 multiqueue config support for mlx5 vdpa
 
 Misc fixes, cleanups.
 
 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQFDBAABCAAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmHiDHkPHG1zdEByZWRo
 YXQuY29tAAoJECgfDbjSjVRpVT4H/3Veixt3uYPOmuLU2tSx+8X+sFTtik81hyiE
 okz5fRJrxxA8SqS76FnmO10FS4hlPOGNk0Z5WVhr0yihwFvPLvpCM/xi2Lmrz9I7
 pB0sXOIocEL1xApsxukR9K1Twpb2hfYsflbJYUVlRfhS5G0izKJNZp5I7OPrzd80
 vVNNDWKW2iLDlfqsavumI4Kvm4nsFuCHG03jzMtcIa7YTXYV3DORD4ZGFFVUOIQN
 t5F74TznwHOeYgJeg7TzjFjfPWmXjLetvx10QX1A1uOvwppWW/QY6My0UafTXNXj
 VB3gOwJPf+gxXAXl/4bafq4NzM0xys6cpcPpjvhmU+erY4UuyAU=
 =Y1eO
 -----END PGP SIGNATURE-----

Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

Pull virtio updates from Michael Tsirkin:
 "virtio,vdpa,qemu_fw_cfg: features, cleanups, and fixes.

   - partial support for < MAX_ORDER - 1 granularity for virtio-mem

   - driver_override for vdpa

   - sysfs ABI documentation for vdpa

   - multiqueue config support for mlx5 vdpa

   - and misc fixes, cleanups"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (42 commits)
  vdpa/mlx5: Fix tracking of current number of VQs
  vdpa/mlx5: Fix is_index_valid() to refer to features
  vdpa: Protect vdpa reset with cf_mutex
  vdpa: Avoid taking cf_mutex lock on get status
  vdpa/vdpa_sim_net: Report max device capabilities
  vdpa: Use BIT_ULL for bit operations
  vdpa/vdpa_sim: Configure max supported virtqueues
  vdpa/mlx5: Report max device capabilities
  vdpa: Support reporting max device capabilities
  vdpa/mlx5: Restore cur_num_vqs in case of failure in change_num_qps()
  vdpa: Add support for returning device configuration information
  vdpa/mlx5: Support configuring max data virtqueue
  vdpa/mlx5: Fix config_attr_mask assignment
  vdpa: Allow to configure max data virtqueues
  vdpa: Read device configuration only if FEATURES_OK
  vdpa: Sync calls set/get config/status with cf_mutex
  vdpa/mlx5: Distribute RX virtqueues in RQT object
  vdpa: Provide interface to read driver features
  vdpa: clean up get_config_size ret value handling
  virtio_ring: mark ring unused on error
  ...
2022-01-18 10:05:48 +02:00
Michael S. Tsirkin d9679d0013 virtio: wrap config->reset calls
This will enable cleanups down the road.
The idea is to disable cbs, then add "flush_queued_cbs" callback
as a parameter, this way drivers can flush any work
queued after callbacks have been disabled.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Link: https://lore.kernel.org/r/20211013105226.20225-1-mst@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2022-01-14 18:50:52 -05:00
Linus Torvalds 112450df61 Merge branch 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:
 "Mostly driver updates and refactorization.

  The removal of the XLR driver and the i801 refactoring stand out a
  little. In the core, we enabled async suspend/resume for I2C
  controllers and their clients. No issues were reported during the test
  phase in -next. We will see how this goes for mainline"

* 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (54 commits)
  i2c: sh_mobile: remove unneeded semicolon
  i2c: riic: Use platform_get_irq() to get the interrupt
  i2c: sh_mobile: Use platform_get_irq_optional() to get the interrupt
  i2c: bcm2835: Use platform_get_irq() to get the interrupt
  i2c: aspeed: Remove unused includes
  dt-bindings: i2c: aspeed: Drop stray '#interrupt-cells'
  i2c: sh_mobile: update to new DMAENGINE API when terminating
  i2c: rcar: update to new DMAENGINE API when terminating
  i2c: exynos5: Fix getting the optional clock
  i2c: designware-pci: Convert to use dev_err_probe()
  i2c: designware-pci: use __maybe_unused for PM functions
  i2c: designware-pci: Group MODULE_*() macros
  i2c: designware-pci: Add a note about struct dw_scl_sda_cfg usage
  i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters
  i2c: designware: Do not complete i2c read without RX_FULL interrupt
  eeprom: at24: Add support for 24c1025 EEPROM
  dt-bindings: at24: add at24c1025
  i2c: tegra: use i2c_timings for bus clock freq
  dt-bindings: at24: Rework special case compatible handling
  i2c: i801: Don't clear status flags twice in interrupt mode
  ...
2022-01-14 16:19:38 +01:00
Yang Li bf3c39f5da i2c: sh_mobile: remove unneeded semicolon
Eliminate the following coccicheck warning:
./drivers/i2c/busses/i2c-sh_mobile.c:849:3-4: Unneeded semicolon

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-01-11 21:11:24 +01:00
Linus Torvalds bca21755b9 ACPI updates for 5.17-rc1
- Update ACPICA code in the kernel to the 20211217 upstream release
    including the following changes:
 
    * iASL/Disassembler: Additional support for NHLT table (Bob Moore).
    * Change a return_ACPI_STATUS (AE_BAD_PARAMETER) (Bob Moore).
    * Fix a couple of warnings under MSVC (Bob Moore).
    * iASL: Add TDEL table to both compiler/disassembler (Bob Moore).
    * iASL/NHLT table: "Specific Data" field support (Bob Moore).
    * Use original data_table_region pointer for accesses (Jessica
      Clarke).
    * Use original pointer for virtual origin tables (Jessica Clarke).
    * Macros: Remove ACPI_PHYSADDR_TO_PTR (Jessica Clarke).
    * Avoid subobject buffer overflow when validating RSDP signature
      (Jessica Clarke).
    * iASL: Add suppport for AGDI table (Ilkka Koskinen).
    * Hardware: Do not flush CPU cache when entering S4 and S5 (Kirill
      A. Shutemov).
    * Expand the ACPI_ACCESS_ definitions (Mark Langsdorf).
    * Utilities: Avoid deleting the same object twice in a row (Rafael
      Wysocki).
    * Executer: Fix REFCLASS_REFOF case in acpi_ex_opcode_1A_0T_1R()
      (Rafael Wysocki).
    * Fix AEST Processor generic resource substructure data field byte
      length (Shuuichirou Ishii).
    * Fix wrong interpretation of PCC address (Sudeep Holla).
    * Add support for PCC Opregion special context data (Sudeep Holla).
 
  - Implement OperationRegion handler for PCC Type 3 subtype (Sudeep
    Holla).
 
  - Introduce acpi_fetch_acpi_dev() as a replacement for
    acpi_bus_get_device() and use it in the ACPI subsystem (Rafael
    Wysocki).
 
  - Avoid using _CID for device enumaration if _HID is missing or
    invalid (Rafael Wysocki).
 
  - Rework quirk handling during ACPI device enumeration and add some
    new quirks for known broken platforms (Hans de Goede).
 
  - Avoid unnecessary or redundant CPU cache flushing during system
    PM transitions (Kirill A. Shutemov).
 
  - Add PM debug messages related to power resources (Rafael Wysocki).
 
  - Fix kernel-doc comment in the PCI host bridge ACPI driver (Yang Li).
 
  - Rework flushing of EC work while suspended to idle and clean up
    the handling of events in the ACPI EC driver (Rafael Wysocki).
 
  - Prohibit ec_sys module parameter write_support from being used
    when the system is locked down (Hans de Goede).
 
  - Make the ACPI processor thermal driver use cpufreq_cpu_get() to
    check for presence of cpufreq policy (Manfred Spraul).
 
  - Avoid unnecessary CPU cache flushing in the ACPI processor idle
    driver (Kirill A. Shutemov).
 
  - Replace kernel.h with the necessary inclusions in the ACPI
    processor driver (Andy Shevchenko).
 
  - Use swap() instead of open coding it in the ACPI processor idle
    driver (Guo Zhengkui).
 
  - Fix the handling of defective LPAT in the ACPI xpower PMIC driver
    and clean up some definitions of PMIC data structures (Hans de
    Goede).
 
  - Fix outdated comment in the ACPI DPTF driver (Sumeet Pawnikar).
 
  - Add AEST to the list of known ACPI table signatures (Shuuichirou
    Ishii).
 
  - Make ACPI NUMA code take hotpluggable memblocks into account when
    CONFIG_MEMORY_HOTPLUG is not set (Vitaly Kuznetsov).
 
  - Use default_groups in kobj_type in the ACPI sysfs code (Greg
    Kroah-Hartman).
 
  - Rearrange _CPC structure documentation (Andy Shevchenko).
 
  - Drop an always true check from the ACPI thermal driver (Adam
    Borowski).
 
  - Add new "not charging" quirk for Lenovo ThinkPads to the ACPI
    battery driver (Thomas Weißschuh).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmHcgasSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxY0sP/RaSSJ/T10aKRkrGHgsdd+XV5xcnrZEZ
 Kt/QLRLHB0hAChwzquLmeZ0URk+OUhiH2YCIQCIx9vUGFnSBYiuz8wbyGmqtsQ6Y
 0VmBiCMYGQA4wBMNyLphKg5xp8iyYuHotCtAntuiK7bHP1779r0GUFrcuSYk0K0Q
 LPNomP0wCX/iNrjEAvfmvCUohys5QPVh9V0rrB9gZ5jbpCigJVm77jfbReG83A9P
 FXMYC0MZ3z2oi9N5HAqr4+K8FIW6leYmg7FVie85nEYPO0oUig+kLmbzhTi7hGEu
 mQ/Yz3G1vq8tphL7X5v+ayTqNQD28rPUW5P0pXcMpU+Z4R/O4VsL0PMToms8Ybcu
 z/vArFmY9CFjVe7Z0U0ZgYt+2tXg1n06vCca+Jjll8IvCz7SLxU6ZHgvzZuMxinS
 HN+lpYAyeDQXOXg18h3Q4p177FIwvcAgx/Ntl3zfQw6aC0kCMTfc9hdbDhW5pFQ+
 emqf8QboP+7o5JnRk1NrXBHDxvqYbHelUY7qcaVoL2GvFLVuFVes1VGMNgfAQy7y
 bfdl7LECv5XWJqS6Zn7RlrKQnJbNkWC7L7Gp1Od+dyEofH/ICiBfXt2ZAUoqJeQm
 gzLKJPoFtTC0mHUz6qUN9AwBobZtI8wk/JeTpnhNLkrfpqQYnSssqDMIktUwMjpr
 YQUIQ7gVrhTf
 =IGwJ
 -----END PGP SIGNATURE-----

Merge tag 'acpi-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These are usual ACPICA code updates (although there are more of them
  than in the last few releases), a noticeable EC driver update (which
  mostly consists of cleanups, though), the device enumeration quirks
  handling rework from Hans, some updates eliminating unnecessary CPU
  cache flushing in some places (processor idle and system-wide PM code)
  and a bunch of assorted cleanups and fixes.

  Specifics:

   - Update ACPICA code in the kernel to the 20211217 upstream release
     including the following changes:

      - iASL/Disassembler: Additional support for NHLT table (Bob
        Moore).
      - Change a return_ACPI_STATUS (AE_BAD_PARAMETER) (Bob Moore).
      - Fix a couple of warnings under MSVC (Bob Moore).
      - iASL: Add TDEL table to both compiler/disassembler (Bob Moore).
      - iASL/NHLT table: "Specific Data" field support (Bob Moore).
      - Use original data_table_region pointer for accesses (Jessica
        Clarke).
      - Use original pointer for virtual origin tables (Jessica Clarke).
      - Macros: Remove ACPI_PHYSADDR_TO_PTR (Jessica Clarke).
      - Avoid subobject buffer overflow when validating RSDP signature
        (Jessica Clarke).
      - iASL: Add suppport for AGDI table (Ilkka Koskinen).
      - Hardware: Do not flush CPU cache when entering S4 and S5 (Kirill
        A. Shutemov).
      - Expand the ACPI_ACCESS_ definitions (Mark Langsdorf).
      - Utilities: Avoid deleting the same object twice in a row (Rafael
        Wysocki).
      - Executer: Fix REFCLASS_REFOF case in acpi_ex_opcode_1A_0T_1R()
        (Rafael Wysocki).
      - Fix AEST Processor generic resource substructure data field byte
        length (Shuuichirou Ishii).
      - Fix wrong interpretation of PCC address (Sudeep Holla).
      - Add support for PCC Opregion special context data (Sudeep
        Holla).

   - Implement OperationRegion handler for PCC Type 3 subtype (Sudeep
     Holla).

   - Introduce acpi_fetch_acpi_dev() as a replacement for
     acpi_bus_get_device() and use it in the ACPI subsystem (Rafael
     Wysocki).

   - Avoid using _CID for device enumaration if _HID is missing or
     invalid (Rafael Wysocki).

   - Rework quirk handling during ACPI device enumeration and add some
     new quirks for known broken platforms (Hans de Goede).

   - Avoid unnecessary or redundant CPU cache flushing during system PM
     transitions (Kirill A. Shutemov).

   - Add PM debug messages related to power resources (Rafael Wysocki).

   - Fix kernel-doc comment in the PCI host bridge ACPI driver (Yang
     Li).

   - Rework flushing of EC work while suspended to idle and clean up the
     handling of events in the ACPI EC driver (Rafael Wysocki).

   - Prohibit ec_sys module parameter write_support from being used when
     the system is locked down (Hans de Goede).

   - Make the ACPI processor thermal driver use cpufreq_cpu_get() to
     check for presence of cpufreq policy (Manfred Spraul).

   - Avoid unnecessary CPU cache flushing in the ACPI processor idle
     driver (Kirill A. Shutemov).

   - Replace kernel.h with the necessary inclusions in the ACPI
     processor driver (Andy Shevchenko).

   - Use swap() instead of open coding it in the ACPI processor idle
     driver (Guo Zhengkui).

   - Fix the handling of defective LPAT in the ACPI xpower PMIC driver
     and clean up some definitions of PMIC data structures (Hans de
     Goede).

   - Fix outdated comment in the ACPI DPTF driver (Sumeet Pawnikar).

   - Add AEST to the list of known ACPI table signatures (Shuuichirou
     Ishii).

   - Make ACPI NUMA code take hotpluggable memblocks into account when
     CONFIG_MEMORY_HOTPLUG is not set (Vitaly Kuznetsov).

   - Use default_groups in kobj_type in the ACPI sysfs code (Greg
     Kroah-Hartman).

   - Rearrange _CPC structure documentation (Andy Shevchenko).

   - Drop an always true check from the ACPI thermal driver (Adam
     Borowski).

   - Add new "not charging" quirk for Lenovo ThinkPads to the ACPI
     battery driver (Thomas Weißschuh)"

* tag 'acpi-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (64 commits)
  ACPI: PCC: Implement OperationRegion handler for the PCC Type 3 subtype
  ACPI / x86: Skip AC and battery devices on x86 Android tablets with broken DSDTs
  ACPI / x86: Introduce an acpi_quirk_skip_acpi_ac_and_battery() helper
  ACPI: processor: thermal: avoid cpufreq_get_policy()
  serdev: Do not instantiate serdevs on boards with known bogus DSDT entries
  i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries
  ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration() helpers
  ACPI: scan: Create platform device for BCM4752 and LNV4752 ACPI nodes
  PCI/ACPI: Fix acpi_pci_osc_control_set() kernel-doc comment
  ACPI: battery: Add the ThinkPad "Not Charging" quirk
  ACPI: sysfs: use default_groups in kobj_type
  ACPICA: Update version to 20211217
  ACPICA: iASL/NHLT table: "Specific Data" field support
  ACPICA: iASL: Add suppport for AGDI table
  ACPICA: iASL: Add TDEL table to both compiler/disassembler
  ACPICA: Fixed a couple of warnings under MSVC
  ACPICA: Change a return_ACPI_STATUS (AE_BAD_PARAMETER)
  ACPICA: Hardware: Do not flush CPU cache when entering S4 and S5
  ACPICA: Add support for PCC Opregion special context data
  ACPICA: Fix wrong interpretation of PCC address
  ...
2022-01-10 20:26:56 -08:00
Linus Torvalds 9bcbf894b6 media updates for v5.17-rc1
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE+QmuaPwR3wnBdVwACF8+vY7k4RUFAmHPqrMACgkQCF8+vY7k
 4RUM2g//VzdGU6kq19k7++N7ewGV1VhTnwAXCzdjjMuigdYpTnH/i2fIN/3BS2Mw
 RQVTc3Ys26SGdaKCPsMONKjNwQk62hiaQGW4gwnCZ9Me+hgR3e6z67rJa6XWpKuw
 aH81Z+XFfyn3Oo8qu7jqCABRCWXfKuxs8Vmc8XdcjvrqlREpiQ0c10oXiboeOoWE
 RmVPrnJ94pK8J859dO01cRkDCCo2G9AL9vnBHVA5050VEskSb20+8EmJQDfmkgsO
 Itd6JpCK97QTH5gtF44iO3CDWi5f3x9ODWJkQXJEZRAiKORZkcQUpCOXafQjb2vN
 YgxO86F/sD7XlhZ3V5AjvztZuQPTmnLNcgnrIVUa7iCAWDft1xBIsjQ+BxV9uROe
 g3/Yl6J+Y2Qi+wfAVhCJ94pfA2ZCIoN/+loVi9TQ22X4+tbr6+K4qWu3y1eu9bTW
 TYVD//nUMZz/ljFBAgj4OM6RhtMCqI6c2IB3weOEey5wcR641M0mVHPmzgNo5VMQ
 mFYkRXwrHrbsWWXxRB9yEJKK6P0MsDWAvoD8QBFvaOmqEBr7gG4ET44G76lcFoyD
 Tks4+MZQFQvzas/Xd/GndFlD/T4Cyn+CoPLP1SaP3R01mldoSA39o/cVZlHbZgjI
 8zFnPCAsE2C/w+Oko/vGLQZyyetJ8PzohPmlMy8XPaejYulHQqA=
 =cCwW
 -----END PGP SIGNATURE-----

Merge tag 'media/v5.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

Pull media updates from Mauro Carvalho Chehab:

 - New sensor driver: ov5693

 - A new driver for STM32 Chrom-ART Accelerator

 - Added V4L2 core helper functions for VP9 codec

 - Hantro driver has gained support for VP9 codecs

 - Added support for Maxim MAX96712 Quad GMSL2 Deserializer

 - The staging atomisp driver has gained lots of improvements, fixes and
   cleanups. It now works with userptr

 - Lots of random driver improvements as usual

* tag 'media/v5.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (397 commits)
  media: ipu3-cio2: Add support for instantiating i2c-clients for VCMs
  media: ipu3-cio2: Call cio2_bridge_init() before anything else
  media: ipu3-cio2: Defer probing until the PMIC is fully setup
  media: hantro: Add support for Allwinner H6
  media: dt-bindings: allwinner: document H6 Hantro G2 binding
  media: hantro: Convert imx8m_vpu_g2_irq to helper
  media: hantro: move postproc enablement for old cores
  media: hantro: vp9: add support for legacy register set
  media: hantro: vp9: use double buffering if needed
  media: hantro: add support for reset lines
  media: hantro: Fix probe func error path
  media: i2c: hi846: use pm_runtime_force_suspend/resume for system suspend
  media: i2c: hi846: check return value of regulator_bulk_disable()
  media: hi556: Support device probe in non-zero ACPI D state
  media: ov5675: Support device probe in non-zero ACPI D state
  media: imx208: Support device probe in non-zero ACPI D state
  media: ov2740: support device probe in non-zero ACPI D state
  media: ov5670: Support device probe in non-zero ACPI D state
  media: ov8856: support device probe in non-zero ACPI D state
  media: ov8865: Disable only enabled regulators on error path
  ...
2022-01-10 18:55:43 -08:00
Linus Torvalds 1135ec008e ARM: SoC updates for v5.17
These are all minor bug fixes and cleanups to code in arch/arm and
 arch/arm64 that is specific to one SoC, updating Kconfig symbols,
 the MAINTAINERS file, and removing some dead code.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmHDpXoACgkQmmx57+YA
 GNlCwBAApX4cCczBVOmnmYnqQG5aO9dejSkN1zbL4S1htTj2BakPxnSJLlL3ttFW
 gGU9vPKnUQbJ7anTZz7gjNC5ms/ARAHvj5Jhh/CmjPIM7qKIzMRj2y6dnI5Ax8D+
 +MWBGU4yPlC5oTeGRrnzfcgzn10tJFHs+HfEYPOjqnmnyqem7QDDwhjSPdbZhvy3
 wk0jmp6MOs6oX3WPJJYTkydEYyhBRCNWm52wUbQH2uCfVt5gonooWkYcki156hKd
 V1Q/cHK7Kn2PqDrOwj9MXTPkdaaQW7FC7T3FEw1tZhp/k5u/pvyGE4TlAQULLv2y
 lugKc3sqAPCgRBvwVSzkn2E6UCYMUH7W3lMBHbfmMR/qpo3VBCr8+2EofskkJl7e
 1fZBriHzh3CEaCUmdb7cqvT6T2p1liB18EmH2i+YxRv/UsrWRcXjLrv0VjLGSZPM
 VXMZzJpoNhYwS+b/TlRTyJLPJKHEfgAOObLzr5wXGjxXL6088nENY3K0Wkfuw9Tb
 1BrFw/NyC8JDO+GJGVXCjPMELgFlfLN+feS8cMlR45ZalOPd+AQtwqkXGEx41Pjq
 jJhS/A5a6IIJ6dLgsW+ncVpCUL+Jxmf+JV7b2e7p/KvavQHQq6cI/wkmd6pMInlw
 hvkydpLh88SWuI1fNFoS04eCfkya6w29pQo0pGlsbPiyRjP/vYI=
 =8wnp
 -----END PGP SIGNATURE-----

Merge tag 'soc-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM SoC updates from Arnd Bergmann:
 "These are all minor bug fixes and cleanups to code in arch/arm and
  arch/arm64 that is specific to one SoC, updating Kconfig symbols, the
  MAINTAINERS file, and removing some dead code"

* tag 'soc-5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc:
  arm64: exynos: Enable Exynos Multi-Core Timer driver
  ARM: ixp4xx: remove unused header file pata_ixp4xx_cf.h
  ARM: ixp4xx: remove dead configs CPU_IXP43X and CPU_IXP46X
  MAINTAINERS: Add Florian as BCM5301X and BCM53573 maintainer
  ARM: samsung: Remove HAVE_S3C2410_I2C and use direct dependencies
  ARM: imx: rename DEBUG_IMX21_IMX27_UART to DEBUG_IMX27_UART
  ARM: imx: remove dead left-over from i.MX{27,31,35} removal
  ARM: s3c: add one more "fallthrough" statement in Jive
  ARM: s3c: include header for prototype of s3c2410_modify_misccr
  ARM: shmobile: rcar-gen2: Add missing of_node_put()
2022-01-10 08:10:20 -08:00
Rafael J. Wysocki b659ea768a Merge branches 'acpi-scan', 'acpi-pm', 'acpi-power' and 'acpi-pci'
Merge ACPI device enumeration updates, ACPI power management updates
and PCI host bridge ACPI driver updates for 5.17-rc1:

 - Introduce acpi_fetch_acpi_dev() as a replacement for
   acpi_bus_get_device() and use it in the ACPI subsystem (Rafael
   Wysocki).

 - Avoid using _CID for device enumaration if _HID is missing or
   invalid (Rafael Wysocki).

 - Rework quirk handling during ACPI device enumeration and add some
   new quirks for known broken platforms (Hans de Goede).

 - Avoid unnecessary or redundant CPU cache flushing during system
   PM transitions (Kirill A. Shutemov).

 - Add PM debug messages related to power resources (Rafael Wysocki).

 - Fix kernel-doc comment in the PCI host bridge ACPI driver (Yang Li).

* acpi-scan:
  serdev: Do not instantiate serdevs on boards with known bogus DSDT entries
  i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries
  ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration() helpers
  ACPI: scan: Create platform device for BCM4752 and LNV4752 ACPI nodes
  ACPI: Use acpi_fetch_acpi_dev() instead of acpi_bus_get_device()
  ACPI: scan: Introduce acpi_fetch_acpi_dev()
  ACPI: scan: Do not add device IDs from _CID if _HID is not valid

* acpi-pm:
  ACPI: PM: Remove redundant cache flushing
  ACPI: PM: Avoid CPU cache flush when entering S4

* acpi-power:
  ACPI: PM: Emit debug messages when enabling/disabling wakeup power

* acpi-pci:
  PCI/ACPI: Fix acpi_pci_osc_control_set() kernel-doc comment
2022-01-10 16:48:27 +01:00
Wolfram Sang a19f75de73 Revert "i2c: core: support bus regulator controlling in adapter"
This largely reverts commit 5a7b95fb99. It
breaks suspend with AMD GPUs, and we couldn't incrementally fix it. So,
let's remove the code and go back to the drawing board. We keep the
header extension to not break drivers already populating the regulator.
We expect to re-add the code handling it soon.

Fixes: 5a7b95fb99 ("i2c: core: support bus regulator controlling in adapter")
Reported-by: "Tareque Md.Hanif" <tarequemd.hanif@yahoo.com>
Link: https://lore.kernel.org/r/1295184560.182511.1639075777725@mail.yahoo.com
Reported-by: Konstantin Kharlamov <hi-angel@yandex.ru>
Link: https://lore.kernel.org/r/7143a7147978f4104171072d9f5225d2ce355ec1.camel@yandex.ru
BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1850
Tested-by: "Tareque Md.Hanif" <tarequemd.hanif@yahoo.com>
Tested-by: Konstantin Kharlamov <hi-angel@yandex.ru>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Cc: <stable@vger.kernel.org> # 5.14+
2022-01-07 21:27:15 +01:00
Chris Packham 72a4a87da8 i2c: mpc: Avoid out of bounds memory access
When performing an I2C transfer where the last message was a write KASAN
would complain:

  BUG: KASAN: slab-out-of-bounds in mpc_i2c_do_action+0x154/0x630
  Read of size 2 at addr c814e310 by task swapper/2/0

  CPU: 2 PID: 0 Comm: swapper/2 Tainted: G    B             5.16.0-rc8 #1
  Call Trace:
  [e5ee9d50] [c08418e8] dump_stack_lvl+0x4c/0x6c (unreliable)
  [e5ee9d70] [c02f8a14] print_address_description.constprop.13+0x64/0x3b0
  [e5ee9da0] [c02f9030] kasan_report+0x1f0/0x204
  [e5ee9de0] [c0c76ee4] mpc_i2c_do_action+0x154/0x630
  [e5ee9e30] [c0c782c4] mpc_i2c_isr+0x164/0x240
  [e5ee9e60] [c00f3a04] __handle_irq_event_percpu+0xf4/0x3b0
  [e5ee9ec0] [c00f3d40] handle_irq_event_percpu+0x80/0x110
  [e5ee9f40] [c00f3e48] handle_irq_event+0x78/0xd0
  [e5ee9f60] [c00fcfec] handle_fasteoi_irq+0x19c/0x370
  [e5ee9fa0] [c00f1d84] generic_handle_irq+0x54/0x80
  [e5ee9fc0] [c0006b54] __do_irq+0x64/0x200
  [e5ee9ff0] [c0007958] __do_IRQ+0xe8/0x1c0
  [c812dd50] [e3eaab20] 0xe3eaab20
  [c812dd90] [c0007a4c] do_IRQ+0x1c/0x30
  [c812dda0] [c0000c04] ExternalInput+0x144/0x160
  --- interrupt: 500 at arch_cpu_idle+0x34/0x60
  NIP:  c000b684 LR: c000b684 CTR: c0019688
  REGS: c812ddb0 TRAP: 0500   Tainted: G    B              (5.16.0-rc8)
  MSR:  00029002 <CE,EE,ME>  CR: 22000488  XER: 20000000

  GPR00: c10ef7fc c812de90 c80ff200 c2394718 00000001 00000001 c10e3f90 00000003
  GPR08: 00000000 c0019688 c2394718 fc7d625b 22000484 00000000 21e17000 c208228c
  GPR16: e3e99284 00000000 ffffffff c2390000 c001bac0 c2082288 c812df60 c001ba60
  GPR24: c23949c0 00000018 00080000 00000004 c80ff200 00000002 c2348ee4 c2394718
  NIP [c000b684] arch_cpu_idle+0x34/0x60
  LR [c000b684] arch_cpu_idle+0x34/0x60
  --- interrupt: 500
  [c812de90] [c10e3f90] rcu_eqs_enter.isra.60+0xc0/0x110 (unreliable)
  [c812deb0] [c10ef7fc] default_idle_call+0xbc/0x230
  [c812dee0] [c00af0e8] do_idle+0x1c8/0x200
  [c812df10] [c00af3c0] cpu_startup_entry+0x20/0x30
  [c812df20] [c001e010] start_secondary+0x5d0/0xba0
  [c812dff0] [c00028a0] __secondary_start+0x90/0xdc

This happened because we would overrun the i2c->msgs array on the final
interrupt for the I2C STOP. This didn't happen if the last message was a
read because there is no interrupt in that case. Ensure that we only
access the current message if we are not processing a I2C STOP
condition.

Fixes: 1538d82f46 ("i2c: mpc: Interrupt driven transfer")
Reported-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-01-06 14:39:59 +01:00
Lad Prabhakar 8ab1ff9b1e i2c: riic: Use platform_get_irq() to get the interrupt
platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-01-03 10:17:32 +01:00
Lad Prabhakar aab799e44c i2c: sh_mobile: Use platform_get_irq_optional() to get the interrupt
platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_optional() for DT users only.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-01-03 10:17:24 +01:00
Lad Prabhakar c3b2f911ac i2c: bcm2835: Use platform_get_irq() to get the interrupt
platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-01-03 10:17:14 +01:00
Pavel Skripkin bb436283e2 i2c: validate user data in compat ioctl
Wrong user data may cause warning in i2c_transfer(), ex: zero msgs.
Userspace should not be able to trigger warnings, so this patch adds
validation checks for user data in compact ioctl to prevent reported
warnings

Reported-and-tested-by: syzbot+e417648b303855b91d8a@syzkaller.appspotmail.com
Fixes: 7d5cb45655 ("i2c compat ioctls: move to ->compat_ioctl()")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-31 14:28:22 +01:00
Hans de Goede a6e1445c44 i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries
x86 ACPI devices which ship with only Android as their factory image
usually declare a whole bunch of bogus I2C devices in their ACPI tables.

Instantiating I2C clients for these bogus devices causes various issues,
e.g. GPIO/IRQ resource conflicts because sometimes drivers do bind to them.
The Android x86 kernel fork shipped on these devices has some special code
to remove these bogus devices, instead of just fixing the DSDT <sigh>.

Use the new acpi_quirk_skip_i2c_client_enumeration() helper to identify
known boards / acpi devices with this issue, and skip enumerating these.

Note these boards typically do actually have I2C devices, just
different ones then the ones described in their DSDT. The devices
which are actually present are manually instantiated by the
drivers/platform/x86/x86-android-tablets.c kernel module.

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-12-30 19:01:42 +01:00
Thierry Reding 653becec6d i2c: aspeed: Remove unused includes
No symbols from the linux/irqchip/chained_irq.h and linux/irqdomain.h
headers are used in the driver, so they can be removed.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:27:16 +01:00
Wolfram Sang 44df8a7928 i2c: sh_mobile: update to new DMAENGINE API when terminating
dmaengine_terminate_all() is deprecated. When converting the existing
calls, it turned out that the termination in the DMA setup and callback
were superfluous and only a side effect of simply calling
rcar_i2c_cleanup_dma(). As either no DMA transfers have been submitted
yet or the last one has successfully completed, there is nothing to
terminate and we can leave it out. So, merge the DMA unmap and cleanup
function to save some code. Then, add a flag if the new cleanup function
needs to terminate DMA. This is only the case for the erorr handling in
the main thread, so we can finally switch from dmaengine_terminate_all()
to dmaengine_terminate_sync() here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:23:04 +01:00
Wolfram Sang a5f7cf953f i2c: rcar: update to new DMAENGINE API when terminating
dmaengine_terminate_all() is deprecated. When converting the existing
calls, it turned out that the termination in the interrupt handlers was
superfluous and only a side effect of simply calling
rcar_i2c_cleanup_dma(). As either no DMA transfers have been submitted
yet or the last one has successfully completed, there is nothing to
terminate and we can leave it out. So, merge the DMA unmap and cleanup
function to save some code. Then, add a flag if the new cleanup function
needs to terminate DMA. This is only the case for the erorr handling in
the main thread, so we can finally switch from dmaengine_terminate_all()
to dmaengine_terminate_sync() here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:22:56 +01:00
Sam Protsenko ac18935d2e i2c: exynos5: Fix getting the optional clock
"hsi2c_pclk" clock is optional and may not be present for some SoCs
supported by this driver. Nevertheless, in case the clock is provided
but some error happens during its getting, that error should be handled
properly. Use devm_clk_get_optional() API for that. Also report possible
errors using dev_err_probe() to handle properly -EPROBE_DEFER error (if
clock provider is not ready by the time I2C probe function is executed).

Fixes: 697ad2490c ("i2c: exynos5: Add bus clock support")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Chanho Park <chanho61.park@samsung.com>
[wsa: fixed SHA1 of Fixes tag]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:21:27 +01:00
Andy Shevchenko 2759181d9a i2c: designware-pci: Convert to use dev_err_probe()
It's fine to call dev_err_probe() in ->probe() when error code is known.
Convert the driver to use dev_err_probe().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:19:13 +01:00
Andy Shevchenko 0897f17359 i2c: designware-pci: use __maybe_unused for PM functions
Use __maybe_unused for PM functions instead of ifdeffery.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:19:12 +01:00
Andy Shevchenko c3c9bab1e3 i2c: designware-pci: Group MODULE_*() macros
For better maintenance group MODULE_*() macros together.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:19:08 +01:00
Andy Shevchenko c2d7fa2207 i2c: designware-pci: Add a note about struct dw_scl_sda_cfg usage
Add a note about struct dw_scl_sda_cfg usage to discourage people
of using this structure on new platforms. Instead they should try
hard to put the needed information into firmware descriptions.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:14:02 +01:00
Lakshmi Sowjanya D d520970100 i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters
The data type of hcnt and lcnt in the struct dw_i2c_dev is of type u16.
It's better to have same data type in struct dw_scl_sda_cfg as well.

Reported-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:13:32 +01:00
Tamal Saha f4e0ba52a8 i2c: designware: Do not complete i2c read without RX_FULL interrupt
Intel Keem Bay platform supports multi-master operations over same i2c
bus using Synopsys i2c DesignWare IP. When multi-masters initiate i2c
operation simultaneously in a loop, SCL line is stucked low forever
after few i2c operations. Following interrupt sequences are observed
in:
  working case: TX_EMPTY, RX_FULL and STOP_DET
  non working case: TX_EMPTY, STOP_DET, RX_FULL.

DW_apb_i2c stretches the SCL line when the TX FIFO is empty or when
RX FIFO is full. The DW_apb_i2c master will continue to hold the SCL
line LOW until RX FIFO is read.

Linux kernel i2c DesignWare driver does not handle above non working
sequence. TX_EMPTY, RX_FULL and STOP_DET routine execution are required
in sequence although RX_FULL interrupt is raised after STOP_DET by
hardware. Clear STOP_DET for the following conditions:
  (STOP_DET ,RX_FULL, rx_outstanding)
    Write Operation: (1, 0, 0)
    Read Operation:
      RX_FULL followed by STOP_DET: (0, 1, 1) -> (1, 0, 0)
      STOP_DET followed by RX_FULL: (1, 0, 1) -> (1, 1, 0)
      RX_FULL and STOP_DET together: (1, 1, 1)

Signed-off-by: Tamal Saha <tamal.saha@intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-16 22:13:24 +01:00
Mauro Carvalho Chehab 3a956f0b12 Signed tag for the immutable platform-drivers-x86-int3472 branch
This branch contains 5.16-rc1 + the pending ACPI/i2c, tps68570 platform_data
 and INT3472 driver patches.
 -----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCAAyFiEEuvA7XScYQRpenhd+kuxHeUQDJ9wFAmG6YLQUHGhkZWdvZWRl
 QHJlZGhhdC5jb20ACgkQkuxHeUQDJ9zwGwf8Csb4wXyc3duBlnX/9jO9REDVKTN9
 HhmU2KQm29g10dN2nlFXEOG16xAy8zt3BE7QwniL/R5sUsKTCAEugY8Aqq/4+lFA
 vTU+YR9YqZFmEDGMfDngHeh9ZvSWIJS7IEXthxCkgGVhrd2Wl50jKTjVyq1RIDKv
 a7B4fOhguFv95xRlnXK+yoVUU7zZPWAgxyCqV0E0JEi8aWE8Y483IRCzcDEyJeDa
 HkgZLVwD9l3WQ4uZllVg1q5jfSprHwBa8dFxgcd6mOOYaKowiJ+GjnvnXOto5X72
 zsODBJH15VzfVXF5cAqIvzN6nAFR8Mxieei+21iFyUD/Ps1vfWlodFHH2w==
 =Q1N9
 -----END PGP SIGNATURE-----

Merge tag 'platform-drivers-x86-int3472-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86 into media_tree

Signed tag for the immutable platform-drivers-x86-int3472 branch

This branch contains 5.16-rc1 + the pending ACPI/i2c, tps68570 platform_data
and INT3472 driver patches.

* tag 'platform-drivers-x86-int3472-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
  platform/x86: int3472: Deal with probe ordering issues
  platform/x86: int3472: Pass tps68470_regulator_platform_data to the tps68470-regulator MFD-cell
  platform/x86: int3472: Pass tps68470_clk_platform_data to the tps68470-regulator MFD-cell
  platform/x86: int3472: Add get_sensor_adev_and_name() helper
  platform/x86: int3472: Split into 2 drivers
  platform_data: Add linux/platform_data/tps68470.h file
  i2c: acpi: Add i2c_acpi_new_device_by_fwnode() function
  i2c: acpi: Use acpi_dev_ready_for_enumeration() helper
  ACPI: delay enumeration of devices with a _DEP pointing to an INT3472 device
2021-12-16 20:54:02 +01:00
Hans de Goede c537be0bfa i2c: acpi: Add i2c_acpi_new_device_by_fwnode() function
Change i2c_acpi_new_device() into i2c_acpi_new_device_by_fwnode() and
add a static inline wrapper providing the old i2c_acpi_new_device()
behavior.

This is necessary because in some cases we may only have access
to the fwnode / acpi_device and not to the matching physical-node
struct device *.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-4-hdegoede@redhat.com
2021-12-13 11:44:47 +01:00
Hans de Goede fb90e58f7c i2c: acpi: Use acpi_dev_ready_for_enumeration() helper
The clk and regulator frameworks expect clk/regulator consumer-devices
to have info about the consumed clks/regulators described in the device's
fw_node.

To work around cases where this info is not present in the firmware tables,
which is often the case on x86/ACPI devices, both frameworks allow the
provider-driver to attach info about consumers to the clks/regulators
when registering these.

This causes problems with the probe ordering wrt drivers for consumers
of these clks/regulators. Since the lookups are only registered when the
provider-driver binds, trying to get these clks/regulators before then
results in a -ENOENT error for clks and a dummy regulator for regulators.

To ensure the correct probe-ordering the ACPI core has code to defer the
enumeration of consumers affected by this until the providers are ready.

Call the new acpi_dev_ready_for_enumeration() helper to avoid
enumerating / instantiating i2c-clients too early.

Acked-by: Wolfram Sang <wsa@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20211203102857.44539-3-hdegoede@redhat.com
2021-12-13 11:44:47 +01:00
Chris Packham a74c313aca i2c: mpc: Use atomic read and fix break condition
Maxime points out that the polling code in mpc_i2c_isr should use the
_atomic API because it is called in an irq context and that the
behaviour of the MCF bit is that it is 1 when the byte transfer is
complete. All of this means the original code was effectively a
udelay(100).

Fix this by using readb_poll_timeout_atomic() and removing the negation
of the break condition.

Fixes: 4a8ac5e45c ("i2c: mpc: Poll for MCF")
Reported-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Tested-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-10 22:27:30 +01:00
Akhil R 50665d58db i2c: tegra: use i2c_timings for bus clock freq
Use i2c_timings struct and corresponding methods to get bus clock frequency

Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-10 22:23:05 +01:00
Heiner Kallweit 4f7275fc7e i2c: i801: Don't clear status flags twice in interrupt mode
In interrupt mode we clear the status flags twice, in the interrupt
handler and in i801_check_post(). Remove clearing the status flags
from i801_check_post() and handle polling mode by using the
SMBus unlocking write to also clear the status flags if still set.
To be precise: One could still argue that the status flags are
cleared twice in interrupt mode, but it comes for free.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-09 15:52:10 +01:00
Heiner Kallweit 8c7a89678f i2c: i801: Don't read back cleared status in i801_check_pre()
I see no need to read back the registers to verify that the bits
have actually been cleared. I can't imagine any scenario where
the bits would remain set after a write to them.

Whilst at it, change involved syslog messages to use pci_dbg() et al.
to simplify them.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-09 15:51:16 +01:00
Sam Protsenko c4bcef90cc i2c: exynos5: Mention Exynos850 and ExynosAutoV9 in Kconfig
I2C controller chosen by I2C_EXYNOS5 config option is also suitable for
Exynos850 and ExynosAutoV9 SoCs. State that specifically in I2C_EXYNOS5
symbol help section.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-09 15:49:23 +01:00
Sam Protsenko 697ad2490c i2c: exynos5: Add bus clock support
In new Exynos SoCs (like Exynos850) where HSI2C is implemented as a
part of USIv2 block, there are two clocks provided to HSI2C controller:
  - PCLK: bus clock (APB), provides access to register interface
  - IPCLK: operating IP-core clock; SCL is derived from this one

Both clocks have to be asserted for HSI2C to be functional in that case.

Add code to obtain and enable/disable PCLK in addition to already
handled operating clock. Make it optional though, as older Exynos SoC
variants only have one HSI2C clock.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-09 15:46:01 +01:00
Jaewon Kim 3f68910259 i2c: exynos5: Add support for ExynosAutoV9 SoC
ExynosAutoV9 functioning logic mostly follows I2C_TYPE_EXYNOS7, but
timing calculation and configuration procedure is changed: e.g. only
timing_s3 has to be set now.

Another change of HSI2C controller in ExynosAutoV9 SoC is that it's now
a part of USIv2 IP-core. No changes is needed for I2C driver though, as
all USI related configuration is done in USI driver.

Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-09 10:05:11 +01:00
Vincent Whitchurch b503de239f i2c: virtio: fix completion handling
The driver currently assumes that the notify callback is only received
when the device is done with all the queued buffers.

However, this is not true, since the notify callback could be called
without any of the queued buffers being completed (for example, with
virtio-pci and shared interrupts) or with only some of the buffers being
completed (since the driver makes them available to the device in
multiple separate virtqueue_add_sgs() calls).

This can lead to incorrect data on the I2C bus or memory corruption in
the guest if the device operates on buffers which are have been freed by
the driver.  (The WARN_ON in the driver is also triggered.)

 BUG kmalloc-128 (Tainted: G        W        ): Poison overwritten
 First byte 0x0 instead of 0x6b
 Allocated in i2cdev_ioctl_rdwr+0x9d/0x1de age=243 cpu=0 pid=28
 	memdup_user+0x2e/0xbd
 	i2cdev_ioctl_rdwr+0x9d/0x1de
 	i2cdev_ioctl+0x247/0x2ed
 	vfs_ioctl+0x21/0x30
 	sys_ioctl+0xb18/0xb41
 Freed in i2cdev_ioctl_rdwr+0x1bb/0x1de age=68 cpu=0 pid=28
 	kfree+0x1bd/0x1cc
 	i2cdev_ioctl_rdwr+0x1bb/0x1de
 	i2cdev_ioctl+0x247/0x2ed
 	vfs_ioctl+0x21/0x30
 	sys_ioctl+0xb18/0xb41

Fix this by calling virtio_get_buf() from the notify handler like other
virtio drivers and by actually waiting for all the buffers to be
completed.

Fixes: 3cfc883804 ("i2c: virtio: add a virtio i2c frontend driver")
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-09 09:49:58 +01:00
Wolfram Sang 15f0ae7a91 i2c: stm32f7: remove noisy and imprecise log messages
The log messages talk about 'bus recovery' while it is not a bus
recovery with 9 pulses but merely a controller reset. Controller resets
are not worth log messages. The 'bus busy' message should be emitted by
upper layers, a busy bus may be expected in some cases.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
Reviewed-by: Alain Volmat <alain.volmat@foss.st.com>
2021-12-01 22:20:03 +01:00
Alain Volmat 05907656b9 i2c: stm32: get rid of stm32f7_i2c_release_bus return value
Function stm32f7_i2c_release_bus is always returning 0, hence it
should be a void function.  Update the function and remove the
return value error checking code in caller functions.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-12-01 22:14:01 +01:00
Ondrej Jirman 02fe0fbd8a i2c: rk3x: Handle a spurious start completion interrupt flag
In a typical read transfer, start completion flag is being set after
read finishes (notice ipd bit 4 being set):

trasnfer poll=0
i2c start
rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10
i2c read
rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b
i2c stop
rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 33

This causes I2C transfer being aborted in polled mode from a stop completion
handler:

trasnfer poll=1
i2c start
rk3x-i2c fdd40000.i2c: IRQ: state 1, ipd: 10
i2c read
rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 0
rk3x-i2c fdd40000.i2c: IRQ: state 2, ipd: 1b
i2c stop
rk3x-i2c fdd40000.i2c: IRQ: state 4, ipd: 13
i2c stop
rk3x-i2c fdd40000.i2c: unexpected irq in STOP: 0x10

Clearing the START flag after read fixes the issue without any obvious
side effects.

This issue was dicovered on RK3566 when adding support for powering
off the RK817 PMIC.

Signed-off-by: Ondrej Jirman <megous@megous.com>
Reviewed-by: John Keeping <john@metanate.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-30 22:38:15 +01:00
Wolfram Sang 1071d1ad31 Revert "i2c: designware-pci: Add support for Fast Mode Plus and High Speed Mode"
This reverts commit e8578547ce. Drivers
should read these values from ACPI tables.

Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-30 22:32:47 +01:00
Wolfram Sang 606974c7ac Revert "i2c: designware-pci: Set ideal timing parameters for Elkhart Lake PSE"
This reverts commit 36af188f79. Drivers
should read these values from ACPI tables.

Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-30 22:32:01 +01:00
Alain Volmat 1229f82dea i2c: stm32f7: use proper DMAENGINE API for termination
dmaengine_terminate_all() is deprecated in favor of explicitly saying if
it should be sync or async.  Here, we use dmaengine_terminate_sync in
i2c_xfer and i2c_smbus_xfer handlers and rely on
dmaengine_terminate_async within interrupt handlers
(transmission error cases).
dmaengine_synchronize is added within i2c_xfer and i2c_smbus_xfer handler
to finalize terminate started in interrupt handlers.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-30 10:22:14 +01:00
Alain Volmat 31b90a95cc i2c: stm32f7: stop dma transfer in case of NACK
In case of receiving a NACK, the dma transfer should be stopped
to avoid feeding data into the FIFO.
Also ensure to properly return the proper error code and avoid
waiting for the end of the dma completion in case of
error happening during the transmission.

Fixes: 7ecc8cfde5 ("i2c: i2c-stm32f7: Add DMA support")
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-30 10:22:11 +01:00
Alain Volmat b933d1faf8 i2c: stm32f7: recover the bus on access timeout
When getting an access timeout, ensure that the bus is in a proper
state prior to returning the error.

Fixes: aeb068c572 ("i2c: i2c-stm32f7: add driver")
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-30 10:22:07 +01:00
Heiner Kallweit 2352b05fdf i2c: i801: Improve handling platform data for tco device
The platform data structures are used in the respective i801_add_tco
functions only. Therefore we can make the definitions local to these
functions.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 23:22:02 +01:00
Lakshmi Sowjanya D 36af188f79 i2c: designware-pci: Set ideal timing parameters for Elkhart Lake PSE
Set optimal HCNT, LCNT and hold time values for all the speeds supported
in Intel Programmable Service Engine I2C controller in Intel Elkhart
Lake.

Signed-off-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 17:55:32 +01:00
Lakshmi Sowjanya D e8578547ce i2c: designware-pci: Add support for Fast Mode Plus and High Speed Mode
Add support to configure HCNT, LCNT values for Fast Mode Plus and High
Speed Mode.

Signed-off-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 17:55:17 +01:00
Derek Basehore 172d931910 i2c: enable async suspend/resume on i2c client devices
This enables the async suspend for i2c client devices. This reduces
the suspend/resume time considerably on platforms where i2c devices
can take a lot of time (hundreds of ms) to resume.

Signed-off-by: Derek Basehore <dbasehore@chromium.org>
Signed-off-by: Rajat Jain <rajatja@google.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 17:50:34 +01:00
Rajat Jain d320ec7acc i2c: enable async suspend/resume for i2c adapters
Enable async suspend/resume of i2c adapters. It enormously helps with
reducing the resume time of systems (as much as 20%-40%) where I2C devices
can take significant time (100s of ms) to resume.

Signed-off-by: Rajat Jain <rajatja@google.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 17:50:33 +01:00
Rajat Jain 7c5b3c158b i2c: designware: Enable async suspend / resume of designware devices
Mark the designware devices for asynchronous suspend. With this, the
resume for designware devices does not get stuck behind other unrelated
devices (e.g. intel_backlight that takes hundreds of ms to resume,
waiting for its parent devices).

Signed-off-by: Rajat Jain <rajatja@google.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 17:50:33 +01:00
Joakim Tjernlund ebe82cf92c i2c: mpc: Correct I2C reset procedure
Current I2C reset procedure is broken in two ways:
1) It only generate 1 START instead of 9 STARTs and STOP.
2) It leaves the bus Busy so every I2C xfer after the first
   fixup calls the reset routine again, for every xfer there after.

This fixes both errors.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Acked-by: Scott Wood <oss@buserror.net>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 17:50:28 +01:00
Alain Volmat 0c21d02ca4 i2c: stm32f7: flush TX FIFO upon transfer errors
While handling an error during transfer (ex: NACK), it could
happen that the driver has already written data into TXDR
before the transfer get stopped.
This commit add TXDR Flush after end of transfer in case of error to
avoid sending a wrong data on any other slave upon next transfer.

Fixes: aeb068c572 ("i2c: i2c-stm32f7: add driver")
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@foss.st.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 13:11:50 +01:00
Andy Shevchenko 1ead7e992a i2c: designware: Fix the kernel doc description for struct dw_i2c_dev
$ scripts/kernel-doc -none drivers/i2c/busses/i2c-designware-core.h
warning: Function parameter or member 'rst' not described in 'dw_i2c_dev'
warning: Function parameter or member 'get_clk_rate_khz' not described in 'dw_i2c_dev'
warning: Function parameter or member 'flags' not described in 'dw_i2c_dev'
warning: Function parameter or member 'functionality' not described in 'dw_i2c_dev'
warning: Function parameter or member 'master_cfg' not described in 'dw_i2c_dev'
warning: Function parameter or member 'set_sda_hold_time' not described in 'dw_i2c_dev'
warning: Function parameter or member 'rinfo' not described in 'dw_i2c_dev'

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Randy Dunlap <rdunla@infradead.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 10:41:48 +01:00
John Keeping b57e90189f i2c: rk3x: enable clock before getting rate
clk_get_rate() is documented as requiring the clock to be enabled.
Ensure that the bus clock is enabled before calling clk_get_rate() in
rk3x_i2c_probe() to satisfy this requirement.

Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 10:38:36 +01:00
Heiner Kallweit 41acd4b03c i2c: i801: Improve handling of chip-specific feature definitions
Reduce source code and code size by defining the chip features
statically.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 09:55:58 +01:00
Heiner Kallweit 1e1d6582f4 i2c: i801: Remove i801_set_block_buffer_mode
If FEATURE_BLOCK_BUFFER is set then bit SMBAUXCTL_E32B is supported
and there's no benefit in reading it back. Origin of this check
seems to be 14 yrs ago when people were not completely sure which
chip versions support the block buffer mode.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 09:54:58 +01:00
Heiner Kallweit effa453168 i2c: i801: Don't silently correct invalid transfer size
If an invalid block size is provided, reject it instead of silently
changing it to a supported value. Especially critical I see the case of
a write transfer with block length 0. In this case we have no guarantee
that the byte we would write is valid. When silently reducing a read to
32 bytes then we don't return an error and the caller may falsely
assume that we returned the full requested data.

If this change should break any (broken) caller, then I think we should
fix the caller.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 09:53:56 +01:00
Aaro Koskinen b12764695c i2c: cbus-gpio: set atomic transfer callback
CBUS transfers have always been atomic, but after commit 63b96983a5
("i2c: core: introduce callbacks for atomic transfers") we started to see
warnings during e.g. poweroff as the atomic callback is not explicitly set.
Fix that.

Fixes the following WARNING seen during Nokia N810 power down:

[  786.570617] reboot: Power down
[  786.573913] ------------[ cut here ]------------
[  786.578826] WARNING: CPU: 0 PID: 672 at drivers/i2c/i2c-core.h:40 i2c_smbus_xfer+0x100/0x110
[  786.587799] No atomic I2C transfer handler for 'i2c-2'

Fixes: 63b96983a5 ("i2c: core: introduce callbacks for atomic transfers")
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 09:52:10 +01:00
Akhil R bd2fdedbf2 i2c: tegra: Add the ACPI support
Add support for the ACPI based device registration so that the driver
can be also enabled through ACPI table.

This does not include the ACPI support for Tegra VI and DVC I2C.

Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-29 09:46:09 +01:00
Wolfram Sang c55526a1c1 Merge branch 'i2c/for-current' into i2c/for-mergewindow 2021-11-29 09:39:23 +01:00
Andy Shevchenko a2fd6f6bc0 i2c: mux: gpio: Use array_size() helper
Use array_size() helper to aid in 2-factor allocation instances.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Evan Green <evgreen@chromium.org>
Acked-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 11:54:41 +01:00
Andy Shevchenko 533f05f0ab i2c: mux: gpio: Don't dereference fwnode from struct device
We have a special helper to get fwnode out of struct device.
Moreover, dereferencing it directly prevents the fwnode
modifications in the future.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Evan Green <evgreen@chromium.org>
Acked-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 11:54:41 +01:00
Andy Shevchenko 379920f5c0 i2c: mux: gpio: Replace custom acpi_get_local_address()
Recently ACPI gained the acpi_get_local_address() API which may be used
instead of home grown i2c_mux_gpio_get_acpi_adr().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Evan Green <evgreen@chromium.org>
Acked-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 11:54:41 +01:00
Corey Minyard f89bf95632 i2c: imx: Add timer for handling the stop condition
Most IMX I2C interfaces don't generate an interrupt on a stop condition,
so it won't generate a timely stop event on a slave mode transfer.
Some users, like IPMB, need a timely stop event to work properly.

So, add a timer and add the proper handling to generate a stop event in
slave mode if the interface goes idle.

Signed-off-by: Corey Minyard <minyard@acm.org>
Tested-by: Andrew Manley <andrew.manley@sealingtech.com>
Reviewed-by: Andrew Manley <andrew.manley@sealingtech.com>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 11:16:56 +01:00
Vincent Whitchurch 84e1d0bf1d i2c: virtio: disable timeout handling
If a timeout is hit, it can result is incorrect data on the I2C bus
and/or memory corruptions in the guest since the device can still be
operating on the buffers it was given while the guest has freed them.

Here is, for example, the start of a slub_debug splat which was
triggered on the next transfer after one transfer was forced to timeout
by setting a breakpoint in the backend (rust-vmm/vhost-device):

 BUG kmalloc-1k (Not tainted): Poison overwritten
 First byte 0x1 instead of 0x6b
 Allocated in virtio_i2c_xfer+0x65/0x35c age=350 cpu=0 pid=29
 	__kmalloc+0xc2/0x1c9
 	virtio_i2c_xfer+0x65/0x35c
 	__i2c_transfer+0x429/0x57d
 	i2c_transfer+0x115/0x134
 	i2cdev_ioctl_rdwr+0x16a/0x1de
 	i2cdev_ioctl+0x247/0x2ed
 	vfs_ioctl+0x21/0x30
 	sys_ioctl+0xb18/0xb41
 Freed in virtio_i2c_xfer+0x32e/0x35c age=244 cpu=0 pid=29
 	kfree+0x1bd/0x1cc
 	virtio_i2c_xfer+0x32e/0x35c
 	__i2c_transfer+0x429/0x57d
 	i2c_transfer+0x115/0x134
 	i2cdev_ioctl_rdwr+0x16a/0x1de
 	i2cdev_ioctl+0x247/0x2ed
 	vfs_ioctl+0x21/0x30
 	sys_ioctl+0xb18/0xb41

There is no simple fix for this (the driver would have to always create
bounce buffers and hold on to them until the device eventually returns
the buffers), so just disable the timeout support for now.

Fixes: 3cfc883804 ("i2c: virtio: add a virtio i2c frontend driver")
Acked-by: Jie Deng <jie.deng@intel.com>
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 10:55:48 +01:00
Jarkko Nikula 03a976c9af i2c: i801: Fix interrupt storm from SMB_ALERT signal
Currently interrupt storm will occur from i2c-i801 after first
transaction if SMB_ALERT signal is enabled and ever asserted. It is
enough if the signal is asserted once even before the driver is loaded
and does not recover because that interrupt is not acknowledged.

This fix aims to fix it by two ways:
- Add acknowledging for the SMB_ALERT interrupt status
- Disable the SMB_ALERT interrupt on platforms where possible since the
  driver currently does not make use for it

Acknowledging resets the SMB_ALERT interrupt status on all platforms and
also should help to avoid interrupt storm on older platforms where the
SMB_ALERT interrupt disabling is not available.

For simplicity this fix reuses the host notify feature for disabling and
restoring original register value.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=177311
Reported-by: ck+kernelbugzilla@bl4ckb0x.de
Reported-by: stephane.poignant@protonmail.com
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 10:43:50 +01:00
Jean Delvare 9b5bf58781 i2c: i801: Restore INTREN on unload
If driver interrupts are enabled, SMBHSTCNT_INTREN will be 1 after
the first transaction, and will stay to that value forever. This
means that interrupts will be generated for both host-initiated
transactions and also SMBus Alert events even after the driver is
unloaded. To be on the safe side, we should restore the initial state
of this bit at suspend and reboot time, as we do for several other
configuration bits already and for the same reason: the BIOS should
be handed the device in the same configuration state in which we
received it. Otherwise interrupts may be generated which nobody
will process.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 10:43:50 +01:00
Rob Herring 77e0164630 i2c: Remove unused Netlogic/Sigma Designs XLR driver
Commits 95b8a5e011 ("MIPS: Remove NETLOGIC support") and edd4488aea
("ARM: remove tango platform") removed Netlogic XLR and Sigma Designs
Tango platforms which means there are no platforms using the XLR I2C
driver and it can be removed.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 10:00:29 +01:00
Rob Herring ef99066c7d i2c: Remove Netlogic XLP variant
Netlogic XLP was removed in commit 95b8a5e011 ("MIPS: Remove NETLOGIC
support"). With those gone, the single platform left to support is
Cavium ThunderX2. Remove the Netlogic variant and DT support.

For simplicity, the existing kconfig name is retained.

Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by George Cherian <gcherian@marvell.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-23 10:00:12 +01:00
Sam Protsenko 3ac5f9db26 ARM: samsung: Remove HAVE_S3C2410_I2C and use direct dependencies
A separate Kconfig option HAVE_S3C2410_I2C for Samsung SoCs is not
really needed and the i2c-s3c24xx driver can depend on Samsung ARM
architectures instead. This also enables i2c-s3c2410 for arm64 Exynos
SoCs, which is required for example by Exynos850.

This is basically continuation of work made in following commits:
  - commit d96890fca9 ("rtc: s3c: remove HAVE_S3C_RTC in favor of
    direct dependencies")
  - commit 7dd3cae90d ("ARM: samsung: remove HAVE_S3C2410_WATCHDOG and
    use direct dependencies")

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Link: https://lore.kernel.org/r/20211121150558.21801-2-semen.protsenko@linaro.org
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-11-21 17:46:18 +01:00
Linus Torvalds 285fc3db0a More ACPI updates for 5.16-rc1
- Add support for new ACPI device configuration object called _DSC
    to allow certain devices to be probed without changing their power
    states, document it and make two drivers use it (Sakari Ailus,
    Rajmohan Mani).
 
  - Fix device wakeup power reference counting broken recently by
    mistake (Rafael Wysocki).
 
  - Drop unused symbol and macros depending on it from acgcc.h (Rafael
    Wysocki).
 
  - Add HP ZHAN 66 Pro to the "no EC wakeup" quirk list (Binbin Zhou).
 
  - Add Xiaomi Mi Pad 2 to the backlight quirk list and drop an unused
    piece of data from all of the list entries (Hans de Goede).
 
  - Fix register read accesses handling in the Intel PMIC operation
    region driver (Hans de Goede).
 
  - Clean up static variables initialization in the EC driver
    (wangzhitong).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmGL01cSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxF0YQAKXlCWrebWXwkDDqnSXZOqk7/aL+QZ9x
 Di1snFSqrpzgnSgZTuEjpUWLCFZ6hdpEyIH9X12PYo3o9SI3TkfGWpoA4XWEU6v7
 CRpFWIXGHznFWFx3IHoyuUgfDMT2bLxdSrYQrC1lw0icvZHOyk72zNH7oVp0tsXq
 QwfxQDozJKypgSnNxbL+KsabG/DhK8Vyf4HjE6K1pTZ9fpsf0q9CnRGWWgdiaqdE
 B5iFxVIA46J1+izE2C9aN+bEJ43HThgVrvv9V+WOMLJKLJoHwEikZaDRBzvR1ofZ
 dm2f7J5/TDhJQSrlRYftMtNkYrw4Fcey+1xeGE1lTrmw0GM+/pvOs8THfj+TaUp9
 0dmJCsHTndEby6PpQqCqTdfTRYsCIbhp8xRK3Q9qZcrYVNXcOrrifzmqY9bUDh2G
 IXHzPao6sfv4E9yWypuZ7VO4UR5alzxTQfnB5K+cCju2vMqz6Zkk1tr32xJLlsw/
 vd6w3q3Bataa1xGZEBbgSYvgSkKEJwFOeU9R+Rvcn1QWgXQuoPufOssz28KSH3oQ
 0mj/nHMJdRdlSDqADzyRUgoaxv7KUmRYRxbTUMiM+aWnDCu/OD7jWNq24sTNi9xC
 c7WMWHYC+0t5YxsyHo1MRfz8Q12zE1qWJFjBqMO23IZuBO3M1p3YSjl+z6NkUMj6
 95M4WeJK2cBb
 =k8+T
 -----END PGP SIGNATURE-----

Merge tag 'acpi-5.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more ACPI updates from Rafael Wysocki:
 "These add support for a new ACPI device configuration object called
  _DSC, fix some issues including one recent regression, add two new
  items to quirk lists and clean up assorted pieces of code.

  Specifics:

   - Add support for new ACPI device configuration object called _DSC
     ("Deepest State for Configuration") to allow certain devices to be
     probed without changing their power states, document it and make
     two drivers use it (Sakari Ailus, Rajmohan Mani).

   - Fix device wakeup power reference counting broken recently by
     mistake (Rafael Wysocki).

   - Drop unused symbol and macros depending on it from acgcc.h (Rafael
     Wysocki).

   - Add HP ZHAN 66 Pro to the "no EC wakeup" quirk list (Binbin Zhou).

   - Add Xiaomi Mi Pad 2 to the backlight quirk list and drop an unused
     piece of data from all of the list entries (Hans de Goede).

   - Fix register read accesses handling in the Intel PMIC operation
     region driver (Hans de Goede).

   - Clean up static variables initialization in the EC driver
     (wangzhitong)"

* tag 'acpi-5.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  Documentation: ACPI: Fix non-D0 probe _DSC object example
  ACPI: Drop ACPI_USE_BUILTIN_STDARG ifdef from acgcc.h
  ACPI: PM: Fix device wakeup power reference counting error
  ACPI: video: use platform backlight driver on Xiaomi Mi Pad 2
  ACPI: video: Drop dmi_system_id.ident settings from video_detect_dmi_table[]
  ACPI: PMIC: Fix intel_pmic_regs_handler() read accesses
  ACPI: EC: Remove initialization of static variables to false
  ACPI: EC: Use ec_no_wakeup on HP ZHAN 66 Pro
  at24: Support probing while in non-zero ACPI D state
  media: i2c: imx319: Support device probe in non-zero ACPI D state
  ACPI: Add a convenience function to tell a device is in D0 state
  Documentation: ACPI: Document _DSC object usage for enum power state
  i2c: Allow an ACPI driver to manage the device's power state during probe
  ACPI: scan: Obtain device's desired enumeration power state
2021-11-10 11:52:40 -08:00
Linus Torvalds dab334c98b Merge branch 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:

 - big refactoring of the PASEMI driver to support the Apple M1

 - huge improvements to the XIIC in terms of locking and SMP safety

 - refactoring and clean ups for the i801 driver

... and the usual bunch of small driver updates

* 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (43 commits)
  i2c: amd-mp2-plat: ACPI: Use ACPI_COMPANION() directly
  i2c: i801: Add support for Intel Ice Lake PCH-N
  i2c: virtio: update the maintainer to Conghui
  i2c: xlr: Fix a resource leak in the error handling path of 'xlr_i2c_probe()'
  i2c: qup: move to use request_irq by IRQF_NO_AUTOEN flag
  i2c: qup: fix a trivial typo
  i2c: tegra: Ensure that device is suspended before driver is removed
  i2c: i801: Fix incorrect and needless software PEC disabling
  i2c: mediatek: Dump i2c/dma register when a timeout occurs
  i2c: mediatek: Reset the handshake signal between i2c and dma
  i2c: mlxcpld: Allow flexible polling time setting for I2C transactions
  i2c: pasemi: Set enable bit for Apple variant
  i2c: pasemi: Add Apple platform driver
  i2c: pasemi: Refactor _probe to use devm_*
  i2c: pasemi: Allow to configure bus frequency
  i2c: pasemi: Move common reset code to own function
  i2c: pasemi: Split pci driver to its own file
  i2c: pasemi: Split off common probing code
  i2c: pasemi: Remove usage of pci_dev
  i2c: pasemi: Use dev_name instead of port number
  ...
2021-11-08 11:46:10 -08:00
Rafael J. Wysocki c6f49acb52 i2c: amd-mp2-plat: ACPI: Use ACPI_COMPANION() directly
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION()
macro and the ACPI handle produced by the former comes from the
ACPI device object produced by the latter, so it is way more
straightforward to evaluate the latter directly instead of passing
the handle produced by the former to acpi_bus_get_device().

Modify i2c_amd_probe() accordingly (no intentional functional impact).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-07 14:57:41 +01:00
Andy Shevchenko 76eb4db611 i2c: i801: Add support for Intel Ice Lake PCH-N
Add PCI ID of SMBus controller on Intel Ice Lake PCH-N.

The device can be found on MacBookPro16,2 [1].

[1]: https://linux-hardware.org/?probe=f1c5cf0c43

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-07 14:54:32 +01:00
Wei Yongjun c80be257a4 i2c: xgene-slimpro: Fix wrong pointer passed to PTR_ERR()
PTR_ERR should access the value just tested by IS_ERR, otherwise
the wrong error code will be returned.

Fixes: 7b6da7fe7b ("mailbox: pcc: Use PCC mailbox channel pointer instead of standard")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-11-06 22:09:37 +01:00
Linus Torvalds 95faf6ba65 Driver core changes for 5.16-rc1
Here is the big set of driver core changes for 5.16-rc1.
 
 All of these have been in linux-next for a while now with no reported
 problems.
 
 Included in here are:
 	- big update and cleanup of the sysfs abi documentation files
 	  and scripts from Mauro.  We are almost at the place where we
 	  can properly check that the running kernel's sysfs abi is
 	  documented fully.
 	- firmware loader updates
 	- dyndbg updates
 	- kernfs cleanups and fixes from Christoph
 	- device property updates
 	- component fix
 	- other minor driver core cleanups and fixes
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCYYPbjQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ync9gCfXKMUI1GAnCfJWAwTdTcd18q5akoAoMw32/AH
 0yh5TjAWFyFd7xz5d7qs
 =itsC
 -----END PGP SIGNATURE-----

Merge tag 'driver-core-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
 "Here is the big set of driver core changes for 5.16-rc1.

  All of these have been in linux-next for a while now with no reported
  problems.

  Included in here are:

   - big update and cleanup of the sysfs abi documentation files and
     scripts from Mauro. We are almost at the place where we can
     properly check that the running kernel's sysfs abi is documented
     fully.

   - firmware loader updates

   - dyndbg updates

   - kernfs cleanups and fixes from Christoph

   - device property updates

   - component fix

   - other minor driver core cleanups and fixes"

* tag 'driver-core-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (122 commits)
  device property: Drop redundant NULL checks
  x86/build: Tuck away built-in firmware under FW_LOADER
  vmlinux.lds.h: wrap built-in firmware support under FW_LOADER
  firmware_loader: move struct builtin_fw to the only place used
  x86/microcode: Use the firmware_loader built-in API
  firmware_loader: remove old DECLARE_BUILTIN_FIRMWARE()
  firmware_loader: formalize built-in firmware API
  component: do not leave master devres group open after bind
  dyndbg: refine verbosity 1-4 summary-detail
  gpiolib: acpi: Replace custom code with device_match_acpi_handle()
  i2c: acpi: Replace custom function with device_match_acpi_handle()
  driver core: Provide device_match_acpi_handle() helper
  dyndbg: fix spurious vNpr_info change
  dyndbg: no vpr-info on empty queries
  dyndbg: vpr-info on remove-module complete, not starting
  device property: Add missed header in fwnode.h
  Documentation: dyndbg: Improve cli param examples
  dyndbg: Remove support for ddebug_query param
  dyndbg: make dyndbg a known cli param
  dyndbg: show module in vpr-info in dd-exec-queries
  ...
2021-11-04 08:32:38 -07:00
Linus Torvalds 43e1b12927 vhost,virtio,vhost: fixes,features
Hardening work by Jason
 vdpa driver for Alibaba ENI
 Performance tweaks for virtio blk
 virtio rng rework using an internal buffer
 mac/mtu programming for mlx5 vdpa
 Misc fixes, cleanups
 
 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQFDBAABCAAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmF/su8PHG1zdEByZWRo
 YXQuY29tAAoJECgfDbjSjVRpo+sIAJjBTvbET+d0KuIMt8YBGsU+NWgHaJxW06hm
 GHZzinueZYWaS20MPMYMPfcHUgigWj0kk7F0gMljG5rtDFzR85JkOi7+e5V6RVJW
 8SQc7JjA1Krde6EiPJdlv3mVkLz/5VbrGUgjAW9di/O04Xc/jAc9kmJ41wTYr0mL
 E5IsUi9QBmgHtKQ+2ofb9QEWuebJclGK+NVd3Kp08BtAQOrdn5UrIzY30/sjkZwE
 ul2ll6v/k7T3dCQbHD/wMgfFycPvoZVfxaVj+FWQnwdWkqZwzMRmpKPRes4KJfww
 Lfx1qox10mJzH7XJCs7xmOM8f7HgNNWi0gD5FxNlfkiz1AwHYOk=
 =DTXY
 -----END PGP SIGNATURE-----

Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

Pull virtio updates from Michael Tsirkin:
 "vhost and virtio fixes and features:

   - Hardening work by Jason

   - vdpa driver for Alibaba ENI

   - Performance tweaks for virtio blk

   - virtio rng rework using an internal buffer

   - mac/mtu programming for mlx5 vdpa

   - Misc fixes, cleanups"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (45 commits)
  vdpa/mlx5: Forward only packets with allowed MAC address
  vdpa/mlx5: Support configuration of MAC
  vdpa/mlx5: Fix clearing of VIRTIO_NET_F_MAC feature bit
  vdpa_sim_net: Enable user to set mac address and mtu
  vdpa: Enable user to set mac and mtu of vdpa device
  vdpa: Use kernel coding style for structure comments
  vdpa: Introduce query of device config layout
  vdpa: Introduce and use vdpa device get, set config helpers
  virtio-scsi: don't let virtio core to validate used buffer length
  virtio-blk: don't let virtio core to validate used length
  virtio-net: don't let virtio core to validate used length
  virtio_ring: validate used buffer length
  virtio_blk: correct types for status handling
  virtio_blk: allow 0 as num_request_queues
  i2c: virtio: Add support for zero-length requests
  virtio-blk: fixup coccinelle warnings
  virtio_ring: fix typos in vring_desc_extra
  virtio-pci: harden INTX interrupts
  virtio_pci: harden MSI-X interrupts
  virtio_config: introduce a new .enable_cbs method
  ...
2021-11-03 15:00:39 -07:00
Sakari Ailus b18c1ad685 i2c: Allow an ACPI driver to manage the device's power state during probe
Enable drivers to tell ACPI that there's no need to power on a device for
probe. Drivers should still perform this by themselves if there's a need
to. In some cases powering on the device during probe is undesirable, and
this change enables a driver to choose what fits best for it.

Add a field called "flags" into struct i2c_driver for driver flags, and a
flag I2C_DRV_ACPI_WAIVE_D0_PROBE to tell a driver supports probe in ACPI D
states other than 0.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Acked-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-11-03 19:03:55 +01:00
Viresh Kumar dcce162559 i2c: virtio: Add support for zero-length requests
The virtio specification received a new mandatory feature
(VIRTIO_I2C_F_ZERO_LENGTH_REQUEST) for zero length requests. Fail if the
feature isn't offered by the device.

For each read-request, set the VIRTIO_I2C_FLAGS_M_RD flag, as required
by the VIRTIO_I2C_F_ZERO_LENGTH_REQUEST feature.

This allows us to support zero length requests, like SMBUS Quick, where
the buffer need not be sent anymore.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/7c58868cd26d2fc4bd82d0d8b0dfb55636380110.1634808714.git.viresh.kumar@linaro.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jie Deng <jie.deng@intel.com> # once the spec is merged
2021-11-01 05:26:48 -04:00
Sudeep Holla 7b6da7fe7b mailbox: pcc: Use PCC mailbox channel pointer instead of standard
Now that we have all the shared memory region information populated in
the pcc_mbox_chan, let us propagate the pointer to the same as the
return value to pcc_mbox_request channel.

This eliminates the need for the individual users of PCC mailbox to
parse the PCCT subspace entries and fetch the shmem information. This
also eliminates the need for PCC mailbox controller to set con_priv to
PCCT subspace entries. This is required as con_priv is private to the
controller driver to attach private data associated with the channel and
not meant to be used by the mailbox client/users.

Let us convert all the users of pcc_mbox_{request,free}_channel to use
new interface.

Cc: Jean Delvare <jdelvare@suse.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2021-10-29 22:46:38 -05:00
Christophe JAILLET 7f98960c04 i2c: xlr: Fix a resource leak in the error handling path of 'xlr_i2c_probe()'
A successful 'clk_prepare()' call should be balanced by a corresponding
'clk_unprepare()' call in the error handling path of the probe, as already
done in the remove function.

More specifically, 'clk_prepare_enable()' is used, but 'clk_disable()' is
also already called. So just the unprepare step has still to be done.

Update the error handling path accordingly.

Fixes: 75d31c2372 ("i2c: xlr: add support for Sigma Designs controller variant")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-29 22:04:35 +02:00
Tian Tao 5fe058b04d i2c: qup: move to use request_irq by IRQF_NO_AUTOEN flag
disable_irq() after request_irq() still has a time gap in which
interrupts can come. request_irq() with IRQF_NO_AUTOEN flag will
disable IRQ auto-enable because of requesting.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-29 21:57:33 +02:00
Randy Dunlap 8e98c4f5c3 i2c: qup: fix a trivial typo
Correct the typo of "reamining" to "remaining".

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-29 21:53:32 +02:00
Dmitry Osipenko ef3fe574d4 i2c: tegra: Ensure that device is suspended before driver is removed
Tegra I2C device isn't guaranteed to be suspended after removal of
the driver since driver uses pm_runtime_put() that is asynchronous and
pm_runtime_disable() cancels pending power-change requests. This means
that potentially refcount of the clocks may become unbalanced after
removal of the driver. This a very minor problem which unlikely to
happen in practice and won't cause any visible problems, nevertheless
let's replace pm_runtime_disable() with pm_runtime_force_suspend() and
use pm_runtime_put_sync() which disables RPM of the device and puts it
into suspend before driver is removed.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-29 21:51:31 +02:00
Jarkko Nikula 1ad5dc3540 i2c: i801: Fix incorrect and needless software PEC disabling
Commit a6b8bb6a81 ("i2c: i801: Fix handling SMBHSTCNT_PEC_EN")
attempts to disable software PEC by clearing the SMBHSTCNT_PEC_EN (bit 7)
in the SMBus Host Control register (I/O SMBHSTCNT) but incorrectly
clears it in the PCI Host Configuration register (PCI SMBHSTCFG).

This clearing is actually needless since after above commit the
SMBHSTCNT_PEC_EN is never set and the register is initialized with known
values.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-29 21:30:26 +02:00
Andy Shevchenko 0a2d47aa32 i2c: acpi: Replace custom function with device_match_acpi_handle()
Since driver core provides a generic device_match_acpi_handle()
we may replace the custom one with it. This unifies code to find
an adapter with the similar one which finds a client.

Acked-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/20211014134756.39092-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-20 19:38:58 +02:00
Kewei Xu cc28e578f5 i2c: mediatek: Dump i2c/dma register when a timeout occurs
When a timeout error occurs in i2c transter, it is usually related
to the i2c/dma IP hardware configuration. Therefore, the purpose of
this patch is to dump the key register values of i2c/dma when a
timeout occurs in i2c for debugging.

Signed-off-by: Kewei Xu <kewei.xu@mediatek.com>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 12:40:05 +02:00
Kewei Xu e3e4949e63 i2c: mediatek: Reset the handshake signal between i2c and dma
Due to changes in the hardware design of the handshaking signal
between i2c and dma, it is necessary to reset the handshaking
signal before each transfer to ensure that the multi-msgs can
be transferred correctly.

Signed-off-by: Kewei Xu <kewei.xu@mediatek.com>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 12:39:53 +02:00
Vadim Pasternak 712d6617d0 i2c: mlxcpld: Allow flexible polling time setting for I2C transactions
Allow polling time setting according to I2C frequency supported across
the system. For base frequency 400 KHz and 1 MHz set polling time is set
four times less than for system with base frequency 100KHz.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 12:32:00 +02:00
Sven Peter 3abdc89b5e i2c: pasemi: Set enable bit for Apple variant
Some later revisions after the original PASemi I2C controller introduce
what likely is an enable bit to the CTL register. Without setting it the
actual i2c transmission is never started.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:45:56 +02:00
Sven Peter d88ae2932d i2c: pasemi: Add Apple platform driver
With all the previous preparations we can now finally add
the platform driver to support the PASemi-based controllers
in Apple SoCs. This does not work on the M1 yet but should
work on the early iPhones already.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:45:48 +02:00
Sven Peter a2c34bfd2c i2c: pasemi: Refactor _probe to use devm_*
Using managed device resources means there's nothing left to be done in
pasemi_smb_pci_remove and also allows to remove base and size from
struct pasemi_smbus.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:45:35 +02:00
Sven Peter fd664ab231 i2c: pasemi: Allow to configure bus frequency
Right now the bus frequency has always been hardcoded as
100 KHz with the specific reference clock used in the PASemi
PCI controllers. Make this configurable to prepare for the
platform driver.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:45:28 +02:00
Sven Peter 1a62668cef i2c: pasemi: Move common reset code to own function
Split out common reset call to its own function so that we
can later add support for selecting the clock frequency
and an additional enable bit found in newer revisions.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:45:21 +02:00
Sven Peter 9bc5f4f660 i2c: pasemi: Split pci driver to its own file
Split off the PCI driver so that we can reuse common code for the
platform driver.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:45:16 +02:00
Sven Peter 6adb00c7f0 i2c: pasemi: Split off common probing code
Split off common probing code that will be used by both the PCI and the
platform device.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:45:09 +02:00
Sven Peter c06f50ed36 i2c: pasemi: Remove usage of pci_dev
Prepare to create a platform driver by removing all usages of pci_dev we
can.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:45:04 +02:00
Sven Peter 07e820d4fc i2c: pasemi: Use dev_name instead of port number
Right now the i2c adapter name includes the port number which can
indirectly be used to identify the device. Replace that with dev_name
to directly identify the device and to also allow this to work correctly
once we add platform support.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:44:59 +02:00
Sven Peter 3a7442ac1d i2c: pasemi: Use io{read,write}32
In preparation for splitting this driver up into a platform_driver
and a pci_driver, replace outl/inl usage with pci_iomap and
ioread32/iowrite32.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Acked-by: Olof Johansson <olof@lixom.net>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-11 11:44:55 +02:00
Wolfram Sang c5c34f5793 Merge branch 'i2c/for-current' into i2c/for-mergewindow 2021-10-11 08:15:48 +02:00
Vadim Pasternak 669b2e4aa1 i2c: mlxcpld: Reduce polling time for performance improvement
Decrease polling time 'MLXCPLD_I2C_POLL_TIME' from 400 usec to 200
usec. It improves performance of I2C transactions.

Reliability of setting polling time to 200 usec has been validated
across all the supported systems.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-04 21:57:14 +02:00
Vadim Pasternak fa1049135c i2c: mlxcpld: Modify register setting for 400KHz frequency
Change setting for 400KHz frequency support by more accurate value.

Fixes: 66b0c2846b ("i2c: mlxcpld: Add support for I2C bus frequency setting")
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-04 21:56:20 +02:00
Vadim Pasternak 52f57396c7 i2c: mlxcpld: Fix criteria for frequency setting
Value for getting frequency capability wrongly has been taken from
register offset instead of register value.

Fixes: 66b0c2846b ("i2c: mlxcpld: Add support for I2C bus frequency setting")
Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-04 21:56:13 +02:00
Christophe JAILLET d56baf6efa i2c: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below.

It has been hand modified to use 'dma_set_mask_and_coherent()' instead of
'pci_set_dma_mask()/pci_set_consistent_dma_mask()' when applicable.
This is less verbose.

While at it a 'dev_err()' message has been slightly simplified.

It has been compile tested.

@@
@@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@
@@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@
@@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@
@@
-    PCI_DMA_NONE
+    DMA_NONE

@@
expression e1, e2, e3;
@@
-    pci_alloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-    pci_zalloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-    pci_free_consistent(e1, e2, e3, e4)
+    dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_single(e1, e2, e3, e4)
+    dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_single(e1, e2, e3, e4)
+    dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-    pci_map_page(e1, e2, e3, e4, e5)
+    dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_page(e1, e2, e3, e4)
+    dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_sg(e1, e2, e3, e4)
+    dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_sg(e1, e2, e3, e4)
+    dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_device(e1, e2, e3, e4)
+    dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_dma_mask(e1, e2)
+    dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_consistent_dma_mask(e1, e2)
+    dma_set_coherent_mask(&e1->dev, e2)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-02 09:48:53 +02:00
Krzysztof Kozlowski cf9ae42c43 i2c: exynos: describe drivers in KConfig
Describe better which driver applies to which SoC, to make configuring
kernel for Samsung SoC easier.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-02 09:32:22 +02:00
Krzysztof Kozlowski 511899ec34 i2c: pxa: drop unneeded MODULE_ALIAS
The MODULE_DEVICE_TABLE already creates proper alias for platform
driver.  Having another MODULE_ALIAS causes the alias to be duplicated.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-02 09:32:06 +02:00
Kewei Xu 3bce7703c7 i2c: mediatek: Add OFFSET_EXT_CONF setting back
In the commit be5ce0e97c ("i2c: mediatek: Add i2c ac-timing adjust
support"), we miss setting OFFSET_EXT_CONF register if
i2c->dev_comp->timing_adjust is false, now add it back.

Fixes: be5ce0e97c ("i2c: mediatek: Add i2c ac-timing adjust support")
Signed-off-by: Kewei Xu <kewei.xu@mediatek.com>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-02 08:39:36 +02:00
Jamie Iles 6558b646ce i2c: acpi: fix resource leak in reconfiguration device addition
acpi_i2c_find_adapter_by_handle() calls bus_find_device() which takes a
reference on the adapter which is never released which will result in a
reference count leak and render the adapter unremovable.  Make sure to
put the adapter after creating the client in the same manner that we do
for OF.

Fixes: 525e6fabea ("i2c / ACPI: add support for ACPI reconfigure notifications")
Signed-off-by: Jamie Iles <quic_jiles@quicinc.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
[wsa: fixed title]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-02 08:38:43 +02:00
Kewei Xu b8228aea5a i2c: mediatek: fixing the incorrect register offset
The reason for the modification here is that the previous
offset information is incorrect, OFFSET_DEBUGSTAT = 0xE4 is
the correct value.

Fixes: 25708278f8 ("i2c: mediatek: Add i2c support for MediaTek MT8183")
Signed-off-by: Kewei Xu <kewei.xu@mediatek.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-10-02 08:27:25 +02:00
Michael Brunner 647d908816 i2c: kempld: deprecate class based instantiation
Warn users that class based instantiation is going away soon in favour
of more robust probing and faster bootup times.

Class based instantiation has already been removed for other controllers
and it makes absolutely sense to do it for this one too.

Signed-off-by: Michael Brunner <michael.brunner@kontron.com>
Acked-by: Ingmar Klein <ingmar.klein@kontron.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-29 23:07:02 +02:00
zhaoxiao ed2f85115a i2c: bcm-kona: Fix return value in probe()
When call function devm_platform_ioremap_resource(), we should use IS_ERR()
to check the return value and return PTR_ERR() if failed.

Signed-off-by: zhaoxiao <long870912@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-29 23:05:05 +02:00
Wolfram Sang e7f4264821 i2c: rcar: enable interrupts before starting transfer
We want to enable the interrupts _before_ starting the transfer because
it is good programming style and also the proposed order in the R-Car
manual. There is no difference in practice because it doesn't matter in
which order both conditions appear if we wait for both to happen.

Signed-off-by: Ryo Kataoka <ryo.kataoka.wt@renesas.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-29 23:02:59 +02:00
Heiner Kallweit c073b25dad i2c: i801: Stop using pm_runtime_set_autosuspend_delay(-1)
The original change works as intended, but Andy pointed in [0] that now
userspace could re-enable RPM via sysfs, even though we explicitly want
to disable it. So effectively revert the original patch, just with small
improvements:
- Calls to pm_runtime_allow()/pm_runtime_forbid() don't have to be
  balanced, so we can remove the call to pm_runtime_forbid() in
  i801_remove().
- priv->acpi_reserved is accessed after i801_acpi_remove(), and according
  to Robert [1] the custom handler can't run any longer. Therefore we
  don't have to take priv->acpi_lock.

[0] https://www.spinics.net/lists/linux-i2c/msg52730.html
[1] https://lore.kernel.org/linux-acpi/BYAPR11MB32561D19A0FD9AB93E2B1E5287D39@BYAPR11MB3256.namprd11.prod.outlook.com/T/#t

Fixes: 4e60d5dd10 ("i2c: i801: Improve disabling runtime pm")
Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-29 22:13:45 +02:00
Heiner Kallweit 7d6b61c394 i2c: i801: Use PCI bus rescan mutex to protect P2SB access
As pointed out by Andy in [0] using a local mutex here isn't strictly
wrong but not sufficient. We should hold the PCI rescan lock for P2SB
operations.

[0] https://www.spinics.net/lists/linux-i2c/msg52717.html

Fixes: 1a987c69ce ("i2c: i801: make p2sb_spinlock a mutex")
Reported-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-29 22:12:44 +02:00
Heiner Kallweit 4c5910631c i2c: i801: Improve i801_add_mux
The return value of i801_add_mux() isn't used, so let's change it to void.
In addition remove the not needed cast to struct gpiod_lookup.
GPIO_LOOKUP() uses GPIO_LOOKUP_IDX() that includes this cast.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-29 21:37:40 +02:00
Heiner Kallweit 4811a411a9 i2c: i801: Improve i801_acpi_probe/remove functions
By using ACPI_HANDLE() the handler argument can be retrieved directly.
Both address space handler functions check the handler argument and
return an error if it's NULL. This allows to further simplify the code.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-29 21:37:24 +02:00
Heiner Kallweit e462aa7e39 i2c: i801: Remove not needed check for PCI_COMMAND_INTX_DISABLE
do_pci_enable_device() takes care that PCI_COMMAND_INTX_DISABLE
is cleared if a legacy interrupt is used.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-29 21:37:01 +02:00
Heiner Kallweit 2b3db4db66 i2c: i801: Improve is_dell_system_with_lis3lv02d
Replace the ugly cast of the return_value pointer with proper usage.
In addition use dmi_match() instead of open-coding it.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-29 21:36:35 +02:00
Marek Vasut 294b29f154 i2c: xiic: Fix RX IRQ busy check
In case the XIIC does TX/RX transfer, make sure no other kernel thread
can start another TX transfer at the same time. This could happen since
the driver only checks tx_msg for being non-NULL and returns -EBUSY in
that case, however it is necessary to check also rx_msg for the same.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-14 12:22:54 +02:00
Marek Vasut d12e4bbb19 i2c: xiic: Only ever transfer single message
Transferring multiple messages via XIIC suffers from strange interaction
between the interrupt status/enable register flags. These flags are being
reused in the hardware to indicate different things for read and write
transfer, and doing multiple transactions becomes horribly complex. Just
send a single transaction and reload the controller with another message
once the transaction is done in the interrupt handler thread.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-14 12:22:51 +02:00
Marek Vasut fdacc3c740 i2c: xiic: Switch from waitqueue to completion
There will never be threads queueing up in the xiic_xmit(), use
completion synchronization primitive to wait for the interrupt
handler thread to complete instead as it is much better fit and
there is no need to overload it for this purpose.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-14 12:22:49 +02:00
Marek Vasut 743e227a89 i2c: xiic: Defer xiic_wakeup() and __xiic_start_xfer() in xiic_process()
The __xiic_start_xfer() manipulates the interrupt flags, xiic_wakeup()
may result in return from xiic_xfer() early. Defer both to the end of
the xiic_process() interrupt thread, so that they are executed after
all the other interrupt bits handling completed and once it completely
safe to perform changes to the interrupt bits in the hardware.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-14 12:22:46 +02:00
Marek Vasut 861dcffe1b i2c: xiic: Drop broken interrupt handler
The interrupt handler is missing locking when reading out registers
and is racing with other threads which might access the driver. Drop
it altogether, so that the threaded interrupt is always executed, as
that one is already serialized by the driver mutex. This also allows
dropping local_irq_save()/local_irq_restore() in xiic_start_recv().

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-14 12:22:44 +02:00
Marek Vasut c119e7d00c i2c: xiic: Fix broken locking on tx_msg
The tx_msg is set from multiple places, sometimes without locking,
which fall apart on any SMP system. Only ever access tx_msg inside
the driver mutex.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-09-14 12:22:41 +02:00
Linus Torvalds 7ba88a2a09 platform-drivers-x86 for v5.15-1
Highlights:
  - Move all the Intel drivers into their own subdir(s) (mostly Kate's work)
  - New meraki-mx100 platform driver
  - Asus WMI driver enhancements, including
    /sys/firmware/acpi/platform_profile support
  - New BIOS SAR driver for Intel M.2 WWAM modems
  - Alder Lake support for the Intel PMC driver
  - A whole bunch of cleanups + fixes all over the place
 
 The following is an automated git shortlog grouped by driver:
 
 BIOS SAR driver for Intel M.2 Modem:
  - BIOS SAR driver for Intel M.2 Modem
 
 ISST:
  -  use semi-colons instead of commas
  -  Fix optimization with use of numa
 
 Replace deprecated CPU-hotplug functions.:
  - Replace deprecated CPU-hotplug functions.
 
 Update Mario Limonciello's email address in the docs:
  - Update Mario Limonciello's email address in the docs
 
 acer-wmi:
  -  Add Turbo Mode support for Acer PH315-53
 
 add meraki-mx100 platform driver:
  - add meraki-mx100 platform driver
 
 asus-nb-wmi:
  -  Add tablet_mode_sw=lid-flip quirk for the TP200s
  -  Allow configuring SW_TABLET_MODE method with a module option
 
 asus-wmi:
  -  Fix "unsigned 'retval' is never less than zero" smatch warning
  -  Delete impossible condition
  -  Add support for platform_profile
  -  Add egpu enable method
  -  Add dgpu disable method
  -  Add panel overdrive functionality
 
 dell-smbios:
  -  Remove unused dmi_system_id table
 
 dell-smbios-wmi:
  -  Add missing kfree in error-exit from run_smbios_call
  -  Avoid false-positive memcpy() warning
 
 dell-smo8800:
  -  Convert to be a platform driver
 
 dual_accel_detect:
  -  Use the new i2c_acpi_client_count() helper
 
 gigabyte-wmi:
  -  add support for B450M S2H V2
  -  add support for X570 GAMING X
 
 hp_accel:
  -  Convert to be a platform driver
  -  Remove _INI method call
 
 i2c:
  -  acpi: Add an i2c_acpi_client_count() helper function
 
 i2c-multi-instantiate:
  -  Use the new i2c_acpi_client_count() helper
 
 ideapad-laptop:
  -  Fix Legion 5 Fn lock LED
 
 intel-hid:
  -  Move to intel sub-directory
 
 intel-rst:
  -  Move to intel sub-directory
 
 intel-smartconnect:
  -  Move to intel sub-directory
 
 intel-uncore-frequency:
  -  Move to intel sub-directory
 
 intel-vbtn:
  -  Move to intel sub-directory
 
 intel-wmi-sbl-fw-update:
  -  Move to intel sub-directory
 
 intel-wmi-thunderbolt:
  -  Move to intel sub-directory
 
 intel_atomisp2:
  -  Move to intel sub-directory
 
 intel_bxtwc_tmu:
  -  Move to intel sub-directory
 
 intel_cht_int33fe:
  -  Use the new i2c_acpi_client_count() helper
 
 intel_chtdc_ti_pwrbtn:
  -  Move to intel sub-directory
 
 intel_int0002_vgpio:
  -  Move to intel sub-directory
 
 intel_mrfld_pwrbtn:
  -  Move to intel sub-directory
 
 intel_oaktrail:
  -  Move to intel sub-directory
 
 intel_pmc_core:
  -  Move to intel sub-directory
  -  Prevent possibile overflow
 
 intel_pmt_telemetry:
  -  Ignore zero sized entries
 
 intel_punit_ipc:
  -  Move to intel sub-directory
 
 intel_scu_ipc:
  -  Fix doc of intel_scu_ipc_dev_command_with_size()
 
 intel_speed_select_if:
  -  Move to intel sub-directory
 
 intel_telemetry:
  -  Move to intel sub-directory
 
 intel_turbo_max_3:
  -  Move to intel sub-directory
 
 lg-laptop:
  -  Use correct event for keyboard backlight FN-key
  -  Use correct event for touchpad toggle FN-key
  -  Support for battery charge limit on newer models
 
 platform/mellanox:
  -  mlxbf-pmc: fix kernel-doc notation
 
 platform/surface:
  -  aggregator: Use y instead of objs in Makefile
  -  surface3_power: Use i2c_acpi_get_i2c_resource() helper
 
 platform/x86/intel:
  -  pmc/core: Add GBE Package C10 fix for Alder Lake PCH
  -  pmc/core: Add Alder Lake low power mode support for pmc core
  -  pmc/core: Add Latency Tolerance Reporting (LTR) support to Alder Lake
  -  pmc/core: Add Alderlake support to pmc core driver
  -  int3472: Use y instead of objs in Makefile
  -  pmt: Use y instead of objs in Makefile
  -  int33fe: Use y instead of objs in Makefile
  -  Move Intel PMT drivers to new subfolder
 
 thermal/drivers/intel:
  -  Move intel_menlow to thermal drivers
 
 think-lmi:
  -  add debug_cmd
 -----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCAAyFiEEuvA7XScYQRpenhd+kuxHeUQDJ9wFAmEw1KAUHGhkZWdvZWRl
 QHJlZGhhdC5jb20ACgkQkuxHeUQDJ9wk7Qf/dsaaDgx7aC6DfKzdcMgfeLIdTaGm
 a6svNXM2t/JFdvhjYzxA+4QlQgco7zkN06iRlWbObEonSUsHlGlwEOHX60VgcopO
 qJaqnznmfdXUocFTnA+5acJXabNaw7xkKHS0K61UWgk+mm6aMuygpKxULnNTa4X+
 p3HoU6uXFckpoA/Jstzo5UfegNYhg11bflNd7XN4F3rMCbbNHAsWlf4oVr2YsEHa
 wECW+1e8wZl4BInUzoXQhilRoybJWXWJ8sLsvQfDXLs9aNoLdDqu9p0MuXEW5QqE
 wNt26SNNAP2L49BD6kaJszV5Ry/jNSEtVkWwkrzHbGTZoOEyMYas8pm6Uw==
 =iK1W
 -----END PGP SIGNATURE-----

Merge tag 'platform-drivers-x86-v5.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver updates from Hans de Goede:
 "Highlights:

   - Move all the Intel drivers into their own subdir(s) (mostly Kate's
     work)

   - New meraki-mx100 platform driver

   - Asus WMI driver enhancements, including support for
     /sys/firmware/acpi/platform_profile

   - New BIOS SAR driver for Intel M.2 WWAM modems

   - Alder Lake support for the Intel PMC driver

   - A whole bunch of cleanups + fixes all over the place"

* tag 'platform-drivers-x86-v5.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (65 commits)
  platform/x86: dell-smbios-wmi: Add missing kfree in error-exit from run_smbios_call
  platform/x86: dell-smbios-wmi: Avoid false-positive memcpy() warning
  platform/x86: ISST: use semi-colons instead of commas
  platform/x86: asus-wmi: Fix "unsigned 'retval' is never less than zero" smatch warning
  platform/x86: asus-wmi: Delete impossible condition
  platform/x86: hp_accel: Convert to be a platform driver
  platform/x86: hp_accel: Remove _INI method call
  platform/mellanox: mlxbf-pmc: fix kernel-doc notation
  platform/x86/intel: pmc/core: Add GBE Package C10 fix for Alder Lake PCH
  platform/x86/intel: pmc/core: Add Alder Lake low power mode support for pmc core
  platform/x86/intel: pmc/core: Add Latency Tolerance Reporting (LTR) support to Alder Lake
  platform/x86/intel: pmc/core: Add Alderlake support to pmc core driver
  platform/x86: intel-wmi-thunderbolt: Move to intel sub-directory
  platform/x86: intel-wmi-sbl-fw-update: Move to intel sub-directory
  platform/x86: intel-vbtn: Move to intel sub-directory
  platform/x86: intel_oaktrail: Move to intel sub-directory
  platform/x86: intel_int0002_vgpio: Move to intel sub-directory
  platform/x86: intel-hid: Move to intel sub-directory
  platform/x86: intel_atomisp2: Move to intel sub-directory
  platform/x86: intel_speed_select_if: Move to intel sub-directory
  ...
2021-09-02 13:49:39 -07:00
Linus Torvalds c6c3c5704b Driver core update for 5.15-rc1
Here is the big set of driver core patches for 5.15-rc1.
 
 These do change a number of different things across different
 subsystems, and because of that, there were 2 stable tags created that
 might have already come into your tree from different pulls that did the
 following
 	- changed the bus remove callback to return void
 	- sysfs iomem_get_mapping rework
 
 The latter one will cause a tiny merge issue with your tree, as there
 was a last-minute fix for this in 5.14 in your tree, but the fixup
 should be "obvious".  If you want me to provide a fixed merge for this,
 please let me know.
 
 Other than those two things, there's only a few small things in here:
 	- kernfs performance improvements for huge numbers of sysfs
 	  users at once
 	- tiny api cleanups
 	- other minor changes
 
 All of these have been in linux-next for a while with no reported
 problems, other than the before-mentioned merge issue.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCYS+FLQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylXuACfWECnysDtXNe66DdETCFs1a1RToYAoMokWeU5
 s8VFP1NY2BjmxJbkebLL
 =8kVu
 -----END PGP SIGNATURE-----

Merge tag 'driver-core-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
 "Here is the big set of driver core patches for 5.15-rc1.

  These do change a number of different things across different
  subsystems, and because of that, there were 2 stable tags created that
  might have already come into your tree from different pulls that did
  the following

   - changed the bus remove callback to return void

   - sysfs iomem_get_mapping rework

  Other than those two things, there's only a few small things in here:

   - kernfs performance improvements for huge numbers of sysfs users at
     once

   - tiny api cleanups

   - other minor changes

  All of these have been in linux-next for a while with no reported
  problems, other than the before-mentioned merge issue"

* tag 'driver-core-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (33 commits)
  MAINTAINERS: Add dri-devel for component.[hc]
  driver core: platform: Remove platform_device_add_properties()
  ARM: tegra: paz00: Handle device properties with software node API
  bitmap: extend comment to bitmap_print_bitmask/list_to_buf
  drivers/base/node.c: use bin_attribute to break the size limitation of cpumap ABI
  topology: use bin_attribute to break the size limitation of cpumap ABI
  lib: test_bitmap: add bitmap_print_bitmask/list_to_buf test cases
  cpumask: introduce cpumap_print_list/bitmask_to_buf to support large bitmask and list
  sysfs: Rename struct bin_attribute member to f_mapping
  sysfs: Invoke iomem_get_mapping() from the sysfs open callback
  debugfs: Return error during {full/open}_proxy_open() on rmmod
  zorro: Drop useless (and hardly used) .driver member in struct zorro_dev
  zorro: Simplify remove callback
  sh: superhyway: Simplify check in remove callback
  nubus: Simplify check in remove callback
  nubus: Make struct nubus_driver::remove return void
  kernfs: dont call d_splice_alias() under kernfs node lock
  kernfs: use i_lock to protect concurrent inode updates
  kernfs: switch kernfs to use an rwsem
  kernfs: use VFS negative dentry caching
  ...
2021-09-01 08:44:42 -07:00
Linus Torvalds 871dda463c Merge branch 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:
 "I2C has a smaller pull reuest this time:

   - new driver for I2C virtio

   - removal of PMC SMP driver because platform is already gone

   - IRQ probing and DMAENGINE API cleanups

   - add SI metric prefix definitions to units.h

   - beginning of i801 refactorization

   - a few driver improvements"

* 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (28 commits)
  i2c: cadence: Implement save restore
  i2c: xlp9xx: fix main IRQ check
  i2c: mt65xx: fix IRQ check
  i2c: virtio: add a virtio i2c frontend driver
  i2c: hix5hd2: fix IRQ check
  i2c: s3c2410: fix IRQ check
  i2c: iop3xx: fix deferred probing
  i2c: synquacer: fix deferred probing
  i2c: sun6i-pw2i: Prefer strscpy over strlcpy
  i2c: remove dead PMC MSP TWI/SMBus/I2C driver
  i2c: dev: Use sysfs_emit() in "show" functions
  i2c: dev: Define pr_fmt() and drop duplication substrings
  i2c: designware: Fix indentation in the header
  i2c: designware: Use DIV_ROUND_CLOSEST() macro
  units: Add SI metric prefix definitions
  i2c: at91: mark PM ops as __maybe unused
  i2c: sh_mobile: : use proper DMAENGINE API for termination
  i2c: qup: : use proper DMAENGINE API for termination
  i2c: mxs: : use proper DMAENGINE API for termination
  i2c: imx: : use proper DMAENGINE API for termination
  ...
2021-08-31 14:34:01 -07:00
Shubhrajyoti Datta 8b51a8e644 i2c: cadence: Implement save restore
The zynqmp platform now supports chip-off so the registers can
lose context.
Implement save restore for i2c module.
Since we have only a couple of registers
an unconditional restore is done.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-25 23:07:05 +02:00
Sergey Shtylyov 661e8a88e8 i2c: xlp9xx: fix main IRQ check
Iff platform_get_irq() returns 0 for the main IRQ, the driver's probe()
method will return 0 early (as if the method's call was successful).
Let's consider IRQ0 valid for simplicity -- devm_request_irq() can always
override that decision...

Fixes: 2bbd681ba2 ("i2c: xlp9xx: Driver for Netlogic XLP9XX/5XX I2C controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Reviewed-by: George Cherian <george.cherian@marvell.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-25 23:04:17 +02:00
Sergey Shtylyov 58fb7c643d i2c: mt65xx: fix IRQ check
Iff platform_get_irq() returns 0, the driver's probe() method will return 0
early (as if the method's call was successful).  Let's consider IRQ0 valid
for simplicity -- devm_request_irq() can always override that decision...

Fixes: ce38815d39 ("I2C: mediatek: Add driver for MediaTek I2C controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-25 23:00:09 +02:00
Jie Deng 3cfc883804 i2c: virtio: add a virtio i2c frontend driver
Add an I2C bus driver for virtio para-virtualization.

The controller can be emulated by the backend driver in
any device model software by following the virtio protocol.

The device specification can be found on
https://lists.oasis-open.org/archives/virtio-comment/202101/msg00008.html.

By following the specification, people may implement different
backend drivers to emulate different controllers according to
their needs.

Co-developed-by: Conghui Chen <conghui.chen@intel.com>
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Signed-off-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-19 21:21:19 +02:00
Sergey Shtylyov f9b459c2ba i2c: hix5hd2: fix IRQ check
Iff platform_get_irq() returns 0, the driver's probe() method will return 0
early (as if the method's call was successful).  Let's consider IRQ0 valid
for simplicity -- devm_request_irq() can always override that decision...

Fixes: 15ef27756b ("i2c: hix5hd2: add i2c controller driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-19 19:18:24 +02:00
Sergey Shtylyov d6840a5e37 i2c: s3c2410: fix IRQ check
Iff platform_get_irq() returns 0, the driver's probe() method will return 0
early (as if the method's call was successful).  Let's consider IRQ0 valid
for simplicity -- devm_request_irq() can always override that decision...

Fixes: e0d1ec9785 ("i2c-s3c2410: Change IRQ to be plain integer.")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-19 19:18:24 +02:00
Sergey Shtylyov a129950516 i2c: iop3xx: fix deferred probing
When adding the code to handle platform_get_irq*() errors in the commit
489447380a ("handle errors returned by platform_get_irq*()"), the
actual error code was enforced to be -ENXIO in the driver for some
strange reason.  This didn't matter much until the deferred probing was
introduced -- which requires an actual error code to be propagated
upstream from the failure site.

While fixing this, also stop overriding the errors from request_irq() to
-EIO (done since the pre-git era).

Fixes: 489447380a ("[PATCH] handle errors returned by platform_get_irq*()")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-19 19:18:17 +02:00
Sergey Shtylyov 8d744da241 i2c: synquacer: fix deferred probing
The driver overrides the error codes returned by platform_get_irq() to
-ENODEV, so if it returns -EPROBE_DEFER, the driver will fail the probe
permanently instead of the deferred probing. Switch to propagating the
error codes upstream.

Fixes: 0d676a6c43 ("i2c: add support for Socionext SynQuacer I2C controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-17 21:41:32 +02:00
Len Baker e47a0ced40 i2c: sun6i-pw2i: Prefer strscpy over strlcpy
strlcpy() reads the entire source buffer first. This read may exceed the
destination size limit. This is both inefficient and can lead to linear
read overflows if a source string is not NUL-terminated. The safe
replacement is strscpy().

This is a previous step in the path to remove the strlcpy() function
entirely from the kernel [1].

[1] https://github.com/KSPP/linux/issues/89

Signed-off-by: Len Baker <len.baker@gmx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-17 21:37:40 +02:00
Lukas Bulwahn e517992bbc i2c: remove dead PMC MSP TWI/SMBus/I2C driver
Commit 1b00767fd8 ("MIPS: Remove PMC MSP71xx platform") removes the
config PMC_MSP in ./arch/mips/Kconfig.

Hence, since then, the corresponding PMC MSP TWI/SMBus/I2C driver is
dead code. Remove this dead driver.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-17 21:17:46 +02:00
Hans de Goede 20a1b3acfc i2c: acpi: Add an i2c_acpi_client_count() helper function
We have 3 files now which have the need to count the number of
I2cSerialBus resources in an ACPI-device's resource-list.

Currently all implement their own helper function for this,
add a generic helper function to replace the 3 implementations.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210803160044.158802-2-hdegoede@redhat.com
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
2021-08-12 17:26:24 +02:00
Andy Shevchenko b18f32d987 i2c: dev: Use sysfs_emit() in "show" functions
The sysfs_emit() function was introduced to make it less ambiguous
which function is preferred when writing to the output buffer in
a "show" callback [1].

Convert the I²C device sysfs interface from sprintf() to sysfs_emit()
accordingly, as the latter is aware of the PAGE_SIZE buffer and correctly
returns the number of bytes written into the buffer.

No functional change intended.

[1] Documentation/filesystems/sysfs.rst

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 16:48:51 +02:00
Andy Shevchenko 295e0e7be7 i2c: dev: Define pr_fmt() and drop duplication substrings
Define pr_fmt() to print module name as prefix and at the same time
drop duplication substrings in the messages.

While at it, convert printk(<LEVEL>) to pr_<level>().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 16:46:41 +02:00
Andy Shevchenko 85888376a8 i2c: designware: Fix indentation in the header
In couple of places the indentation makes harder to read the code.
Fix it to be sane.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 16:43:32 +02:00
Andy Shevchenko c045214a0f i2c: designware: Use DIV_ROUND_CLOSEST() macro
Instead of open-coding DIV_ROUND_CLOSEST() and similar use the macros directly.
While at it, replace numbers with predefined SI metric prefixes.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 16:43:25 +02:00
Wolfram Sang a2c21668a0 i2c: at91: mark PM ops as __maybe unused
The driver uses pm_ptr(), so the PM ops could be unused.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: dab4b0e8c9 ("i2c: at91: remove #define CONFIG_PM")
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Reviewed-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 15:54:01 +02:00
Wolfram Sang e5a7cb0d90 i2c: sh_mobile: : use proper DMAENGINE API for termination
dmaengine_terminate_all() is deprecated in favor of explicitly saying if
it should be sync or async. Here, we want dmaengine_terminate_sync()
because there is no other synchronization code in the driver to handle
an async case.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 15:22:24 +02:00
Wolfram Sang 0425b937a7 i2c: qup: : use proper DMAENGINE API for termination
dmaengine_terminate_all() is deprecated in favor of explicitly saying if
it should be sync or async. Here, we want dmaengine_terminate_sync()
because there is no other synchronization code in the driver to handle
an async case.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 15:19:00 +02:00
Wolfram Sang 101703ca8e i2c: mxs: : use proper DMAENGINE API for termination
dmaengine_terminate_all() is deprecated in favor of explicitly saying if
it should be sync or async. Here, we want dmaengine_terminate_sync()
because there is no other synchronization code in the driver to handle
an async case.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 15:16:01 +02:00
Wolfram Sang 73a370cff4 i2c: imx: : use proper DMAENGINE API for termination
dmaengine_terminate_all() is deprecated in favor of explicitly saying if
it should be sync or async. Here, we want dmaengine_terminate_sync()
because there is no other synchronization code in the driver to handle
an async case.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 15:15:30 +02:00
Wolfram Sang 73c76332a4 i2c: at91-master: : use proper DMAENGINE API for termination
dmaengine_terminate_all() is deprecated in favor of explicitly saying if
it should be sync or async. Here, we want dmaengine_terminate_sync()
because there is no other synchronization code in the driver to handle
an async case.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-11 15:12:18 +02:00
Claudiu Beznea dab4b0e8c9 i2c: at91: remove #define CONFIG_PM
Remove #define CONFIG_PM and use __maybe_unused for PM functions and
pm_ptr() for PM ops.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Reviewed-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-10 23:08:42 +02:00
Andy Shevchenko 9c5b1daa3b i2c: parport: Switch to use module_parport_driver()
Switch to use module_parport_driver() to reduce boilerplate code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-10 23:07:37 +02:00
Greg Kroah-Hartman 86ff25ed6c i2c: dev: zero out array used for i2c reads from userspace
If an i2c driver happens to not provide the full amount of data that a
user asks for, it is possible that some uninitialized data could be sent
to userspace.  While all in-kernel drivers look to be safe, just be sure
by initializing the buffer to zero before it is passed to the i2c driver
so that any future drivers will not have this issue.

Also properly copy the amount of data recvieved to the userspace buffer,
as pointed out by Dan Carpenter.

Reported-by: Eric Dumazet <edumazet@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-10 22:54:10 +02:00
Dhananjay Phadke bba676cc0b i2c: iproc: fix race between client unreg and tasklet
Similar NULL deref was originally fixed by graceful teardown sequence -

https://lore.kernel.org/linux-i2c/1597106560-79693-1-git-send-email-dphadke@linux.microsoft.com

After this, a tasklet was added to take care of FIFO full condition for large i2c
transaction.

https://lore.kernel.org/linux-arm-kernel/20201102035433.6774-1-rayagonda.kokatanur@broadcom.com/

This introduced regression, a new race condition between tasklet enabling
interrupts and client unreg teardown sequence.

Kill tasklet before unreg_slave() masks bits in IE_OFFSET.
Updated teardown sequence -
(1) disable_irq()
(2) Kill tasklet
(3) Mask event enable bits in control reg
(4) Erase slave address (avoid further writes to rx fifo)
(5) Flush tx and rx FIFOs
(6) Clear pending event (interrupt) bits in status reg
(7) Set client pointer to NULL
(8) enable_irq()

 --

 Unable to handle kernel read from unreadable memory at virtual address 0000000000000320
 Mem abort info:
   ESR = 0x96000004
   EC = 0x25: DABT (current EL), IL = 32 bits
   SET = 0, FnV = 0
   EA = 0, S1PTW = 0
 Data abort info:
   ISV = 0, ISS = 0x00000004
   CM = 0, WnR = 0
 user pgtable: 4k pages, 48-bit VAs, pgdp=000000009212a000
 [0000000000000320] pgd=0000000000000000, p4d=0000000000000000
 Internal error: Oops: 96000004 [#1] SMP
 CPU: 0 PID: 0 Comm: swapper/0 Tainted: G           O
 Hardware name: Overlake (DT)
 pstate: 40400085 (nZcv daIf +PAN -UAO -TCO BTYPE=--)
 pc : bcm_iproc_i2c_slave_isr+0x2b8/0x8e4
 lr : bcm_iproc_i2c_slave_isr+0x1c8/0x8e4
 sp : ffff800010003e70
 x29: ffff800010003e80 x28: ffffda017acdc000
 x27: ffffda017b0ae000 x26: ffff800010004000
 x25: ffff800010000000 x24: ffffda017af4a168
 x23: 0000000000000073 x22: 0000000000000000
 x21: 0000000001400000 x20: 0000000001000000
 x19: ffff06f09583f880 x18: 00000000fa83b2da
 x17: 000000000000b67e x16: 0000000002edb2f3
 x15: 00000000000002c7 x14: 00000000000002c7
 x13: 0000000000000006 x12: 0000000000000033
 x11: 0000000000000000 x10: 0000000001000000
 x9 : 0000000003289312 x8 : 0000000003289311
 x7 : 02d0cd03a303adbc x6 : 02d18e7f0a4dfc6c
 x5 : 02edb2f33f76ea68 x4 : 00000000fa83b2da
 x3 : ffffda017af43cd0 x2 : ffff800010003e74
 x1 : 0000000001400000 x0 : 0000000000000000
 Call trace:
  bcm_iproc_i2c_slave_isr+0x2b8/0x8e4
  bcm_iproc_i2c_isr+0x178/0x290
  __handle_irq_event_percpu+0xd0/0x200
  handle_irq_event+0x60/0x1a0
  handle_fasteoi_irq+0x130/0x220
  __handle_domain_irq+0x8c/0xcc
  gic_handle_irq+0xc0/0x120
  el1_irq+0xcc/0x180
  finish_task_switch+0x100/0x1d8
  __schedule+0x61c/0x7a0
  schedule_idle+0x28/0x44
  do_idle+0x254/0x28c
  cpu_startup_entry+0x28/0x2c
  rest_init+0xc4/0xd0
  arch_call_rest_init+0x14/0x1c
  start_kernel+0x33c/0x3b8
 Code: f9423260 910013e2 11000509 b9047a69 (f9419009)
 ---[ end trace 4781455b2a7bec15 ]---

Fixes: 4d658451c9 ("i2c: iproc: handle rx fifo full interrupt")

Signed-off-by: Dhananjay Phadke <dphadke@linux.microsoft.com>
Acked-by: Ray Jui <ray.jui@broadcom.com>
Acked-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-10 22:40:55 +02:00
Heiner Kallweit 60aea76d85 i2c: i801: Remove not needed debug message
If a user is interested in such details he can enable smbus tracing.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-10 22:36:37 +02:00
Heiner Kallweit 1a987c69ce i2c: i801: make p2sb_spinlock a mutex
p2sb_spinlock is used in i801_add_tco_spt() only, and in process context
only. Therefore a mutex is sufficient, and we can make the definition
local to i801_add_tco_spt().

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-10 22:36:27 +02:00
Heiner Kallweit 4e60d5dd10 i2c: i801: Improve disabling runtime pm
Setting the autosuspend delay to a negative value disables runtime pm in
a little bit smarter way, because we need no cleanup when removing the
driver. Note that this is safe when reloading the driver, because the
call to pm_runtime_set_autosuspend_delay() in probe() will reverse the
effect. See update_autosuspend() for details.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-10 22:36:15 +02:00
Sergey Shtylyov f16a3bb69a i2c: highlander: add IRQ check
The driver is written as if platform_get_irq() returns 0 on errors (while
actually it returns a negative error code), blithely passing these error
codes to request_irq() (which takes *unsigned* IRQ #) -- which fails with
-EINVAL. Add the necessary error check to the pre-existing *if* statement
forcing the driver into the polling mode...

Fixes: 4ad48e6ab1 ("i2c: Renesas Highlander FPGA SMBus support")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-08-03 22:48:39 +02:00
Heiner Kallweit a6b8bb6a81 i2c: i801: Fix handling SMBHSTCNT_PEC_EN
Bit SMBHSTCNT_PEC_EN is used only if software calculates the CRC and
uses register SMBPEC. This is not supported by the driver, it supports
hw-calculation of CRC only (using bit SMBAUXSTS_CRCE). The chip spec
states the following, therefore never set bit SMBHSTCNT_PEC_EN.

Chapter SMBus CRC Generation and Checking
If the AAC bit is set in the Auxiliary Control register, the PCH
automatically calculates and drives CRC at the end of the transmitted
packet for write cycles, and will check the CRC for read cycles. It will
not transmit the contents of the PEC register for CRC. The PEC bit must
not be set in the Host Control register. If this bit is set, unspecified
behavior will result.

This patch is based solely on the specification and compile-tested only,
because I have no PEC-capable devices.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-07-28 11:35:39 +02:00
Greg Kroah-Hartman bdac4d8abb Merge 5.14-rc3 into driver-core-next
We need the driver-core fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-27 09:22:08 +02:00
Uwe Kleine-König fc7a6209d5 bus: Make remove callback return void
The driver core ignores the return value of this callback because there
is only little it can do when a device disappears.

This is the final bit of a long lasting cleanup quest where several
buses were converted to also return void from their remove callback.
Additionally some resource leaks were fixed that were caused by drivers
returning an error code in the expectation that the driver won't go
away.

With struct bus_type::remove returning void it's prevented that newly
implemented buses return an ignored error code and so don't anticipate
wrong expectations for driver authors.

Reviewed-by: Tom Rix <trix@redhat.com> (For fpga)
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Cornelia Huck <cohuck@redhat.com> (For drivers/s390 and drivers/vfio)
Acked-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> (For ARM, Amba and related parts)
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Chen-Yu Tsai <wens@csie.org> (for sunxi-rsb)
Acked-by: Pali Rohár <pali@kernel.org>
Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org> (for media)
Acked-by: Hans de Goede <hdegoede@redhat.com> (For drivers/platform)
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-By: Vinod Koul <vkoul@kernel.org>
Acked-by: Juergen Gross <jgross@suse.com> (For xen)
Acked-by: Lee Jones <lee.jones@linaro.org> (For mfd)
Acked-by: Johannes Thumshirn <jth@kernel.org> (For mcb)
Acked-by: Johan Hovold <johan@kernel.org>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> (For slimbus)
Acked-by: Kirti Wankhede <kwankhede@nvidia.com> (For vfio)
Acked-by: Maximilian Luz <luzmaximilian@gmail.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> (For ulpi and typec)
Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> (For ipack)
Acked-by: Geoff Levand <geoff@infradead.org> (For ps3)
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com> (For thunderbolt)
Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> (For intel_th)
Acked-by: Dominik Brodowski <linux@dominikbrodowski.net> (For pcmcia)
Acked-by: Rafael J. Wysocki <rafael@kernel.org> (For ACPI)
Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org> (rpmsg and apr)
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> (For intel-ish-hid)
Acked-by: Dan Williams <dan.j.williams@intel.com> (For CXL, DAX, and NVDIMM)
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com> (For isa)
Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (For firewire)
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> (For hid)
Acked-by: Thorsten Scherer <t.scherer@eckelmann.de> (For siox)
Acked-by: Sven Van Asbroeck <TheSven73@gmail.com> (For anybuss)
Acked-by: Ulf Hansson <ulf.hansson@linaro.org> (For MMC)
Acked-by: Wolfram Sang <wsa@kernel.org> # for I2C
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Finn Thain <fthain@linux-m68k.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20210713193522.1770306-6-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-21 11:53:42 +02:00
Chris Packham 4a8ac5e45c i2c: mpc: Poll for MCF
During some transfers the bus can still be busy when an interrupt is
received. Commit 763778cd79 ("i2c: mpc: Restore reread of I2C status
register") attempted to address this by re-reading MPC_I2C_SR once but
that just made it less likely to happen without actually preventing it.
Instead of a single re-read, poll with a timeout so that the bus is given
enough time to settle but a genuine stuck SCL is still noticed.

Fixes: 1538d82f46 ("i2c: mpc: Interrupt driven transfer")
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-07-20 22:32:01 +02:00
Linus Torvalds 855ff900b8 Merge branch 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang:

 - core supports now bus regulators controlling power for SCL/SDA

 - quite some DT binding conversions to YAML

 - added a seperate DT binding for the optional SMBus Alert feature

 - documentation with examples how to deal with I2C sysfs files

 - some bigger rework for the i801 driver

 - and a few usual driver updates

* 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (42 commits)
  i2c: ali1535: mention that the device should not be disabled
  i2c: mpc: Restore reread of I2C status register
  i2c: core-smbus: Expose PEC calculate function for generic use
  Documentation: i2c: Add doc for I2C sysfs
  i2c: core: Disable client irq on reboot/shutdown
  dt-bindings: i2c: update bindings for MT8195 SoC
  i2c: imx: Fix some checkpatch warnings
  i2c: davinci: Simplify with dev_err_probe()
  i2c: cadence: Simplify with dev_err_probe()
  i2c: xiic: Simplify with dev_err_probe()
  i2c: cadence: Clear HOLD bit before xfer_size register rolls over
  dt-bindings: i2c: ce4100: Replace "ti,pcf8575" by "nxp,pcf8575"
  i2c: i801: Improve i801_setup_hstcfg
  i2c: i801: Use driver name constant instead of function dev_driver_string
  i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves
  i2c: i801: Improve status polling
  i2c: cht-wc: Replace of_node by NULL
  i2c: riic: Add RZ/G2L support
  dt-bindings: i2c: renesas,riic: Document RZ/G2L I2C controller
  dt-bindings: i2c: renesas,iic: Convert to json-schema
  ...
2021-07-04 11:47:18 -07:00
Wolfram Sang 9d6336831b i2c: ali1535: mention that the device should not be disabled
The comment from the i801 driver is valid here, too, so copy it.

Reported-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-07-02 09:14:46 +02:00
Chris Packham 763778cd79 i2c: mpc: Restore reread of I2C status register
Prior to commit 1538d82f46 ("i2c: mpc: Interrupt driven transfer") the
old interrupt handler would reread MPC_I2C_SR after checking the CSR_MIF
bit. When the driver was re-written this was removed as it seemed
unnecessary. However as it turns out this is necessary for i2c devices
which do clock stretching otherwise we end up thinking the bus is still
busy when processing the interrupt.

Fixes: 1538d82f46 ("i2c: mpc: Interrupt driven transfer")
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-07-02 09:12:51 +02:00
Linus Torvalds 5e6928249b ACPI updates for 5.14-rc1
- Update ACPICA code in the kernel to upstrea revision 20210604
    including the following changes:
 
    * Add defines for the CXL Host Bridge Structureand and add the
      CFMWS structure definition to CEDT (Alison Schofield).
    * iASL: Finish support for the IVRS ACPI table (Bob Moore).
    * iASL: Add support for the SVKL table (Bob Moore).
    * iASL: Add full support for RGRT ACPI table (Bob Moore).
    * iASL: Add support for the BDAT ACPI table (Bob Moore).
    * iASL: add disassembler support for PRMT (Erik Kaneda).
    * Fix memory leak caused by _CID repair function (Erik Kaneda).
    * Add support for PlatformRtMechanism OpRegion (Erik Kaneda).
    * Add PRMT module header to facilitate parsing (Erik Kaneda).
    * Add _PLD panel positions (Fabian Wüthrich).
    * MADT: add Multiprocessor Wakeup Mailbox Structure and the
      SVKL table headers (Kuppuswamy Sathyanarayanan).
    * Use ACPI_FALLTHROUGH (Wei Ming Chen).
 
  - Add preliminary support for the Platform Runtime Mechanism (PRM)
    to allow the AML interpreter to call PRM functions (Erik Kaneda).
 
  - Address some issues related to the handling of device dependencies
    reported by _DEP in the ACPI device enumeration code and clean up
    some related pieces of it (Rafael Wysocki).
 
  - Improve the tracking of states of ACPI power resources (Rafael
    Wysocki).
 
  - Improve ACPI support for suspend-to-idle on AMD systems (Alex
    Deucher, Mario Limonciello, Pratik Vishwakarma).
 
  - Continue the unification and cleanup of message printing in the
    ACPI code (Hanjun Guo, Heiner Kallweit).
 
  - Fix possible buffer overrun issue with the description_show()
    sysfs attribute method (Krzysztof Wilczyński).
 
  - Improve the acpi_mask_gpe kernel command line parameter handling
    and clean up the core ACPI code related to sysfs (Andy Shevchenko,
    Baokun Li, Clayton Casciato).
 
  - Postpone bringing devices in the general ACPI PM domain to D0
    during resume from system-wide suspend until they are really
    needed (Dmitry Torokhov).
 
  - Make the ACPI processor driver fix up C-state latency if not
    ordered (Mario Limonciello).
 
  - Add support for identifying devices depening on the given one
    that are not its direct descendants with the help of _DEP (Daniel
    Scally).
 
  - Extend the checks related to ACPI IRQ overrides on x86 in order to
    avoid false-positives (Hui Wang).
 
  - Add battery DPTF participant for Intel SoCs (Sumeet Pawnikar).
 
  - Rearrange the ACPI fan driver and device power management code to
    use a common list of device IDs (Rafael Wysocki).
 
  - Fix clang CFI violation in the ACPI BGRT table parsing code and
    clean it up (Nathan Chancellor).
 
  - Add GPE-related quirks for some laptops to the EC driver (Chris
    Chiu, Zhang Rui).
 
  - Make the ACPI PPTT table parsing code populate the cache-id
    value if present in the firmware (James Morse).
 
  - Remove redundant clearing of context->ret.pointer from
    acpi_run_osc() (Hans de Goede).
 
  - Add missing acpi_put_table() in acpi_init_fpdt() (Jing Xiangfeng).
 
  - Make ACPI APEI handle ARM Processor Error CPER records like
    Memory Error ones to avoid user space task lockups (Xiaofei Tan).
 
  - Stop warning about disabled ACPI in APEI (Jon Hunter).
 
  - Fix fall-through warning for Clang in the SBSHC driver (Gustavo A.
    R. Silva).
 
  - Add custom DSDT file as Makefile prerequisite (Richard Fitzgerald).
 
  - Initialize local variable to avoid garbage being returned (Colin
    Ian King).
 
  - Simplify assorted pieces of code, address assorted coding style
    and documentation issues and comment typos (Baokun Li, Christophe
    JAILLET, Clayton Casciato, Liu Shixin, Shaokun Zhang, Wei Yongjun,
    Yang Li, Zhen Lei).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmDbajwSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxkCkQAKRZbSiyrCRLHCV81ZcxAWkluxfT8ljv
 B4C4kuKvYDvnEO2Bo40QByvQsgE176nexIxsO9BKEoSlrokX5tIBC1KbMmc7ZbtQ
 SFU6gCs+FgsVWQoD0PTJKIRaGFfLl8GRr45Bb+5Ta2DUYIkgMlV/8jf7WWqYLvw3
 QkCeU/7CiCUUPxE8i0dv5thEIsWLahkE/9FdCN9yVTxLX/9hqhepWdC62N6TYYy7
 Ai8Yt4BCLOSg1ZG8oqHo4I8bzuXgIb6zBFZJwNtP+ISh218RE/zl+0siCF/x5WQ0
 pUEDDiji7f6Puwk91IYn5ODlq8iTKO0mKJssIXFGn8lYyhZOdm9LpuTL0+x7zqrz
 Nt9Lw/85Ibf11XHetT5O0OrMygChtB2en1G593gI95TJeOfvJ+/374hhROGTd0bL
 rw0uOjc5g8MP2WQiGErNgyY0xAUkbKXSOXNOG0iTTKHKOGCBKhs5VWNL216j/wyD
 nsJoSyF//xJfvTd3CHp8m0LYe0PM06lWUTIfrVLxQYE2fU13hJcAzIt+6+1Pwmk7
 +gvGsVsf8kjjFAvHKT7EgM67JHecx6s6kh8MJ2DAqToAeuuCHFVHj8msIFBeZ28e
 vQ62CmdcXax3VNTYV6qC633ZwvaJ99QUX2x18hJpx8P2Z43rBgRBNZl/s/8/NIq4
 VVx6u54hGpWH
 =S//q
 -----END PGP SIGNATURE-----

Merge tag 'acpi-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These update the ACPICA code in the kernel to the 20210604 upstream
  revision, add preliminary support for the Platform Runtime Mechanism
  (PRM), address issues related to the handling of device dependencies
  in the ACPI device eunmeration code, improve the tracking of ACPI
  power resource states, improve the ACPI support for suspend-to-idle on
  AMD systems, continue the unification of message printing in the ACPI
  code, address assorted issues and clean up the code in a number of
  places.

  Specifics:

   - Update ACPICA code in the kernel to upstrea revision 20210604
     including the following changes:

      - Add defines for the CXL Host Bridge Structureand and add the
        CFMWS structure definition to CEDT (Alison Schofield).
      - iASL: Finish support for the IVRS ACPI table (Bob Moore).
      - iASL: Add support for the SVKL table (Bob Moore).
      - iASL: Add full support for RGRT ACPI table (Bob Moore).
      - iASL: Add support for the BDAT ACPI table (Bob Moore).
      - iASL: add disassembler support for PRMT (Erik Kaneda).
      - Fix memory leak caused by _CID repair function (Erik Kaneda).
      - Add support for PlatformRtMechanism OpRegion (Erik Kaneda).
      - Add PRMT module header to facilitate parsing (Erik Kaneda).
      - Add _PLD panel positions (Fabian Wüthrich).
      - MADT: add Multiprocessor Wakeup Mailbox Structure and the SVKL
        table headers (Kuppuswamy Sathyanarayanan).
      - Use ACPI_FALLTHROUGH (Wei Ming Chen).

   - Add preliminary support for the Platform Runtime Mechanism (PRM) to
     allow the AML interpreter to call PRM functions (Erik Kaneda).

   - Address some issues related to the handling of device dependencies
     reported by _DEP in the ACPI device enumeration code and clean up
     some related pieces of it (Rafael Wysocki).

   - Improve the tracking of states of ACPI power resources (Rafael
     Wysocki).

   - Improve ACPI support for suspend-to-idle on AMD systems (Alex
     Deucher, Mario Limonciello, Pratik Vishwakarma).

   - Continue the unification and cleanup of message printing in the
     ACPI code (Hanjun Guo, Heiner Kallweit).

   - Fix possible buffer overrun issue with the description_show() sysfs
     attribute method (Krzysztof Wilczyński).

   - Improve the acpi_mask_gpe kernel command line parameter handling
     and clean up the core ACPI code related to sysfs (Andy Shevchenko,
     Baokun Li, Clayton Casciato).

   - Postpone bringing devices in the general ACPI PM domain to D0
     during resume from system-wide suspend until they are really needed
     (Dmitry Torokhov).

   - Make the ACPI processor driver fix up C-state latency if not
     ordered (Mario Limonciello).

   - Add support for identifying devices depening on the given one that
     are not its direct descendants with the help of _DEP (Daniel
     Scally).

   - Extend the checks related to ACPI IRQ overrides on x86 in order to
     avoid false-positives (Hui Wang).

   - Add battery DPTF participant for Intel SoCs (Sumeet Pawnikar).

   - Rearrange the ACPI fan driver and device power management code to
     use a common list of device IDs (Rafael Wysocki).

   - Fix clang CFI violation in the ACPI BGRT table parsing code and
     clean it up (Nathan Chancellor).

   - Add GPE-related quirks for some laptops to the EC driver (Chris
     Chiu, Zhang Rui).

   - Make the ACPI PPTT table parsing code populate the cache-id value
     if present in the firmware (James Morse).

   - Remove redundant clearing of context->ret.pointer from
     acpi_run_osc() (Hans de Goede).

   - Add missing acpi_put_table() in acpi_init_fpdt() (Jing Xiangfeng).

   - Make ACPI APEI handle ARM Processor Error CPER records like Memory
     Error ones to avoid user space task lockups (Xiaofei Tan).

   - Stop warning about disabled ACPI in APEI (Jon Hunter).

   - Fix fall-through warning for Clang in the SBSHC driver (Gustavo A.
     R. Silva).

   - Add custom DSDT file as Makefile prerequisite (Richard Fitzgerald).

   - Initialize local variable to avoid garbage being returned (Colin
     Ian King).

   - Simplify assorted pieces of code, address assorted coding style and
     documentation issues and comment typos (Baokun Li, Christophe
     JAILLET, Clayton Casciato, Liu Shixin, Shaokun Zhang, Wei Yongjun,
     Yang Li, Zhen Lei)"

* tag 'acpi-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (97 commits)
  ACPI: PM: postpone bringing devices to D0 unless we need them
  ACPI: tables: Add custom DSDT file as makefile prerequisite
  ACPI: bgrt: Use sysfs_emit
  ACPI: bgrt: Fix CFI violation
  ACPI: EC: trust DSDT GPE for certain HP laptop
  ACPI: scan: Simplify acpi_table_events_fn()
  ACPI: PM: Adjust behavior for field problems on AMD systems
  ACPI: PM: s2idle: Add support for new Microsoft UUID
  ACPI: PM: s2idle: Add support for multiple func mask
  ACPI: PM: s2idle: Refactor common code
  ACPI: PM: s2idle: Use correct revision id
  ACPI: sysfs: Remove tailing return statement in void function
  ACPI: sysfs: Use __ATTR_RO() and __ATTR_RW() macros
  ACPI: sysfs: Sort headers alphabetically
  ACPI: sysfs: Refactor param_get_trace_state() to drop dead code
  ACPI: sysfs: Unify pattern of memory allocations
  ACPI: sysfs: Allow bitmap list to be supplied to acpi_mask_gpe
  ACPI: sysfs: Make sparse happy about address space in use
  ACPI: scan: Fix race related to dropping dependencies
  ACPI: scan: Reorganize acpi_device_add()
  ...
2021-06-29 13:39:41 -07:00
Rafael J. Wysocki dfef7710d7 Merge branches 'acpi-bus', 'acpi-scan' and 'acpi-tables'
* acpi-bus:
  ACPI: Remove redundant clearing of context->ret.pointer from acpi_run_osc()

* acpi-scan:
  ACPI: scan: Simplify acpi_table_events_fn()
  ACPI: scan: Fix race related to dropping dependencies
  ACPI: scan: Reorganize acpi_device_add()
  ACPI: scan: Fix device object rescan in acpi_scan_clear_dep()
  ACPI: scan: Make acpi_walk_dep_device_list()
  ACPI: scan: Rearrange acpi_dev_get_first_consumer_dev_cb()
  ACPI: scan: Define acpi_bus_put_acpi_device() as static inline
  ACPI: scan: initialize local variable to avoid garbage being returned
  ACPI: scan: Add function to fetch dependent of ACPI device
  ACPI: scan: Extend acpi_walk_dep_device_list()
  ACPI: scan: Rearrange dep_unmet initialization

* acpi-tables:
  ACPI: tables: Add custom DSDT file as makefile prerequisite
  ACPI: bgrt: Use sysfs_emit
  ACPI: bgrt: Fix CFI violation
  ACPI: tables: FPDT: Add missing acpi_put_table() in acpi_init_fpdt()
  ACPI: tables: PPTT: Populate cache-id if provided by firmware
2021-06-29 15:46:52 +02:00
Quan Nguyen 87cf512796 i2c: core-smbus: Expose PEC calculate function for generic use
Expose the PEC calculation i2c_smbus_pec() for generic use.

Signed-off-by: Quan Nguyen <quan@os.amperecomputing.com>
Acked-by: Matt Johnston <matt@codeconstruct.com.au>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-25 17:09:34 +02:00
Johan Hovold 4ca070ef0d i2c: robotfuzz-osif: fix control-request directions
The direction of the pipe argument must match the request-type direction
bit or control requests may fail depending on the host-controller-driver
implementation.

Control transfers without a data stage are treated as OUT requests by
the USB stack and should be using usb_sndctrlpipe(). Failing to do so
will now trigger a warning.

Fix the OSIFI2C_SET_BIT_RATE and OSIFI2C_STOP requests which erroneously
used the osif_usb_read() helper and set the IN direction bit.

Reported-by: syzbot+9d7dadd15b8819d73f41@syzkaller.appspotmail.com
Fixes: 83e53a8f12 ("i2c: Add bus driver for for OSIF USB i2c device.")
Cc: stable@vger.kernel.org      # 3.14
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-24 22:08:00 +02:00
Dmitry Torokhov b64210f2f7 i2c: core: Disable client irq on reboot/shutdown
If an i2c client receives an interrupt during reboot or shutdown it may
be too late to service it by making an i2c transaction on the bus
because the i2c controller has already been shutdown. This can lead to
system hangs if the i2c controller tries to make a transfer that is
doomed to fail because the access to the i2c pins is already shut down,
or an iommu translation has been torn down so i2c controller register
access doesn't work.

Let's simply disable the irq if there isn't a shutdown callback for an
i2c client when there is an irq associated with the device. This will
make sure that irqs don't come in later than the time that we can handle
it. We don't do this if the i2c client device already has a shutdown
callback because presumably they're doing the right thing and quieting
the device so irqs don't come in after the shutdown callback returns.

Reported-by: kernel test robot <lkp@intel.com>
[swboyd@chromium.org: Dropped newline, added commit text, added
interrupt.h for robot build error]
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-24 22:03:55 +02:00
Kwon Tae-young 2f799b25db i2c: imx: Fix some checkpatch warnings
Fix the following warnings reported by checkpatch::
drivers/i2c/busses/i2c-imx.c:173: WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
drivers/i2c/busses/i2c-imx.c:175: WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
drivers/i2c/busses/i2c-imx.c:176: WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
drivers/i2c/busses/i2c-imx.c:177: WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
drivers/i2c/busses/i2c-imx.c:455: WARNING: Unnecessary ftrace-like logging - prefer using ftrace
drivers/i2c/busses/i2c-imx.c:602: WARNING: Unnecessary ftrace-like logging - prefer using ftrace
drivers/i2c/busses/i2c-imx.c:638: WARNING: Unnecessary ftrace-like logging - prefer using ftrace
drivers/i2c/busses/i2c-imx.c:1170: WARNING: Unnecessary ftrace-like logging - prefer using ftrace
drivers/i2c/busses/i2c-imx.c:1374: WARNING: Unnecessary ftrace-like logging - prefer using ftrace
drivers/i2c/busses/i2c-imx.c:1398: WARNING: Prefer strscpy over strlcpy - see: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/

Signed-off-by: Kwon Tae-young <tykwon@m2i.co.kr>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-24 21:58:35 +02:00
Andreas Hecht 3265a7e6b4 i2c: dev: Add __user annotation
Fix Sparse warnings:
drivers/i2c/i2c-dev.c:546:19: warning: incorrect type in assignment (different address spaces)
drivers/i2c/i2c-dev.c:549:53: warning: incorrect type in argument 2 (different address spaces)

compat_ptr() returns a pointer tagged __user which gets assigned to a
pointer missing the __user annotation. The same pointer is passed to
copy_from_user() as an argument where it is expected to have the __user
annotation. Fix both by adding the __user annotation to the pointer.

Fixes: 7d5cb45655 ("i2c compat ioctls: move to ->compat_ioctl()")
Signed-off-by: Andreas Hecht <andreas.e.hecht@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-24 21:47:43 +02:00
Krzysztof Kozlowski cc883cdf68 i2c: davinci: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and the error value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-23 18:23:55 +02:00
Krzysztof Kozlowski 2d1a83a4f3 i2c: cadence: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and the error value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-23 18:22:28 +02:00
Krzysztof Kozlowski 9dbba3f87c i2c: xiic: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and the error value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-23 18:22:17 +02:00
Raviteja Narayanam dd66b39f60 i2c: cadence: Clear HOLD bit before xfer_size register rolls over
On Xilinx zynq SOC if the delay between address register write and
control register write in cdns_mrecv function is more, the xfer size
register rolls over and controller is stuck. This is an IP bug and
is resolved in later versions of IP.

To avoid this scenario, disable the interrupts on the current processor
core between the two register writes and enable them later. This can
help achieve the timing constraint.

Signed-off-by: Raviteja Narayanam <raviteja.narayanam@xilinx.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-23 18:17:08 +02:00
Dan Carpenter 2269583753 i2c: cp2615: check for allocation failure in cp2615_i2c_recv()
We need to add a check for if the kzalloc() fails.

Fixes: 4a7695429e ("i2c: cp2615: add i2c driver for Silicon Labs' CP2615 Digital Audio Bridge")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Bence Csókás <bence98@sch.bme.hu>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-20 23:13:34 +02:00
Heiner Kallweit 065b6211a8 i2c: i801: Ensure that SMBHSTSTS_INUSE_STS is cleared when leaving i801_access
As explained in [0] currently we may leave SMBHSTSTS_INUSE_STS set,
thus potentially breaking ACPI/BIOS usage of the SMBUS device.

Seems patch [0] needs a little bit more of review effort, therefore
I'd suggest to apply a part of it as quick win. Just clearing
SMBHSTSTS_INUSE_STS when leaving i801_access() should fix the
referenced issue and leaves more time for discussing a more
sophisticated locking handling.

[0] https://www.spinics.net/lists/linux-i2c/msg51558.html

Fixes: 01590f361e ("i2c: i801: Instantiate SPD EEPROMs automatically")
Suggested-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Hector Martin <marcan@marcan.st>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-20 22:58:58 +02:00
Heiner Kallweit c601610cd7 i2c: i801: Improve i801_setup_hstcfg
i801_setup_hstcfg() leaves the bits in priv->original_hstcfg that
we're interested in intact. Therefore we can remove the return value
from the function and use priv->original_hstcfg directly.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-20 22:56:21 +02:00
Heiner Kallweit d4a994f69f i2c: i801: Use driver name constant instead of function dev_driver_string
We are the driver, so we can use the driver name directly instead of
retrieving it by calling dev_driver_string().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-20 22:55:24 +02:00
Heiner Kallweit 8d83973e7a i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves
Why shall we bother to open-code something that the compiler can do for us.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-20 22:54:24 +02:00
Heiner Kallweit 44c54c4ec3 i2c: i801: Improve status polling
Polling uses the same timeout as irq mode: 400 * 500us = 200ms = HZ / 5.
So let's use the adapter->timeout value also for polling. This has the
advantage that userspace can control the timeout value for polling as
well. In addition change the code to make it better readable.
Last but not least remove the timeout debug messages. Calls to both
functions are followed by a call to i801_check_post() that will print
an error message in case of timeout.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-20 22:51:26 +02:00
Andy Shevchenko e11654ec22 i2c: cht-wc: Replace of_node by NULL
The driver is run on the platforms where OF node is always NULL.
The confusion comes from IRQ domain APIs that take either OF or
firmware node as input parameter. Since fwnode is not used here
either, replace of_node by NULL.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-20 22:47:24 +02:00
Biju Das 010e765b40 i2c: riic: Add RZ/G2L support
RZ/G2L i2c controller is compatible with RZ/A i2c controller.
By default IP is in reset state, so need to perform release
reset before accessing any register.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-20 22:40:44 +02:00
Daniel Scally a9e10e5873 ACPI: scan: Extend acpi_walk_dep_device_list()
The acpi_walk_dep_device_list() function is not as generic as its
name implies, serving only to decrement the dependency count for each
dependent device of the input.

Extend it to accept a callback which can be applied to all the
dependencies in acpi_dep_list.

Replace all existing calls to the function with calls to a wrapper,
passing a callback that applies the same dependency reduction.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Maximilian Luz <luzmaximilian@gmail.com>  # for platform/surface parts
Signed-off-by: Daniel Scally <djrscally@gmail.com>
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-06-07 16:45:05 +02:00
Roja Rani Yarubandi 57648e8604 i2c: qcom-geni: Suspend and resume the bus during SYSTEM_SLEEP_PM ops
Mark bus as suspended during system suspend to block the future
transfers. Implement geni_i2c_resume_noirq() to resume the bus.

Fixes: 37692de5d5 ("i2c: i2c-qcom-geni: Add bus driver for the Qualcomm GENI I2C controller")
Signed-off-by: Roja Rani Yarubandi <rojay@codeaurora.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-04 22:32:58 +02:00
Roja Rani Yarubandi 9f78c60760 i2c: qcom-geni: Add shutdown callback for i2c
If the hardware is still accessing memory after SMMU translation
is disabled (as part of smmu shutdown callback), then the
IOVAs (I/O virtual address) which it was using will go on the bus
as the physical addresses which will result in unknown crashes
like NoC/interconnect errors.

So, implement shutdown callback for i2c driver to suspend the bus
during system "reboot" or "shutdown".

Fixes: 37692de5d5 ("i2c: i2c-qcom-geni: Add bus driver for the Qualcomm GENI I2C controller")
Signed-off-by: Roja Rani Yarubandi <rojay@codeaurora.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-04 22:32:39 +02:00
Lee Jones de2646f34a i2c: tegra-bpmp: Demote kernel-doc abuses
Fixes the following W=1 kernel build warning(s):

 drivers/i2c/busses/i2c-tegra-bpmp.c:86: warning: Function parameter or member 'i2c' not described in 'tegra_bpmp_serialize_i2c_msg'
 drivers/i2c/busses/i2c-tegra-bpmp.c:86: warning: Function parameter or member 'request' not described in 'tegra_bpmp_serialize_i2c_msg'
 drivers/i2c/busses/i2c-tegra-bpmp.c:86: warning: Function parameter or member 'msgs' not described in 'tegra_bpmp_serialize_i2c_msg'
 drivers/i2c/busses/i2c-tegra-bpmp.c:86: warning: Function parameter or member 'num' not described in 'tegra_bpmp_serialize_i2c_msg'
 drivers/i2c/busses/i2c-tegra-bpmp.c:86: warning: expecting prototype for The serialized I2C format is simply the following(). Prototype was for tegra_bpmp_serialize_i2c_msg() instead
 drivers/i2c/busses/i2c-tegra-bpmp.c:130: warning: Function parameter or member 'i2c' not described in 'tegra_bpmp_i2c_deserialize'
 drivers/i2c/busses/i2c-tegra-bpmp.c:130: warning: Function parameter or member 'response' not described in 'tegra_bpmp_i2c_deserialize'
 drivers/i2c/busses/i2c-tegra-bpmp.c:130: warning: Function parameter or member 'msgs' not described in 'tegra_bpmp_i2c_deserialize'
 drivers/i2c/busses/i2c-tegra-bpmp.c:130: warning: Function parameter or member 'num' not described in 'tegra_bpmp_i2c_deserialize'
 drivers/i2c/busses/i2c-tegra-bpmp.c:130: warning: expecting prototype for The data in the BPMP(). Prototype was for tegra_bpmp_i2c_deserialize() instead

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-03 22:31:42 +02:00
Lee Jones a4931dcab1 i2c: altera: Fix formatting issue in struct and demote unworthy kernel-doc headers
Fixes the following W=1 kernel build warning(s):

 drivers/i2c/busses/i2c-altera.c:74: warning: cannot understand function prototype: 'struct altr_i2c_dev '
 drivers/i2c/busses/i2c-altera.c:180: warning: Function parameter or member 'idev' not described in 'altr_i2c_transfer'
 drivers/i2c/busses/i2c-altera.c:180: warning: Function parameter or member 'data' not described in 'altr_i2c_transfer'
 drivers/i2c/busses/i2c-altera.c:193: warning: Function parameter or member 'idev' not described in 'altr_i2c_empty_rx_fifo'
 drivers/i2c/busses/i2c-altera.c:209: warning: Function parameter or member 'idev' not described in 'altr_i2c_fill_tx_fifo'

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-06-03 22:25:24 +02:00
Hsin-Yi Wang 9029b9b2ae i2c: mediatek: mt65xx: add optional vbus-supply
Add vbus-supply which provides power to SCL/SDA. Pass this regulator
into core so it can be turned on/off for low power mode support.

Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Reviewed-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-05-28 21:06:38 +02:00
Bibby Hsieh 5a7b95fb99 i2c: core: support bus regulator controlling in adapter
Although in the most platforms, the bus power of i2c
are alway on, some platforms disable the i2c bus power
in order to meet low power request.

We can control bulk regulator if it is provided in i2c
adapter device.

Signed-off-by: Bibby Hsieh <bibby.hsieh@mediatek.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-05-28 20:50:01 +02:00
Andy Shevchenko cb3c66af95 i2c: core: Make debug message even more debuggish
One may notice that dev_printk(KERN_DEBUG ...) is *not* an equivalent
to dev_dbg(). It will be printed whenever loglevel is high enough.
And currently it will be the only message in the I²C core in some
configurations that got printed under above conditions.

Moving to dev_dbg() will hide it in the configurations where Dynamic Debug
is enabled and hence align with all other debug messages in the I²C core..

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-05-28 16:01:49 +02:00
Krzysztof Kozlowski 2499042326 i2c: s3c2410: fix possible NULL pointer deref on read message after write
Interrupt handler processes multiple message write requests one after
another, till the driver message queue is drained.  However if driver
encounters a read message without preceding START, it stops the I2C
transfer as it is an invalid condition for the controller.  At least the
comment describes a requirement "the controller forces us to send a new
START when we change direction".  This stop results in clearing the
message queue (i2c->msg = NULL).

The code however immediately jumped back to label "retry_write" which
dereferenced the "i2c->msg" making it a possible NULL pointer
dereference.

The Coverity analysis:
1. Condition !is_msgend(i2c), taking false branch.
   if (!is_msgend(i2c)) {

2. Condition !is_lastmsg(i2c), taking true branch.
   } else if (!is_lastmsg(i2c)) {

3. Condition i2c->msg->flags & 1, taking true branch.
   if (i2c->msg->flags & I2C_M_RD) {

4. write_zero_model: Passing i2c to s3c24xx_i2c_stop, which sets i2c->msg to NULL.
   s3c24xx_i2c_stop(i2c, -EINVAL);

5. Jumping to label retry_write.
   goto retry_write;

6. var_deref_model: Passing i2c to is_msgend, which dereferences null i2c->msg.
   if (!is_msgend(i2c)) {"

All previous calls to s3c24xx_i2c_stop() in this interrupt service
routine are followed by jumping to end of function (acknowledging
the interrupt and returning).  This seems a reasonable choice also here
since message buffer was entirely emptied.

Addresses-Coverity: Explicit null dereferenced
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-05-28 10:16:23 +02:00
Qii Wang fed1bd51a5 i2c: mediatek: Disable i2c start_en and clear intr_stat brfore reset
The i2c controller driver do dma reset after transfer timeout,
but sometimes dma reset will trigger an unexpected DMA_ERR irq.
It will cause the i2c controller to continuously send interrupts
to the system and cause soft lock-up. So we need to disable i2c
start_en and clear intr_stat to stop i2c controller before dma
reset when transfer timeout.

Fixes: aafced673c06("i2c: mediatek: move dma reset before i2c reset")
Signed-off-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-05-28 10:13:07 +02:00
Geert Uytterhoeven 7475d2fbca i2c: rcar: Drop "renesas,i2c-rcar"
The compatible value "renesas,i2c-rcar" was deprecated in commit
ad4a8dc3fe ("i2c: rcar: Add per-Generation fallback bindings"),
and never had any users in upstream Linux.  Drop its match entry from
the driver.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-05-28 09:50:43 +02:00
Qii Wang 7fb9dc8109 i2c: mediatek: Rename i2c irq name
Rename i2c irq name with dev_name() which can provide unique
naming in /proc/interrupts for each instance of the I2C IP core.

Signed-off-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-05-27 22:12:46 +02:00
Heiner Kallweit 0d3f1e4524 i2c: i801: Use standard PCI constants instead of own ones
Layout of these registers is part of the PCI standard. Therefore use
the constants defined by the PCI subsystem.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2021-05-27 22:10:21 +02:00