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
77 title: Pinctrl-based I2C Bus Mux
88
99 maintainers:
10− - Wolfram Sang <wsa@kernel.org>
10+ - Thierry Reding <thierry.reding@kernel.org>
1111
1212 description: |
1313 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 @@
1−Register-based I2C Bus Mux
2−
3−This binding describes an I2C bus multiplexer that uses a single register
4−to route the I2C signals.
5−
6−Required 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−
13−Optional 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−
26−Whenever an access is made to a device on a child bus, the value set
27−in the relevant node's reg property will be output to the register.
28−
29−If an idle state is defined, using the idle-state (optional) property,
30−whenever an access is not being made to a device on a child bus, the
31−register will be set according to the idle value.
32−
33−If an idle state is not defined, the most recently used value will be
34−left programmed into the register.
35−
36−Example 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+
7+title: Register-based I2C Bus Mux
8+
9+maintainers:
10+ - Peter Rosin <peda@axentia.se>
11+
12+description: |
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+
23+allOf:
24+ - $ref: /schemas/i2c/i2c-mux.yaml#
25+
26+properties:
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+
64+required:
65+ - compatible
66+ - i2c-parent
67+
68+unevaluatedProperties: false
69+
70+examples:
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
3737 modes are supported, possible values are 100000 and 400000.
3838 enum: [100000, 400000]
3939
40+ resets:
41+ maxItems: 1
42+
4043 required:
4144 - compatible
4245 - reg
drivers/i2c/algos/i2c-algo-bit.c+3−2
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 #include <linux/delay.h>
1414 #include <linux/errno.h>
1515 #include <linux/sched.h>
16+#include <linux/string_choices.h>
1617 #include <linux/i2c.h>
1718 #include <linux/i2c-algo-bit.h>
1819
@@ -562,7 +563,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, · 543 unmodified lines
562563 ret = readbytes(i2c_adap, pmsg);
563564 if (ret >= 1)
564565 bit_dbg(2, &i2c_adap->dev, "read %d byte%s\n",
565− ret, ret == 1 ? "" : "s");
566+ ret, str_plural(ret));
566567 if (ret < pmsg->len) {
567568 if (ret >= 0)
568569 ret = -EIO;
@@ -573,7 +574,7 @@ static int bit_xfer(struct i2c_adapter *i2c_adap, · 4 unmodified lines
573574 ret = sendbytes(i2c_adap, pmsg);
574575 if (ret >= 1)
575576 bit_dbg(2, &i2c_adap->dev, "wrote %d byte%s\n",
576− ret, ret == 1 ? "" : "s");
577+ ret, str_plural(ret));
577578 if (ret < pmsg->len) {
578579 if (ret >= 0)
579580 ret = -EIO;
drivers/i2c/busses/Kconfig+1−1
@@ -1058,7 +1058,7 @@ config I2C_QCOM_CCI · 1057 unmodified lines
10581058 will be called i2c-qcom-cci.
10591059
10601060 config I2C_QCOM_GENI
1061− tristate "Qualcomm Technologies Inc.'s GENI based I2C controller"
1061+ tristate "Qualcomm GENI based I2C controller"
10621062 depends on ARCH_QCOM || COMPILE_TEST
10631063 depends on QCOM_GENI_SE
10641064 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
818818 adap->nr = pdev->id;
819819 r = i2c_add_numbered_adapter(adap);
820820 if (r)
821− goto err_unuse_clocks;
821+ goto err_cpufreq;
822822
823823 pm_runtime_put_autosuspend(dev->dev);
824824
825825 return 0;
826826
827+err_cpufreq:
828+ i2c_davinci_cpufreq_deregister(dev);
827829 err_unuse_clocks:
828830 pm_runtime_dont_use_autosuspend(dev->dev);
829831 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
16461646
16471647 static int __maybe_unused lpi2c_suspend_noirq(struct device *dev)
16481648 {
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;
16501661 }
16511662
16521663 static 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
16661677 if (lpi2c_imx->target)
16671678 lpi2c_imx_target_init(lpi2c_imx);
16681679
1680+ i2c_mark_adapter_resumed(&lpi2c_imx->adapter);
1681+
16691682 return 0;
16701683 }
16711684
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
304304 regmap_read(priv->regmap, LOONGSON2_I2C_SR1, &status);
305305 if (status & LOONGSON2_I2C_SR1_ITERREN_MASK) {
306306 loongson2_i2c_isr_error(status, data);
307− return IRQ_NONE;
307+ return IRQ_HANDLED;
308308 }
309309
310310 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
214214 MODULE_DEVICE_TABLE(of, i2c_pxa_dt_ids);
215215
216216 static const struct platform_device_id i2c_pxa_id_table[] = {
217− { "pxa2xx-i2c", REGS_PXA2XX },
218− { "pxa3xx-pwri2c", REGS_PXA3XX },
219− { "ce4100-i2c", REGS_CE4100 },
220− { "pxa910-i2c", REGS_PXA910 },
221− { "armada-3700-i2c", REGS_A3700 },
217+ { .name = "pxa2xx-i2c", .driver_data = REGS_PXA2XX },
218+ { .name = "pxa3xx-pwri2c", .driver_data = REGS_PXA3XX },
219+ { .name = "ce4100-i2c", .driver_data = REGS_CE4100 },
220+ { .name = "pxa910-i2c", .driver_data = REGS_PXA910 },
221+ { .name = "armada-3700-i2c", .driver_data = REGS_A3700 },
222222 { }
223223 };
224224 MODULE_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
225225 return 0;
226226 }
227227
228−static int cci_reset(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−
246−static int cci_init(struct cci *cci)
228+static void cci_init(struct cci *cci)
247229 {
248230 u32 val = CCI_IRQ_MASK_0_I2C_M0_RD_DONE |
249231 CCI_IRQ_MASK_0_I2C_M0_Q0_REPORT |
@@ -284,6 +266,24 @@ static int cci_init(struct cci *cci) · 34 unmodified lines
284266 val = hw->scl_stretch_en << 8 | hw->trdhld << 4 | hw->tsp;
285267 writel(val, cci->base + CCI_I2C_Mm_MISC_CTL(i));
286268 }
269+}
270+
271+static 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);
287287
288288 return 0;
289289 }
@@ -304,7 +304,6 @@ static int cci_run_queue(struct cci *cci, u8 master, u8 queue) · 14 unmodified lines
304304 dev_err(cci->dev, "master %d queue %d timeout\n",
305305 master, queue);
306306 cci_reset(cci);
307− cci_init(cci);
308307 return -ETIMEDOUT;
309308 }
310309
@@ -609,11 +608,7 @@ static int cci_probe(struct platform_device *pdev) · 298 unmodified lines
609608
610609 ret = cci_reset(cci);
611610 if (ret < 0)
612− goto error;
613−
614− ret = cci_init(cci);
615− if (ret < 0)
616− goto error;
611+ goto disable_clocks;
617612
618613 pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC);
619614 pm_runtime_use_autosuspend(dev);
@@ -643,8 +638,6 @@ error_i2c: · 23 unmodified lines
643638 of_node_put(cci->master[i].adap.dev.of_node);
644639 }
645640 }
646−error:
647− disable_irq(cci->irq);
648641 disable_clocks:
649642 cci_disable_clocks(cci);
650643
@@ -664,7 +657,6 @@ static void cci_remove(struct platform_device *pdev) · 13 unmodified lines
664657 }
665658 }
666659
667− disable_irq(cci->irq);
668660 pm_runtime_disable(&pdev->dev);
669661 pm_runtime_set_suspended(&pdev->dev);
670662 }
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
464464 {
465465 struct stm32f7_i2c_spec *specs;
466466 u32 p_prev = STM32F7_PRESC_MAX;
467− u32 i2cclk = DIV_ROUND_CLOSEST(NSEC_PER_SEC,
468− setup->clock_src);
467+ /*
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;
469474 u32 i2cbus = DIV_ROUND_CLOSEST(NSEC_PER_SEC,
470475 setup->speed_freq);
471476 u32 clk_error_prev = i2cbus;
include/linux/i2c-atr.h+1−1
@@ -71,7 +71,7 @@ struct i2c_atr_adap_desc { · 70 unmodified lines
7171 struct device *parent;
7272 struct fwnode_handle *bus_handle;
7373 size_t num_aliases;
74− u16 *aliases;
74+ u16 *aliases __counted_by_ptr(num_aliases);
7575 };
7676
7777 /**

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