History

Merge tag 'i2c-7.2-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux

Pull more i2c updates from Andi Shyti: "Cleanups: - generic cleanups in qcom, qcom-cci and pxa, plus core cleanups in algo-bit and atr Fixes: - davinci: clean up cpufreq notifier on probe failure - imx-lpi2c: suspend the adapter while hardware is powered down - ls2x-v2: return IRQ_HANDLED after servicing error interrupts - stm32f7: fix timing calculation accuracy DT bindings: - microchip: permit resets - i2c-mux-pinctrl: update maintainer entry - i2c-mux-reg: convert bindings to DT schema" * tag 'i2c-7.2-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux: i2c: pxa: Use named initializers for the platform_device_id array i2c: imx-lpi2c: mark I2C adapter when hardware is powered down i2c: stm32f7: truncate clock period instead of rounding it dt-bindings: i2c: microchip,corei2c: permit resets i2c: qcom: Unify user-visible "Qualcomm" name i2c: ls2x-v2: return IRQ_HANDLED after servicing an error i2c: atr: annotate i2c_atr_adap_desc->aliases with __counted_by_ptr i2c: algo: bit: use str_plural helper in bit_xfer dt-bindings: i2c: i2c-mux-pinctrl: change maintainer dt-bindings: i2c: convert i2c-mux-reg to DT schema i2c: davinci: Unregister cpufreq notifier on probe failure i2c: qcom-cci: Remove overcautious disable_irq() calls i2c: qcom-cci: Move cci_init() under cci_reset() function i2c: qcom-cci: Do not check return value of cci_init()

Linus Torvalds committed 4 months ago

Commit 1dc18802 parents 9f333cb ac930b813 files · +151 −117Browse files

Unified · Split

13 files
  1. Documentation/devicetree/bindings/i2c/i2c-mux-pinctrl.yaml +1 −1
  2. Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt +0 −74
  3. Documentation/devicetree/bindings/i2c/i2c-mux-reg.yaml +92 −0
  4. Documentation/devicetree/bindings/i2c/microchip,corei2c.yaml +3 −0
  5. drivers/i2c/algos/i2c-algo-bit.c +3 −2
  6. drivers/i2c/busses/Kconfig +1 −1
  7. drivers/i2c/busses/i2c-davinci.c +3 −1
  8. drivers/i2c/busses/i2c-imx-lpi2c.c +14 −1
  9. drivers/i2c/busses/i2c-ls2x-v2.c +1 −1
  10. drivers/i2c/busses/i2c-pxa.c +5 −5
  11. drivers/i2c/busses/i2c-qcom-cci.c +20 −28
  12. drivers/i2c/busses/i2c-stm32f7.c +7 −2
  13. include/linux/i2c-atr.h +1 −1
