* [PATCH] i2c: aspeed: Deassert reset in probe
@ 2017-10-10 4:48 Joel Stanley
2017-10-13 18:44 ` Wolfram Sang
0 siblings, 1 reply; 2+ messages in thread
From: Joel Stanley @ 2017-10-10 4:48 UTC (permalink / raw)
To: Wolfram Sang
Cc: Brendan Higgins, Benjamin Herrenschmidt, Andrew Jeffery,
linux-i2c, linux-kernel
In order to use i2c from a cold boot, the i2c peripheral must be taken
out of reset. We request a shared reset controller each time a bus
driver is loaded, as the reset is shared between the 14 i2c buses.
On remove the reset is asserted, which only touches the hardware once
the last i2c bus is removed.
The request is optional, so if a device tree does not specify a reset
controller (or the driver is not built in), the driver continues to
probe.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
drivers/i2c/busses/i2c-aspeed.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 284f8670dbeb..ad06f902f90f 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -28,6 +28,8 @@
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/reset.h>
/* I2C Register */
#define ASPEED_I2C_FUN_CTRL_REG 0x00
@@ -132,6 +134,7 @@ struct aspeed_i2c_bus {
struct i2c_adapter adap;
struct device *dev;
void __iomem *base;
+ struct reset_control *rst;
/* Synchronizes I/O mem access to base. */
spinlock_t lock;
struct completion cmd_complete;
@@ -847,6 +850,9 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
/* We just need the clock rate, we don't actually use the clk object. */
devm_clk_put(&pdev->dev, parent_clk);
+ bus->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
+ reset_control_deassert(bus->rst);
+
ret = of_property_read_u32(pdev->dev.of_node,
"bus-frequency", &bus->bus_frequency);
if (ret < 0) {
@@ -919,6 +925,8 @@ static int aspeed_i2c_remove_bus(struct platform_device *pdev)
i2c_del_adapter(&bus->adap);
+ reset_control_assert(bus->rst);
+
return 0;
}
--
2.14.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: aspeed: Deassert reset in probe
2017-10-10 4:48 [PATCH] i2c: aspeed: Deassert reset in probe Joel Stanley
@ 2017-10-13 18:44 ` Wolfram Sang
0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2017-10-13 18:44 UTC (permalink / raw)
To: Joel Stanley
Cc: Brendan Higgins, Benjamin Herrenschmidt, Andrew Jeffery,
linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 200 bytes --]
> #include <linux/of_platform.h>
> #include <linux/platform_device.h>
> #include <linux/slab.h>
> +#include <linux/delay.h>
> +#include <linux/reset.h>
Please keep the sorting. Rest looks good.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-13 18:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-10 4:48 [PATCH] i2c: aspeed: Deassert reset in probe Joel Stanley
2017-10-13 18:44 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).