i2c: mux: Add i2c-arbitrator-cros-ec 'mux' driver
Subsystems (5)
PATCH v2 1/3 i2c: mux: Add i2c-arbitrator-cros-ec 'mux' driver
The i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
---
Changes in v2:
- Renamed to i2c-arbitrator-cros-ec.
- Documented "microsecond" properties as optional; removed "bus-arbitration" prefix since it was just extra wordy.
- Split GPIOs into two properties to make it cleaner.
- Capitalized I2C in freeform text.
- Get GPIO active_low from device tree.
.../bindings/i2c/i2c-arbitrator-cros-ec.txt | 76 +++++++ drivers/i2c/muxes/Kconfig | 11 + drivers/i2c/muxes/Makefile | 2 + drivers/i2c/muxes/i2c-arbitrator-cros-ec.c | 232 +++++++++++++++++++++ 4 files changed, 321 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt create mode 100644 drivers/i2c/muxes/i2c-arbitrator-cros-ec.c
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt new file +76 -0
@@ -0,0 +1,76 @@ +GPIO-based Arbitration used by the ARM Chromebook (exynos5250-snow) +=================================================================== +This uses GPIO lines between the AP (Application Processor) and an attached +EC (Embedded Controller) which both want to talk on the same I2C bus as master. + +The AP and EC each have a 'bus claim' line, which is an output that the +other can see. These are both active low, with pull-ups enabled. + +- AP_CLAIM: output from AP, signalling to the EC that the AP wants the bus +- EC_CLAIM: output from EC, signalling to the AP that the EC wants the bus + +This mechanism is used instead of standard I2C multimaster to avoid some of the +subtle driver and silicon bugs that are often present with I2C multimaster. + + +Algorithm: + +The basic algorithm is to assert your line when you want the bus, then make +sure that the other side doesn't want it also. A detailed explanation is best +done with an example. + +Let's say the AP wants to claim the bus. It: +1. Asserts AP_CLAIM. +2. Waits a little bit for the other side to notice (slew time, say 10 + microseconds). +3. Checks EC_CLAIM. If this is not asserted then the AP has the bus and we are + done. +4. Otherwise, wait for a few milliseconds and see if EC_CLAIM is released. +5. If not, back off, release the claim and wait for a few more milliseconds. +6. Go back to 1 (until retry time has expired). + + +Required properties: +- compatible: i2c-arbitrator-cros-ec +- ap-claim-gpio: The GPIO that we (the AP) use to claim the bus. +- ec-claim-gpio: The GPIO that the other side (the EC) uses the claim the bus. +- Standard I2C mux properties. See mux.txt in this directory. +- Single I2C child bus node at reg 0. See mux.txt in this directory. + +Optional properties: +- slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us. +- wait-retry-us: we'll attempt another claim after this many microseconds. + Default is 3000 us. +- wait-free-us: we'll give up after this many microseconds. Default is 50000 us. + + +Example: + i2c@12CA0000 { + compatible = "acme,some-i2c-device"; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c-arbitrator { + compatible = "i2c-arbitrator-cros-ec"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + ap-claim-gpio = <&gpf0 3 1 0x10000 0>; + ec-claim-gpio = <&gpe0 4 0 0x10003 0>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + i2c@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + i2c@52 { + // Normal I2C device + }; + }; + };
drivers/i2c/muxes/Kconfig +11 -0
@@ -5,6 +5,17 @@ menu "Multiplexer I2C Chip support" depends on I2C_MUX +config I2C_ARBITRATOR_CROS_EC + tristate "GPIO-based I2C arbitrator used on exynos5250-snow" + depends on GENERIC_GPIO && OF + help + If you say yes to this option, support will be included for an + I2C multimaster arbitration scheme using GPIOs that is used in + the Samsung ARM Chromebook (exynos5250-snow). + + This driver can also be built as a module. If so, the module + will be called i2c-arbitrator-cros-ec. + config I2C_MUX_GPIO tristate "GPIO-based I2C multiplexer" depends on GENERIC_GPIO
drivers/i2c/muxes/Makefile +2 -0
@@ -1,6 +1,8 @@ # # Makefile for multiplexer I2C chip drivers. +obj-$(CONFIG_I2C_ARBITRATOR_CROS_EC) += i2c-arbitrator-cros-ec.o + obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c new file +232 -0
232 lines not on this page · raw message
Signature · 1 line
1.8.1
PATCH v2 2/3 ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
---
Changes in v2:
- Use new device tree property names / compatible string.
- Include that the GPIOs for arbitration are active low.
arch/arm/boot/dts/cros5250-common.dtsi | 5 ++++- arch/arm/boot/dts/exynos5250-snow.dts | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
arch/arm/boot/dts/cros5250-common.dtsi +4 -1
@@ -58,7 +58,10 @@ }; i2c at 12CA0000 { - status = "disabled"; + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; + gpios = <&gpa2 0 3 3 0>, + <&gpa2 1 3 3 0>; }; i2c at 12CB0000 {
arch/arm/boot/dts/exynos5250-snow.dts +25 -0
@@ -16,6 +16,10 @@ model = "Google Snow"; compatible = "google,snow", "samsung,exynos5250"; + aliases { + i2c104 = &i2c_104; + }; + gpio-keys { compatible = "gpio-keys";
@@ -29,6 +33,27 @@ }; }; + i2c-arbitrator { + compatible = "i2c-arbitrator-cros-ec"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + ap-claim-gpio = <&gpf0 3 1 0x10000 0>; + ec-claim-gpio = <&gpe0 4 0 0x10003 0>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + /* Use ID 104 as a hint that we're on physical bus 4 */ + i2c_104: i2c at 0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + /* * On Snow we've got SIP WiFi and so can keep drive strengths low to * reduce EMI.
Signature · 1 line
1.8.1
PATCH v2 3/3 ARM: dts: Add sbs-battery for exynos5250-snow
In reply to Doug AndersonNow that we have i2c-arbitrator in place on bus 4 we can add the sbs-battery driver. Future devices will be added onto bus 4 once drivers are in good shape.
---
Changes in v2: None
arch/arm/boot/dts/exynos5250-snow.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/exynos5250-snow.dts +6 -0
@@ -51,6 +51,12 @@ reg = <0>; #address-cells = <1>; #size-cells = <0>; + + battery: sbs-battery at b { + compatible = "sbs,sbs-battery"; + reg = <0xb>; + sbs,poll-retry-count = <1>; + }; }; };
Signature · 1 line
1.8.1
Quoted 12 lines · Doug Anderson
The i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 146
Quoted 6 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +4
-0+static int i2c_arbitrator_probe (struct platform_device *pdev) + arb->parent = of_find_i2c_adapter_by_node(parent_np); +if (WARN_ON (!arb->parent)) +return -EINVAL ;
I think for all error paths after this point, a call to i2c_put_adapter() is needed.
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 151
Quoted 4 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +4
-0+/* Request GPIOs */ + ret =of_get_named_gpio_flags (np,"ap-claim-gpio" ,0 , &gpio_flags); +if (WARN_ON (!gpio_is_valid (ret))) +return ret;
You shouldn't warn in all cases; -EPROBE_DEFER can quite legitimately happen and only temporarily prevents probe() - it's retried later.
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 152
Quoted 1 line
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +1
-0+ arb->ap_gpio = ret;
Nit: Perhaps simply assign arb->ap_gpio directly from the of_get_named_gpio_flags call? It would make that call slightly clearer.
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 155
Quoted 3 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +3
-0+ arb->ap_gpio_release = !!(gpio_flags &OF_GPIO_ACTIVE_LOW ); + out_init = (gpio_flags &OF_GPIO_ACTIVE_LOW ) ? +GPIOF_OUT_INIT_HIGH :GPIOF_OUT_INIT_LOW ;
Nit: I'd be tempted to test arb->ap_gpio_release here, rather than extracting the value from the flags again. Semantically equivalent, but it seems to slightly more directly show why it's being tested.
Quoted 1 line
+subsys_initcall(i2c_arbitrator_init);
You mentioned that you only saw problems using module_init/module_platform_driver in your downstream tree, so the problem doesn't affect upstream. Presumably those problems would be fixed when upstreaming any other drivers into the mainline kernel. I'd still be tempted to just use module_platform_driver here. But, I guess I'm fine with the patch either way; I'll leave the call to Wolfram.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Stephen,
New version will come shortly with fixes below...
Quoted 14 lines · Stephen Warren
Quoted 12 lines · Doug Anderson
The i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +0
-0
Quoted 8 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 146
Quoted 5 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +4
-0+static int i2c_arbitrator_probe (struct platform_device *pdev) + arb->parent = of_find_i2c_adapter_by_node(parent_np); +if (WARN_ON (!arb->parent)) +return -EINVAL ;I think for all error paths after this point, a call to
i2c_put_adapter()is needed.
Right. I messed that up when I reworked. I'll reorder this one to last since it's the only one that needs cleanup. Thanks for catching!
Quoted 7 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 151
Quoted 4 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +4
-0+/* Request GPIOs */ + ret =of_get_named_gpio_flags (np,"ap-claim-gpio" ,0 , &gpio_flags); +if (WARN_ON (!gpio_is_valid (ret))) +return ret;You shouldn't warn in all cases; -EPROBE_DEFER can quite legitimately happen and only temporarily prevents
probe()- it's retried later.
Done.
Quoted 4 lines
Quoted 1 line
+
arb->ap_gpio= ret;Nit: Perhaps simply assign
arb->ap_gpiodirectly from theof_get_named_gpio_flagscall? It would make that call slightly clearer.
With the addition of checks for -EPROBE_DEFER this causes several line wraps including the "if" test so not doing.
Quoted 7 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 155
Quoted 3 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +3
-0+ arb->ap_gpio_release = !!(gpio_flags &OF_GPIO_ACTIVE_LOW ); + out_init = (gpio_flags &OF_GPIO_ACTIVE_LOW ) ? +GPIOF_OUT_INIT_HIGH :GPIOF_OUT_INIT_LOW ;Nit: I'd be tempted to test
arb->ap_gpio_releasehere, rather than extracting the value from the flags again. Semantically equivalent, but it seems to slightly more directly show why it's being tested.
I wrote it both ways and decided I liked this way better. IMHO the symmetry between the ec_gpio_release code and the ap_gpio_release code is worth the extra test. ...but I can see both sides of the argument so will change it if you wish.
Quoted 8 lines
Quoted 1 line
+subsys_initcall(i2c_arbitrator_init);
You mentioned that you only saw problems using module_init/module_platform_driver in your downstream tree, so the problem doesn't affect upstream. Presumably those problems would be fixed when upstreaming any other drivers into the mainline kernel. I'd still be tempted to just use
module_platform_driverhere. But, I guess I'm fine with the patch either way; I'll leave the call to Wolfram.
I take it you thought my "since this provides a bus it should be a subsystem" argument was BS? It seems like the "it needs to be this way for correctness" is a pretty weak argument, but even if we fix the other problems it still seems like it is more ideal for bus providers to be registered as subsystems just to avoid defers (so you get a faster boot).
If it will make the patch more palatable I'll move it to module_platform_driver() and we'll figure out how to make it work.
-Doug
A message that is not in the archive (sent off-list or not yet received): CAD=FV=W9WwSsid_KqtDRmAkFXnneRXu5zcakDB3t4hLhOpuCtw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 12 lines · Doug Anderson
Stephen,
New version will come shortly with fixes below...
Quoted 6 lines · Stephen Warren
Quoted 5 lines · Doug Anderson
The i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
...
Quoted 11 lines
Quoted 8 lines
Quoted 1 line
+subsys_initcall(i2c_arbitrator_init);
You mentioned that you only saw problems using module_init/module_platform_driver in your downstream tree, so the problem doesn't affect upstream. Presumably those problems would be fixed when upstreaming any other drivers into the mainline kernel. I'd still be tempted to just use
module_platform_driverhere. But, I guess I'm fine with the patch either way; I'll leave the call to Wolfram.I take it you thought my "since this provides a bus it should be a subsystem" argument was BS?
I think subsystem and bus are different things. A driver for a specific device provides a bus, and happens to use the facilities (or be part of) a specific subsystem. Generally the subsystem isn't actually the bus itself (although perhaps something like PCI could be an exception).
Admittedly I have no history/experience really with what the different initcall levels are really intended for, but my suspicion is that subsys_initcall is intended for whole subsystems to initialize their infra-structure before handling drivers or serving requests out to other code. But, who knows.
Either way though, I believe that upstream, no driver should be relying on specific initcall levels in order to get dependencies/initialization ordering correct.
Quoted 3 lines · Stephen Warren
Either way though, I believe that upstream, no driver should be relying on specific initcall levels in order to get dependencies/initialization ordering correct.
Right, in the past we did bodges like this but in the glorious new present where deferred probing is available it shouldn't be needed any more except for a few fun cases like cpufreq that are outside the device model.
A message that is not in the archive (sent off-list or not yet received): 20130215174425.GF22283-yzvPICuk2AATkU/[email protected]
Quoted 10 lines · Mark Brown
Quoted 3 lines · Stephen Warren
Either way though, I believe that upstream, no driver should be relying on specific initcall levels in order to get dependencies/initialization ordering correct.
Right, in the past we did bodges like this but in the glorious new present where deferred probing is available it shouldn't be needed any more except for a few fun cases like cpufreq that are outside the device model.
OK, thanks to all. I will submit with module_platform_driver() shortly.
PATCH v3 1/3 i2c: mux: Add i2c-arbitrator-cros-ec 'mux' driver
In reply to Doug AndersonThe i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
---
Changes in v3:
- Handle of_find_i2c_adapter_by_node() failure more properly by changing init order.
- Don't warn on -EPROBE_DEFER from calls that could return it.
- Move to module_platform_driver(). As we pull in parts of the system that rely on devices under this i2c bus we'll need to make sure they can handle the fact that they'll be initted later now.
Changes in v2:
- Renamed to i2c-arbitrator-cros-ec.
- Documented "microsecond" properties as optional; removed "bus-arbitration" prefix since it was just extra wordy.
- Split GPIOs into two properties to make it cleaner.
- Capitalized I2C in freeform text.
- Get 'active low' from device tree.
.../bindings/i2c/i2c-arbitrator-cros-ec.txt | 76 +++++++ drivers/i2c/muxes/Kconfig | 11 + drivers/i2c/muxes/Makefile | 2 + drivers/i2c/muxes/i2c-arbitrator-cros-ec.c | 222 +++++++++++++++++++++ 4 files changed, 311 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt create mode 100644 drivers/i2c/muxes/i2c-arbitrator-cros-ec.c
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt new file +76 -0
@@ -0,0 +1,76 @@ +GPIO-based Arbitration used by the ARM Chromebook (exynos5250-snow) +=================================================================== +This uses GPIO lines between the AP (Application Processor) and an attached +EC (Embedded Controller) which both want to talk on the same I2C bus as master. + +The AP and EC each have a 'bus claim' line, which is an output that the +other can see. These are both active low, with pull-ups enabled. + +- AP_CLAIM: output from AP, signalling to the EC that the AP wants the bus +- EC_CLAIM: output from EC, signalling to the AP that the EC wants the bus + +This mechanism is used instead of standard I2C multimaster to avoid some of the +subtle driver and silicon bugs that are often present with I2C multimaster. + + +Algorithm: + +The basic algorithm is to assert your line when you want the bus, then make +sure that the other side doesn't want it also. A detailed explanation is best +done with an example. + +Let's say the AP wants to claim the bus. It: +1. Asserts AP_CLAIM. +2. Waits a little bit for the other side to notice (slew time, say 10 + microseconds). +3. Checks EC_CLAIM. If this is not asserted then the AP has the bus and we are + done. +4. Otherwise, wait for a few milliseconds and see if EC_CLAIM is released. +5. If not, back off, release the claim and wait for a few more milliseconds. +6. Go back to 1 (until retry time has expired). + + +Required properties: +- compatible: i2c-arbitrator-cros-ec +- ap-claim-gpio: The GPIO that we (the AP) use to claim the bus. +- ec-claim-gpio: The GPIO that the other side (the EC) uses the claim the bus. +- Standard I2C mux properties. See mux.txt in this directory. +- Single I2C child bus node at reg 0. See mux.txt in this directory. + +Optional properties: +- slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us. +- wait-retry-us: we'll attempt another claim after this many microseconds. + Default is 3000 us. +- wait-free-us: we'll give up after this many microseconds. Default is 50000 us. + + +Example: + i2c@12CA0000 { + compatible = "acme,some-i2c-device"; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c-arbitrator { + compatible = "i2c-arbitrator-cros-ec"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + ap-claim-gpio = <&gpf0 3 1 0x10000 0>; + ec-claim-gpio = <&gpe0 4 0 0x10003 0>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + i2c@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + i2c@52 { + // Normal I2C device + }; + }; + };
drivers/i2c/muxes/Kconfig +11 -0
@@ -5,6 +5,17 @@ menu "Multiplexer I2C Chip support" depends on I2C_MUX +config I2C_ARBITRATOR_CROS_EC + tristate "GPIO-based I2C arbitrator used on exynos5250-snow" + depends on GENERIC_GPIO && OF + help + If you say yes to this option, support will be included for an + I2C multimaster arbitration scheme using GPIOs that is used in + the Samsung ARM Chromebook (exynos5250-snow). + + This driver can also be built as a module. If so, the module + will be called i2c-arbitrator-cros-ec. + config I2C_MUX_GPIO tristate "GPIO-based I2C multiplexer" depends on GENERIC_GPIO
drivers/i2c/muxes/Makefile +2 -0
@@ -1,6 +1,8 @@ # # Makefile for multiplexer I2C chip drivers. +obj-$(CONFIG_I2C_ARBITRATOR_CROS_EC) += i2c-arbitrator-cros-ec.o + obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c new file +222 -0
222 lines not on this page · raw message
Signature · 1 line
1.8.1
PATCH v3 2/3 ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
---
Changes in v3: None
Changes in v2:
- Use new device tree property names / compatible string.
- Include that the GPIOs for arbitration are active low.
arch/arm/boot/dts/cros5250-common.dtsi | 5 ++++- arch/arm/boot/dts/exynos5250-snow.dts | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)
arch/arm/boot/dts/cros5250-common.dtsi +4 -1
@@ -58,7 +58,10 @@ }; i2c at 12CA0000 { - status = "disabled"; + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; + gpios = <&gpa2 0 3 3 0>, + <&gpa2 1 3 3 0>; }; i2c at 12CB0000 {
arch/arm/boot/dts/exynos5250-snow.dts +25 -0
@@ -16,6 +16,10 @@ model = "Google Snow"; compatible = "google,snow", "samsung,exynos5250"; + aliases { + i2c104 = &i2c_104; + }; + gpio-keys { compatible = "gpio-keys";
@@ -29,6 +33,27 @@ }; }; + i2c-arbitrator { + compatible = "i2c-arbitrator-cros-ec"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + ap-claim-gpio = <&gpf0 3 1 0x10000 0>; + ec-claim-gpio = <&gpe0 4 0 0x10003 0>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + /* Use ID 104 as a hint that we're on physical bus 4 */ + i2c_104: i2c at 0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + /* * On Snow we've got SIP WiFi and so can keep drive strengths low to * reduce EMI.
Signature · 1 line
1.8.1
Re: [PATCH v3 2/3] ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
Quoted 6 lines · Doug Anderson
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
Quoted 8 lines
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
Signed-off-by Doug Anderson <[email protected]>
The patch set [v3] is tested on snow with test case which uses i2c-4 from both EC and AP side continuously for a more than a couple of minutes.
Quoted 72 lines
---
Changes in v3: None
Changes in v2:
- Use new device tree property names / compatible string.
- Include that the GPIOs for arbitration are active low.arch/arm/boot/dts/cros5250-common.dtsi | 5 ++++- arch/arm/boot/dts/exynos5250-snow.dts | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)arch/arm/boot/dts/cros5250-common.dtsi +4
-1@@ -58,7 +58,10 @@ }; i2c at 12CA0000 { - status = "disabled"; + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; + gpios = <&gpa2 0 3 3 0>, + <&gpa2 1 3 3 0>; }; i2c at 12CB0000 {arch/arm/boot/dts/exynos5250-snow.dts +25
-1@@ -16,6 +16,10 @@ model = "Google Snow"; compatible = "google,snow", "samsung,exynos5250"; + aliases { + i2c104 = &i2c_104; + }; + gpio-keys { compatible = "gpio-keys";@@ -29,6 +33,27 @@ }; }; + i2c-arbitrator { + compatible = "i2c-arbitrator-cros-ec"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + ap-claim-gpio = <&gpf0 3 1 0x10000 0>; + ec-claim-gpio = <&gpe0 4 0 0x10003 0>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + /* Use ID 104 as a hint that we're on physical bus 4 */ + i2c_104: i2c at 0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + /* * On Snow we've got SIP WiFi and so can keep drive strengths low to * reduce EMI. --1.8.1
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
--
Shine bright,
(: Nav :)
RE: [PATCH v3 2/3] ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
Quoted 11 lines · Naveen Krishna Ch
Quoted 10 lines · Doug Anderson
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
Quoted 8 lines
Quoted 4 lines
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
Signed-off-by Doug Anderson <[email protected]>The patch set [v3] is tested on snow with test case which uses i2c-4 from both EC and AP side continuously for a more than a couple of minutes.
Thanks for your test and looks good to me.
BTW, Doug, I think, this should be re-worked to use pinctrl. Can you?
Thanks.
- Kukjin
Quoted 85 lines
Review
Quoted 11 lines
---
Changes in v3: None
Changes in v2:
- Use new device tree property names / compatible string.
- Include that the GPIOs for arbitration are active low.arch/arm/boot/dts/cros5250-common.dtsi | 5 ++++- arch/arm/boot/dts/exynos5250-snow.dts | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/arch/arm/boot/dts/cros5250-common.dtsiReview
Quoted 16 lines
index 46c0980..f451375 100644
arch/arm/boot/dts/cros5250-common.dtsi +4
-1@@ -58,7 +58,10 @@ }; i2c at 12CA0000 { - status = "disabled"; + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; + gpios = <&gpa2 0 3 3 0>, + <&gpa2 1 3 3 0>; }; i2c at 12CB0000 {(quoted diff) +0
-0
b/arch/arm/boot/dts/exynos5250-snow.dtsQuoted 45 lines
index 17dd951..d2d4b48 100644
arch/arm/boot/dts/exynos5250-snow.dts +25
-1@@ -16,6 +16,10 @@ model = "Google Snow"; compatible = "google,snow", "samsung,exynos5250"; + aliases { + i2c104 = &i2c_104; + }; + gpio-keys { compatible = "gpio-keys";@@ -29,6 +33,27 @@ }; }; + i2c-arbitrator { + compatible = "i2c-arbitrator-cros-ec"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + ap-claim-gpio = <&gpf0 3 1 0x10000 0>; + ec-claim-gpio = <&gpe0 4 0 0x10003 0>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + /* Use ID 104 as a hint that we're on physical bus 4 */ + i2c_104: i2c at 0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + /* * On Snow we've got SIP WiFi and so can keep drive strengths low to * reduce EMI. --1.8.1
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
Shine bright,
(: Nav :)
Re: [PATCH v3 2/3] ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
Kukjin,
Quoted 1 line · Kukjin Kim
BTW, Doug, I think, this should be re-worked to use pinctrl. Can you?
Yes, I've already got this locally. I hadn't sent it up yet since I wasn't sure whether pinctrl would land before or after this. I'll send it up today against my local cherry-pick of Thomas's pinctrl stuff (since it doesn't seem to be in linux-next nor in arm-soc/for-next).
Naveen: I'm going to keep your Tested-by on all 3 patches if that's OK. The only difference will be the gpio specifier in the device tree and the change is trivial.
-Doug
PATCH v3 3/3 ARM: dts: Add sbs-battery for exynos5250-snow
In reply to Doug AndersonNow that we have i2c-arbitrator in place on bus 4 we can add the sbs-battery driver. Future devices will be added onto bus 4 once drivers are in good shape.
---
Changes in v3: None
Changes in v2: None
arch/arm/boot/dts/exynos5250-snow.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/exynos5250-snow.dts +6 -0
@@ -51,6 +51,12 @@ reg = <0>; #address-cells = <1>; #size-cells = <0>; + + battery: sbs-battery at b { + compatible = "sbs,sbs-battery"; + reg = <0xb>; + sbs,poll-retry-count = <1>; + }; }; };
Signature · 1 line
1.8.1
Re: [PATCH v3 3/3] ARM: dts: Add sbs-battery for exynos5250-snow
Quoted 5 lines · Doug Anderson
Now that we have i2c-arbitrator in place on bus 4 we can add the sbs-battery driver. Future devices will be added onto bus 4 once drivers are in good shape.
Signed-off-by Doug Anderson <[email protected]>
The patchset v3 is tested on snow with test case which uses i2c-4 from both EC and AP side continuously for a more than a couple of minutes
Quoted 27 lines
---
Changes in v3: None
Changes in v2: Nonearch/arm/boot/dts/exynos5250-snow.dts | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm/boot/dts/exynos5250-snow.dts +6
-1@@ -51,6 +51,12 @@ reg = <0>; #address-cells = <1>; #size-cells = <0>; + + battery: sbs-battery at b { + compatible = "sbs,sbs-battery"; + reg = <0xb>; + sbs,poll-retry-count = <1>; + }; }; }; --1.8.1
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
--
Shine bright,
(: Nav :)
Quoted 10 lines · Doug Anderson
The i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 143
Quoted 8 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +5
-0+static int i2c_arbitrator_probe (struct platform_device *pdev) +/* Request GPIOs */ + ret =of_get_named_gpio_flags (np,"ap-claim-gpio" ,0 , &gpio_flags); +if (ret == -EPROBE_DEFER ||WARN_ON (!gpio_is_valid (ret))) +return ret;
I think by the time that doesn't return -EPROBE_DEFER ...
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 151
Quoted 8 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c +8
-0+ arb->ap_gpio = ret; + arb->ap_gpio_release = !!(gpio_flags &OF_GPIO_ACTIVE_LOW ); + out_init = (gpio_flags &OF_GPIO_ACTIVE_LOW ) ? +GPIOF_OUT_INIT_HIGH :GPIOF_OUT_INIT_LOW ; + ret =devm_gpio_request_one (&pdev->dev, arb->ap_gpio, out_init, +"ap-claim-gpio" ); +if (ret == -EPROBE_DEFER ||WARN_ON (ret)) +return ret;
... that won't either, since of_get_named_gpio_flags()'s implementation requires the relevant GPIO driver to be active already.
Still, there's no harm in the code as it stands, so no need to change.
Wolfram,
Quoted 31 lines · Doug Anderson
The i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.Signed-off-by Doug Anderson <[email protected]>Signed-off-by Simon Glass <[email protected]>Signed-off-by Naveen Krishna Chatradhi <[email protected]>---
Changes in v3:
- Handleof_find_i2c_adapter_by_node()failure more properly by changing init order.
- Don't warn on -EPROBE_DEFER from calls that could return it.
- Move tomodule_platform_driver(). As we pull in parts of the system that rely on devices under this i2c bus we'll need to make sure they can handle the fact that they'll be initted later now.Changes in v2:
- Renamed to i2c-arbitrator-cros-ec.
- Documented "microsecond" properties as optional; removed "bus-arbitration" prefix since it was just extra wordy.
- Split GPIOs into two properties to make it cleaner.
- Capitalized I2C in freeform text.
- Get 'active low' from device tree.
Quoted 7 lines
.../bindings/i2c/i2c-arbitrator-cros-ec.txt | 76 +++++++ drivers/i2c/muxes/Kconfig | 11 + drivers/i2c/muxes/Makefile | 2 + drivers/i2c/muxes/i2c-arbitrator-cros-ec.c | 222 +++++++++++++++++++++ 4 files changed, 311 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt create mode 100644 drivers/i2c/muxes/i2c-arbitrator-cros-ec.c
Is there anything you'd like done before landing this patch for 3.10? It's been reviewed by Stephen Warren (thanks Stephen!). From what I remember from Olof's talk at ELC it seems like the best thing would be to merge part 1 through i2c tree and then ask Olof to merge parts 2 and 3 (the dts bits) through the arm-soc tree.
I believe you could also add a "Tested-by" from Naveen to patch #1. He sent a tested by for parts 2 and 3 so must have also tested part 1 (the other two don't function without it).
Please let me know--I'm happy to spin with any changes needed. :)
-Doug
PATCH v4 1/3 i2c: mux: Add i2c-arbitrator-cros-ec 'mux' driver
In reply to Doug AndersonThe i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
---
Changes in v4: None
Changes in v3:
- Handle of_find_i2c_adapter_by_node() failure more properly by changing init order.
- Don't warn on -EPROBE_DEFER from calls that could return it.
- Move to module_platform_driver(). As we pull in parts of the system that rely on devices under this i2c bus we'll need to make sure they can handle the fact that they'll be initted later now.
Changes in v2:
- Renamed to i2c-arbitrator-cros-ec.
- Documented "microsecond" properties as optional; removed "bus-arbitration" prefix since it was just extra wordy.
- Split GPIOs into two properties to make it cleaner.
- Capitalized I2C in freeform text.
- Get 'active low' from device tree.
.../bindings/i2c/i2c-arbitrator-cros-ec.txt | 76 +++++++ drivers/i2c/muxes/Kconfig | 11 + drivers/i2c/muxes/Makefile | 2 + drivers/i2c/muxes/i2c-arbitrator-cros-ec.c | 222 +++++++++++++++++++++ 4 files changed, 311 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt create mode 100644 drivers/i2c/muxes/i2c-arbitrator-cros-ec.c
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt new file +76 -0
@@ -0,0 +1,76 @@ +GPIO-based Arbitration used by the ARM Chromebook (exynos5250-snow) +=================================================================== +This uses GPIO lines between the AP (Application Processor) and an attached +EC (Embedded Controller) which both want to talk on the same I2C bus as master. + +The AP and EC each have a 'bus claim' line, which is an output that the +other can see. These are both active low, with pull-ups enabled. + +- AP_CLAIM: output from AP, signalling to the EC that the AP wants the bus +- EC_CLAIM: output from EC, signalling to the AP that the EC wants the bus + +This mechanism is used instead of standard I2C multimaster to avoid some of the +subtle driver and silicon bugs that are often present with I2C multimaster. + + +Algorithm: + +The basic algorithm is to assert your line when you want the bus, then make +sure that the other side doesn't want it also. A detailed explanation is best +done with an example. + +Let's say the AP wants to claim the bus. It: +1. Asserts AP_CLAIM. +2. Waits a little bit for the other side to notice (slew time, say 10 + microseconds). +3. Checks EC_CLAIM. If this is not asserted then the AP has the bus and we are + done. +4. Otherwise, wait for a few milliseconds and see if EC_CLAIM is released. +5. If not, back off, release the claim and wait for a few more milliseconds. +6. Go back to 1 (until retry time has expired). + + +Required properties: +- compatible: i2c-arbitrator-cros-ec +- ap-claim-gpio: The GPIO that we (the AP) use to claim the bus. +- ec-claim-gpio: The GPIO that the other side (the EC) uses the claim the bus. +- Standard I2C mux properties. See mux.txt in this directory. +- Single I2C child bus node at reg 0. See mux.txt in this directory. + +Optional properties: +- slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us. +- wait-retry-us: we'll attempt another claim after this many microseconds. + Default is 3000 us. +- wait-free-us: we'll give up after this many microseconds. Default is 50000 us. + + +Example: + i2c@12CA0000 { + compatible = "acme,some-i2c-device"; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c-arbitrator { + compatible = "i2c-arbitrator-cros-ec"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + ap-claim-gpio = <&gpf0 3 1 0x10000 0>; + ec-claim-gpio = <&gpe0 4 0 0x10003 0>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + i2c@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + i2c@52 { + // Normal I2C device + }; + }; + };
drivers/i2c/muxes/Kconfig +11 -0
@@ -5,6 +5,17 @@ menu "Multiplexer I2C Chip support" depends on I2C_MUX +config I2C_ARBITRATOR_CROS_EC + tristate "GPIO-based I2C arbitrator used on exynos5250-snow" + depends on GENERIC_GPIO && OF + help + If you say yes to this option, support will be included for an + I2C multimaster arbitration scheme using GPIOs that is used in + the Samsung ARM Chromebook (exynos5250-snow). + + This driver can also be built as a module. If so, the module + will be called i2c-arbitrator-cros-ec. + config I2C_MUX_GPIO tristate "GPIO-based I2C multiplexer" depends on GENERIC_GPIO
drivers/i2c/muxes/Makefile +2 -0
@@ -1,6 +1,8 @@ # # Makefile for multiplexer I2C chip drivers. +obj-$(CONFIG_I2C_ARBITRATOR_CROS_EC) += i2c-arbitrator-cros-ec.o + obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c new file +222 -0
222 lines not on this page · raw message
Signature · 1 line
1.8.1.3
PATCH v4 2/3 ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
---
Changes in v4:
- Changed mux gpio syntax to work atop Thomas's "ARM: dts: add pin state information in client nodes for Exynos5 platforms"; avoid adding gpios property to i2c at 12CA0000 for the same reason.
Changes in v3: None
Changes in v2:
- Use new device tree property names / compatible string.
- Include that the GPIOs for arbitration are active low.
arch/arm/boot/dts/cros5250-common.dtsi | 3 ++- arch/arm/boot/dts/exynos5250-snow.dts | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-)
arch/arm/boot/dts/cros5250-common.dtsi +2 -1
@@ -193,7 +193,8 @@ }; i2c at 12CA0000 { - status = "disabled"; + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; }; i2c at 12CB0000 {
arch/arm/boot/dts/exynos5250-snow.dts +25 -0
@@ -16,6 +16,10 @@ model = "Google Snow"; compatible = "google,snow", "samsung,exynos5250"; + aliases { + i2c104 = &i2c_104; + }; + pinctrl at 11400000 { sd3_clk: sd3-clk { samsung,pin-drv = <0>;
@@ -44,6 +48,27 @@ }; }; + i2c-arbitrator { + compatible = "i2c-arbitrator-cros-ec"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + ap-claim-gpio = <&gpf0 3 1>; + ec-claim-gpio = <&gpe0 4 1>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + /* Use ID 104 as a hint that we're on physical bus 4 */ + i2c_104: i2c at 0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + /* * On Snow we've got SIP WiFi and so can keep drive strengths low to * reduce EMI.
Signature · 1 line
1.8.1.3
PATCH v4 3/3 ARM: dts: Add sbs-battery for exynos5250-snow
In reply to Doug AndersonNow that we have i2c-arbitrator in place on bus 4 we can add the sbs-battery driver. Future devices will be added onto bus 4 once drivers are in good shape.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/arm/boot/dts/exynos5250-snow.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/exynos5250-snow.dts +6 -0
@@ -66,6 +66,12 @@ reg = <0>; #address-cells = <1>; #size-cells = <0>; + + battery: sbs-battery at b { + compatible = "sbs,sbs-battery"; + reg = <0xb>; + sbs,poll-retry-count = <1>; + }; }; };
Signature · 1 line
1.8.1.3
Quoted 10 lines · Doug Anderson
The i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
...
Quoted 1 line
Changes in v4: None
Isn't this 'PATCH V3 REPOST' then?
Stephen,
Quoted 3 lines · Stephen Warren
Quoted 1 line
Changes in v4: None
Isn't this 'PATCH V3 REPOST' then?
In this case part 2 in the patch series changes but not parts 1 and 3.
I could have just reposted part 2 with a higher version, but that
makes it a little harder to piece together all of the parts of the series so I decided to repost all 3. I can do differently in the future if you prefer, but my understanding was that it was a matter of preference/judgement call.
Thanks! :)
-Doug
Quoted 5 lines · Doug Anderson
Stephen,
Quoted 2 lines · Stephen Warren
Quoted 1 line
Changes in v4: None
Quoted 8 lines
Quoted 1 line
Isn't this 'PATCH V3 REPOST' then?
In this case part 2 in the patch series changes but not parts 1 and 3.
I could have just reposted part 2 with a higher version, but that
makes it a little harder to piece together all of the parts of the series so I decided to repost all 3. I can do differently in the future if you prefer, but my understanding was that it was a matter of preference/judgement call.
Oh no you're quite right. I didn't notice it was a 3-part series, since I only got patch 1/3 filtered into my inbox; I guess I wasn't CC'd on the rest. Sorry for the noise.
A message that is not in the archive (sent off-list or not yet received): 1363192583-26363-1-git-send-email-dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
Wolfram,
Quoted 34 lines · Doug Anderson
The i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.Signed-off-by Doug Anderson <[email protected]>Signed-off-by Simon Glass <[email protected]>Signed-off-by Naveen Krishna Chatradhi <[email protected]>Reviewed-by Stephen Warren <[email protected]>---
Changes in v4: None
Changes in v3:
- Handleof_find_i2c_adapter_by_node()failure more properly by changing init order.
- Don't warn on -EPROBE_DEFER from calls that could return it.
- Move tomodule_platform_driver(). As we pull in parts of the system that rely on devices under this i2c bus we'll need to make sure they can handle the fact that they'll be initted later now.Changes in v2:
- Renamed to i2c-arbitrator-cros-ec.
- Documented "microsecond" properties as optional; removed "bus-arbitration" prefix since it was just extra wordy.
- Split GPIOs into two properties to make it cleaner.
- Capitalized I2C in freeform text.
- Get 'active low' from device tree.
Quoted 5 lines
.../bindings/i2c/i2c-arbitrator-cros-ec.txt | 76 +++++++ drivers/i2c/muxes/Kconfig | 11 + drivers/i2c/muxes/Makefile | 2 + drivers/i2c/muxes/i2c-arbitrator-cros-ec.c | 222 +++++++++++++++++++++ 4 files changed, 311 insertions(+)
I'm still looking for some feedback about this patch. Should I ask another maintainer to review / pick it up or are you planning on reviewing / picking up once you have some time? The lack of this patch blocks access to quite a few important devices on the ARM Chromebook.
Note: I'd expect that "dts" parts of this patchset would be picked up by Kukjin once the main code lands.
Thanks! :)
-Doug
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20130329115821.GC6359-z923LK4zBo2bacvFa/[email protected]
Wolfram,
Quoted 4 lines · Wolfram Sang
I can't recall the reason standard I2C bus arbitration is not working and why this is needed. I need the feeling this is a solution and not a workaround. I mean driver bugs can be fixed and I am unsure if it is a good idea to open the i2c-arbitration-*.c namespace.
Thanks for the feedback!
Separately from a discussion of the technical merits, I'd say that this patch is needed because the Embedded Controller (EC) on the ARM Chromebook shipped expecting to communicate with this scheme. While it is technically possible to update the read-write copy of the software on the EC, it would be prohibitively difficult to ship an update that changed the communication method. Specifically we'd still require fallback to the old scheme in cases where we need to talk to the read-only copy of the software on the EC.
...but we can also talk technical merits. One person on our team spent a bit of time thinking about this and decided that traditional i2c arbitration can't actually be used in this case (aside from the general experience about multimaster being buggy). Specifically, our bus is setup with these devices on it:
* AP (running Linux) - Master only. Only talks when awake.
* EC (running custom code) - Acts as a master and _also_ a slave.
* Battery (smart battery) - Only a slave
* Power Management Unit (PMU - tps65090) - Only a slave
Both the AP and the EC would like to talk to the battery and PMU. The AP needs to be able to talk to the EC.
The problem here is that the EC is both a master and a slave. It's my understanding that if the AP tries to talk EC on the bus at the same time that the EC is trying to talk to the battery of PMU that we can get into trouble. Specifically the EC needs to be switched to "master mode" to talk to the battery/PMU and thus has a period of time where it won't be listening for the AP's messages. The arbitration lines make it very clear that the EC has gained mastery of the bus and is free to switch into "master mode" without worrying that the AP may talk to it.
I will freely admit that I am not an expert on multimater I2C so if the above is incorrect then let me know. As I said, though, it's still useful to get this patch in because that's simply how the shipping EC expects to communicate.
Thanks! :)
-Doug
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20130403191938.GA7875-z923LK4zBo2bacvFa/[email protected]
HI Wolfram,
Quoted 13 lines · Wolfram Sang
Doug,
Quoted 3 lines
Separately from a discussion of the technical merits, I'd say that this patch is needed because the Embedded Controller (EC) on the ARM Chromebook shipped expecting to communicate with this scheme. While
Uhrm, with all respect, "we already shipped it" is not a convincing argument regarding inclusion. Benefit for the kernel is.
Quoted 3 lines
...but we can also talk technical merits. One person on our team spent a bit of time thinking about this and decided that traditional i2c arbitration can't actually be used in this case (aside from the
Quoted 8 lines
The details would be extremly interesting here. I am very interested in this and will ask a few questions further on. This is to get a better undestanding for the situation regarding multi-master and what is needed, because I expect some demand for it in the near future.
Quoted 1 line
general experience about multimaster being buggy). Specifically, our
I'm also interested in these experiences.
Thanks for coming back on this. Please see my comments below.
Quoted 6 lines
Quoted 5 lines
The problem here is that the EC is both a master and a slave. It's my understanding that if the AP tries to talk EC on the bus at the same time that the EC is trying to talk to the battery of PMU that we can get into trouble.
Quoted 6 lines
If I understand correctly, the I2C Specs mention this case explicitly:
"If a master also incorporates a slave function and it loses arbitration during the addressing stage, it is possible that the winning master is trying to address it. The losing master must therefore switch over immediately to its slave mode."
This seems pretty complicated - does the EC then need to compare the address it was sending with the remaining bits that are to be received in that address?
Anyway yes we did consider this case at the time, and the STM32 datasheet had mention of it. But it adds quite a bit of complexity. I think the start sequence is intended to make this all work, at least in theory, but it seemed risky to rely on it.
The practical problem here is that in my experience the I2C multi-master feature is lightly used in practice, and is quite tricky to get right. That experience was shared with other engineers in the team, and no one was willing to take the risk on getting everything running perfectly with i2c multi-master, or doing it on a tight timeline. I suspect this same problem has arisen many times before, and will arise again, so from that point of view this feature is a useful addition to the kernel.
If you are interested in specific experiences then I might be able to collect some comments from people here. For myself I have found that getting a reliable I2C driver at all is a sufficient challenge and time sink with many embedded chips. My memory is a little vague now, but I know that in 2-3 projects we had to use bit-bash due to bugs or insufficient documentation in the chip's dedicated I2C peripheral. One project which had multi-master used a retry scheme with sequenced packets which seemed to work well enough (i.e. adding a layer above the I2C layer to sort out problems). The snow project was more challenging on the I2C ront, due to the critical nature of I2C buses in the device.
For snow we found that the Exynos driver did not support arbitration loss, the STM32 driver we had did not support it, the STM32F I2C errata indicated problems with I2C in general which reduced our confidence, and we were unable to determine whether the slave devices on the bus (smart battery and pmic) would definitely do the right thing (both chips had I2C issues which we were tracking). I am not trying to point fingers here, and certainly anything can be solved given sufficient persistence...but keeping to common features that are well-tested and available is prudent. As it was we spent more time on I2C drivers than I would like, and you can get a feel for that in the Chromium bug tracker if you wish.
Again, I don't believe this would be an unusual situation in a product development. We need to consider the risk and cost of an approach, rather than just whether it is technically possible.
Quoted 1 line
From the point of view of arbitration, the two critical points in the
I2C transfer are claiming the bus (detecting that the start condition failed) and detecting loss of arbitration during a transfer. These points need to be tested and validated on all master devices, which can add a considerable burden. Silicon and driver bugs may make this even more onerous and in fact for some non-compliant implementations it simply might not work, or might not work reliably.
Please don't take this as a negative view of I2C in general, which is an excellent bus, unmatched for what it was designed in my view.
Quoted 7 lines
Quoted 4 lines
Specifically the EC needs to be switched to "master
mode" to talk to the battery/PMU and thus has a period of time where it won't be listening for the AP's messages.When it talks to the battery, the bus is busy and the EC will not be addressed by the AP?
That's right - there is only one bus and we want to avoid contention for it.
Quoted 10 lines
Quoted 4 lines
The arbitration lines make it very clear that the EC has gained mastery of the bus and is free to switch into "master mode" without worrying that the AP may talk to it.
There is another thing I wonder: The arbitration is not I2C specific. You could use this scheme for various busses. So, besides the question if this is really needed on top of I2C arbitration, the other question is if this should reside inside the I2C kernel realm or should/could be generic.
Yes this is an interesting point! So far this feature has been added:
- in a separate 'arbitrator' driver (my original implementation, and now suggested by you)
- in the Samsung I2C driver (suggested by Olof Johansson, my second implementation)
- in the I2C core (suggested in code review I think and implemented by Naveen Chatradhi)
- as an I2C mux (suggested by Grant Likely, implemented by Doug Anderson)
So yes there are clearly a number of places where it could go and we might be going around in circles. But we should be careful to address this question based on present need rather than theoretical value. I believe there is clear value in having an I2C mux which can arbitrate between masters using an out-of-band method for the reasons explained above. Other needs and wishes should be justified on their merits when they arise.
Having a mux, which can be is set up using the device tree, is quite an attractive option. It allows the feature to be used by any I2C driver, and does not touch the core I2C code.
The present patch is a nice clean implementation IMO, and I believe it has value for the kernel.
Regards,
Simon
Quoted 11 lines · Simon Glass
HI Wolfram,
Quoted 8 lines · Wolfram Sang
Doug,
Quoted 3 lines
Separately from a discussion of the technical merits, I'd say that this patch is needed because the Embedded Controller (EC) on the ARM Chromebook shipped expecting to communicate with this scheme. While
Uhrm, with all respect, "we already shipped it" is not a convincing argument regarding inclusion. Benefit for the kernel is.
I'm not quite sure why that isn't a convincing argument.
The hardware has shipped. I don't know whether the EC microcode can be updated in the field; it seems risky to do so even if it's possible. So, it either gets supported or not; the HW/ucode isn't going to change I suspect.
Hence, it seems that the decision would be:
a) Disallow the implementation of the arbitration scheme in the kernel, and hence don't support this board in the kernel. (or at least some very core features of this board)
b) Allow the implementation of the arbitration scheme in the kernel, and hence make possible support this board in the kernel.
Quoted 1 line
From that perspective, the benefit for the kernel question comes down
to: do we see a benefit for the kernel to support this board? I can't see why that wouldn't be a benefit.
The only disadvantage would be having to carrying code to support that board. That same argument can be made for any board, and I think typically doesn't cause any issue. The code for this I2C mux seems pretty self-contained, so even if it was absolutely terrible (which I don't think it is), it still wouldn't cause any wide-spread issues, I think.
Quoted 33 lines · Stephen Warren
Quoted 11 lines · Simon Glass
HI Wolfram,
Quoted 8 lines · Wolfram Sang
Doug,
Quoted 3 lines
Separately from a discussion of the technical merits, I'd say that this patch is needed because the Embedded Controller (EC) on the ARM Chromebook shipped expecting to communicate with this scheme. While
Uhrm, with all respect, "we already shipped it" is not a convincing argument regarding inclusion. Benefit for the kernel is.
I'm not quite sure why that isn't a convincing argument.
The hardware has shipped. I don't know whether the EC microcode can be updated in the field; it seems risky to do so even if it's possible. So, it either gets supported or not; the HW/ucode isn't going to change I suspect.
Hence, it seems that the decision would be:
a) Disallow the implementation of the arbitration scheme in the kernel, and hence don't support this board in the kernel. (or at least some very core features of this board)
b) Allow the implementation of the arbitration scheme in the kernel, and hence make possible support this board in the kernel.
From that perspective, the benefit for the kernel question comes down
to: do we see a benefit for the kernel to support this board? I can't see why that wouldn't be a benefit.
Quoted 5 lines
The only disadvantage would be having to carrying code to support that board. That same argument can be made for any board, and I think typically doesn't cause any issue. The code for this I2C mux seems pretty self-contained, so even if it was absolutely terrible (which I don't think it is), it still wouldn't cause any wide-spread issues, I think.
Very interesting discussion, especially the argument that "we already shipped" would not be a convincing argument.
I had senior kernel maintainers tell me and the company I work for that we should submit _all_ our platform specific kernel code and drivers for inclusion into the upstream kernel.
This exchange suggests that "it is a shipping product" does not count for such submissions, and that "Benefit for the kernel" would be the deciding factor instead. Which of course is a very vague statement - if code supporting Chromebookis is of no benefit for the kernel, support for my company's products for sure is much less so.
Which kind of leaves me in a bind. On one side I promote that we should submit all our kernel code, on the other side there is a very compelling case to be made that it won't be accepted anyway. That doesn't make my life easier - essentially since it supports those who say that we should not submit anything in the first place. And believe me, there are many of those.
Just to give some examples:
- I2C multiplexers. We have a bunch of those. Looking at this exchange, it doesn't look good to get that code included.
- Custom multi-function FPGAs and CPLDs, amongst others implementing I2C controllers, I2C muxes, GPIO access, Flash access, and other functions. Same as above.
- Devicetree support for UIO devices (mostly forwarding ASICs), including gpio bindings, interrupt bindings, and clock bindings. Looking at older exchanges, that doesn't look good either. And please dont expect me to implement hacks around a clean solution because any devicetree binding for UIO drivers "does not describe hardware but its use".
Now, I can understand that there may be technical or architectural issues preventing one driver or another from being accepted. For example, I can understand if a driver for an USB-I2C adapder isn't accepted because the adapter reports itself to the USB subsystem as serial driver. But "Benefit for the kernel" is vague enough to reject anything for no real reason other than someone not liking it (or the submitter, or the company the submitter works for, or the hardware architecture).
It would be nice have to get some well defined guidelines for "acceptable" contributions. "Benefit for the kernel" sure isn't one.
Guenter
Hi,
Quoted 6 lines
Very interesting discussion, especially the argument that "we already shipped" would not be a convincing argument.
I had senior kernel maintainers tell me and the company I work for that we should submit _all_ our platform specific kernel code and drivers for inclusion into the upstream kernel.
Yes, great. Really!
Quoted 5 lines
This exchange suggests that "it is a shipping product" does not count for such submissions, and that "Benefit for the kernel" would be the deciding factor instead. Which of course is a very vague statement - if code supporting Chromebookis is of no benefit for the kernel, support for my company's products for sure is much less so.
First, let me state that I did not intend to say that the arbitrator muxer here has NO benefit for the kernel. I was aware there might be arguments for that and I wanted some more discussion to make that clearer to me. Simon's mail was very helpful in that regard and I will comment on that somewhen later.
Still, I do have problems with "we already shipped it". If the driver is bad or the underlying concept is fragile, I want the freedom to reject a patch, product shipped or not. I will be supportive to find a proper solution, promised. If all fails, there is still staging/ or the possibility of out-of-tree patches.
Quoted 3 lines
Which kind of leaves me in a bind. On one side I promote that we should submit all our kernel code, on the other side there is a very compelling case to be made that it won't be accepted anyway. That doesn't make my life easier -
Concentrate on argumenting why the driver is useful and it will be fine. "we already shipped this" feels a bit like blackmailing to me. And since most drivers do have well thought reasons for their existance, I'd primarily like to hear about those.
Quoted 6 lines
essentially since it supports those who say that we should not submit anything in the first place. And believe me, there are many of those.
Just to give some examples:
- I2C multiplexers. We have a bunch of those. Looking at this exchange, it doesn't look good to get that code included.
Multiplexers should be easy going, it is the arbitration which is discussed here. I am open to consider some generic arbitration schemes. What I am reluctant to do is to allow every board to have its own arbitration scheme. This would be board support hosted in the I2C directory. Meh.
Quoted 2 lines
It would be nice have to get some well defined guidelines for "acceptable" contributions. "Benefit for the kernel" sure isn't one.
I don't think it is possible to write down concrete guidelines for this. "According to rule 4a) of the guidelines you have to accept my patch"? That would be a mess, I think.
Regards,
Wolfram
Quoted 11 lines · Wolfram Sang
Hi,
Quoted 6 lines
Very interesting discussion, especially the argument that "we already shipped" would not be a convincing argument.
I had senior kernel maintainers tell me and the company I work for that we should submit _all_ our platform specific kernel code and drivers for inclusion into the upstream kernel.
Yes, great. Really!
Yes, though, thinking about it, it was "submit" and didn't say anything about potential for acceptance.
Quoted 12 lines
Quoted 5 lines
This exchange suggests that "it is a shipping product" does not count for such submissions, and that "Benefit for the kernel" would be the deciding factor instead. Which of course is a very vague statement - if code supporting Chromebookis is of no benefit for the kernel, support for my company's products for sure is much less so.
First, let me state that I did not intend to say that the arbitrator muxer here has NO benefit for the kernel. I was aware there might be arguments for that and I wanted some more discussion to make that clearer to me. Simon's mail was very helpful in that regard and I will comment on that somewhen later.
Quoted 6 lines
Still, I do have problems with "we already shipped it". If the driver is bad or the underlying concept is fragile, I want the freedom to reject a patch, product shipped or not. I will be supportive to find a proper solution, promised. If all fails, there is still staging/ or the possibility of out-of-tree patches.
I think there is a difference between a bad driver or underlying hardware. To me, "shipped" applies to hardware or firmware which can not be upgraded, not to the software running on it.
Quoted 12 lines
Quoted 3 lines
Which kind of leaves me in a bind. On one side I promote that we should submit all our kernel code, on the other side there is a very compelling case to be made that it won't be accepted anyway. That doesn't make my life easier -
Concentrate on argumenting why the driver is useful and it will be fine. "we already shipped this" feels a bit like blackmailing to me. And since most drivers do have well thought reasons for their existance, I'd primarily like to hear about those.
Quoted 3 lines
essentially since it supports those who say that we should not submit anything in the first place. And believe me, there are many of those.
Quoted 9 lines
Quoted 3 lines
Just to give some examples:
- I2C multiplexers. We have a bunch of those. Looking at this exchange, it doesn't look good to get that code included.Multiplexers should be easy going, it is the arbitration which is discussed here. I am open to consider some generic arbitration schemes. What I am reluctant to do is to allow every board to have its own arbitration scheme. This would be board support hosted in the I2C directory. Meh.
"board support hosted in the I2C directory". But that is exactly what I am talking about, isn't it ? I have board specific multiplexers and a board specific I2C controller, and that is just talking about the I2C code.
Quoted 7 lines
Quoted 2 lines
It would be nice have to get some well defined guidelines for "acceptable" contributions. "Benefit for the kernel" sure isn't one.
I don't think it is possible to write down concrete guidelines for this. "According to rule 4a) of the guidelines you have to accept my patch"? That would be a mess, I think.
Looking at it from a maintainer perspective, I agree.
Where it gets murky is really the hardware part. The (in my opinion) philosophical arguments around not permitting device-tree based instantiation of uio devices is one example. Another practical example I had to deal with in my previous company is VGA memory space. Some hw geniuses decided to re-use the VGA memory space in an embedded x86 device for an EEPROM. Guess what - the x86 kernel writes into that space no matter what. A patch to address that problem was rejected because "you should not re-use VGA memory space". As if I had a choice.
A better example might be Kontron board support. They implement gpio, I2C mux, and a watchdog in a PLD. They too have an access arbitration scheme where one has to acquire a hardware mutex before accessing the pld, if I understand correctly because some microcontroller might need to access it as well. Leaving the actual code aside, would you reject that too if you don't like the arbitration scheme, or because you don't want to have board support in the i2c directory ?
Thanks,
Guenter
Guenter,
Quoted 3 lines
I think there is a difference between a bad driver or underlying hardware. To me, "shipped" applies to hardware or firmware which can not be upgraded, not to the software running on it.
OK. Valuable distinction.
Quoted 3 lines
"board support hosted in the I2C directory". But that is exactly what I am talking about, isn't it ? I have board specific multiplexers and a board specific I2C controller, and that is just talking about the I2C code.
Yes and no. I think I can accept that some hardware has GPIOs wired to handle I2C arbitration. I still have problems in having arbitrator drivers per board, each one with various ideas how to do it. That would be a maintenance horror and has nothing to do with I2C, strictly speaking. What I would love to see is a few generic arbitrator drivers, e.g. utilizing a timeout-based scheme (as proposed here). Or like the old SCSI method putting IDs on the wire and the lowest wins. Stuff like that.
Quoted 7 lines
A better example might be Kontron board support. They implement gpio, I2C mux, and a watchdog in a PLD. They too have an access arbitration scheme where one has to acquire a hardware mutex before accessing the pld, if I understand correctly because some microcontroller might need to access it as well. Leaving the actual code aside, would you reject that too if you don't like the arbitration scheme, or because you don't want to have board support in the i2c directory ?
If I understood correctly, getting the mutex would be done in some platform code and the I2C driver will simply call the necessary function to obtain and release the mutex. Or maybe the MFD layer can help, dunno. Both are fine with me and I don't care about the actual PLD arbitration.
Thanks,
Wolfram
PATCH v5 1/3 i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to a message not in the archiveThe i2c-arb-gpio-challenge driver implements an I2C arbitration scheme where masters need to claim the bus with a GPIO before they can start a transcation. This should generally only be used when standard I2C multimaster isn't appropriate for some reason (errata/bugs).
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
---
Changes in v5:
- Renamed as per Wolfram Sang.
- Avoid references to AP and EC.
- Bindings are now generic and could support N other masters; code still only supports one other master.
- Replaced all instances of WARN_ON with error messages.
- Left Stephen's Reviewed-by from v4 since changes aren't huge, but please yell if you want it removed or don't like something about the new code; removed Naveen's Tested-by for now.
Changes in v4: None
Changes in v3:
- Handle of_find_i2c_adapter_by_node() failure more properly by changing init order.
- Don't warn on -EPROBE_DEFER from calls that could return it.
- Move to module_platform_driver(). As we pull in parts of the system that rely on devices under this i2c bus we'll need to make sure they can handle the fact that they'll be initted later now.
Changes in v2:
- Renamed to i2c-arb-gpio-challenge.
- Documented "microsecond" properties as optional; removed "bus-arbitration" prefix since it was just extra wordy.
- Split GPIOs into two properties to make it cleaner.
- Capitalized I2C in freeform text.
- Get 'active low' from device tree.
.../bindings/i2c/i2c-arb-gpio-challenge.txt | 80 +++++++ drivers/i2c/muxes/Kconfig | 11 + drivers/i2c/muxes/Makefile | 2 + drivers/i2c/muxes/i2c-arb-gpio-challenge.c | 252 +++++++++++++++++++++ 4 files changed, 345 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt create mode 100644 drivers/i2c/muxes/i2c-arb-gpio-challenge.c
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt new file +80 -0
@@ -0,0 +1,80 @@ +GPIO-based I2C Arbitration +========================== +This uses GPIO lines to arbitrate who is the master of an I2C bus in a +multimaster situation. + +In many cases using GPIOs to arbitrate is not needed and a design can use +the standard I2C multi-master rules. Using GPIOs is generally useful in +the case where there is a device on the bus that has errata and/or bugs +that makes standard multimaster mode not feasible. + + +Algorithm: + +All masters on the bus have a 'bus claim' line which is an output that the +others can see. These are all active low with pull-ups enabled. We'll +describe these lines as: + +- OUR_CLAIM: output from us signaling to other hosts that we want the bus +- THEIR_CLAIMS: output from others signaling that they want the bus + +The basic algorithm is to assert your line when you want the bus, then make +sure that the other side doesn't want it also. A detailed explanation is best +done with an example. + +Let's say we want to claim the bus. We: +1. Assert OUR_CLAIM. +2. Waits a little bit for the other sides to notice (slew time, say 10 + microseconds). +3. Check THEIR_CLAIMS. If none are asserted then the we have the bus and we are + done. +4. Otherwise, wait for a few milliseconds and see if THEIR_CLAIMS are released. +5. If not, back off, release the claim and wait for a few more milliseconds. +6. Go back to 1 (until retry time has expired). + + +Required properties: +- compatible: i2c-arb-gpio-challenge +- our-claim-gpio: The GPIO that we use to claim the bus. +- their-claim-gpios: The GPIOs that the other sides use the claim the bus. + Note that some implementations may only support a single other master. +- Standard I2C mux properties. See mux.txt in this directory. +- Single I2C child bus node at reg 0. See mux.txt in this directory. + +Optional properties: +- slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us. +- wait-retry-us: we'll attempt another claim after this many microseconds. + Default is 3000 us. +- wait-free-us: we'll give up after this many microseconds. Default is 50000 us. + + +Example: + i2c@12CA0000 { + compatible = "acme,some-i2c-device"; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c-arbitrator { + compatible = "i2c-arb-gpio-challenge"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + our-claim-gpio = <&gpf0 3 1>; + their-claim-gpios = <&gpe0 4 1>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + i2c@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + i2c@52 { + // Normal I2C device + }; + }; + };
drivers/i2c/muxes/Kconfig +11 -0
@@ -5,6 +5,17 @@ menu "Multiplexer I2C Chip support" depends on I2C_MUX +config I2C_ARB_GPIO_CHALLENGE + tristate "GPIO-based I2C arbitration" + depends on GENERIC_GPIO && OF + help + If you say yes to this option, support will be included for an + I2C multimaster arbitration scheme using GPIOs where masters have + to claim the bus by asserting a GPIO. + + This driver can also be built as a module. If so, the module + will be called i2c-arb-gpio-challenge. + config I2C_MUX_GPIO tristate "GPIO-based I2C multiplexer" depends on GENERIC_GPIO
drivers/i2c/muxes/Makefile +2 -0
@@ -1,6 +1,8 @@ # # Makefile for multiplexer I2C chip drivers. +obj-$(CONFIG_I2C_ARB_GPIO_CHALLENGE) += i2c-arb-gpio-challenge.o + obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +252 -0
252 lines not on this page · raw message
Signature · 1 line
1.8.1.3
PATCH v5 2/3 ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
---
Changes in v5:
- Adjust bindings as per Wolfram Sang.
Changes in v4:
- Changed mux gpio syntax to work atop Thomas's "ARM: dts: add pin state information in client nodes for Exynos5 platforms"; avoid adding gpios property to i2c at 12CA0000 for the same reason.
Changes in v3: None
Changes in v2:
- Use new device tree property names / compatible string.
- Include that the GPIOs for arbitration are active low.
arch/arm/boot/dts/cros5250-common.dtsi | 3 ++- arch/arm/boot/dts/exynos5250-snow.dts | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-)
arch/arm/boot/dts/cros5250-common.dtsi +2 -1
@@ -193,7 +193,8 @@ }; i2c at 12CA0000 { - status = "disabled"; + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; }; i2c at 12CB0000 {
arch/arm/boot/dts/exynos5250-snow.dts +25 -0
@@ -16,6 +16,10 @@ model = "Google Snow"; compatible = "google,snow", "samsung,exynos5250"; + aliases { + i2c104 = &i2c_104; + }; + pinctrl at 11400000 { sd3_clk: sd3-clk { samsung,pin-drv = <0>;
@@ -44,6 +48,27 @@ }; }; + i2c-arbitrator { + compatible = "i2c-arb-gpio-challenge"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + our-claim-gpio = <&gpf0 3 1>; + their-claim-gpios = <&gpe0 4 1>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + /* Use ID 104 as a hint that we're on physical bus 4 */ + i2c_104: i2c at 0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + /* * On Snow we've got SIP WiFi and so can keep drive strengths low to * reduce EMI.
Signature · 1 line
1.8.1.3
PATCH v5 3/3 ARM: dts: Add sbs-battery for exynos5250-snow
In reply to Doug AndersonNow that we have i2c-arbitrator in place on bus 4 we can add the sbs-battery driver. Future devices will be added onto bus 4 once drivers are in good shape.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/arm/boot/dts/exynos5250-snow.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/exynos5250-snow.dts +6 -0
@@ -66,6 +66,12 @@ reg = <0>; #address-cells = <1>; #size-cells = <0>; + + battery: sbs-battery at b { + compatible = "sbs,sbs-battery"; + reg = <0xb>; + sbs,poll-retry-count = <1>; + }; }; };
Signature · 1 line
1.8.1.3
Quoted 11 lines · Doug Anderson
The i2c-arbitrator-cros-ec driver implements the arbitration scheme that the Embedded Controller (EC) on the ARM Chromebook expects to use for bus multimastering. This i2c-arbitrator-cros-ec driver could also be used in other places where standard I2C bus arbitration can't be used and two extra GPIOs are available for arbitration.
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
Quoted 5 lines
Signed-off-by Doug Anderson <[email protected]>Signed-off-by Simon Glass <[email protected]>Signed-off-by Naveen Krishna Chatradhi <[email protected]>Reviewed-by Stephen Warren <[email protected]>
I'd like to have the bindings more generic. They should allow for n possible masters IMO. It doesn't need to be implemented right now, but it should be possible to add that later.
Quoted 18 lines
---
Changes in v4: None
Changes in v3:
- Handleof_find_i2c_adapter_by_node()failure more properly by changing init order.
- Don't warn on -EPROBE_DEFER from calls that could return it.
- Move tomodule_platform_driver(). As we pull in parts of the system that rely on devices under this i2c bus we'll need to make sure they can handle the fact that they'll be initted later now.Changes in v2:
- Renamed to i2c-arbitrator-cros-ec.
- Documented "microsecond" properties as optional; removed "bus-arbitration" prefix since it was just extra wordy.
- Split GPIOs into two properties to make it cleaner.
- Capitalized I2C in freeform text.
- Get 'active low' from device tree.
Quoted 1 line
.../bindings/i2c/i2c-arbitrator-cros-ec.txt | 76 +++++++
I wonder about a more generic name. i2c-arb-gpio-challenge.* maybe?
Quoted 13 lines
drivers/i2c/muxes/Kconfig | 11 + drivers/i2c/muxes/Makefile | 2 + drivers/i2c/muxes/i2c-arbitrator-cros-ec.c | 222 +++++++++++++++++++++ 4 files changed, 311 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt create mode 100644 drivers/i2c/muxes/i2c-arbitrator-cros-ec.cDocumentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt new file +0
-0
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt line 10
Quoted 10 lines
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt new file +10
-0@@ -0,0 +1,76 @@ +GPIO-based Arbitration used by the ARM Chromebook (exynos5250-snow) +=================================================================== +This uses GPIO lines between the AP (Application Processor) and an attached +EC (Embedded Controller) which both want to talk on the same I2C bus as master. + +The AP and EC each have a 'bus claim' line, which is an output that the +other can see. These are both active low, with pull-ups enabled. + +- AP_CLAIM: output from AP, signalling to the EC that the AP wants the bus +- EC_CLAIM: output from EC, signalling to the AP that the EC wants the bus
I'd like to drop the specific terms of AP and EC and just talk about multiple masters.
Quoted 15 lines
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt new file +15
-0+This mechanism is used instead of standard I2C multimaster to avoid some of the +subtle driver and silicon bugs that are often present with I2C multimaster. + + +Algorithm: + +The basic algorithm is to assert your line when you want the bus, then make +sure that the other side doesn't want it also. A detailed explanation is best +done with an example. + +Let's say the AP wants to claim the bus. It: +1. Asserts AP_CLAIM. +2. Waits a little bit for the other side to notice (slew time, say 10 + microseconds). +3. Checks EC_CLAIM. If this is not asserted then the AP has the bus and we are
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt line 36
Quoted 10 lines
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt new file +10
-0+ done. +4. Otherwise, wait for a few milliseconds and see if EC_CLAIM is released. +5. If not, back off, release the claim and wait for a few more milliseconds. +6. Go back to 1 (until retry time has expired). + + +Required properties: +- compatible: i2c-arbitrator-cros-ec +- ap-claim-gpio: The GPIO that we (the AP) use to claim the bus. +- ec-claim-gpio: The GPIO that the other side (the EC) uses the claim the bus.
An array based approach like in the i2c-mux-gpio driver would be more generic. Just mention that the driver only supports 2 entries at the moment.
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt line 44
Quoted 8 lines
Documentation/devicetree/bindings/i2c/i2c-arbitrator-cros-ec.txt new file +8
-0+- Standard I2C mux properties. See mux.txt in this directory. +- Single I2C child bus node at reg 0. See mux.txt in this directory. + +Optional properties: +- slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us. +- wait-retry-us: we'll attempt another claim after this many microseconds. + Default is 3000 us. +- wait-free-us: we'll give up after this many microseconds. Default is 50000 us.
Grant, I assume it is okay to introduce these generic bindings?
Quoted 9 lines
drivers/i2c/muxes/Kconfig +1
-0@@ -5,6 +5,17 @@ menu "Multiplexer I2C Chip support" depends on I2C_MUX +config I2C_ARBITRATOR_CROS_EC
drivers/i2c/muxes/Kconfig line 18
Quoted 10 lines
drivers/i2c/muxes/Kconfig +10
-0+ tristate "GPIO-based I2C arbitrator used on exynos5250-snow" + depends on GENERIC_GPIO && OF + help + If you say yes to this option, support will be included for an + I2C multimaster arbitration scheme using GPIOs that is used in + the Samsung ARM Chromebook (exynos5250-snow). + + This driver can also be built as a module. If so, the module + will be called i2c-arbitrator-cros-ec. +
This text could be more generic then, too.
drivers/i2c/muxes/Kconfig
Quoted 12 lines
drivers/i2c/muxes/Kconfig +12
-0+static int i2c_arbitrator_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device_node *parent_np; + struct i2c_arbitrator_data *arb; + enum of_gpio_flags gpio_flags; + unsigned long out_init; + int ret; + + /* We only support probing from device tree; no platform_data */ + if (WARN_ON(!np)) + return -ENODEV;
Too much WARN_ON for my taste.
Thanks,
Wolfram
A message that is not in the archive (sent off-list or not yet received): 20130408102617.GC3496-z923LK4zBo2bacvFa/[email protected]
Wolfram,
Thanks for your review!
Quoted 3 lines · Wolfram Sang
I'd like to have the bindings more generic. They should allow for n possible masters IMO. It doesn't need to be implemented right now, but it should be possible to add that later.
Done. Left code as only handling one other master (as you suggested) since it has been tested that way and there are no known users with more than one other master. Code will give an error if it encounters a device tree with more than one master.
Quoted 1 line
I wonder about a more generic name. i2c-arb-gpio-challenge.* maybe?
Done.
Quoted 2 lines
I'd like to drop the specific terms of AP and EC and just talk about multiple masters.
Done.
Quoted 3 lines
An array based approach like in the i2c-mux-gpio driver would be more generic. Just mention that the driver only supports 2 entries at the moment.
Done. Mentioned that some drivers may only support one other master (rather than describing the current state of the kernel code) since bindings should make sense even outside of a single driver, I think.
Quoted 1 line
Grant, I assume it is okay to introduce these generic bindings?
You are thinking that Grant wouldn't like the names I chose, or that bindings of this type might not be OK? The scheme as it stands is pretty close to what Grant suggested himself here
<https://patchwork.kernel.org/patch/1877311/>.
I did drop the "bus-arbitration-" prefix from the ones he wrote up since it seemed redundant to have that prefix on all properties of a node that's only for bus arbitration anyway. I can add them back in if you think it's better. I think Grant only had that prefix in his proposed bindings because that was the name of the properties in Naveen's patch (where the bus arbitration was bolted on to the i2c bus and thus needed differentiation).
Quoted 5 lines
Quoted 5 lines
drivers/i2c/muxes/Kconfig +5
-0+config I2C_ARBITRATOR_CROS_EC + tristate "GPIO-based I2C arbitrator used on exynos5250-snow" + depends on GENERIC_GPIO && OF + help + If you say yes to this option, support will be included for an
Quoted 8 lines
drivers/i2c/muxes/Kconfig line 18
Quoted 6 lines
drivers/i2c/muxes/Kconfig +6
-0+ I2C multimaster arbitration scheme using GPIOs that is used in + the Samsung ARM Chromebook (exynos5250-snow). + + This driver can also be built as a module. If so, the module + will be called i2c-arbitrator-cros-ec. +This text could be more generic then, too.
Done.
Quoted 5 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c line 131
Quoted 3 lines
drivers/i2c/muxes/i2c-arbitrator-cros-ec.c new file +3
-0+/* We only support probing from device tree; no platform_data */ +if (WARN_ON (!np)) +return -ENODEV ;Too much
WARN_ONfor my taste.
Sure. I've removed them all and put dev_err() messages everywhere as other mux drivers seem to. I'd been of the mindset that there was no need for verbose error messages and extra complexity for uncommon cases like this, but I can see the benefit of describing exactly what went wrong in the kernel log.
Please let me know if there's any other fixes needed.
-Doug
PATCH v5 1/3 i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to Doug AndersonThe i2c-arb-gpio-challenge driver implements an I2C arbitration scheme where masters need to claim the bus with a GPIO before they can start a transcation. This should generally only be used when standard I2C multimaster isn't appropriate for some reason (errata/bugs).
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
---
(Sorry if you got v5 more than once--apparently the CC list has grown
too long and my mail was rejected; resending with a shorter header)
Changes in v5:
- Renamed as per Wolfram Sang.
- Avoid references to AP and EC.
- Bindings are now generic and could support N other masters; code still only supports one other master.
- Replaced all instances of WARN_ON with error messages.
- Left Stephen's Reviewed-by from v4 since changes aren't huge, but please yell if you want it removed or don't like something about the new code; removed Naveen's Tested-by for now.
Changes in v4: None
Changes in v3:
- Handle of_find_i2c_adapter_by_node() failure more properly by changing init order.
- Don't warn on -EPROBE_DEFER from calls that could return it.
- Move to module_platform_driver(). As we pull in parts of the system that rely on devices under this i2c bus we'll need to make sure they can handle the fact that they'll be initted later now.
Changes in v2:
- Renamed to i2c-arb-gpio-challenge.
- Documented "microsecond" properties as optional; removed "bus-arbitration" prefix since it was just extra wordy.
- Split GPIOs into two properties to make it cleaner.
- Capitalized I2C in freeform text.
- Get 'active low' from device tree.
.../bindings/i2c/i2c-arb-gpio-challenge.txt | 80 +++++++ drivers/i2c/muxes/Kconfig | 11 + drivers/i2c/muxes/Makefile | 2 + drivers/i2c/muxes/i2c-arb-gpio-challenge.c | 252 +++++++++++++++++++++ 4 files changed, 345 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt create mode 100644 drivers/i2c/muxes/i2c-arb-gpio-challenge.c
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt new file +80 -0
@@ -0,0 +1,80 @@ +GPIO-based I2C Arbitration +========================== +This uses GPIO lines to arbitrate who is the master of an I2C bus in a +multimaster situation. + +In many cases using GPIOs to arbitrate is not needed and a design can use +the standard I2C multi-master rules. Using GPIOs is generally useful in +the case where there is a device on the bus that has errata and/or bugs +that makes standard multimaster mode not feasible. + + +Algorithm: + +All masters on the bus have a 'bus claim' line which is an output that the +others can see. These are all active low with pull-ups enabled. We'll +describe these lines as: + +- OUR_CLAIM: output from us signaling to other hosts that we want the bus +- THEIR_CLAIMS: output from others signaling that they want the bus + +The basic algorithm is to assert your line when you want the bus, then make +sure that the other side doesn't want it also. A detailed explanation is best +done with an example. + +Let's say we want to claim the bus. We: +1. Assert OUR_CLAIM. +2. Waits a little bit for the other sides to notice (slew time, say 10 + microseconds). +3. Check THEIR_CLAIMS. If none are asserted then the we have the bus and we are + done. +4. Otherwise, wait for a few milliseconds and see if THEIR_CLAIMS are released. +5. If not, back off, release the claim and wait for a few more milliseconds. +6. Go back to 1 (until retry time has expired). + + +Required properties: +- compatible: i2c-arb-gpio-challenge +- our-claim-gpio: The GPIO that we use to claim the bus. +- their-claim-gpios: The GPIOs that the other sides use the claim the bus. + Note that some implementations may only support a single other master. +- Standard I2C mux properties. See mux.txt in this directory. +- Single I2C child bus node at reg 0. See mux.txt in this directory. + +Optional properties: +- slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us. +- wait-retry-us: we'll attempt another claim after this many microseconds. + Default is 3000 us. +- wait-free-us: we'll give up after this many microseconds. Default is 50000 us. + + +Example: + i2c@12CA0000 { + compatible = "acme,some-i2c-device"; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c-arbitrator { + compatible = "i2c-arb-gpio-challenge"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + our-claim-gpio = <&gpf0 3 1>; + their-claim-gpios = <&gpe0 4 1>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + i2c@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + i2c@52 { + // Normal I2C device + }; + }; + };
drivers/i2c/muxes/Kconfig +11 -0
@@ -5,6 +5,17 @@ menu "Multiplexer I2C Chip support" depends on I2C_MUX +config I2C_ARB_GPIO_CHALLENGE + tristate "GPIO-based I2C arbitration" + depends on GENERIC_GPIO && OF + help + If you say yes to this option, support will be included for an + I2C multimaster arbitration scheme using GPIOs where masters have + to claim the bus by asserting a GPIO. + + This driver can also be built as a module. If so, the module + will be called i2c-arb-gpio-challenge. + config I2C_MUX_GPIO tristate "GPIO-based I2C multiplexer" depends on GENERIC_GPIO
drivers/i2c/muxes/Makefile +2 -0
@@ -1,6 +1,8 @@ # # Makefile for multiplexer I2C chip drivers. +obj-$(CONFIG_I2C_ARB_GPIO_CHALLENGE) += i2c-arb-gpio-challenge.o + obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +252 -0
252 lines not on this page · raw message
Signature · 1 line
1.8.1.3
PATCH v5 2/3 ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
---
Changes in v5:
- Adjust bindings as per Wolfram Sang.
Changes in v4:
- Changed mux gpio syntax to work atop Thomas's "ARM: dts: add pin state information in client nodes for Exynos5 platforms"; avoid adding gpios property to i2c at 12CA0000 for the same reason.
Changes in v3: None
Changes in v2:
- Use new device tree property names / compatible string.
- Include that the GPIOs for arbitration are active low.
arch/arm/boot/dts/cros5250-common.dtsi | 3 ++- arch/arm/boot/dts/exynos5250-snow.dts | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-)
arch/arm/boot/dts/cros5250-common.dtsi +2 -1
@@ -193,7 +193,8 @@ }; i2c at 12CA0000 { - status = "disabled"; + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; }; i2c at 12CB0000 {
arch/arm/boot/dts/exynos5250-snow.dts +25 -0
@@ -16,6 +16,10 @@ model = "Google Snow"; compatible = "google,snow", "samsung,exynos5250"; + aliases { + i2c104 = &i2c_104; + }; + pinctrl at 11400000 { sd3_clk: sd3-clk { samsung,pin-drv = <0>;
@@ -44,6 +48,27 @@ }; }; + i2c-arbitrator { + compatible = "i2c-arb-gpio-challenge"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + our-claim-gpio = <&gpf0 3 1>; + their-claim-gpios = <&gpe0 4 1>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + /* Use ID 104 as a hint that we're on physical bus 4 */ + i2c_104: i2c at 0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + /* * On Snow we've got SIP WiFi and so can keep drive strengths low to * reduce EMI.
Signature · 1 line
1.8.1.3
RE: [PATCH v5 2/3] ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
Quoted 7 lines · Doug Anderson
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
Quoted 8 lines
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
Signed-off-by Doug Anderson <[email protected]>
I'm fine on 2nd and 3rd patches. Shall I take only two patches without 1st one in samsung tree?
- Kukjin
Quoted 80 lines
---
Changes in v5:
- Adjust bindings as per Wolfram Sang.Changes in v4:
- Changed mux gpio syntax to work atop Thomas's "ARM: dts: add pin state information in client nodes for Exynos5 platforms"; avoid adding gpios property to i2c at 12CA0000 for the same reason.Changes in v3: None
Changes in v2:
- Use new device tree property names / compatible string.
- Include that the GPIOs for arbitration are active low.arch/arm/boot/dts/cros5250-common.dtsi | 3 ++- arch/arm/boot/dts/exynos5250-snow.dts | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-)arch/arm/boot/dts/cros5250-common.dtsi +2
-1@@ -193,7 +193,8 @@ }; i2c at 12CA0000 { - status = "disabled"; + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; }; i2c at 12CB0000 {arch/arm/boot/dts/exynos5250-snow.dts +25
-0@@ -16,6 +16,10 @@ model = "Google Snow"; compatible = "google,snow", "samsung,exynos5250"; + aliases { + i2c104 = &i2c_104; + }; + pinctrl at 11400000 { sd3_clk: sd3-clk { samsung,pin-drv = <0>;@@ -44,6 +48,27 @@ }; }; + i2c-arbitrator { + compatible = "i2c-arb-gpio-challenge"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + our-claim-gpio = <&gpf0 3 1>; + their-claim-gpios = <&gpe0 4 1>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + /* Use ID 104 as a hint that we're on physical bus 4 */ + i2c_104: i2c at 0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + /* * On Snow we've got SIP WiFi and so can keep drive strengths lowto
* reduce EMI.
--
1.8.1.3
Re: [PATCH v5 2/3] ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
Quoted 12 lines · Kukjin Kim
Quoted 11 lines · Doug Anderson
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
Quoted 7 lines
Quoted 4 lines
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
Signed-off-by Doug Anderson <[email protected]>I'm fine on 2nd and 3rd patches. Shall I take only two patches without 1st one in samsung tree?
Please wait for my OK on patch 1. Or ack patches 2 and 3 and I will pick them up. I am fine with both.
Re: [PATCH v5 2/3] ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
Quoted 16 lines · Wolfram Sang
Quoted 15 lines · Kukjin Kim
Quoted 14 lines · Doug Anderson
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Doug Anderson<[email protected]>I'm fine on 2nd and 3rd patches. Shall I take only two patches without 1st one in samsung tree?
Please wait for my OK on patch 1. Or ack patches 2 and 3 and I will pick them up. I am fine with both.
OK, I will wait for your reply on this. Because I suppose if the dt patches in your tree could make useless conflicts. Anyway let me know your opinion on that.
Thanks.
- Kukjin
PATCH v5 3/3 ARM: dts: Add sbs-battery for exynos5250-snow
In reply to Doug AndersonNow that we have i2c-arbitrator in place on bus 4 we can add the sbs-battery driver. Future devices will be added onto bus 4 once drivers are in good shape.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/arm/boot/dts/exynos5250-snow.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/exynos5250-snow.dts +6 -0
@@ -66,6 +66,12 @@ reg = <0>; #address-cells = <1>; #size-cells = <0>; + + battery: sbs-battery at b { + compatible = "sbs,sbs-battery"; + reg = <0xb>; + sbs,poll-retry-count = <1>; + }; }; };
Signature · 1 line
1.8.1.3
Re: [PATCH v5 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to Doug AndersonDoug,
Quoted 10 lines · Doug Anderson
The i2c-arb-gpio-challenge driver implements an I2C arbitration scheme where masters need to claim the bus with a GPIO before they can start a transcation. This should generally only be used when standard I2C multimaster isn't appropriate for some reason (errata/bugs).
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
Quoted 4 lines
Signed-off-by Doug Anderson <[email protected]>Signed-off-by Simon Glass <[email protected]>Signed-off-by Naveen Krishna Chatradhi <[email protected]>Reviewed-by Stephen Warren <[email protected]>
Mostly good, except for some documentation updates.
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt line 4
Quoted 10 lines
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt new file +4
-0@@ -0,0 +1,80 @@ +GPIO-based I2C Arbitration +========================== +This uses GPIO lines to arbitrate who is the master of an I2C bus in a +multimaster situation.
"uses GPIO lines and a challange & response mechanism" or something like that. There might be other GPIO based arbitrations in the future (though I hope there won't).
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt line 9
Quoted 5 lines
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt new file +5
-0+ +In many cases using GPIOs to arbitrate is not needed and a design can use +the standard I2C multi-master rules. Using GPIOs is generally useful in +the case where there is a device on the bus that has errata and/or bugs +that makes standard multimaster mode not feasible.
I like this paragraph!
...
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt line 40
Quoted 2 lines
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt new file +2
-0+- their-claim-gpios: The GPIOs that the other sides use the claim the bus. + Note that some implementations may only support a single other master.
Stronger? "Currently, only one other master is supported"?
...
Quoted 5 lines
drivers/i2c/muxes/Kconfig +0
-0
drivers/i2c/muxes/Kconfig line 14
Quoted 10 lines
drivers/i2c/muxes/Kconfig +7
-0@@ -5,6 +5,17 @@ menu "Multiplexer I2C Chip support" depends on I2C_MUX +config I2C_ARB_GPIO_CHALLENGE + tristate "GPIO-based I2C arbitration" + depends on GENERIC_GPIO && OF + help + If you say yes to this option, support will be included for an + I2C multimaster arbitration scheme using GPIOs where masters have + to claim the bus by asserting a GPIO.
"callenge & response"?
...
drivers/i2c/muxes/i2c-arb-gpio-challenge.c line 2
Quoted 8 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +2
-0@@ -0,0 +1,252 @@ +/* +* GPIO-based I2C Arbitration
"callenge & response"?
...
Quoted 37 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +37
-0+* +* Copyright (C) 2012 Google, Inc +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <linux/delay.h> +#include <linux/gpio.h> +#include <linux/kernel.h> +#include <linux/i2c.h> +#include <linux/i2c-mux.h> +#include <linux/init.h> +#include <linux/module.h> +#include <linux/of_i2c.h> +#include <linux/of_gpio.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + + +/** +* struct i2c_arbitrator_data - Driver data for I2C arbitrator +* +* @parent: Parent adapter +* @child: Child bus +* @our_gpio: GPIO we'll use to claim. +* @our_gpio_release: 0 if active high; 1 if active low; AKA if the GPIO == +* this then consider it released. +* @their_gpio: GPIO that the other side will use to claim. +* @their_gpio_release: 0 if active high; 1 if active low; AKA if the GPIO ==
drivers/i2c/muxes/i2c-arb-gpio-challenge.c line 49
Quoted 10 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +10
-0+* this then consider it released. +* @slew_delay_us: microseconds to wait for a GPIO to go high. +* @wait_retry_us: we'll attempt another claim after this many microseconds. +* @wait_free_us: we'll give up after this many microseconds. +*/ + +struct i2c_arbitrator_data { +struct i2c_adapter *parent; +struct i2c_adapter *child; +
No empty line.
drivers/i2c/muxes/i2c-arb-gpio-challenge.c line 57
Quoted 8 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +8
-0+int our_gpio; +int our_gpio_release; +int their_gpio; +int their_gpio_release; +unsigned int slew_delay_us; +unsigned int wait_retry_us; +unsigned int wait_free_us; +};
Single space as indentaion after "int".
Other than that, looks fine to me.
Thanks!
Re: [PATCH v5 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Wolfram" == Wolfram Sang <[email protected]> writes:
Hi,
Quoted 2 lines
Quoted 2 lines
+- their-claim-gpios: The GPIOs that the other sides use the claim the bus. + Note that some implementations may only support a single other master.
Wolfram> Stronger? "Currently, only one other master is supported"?
Also there's a typo: s/use the claim/use to claim/
Signature · 1 line
Bye, Peter Korsgaard
Re: [PATCH v5 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to Wolfram SangQuoted 2 lines · Wolfram Sang
Doug,
[ ... ]
Quoted 5 lines
"callenge & response"?
...
Quoted 11 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c line 2
Quoted 8 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +2
-0@@ -0,0 +1,252 @@ +/* +* GPIO-based I2C Arbitration "callenge & response"?
s/callenge/challenge/g
Re: [PATCH v5 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to Wolfram SangQuoted 15 lines · Wolfram Sang
Doug,
Quoted 11 lines · Doug Anderson
The i2c-arb-gpio-challenge driver implements an I2C arbitration scheme where masters need to claim the bus with a GPIO before they can start a transcation. This should generally only be used when standard I2C multimaster isn't appropriate for some reason (errata/bugs).
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt +0
-0
Quoted 8 lines
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt line 4
Quoted 4 lines
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt +4
-0+GPIO-based I2C Arbitration +========================== +This uses GPIO lines to arbitrate who is the master of an I2C bus in a +multimaster situation."uses GPIO lines and a challange & response mechanism" or something like that. There might be other GPIO based arbitrations in the future (though I hope there won't).
The existing text appears clearer to me; this document should spell out the exact details of the protocol in later paragraphs, so there's no need to try and spell it out here.
Quoted 4 lines
Quoted 2 lines
+- their-claim-gpios: The GPIOs that the other sides use the claim the bus. + Note that some implementations may only support a single other master.Stronger? "Currently, only one other master is supported"?
The DT binding documentation, which should be OS-/driver-agnostic, should describe the binding, not the implementation. The limitation that Linux imposes is OS-specific and hence should not be mentioned here as an absolute, or perhaps even at all.
A message that is not in the archive (sent off-list or not yet received): 20130416093633.GC16978-z923LK4zBo2bacvFa/[email protected]
Re: [PATCH v5 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
Wolfram / Guenter / Stephen,
Thanks for your reviews. New version on its way...
Quoted 3 lines · Wolfram Sang
"uses GPIO lines and a challange & response mechanism" or something like that. There might be other GPIO based arbitrations in the future (though I hope there won't).
Done (including fixing spelling of challenge). Stephen: I think the new paragraph is still high-level enough even with Wolfram's requested addition.
Quoted 4 lines
Quoted 2 lines
+- their-claim-gpios: The GPIOs that the other sides use the claim the bus. + Note that some implementations may only support a single other master.Stronger? "Currently, only one other master is supported"?
As per Stephen Warren, I didn't touch this. He says:
The DT binding documentation, which should be OS-/driver-agnostic, should describe the binding, not the implementation. The limitation that Linux imposes is OS-specific and hence should not be mentioned here as an absolute, or perhaps even at all.
I think the current wording about "may only support a single other master" is a compromise and would at least give some a clue that they should check the Linux driver for details.
Quoted 5 lines
drivers/i2c/muxes/Kconfig line 14
Quoted 3 lines
drivers/i2c/muxes/Kconfig +3
-0+ If you say yes to this option, support will be included for an + I2C multimaster arbitration scheme using GPIOs where masters have + to claim the bus by asserting a GPIO."callenge & response"?
Done (including fixing spelling of challenge).
Quoted 3 lines
Quoted 1 line
+ * GPIO-based I2C Arbitration
"callenge & response"?
Done (including fixing spelling of challenge).
Quoted 6 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c line 49
Quoted 4 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +4
-0+struct i2c_arbitrator_data { +struct i2c_adapter *parent; +struct i2c_adapter *child; +No empty line.
Done.
Quoted 10 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c line 57
Quoted 8 lines
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +8
-0+int our_gpio; +int our_gpio_release; +int their_gpio; +int their_gpio_release; +unsigned int slew_delay_us; +unsigned int wait_retry_us; +unsigned int wait_free_us; +};Single space as indentaion after "int".
Done.
PATCH v6 1/3 i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to Doug AndersonThe i2c-arb-gpio-challenge driver implements an I2C arbitration scheme where masters need to claim the bus with a GPIO before they can start a transcation. This should generally only be used when standard I2C multimaster isn't appropriate for some reason (errata/bugs).
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
---
Changes in v6:
- Cleaned up documentation, spacing, and typos as per review.
Changes in v5:
- Renamed as per Wolfram Sang.
- Avoid references to AP and EC.
- Bindings are now generic and could support N other masters; code still only supports one other master.
- Replaced all instances of WARN_ON with error messages.
- Left Stephen's Reviewed-by from v4 since changes aren't huge, but please yell if you want it removed or don't like something about the new code; removed Naveen's Tested-by for now.
Changes in v4: None
Changes in v3:
- Handle of_find_i2c_adapter_by_node() failure more properly by changing init order.
- Don't warn on -EPROBE_DEFER from calls that could return it.
- Move to module_platform_driver(). As we pull in parts of the system that rely on devices under this i2c bus we'll need to make sure they can handle the fact that they'll be initted later now.
Changes in v2:
- Renamed to i2c-arb-gpio-challenge.
- Documented "microsecond" properties as optional; removed "bus-arbitration" prefix since it was just extra wordy.
- Split GPIOs into two properties to make it cleaner.
- Capitalized I2C in freeform text.
- Get 'active low' from device tree.
.../bindings/i2c/i2c-arb-gpio-challenge.txt | 80 +++++++ drivers/i2c/muxes/Kconfig | 12 + drivers/i2c/muxes/Makefile | 2 + drivers/i2c/muxes/i2c-arb-gpio-challenge.c | 251 +++++++++++++++++++++ 4 files changed, 345 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt create mode 100644 drivers/i2c/muxes/i2c-arb-gpio-challenge.c
Documentation/devicetree/bindings/i2c/i2c-arb-gpio-challenge.txt new file +80 -0
@@ -0,0 +1,80 @@ +GPIO-based I2C Arbitration Using a Challenge & Response Mechanism +================================================================= +This uses GPIO lines and a challenge & response mechanism to arbitrate who is +the master of an I2C bus in a multimaster situation. + +In many cases using GPIOs to arbitrate is not needed and a design can use +the standard I2C multi-master rules. Using GPIOs is generally useful in +the case where there is a device on the bus that has errata and/or bugs +that makes standard multimaster mode not feasible. + + +Algorithm: + +All masters on the bus have a 'bus claim' line which is an output that the +others can see. These are all active low with pull-ups enabled. We'll +describe these lines as: + +- OUR_CLAIM: output from us signaling to other hosts that we want the bus +- THEIR_CLAIMS: output from others signaling that they want the bus + +The basic algorithm is to assert your line when you want the bus, then make +sure that the other side doesn't want it also. A detailed explanation is best +done with an example. + +Let's say we want to claim the bus. We: +1. Assert OUR_CLAIM. +2. Waits a little bit for the other sides to notice (slew time, say 10 + microseconds). +3. Check THEIR_CLAIMS. If none are asserted then the we have the bus and we are + done. +4. Otherwise, wait for a few milliseconds and see if THEIR_CLAIMS are released. +5. If not, back off, release the claim and wait for a few more milliseconds. +6. Go back to 1 (until retry time has expired). + + +Required properties: +- compatible: i2c-arb-gpio-challenge +- our-claim-gpio: The GPIO that we use to claim the bus. +- their-claim-gpios: The GPIOs that the other sides use to claim the bus. + Note that some implementations may only support a single other master. +- Standard I2C mux properties. See mux.txt in this directory. +- Single I2C child bus node at reg 0. See mux.txt in this directory. + +Optional properties: +- slew-delay-us: microseconds to wait for a GPIO to go high. Default is 10 us. +- wait-retry-us: we'll attempt another claim after this many microseconds. + Default is 3000 us. +- wait-free-us: we'll give up after this many microseconds. Default is 50000 us. + + +Example: + i2c@12CA0000 { + compatible = "acme,some-i2c-device"; + #address-cells = <1>; + #size-cells = <0>; + }; + + i2c-arbitrator { + compatible = "i2c-arb-gpio-challenge"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + our-claim-gpio = <&gpf0 3 1>; + their-claim-gpios = <&gpe0 4 1>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + i2c@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + i2c@52 { + // Normal I2C device + }; + }; + };
drivers/i2c/muxes/Kconfig +12 -0
@@ -5,6 +5,18 @@ menu "Multiplexer I2C Chip support" depends on I2C_MUX +config I2C_ARB_GPIO_CHALLENGE + tristate "GPIO-based I2C arbitration" + depends on GENERIC_GPIO && OF + help + If you say yes to this option, support will be included for an + I2C multimaster arbitration scheme using GPIOs and a challenge & + response mechanism where masters have to claim the bus by asserting + a GPIO. + + This driver can also be built as a module. If so, the module + will be called i2c-arb-gpio-challenge. + config I2C_MUX_GPIO tristate "GPIO-based I2C multiplexer" depends on GENERIC_GPIO
drivers/i2c/muxes/Makefile +2 -0
@@ -1,6 +1,8 @@ # # Makefile for multiplexer I2C chip drivers. +obj-$(CONFIG_I2C_ARB_GPIO_CHALLENGE) += i2c-arb-gpio-challenge.o + obj-$(CONFIG_I2C_MUX_GPIO) += i2c-mux-gpio.o obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o
drivers/i2c/muxes/i2c-arb-gpio-challenge.c new file +251 -0
251 lines not on this page · raw message
Signature · 1 line
1.8.1.3
PATCH v6 2/3 ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
---
Changes in v6: None
Changes in v5:
- Adjust bindings as per Wolfram Sang.
Changes in v4:
- Changed mux gpio syntax to work atop Thomas's "ARM: dts: add pin state information in client nodes for Exynos5 platforms"; avoid adding gpios property to i2c at 12CA0000 for the same reason.
Changes in v3: None
Changes in v2:
- Use new device tree property names / compatible string.
- Include that the GPIOs for arbitration are active low.
arch/arm/boot/dts/cros5250-common.dtsi | 3 ++- arch/arm/boot/dts/exynos5250-snow.dts | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-)
arch/arm/boot/dts/cros5250-common.dtsi +2 -1
@@ -193,7 +193,8 @@ }; i2c at 12CA0000 { - status = "disabled"; + samsung,i2c-sda-delay = <100>; + samsung,i2c-max-bus-freq = <66000>; }; i2c at 12CB0000 {
arch/arm/boot/dts/exynos5250-snow.dts +25 -0
@@ -16,6 +16,10 @@ model = "Google Snow"; compatible = "google,snow", "samsung,exynos5250"; + aliases { + i2c104 = &i2c_104; + }; + pinctrl at 11400000 { sd3_clk: sd3-clk { samsung,pin-drv = <0>;
@@ -44,6 +48,27 @@ }; }; + i2c-arbitrator { + compatible = "i2c-arb-gpio-challenge"; + #address-cells = <1>; + #size-cells = <0>; + + i2c-parent = <&{/i2c@12CA0000}>; + + our-claim-gpio = <&gpf0 3 1>; + their-claim-gpios = <&gpe0 4 1>; + slew-delay-us = <10>; + wait-retry-us = <3000>; + wait-free-us = <50000>; + + /* Use ID 104 as a hint that we're on physical bus 4 */ + i2c_104: i2c at 0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + }; + }; + /* * On Snow we've got SIP WiFi and so can keep drive strengths low to * reduce EMI.
Signature · 1 line
1.8.1.3
Re: [PATCH v6 2/3] ARM: dts: Add i2c-arbitrator bus for exynos5250-snow
Quoted 6 lines · Doug Anderson
We need to use the i2c-arbitrator to talk to any of the devices on i2c bus 4 on exynos5250-snow so that we don't confuse the embedded controller (EC). Add the i2c-arbitrator to the device tree. As we add future devices (keyboard, sbs, tps65090) we'll add them on top of this.
Quoted 8 lines
The arbitrated bus is numbered 104 simply as a convenience to make it easier for people poking around to guess that it might have something to do with the physical bus 4.
The addition is split between the cros5250-common and the snow device tree file since not all cros5250-class devices use arbitration.
Signed-off-by Doug Anderson <[email protected]>
-Olof
PATCH v6 3/3 ARM: dts: Add sbs-battery for exynos5250-snow
In reply to Doug AndersonNow that we have i2c-arbitrator in place on bus 4 we can add the sbs-battery driver. Future devices will be added onto bus 4 once drivers are in good shape.
---
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/arm/boot/dts/exynos5250-snow.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/exynos5250-snow.dts +6 -0
@@ -66,6 +66,12 @@ reg = <0>; #address-cells = <1>; #size-cells = <0>; + + battery: sbs-battery at b { + compatible = "sbs,sbs-battery"; + reg = <0xb>; + sbs,poll-retry-count = <1>; + }; }; };
Signature · 1 line
1.8.1.3
Re: [PATCH v6 3/3] ARM: dts: Add sbs-battery for exynos5250-snow
Quoted 5 lines · Doug Anderson
Now that we have i2c-arbitrator in place on bus 4 we can add the sbs-battery driver. Future devices will be added onto bus 4 once drivers are in good shape.
Signed-off-by Doug Anderson <[email protected]>
-Olof
Re: [PATCH v6 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to Doug AndersonOverdue, should have added a few iterations ago: :)
Quoted 10 lines · Doug Anderson
The i2c-arb-gpio-challenge driver implements an I2C arbitration scheme where masters need to claim the bus with a GPIO before they can start a transcation. This should generally only be used when standard I2C multimaster isn't appropriate for some reason (errata/bugs).
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
Quoted 4 lines
Signed-off-by Doug Anderson <[email protected]>Signed-off-by Simon Glass <[email protected]>Signed-off-by Naveen Krishna Chatradhi <[email protected]>Reviewed-by Stephen Warren <[email protected]>
Re: [PATCH v6 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
Quoted 1 line · Olof Johansson
Overdue, should have added a few iterations ago: :)
Why is that? Is the current iteration too generic for your taste?
A message that is not in the archive (sent off-list or not yet received): 20130417093424.GC4508-z923LK4zBo2bacvFa/[email protected]
Re: [PATCH v6 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
Quoted 6 lines · Wolfram Sang
Quoted 1 line · Olof Johansson
Overdue, should have added a few iterations ago: :)
Why is that? Is the current iteration too generic for your taste?
No, nothing like that.
I've been talking to Doug and others offlist (at work) about this but never acked the patches on the list. I've been happy with them for a while and I'm glad you've reached that point too :)
-Olof
_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH v6 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to a message not in the archive(Resend since I replied from my phone earlier and got list rejects due to HTML email)
Quoted 6 lines · Wolfram Sang
Quoted 1 line · Olof Johansson
Overdue, should have added a few iterations ago: :)
Why is that? Is the current iteration too generic for your taste?
No, nothing like that.
I've been talking to Doug and others offlist (at work) about this but never acked the patches on the list. I've been happy with them for a while and I'm glad you've reached that point too :)
-Olof
Re: [PATCH v6 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to Doug AndersonQuoted 3 lines · Doug Anderson
The i2c-arb-gpio-challenge driver implements an I2C arbitration scheme where masters need to claim the bus with a GPIO before they can start a transcation. This should generally only be used when standard I2C
I am having fun with spelling today :)
s/transcation/transaction/
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v6 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
Guenter,
Quoted 8 lines · Guenter Roeck
Quoted 3 lines · Doug Anderson
The i2c-arb-gpio-challenge driver implements an I2C arbitration scheme where masters need to claim the bus with a GPIO before they can start a transcation. This should generally only be used when standard I2C
I am having fun with spelling today :)
s/transcation/transaction/
Doh. I'm a terrable spellar. Thenks fur cetching.
Wolfram: I'm happy to send up a v7 to fix this if you'd like or you can fix it on your end when applying. Please let me know. It's trivial for me to send up a v7 but I'd hate to add yet more noise.
-Doug
Re: [PATCH v6 1/3] i2c: mux: Add i2c-arb-gpio-challenge 'mux' driver
In reply to Doug AndersonQuoted 10 lines · Doug Anderson
The i2c-arb-gpio-challenge driver implements an I2C arbitration scheme where masters need to claim the bus with a GPIO before they can start a transcation. This should generally only be used when standard I2C multimaster isn't appropriate for some reason (errata/bugs).
This driver is based on code that Simon Glass added to the i2c-s3c2410 driver in the Chrome OS kernel 3.4 tree. The current incarnation as a mux driver is as suggested by Grant Likely. See
<https://patchwork.kernel.org/patch/1877311/> for some history.
Quoted 4 lines
Signed-off-by Doug Anderson <[email protected]>Signed-off-by Simon Glass <[email protected]>Signed-off-by Naveen Krishna Chatradhi <[email protected]>Reviewed-by Stephen Warren <[email protected]>
I fixed the typo myself. Applied to for-next, thanks everyone!