Documentation/devicetree/bindings/i2c/i2c-mux-pinctrl.yaml+1−1
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# · 6 unmodified lines
7title: Pinctrl-based I2C Bus Mux7title: Pinctrl-based I2C Bus Mux
8 8
9maintainers:9maintainers:
10 - Wolfram Sang <wsa@kernel.org>10 - Thierry Reding <thierry.reding@kernel.org>
11 11
12description: |12description: |
13 This binding describes an I2C bus multiplexer that uses pin multiplexing to route the I2C13 This binding describes an I2C bus multiplexer that uses pin multiplexing to route the I2C
Documentation/devicetree/bindings/i2c/i2c-mux-reg.txt+0−74
@@ -1,74 +0,0 @@
1Register-based I2C Bus Mux
2
3This binding describes an I2C bus multiplexer that uses a single register
4to route the I2C signals.
5
6Required properties:
7- compatible: i2c-mux-reg
8- i2c-parent: The phandle of the I2C bus that this multiplexer's master-side
9 port is connected to.
10* Standard I2C mux properties. See i2c-mux.yaml in this directory.
11* I2C child bus nodes. See i2c-mux.yaml in this directory.
12
13Optional properties:
14- reg: this pair of <offset size> specifies the register to control the mux.
15 The <offset size> depends on its parent node. It can be any memory-mapped
16 address. The size must be either 1, 2, or 4 bytes. If reg is omitted, the
17 resource of this device will be used.
18- little-endian: The existence indicates the register is in little endian.
19- big-endian: The existence indicates the register is in big endian.
20 If both little-endian and big-endian are omitted, the endianness of the
21 CPU will be used.
22- write-only: The existence indicates the register is write-only.
23- idle-state: value to set the muxer to when idle. When no value is
24 given, it defaults to the last value used.
25
26Whenever an access is made to a device on a child bus, the value set
27in the relevant node's reg property will be output to the register.
28
29If an idle state is defined, using the idle-state (optional) property,
30whenever an access is not being made to a device on a child bus, the
31register will be set according to the idle value.
32
33If an idle state is not defined, the most recently used value will be
34left programmed into the register.
35
36Example of a mux on PCIe card, the host is a powerpc SoC (big endian):
37
38 i2c-mux {
39 /* the <offset size> depends on the address translation
40 * of the parent device. If omitted, device resource
41 * will be used instead. The size is to determine
42 * whether iowrite32, iowrite16, or iowrite8 will be used.
43 */
44 reg = <0x6028 0x4>;
45 little-endian; /* little endian register on PCIe */
46 compatible = "i2c-mux-reg";
47 #address-cells = <1>;
48 #size-cells = <0>;
49 i2c-parent = <&i2c1>;
50 i2c@0 {
51 reg = <0>;
52 #address-cells = <1>;
53 #size-cells = <0>;
54
55 si5338: clock-generator@70 {
56 compatible = "silabs,si5338";
57 reg = <0x70>;
58 /* other stuff */
59 };
60 };
61
62 i2c@1 {
63 /* data is written using iowrite32 */
64 reg = <1>;
65 #address-cells = <1>;
66 #size-cells = <0>;
67
68 si5338: clock-generator@70 {
69 compatible = "silabs,si5338";
70 reg = <0x70>;
71 /* other stuff */
72 };
73 };
74 };
Documentation/devicetree/bindings/i2c/i2c-mux-reg.yaml+92−0
@@ -0,0 +1,92 @@
1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/i2c/i2c-mux-reg.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Register-based I2C Bus Mux
8
9maintainers:
10 - Peter Rosin <peda@axentia.se>
11
12description: |
13 This binding describes an I2C bus multiplexer that uses a single
14 memory-mapped register to route the I2C signals.
15
16 Whenever an access is made to a device on a child bus, the value
17 set in the relevant node's reg property is output to the register.
18
19 If an idle state is defined via the idle-state property, the
20 register is set to that value whenever no access is being made.
21 Otherwise the most recently used value is left programmed.
22
23allOf:
24 - $ref: /schemas/i2c/i2c-mux.yaml#
25
26properties:
27 compatible:
28 const: i2c-mux-reg
29
30 reg:
31 maxItems: 1
32 description: |
33 Offset and size of the register that selects the active child
34 bus, relative to the parent node's address space. The size
35 determines the access width and must be 1, 2, or 4 bytes. If
36 omitted, the platform device's own memory resource is used
37 instead.
38
39 i2c-parent:
40 $ref: /schemas/types.yaml#/definitions/phandle
41 description:
42 Phandle of the I2C bus that this multiplexer's master-side port
43 is connected to.
44
45 little-endian:
46 type: boolean
47 description: Register is accessed in little-endian byte order.
48
49 big-endian:
50 type: boolean
51 description: Register is accessed in big-endian byte order.
52
53 write-only:
54 type: boolean
55 description:
56 Register is write-only; the driver must not read back the
57 current selection.
58
59 idle-state:
60 $ref: /schemas/types.yaml#/definitions/uint32
61 description:
62 Value to write to the register when no child bus is selected.
63
64required:
65 - compatible
66 - i2c-parent
67
68unevaluatedProperties: false
69
70examples:
71 - |
72 i2c-mux@6028 {
73 compatible = "i2c-mux-reg";
74 reg = <0x6028 0x4>;
75 little-endian;
76 #address-cells = <1>;
77 #size-cells = <0>;
78 i2c-parent = <&i2c1>;
79
80 i2c@0 {
81 reg = <0>;
82 #address-cells = <1>;
83 #size-cells = <0>;
84 };
85
86 i2c@1 {
87 reg = <1>;
88 #address-cells = <1>;
89 #size-cells = <0>;
90 };
91 };
92...
Documentation/devicetree/bindings/i2c/microchip,corei2c.yaml+3−0
@@ -37,6 +37,9 @@ properties: · 36 unmodified lines
37 modes are supported, possible values are 100000 and 400000.37 modes are supported, possible values are 100000 and 400000.
38 enum: [100000, 400000]38 enum: [100000, 400000]
39 39
40 resets:
41 maxItems: 1
42
40required:43required:
41 - compatible44 - compatible
42 - reg45 - reg
drivers/i2c/algos/i2c-algo-bit.c+3−2
@@ -13,6 +13,7 @@ · 12 unmodified lines
13#include <linux/delay.h>13#include <linux/delay.h>
14#include <linux/errno.h>14#include <linux/errno.h>
15#include <linux/sched.h>15#include <linux/sched.h>
16#include <linux/string_choices.h>
16#include <linux/i2c.h>17#include <linux/i2c.h>
17#include <linux/i2c-algo-bit.h>18#include <linux/i2c-algo-bit.h>
18 19
@@ -562,7 +563,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, · 543 unmodified lines
562 ret = readbytes(i2c_adap, pmsg);563 ret = readbytes(i2c_adap, pmsg);
563 if (ret >= 1)564 if (ret >= 1)
564 bit_dbg(2, &i2c_adap->dev, "read %d byte%s\n",565 bit_dbg(2, &i2c_adap->dev, "read %d byte%s\n",
565 ret, ret == 1 ? "" : "s");566 ret, str_plural(ret));
566 if (ret < pmsg->len) {567 if (ret < pmsg->len) {
567 if (ret >= 0)568 if (ret >= 0)
568 ret = -EIO;569 ret = -EIO;
@@ -573,7 +574,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, · 4 unmodified lines
573 ret = sendbytes(i2c_adap, pmsg);574 ret = sendbytes(i2c_adap, pmsg);
574 if (ret >= 1)575 if (ret >= 1)
575 bit_dbg(2, &i2c_adap->dev, "wrote %d byte%s\n",576 bit_dbg(2, &i2c_adap->dev, "wrote %d byte%s\n",
576 ret, ret == 1 ? "" : "s");577 ret, str_plural(ret));
577 if (ret < pmsg->len) {578 if (ret < pmsg->len) {
578 if (ret >= 0)579 if (ret >= 0)
579 ret = -EIO;580 ret = -EIO;
drivers/i2c/busses/Kconfig+1−1
@@ -1058,7 +1058,7 @@ config I2C_QCOM_CCI · 1057 unmodified lines
1058 will be called i2c-qcom-cci.1058 will be called i2c-qcom-cci.
1059 1059
1060config I2C_QCOM_GENI1060config I2C_QCOM_GENI
1061 tristate "Qualcomm Technologies Inc.'s GENI based I2C controller"1061 tristate "Qualcomm GENI based I2C controller"
1062 depends on ARCH_QCOM || COMPILE_TEST1062 depends on ARCH_QCOM || COMPILE_TEST
1063 depends on QCOM_GENI_SE1063 depends on QCOM_GENI_SE
1064 help1064 help
drivers/i2c/busses/i2c-davinci.c+3−1
@@ -818,12 +818,14 @@ static int davinci_i2c_probe(struct platform_device *pdev) · 817 unmodified lines
818 adap->nr = pdev->id;818 adap->nr = pdev->id;
819 r = i2c_add_numbered_adapter(adap);819 r = i2c_add_numbered_adapter(adap);
820 if (r)820 if (r)
821 goto err_unuse_clocks;821 goto err_cpufreq;
822 822
823 pm_runtime_put_autosuspend(dev->dev);823 pm_runtime_put_autosuspend(dev->dev);
824 824
825 return 0;825 return 0;
826 826
827err_cpufreq:
828 i2c_davinci_cpufreq_deregister(dev);
827err_unuse_clocks:829err_unuse_clocks:
828 pm_runtime_dont_use_autosuspend(dev->dev);830 pm_runtime_dont_use_autosuspend(dev->dev);
829 pm_runtime_put_sync(dev->dev);831 pm_runtime_put_sync(dev->dev);
drivers/i2c/busses/i2c-imx-lpi2c.c+14−1
@@ -1646,7 +1646,18 @@ static int __maybe_unused lpi2c_runtime_resume(struct device *dev) · 1645 unmodified lines
1646 1646
1647static int __maybe_unused lpi2c_suspend_noirq(struct device *dev)1647static int __maybe_unused lpi2c_suspend_noirq(struct device *dev)
1648{1648{
1649 return pm_runtime_force_suspend(dev);1649 struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev);
1650 int ret;
1651
1652 i2c_mark_adapter_suspended(&lpi2c_imx->adapter);
1653
1654 ret = pm_runtime_force_suspend(dev);
1655 if (ret) {
1656 i2c_mark_adapter_resumed(&lpi2c_imx->adapter);
1657 return ret;
1658 }
1659
1660 return 0;
1650}1661}
1651 1662
1652static int __maybe_unused lpi2c_resume_noirq(struct device *dev)1663static int __maybe_unused lpi2c_resume_noirq(struct device *dev)
@@ -1666,6 +1677,8 @@ static int __maybe_unused lpi2c_resume_noirq(struct device *dev) · 13 unmodified lines
1666 if (lpi2c_imx->target)1677 if (lpi2c_imx->target)
1667 lpi2c_imx_target_init(lpi2c_imx);1678 lpi2c_imx_target_init(lpi2c_imx);
1668 1679
1680 i2c_mark_adapter_resumed(&lpi2c_imx->adapter);
1681
1669 return 0;1682 return 0;
1670}1683}
1671 1684
drivers/i2c/busses/i2c-ls2x-v2.c+1−1
@@ -304,7 +304,7 @@ static irqreturn_t loongson2_i2c_isr_event(int irq, void *data) · 303 unmodified lines
304 regmap_read(priv->regmap, LOONGSON2_I2C_SR1, &status);304 regmap_read(priv->regmap, LOONGSON2_I2C_SR1, &status);
305 if (status & LOONGSON2_I2C_SR1_ITERREN_MASK) {305 if (status & LOONGSON2_I2C_SR1_ITERREN_MASK) {
306 loongson2_i2c_isr_error(status, data);306 loongson2_i2c_isr_error(status, data);
307 return IRQ_NONE;307 return IRQ_HANDLED;
308 }308 }
309 309
310 regmap_read(priv->regmap, LOONGSON2_I2C_CR2, &cr2);310 regmap_read(priv->regmap, LOONGSON2_I2C_CR2, &cr2);
drivers/i2c/busses/i2c-pxa.c+5−5
@@ -214,11 +214,11 @@ static const struct of_device_id i2c_pxa_dt_ids[] = { · 213 unmodified lines
214MODULE_DEVICE_TABLE(of, i2c_pxa_dt_ids);214MODULE_DEVICE_TABLE(of, i2c_pxa_dt_ids);
215 215
216static const struct platform_device_id i2c_pxa_id_table[] = {216static const struct platform_device_id i2c_pxa_id_table[] = {
217 { "pxa2xx-i2c", REGS_PXA2XX },217 { .name = "pxa2xx-i2c", .driver_data = REGS_PXA2XX },
218 { "pxa3xx-pwri2c", REGS_PXA3XX },218 { .name = "pxa3xx-pwri2c", .driver_data = REGS_PXA3XX },
219 { "ce4100-i2c", REGS_CE4100 },219 { .name = "ce4100-i2c", .driver_data = REGS_CE4100 },
220 { "pxa910-i2c", REGS_PXA910 },220 { .name = "pxa910-i2c", .driver_data = REGS_PXA910 },
221 { "armada-3700-i2c", REGS_A3700 },221 { .name = "armada-3700-i2c", .driver_data = REGS_A3700 },
222 { }222 { }
223};223};
224MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);224MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);
drivers/i2c/busses/i2c-qcom-cci.c+20−28
@@ -225,25 +225,7 @@ static int cci_halt(struct cci *cci, u8 master_num) · 224 unmodified lines
225 return 0;225 return 0;
226}226}
227 227
228static int cci_reset(struct cci *cci)228static void cci_init(struct cci *cci)
229{
230 /*
231 * we reset the whole controller, here and for implicity use
232 * master[0].xxx for waiting on it.
233 */
234 reinit_completion(&cci->master[0].irq_complete);
235 writel(CCI_RESET_CMD_MASK, cci->base + CCI_RESET_CMD);
236
237 if (!wait_for_completion_timeout(&cci->master[0].irq_complete,
238 CCI_TIMEOUT)) {
239 dev_err(cci->dev, "CCI reset timeout\n");
240 return -ETIMEDOUT;
241 }
242
243 return 0;
244}
245
246static int cci_init(struct cci *cci)
247{229{
248 u32 val = CCI_IRQ_MASK_0_I2C_M0_RD_DONE |230 u32 val = CCI_IRQ_MASK_0_I2C_M0_RD_DONE |
249 CCI_IRQ_MASK_0_I2C_M0_Q0_REPORT |231 CCI_IRQ_MASK_0_I2C_M0_Q0_REPORT |
@@ -284,6 +266,24 @@ static int cci_init(struct cci *cci) · 34 unmodified lines
284 val = hw->scl_stretch_en << 8 | hw->trdhld << 4 | hw->tsp;266 val = hw->scl_stretch_en << 8 | hw->trdhld << 4 | hw->tsp;
285 writel(val, cci->base + CCI_I2C_Mm_MISC_CTL(i));267 writel(val, cci->base + CCI_I2C_Mm_MISC_CTL(i));
286 }268 }
269}
270
271static int cci_reset(struct cci *cci)
272{
273 /*
274 * we reset the whole controller, here and for implicity use
275 * master[0].xxx for waiting on it.
276 */
277 reinit_completion(&cci->master[0].irq_complete);
278 writel(CCI_RESET_CMD_MASK, cci->base + CCI_RESET_CMD);
279
280 if (!wait_for_completion_timeout(&cci->master[0].irq_complete,
281 CCI_TIMEOUT)) {
282 dev_err(cci->dev, "CCI reset timeout\n");
283 return -ETIMEDOUT;
284 }
285
286 cci_init(cci);
287 287
288 return 0;288 return 0;
289}289}
@@ -304,7 +304,6 @@ static int cci_run_queue(struct cci *cci, u8 master, u8 queue) · 14 unmodified lines
304 dev_err(cci->dev, "master %d queue %d timeout\n",304 dev_err(cci->dev, "master %d queue %d timeout\n",
305 master, queue);305 master, queue);
306 cci_reset(cci);306 cci_reset(cci);
307 cci_init(cci);
308 return -ETIMEDOUT;307 return -ETIMEDOUT;
309 }308 }
310 309
@@ -609,11 +608,7 @@ static int cci_probe(struct platform_device *pdev) · 298 unmodified lines
609 608
610 ret = cci_reset(cci);609 ret = cci_reset(cci);
611 if (ret < 0)610 if (ret < 0)
612 goto error;611 goto disable_clocks;
613
614 ret = cci_init(cci);
615 if (ret < 0)
616 goto error;
617 612
618 pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);613 pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
619 pm_runtime_use_autosuspend(dev);614 pm_runtime_use_autosuspend(dev);
@@ -643,8 +638,6 @@ error_i2c: · 23 unmodified lines
643 of_node_put(cci->master[i].adap.dev.of_node);638 of_node_put(cci->master[i].adap.dev.of_node);
644 }639 }
645 }640 }
646error:
647 disable_irq(cci->irq);
648disable_clocks:641disable_clocks:
649 cci_disable_clocks(cci);642 cci_disable_clocks(cci);
650 643
@@ -664,7 +657,6 @@ static void cci_remove(struct platform_device *pdev) · 13 unmodified lines
664 }657 }
665 }658 }
666 659
667 disable_irq(cci->irq);
668 pm_runtime_disable(&pdev->dev);660 pm_runtime_disable(&pdev->dev);
669 pm_runtime_set_suspended(&pdev->dev);661 pm_runtime_set_suspended(&pdev->dev);
670}662}
drivers/i2c/busses/i2c-stm32f7.c+7−2
@@ -464,8 +464,13 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev, · 463 unmodified lines
464{464{
465 struct stm32f7_i2c_spec *specs;465 struct stm32f7_i2c_spec *specs;
466 u32 p_prev = STM32F7_PRESC_MAX;466 u32 p_prev = STM32F7_PRESC_MAX;
467 u32 i2cclk = DIV_ROUND_CLOSEST(NSEC_PER_SEC,467 /*
468 setup->clock_src);468 * Truncate instead of rounding to closest: if the clock period is
469 * overestimated, the computed SCL timings will come out shorter on
470 * the wire, which can push the bus above the target rate and below
471 * the spec's tLOW/tHIGH minimums.
472 */
473 u32 i2cclk = NSEC_PER_SEC / setup->clock_src;
469 u32 i2cbus = DIV_ROUND_CLOSEST(NSEC_PER_SEC,474 u32 i2cbus = DIV_ROUND_CLOSEST(NSEC_PER_SEC,
470 setup->speed_freq);475 setup->speed_freq);
471 u32 clk_error_prev = i2cbus;476 u32 clk_error_prev = i2cbus;
include/linux/i2c-atr.h+1−1
@@ -71,7 +71,7 @@ struct i2c_atr_adap_desc { · 70 unmodified lines
71 struct device *parent;71 struct device *parent;
72 struct fwnode_handle *bus_handle;72 struct fwnode_handle *bus_handle;
73 size_t num_aliases;73 size_t num_aliases;
74 u16 *aliases;74 u16 *aliases __counted_by_ptr(num_aliases);
75};75};
76 76
77/**77/**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t