Merge remote-tracking branch 'andi/i2c/andi-for-next' into i2c/for-mergewindow
Pull the patches Andi kindly collected while I was on hiatus. Thanks, Andi!
This commit is contained in:
@@ -48,6 +48,9 @@ properties:
|
||||
default: 16
|
||||
enum: [2, 4, 8, 16, 32, 64, 128, 256]
|
||||
|
||||
power-domains:
|
||||
maxItems: 1
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
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.
|
||||
|
||||
Note that this scheme works well enough but has some downsides:
|
||||
* It is nonstandard (not using standard I2C multimaster)
|
||||
* Having two masters on a bus in general makes it relatively hard to debug
|
||||
problems (hard to tell if i2c issues were caused by one master, another, or
|
||||
some device on the bus).
|
||||
|
||||
|
||||
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.
|
||||
- I2C arbitration bus node. See i2c-arb.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";
|
||||
|
||||
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-arb {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
i2c@52 {
|
||||
// Normal I2C device
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,135 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/i2c/i2c-arb-gpio-challenge.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: GPIO-based I2C Arbitration Using a Challenge & Response Mechanism
|
||||
|
||||
maintainers:
|
||||
- Doug Anderson <dianders@chromium.org>
|
||||
- Peter Rosin <peda@axentia.se>
|
||||
|
||||
description: |
|
||||
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.
|
||||
|
||||
Note that this scheme works well enough but has some downsides:
|
||||
* It is nonstandard (not using standard I2C multimaster)
|
||||
* Having two masters on a bus in general makes it relatively hard to debug
|
||||
problems (hard to tell if i2c issues were caused by one master, another,
|
||||
or some device on the bus).
|
||||
|
||||
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).
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
const: i2c-arb-gpio-challenge
|
||||
|
||||
i2c-parent:
|
||||
$ref: /schemas/types.yaml#/definitions/phandle
|
||||
description:
|
||||
The I2C bus that this multiplexer's master-side port is connected to.
|
||||
|
||||
our-claim-gpios:
|
||||
maxItems: 1
|
||||
description:
|
||||
The GPIO that we use to claim the bus.
|
||||
|
||||
slew-delay-us:
|
||||
default: 10
|
||||
description:
|
||||
Time to wait for a GPIO to go high.
|
||||
|
||||
their-claim-gpios:
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
description:
|
||||
The GPIOs that the other sides use to claim the bus. Note that some
|
||||
implementations may only support a single other master.
|
||||
|
||||
wait-free-us:
|
||||
default: 50000
|
||||
description:
|
||||
We'll give up after this many microseconds.
|
||||
|
||||
wait-retry-us:
|
||||
default: 3000
|
||||
description:
|
||||
We'll attempt another claim after this many microseconds.
|
||||
|
||||
i2c-arb:
|
||||
type: object
|
||||
$ref: /schemas/i2c/i2c-controller.yaml
|
||||
unevaluatedProperties: false
|
||||
description:
|
||||
I2C arbitration bus node.
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- i2c-arb
|
||||
- our-claim-gpios
|
||||
- their-claim-gpios
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
#include <dt-bindings/interrupt-controller/irq.h>
|
||||
|
||||
i2c-arbitrator {
|
||||
compatible = "i2c-arb-gpio-challenge";
|
||||
i2c-parent = <&i2c_4>;
|
||||
|
||||
our-claim-gpios = <&gpf0 3 GPIO_ACTIVE_LOW>;
|
||||
their-claim-gpios = <&gpe0 4 GPIO_ACTIVE_LOW>;
|
||||
slew-delay-us = <10>;
|
||||
wait-retry-us = <3000>;
|
||||
wait-free-us = <50000>;
|
||||
|
||||
i2c-arb {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
sbs-battery@b {
|
||||
compatible = "sbs,sbs-battery";
|
||||
reg = <0xb>;
|
||||
sbs,poll-retry-count = <1>;
|
||||
};
|
||||
|
||||
embedded-controller@1e {
|
||||
compatible = "google,cros-ec-i2c";
|
||||
reg = <0x1e>;
|
||||
interrupts = <6 IRQ_TYPE_LEVEL_HIGH>;
|
||||
interrupt-parent = <&gpx1>;
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&ec_irq>;
|
||||
wakeup-source;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -1,35 +0,0 @@
|
||||
Common i2c arbitration bus properties.
|
||||
|
||||
- i2c-arb child node
|
||||
|
||||
Required properties for the i2c-arb child node:
|
||||
- #address-cells = <1>;
|
||||
- #size-cells = <0>;
|
||||
|
||||
Optional properties for i2c-arb child node:
|
||||
- Child nodes conforming to i2c bus binding
|
||||
|
||||
|
||||
Example :
|
||||
|
||||
/*
|
||||
An NXP pca9541 I2C bus master selector at address 0x74
|
||||
with a NXP pca8574 GPIO expander attached.
|
||||
*/
|
||||
|
||||
arb@74 {
|
||||
compatible = "nxp,pca9541";
|
||||
reg = <0x74>;
|
||||
|
||||
i2c-arb {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
gpio@38 {
|
||||
compatible = "nxp,pca8574";
|
||||
reg = <0x38>;
|
||||
#gpio-cells = <2>;
|
||||
gpio-controller;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
* NXP PCA9541 I2C bus master selector
|
||||
|
||||
Required Properties:
|
||||
|
||||
- compatible: Must be "nxp,pca9541"
|
||||
|
||||
- reg: The I2C address of the device.
|
||||
|
||||
The following required properties are defined externally:
|
||||
|
||||
- I2C arbitration bus node. See i2c-arb.txt in this directory.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
i2c-arbitrator@74 {
|
||||
compatible = "nxp,pca9541";
|
||||
reg = <0x74>;
|
||||
|
||||
i2c-arb {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
eeprom@54 {
|
||||
compatible = "atmel,24c08";
|
||||
reg = <0x54>;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/i2c/nxp,pca9541.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: NXP PCA9541 I2C bus master selector
|
||||
|
||||
maintainers:
|
||||
- Peter Rosin <peda@axentia.se>
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
const: nxp,pca9541
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
i2c-arb:
|
||||
type: object
|
||||
$ref: /schemas/i2c/i2c-controller.yaml
|
||||
unevaluatedProperties: false
|
||||
description:
|
||||
I2C arbitration bus node.
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
- i2c-arb
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
#include <dt-bindings/interrupt-controller/irq.h>
|
||||
|
||||
i2c {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
i2c-arbitrator@74 {
|
||||
compatible = "nxp,pca9541";
|
||||
reg = <0x74>;
|
||||
|
||||
i2c-arb {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
eeprom@54 {
|
||||
compatible = "atmel,24c08";
|
||||
reg = <0x54>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -342,7 +342,6 @@ static void i2c_au1550_remove(struct platform_device *pdev)
|
||||
i2c_au1550_disable(priv);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int i2c_au1550_suspend(struct device *dev)
|
||||
{
|
||||
struct i2c_au1550_data *priv = dev_get_drvdata(dev);
|
||||
@@ -361,21 +360,13 @@ static int i2c_au1550_resume(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops i2c_au1550_pmops = {
|
||||
.suspend = i2c_au1550_suspend,
|
||||
.resume = i2c_au1550_resume,
|
||||
};
|
||||
|
||||
#define AU1XPSC_SMBUS_PMOPS (&i2c_au1550_pmops)
|
||||
|
||||
#else
|
||||
#define AU1XPSC_SMBUS_PMOPS NULL
|
||||
#endif
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(i2c_au1550_pmops,
|
||||
i2c_au1550_suspend, i2c_au1550_resume);
|
||||
|
||||
static struct platform_driver au1xpsc_smbus_driver = {
|
||||
.driver = {
|
||||
.name = "au1xpsc_smbus",
|
||||
.pm = AU1XPSC_SMBUS_PMOPS,
|
||||
.pm = pm_sleep_ptr(&i2c_au1550_pmops),
|
||||
},
|
||||
.probe = i2c_au1550_probe,
|
||||
.remove_new = i2c_au1550_remove,
|
||||
|
||||
@@ -1125,8 +1125,6 @@ static void bcm_iproc_i2c_remove(struct platform_device *pdev)
|
||||
bcm_iproc_i2c_enable_disable(iproc_i2c, false);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
|
||||
static int bcm_iproc_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct bcm_iproc_i2c_dev *iproc_i2c = dev_get_drvdata(dev);
|
||||
@@ -1177,12 +1175,6 @@ static const struct dev_pm_ops bcm_iproc_i2c_pm_ops = {
|
||||
.resume_early = &bcm_iproc_i2c_resume
|
||||
};
|
||||
|
||||
#define BCM_IPROC_I2C_PM_OPS (&bcm_iproc_i2c_pm_ops)
|
||||
#else
|
||||
#define BCM_IPROC_I2C_PM_OPS NULL
|
||||
#endif /* CONFIG_PM_SLEEP */
|
||||
|
||||
|
||||
static int bcm_iproc_i2c_reg_slave(struct i2c_client *slave)
|
||||
{
|
||||
struct bcm_iproc_i2c_dev *iproc_i2c = i2c_get_adapdata(slave->adapter);
|
||||
@@ -1255,7 +1247,7 @@ static struct platform_driver bcm_iproc_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "bcm-iproc-i2c",
|
||||
.of_match_table = bcm_iproc_i2c_of_match,
|
||||
.pm = BCM_IPROC_I2C_PM_OPS,
|
||||
.pm = pm_sleep_ptr(&bcm_iproc_i2c_pm_ops),
|
||||
},
|
||||
.probe = bcm_iproc_i2c_probe,
|
||||
.remove_new = bcm_iproc_i2c_remove,
|
||||
|
||||
@@ -430,10 +430,9 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
|
||||
|
||||
i2c_dev->bus_clk = bcm2835_i2c_register_div(&pdev->dev, mclk, i2c_dev);
|
||||
|
||||
if (IS_ERR(i2c_dev->bus_clk)) {
|
||||
dev_err(&pdev->dev, "Could not register clock\n");
|
||||
return PTR_ERR(i2c_dev->bus_clk);
|
||||
}
|
||||
if (IS_ERR(i2c_dev->bus_clk))
|
||||
return dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->bus_clk),
|
||||
"Could not register clock\n");
|
||||
|
||||
ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
|
||||
&bus_clk_rate);
|
||||
@@ -444,10 +443,9 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
ret = clk_set_rate_exclusive(i2c_dev->bus_clk, bus_clk_rate);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "Could not set clock frequency\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(&pdev->dev, ret,
|
||||
"Could not set clock frequency\n");
|
||||
|
||||
ret = clk_prepare_enable(i2c_dev->bus_clk);
|
||||
if (ret) {
|
||||
|
||||
@@ -697,7 +697,6 @@ static void brcmstb_i2c_remove(struct platform_device *pdev)
|
||||
i2c_del_adapter(&dev->adapter);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int brcmstb_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct brcmstb_i2c_dev *i2c_dev = dev_get_drvdata(dev);
|
||||
@@ -715,10 +714,9 @@ static int brcmstb_i2c_resume(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm, brcmstb_i2c_suspend,
|
||||
brcmstb_i2c_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(brcmstb_i2c_pm, brcmstb_i2c_suspend,
|
||||
brcmstb_i2c_resume);
|
||||
|
||||
static const struct of_device_id brcmstb_i2c_of_match[] = {
|
||||
{.compatible = "brcm,brcmstb-i2c"},
|
||||
@@ -732,7 +730,7 @@ static struct platform_driver brcmstb_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "brcmstb-i2c",
|
||||
.of_match_table = brcmstb_i2c_of_match,
|
||||
.pm = &brcmstb_i2c_pm,
|
||||
.pm = pm_sleep_ptr(&brcmstb_i2c_pm),
|
||||
},
|
||||
.probe = brcmstb_i2c_probe,
|
||||
.remove_new = brcmstb_i2c_remove,
|
||||
|
||||
@@ -765,7 +765,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0)
|
||||
return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n");
|
||||
return irq;
|
||||
|
||||
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
|
||||
if (!dev)
|
||||
@@ -902,7 +902,6 @@ static void davinci_i2c_remove(struct platform_device *pdev)
|
||||
pm_runtime_disable(dev->dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int davinci_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct davinci_i2c_dev *i2c_dev = dev_get_drvdata(dev);
|
||||
@@ -926,15 +925,10 @@ static int davinci_i2c_resume(struct device *dev)
|
||||
static const struct dev_pm_ops davinci_i2c_pm = {
|
||||
.suspend = davinci_i2c_suspend,
|
||||
.resume = davinci_i2c_resume,
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
|
||||
pm_runtime_force_resume)
|
||||
NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
|
||||
pm_runtime_force_resume)
|
||||
};
|
||||
|
||||
#define davinci_i2c_pm_ops (&davinci_i2c_pm)
|
||||
#else
|
||||
#define davinci_i2c_pm_ops NULL
|
||||
#endif
|
||||
|
||||
static const struct platform_device_id davinci_i2c_driver_ids[] = {
|
||||
{ .name = "i2c_davinci", },
|
||||
{ /* sentinel */ }
|
||||
@@ -947,7 +941,7 @@ static struct platform_driver davinci_i2c_driver = {
|
||||
.id_table = davinci_i2c_driver_ids,
|
||||
.driver = {
|
||||
.name = "i2c_davinci",
|
||||
.pm = davinci_i2c_pm_ops,
|
||||
.pm = pm_sleep_ptr(&davinci_i2c_pm),
|
||||
.of_match_table = davinci_i2c_of_match,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -418,7 +418,6 @@ static void dw_i2c_plat_remove(struct platform_device *pdev)
|
||||
reset_control_assert(dev->rst);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int dw_i2c_plat_prepare(struct device *dev)
|
||||
{
|
||||
/*
|
||||
@@ -429,11 +428,7 @@ static int dw_i2c_plat_prepare(struct device *dev)
|
||||
*/
|
||||
return !has_acpi_companion(dev);
|
||||
}
|
||||
#else
|
||||
#define dw_i2c_plat_prepare NULL
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int dw_i2c_plat_runtime_suspend(struct device *dev)
|
||||
{
|
||||
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
|
||||
@@ -447,7 +442,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __maybe_unused dw_i2c_plat_suspend(struct device *dev)
|
||||
static int dw_i2c_plat_suspend(struct device *dev)
|
||||
{
|
||||
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
|
||||
|
||||
@@ -468,7 +463,7 @@ static int dw_i2c_plat_runtime_resume(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __maybe_unused dw_i2c_plat_resume(struct device *dev)
|
||||
static int dw_i2c_plat_resume(struct device *dev)
|
||||
{
|
||||
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
|
||||
|
||||
@@ -479,16 +474,11 @@ static int __maybe_unused dw_i2c_plat_resume(struct device *dev)
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
|
||||
.prepare = dw_i2c_plat_prepare,
|
||||
SET_LATE_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume)
|
||||
SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL)
|
||||
.prepare = pm_sleep_ptr(dw_i2c_plat_prepare),
|
||||
LATE_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume)
|
||||
RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL)
|
||||
};
|
||||
|
||||
#define DW_I2C_DEV_PMOPS (&dw_i2c_dev_pm_ops)
|
||||
#else
|
||||
#define DW_I2C_DEV_PMOPS NULL
|
||||
#endif
|
||||
|
||||
/* Work with hotplug and coldplug */
|
||||
MODULE_ALIAS("platform:i2c_designware");
|
||||
|
||||
@@ -499,7 +489,7 @@ static struct platform_driver dw_i2c_driver = {
|
||||
.name = "i2c_designware",
|
||||
.of_match_table = of_match_ptr(dw_i2c_of_match),
|
||||
.acpi_match_table = ACPI_PTR(dw_i2c_acpi_match),
|
||||
.pm = DW_I2C_DEV_PMOPS,
|
||||
.pm = pm_ptr(&dw_i2c_dev_pm_ops),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -218,10 +218,8 @@ static int dln2_i2c_probe(struct platform_device *pdev)
|
||||
|
||||
/* initialize the i2c interface */
|
||||
ret = dln2_i2c_enable(dln2, true);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "failed to initialize adapter: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "failed to initialize adapter\n");
|
||||
|
||||
/* and finally attach to i2c layer */
|
||||
ret = i2c_add_adapter(&dln2->adapter);
|
||||
|
||||
@@ -892,7 +892,6 @@ static void exynos5_i2c_remove(struct platform_device *pdev)
|
||||
clk_unprepare(i2c->pclk);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int exynos5_i2c_suspend_noirq(struct device *dev)
|
||||
{
|
||||
struct exynos5_i2c *i2c = dev_get_drvdata(dev);
|
||||
@@ -934,11 +933,10 @@ err_pclk:
|
||||
clk_disable_unprepare(i2c->pclk);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct dev_pm_ops exynos5_i2c_dev_pm_ops = {
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(exynos5_i2c_suspend_noirq,
|
||||
exynos5_i2c_resume_noirq)
|
||||
NOIRQ_SYSTEM_SLEEP_PM_OPS(exynos5_i2c_suspend_noirq,
|
||||
exynos5_i2c_resume_noirq)
|
||||
};
|
||||
|
||||
static struct platform_driver exynos5_i2c_driver = {
|
||||
@@ -946,7 +944,7 @@ static struct platform_driver exynos5_i2c_driver = {
|
||||
.remove_new = exynos5_i2c_remove,
|
||||
.driver = {
|
||||
.name = "exynos5-hsi2c",
|
||||
.pm = &exynos5_i2c_dev_pm_ops,
|
||||
.pm = pm_sleep_ptr(&exynos5_i2c_dev_pm_ops),
|
||||
.of_match_table = exynos5_i2c_match,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -462,18 +462,14 @@ static int hisi_i2c_probe(struct platform_device *pdev)
|
||||
hisi_i2c_disable_int(ctlr, HISI_I2C_INT_ALL);
|
||||
|
||||
ret = devm_request_irq(dev, ctlr->irq, hisi_i2c_irq, 0, "hisi-i2c", ctlr);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to request irq handler, ret = %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to request irq handler\n");
|
||||
|
||||
ctlr->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
|
||||
if (IS_ERR_OR_NULL(ctlr->clk)) {
|
||||
ret = device_property_read_u64(dev, "clk_rate", &clk_rate_hz);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to get clock frequency, ret = %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to get clock frequency\n");
|
||||
} else {
|
||||
clk_rate_hz = clk_get_rate(ctlr->clk);
|
||||
}
|
||||
|
||||
@@ -475,7 +475,6 @@ static void hix5hd2_i2c_remove(struct platform_device *pdev)
|
||||
pm_runtime_set_suspended(priv->dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int hix5hd2_i2c_runtime_suspend(struct device *dev)
|
||||
{
|
||||
struct hix5hd2_i2c_priv *priv = dev_get_drvdata(dev);
|
||||
@@ -494,12 +493,11 @@ static int hix5hd2_i2c_runtime_resume(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct dev_pm_ops hix5hd2_i2c_pm_ops = {
|
||||
SET_RUNTIME_PM_OPS(hix5hd2_i2c_runtime_suspend,
|
||||
hix5hd2_i2c_runtime_resume,
|
||||
NULL)
|
||||
RUNTIME_PM_OPS(hix5hd2_i2c_runtime_suspend,
|
||||
hix5hd2_i2c_runtime_resume,
|
||||
NULL)
|
||||
};
|
||||
|
||||
static const struct of_device_id hix5hd2_i2c_match[] = {
|
||||
@@ -513,7 +511,7 @@ static struct platform_driver hix5hd2_i2c_driver = {
|
||||
.remove_new = hix5hd2_i2c_remove,
|
||||
.driver = {
|
||||
.name = "hix5hd2-i2c",
|
||||
.pm = &hix5hd2_i2c_pm_ops,
|
||||
.pm = pm_ptr(&hix5hd2_i2c_pm_ops),
|
||||
.of_match_table = hix5hd2_i2c_match,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1808,7 +1808,6 @@ static void i801_shutdown(struct pci_dev *dev)
|
||||
pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int i801_suspend(struct device *dev)
|
||||
{
|
||||
struct i801_priv *priv = dev_get_drvdata(dev);
|
||||
@@ -1827,9 +1826,8 @@ static int i801_resume(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume);
|
||||
|
||||
static struct pci_driver i801_driver = {
|
||||
.name = DRV_NAME,
|
||||
@@ -1838,7 +1836,7 @@ static struct pci_driver i801_driver = {
|
||||
.remove = i801_remove,
|
||||
.shutdown = i801_shutdown,
|
||||
.driver = {
|
||||
.pm = &i801_pm_ops,
|
||||
.pm = pm_sleep_ptr(&i801_pm_ops),
|
||||
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1454,7 +1454,6 @@ static int img_i2c_runtime_resume(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int img_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct img_i2c *i2c = dev_get_drvdata(dev);
|
||||
@@ -1482,13 +1481,10 @@ static int img_i2c_resume(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_PM_SLEEP */
|
||||
|
||||
static const struct dev_pm_ops img_i2c_pm = {
|
||||
SET_RUNTIME_PM_OPS(img_i2c_runtime_suspend,
|
||||
img_i2c_runtime_resume,
|
||||
NULL)
|
||||
SET_SYSTEM_SLEEP_PM_OPS(img_i2c_suspend, img_i2c_resume)
|
||||
RUNTIME_PM_OPS(img_i2c_runtime_suspend, img_i2c_runtime_resume, NULL)
|
||||
SYSTEM_SLEEP_PM_OPS(img_i2c_suspend, img_i2c_resume)
|
||||
};
|
||||
|
||||
static const struct of_device_id img_scb_i2c_match[] = {
|
||||
@@ -1501,7 +1497,7 @@ static struct platform_driver img_scb_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "img-i2c-scb",
|
||||
.of_match_table = img_scb_i2c_match,
|
||||
.pm = &img_i2c_pm,
|
||||
.pm = pm_ptr(&img_i2c_pm),
|
||||
},
|
||||
.probe = img_i2c_probe,
|
||||
.remove_new = img_i2c_remove,
|
||||
|
||||
@@ -514,14 +514,12 @@ static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id)
|
||||
temp = readl(lpi2c_imx->base + LPI2C_MSR);
|
||||
temp &= enabled;
|
||||
|
||||
if (temp & MSR_RDF)
|
||||
lpi2c_imx_read_rxfifo(lpi2c_imx);
|
||||
|
||||
if (temp & MSR_TDF)
|
||||
lpi2c_imx_write_txfifo(lpi2c_imx);
|
||||
|
||||
if (temp & MSR_NDF)
|
||||
complete(&lpi2c_imx->complete);
|
||||
else if (temp & MSR_RDF)
|
||||
lpi2c_imx_read_rxfifo(lpi2c_imx);
|
||||
else if (temp & MSR_TDF)
|
||||
lpi2c_imx_write_txfifo(lpi2c_imx);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
@@ -569,10 +567,8 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
|
||||
sizeof(lpi2c_imx->adapter.name));
|
||||
|
||||
ret = devm_clk_bulk_get_all(&pdev->dev, &lpi2c_imx->clks);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "can't get I2C peripheral clock, ret=%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(&pdev->dev, ret, "can't get I2C peripheral clock\n");
|
||||
lpi2c_imx->num_clks = ret;
|
||||
|
||||
ret = of_property_read_u32(pdev->dev.of_node,
|
||||
@@ -582,10 +578,8 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
|
||||
|
||||
ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, 0,
|
||||
pdev->name, lpi2c_imx);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "can't claim irq %d\n", irq);
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(&pdev->dev, ret, "can't claim irq %d\n", irq);
|
||||
|
||||
i2c_set_adapdata(&lpi2c_imx->adapter, lpi2c_imx);
|
||||
platform_set_drvdata(pdev, lpi2c_imx);
|
||||
|
||||
@@ -1506,8 +1506,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
|
||||
goto rpm_disable;
|
||||
|
||||
/* Request IRQ */
|
||||
ret = request_threaded_irq(irq, i2c_imx_isr, NULL, IRQF_SHARED,
|
||||
pdev->name, i2c_imx);
|
||||
ret = request_irq(irq, i2c_imx_isr, IRQF_SHARED, pdev->name, i2c_imx);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "can't claim irq %d\n", irq);
|
||||
goto rpm_disable;
|
||||
|
||||
@@ -350,10 +350,9 @@ static void kempld_i2c_remove(struct platform_device *pdev)
|
||||
i2c_del_adapter(&i2c->adap);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int kempld_i2c_suspend(struct platform_device *pdev, pm_message_t state)
|
||||
static int kempld_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct kempld_i2c_data *i2c = platform_get_drvdata(pdev);
|
||||
struct kempld_i2c_data *i2c = dev_get_drvdata(dev);
|
||||
struct kempld_device_data *pld = i2c->pld;
|
||||
u8 ctrl;
|
||||
|
||||
@@ -366,9 +365,9 @@ static int kempld_i2c_suspend(struct platform_device *pdev, pm_message_t state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int kempld_i2c_resume(struct platform_device *pdev)
|
||||
static int kempld_i2c_resume(struct device *dev)
|
||||
{
|
||||
struct kempld_i2c_data *i2c = platform_get_drvdata(pdev);
|
||||
struct kempld_i2c_data *i2c = dev_get_drvdata(dev);
|
||||
struct kempld_device_data *pld = i2c->pld;
|
||||
|
||||
kempld_get_mutex(pld);
|
||||
@@ -377,19 +376,17 @@ static int kempld_i2c_resume(struct platform_device *pdev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#define kempld_i2c_suspend NULL
|
||||
#define kempld_i2c_resume NULL
|
||||
#endif
|
||||
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(kempld_i2c_pm_ops,
|
||||
kempld_i2c_suspend, kempld_i2c_resume);
|
||||
|
||||
static struct platform_driver kempld_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "kempld-i2c",
|
||||
.pm = pm_sleep_ptr(&kempld_i2c_pm_ops),
|
||||
},
|
||||
.probe = kempld_i2c_probe,
|
||||
.remove_new = kempld_i2c_remove,
|
||||
.suspend = kempld_i2c_suspend,
|
||||
.resume = kempld_i2c_resume,
|
||||
};
|
||||
|
||||
module_platform_driver(kempld_i2c_driver);
|
||||
|
||||
@@ -431,7 +431,6 @@ static void i2c_lpc2k_remove(struct platform_device *dev)
|
||||
i2c_del_adapter(&i2c->adap);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int i2c_lpc2k_suspend(struct device *dev)
|
||||
{
|
||||
struct lpc2k_i2c *i2c = dev_get_drvdata(dev);
|
||||
@@ -456,11 +455,6 @@ static const struct dev_pm_ops i2c_lpc2k_dev_pm_ops = {
|
||||
.resume_noirq = i2c_lpc2k_resume,
|
||||
};
|
||||
|
||||
#define I2C_LPC2K_DEV_PM_OPS (&i2c_lpc2k_dev_pm_ops)
|
||||
#else
|
||||
#define I2C_LPC2K_DEV_PM_OPS NULL
|
||||
#endif
|
||||
|
||||
static const struct of_device_id lpc2k_i2c_match[] = {
|
||||
{ .compatible = "nxp,lpc1788-i2c" },
|
||||
{},
|
||||
@@ -472,7 +466,7 @@ static struct platform_driver i2c_lpc2k_driver = {
|
||||
.remove_new = i2c_lpc2k_remove,
|
||||
.driver = {
|
||||
.name = "lpc2k-i2c",
|
||||
.pm = I2C_LPC2K_DEV_PM_OPS,
|
||||
.pm = pm_sleep_ptr(&i2c_lpc2k_dev_pm_ops),
|
||||
.of_match_table = lpc2k_i2c_match,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -378,9 +378,8 @@ static int mchp_corei2c_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(idev->base);
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq <= 0)
|
||||
return dev_err_probe(&pdev->dev, -ENXIO,
|
||||
"invalid IRQ %d for I2C controller\n", irq);
|
||||
if (irq < 0)
|
||||
return irq;
|
||||
|
||||
idev->i2c_clk = devm_clk_get(&pdev->dev, NULL);
|
||||
if (IS_ERR(idev->i2c_clk))
|
||||
|
||||
@@ -2323,10 +2323,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
|
||||
|
||||
ret = mlxbf_i2c_init_resource(pdev, &priv->smbus,
|
||||
MLXBF_I2C_SMBUS_RES);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Cannot fetch smbus resource info");
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "Cannot fetch smbus resource info");
|
||||
|
||||
priv->timer->io = priv->smbus->io;
|
||||
priv->mst->io = priv->smbus->io + MLXBF_I2C_MST_ADDR_OFFSET;
|
||||
@@ -2334,39 +2332,29 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
|
||||
} else {
|
||||
ret = mlxbf_i2c_init_resource(pdev, &priv->timer,
|
||||
MLXBF_I2C_SMBUS_TIMER_RES);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Cannot fetch timer resource info");
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "Cannot fetch timer resource info");
|
||||
|
||||
ret = mlxbf_i2c_init_resource(pdev, &priv->mst,
|
||||
MLXBF_I2C_SMBUS_MST_RES);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Cannot fetch master resource info");
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "Cannot fetch master resource info");
|
||||
|
||||
ret = mlxbf_i2c_init_resource(pdev, &priv->slv,
|
||||
MLXBF_I2C_SMBUS_SLV_RES);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Cannot fetch slave resource info");
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "Cannot fetch slave resource info");
|
||||
}
|
||||
|
||||
ret = mlxbf_i2c_init_resource(pdev, &priv->mst_cause,
|
||||
MLXBF_I2C_MST_CAUSE_RES);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Cannot fetch cause master resource info");
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "Cannot fetch cause master resource info");
|
||||
|
||||
ret = mlxbf_i2c_init_resource(pdev, &priv->slv_cause,
|
||||
MLXBF_I2C_SLV_CAUSE_RES);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Cannot fetch cause slave resource info");
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "Cannot fetch cause slave resource info");
|
||||
|
||||
adap = &priv->adap;
|
||||
adap->owner = THIS_MODULE;
|
||||
@@ -2397,11 +2385,9 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
|
||||
* does not really hurt, then keep the code as is.
|
||||
*/
|
||||
ret = mlxbf_i2c_init_master(pdev, priv);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "failed to initialize smbus master %d",
|
||||
priv->bus);
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "failed to initialize smbus master %d",
|
||||
priv->bus);
|
||||
|
||||
mlxbf_i2c_init_timings(pdev, priv);
|
||||
|
||||
@@ -2413,10 +2399,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
|
||||
ret = devm_request_irq(dev, irq, mlxbf_i2c_irq,
|
||||
IRQF_SHARED | IRQF_PROBE_SHARED,
|
||||
dev_name(dev), priv);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Cannot get irq %d\n", irq);
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(dev, ret, "Cannot get irq %d\n", irq);
|
||||
|
||||
priv->irq = irq;
|
||||
|
||||
|
||||
@@ -1514,7 +1514,6 @@ static void mtk_i2c_remove(struct platform_device *pdev)
|
||||
clk_bulk_unprepare(I2C_MT65XX_CLK_MAX, i2c->clocks);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int mtk_i2c_suspend_noirq(struct device *dev)
|
||||
{
|
||||
struct mtk_i2c *i2c = dev_get_drvdata(dev);
|
||||
@@ -1544,11 +1543,10 @@ static int mtk_i2c_resume_noirq(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct dev_pm_ops mtk_i2c_pm = {
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_i2c_suspend_noirq,
|
||||
mtk_i2c_resume_noirq)
|
||||
NOIRQ_SYSTEM_SLEEP_PM_OPS(mtk_i2c_suspend_noirq,
|
||||
mtk_i2c_resume_noirq)
|
||||
};
|
||||
|
||||
static struct platform_driver mtk_i2c_driver = {
|
||||
@@ -1556,7 +1554,7 @@ static struct platform_driver mtk_i2c_driver = {
|
||||
.remove_new = mtk_i2c_remove,
|
||||
.driver = {
|
||||
.name = I2C_DRV_NAME,
|
||||
.pm = &mtk_i2c_pm,
|
||||
.pm = pm_sleep_ptr(&mtk_i2c_pm),
|
||||
.of_match_table = mtk_i2c_of_match,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -873,7 +873,6 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg)
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int nmk_i2c_suspend_late(struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
@@ -890,9 +889,7 @@ static int nmk_i2c_resume_early(struct device *dev)
|
||||
{
|
||||
return pm_runtime_force_resume(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int nmk_i2c_runtime_suspend(struct device *dev)
|
||||
{
|
||||
struct amba_device *adev = to_amba_device(dev);
|
||||
@@ -925,13 +922,10 @@ static int nmk_i2c_runtime_resume(struct device *dev)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct dev_pm_ops nmk_i2c_pm = {
|
||||
SET_LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early)
|
||||
SET_RUNTIME_PM_OPS(nmk_i2c_runtime_suspend,
|
||||
nmk_i2c_runtime_resume,
|
||||
NULL)
|
||||
LATE_SYSTEM_SLEEP_PM_OPS(nmk_i2c_suspend_late, nmk_i2c_resume_early)
|
||||
RUNTIME_PM_OPS(nmk_i2c_runtime_suspend, nmk_i2c_runtime_resume, NULL)
|
||||
};
|
||||
|
||||
static unsigned int nmk_i2c_functionality(struct i2c_adapter *adap)
|
||||
@@ -1078,7 +1072,7 @@ static struct amba_driver nmk_i2c_driver = {
|
||||
.drv = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = DRIVER_NAME,
|
||||
.pm = &nmk_i2c_pm,
|
||||
.pm = pm_ptr(&nmk_i2c_pm),
|
||||
},
|
||||
.id_table = nmk_i2c_ids,
|
||||
.probe = nmk_i2c_probe,
|
||||
|
||||
@@ -743,7 +743,6 @@ static void ocores_i2c_remove(struct platform_device *pdev)
|
||||
i2c_del_adapter(&i2c->adap);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int ocores_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct ocores_i2c *i2c = dev_get_drvdata(dev);
|
||||
@@ -772,11 +771,8 @@ static int ocores_i2c_resume(struct device *dev)
|
||||
return ocores_init(dev, i2c);
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(ocores_i2c_pm, ocores_i2c_suspend, ocores_i2c_resume);
|
||||
#define OCORES_I2C_PM (&ocores_i2c_pm)
|
||||
#else
|
||||
#define OCORES_I2C_PM NULL
|
||||
#endif
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(ocores_i2c_pm,
|
||||
ocores_i2c_suspend, ocores_i2c_resume);
|
||||
|
||||
static struct platform_driver ocores_i2c_driver = {
|
||||
.probe = ocores_i2c_probe,
|
||||
@@ -784,7 +780,7 @@ static struct platform_driver ocores_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "ocores-i2c",
|
||||
.of_match_table = ocores_i2c_match,
|
||||
.pm = OCORES_I2C_PM,
|
||||
.pm = pm_sleep_ptr(&ocores_i2c_pm),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -613,7 +613,6 @@ static const struct i2c_algorithm pnx_algorithm = {
|
||||
.functionality = i2c_pnx_func,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int i2c_pnx_controller_suspend(struct device *dev)
|
||||
{
|
||||
struct i2c_pnx_algo_data *alg_data = dev_get_drvdata(dev);
|
||||
@@ -630,12 +629,9 @@ static int i2c_pnx_controller_resume(struct device *dev)
|
||||
return clk_prepare_enable(alg_data->clk);
|
||||
}
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(i2c_pnx_pm,
|
||||
i2c_pnx_controller_suspend, i2c_pnx_controller_resume);
|
||||
#define PNX_I2C_PM (&i2c_pnx_pm)
|
||||
#else
|
||||
#define PNX_I2C_PM NULL
|
||||
#endif
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(i2c_pnx_pm,
|
||||
i2c_pnx_controller_suspend,
|
||||
i2c_pnx_controller_resume);
|
||||
|
||||
static int i2c_pnx_probe(struct platform_device *pdev)
|
||||
{
|
||||
@@ -763,7 +759,7 @@ static struct platform_driver i2c_pnx_driver = {
|
||||
.driver = {
|
||||
.name = "pnx-i2c",
|
||||
.of_match_table = of_match_ptr(i2c_pnx_of_match),
|
||||
.pm = PNX_I2C_PM,
|
||||
.pm = pm_sleep_ptr(&i2c_pnx_pm),
|
||||
},
|
||||
.probe = i2c_pnx_probe,
|
||||
.remove_new = i2c_pnx_remove,
|
||||
|
||||
@@ -1404,10 +1404,9 @@ static int i2c_pxa_probe(struct platform_device *dev)
|
||||
strscpy(i2c->adap.name, "pxa_i2c-i2c", sizeof(i2c->adap.name));
|
||||
|
||||
i2c->clk = devm_clk_get(&dev->dev, NULL);
|
||||
if (IS_ERR(i2c->clk)) {
|
||||
dev_err(&dev->dev, "failed to get the clk: %ld\n", PTR_ERR(i2c->clk));
|
||||
return PTR_ERR(i2c->clk);
|
||||
}
|
||||
if (IS_ERR(i2c->clk))
|
||||
return dev_err_probe(&dev->dev, PTR_ERR(i2c->clk),
|
||||
"failed to get the clk\n");
|
||||
|
||||
i2c->reg_ibmr = i2c->reg_base + pxa_reg_layout[i2c_type].ibmr;
|
||||
i2c->reg_idbr = i2c->reg_base + pxa_reg_layout[i2c_type].idbr;
|
||||
@@ -1491,7 +1490,6 @@ static void i2c_pxa_remove(struct platform_device *dev)
|
||||
clk_disable_unprepare(i2c->clk);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int i2c_pxa_suspend_noirq(struct device *dev)
|
||||
{
|
||||
struct pxa_i2c *i2c = dev_get_drvdata(dev);
|
||||
@@ -1516,17 +1514,12 @@ static const struct dev_pm_ops i2c_pxa_dev_pm_ops = {
|
||||
.resume_noirq = i2c_pxa_resume_noirq,
|
||||
};
|
||||
|
||||
#define I2C_PXA_DEV_PM_OPS (&i2c_pxa_dev_pm_ops)
|
||||
#else
|
||||
#define I2C_PXA_DEV_PM_OPS NULL
|
||||
#endif
|
||||
|
||||
static struct platform_driver i2c_pxa_driver = {
|
||||
.probe = i2c_pxa_probe,
|
||||
.remove_new = i2c_pxa_remove,
|
||||
.driver = {
|
||||
.name = "pxa2xx-i2c",
|
||||
.pm = I2C_PXA_DEV_PM_OPS,
|
||||
.pm = pm_sleep_ptr(&i2c_pxa_dev_pm_ops),
|
||||
.of_match_table = i2c_pxa_dt_ids,
|
||||
},
|
||||
.id_table = i2c_pxa_id_table,
|
||||
|
||||
@@ -588,10 +588,8 @@ static int cci_probe(struct platform_device *pdev)
|
||||
/* Clocks */
|
||||
|
||||
ret = devm_clk_bulk_get_all(dev, &cci->clocks);
|
||||
if (ret < 1) {
|
||||
dev_err(dev, "failed to get clocks %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
if (ret < 1)
|
||||
return dev_err_probe(dev, ret, "failed to get clocks\n");
|
||||
cci->nclocks = ret;
|
||||
|
||||
/* Retrieve CCI clock rate */
|
||||
|
||||
@@ -1927,7 +1927,6 @@ static void qup_i2c_remove(struct platform_device *pdev)
|
||||
pm_runtime_set_suspended(qup->dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int qup_i2c_pm_suspend_runtime(struct device *device)
|
||||
{
|
||||
struct qup_i2c_dev *qup = dev_get_drvdata(device);
|
||||
@@ -1945,9 +1944,7 @@ static int qup_i2c_pm_resume_runtime(struct device *device)
|
||||
qup_i2c_enable_clocks(qup);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int qup_i2c_suspend(struct device *device)
|
||||
{
|
||||
if (!pm_runtime_suspended(device))
|
||||
@@ -1962,16 +1959,11 @@ static int qup_i2c_resume(struct device *device)
|
||||
pm_request_autosuspend(device);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const struct dev_pm_ops qup_i2c_qup_pm_ops = {
|
||||
SET_SYSTEM_SLEEP_PM_OPS(
|
||||
qup_i2c_suspend,
|
||||
qup_i2c_resume)
|
||||
SET_RUNTIME_PM_OPS(
|
||||
qup_i2c_pm_suspend_runtime,
|
||||
qup_i2c_pm_resume_runtime,
|
||||
NULL)
|
||||
SYSTEM_SLEEP_PM_OPS(qup_i2c_suspend, qup_i2c_resume)
|
||||
RUNTIME_PM_OPS(qup_i2c_pm_suspend_runtime,
|
||||
qup_i2c_pm_resume_runtime, NULL)
|
||||
};
|
||||
|
||||
static const struct of_device_id qup_i2c_dt_match[] = {
|
||||
@@ -1987,7 +1979,7 @@ static struct platform_driver qup_i2c_driver = {
|
||||
.remove_new = qup_i2c_remove,
|
||||
.driver = {
|
||||
.name = "i2c_qup",
|
||||
.pm = &qup_i2c_qup_pm_ops,
|
||||
.pm = pm_ptr(&qup_i2c_qup_pm_ops),
|
||||
.of_match_table = qup_i2c_dt_match,
|
||||
.acpi_match_table = ACPI_PTR(qup_i2c_acpi_match),
|
||||
},
|
||||
|
||||
@@ -1169,7 +1169,6 @@ static void rcar_i2c_remove(struct platform_device *pdev)
|
||||
pm_runtime_disable(dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int rcar_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct rcar_i2c_priv *priv = dev_get_drvdata(dev);
|
||||
@@ -1187,19 +1186,14 @@ static int rcar_i2c_resume(struct device *dev)
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops rcar_i2c_pm_ops = {
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(rcar_i2c_suspend, rcar_i2c_resume)
|
||||
NOIRQ_SYSTEM_SLEEP_PM_OPS(rcar_i2c_suspend, rcar_i2c_resume)
|
||||
};
|
||||
|
||||
#define DEV_PM_OPS (&rcar_i2c_pm_ops)
|
||||
#else
|
||||
#define DEV_PM_OPS NULL
|
||||
#endif /* CONFIG_PM_SLEEP */
|
||||
|
||||
static struct platform_driver rcar_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "i2c-rcar",
|
||||
.of_match_table = rcar_i2c_dt_ids,
|
||||
.pm = DEV_PM_OPS,
|
||||
.pm = pm_sleep_ptr(&rcar_i2c_pm_ops),
|
||||
},
|
||||
.probe = rcar_i2c_probe,
|
||||
.remove_new = rcar_i2c_remove,
|
||||
|
||||
@@ -1076,7 +1076,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
|
||||
if (!(i2c->quirks & QUIRK_POLL)) {
|
||||
i2c->irq = ret = platform_get_irq(pdev, 0);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "cannot find IRQ\n");
|
||||
clk_unprepare(i2c->clk);
|
||||
return ret;
|
||||
}
|
||||
@@ -1125,7 +1124,6 @@ static void s3c24xx_i2c_remove(struct platform_device *pdev)
|
||||
i2c_del_adapter(&i2c->adap);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int s3c24xx_i2c_suspend_noirq(struct device *dev)
|
||||
{
|
||||
struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
|
||||
@@ -1155,26 +1153,19 @@ static int s3c24xx_i2c_resume_noirq(struct device *dev)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(s3c24xx_i2c_suspend_noirq,
|
||||
s3c24xx_i2c_resume_noirq)
|
||||
NOIRQ_SYSTEM_SLEEP_PM_OPS(s3c24xx_i2c_suspend_noirq,
|
||||
s3c24xx_i2c_resume_noirq)
|
||||
};
|
||||
|
||||
#define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops)
|
||||
#else
|
||||
#define S3C24XX_DEV_PM_OPS NULL
|
||||
#endif
|
||||
|
||||
static struct platform_driver s3c24xx_i2c_driver = {
|
||||
.probe = s3c24xx_i2c_probe,
|
||||
.remove_new = s3c24xx_i2c_remove,
|
||||
.id_table = s3c24xx_driver_ids,
|
||||
.driver = {
|
||||
.name = "s3c-i2c",
|
||||
.pm = S3C24XX_DEV_PM_OPS,
|
||||
.pm = pm_sleep_ptr(&s3c24xx_i2c_dev_pm_ops),
|
||||
.of_match_table = of_match_ptr(s3c24xx_i2c_match),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -965,7 +965,6 @@ static void sh_mobile_i2c_remove(struct platform_device *dev)
|
||||
pm_runtime_disable(&dev->dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int sh_mobile_i2c_suspend(struct device *dev)
|
||||
{
|
||||
struct sh_mobile_i2c_data *pd = dev_get_drvdata(dev);
|
||||
@@ -983,20 +982,15 @@ static int sh_mobile_i2c_resume(struct device *dev)
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops sh_mobile_i2c_pm_ops = {
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sh_mobile_i2c_suspend,
|
||||
sh_mobile_i2c_resume)
|
||||
NOIRQ_SYSTEM_SLEEP_PM_OPS(sh_mobile_i2c_suspend,
|
||||
sh_mobile_i2c_resume)
|
||||
};
|
||||
|
||||
#define DEV_PM_OPS (&sh_mobile_i2c_pm_ops)
|
||||
#else
|
||||
#define DEV_PM_OPS NULL
|
||||
#endif /* CONFIG_PM_SLEEP */
|
||||
|
||||
static struct platform_driver sh_mobile_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "i2c-sh_mobile",
|
||||
.of_match_table = sh_mobile_i2c_dt_ids,
|
||||
.pm = DEV_PM_OPS,
|
||||
.pm = pm_sleep_ptr(&sh_mobile_i2c_pm_ops),
|
||||
},
|
||||
.probe = sh_mobile_i2c_probe,
|
||||
.remove_new = sh_mobile_i2c_remove,
|
||||
|
||||
@@ -2121,12 +2121,12 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
|
||||
phy_addr = (dma_addr_t)res->start;
|
||||
|
||||
irq_event = platform_get_irq(pdev, 0);
|
||||
if (irq_event <= 0)
|
||||
return irq_event ? : -ENOENT;
|
||||
if (irq_event < 0)
|
||||
return irq_event;
|
||||
|
||||
irq_error = platform_get_irq(pdev, 1);
|
||||
if (irq_error <= 0)
|
||||
return irq_error ? : -ENOENT;
|
||||
if (irq_error < 0)
|
||||
return irq_error;
|
||||
|
||||
i2c_dev->wakeup_src = of_property_read_bool(pdev->dev.of_node,
|
||||
"wakeup-source");
|
||||
|
||||
@@ -557,20 +557,16 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
|
||||
dev_dbg(&pdev->dev, "clock source %p\n", i2c->pclk);
|
||||
|
||||
ret = clk_prepare_enable(i2c->pclk);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to enable clock (%d)\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(&pdev->dev, ret, "failed to enable clock\n");
|
||||
i2c->pclkrate = clk_get_rate(i2c->pclk);
|
||||
}
|
||||
|
||||
if (i2c->pclkrate < SYNQUACER_I2C_MIN_CLK_RATE ||
|
||||
i2c->pclkrate > SYNQUACER_I2C_MAX_CLK_RATE) {
|
||||
dev_err(&pdev->dev, "PCLK missing or out of range (%d)\n",
|
||||
i2c->pclkrate);
|
||||
return -EINVAL;
|
||||
}
|
||||
i2c->pclkrate > SYNQUACER_I2C_MAX_CLK_RATE)
|
||||
return dev_err_probe(&pdev->dev, -EINVAL,
|
||||
"PCLK missing or out of range (%d)\n",
|
||||
i2c->pclkrate);
|
||||
|
||||
i2c->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(i2c->base))
|
||||
@@ -582,10 +578,8 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
|
||||
|
||||
ret = devm_request_irq(&pdev->dev, i2c->irq, synquacer_i2c_isr,
|
||||
0, dev_name(&pdev->dev), i2c);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
|
||||
return ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return dev_err_probe(&pdev->dev, ret, "cannot claim IRQ %d\n", i2c->irq);
|
||||
|
||||
i2c->state = STATE_IDLE;
|
||||
i2c->dev = &pdev->dev;
|
||||
@@ -605,10 +599,8 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
|
||||
synquacer_i2c_hw_init(i2c);
|
||||
|
||||
ret = i2c_add_numbered_adapter(&i2c->adapter);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to add bus to i2c core\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(&pdev->dev, ret, "failed to add bus to i2c core\n");
|
||||
|
||||
platform_set_drvdata(pdev, i2c);
|
||||
|
||||
|
||||
@@ -243,7 +243,6 @@ static struct virtio_device_id id_table[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(virtio, id_table);
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int virtio_i2c_freeze(struct virtio_device *vdev)
|
||||
{
|
||||
virtio_i2c_del_vqs(vdev);
|
||||
@@ -254,7 +253,6 @@ static int virtio_i2c_restore(struct virtio_device *vdev)
|
||||
{
|
||||
return virtio_i2c_setup_vqs(vdev->priv);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const unsigned int features[] = {
|
||||
VIRTIO_I2C_F_ZERO_LENGTH_REQUEST,
|
||||
@@ -269,10 +267,8 @@ static struct virtio_driver virtio_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "i2c_virtio",
|
||||
},
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
.freeze = virtio_i2c_freeze,
|
||||
.restore = virtio_i2c_restore,
|
||||
#endif
|
||||
.freeze = pm_sleep_ptr(virtio_i2c_freeze),
|
||||
.restore = pm_sleep_ptr(virtio_i2c_restore),
|
||||
};
|
||||
module_virtio_driver(virtio_i2c_driver);
|
||||
|
||||
|
||||
@@ -529,10 +529,8 @@ static int xlp9xx_i2c_probe(struct platform_device *pdev)
|
||||
|
||||
err = devm_request_irq(&pdev->dev, priv->irq, xlp9xx_i2c_isr, 0,
|
||||
pdev->name, priv);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "IRQ request failed!\n");
|
||||
return err;
|
||||
}
|
||||
if (err)
|
||||
return dev_err_probe(&pdev->dev, err, "IRQ request failed!\n");
|
||||
|
||||
init_completion(&priv->msg_complete);
|
||||
priv->adapter.dev.parent = &pdev->dev;
|
||||
|
||||
@@ -62,7 +62,7 @@ static const struct chip_desc chips[] = {
|
||||
|
||||
static bool ltc4306_is_volatile_reg(struct device *dev, unsigned int reg)
|
||||
{
|
||||
return (reg == LTC_REG_CONFIG) ? true : false;
|
||||
return reg == LTC_REG_CONFIG;
|
||||
}
|
||||
|
||||
static const struct regmap_config ltc4306_regmap_config = {
|
||||
|
||||
@@ -530,7 +530,6 @@ static void pca954x_remove(struct i2c_client *client)
|
||||
pca954x_cleanup(muxc);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
static int pca954x_resume(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
@@ -544,14 +543,13 @@ static int pca954x_resume(struct device *dev)
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(pca954x_pm, NULL, pca954x_resume);
|
||||
static DEFINE_SIMPLE_DEV_PM_OPS(pca954x_pm, NULL, pca954x_resume);
|
||||
|
||||
static struct i2c_driver pca954x_driver = {
|
||||
.driver = {
|
||||
.name = "pca954x",
|
||||
.pm = &pca954x_pm,
|
||||
.pm = pm_sleep_ptr(&pca954x_pm),
|
||||
.of_match_table = pca954x_of_match,
|
||||
},
|
||||
.probe = pca954x_probe,
|
||||
|
||||
@@ -184,10 +184,8 @@ struct virtio_driver {
|
||||
void (*scan)(struct virtio_device *dev);
|
||||
void (*remove)(struct virtio_device *dev);
|
||||
void (*config_changed)(struct virtio_device *dev);
|
||||
#ifdef CONFIG_PM
|
||||
int (*freeze)(struct virtio_device *dev);
|
||||
int (*restore)(struct virtio_device *dev);
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv)
|
||||
|
||||
Reference in New Issue
Block a user