Skip to content

Commit

Permalink
Merge tag 'i2c-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/wsa/linux

Pull i2c updates from Wolfram Sang:
 "Core:

   - list-based mechanisms for handling auto-detected and userspace
     created clients are replaced with a flag-based approach. The
     resulting code is much simpler as well as the locking.

   - i2c clients now get a default debugfs dir managed by the I2C core.
     Drivers don't have to maintain their own directory anymore.

  Driver updates:

   - xiic: atomic_transfer support

   - imx-lpi2c: DMA and target mode support

   - riic cleanups

   - npcm: better timeout handling and more precise frequency setups

   - davinci: remove unused platform_data

   - at24: add new compatibles for variants from Giantec and Puya
     Semiconductor (together with a new vendor prefix)"

* tag 'i2c-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (52 commits)
  i2c: add kdoc for the new debugfs entry of clients
  i2c: designware: Actually make use of the I2C_DW_COMMON and I2C_DW symbol namespaces
  i2c: add core-managed per-client directory in debugfs
  i2c: Force ELAN06FA touchpad I2C bus freq to 100KHz
  i2c: riic: Add `riic_bus_barrier()` to check bus availability
  i2c: riic: Use predefined macro and simplify clock tick calculation
  i2c: riic: Mark riic_irqs array as const
  i2c: riic: Make use of devres helper to request deasserted reset line
  i2c: riic: Use GENMASK() macro for bitmask definitions
  i2c: riic: Use BIT macro consistently
  i2c: riic: Use local `dev` pointer in `dev_err_probe()`
  i2c: riic: Use dev_err_probe in probe and riic_init_hw functions
  i2c: riic: Introduce a separate variable for IRQ
  i2c: amd756: Remove superfluous TODO
  Revert "i2c: amd756: Fix endianness handling for word data"
  i2c: i801: Add lis3lv02d for Dell Precision M6800
  i2c: i801: Remove unnecessary PCI function call
  i2c: core: Allocate temp client on the stack in i2c_detect
  i2c: slave-eeprom: Constify 'struct bin_attribute'
  i2c: imx-lpi2c: make controller available until the system enters suspend_noirq() and from resume_noirq().
  ...
  • Loading branch information
Linus Torvalds committed Jan 22, 2025
2 parents d12f68b + 27c3f0e commit abdebb2
Show file tree
Hide file tree
Showing 27 changed files with 1,714 additions and 507 deletions.
5 changes: 5 additions & 0 deletions Documentation/devicetree/bindings/eeprom/at24.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ properties:
- const: atmel,24c64
- items:
- enum:
- giantec,gt24p128f
- renesas,r1ex24128
- samsung,s524ad0xd1
- const: atmel,24c128
- items:
- enum:
- puya,p24c256c
- const: atmel,24c256
- items:
- const: microchip,24aa025e48
- items:
Expand Down
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/i2c/i2c-exynos5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ properties:
- samsung,exynos5250-hsi2c # Exynos5250 and Exynos5420
- samsung,exynos5260-hsi2c # Exynos5260
- samsung,exynos7-hsi2c # Exynos7
- samsung,exynos8895-hsi2c
- samsung,exynosautov9-hsi2c
- items:
- enum:
Expand Down
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ properties:
- qcom,sm8450-cci
- qcom,sm8550-cci
- qcom,sm8650-cci
- qcom,x1e80100-cci
- const: qcom,msm8996-cci # CCI v2

"#address-cells":
Expand Down Expand Up @@ -224,6 +225,7 @@ allOf:
enum:
- qcom,sm8550-cci
- qcom,sm8650-cci
- qcom,x1e80100-cci
then:
properties:
clocks:
Expand Down
5 changes: 4 additions & 1 deletion Documentation/devicetree/bindings/i2c/renesas,riic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ properties:
- const: renesas,riic-rz # RZ/A or RZ/G2L

- items:
- const: renesas,riic-r9a08g045 # RZ/G3S
- enum:
- renesas,riic-r9a08g045 # RZ/G3S
- renesas,riic-r9a09g047 # RZ/G3E
- const: renesas,riic-r9a09g057 # RZ/V2H(P)

