platform/kernel/linux-starfive.git
4 years agodt-bindings: i2c: npcm7xx: add NPCM I2C controller
Tali Perry [Wed, 27 May 2020 20:08:18 +0000 (23:08 +0300)]
dt-bindings: i2c: npcm7xx: add NPCM I2C controller

Added device tree binding documentation for Nuvoton BMC
NPCM I2C controller.

Signed-off-by: Tali Perry <tali.perry1@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: don't error out if there's no pinctrl
Lubomir Rintel [Tue, 2 Jun 2020 19:38:23 +0000 (21:38 +0200)]
i2c: pxa: don't error out if there's no pinctrl

The bus recovery patch regresses on OLPC XO-1.75 that has no pinctrl in
its DT.

Fixes: 7c9ec2c52518 ("i2c: pxa: implement generic i2c bus recovery")'
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: add 'single-master' property to generic bindings
Wolfram Sang [Wed, 27 May 2020 11:30:39 +0000 (13:30 +0200)]
i2c: add 'single-master' property to generic bindings

It is useful to know if we are the only master on a given bus. Because
this is a HW description of the bus, add it to the generic bindings.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Add Baikal-T1 System I2C support
Serge Semin [Thu, 28 May 2020 09:33:21 +0000 (12:33 +0300)]
i2c: designware: Add Baikal-T1 System I2C support

Baikal-T1 System Controller is equipped with a dedicated I2C Controller
which functionality is based on the DW APB I2C IP-core, the only
difference in a way it' registers are accessed. There are three access
register provided in the System Controller registers map, which indirectly
address the normal DW APB I2C registers space. So in order to have the
Baikal-T1 System I2C Controller supported by the common DW APB I2C driver
we created a dedicated Dw I2C controller model quirk, which retrieves the
syscon regmap from the parental dt node and creates a new regmap based on
it.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Move reg-space remapping into a dedicated function
Serge Semin [Thu, 28 May 2020 09:33:20 +0000 (12:33 +0300)]
i2c: designware: Move reg-space remapping into a dedicated function

This is a preparation patch before adding a quirk with custom registers
map creation required for the Baikal-T1 System I2C support.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Retrieve quirk flags as early as possible
Serge Semin [Thu, 28 May 2020 09:33:19 +0000 (12:33 +0300)]
i2c: designware: Retrieve quirk flags as early as possible

Some platforms might need to activate the driver quirks at a very early
probe stage. For instance, Baikal-T1 System I2C doesn't need to map the
registers space as ones belong to the system controller. Instead it will
request the syscon regmap from the parental DT node. In order to be able
to do so let's retrieve the model flags right after the DW I2C private
data is created. While at it replace the or-assignment with just
assignment operator since or-ing is redundant at this stage.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Convert driver to using regmap API
Serge Semin [Thu, 28 May 2020 09:33:18 +0000 (12:33 +0300)]
i2c: designware: Convert driver to using regmap API

Seeing the DW I2C driver is using flags-based accessors with two
conditional clauses it would be better to replace them with the regmap
API IO methods and to initialize the regmap object with read/write
callbacks specific to the controller registers map implementation. This
will be also handy for the drivers with non-standard registers mapping
(like an embedded into the Baikal-T1 System Controller DW I2C block, which
glue-driver is a part of this series).

As before the driver tries to detect the mapping setup at probe stage and
creates a regmap object accordingly, which will be used by the rest of the
code to correctly access the controller registers. In two places it was
appropriate to convert the hand-written read-modify-write and
read-poll-loop design patterns to the corresponding regmap API
ready-to-use methods.