- const: renesas,riic-r9a09g057 # RZ/V2H(P)
Expand Down Expand Up @@ -89,6 +91,7 @@ if:
- renesas,riic-r9a07g043
- renesas,riic-r9a07g044
- renesas,riic-r9a07g054
- renesas,riic-r9a09g057
then:
required:
- resets
Expand Down
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/vendor-prefixes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,8 @@ patternProperties:
description: PulsedLight, Inc
"^purism,.*":
description: Purism, SPC
"^puya,.*":
description: Puya Semiconductor (Shanghai) Co., Ltd.
"^qca,.*":
description: Qualcomm Atheros, Inc.
"^qcom,.*":
Expand Down
4 changes: 2 additions & 2 deletions drivers/i2c/busses/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ config I2C_BRCMSTB
tristate "BRCM Settop/DSL I2C controller"
depends on ARCH_BCM2835 || ARCH_BCMBCA || ARCH_BRCMSTB || \
BMIPS_GENERIC || COMPILE_TEST
default y
default ARCH_BCM2835 || ARCH_BCMBCA || ARCH_BRCMSTB || BMIPS_GENERIC
help
If you say yes to this option, support will be included for the
I2C interface on the Broadcom Settop/DSL SoCs.
Expand Down Expand Up @@ -910,7 +910,7 @@ config I2C_MXS

config I2C_NOMADIK
tristate "ST-Ericsson Nomadik/Ux500 I2C Controller"
depends on ARM_AMBA
depends on ARM_AMBA || COMPILE_TEST
help
If you say yes to this option, support will be included for the
I2C interface from ST-Ericsson's Nomadik and Ux500 architectures,
Expand Down
4 changes: 2 additions & 2 deletions drivers/i2c/busses/i2c-amd756.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
SMB_HOST_ADDRESS);
outb_p(command, SMB_HOST_COMMAND);
if (read_write == I2C_SMBUS_WRITE)
outw_p(data->word, SMB_HOST_DATA); /* TODO: endian???? */
outw_p(data->word, SMB_HOST_DATA);
size = AMD756_WORD_DATA;
break;
case I2C_SMBUS_BLOCK_DATA:
Expand Down Expand Up @@ -256,7 +256,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
data->byte = inw_p(SMB_HOST_DATA);
break;
case AMD756_WORD_DATA:
data->word = inw_p(SMB_HOST_DATA); /* TODO: endian???? */
data->word = inw_p(SMB_HOST_DATA);
break;
case AMD756_BLOCK_DATA:
data->block[0] = inw_p(SMB_HOST_DATA) & 0x3f;
Expand Down
112 changes: 33 additions & 79 deletions drivers/i2c/busses/i2c-davinci.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
*
* ----------------------------------------------------------------------------
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/i2c.h>

#include <linux/clk.h>
#include <linux/errno.h>
#include <linux/sched.h>
#include <linux/cpufreq.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/cpufreq.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
#include <linux/platform_data/i2c-davinci.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/sched.h>
#include <linux/slab.h>

/* ----- global defines ----------------------------------------------- */

Expand Down Expand Up @@ -117,6 +117,8 @@
/* timeout for pm runtime autosuspend */
#define DAVINCI_I2C_PM_TIMEOUT 1000 /* ms */

#define DAVINCI_I2C_DEFAULT_BUS_FREQ 100