Note the regmap IO methods return value is checked only at the probe
stage. The rest of the code won't do this because basically we have
MMIO-based regmap so non of the read/write methods can fail (this also
won't be needed for the Baikal-T1-specific I2C controller).

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
[wsa: fix type of 'rx_valid' and remove outdated kdoc var description]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Discard Cherry Trail model flag
Serge Semin [Thu, 28 May 2020 09:33:17 +0000 (12:33 +0300)]
i2c: designware: Discard Cherry Trail model flag

A PM workaround activated by the flag MODEL_CHERRYTRAIL has been removed
since commit 9cbeeca05049 ("i2c: designware: Remove Cherry Trail PMIC I2C
bus pm_disabled workaround"), but the flag most likely by mistake has been
left in the Dw I2C drivers. Let's remove it. Since MODEL_MSCC_OCELOT is
the only model-flag left, redefine it to be 0x100 so setting a very first
bit in the MODEL_MASK bits range.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
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>
4 years agoi2c: designware: Add Baytrail sem config DW I2C platform dependency
Serge Semin [Thu, 28 May 2020 09:33:16 +0000 (12:33 +0300)]
i2c: designware: Add Baytrail sem config DW I2C platform dependency

Currently Intel Baytrail I2C semaphore is a feature of the DW APB I2C
platform driver. It's a bit confusing to see it's config in the menu at
some separated place with no reference to the platform code. Let's move the
config definition to be below the I2C_DESIGNWARE_PLATFORM config and mark
it with "depends on I2C_DESIGNWARE_PLATFORM" statement. By doing so the
config menu will display the feature right below the DW I2C platform
driver item and will indent it to the right so signifying its belonging.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: slave: Set DW I2C core module dependency
Serge Semin [Thu, 28 May 2020 09:33:15 +0000 (12:33 +0300)]
i2c: designware: slave: Set DW I2C core module dependency

DW APB I2C slave code in fact depends on the DW I2C driver core, but not
on the platform code as it used to be before commit 90bc1ee6de9f ("i2c:
designware: Allow slave mode for PCI enumerated devices"). Yes, the I2C
slave interface is currently supported by both the platform and PCI
versions of the IP core, but it still depends on the DW I2C core
functionality and must be available only if the last one is enabled.
So make sure the DW APB I2C slave config is only available if the
I2C_DESIGNWARE_CORE config is enabled.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Use `-y` to build multi-object modules
Serge Semin [Thu, 28 May 2020 09:33:14 +0000 (12:33 +0300)]
i2c: designware: Use `-y` to build multi-object modules

Since commit 4f8272802739 ("Documentation: update kbuild loadable modules
goals & examples") `-objs` is fitted for building host programs, lets
change DW I2C core, platform and PCI driver kbuild directives to using
`-y`, which more straightforward for device drivers. By doing so we can
discard the ifeq construction in favor to the more natural and less bulky
`<module>-$(CONFIG_X) += x.o`

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agodt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
Serge Semin [Thu, 28 May 2020 09:33:13 +0000 (12:33 +0300)]
dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller

Add the "baikal,bt1-sys-i2c" compatible string to the DW I2C binding. Even
though the corresponding node is supposed to be a child of the Baikal-T1
System Controller, its reg property is left required for compatibility.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agodt-bindings: i2c: Convert DW I2C slave to the DW I2C master example
Serge Semin [Thu, 28 May 2020 09:33:12 +0000 (12:33 +0300)]
dt-bindings: i2c: Convert DW I2C slave to the DW I2C master example

dtc currently doesn't support I2C_OWN_SLAVE_ADDRESS flag set in the
i2c "reg" property. If dtc finds an i2c-slave sub-node having an address
higher than ten-bits wide it'll print an ugly warning:

Warning (i2c_bus_reg): /example-2/i2c@1120000/eeprom@64: I2C bus unit address format error, expected "40000064"
Warning (i2c_bus_reg): /example-2/i2c@1120000/eeprom@64:reg: I2C address must be less than 10-bits, got "0x40000064"

In order to silence dtc up let's replace the corresponding DT binding
example with a normal DW I2C master mode-based one. It's done by clearing
the I2C_OWN_SLAVE_ADDRESS bit in the reg property and converting the
sub-node to be compatible with normal EEPROM like "atmel,24c02".

Just revert this commit when dtc is fixed.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agodt-bindings: i2c: Convert DW I2C binding to DT schema
Serge Semin [Thu, 28 May 2020 09:33:11 +0000 (12:33 +0300)]
dt-bindings: i2c: Convert DW I2C binding to DT schema

Modern device tree bindings are supposed to be created as YAML-files
in accordance with dt-schema. This commit replaces Synopsys DW I2C
legacy bare text bindings with YAML file. As before the bindings file
states that the corresponding dts node is supposed to be compatible
either with generic DW I2C controller or with Microsemi Ocelot SoC I2C
one, to have registers, interrupts and clocks properties. In addition
the node may have clock-frequency, i2c-sda-hold-time-ns,
i2c-scl-falling-time-ns and i2c-sda-falling-time-ns optional properties.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: sh_mobile: simplify code and remove false compilation warning
Viresh Kumar [Thu, 9 May 2019 04:43:46 +0000 (10:13 +0530)]
i2c: sh_mobile: simplify code and remove false compilation warning

This currently generates a warning:

drivers/i2c/busses/i2c-sh_mobile.c: In function 'sh_mobile_i2c_isr':
drivers/i2c/busses/i2c-sh_mobile.c:399:26: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]

Though the code looks okay and shouldn't ever use the variable
uninitialized. Fix the warning by moving the code around and getting rid
of 'data'.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
[wsa: minor updates to commit message]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: i801: Instantiate SPD EEPROMs automatically
Jean Delvare [Mon, 16 Mar 2020 10:24:48 +0000 (11:24 +0100)]
i2c: i801: Instantiate SPD EEPROMs automatically

Call the function to instantiate SPD EEPROMs automatically on the
main SMBus controller.

Multiplexed SMBus systems are excluded for now as they are more
complex to handle.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: smbus: Add a way to instantiate SPD EEPROMs automatically
Jean Delvare [Mon, 16 Mar 2020 10:22:24 +0000 (11:22 +0100)]
i2c: smbus: Add a way to instantiate SPD EEPROMs automatically

In simple cases we can instantiate SPD EEPROMs on the SMBus
automatically. Start with just DDR2, DDR3 and DDR4 on x86 for now,
and only for systems with no more than 4 memory slots. These
limitations may be lifted later.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
[wsa: minor change for new API]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: avoid confusing naming in header
Wolfram Sang [Mon, 25 May 2020 12:05:04 +0000 (14:05 +0200)]
i2c: avoid confusing naming in header

i2c_client pointers are usually named 'client'. Use it here to get rid
of the ambiguity of 'dev->dev'.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: slave-eeprom: update documentation to recent changes
Wolfram Sang [Mon, 25 May 2020 09:59:34 +0000 (11:59 +0200)]
i2c: slave-eeprom: update documentation to recent changes

Support for 16-bit addresses has been added, so remove it from the todo
list. Also, in the introductory sentence, may clear we talk about "slave
IP cores" to make reading easier.

Fixes: 82d514815441 ("i2c-eeprom_slave: Add support for more eeprom models")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: slave-eeprom: skip useless initialization
Wolfram Sang [Mon, 25 May 2020 09:59:33 +0000 (11:59 +0200)]
i2c: slave-eeprom: skip useless initialization

We have a kzalloced struct, no need to init to 0.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: acpi: Drop double check for ACPI companion device
Andy Shevchenko [Thu, 28 May 2020 14:18:58 +0000 (17:18 +0300)]
i2c: acpi: Drop double check for ACPI companion device

acpi_dev_get_resources() does perform the NULL pointer check against
ACPI companion device which is given as function parameter. Thus,
there is no need to duplicate this check in the caller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: nvidia-gpu: Use PTR_ERR_OR_ZERO() to simplify code
Aishwarya Ramakrishnan [Tue, 5 May 2020 14:52:30 +0000 (20:22 +0530)]
i2c: nvidia-gpu: Use PTR_ERR_OR_ZERO() to simplify code

PTR_ERR_OR_ZERO contains if(IS_ERR(...)) + PTR_ERR.

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

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Reviewed-by: Ajay Gupta <ajayg@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: save a variable in i2c_detect()
Wolfram Sang [Tue, 19 May 2020 11:48:09 +0000 (13:48 +0200)]
i2c: save a variable in i2c_detect()

No need to populate a variable if it is used only in debug output which
may get compiled away anyhow.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: efm32: Avoid unnecessary check in efm32_i2c_probe()
Tang Bin [Wed, 15 Apr 2020 14:06:40 +0000 (22:06 +0800)]
i2c: efm32: Avoid unnecessary check in efm32_i2c_probe()

The function efm32_i2c_probe() is only called with an
openfirmware platform device.Therefore there is no need
to check that it has an openfirmware node.

Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: efm32: Omit superfluous error message in efm32_i2c_probe()
Tang Bin [Wed, 15 Apr 2020 13:57:34 +0000 (21:57 +0800)]
i2c: efm32: Omit superfluous error message in efm32_i2c_probe()

In the function efm32_i2c_probe(),when get irq failed,the function
platform_get_irq() logs an error message,so remove redundant message
here.

Signed-off-by: Shengju Zhang <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoRevert "dt-binding: i2c: add bus-supply property"
Wolfram Sang [Fri, 22 May 2020 14:57:59 +0000 (16:57 +0200)]
Revert "dt-binding: i2c: add bus-supply property"

This reverts commit 6aab46bc52a8f579879d491c9d8062e03caa5c61. Testing in
linux-next showed it needs some more time.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoRevert "i2c: core: support bus regulator controlling in adapter"
Wolfram Sang [Fri, 22 May 2020 14:56:58 +0000 (16:56 +0200)]
Revert "i2c: core: support bus regulator controlling in adapter"

This reverts commit 6fe12cdbcfe35ad4726a619a9546822d34fc934c. Testing in
linux-next showed it needs some more time.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Drop hard coded FIFO depth assignment
Andy Shevchenko [Tue, 19 May 2020 12:50:43 +0000 (15:50 +0300)]
i2c: designware: Drop hard coded FIFO depth assignment

It's not clear why the commit fe20ff5c7e9c
  ("i2c-designware: Add support for Designware core behind PCI devices.")
followed by commit b61b14154b19
  ("i2c-designware: add support for Intel Lynxpoint")
chose to hard code FIFO depth size. The FIFO depth on all hardware,
I have tested on, can be nicely detected automatically.

Thus, we may safely drop hard coded FIFO sizes from the driver.

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>
4 years agoi2c: designware: Read counters from ACPI for PCI driver
Andy Shevchenko [Tue, 19 May 2020 12:50:42 +0000 (15:50 +0300)]
i2c: designware: Read counters from ACPI for PCI driver

PCI devices may have been backed with ACPI handle which supplies
an additional information to the drivers, such as counters.

Call for ACPI configuration from PCI driver in order to utilize counters
provided by ACPI.

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>
4 years agoi2c: designware: Move ACPI parts into common module
Andy Shevchenko [Tue, 19 May 2020 12:50:41 +0000 (15:50 +0300)]
i2c: designware: Move ACPI parts into common module

For possible code reuse in the future, move ACPI parts into common module.

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>
4 years agoi2c: designware: Drop unneeded condition in i2c_dw_validate_speed()
Andy Shevchenko [Tue, 19 May 2020 12:50:40 +0000 (15:50 +0300)]
i2c: designware: Drop unneeded condition in i2c_dw_validate_speed()

We may bailout directly from the loop instead of breaking it and
testing a loop counter. This also gives advantages such as decreased
indentation level along with dropped unneeded condition.

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>
4 years agoi2c: designware: Move i2c_dw_validate_speed() helper to a common code
Andy Shevchenko [Tue, 19 May 2020 12:50:39 +0000 (15:50 +0300)]
i2c: designware: Move i2c_dw_validate_speed() helper to a common code

In order to export array supported speed for wider use, move it
to a header along with i2c_dw_validate_speed() helper moved to
a common code.

No functional changes intended.

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>
4 years agoi2c: designware: Include proper headers in i2c-desingware-core.h
Andy Shevchenko [Tue, 19 May 2020 12:50:38 +0000 (15:50 +0300)]
i2c: designware: Include proper headers in i2c-desingware-core.h

This header is a user of some generic ones, include them respectively.

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>
4 years agoi2c: designware: Get rid of PCI driver specifics in common code
Andy Shevchenko [Tue, 19 May 2020 12:50:37 +0000 (15:50 +0300)]
i2c: designware: Get rid of PCI driver specifics in common code

Do not spread PCI specifics over common code. It seems to be a layering
violation which can be easily avoided. Refactor PCI driver and drop
PCI specifics from common code.

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>
4 years agoi2c: pxa: implement generic i2c bus recovery
Russell King [Wed, 13 May 2020 09:33:12 +0000 (10:33 +0100)]
i2c: pxa: implement generic i2c bus recovery

Implement generic GPIO-based I2C bus recovery for the PXA I2C driver.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoMerge tag 'for-5.8-i2c' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux...
Wolfram Sang [Wed, 20 May 2020 13:37:21 +0000 (15:37 +0200)]
Merge tag 'for-5.8-i2c' of git://git./linux/kernel/git/tegra/linux into i2c/for-5.8

i2c: tegra: Changes for v5.8-rc1

This includes a few improvements to make the Tegra I2C controller behave
properly on suspend/resume, does a bit of cleanup and adds support for
the VI-variant of the I2C controller that is used primarily for video
capture purposes.

4 years agoi2c: altera: cleanup spinlock
Atsushi Nemoto [Fri, 8 May 2020 13:14:36 +0000 (22:14 +0900)]
i2c: altera: cleanup spinlock

Protect altr_i2c_int_enable() by the mutex and remove unneeded spinlock.

Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
Reviewed-by: Thor Thayer <thor.thayer@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoMerge branch 'i2c/for-current-fixed' into i2c/for-5.8
Wolfram Sang [Wed, 20 May 2020 13:27:45 +0000 (15:27 +0200)]
Merge branch 'i2c/for-current-fixed' into i2c/for-5.8

4 years agoi2c: core: support bus regulator controlling in adapter
Bibby Hsieh [Tue, 19 May 2020 07:27:29 +0000 (15:27 +0800)]
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 get and enable bulk regulator in i2c adapter device.

Signed-off-by: Bibby Hsieh <bibby.hsieh@mediatek.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agodt-binding: i2c: add bus-supply property
Bibby Hsieh [Tue, 19 May 2020 07:27:28 +0000 (15:27 +0800)]
dt-binding: i2c: add bus-supply property

In some platforms, they disable the power-supply of i2c due
to power consumption reduction. This patch add bus-supply property.

Signed-off-by: Bibby Hsieh <bibby.hsieh@mediatek.com>
Acked-by: Rob Herring <robh@kernel.org>
[wsa: rebased to i2c/for-next]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: reword explanation about atomic transfers
Wolfram Sang [Tue, 5 May 2020 16:01:01 +0000 (18:01 +0200)]
i2c: reword explanation about atomic transfers

Atomic transfers are not only about sending messages like the original
wording suggested. Speak of 'accessing' now like in i2c.h.

Reported-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: slave-eeprom: add support for 24c512 EEPROMs
Wolfram Sang [Tue, 12 May 2020 14:20:46 +0000 (16:20 +0200)]
i2c: slave-eeprom: add support for 24c512 EEPROMs

I don't plan to support every EEPROM type, but the 24c512 ones need a
tiny code update, so let's have that upstream.

Reported-by: Patrick Williams <patrick@stwcx.xyz>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Patrick Williams <patrick@stwcx.xyz>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: mediatek: Add i2c ac-timing adjust support
Qii Wang [Thu, 14 May 2020 13:09:05 +0000 (21:09 +0800)]
i2c: mediatek: Add i2c ac-timing adjust support

This patch adds a algorithm to calculate some ac-timing parameters
which can fully meet I2C Spec.

Signed-off-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoMAINTAINERS: add maintainer for mediatek i2c controller driver
Qii Wang [Thu, 14 May 2020 13:09:04 +0000 (21:09 +0800)]
MAINTAINERS: add maintainer for mediatek i2c controller driver

Add Qii Wang as maintainer for mediatek i2c controller driver.

Signed-off-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: mux: Replace zero-length array with flexible-array
Gustavo A. R. Silva [Thu, 7 May 2020 18:53:29 +0000 (13:53 -0500)]
i2c: mux: Replace zero-length array with flexible-array

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: mux: demux-pinctrl: Fix an error handling path in 'i2c_demux_pinctrl_probe()'
Christophe JAILLET [Wed, 6 May 2020 19:21:00 +0000 (21:21 +0200)]
i2c: mux: demux-pinctrl: Fix an error handling path in 'i2c_demux_pinctrl_probe()'

A call to 'i2c_demux_deactivate_master()' is missing in the error handling
path, as already done in the remove function.

Fixes: 50a5ba876908 ("i2c: mux: demux-pinctrl: add driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: altera: Fix race between xfer_msg and isr thread
Atsushi Nemoto [Fri, 8 May 2020 13:12:48 +0000 (22:12 +0900)]
i2c: altera: Fix race between xfer_msg and isr thread

Use a mutex to protect access to idev->msg_len, idev->buf, etc. which
are modified by both altr_i2c_xfer_msg() and altr_i2c_isr().

This is the minimal fix for easy backporting. A cleanup to remove the
spinlock will be added later.

Signed-off-by: Atsushi Nemoto <atsushi.nemoto@sord.co.jp>
Acked-by: Thor Thayer <thor.thayer@linux.intel.com>
[wsa: updated commit message]
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: algo-pca: update contact email
Wolfram Sang [Sat, 2 May 2020 14:26:49 +0000 (16:26 +0200)]
i2c: algo-pca: update contact email

The 'pengutronix' address is defunct for years. Use the proper contact
address.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: at91: Fix pinmux after devm_gpiod_get() for bus recovery
Codrin Ciubotariu [Wed, 15 Apr 2020 07:06:43 +0000 (10:06 +0300)]
i2c: at91: Fix pinmux after devm_gpiod_get() for bus recovery

devm_gpiod_get() usually calls gpio_request_enable() for non-strict pinmux
drivers. These puts the pins in GPIO mode, whithout notifying the pinctrl
driver. At this point, the I2C bus no longer owns the pins. To mux the
pins back to the I2C bus, we use the pinctrl driver to change the state
of the pins to GPIO, before using devm_gpiod_get(). After the pins are
received as GPIOs, we switch theer pinctrl state back to the default
one,

Fixes: d3d3fdcc4c90 ("i2c: at91: implement i2c bus recovery")
Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Allow slave mode for PCI enumerated devices
Andy Shevchenko [Sat, 25 Apr 2020 13:44:48 +0000 (16:44 +0300)]
i2c: designware: Allow slave mode for PCI enumerated devices

Allow slave mode for PCI enumerated devices by calling a common i2c_dw_probe()
instead of i2c_dw_probe_master().

While dropping dependency to platform driver in slave module, move its
configuration section above, closer to core.

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>
4 years agoi2c: designware: Rename i2c_dw_probe() to i2c_dw_probe_master()
Andy Shevchenko [Sat, 25 Apr 2020 13:44:47 +0000 (16:44 +0300)]
i2c: designware: Rename i2c_dw_probe() to i2c_dw_probe_master()

As a preparatory patch to support slave mode for PCI enumerated devices rename
i2c_dw_probe() to i2c_dw_probe_master() and split common i2c_dw_probe() as
inline helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Switch PCI driver to use i2c_dw_configure_master()
Andy Shevchenko [Sat, 25 Apr 2020 13:44:46 +0000 (16:44 +0300)]
i2c: designware: Switch PCI driver to use i2c_dw_configure_master()

Since we have available helper to configure master mode, let's use it
in the PCI driver instead of spread open-coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Move configuration routines to respective modules
Andy Shevchenko [Sat, 25 Apr 2020 13:44:45 +0000 (16:44 +0300)]
i2c: designware: Move configuration routines to respective modules

Move configuration routines to respective modules, i.e. master and slave.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: designware: Use devm_platform_ioremap_resource() to simplify code
Andy Shevchenko [Sat, 25 Apr 2020 13:44:44 +0000 (16:44 +0300)]
i2c: designware: Use devm_platform_ioremap_resource() to simplify code

Use devm_platform_ioremap_resource() instead of
platform_get_resource() + devm_ioremap_resource().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: tegra: Add support for the VI I2C on Tegra210
Thierry Reding [Fri, 7 Jun 2019 13:56:23 +0000 (15:56 +0200)]
i2c: tegra: Add support for the VI I2C on Tegra210

Tegra210 has an extra instance of the I2C controller that is in the
domain of host1x and usually used for camera use-cases. The programming
model for the VI variant of the controller is roughly the same as for
the other variants, except that the I2C registers start at an offset
and are spaced further apart. VI I2C also doesn't support slave mode.

Signed-off-by: Thierry Reding <treding@nvidia.com>
4 years agoi2c: tegra: Use FIELD_PREP/FIELD_GET macros
Thierry Reding [Wed, 1 Apr 2020 22:21:28 +0000 (00:21 +0200)]
i2c: tegra: Use FIELD_PREP/FIELD_GET macros

Using these macros helps increase readability of the code.

Signed-off-by: Thierry Reding <treding@nvidia.com>
4 years agoi2c: pxa: use master-abort for device probes
Russell King [Wed, 6 May 2020 09:36:43 +0000 (10:36 +0100)]
i2c: pxa: use master-abort for device probes

Use master-abort to send the stop condition after an address cycle
rather than resetting the controller.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: clear all master action bits in i2c_pxa_stop_message()
Russell King [Wed, 6 May 2020 09:36:38 +0000 (10:36 +0100)]
i2c: pxa: clear all master action bits in i2c_pxa_stop_message()

If we timeout during a message transfer, the control register may
contain bits that cause an action to be set. Read-modify-writing the
register leaving these bits set may trigger the hardware to attempt
one of these actions unintentionally.

Always clear these bits when cleaning up after a message or after
a timeout.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: remove some unnecessary debug
Russell King [Mon, 11 May 2020 21:10:42 +0000 (22:10 +0100)]
i2c: pxa: remove some unnecessary debug

Remove unnecessary show_state() in the loop inside
i2c_pxa_pio_set_master(), which can be unnecessarily verbose.

Remove the i2c_pxa_scream_blue_murder() in i2c_pxa_pio_xfer(), which
will trigger if we are probing the I2C bus and a slave does not
respond; this is a normal event, and not something to report.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: ensure timeout messages are unique
Russell King [Mon, 11 May 2020 21:10:37 +0000 (22:10 +0100)]
i2c: pxa: ensure timeout messages are unique

Ensure that the various timeout messages can identify where in the code
they were produced from to aid debugging.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: avoid complaints with non-responsive slaves
Russell King [Mon, 11 May 2020 21:10:32 +0000 (22:10 +0100)]
i2c: pxa: avoid complaints with non-responsive slaves

Running i2cdetect on a PXA I2C adapter is very noisy; it complains
whenever a slave fails to respond to the address cycle.  Since it is
normal to probe for slaves in this way, we should not fill the kernel
log.  This is especially true with SFP modules that take a while to
respond on the I2C bus, and probing via the I2C bus is the only way to
detect that they are ready.

Fix this by changing the internal transfer return code from I2C_RETRY
to a new NO_SLAVE code (mapped to -ENXIO, as per the I2C documentation
for this condition, but we still return -EREMOTEIO to the I2C stack to
maintain long established driver behaviour.)

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: consolidate i2c_pxa_*xfer() implementations
Russell King [Mon, 11 May 2020 21:10:27 +0000 (22:10 +0100)]
i2c: pxa: consolidate i2c_pxa_*xfer() implementations

Most of i2c_pxa_pio_xfer() and i2c_pxa_xfer() are identical; the only
differences are that i2c_pxa_pio_xfer() may reset the bus, and they
use different underlying transfer functions. The retry loop is the
same. Consolidate these two functions.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: mux: pca954x: Convert license to SPDX identifier
Andy Shevchenko [Sat, 25 Apr 2020 11:51:52 +0000 (14:51 +0300)]
i2c: mux: pca954x: Convert license to SPDX identifier

Use a shorter SPDX identifier instead of pasting the whole license.

While here, replace duplicating PCA954x with PCA984x.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: mux: pca954x: Move device_remove_file() out of pca954x_cleanup()
Andy Shevchenko [Sat, 25 Apr 2020 11:51:51 +0000 (14:51 +0300)]
i2c: mux: pca954x: Move device_remove_file() out of pca954x_cleanup()

device_create_file() is called the last in ->probe() but pca954x_cleanup(),
which is called earlier in error path, tries to remove never created file.
Move device_remove_file() call outside of pca954x_cleanup() to make it
slightly closer to what pca954x_init() is doing.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: mux: pca954x: Make use of device properties
Andy Shevchenko [Sat, 25 Apr 2020 11:51:50 +0000 (14:51 +0300)]
i2c: mux: pca954x: Make use of device properties

Device property API allows to gather device resources from different sources,
such as ACPI. Convert the drivers to unleash the power of device property API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: mux: pca954x: Refactor pca954x_irq_handler()
Andy Shevchenko [Sat, 25 Apr 2020 11:51:49 +0000 (14:51 +0300)]
i2c: mux: pca954x: Refactor pca954x_irq_handler()

Refactor pca954x_irq_handler() to:
  - use for_each_set_bit() macro
  - use IRQ_RETVAL() macro

Above change makes code easy to read and understand.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: tegra: Synchronize DMA before termination
Dmitry Osipenko [Tue, 24 Mar 2020 19:12:17 +0000 (22:12 +0300)]
i2c: tegra: Synchronize DMA before termination

DMA transfer could be completed, but CPU (which handles DMA interrupt)
may get too busy and can't handle the interrupt in a timely manner,
despite of DMA IRQ being raised. In this case the DMA state needs to
synchronized before terminating DMA transfer in order not to miss the
DMA transfer completion.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
4 years agoi2c: tegra: Better handle case where CPU0 is busy for a long time
Dmitry Osipenko [Tue, 24 Mar 2020 19:12:16 +0000 (22:12 +0300)]
i2c: tegra: Better handle case where CPU0 is busy for a long time

Boot CPU0 always handle I2C interrupt and under some rare circumstances
(like running KASAN + NFS root) it may stuck in uninterruptible state for
a significant time. In this case we will get timeout if I2C transfer is
running on a sibling CPU, despite of IRQ being raised. In order to handle
this rare condition, the IRQ status needs to be checked after completion
timeout.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
4 years agoi2c: tegra: Keep IRQs enabled during suspend/resume
Thierry Reding [Wed, 6 May 2020 18:47:25 +0000 (20:47 +0200)]
i2c: tegra: Keep IRQs enabled during suspend/resume

One of the I2C controllers on Tegra SoCs is typically connected to a
system PMIC, which provides controls for critical power supplies for
most platforms.

Some drivers, such as PCI, need to disable these regulators during a
very late stage during suspend and resume them at a very early stage
during resume.

To support these use-cases, keep interrupts disabled during suspend/
resume.

Suggested-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
4 years agoi2c: tegra: Restore pinmux on system resume
Thierry Reding [Fri, 13 Dec 2019 13:44:17 +0000 (14:44 +0100)]
i2c: tegra: Restore pinmux on system resume

Depending on the board design, the I2C controllers found on Tegra SoCs
may require pinmuxing in order to function. This is done as part of the
driver's runtime suspend/resume operations. However, the PM core does
not allow devices to go into runtime suspend during system sleep to
avoid potential races with the suspend/resume of their parents.

As a result of this, when Tegra SoCs resume from system suspend, their
I2C controllers may have lost the pinmux state in hardware, whereas the
pinctrl subsystem is not aware of this. To fix this, make sure that if
the I2C controller is not runtime suspended, the runtime suspend code is
still executed in order to disable the module clock (which we don't need
to be enabled during sleep) and set the pinmux to the idle state.

Conversely, make sure that the I2C controller is properly resumed when
waking up from sleep so that pinmux settings are properly restored.

This fixes a bug seen with DDC transactions to an HDMI monitor timing
out when resuming from system suspend.

Signed-off-by: Thierry Reding <treding@nvidia.com>
4 years agoRevert "i2c: tegra: Fix suspending in active runtime PM state"
Thierry Reding [Thu, 30 Apr 2020 11:31:58 +0000 (13:31 +0200)]
Revert "i2c: tegra: Fix suspending in active runtime PM state"

This reverts commit 9f42de8d4ec2304f10bbc51dc0484f3503d61196.

It's not safe to use pm_runtime_force_{suspend,resume}(), especially
during the noirq phase of suspend. See also the guidance provided in
commit 1e2ef05bb8cf ("PM: Limit race conditions between runtime PM
and system sleep (v2)").

Signed-off-by: Thierry Reding <treding@nvidia.com>
4 years agoi2c: at91: Send bus clear command if SDA is down
Codrin Ciubotariu [Tue, 25 Feb 2020 15:50:09 +0000 (17:50 +0200)]
i2c: at91: Send bus clear command if SDA is down

After a transfer timeout, some faulty I2C slave devices might hold down
the SDA pin. We can generate a bus clear command, hoping that the slave
might release the pins.
If the CLEAR command is not supported, we will use gpio recovery, if
available, to reset the bus.

Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: use my kernel.org address from now on
Wolfram Sang [Sat, 2 May 2020 12:18:35 +0000 (14:18 +0200)]
i2c: use my kernel.org address from now on

The old email is still active, but for easier handling, I am going to
use my kernel.org address from now on. Also, add a mailmap for the now
defunct Pengutronix address.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: fix missing pm_runtime_put_sync in i2c_device_probe
Alain Volmat [Thu, 30 Apr 2020 15:43:21 +0000 (17:43 +0200)]
i2c: fix missing pm_runtime_put_sync in i2c_device_probe

In case of the I2C client exposes the flag I2C_CLIENT_HOST_NOTIFY,
pm_runtime_get_sync is called in order to always keep active the
adapter. However later on, pm_runtime_put_sync is never called
within the function in case of an error. This commit add this
error handling.

Fixes: 72bfcee11cf8 ("i2c: Prevent runtime suspend of adapter when Host Notify is required")
Signed-off-by: Alain Volmat <alain.volmat@st.com>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: fix i2c_pxa_wait_bus_not_busy() boundary condition
Russell King [Mon, 27 Apr 2020 18:49:32 +0000 (19:49 +0100)]
i2c: pxa: fix i2c_pxa_wait_bus_not_busy() boundary condition

Fix i2c_pxa_wait_bus_not_busy()'s boundary conditions, so that a
coincidental success and timeout results in the function returning
success.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: clean up decode_bits()
Russell King [Mon, 27 Apr 2020 18:49:27 +0000 (19:49 +0100)]
i2c: pxa: clean up decode_bits()

Clean up decode_bits() to use pr_cont(), and move the newline into the
function rather than at its two callsites. Avoid printing an
unnecessary space before the newline.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: fix i2c_pxa_scream_blue_murder() debug output
Russell King [Mon, 27 Apr 2020 18:49:22 +0000 (19:49 +0100)]
i2c: pxa: fix i2c_pxa_scream_blue_murder() debug output

The IRQ log output is supposed to appear on a single line.  However,
commit 3a2dc1677b60 ("i2c: pxa: Update debug function to dump more info
on error") resulted in it being printed one-entry-per-line, which is
excessively long.

Fixing this is not a trivial matter; using pr_cont() doesn't work as
the previous dev_dbg() may not have been compiled in, or may be
dynamic.

Since the rest of this function output is at error level, and is also
debug output, promote this to error level as well to avoid this
problem.

Reduce the number of always zero prefix digits to save screen real-
estate.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: move DT IDs along side platform IDs
Russell King [Mon, 27 Apr 2020 18:49:17 +0000 (19:49 +0100)]
i2c: pxa: move DT IDs along side platform IDs

Move the ID tables into one place, near the device dependent data.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: move private definitions to i2c-pxa.c
Russell King [Mon, 27 Apr 2020 18:49:12 +0000 (19:49 +0100)]
i2c: pxa: move private definitions to i2c-pxa.c

Move driver-private definitions out of the i2c-pxa.h platform data
header file into the driver itself. Nothing outside of the driver
makes use of these constants.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: always set fm and hs members for each type
Russell King [Mon, 27 Apr 2020 18:49:07 +0000 (19:49 +0100)]
i2c: pxa: always set fm and hs members for each type

Always set the fm and hs members of struct pxa_reg_layout. These
members are already taking space, we don't need code as well.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: add and use definitions for IBMR register
Russell King [Mon, 27 Apr 2020 18:49:01 +0000 (19:49 +0100)]
i2c: pxa: add and use definitions for IBMR register

Add definitions for the bits in the IBMR register, and use them in the
code. This improves readability.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: re-arrange register field definitions
Russell King [Mon, 27 Apr 2020 18:48:56 +0000 (19:48 +0100)]
i2c: pxa: re-arrange register field definitions

Arrange the register field definitions to be grouped together, rather
than the Armada-3700 definitions being separated from the rest of the
definitions.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: re-arrange functions to flow better
Russell King [Mon, 27 Apr 2020 18:48:51 +0000 (19:48 +0100)]
i2c: pxa: re-arrange functions to flow better

Re-arrange the PXA I2C code to avoid forward declarations, and keep
similar functionality (e.g. the non-IRQ mode support) together. This
improves code readability.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: re-arrange includes to be in alphabetical order
Russell King [Mon, 27 Apr 2020 18:48:46 +0000 (19:48 +0100)]
i2c: pxa: re-arrange includes to be in alphabetical order

Arrange the includes to be in alphabetical order to help avoid
duplicated includes.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: remove unneeded includes
Russell King [Mon, 27 Apr 2020 18:48:41 +0000 (19:48 +0100)]
i2c: pxa: remove unneeded includes

i2c-pxa does not need linux/sched.h nor linux/time.h includes, so
remove these.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoi2c: pxa: use official address byte helper
Russell King [Mon, 27 Apr 2020 18:48:36 +0000 (19:48 +0100)]
i2c: pxa: use official address byte helper

i2c-pxa was created before i2c_8bit_addr_from_msg() was implemented,
and used its own i2c_pxa_addr_byte() which is functionally the same.
Sadly, it was never updated to use this new helper. Switch it over.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
4 years agoLinux 5.7-rc4
Linus Torvalds [Sun, 3 May 2020 21:56:04 +0000 (14:56 -0700)]
Linux 5.7-rc4

4 years agoMerge tag 'for-5.7-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
Linus Torvalds [Sun, 3 May 2020 18:30:08 +0000 (11:30 -0700)]
Merge tag 'for-5.7-rc3-tag' of git://git./linux/kernel/git/kdave/linux

Pull more btrfs fixes from David Sterba:
 "A few more stability fixes, minor build warning fixes and git url
  fixup:

   - fix partial loss of prealloc extent past i_size after fsync

   - fix potential deadlock due to wrong transaction handle passing via
     journal_info

   - fix gcc 4.8 struct intialization warning

   - update git URL in MAINTAINERS entry"

* tag 'for-5.7-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  MAINTAINERS: btrfs: fix git repo URL
  btrfs: fix gcc-4.8 build warning for struct initializer
  btrfs: transaction: Avoid deadlock due to bad initialization timing of fs_info::journal_info
  btrfs: fix partial loss of prealloc extent past i_size after fsync

4 years agoMerge tag 'iommu-fixes-v5.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 3 May 2020 18:04:57 +0000 (11:04 -0700)]
Merge tag 'iommu-fixes-v5.7-rc3' of git://git./linux/kernel/git/joro/iommu

Pull IOMMU fixes from Joerg Roedel:

 - Fix a memory leak when dev_iommu gets freed and a sub-pointer does
   not

 - Build dependency fixes for Mediatek, spapr_tce, and Intel IOMMU
   driver

 - Export iommu_group_get_for_dev() only for GPLed modules

 - Fix AMD IOMMU interrupt remapping when x2apic is enabled

 - Fix error path in the QCOM IOMMU driver probe function

* tag 'iommu-fixes-v5.7-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
  iommu/qcom: Fix local_base status check
  iommu: Properly export iommu_group_get_for_dev()
  iommu/vt-d: Use right Kconfig option name
  iommu/amd: Fix legacy interrupt remapping for x2APIC-enabled system
  iommu: spapr_tce: Disable compile testing to fix build on book3s_32 config
  iommu/mediatek: Fix MTK_IOMMU dependencies
  iommu: Fix the memory leak in dev_iommu_free()

4 years agoMAINTAINERS: btrfs: fix git repo URL
Eric Biggers [Fri, 1 May 2020 23:44:17 +0000 (16:44 -0700)]
MAINTAINERS: btrfs: fix git repo URL

The git repo listed for btrfs hasn't been updated in over a year.
List the current one instead.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
4 years agoMerge tag 'pm-5.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Linus Torvalds [Sat, 2 May 2020 20:45:30 +0000 (13:45 -0700)]
Merge tag 'pm-5.7-rc4' of git://git./linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:

 - prevent the intel_pstate driver from printing excessive diagnostic
   messages in some cases (Chris Wilson)

 - make the hibernation restore kernel freeze kernel threads as well as
   user space tasks (Dexuan Cui)

 - fix the ACPI device PM disagnostic messages to include the correct
   power state name (Kai-Heng Feng).

* tag 'pm-5.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  PM: ACPI: Output correct message on target power state
  PM: hibernate: Freeze kernel threads in software_resume()
  cpufreq: intel_pstate: Only mention the BIOS disabling turbo mode once

4 years agoMerge branches 'pm-cpufreq' and 'pm-sleep'
Rafael J. Wysocki [Sat, 2 May 2020 19:39:17 +0000 (21:39 +0200)]
Merge branches 'pm-cpufreq' and 'pm-sleep'

* pm-cpufreq:
  cpufreq: intel_pstate: Only mention the BIOS disabling turbo mode once

* pm-sleep:
  PM: hibernate: Freeze kernel threads in software_resume()

4 years agoMerge tag 'iomap-5.7-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Linus Torvalds [Sat, 2 May 2020 18:31:12 +0000 (11:31 -0700)]
Merge tag 'iomap-5.7-fixes-1' of git://git./fs/xfs/xfs-linux

Pull iomap fix from Darrick Wong:
 "Hoist the check for an unrepresentable FIBMAP return value into
  ioctl_fibmap.

  The internal kernel function can handle 64-bit values (and is needed
  to fix a regression on ext4 + jbd2). It is only the userspace ioctl
  that is so old that it cannot deal"

* tag 'iomap-5.7-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  fibmap: Warn and return an error in case of block > INT_MAX

4 years agoMerge tag 'nfs-for-5.7-4' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Linus Torvalds [Sat, 2 May 2020 18:24:01 +0000 (11:24 -0700)]
Merge tag 'nfs-for-5.7-4' of git://git.linux-nfs.org/projects/trondmy/linux-nfs

Pull NFS client bugfixes from Trond Myklebust:
 "Highlights include:

  Stable fixes:
   - fix handling of backchannel binding in BIND_CONN_TO_SESSION

  Bugfixes:
   - Fix a credential use-after-free issue in pnfs_roc()
   - Fix potential posix_acl refcnt leak in nfs3_set_acl
   - defer slow parts of rpc_free_client() to a workqueue
   - Fix an Oopsable race in __nfs_list_for_each_server()
   - Fix trace point use-after-free race
   - Regression: the RDMA client no longer responds to server disconnect
     requests
   - Fix return values of xdr_stream_encode_item_{present, absent}
   - _pnfs_return_layout() must always wait for layoutreturn completion

  Cleanups:
   - Remove unreachable error conditions"

* tag 'nfs-for-5.7-4' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
  NFS: Fix a race in __nfs_list_for_each_server()
  NFSv4.1: fix handling of backchannel binding in BIND_CONN_TO_SESSION
  SUNRPC: defer slow parts of rpc_free_client() to a workqueue.
  NFSv4: Remove unreachable error condition due to rpc_run_task()
  SUNRPC: Remove unreachable error condition
  xprtrdma: Fix use of xdr_stream_encode_item_{present, absent}
  xprtrdma: Fix trace point use-after-free race
  xprtrdma: Restore wake-up-all to rpcrdma_cm_event_handler()
  nfs: Fix potential posix_acl refcnt leak in nfs3_set_acl
  NFS/pnfs: Fix a credential use-after-free issue in pnfs_roc()
  NFS/pnfs: Ensure that _pnfs_return_layout() waits for layoutreturn completion

4 years agoMerge tag 'dmaengine-fix-5.7-rc4' of git://git.infradead.org/users/vkoul/slave-dma
Linus Torvalds [Sat, 2 May 2020 18:16:14 +0000 (11:16 -0700)]
Merge tag 'dmaengine-fix-5.7-rc4' of git://git.infradead.org/users/vkoul/slave-dma

Pull dmaengine fixes from Vinod Koul:
 "Core:
   - Documentation typo fixes
   - fix the channel indexes
   - dmatest: fixes for process hang and iterations

  Drivers:
   - hisilicon: build error fix without PCI_MSI
   - ti-k3: deadlock fix
   - uniphier-xdmac: fix for reg region
   - pch: fix data race
   - tegra: fix clock state"

* tag 'dmaengine-fix-5.7-rc4' of git://git.infradead.org/users/vkoul/slave-dma:
  dmaengine: dmatest: Fix process hang when reading 'wait' parameter
  dmaengine: dmatest: Fix iteration non-stop logic
  dmaengine: tegra-apb: Ensure that clock is enabled during of DMA synchronization
  dmaengine: fix channel index enumeration
  dmaengine: mmp_tdma: Reset channel error on release
  dmaengine: mmp_tdma: Do not ignore slave config validation errors
  dmaengine: pch_dma.c: Avoid data race between probe and irq handler
  dt-bindings: dma: uniphier-xdmac: switch to single reg region
  include/linux/dmaengine: Typos fixes in API documentation
  dmaengine: xilinx_dma: Add missing check for empty list
  dmaengine: ti: k3-psil: fix deadlock on error path
  dmaengine: hisilicon: Fix build error without PCI_MSI

4 years agoMerge tag 'vfio-v5.7-rc4' of git://github.com/awilliam/linux-vfio
Linus Torvalds [Sat, 2 May 2020 00:19:15 +0000 (17:19 -0700)]
Merge tag 'vfio-v5.7-rc4' of git://github.com/awilliam/linux-vfio

Pull VFIO fixes from Alex Williamson:

 - copy_*_user validity check for new vfio_dma_rw interface (Yan Zhao)

 - Fix a potential math overflow (Yan Zhao)

 - Use follow_pfn() for calculating PFNMAPs (Sean Christopherson)

* tag 'vfio-v5.7-rc4' of git://github.com/awilliam/linux-vfio:
  vfio/type1: Fix VA->PA translation for PFNMAP VMAs in vaddr_get_pfn()
  vfio: avoid possible overflow in vfio_iommu_type1_pin_pages
  vfio: checking of validity of user vaddr in vfio_dma_rw

4 years agoMerge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Linus Torvalds [Sat, 2 May 2020 00:09:31 +0000 (17:09 -0700)]
Merge tag 'arm64-fixes' of git://git./linux/kernel/git/arm64/linux

Pull arm64 fix from Catalin Marinas:
 "Add -fasynchronous-unwind-tables to the vDSO CFLAGS"

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  arm64: vdso: Add -fasynchronous-unwind-tables to cflags

4 years agoMerge tag 'io_uring-5.7-2020-05-01' of git://git.kernel.dk/linux-block
Linus Torvalds [Sat, 2 May 2020 00:03:06 +0000 (17:03 -0700)]
Merge tag 'io_uring-5.7-2020-05-01' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe:

 - Fix for statx not grabbing the file table, making AT_EMPTY_PATH fail

 - Cover a few cases where async poll can handle retry, eliminating the
   need for an async thread

 - fallback request busy/free fix (Bijan)

 - syzbot reported SQPOLL thread exit fix for non-preempt (Xiaoguang)

 - Fix extra put of req for sync_file_range (Pavel)

 - Always punt splice async. We'll improve this for 5.8, but wanted to
   eliminate the inode mutex lock from the non-blocking path for 5.7
   (Pavel)

* tag 'io_uring-5.7-2020-05-01' of git://git.kernel.dk/linux-block:
  io_uring: punt splice async because of inode mutex
  io_uring: check non-sync defer_list carefully
  io_uring: fix extra put in sync_file_range()
  io_uring: use cond_resched() in io_ring_ctx_wait_and_kill()
  io_uring: use proper references for fallback_req locking
  io_uring: only force async punt if poll based retry can't handle it
  io_uring: enable poll retry for any file with ->read_iter / ->write_iter
  io_uring: statx must grab the file table for valid fd

4 years agoMerge tag 'block-5.7-2020-05-01' of git://git.kernel.dk/linux-block
Linus Torvalds [Fri, 1 May 2020 18:13:36 +0000 (11:13 -0700)]
Merge tag 'block-5.7-2020-05-01' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
 "A few fixes for this release:

   - NVMe pull request from Christoph, with a single fix for a double
     free in the namespace error handling.

   - Kill the bd_openers check in blk_drop_partitions(), fixing a
     regression in this merge window (Christoph)"

* tag 'block-5.7-2020-05-01' of git://git.kernel.dk/linux-block:
  block: remove the bd_openers checks in blk_drop_partitions
  nvme: prevent double free in nvme_alloc_ns() error handling

4 years agoMerge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Fri, 1 May 2020 18:10:09 +0000 (11:10 -0700)]
Merge branch 'i2c/for-current-fixed' of git://git./linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
 "Three driver bugfixes, and two reverts because the original patches
  revealed underlying problems which the Tegra guys are now working on"

* 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: aspeed: Avoid i2c interrupt status clear race condition.
  i2c: amd-mp2-pci: Fix Oops in amd_mp2_pci_init() error handling
  Revert "i2c: tegra: Better handle case where CPU0 is busy for a long time"
  Revert "i2c: tegra: Synchronize DMA before termination"
  i2c: iproc: generate stop event for slave writes