struct davinci_i2c_dev {
struct device *dev;
void __iomem *base;
Expand All @@ -132,13 +134,10 @@ struct davinci_i2c_dev {
#ifdef CONFIG_CPU_FREQ
struct notifier_block freq_transition;
#endif
struct davinci_i2c_platform_data *pdata;
};

/* default platform data to use if not supplied in the platform_device */
static struct davinci_i2c_platform_data davinci_i2c_platform_data_default = {
.bus_freq = 100,
.bus_delay = 0,
/* standard bus frequency (kHz) */
unsigned int bus_freq;
/* Chip has a ICPFUNC register */
bool has_pfunc;
};

static inline void davinci_i2c_write_reg(struct davinci_i2c_dev *i2c_dev,
Expand Down Expand Up @@ -168,14 +167,12 @@ static inline void davinci_i2c_reset_ctrl(struct davinci_i2c_dev *i2c_dev,

static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
{
struct davinci_i2c_platform_data *pdata = dev->pdata;
u16 psc;
u32 clk;
u32 d;
u32 clkh;
u32 clkl;
u32 input_clock = clk_get_rate(dev->clk);
struct device_node *of_node = dev->dev->of_node;

/* NOTE: I2C Clock divider programming info
* As per I2C specs the following formulas provide prescaler
Expand Down Expand Up @@ -209,19 +206,19 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
psc++; /* better to run under spec than over */
d = (psc >= 2) ? 5 : 7 - psc;

if (of_node && of_device_is_compatible(of_node, "ti,keystone-i2c"))
if (device_is_compatible(dev->dev, "ti,keystone-i2c"))
d = 6;

clk = ((input_clock / (psc + 1)) / (pdata->bus_freq * 1000));
clk = ((input_clock / (psc + 1)) / (dev->bus_freq * 1000));
/* Avoid driving the bus too fast because of rounding errors above */
if (input_clock / (psc + 1) / clk > pdata->bus_freq * 1000)
if (input_clock / (psc + 1) / clk > dev->bus_freq * 1000)
clk++;
/*
* According to I2C-BUS Spec 2.1, in FAST-MODE LOW period should be at
* least 1.3uS, which is not the case with 50% duty cycle. Driving HIGH
* to LOW ratio as 1 to 2 is more safe.
*/
if (pdata->bus_freq > 100)
if (dev->bus_freq > 100)
clkl = (clk << 1) / 3;
else
clkl = (clk >> 1);
Expand Down Expand Up @@ -255,8 +252,6 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
*/
static int i2c_davinci_init(struct davinci_i2c_dev *dev)
{
struct davinci_i2c_platform_data *pdata = dev->pdata;

/* put I2C into reset */
davinci_i2c_reset_ctrl(dev, 0);

Expand All @@ -274,8 +269,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
davinci_i2c_read_reg(dev, DAVINCI_I2C_CLKL_REG));
dev_dbg(dev->dev, "CLKH = %d\n",
davinci_i2c_read_reg(dev, DAVINCI_I2C_CLKH_REG));
dev_dbg(dev->dev, "bus_freq = %dkHz, bus_delay = %d\n",
pdata->bus_freq, pdata->bus_delay);
dev_dbg(dev->dev, "bus_freq = %dkHz\n", dev->bus_freq);


/* Take the I2C module out of reset: */
Expand Down Expand Up @@ -309,12 +303,6 @@ static void davinci_i2c_unprepare_recovery(struct i2c_adapter *adap)
i2c_davinci_init(dev);
}

static struct i2c_bus_recovery_info davinci_i2c_gpio_recovery_info = {
.recover_bus = i2c_generic_scl_recovery,
.prepare_recovery = davinci_i2c_prepare_recovery,
.unprepare_recovery = davinci_i2c_unprepare_recovery,
};

static void davinci_i2c_set_scl(struct i2c_adapter *adap, int val)
{
struct davinci_i2c_dev *dev = i2c_get_adapdata(adap);
Expand Down Expand Up @@ -414,7 +402,6 @@ static int
i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
{
struct davinci_i2c_dev *dev = i2c_get_adapdata(adap);
struct davinci_i2c_platform_data *pdata = dev->pdata;
u32 flag;
u16 w;
unsigned long time_left;
Expand All @@ -424,10 +411,6 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
return -EADDRNOTAVAIL;
}

/* Introduce a delay, required for some boards (e.g Davinci EVM) */
if (pdata->bus_delay)
udelay(pdata->bus_delay);

/* set the target address */
davinci_i2c_write_reg(dev, DAVINCI_I2C_SAR_REG, msg->addr);

Expand Down Expand Up @@ -758,8 +741,8 @@ static int davinci_i2c_probe(struct platform_device *pdev)
{
struct davinci_i2c_dev *dev;
struct i2c_adapter *adap;
struct i2c_bus_recovery_info *rinfo;
int r, irq;
u32 prop;

irq = platform_get_irq(pdev, 0);
if (irq < 0)
Expand All @@ -773,29 +756,15 @@ static int davinci_i2c_probe(struct platform_device *pdev)

dev->dev = &pdev->dev;
dev->irq = irq;
dev->pdata = dev_get_platdata(&pdev->dev);
platform_set_drvdata(pdev, dev);

if (!dev->pdata && pdev->dev.of_node) {
u32 prop;

dev->pdata = devm_kzalloc(&pdev->dev,
sizeof(struct davinci_i2c_platform_data), GFP_KERNEL);
if (!dev->pdata)
return -ENOMEM;

memcpy(dev->pdata, &davinci_i2c_platform_data_default,
sizeof(struct davinci_i2c_platform_data));
if (!of_property_read_u32(pdev->dev.of_node, "clock-frequency",
&prop))
dev->pdata->bus_freq = prop / 1000;

dev->pdata->has_pfunc =
of_property_read_bool(pdev->dev.of_node,
"ti,has-pfunc");
} else if (!dev->pdata) {
dev->pdata = &davinci_i2c_platform_data_default;
}
r = device_property_read_u32(&pdev->dev, "clock-frequency", &prop);
if (r)
prop = DAVINCI_I2C_DEFAULT_BUS_FREQ;

dev->bus_freq = prop / 1000;

dev->has_pfunc = device_property_present(&pdev->dev, "ti,has-pfunc");

dev->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dev->clk))
Expand Down Expand Up @@ -841,25 +810,10 @@ static int davinci_i2c_probe(struct platform_device *pdev)
adap->algo = &i2c_davinci_algo;
adap->dev.parent = &pdev->dev;
adap->timeout = DAVINCI_I2C_TIMEOUT;
adap->dev.of_node = pdev->dev.of_node;
adap->dev.of_node = dev_of_node(&pdev->dev);

if (dev->pdata->has_pfunc)
if (dev->has_pfunc)
adap->bus_recovery_info = &davinci_i2c_scl_recovery_info;
else if (dev->pdata->gpio_recovery) {
rinfo = &davinci_i2c_gpio_recovery_info;
adap->bus_recovery_info = rinfo;
rinfo->scl_gpiod = devm_gpiod_get(&pdev->dev, "scl",
GPIOD_OUT_HIGH_OPEN_DRAIN);
if (IS_ERR(rinfo->scl_gpiod)) {
r = PTR_ERR(rinfo->scl_gpiod);
goto err_unuse_clocks;
}
rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN);
if (IS_ERR(rinfo->sda_gpiod)) {
r = PTR_ERR(rinfo->sda_gpiod);
goto err_unuse_clocks;
}
}

adap->nr = pdev->id;
r = i2c_add_numbered_adapter(adap);
Expand Down
5 changes: 3 additions & 2 deletions drivers/i2c/busses/i2c-designware-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* Copyright (C) 2007 MontaVista Software Inc.
* Copyright (C) 2009 Provigent Ltd.
*/

#define DEFAULT_SYMBOL_NAMESPACE "I2C_DW_COMMON"

#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/delay.h>
Expand All @@ -29,8 +32,6 @@
#include <linux/types.h>
#include <linux/units.h>

#define DEFAULT_SYMBOL_NAMESPACE "I2C_DW_COMMON"

#include "i2c-designware-core.h"

static const char *const abort_sources[] = {
Expand Down
5 changes: 3 additions & 2 deletions drivers/i2c/busses/i2c-designware-master.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* Copyright (C) 2007 MontaVista Software Inc.
* Copyright (C) 2009 Provigent Ltd.
*/

#define DEFAULT_SYMBOL_NAMESPACE "I2C_DW"

#include <linux/delay.h>
#include <linux/err.h>
#include <linux/errno.h>
Expand All @@ -22,8 +25,6 @@
#include <linux/regmap.h>
#include <linux/reset.h>

#define DEFAULT_SYMBOL_NAMESPACE "I2C_DW"

#include "i2c-designware-core.h"

#define AMD_TIMEOUT_MIN_US 25
Expand Down
5 changes: 3 additions & 2 deletions drivers/i2c/busses/i2c-designware-slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*
* Copyright (C) 2016 Synopsys Inc.
*/

#define DEFAULT_SYMBOL_NAMESPACE "I2C_DW"

#include <linux/delay.h>
#include <linux/err.h>
#include <linux/errno.h>
Expand All @@ -16,8 +19,6 @@
#include <linux/pm_runtime.h>
#include <linux/regmap.h>

#define DEFAULT_SYMBOL_NAMESPACE "I2C_DW"

#include "i2c-designware-core.h"

static void i2c_dw_configure_fifo_slave(struct dw_i2c_dev *dev)
Expand Down
Loading

0 comments on commit abdebb2

Please sign in to comment.