* [U-Boot] [PATCH] spi: designware_spi: Add reset ctrl to driver
2018-09-06 14:22 [U-Boot] [PATCH] spi: designware_spi: Add reset ctrl to driver Ley Foon Tan
@ 2018-09-06 10:06 ` Marek Vasut
2018-09-06 14:13 ` Jagan Teki
1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2018-09-06 10:06 UTC (permalink / raw)
To: u-boot
On 09/06/2018 04:22 PM, Ley Foon Tan wrote:
> Add code to reset all reset signals as in SPI DT node. A reset property
> is an optional feature, so only print out a warning and do not fail if a
> reset property is not present.
>
> If a reset property is discovered, then use it to deassert, thus
> bringing the IP out of reset.
>
> Release reset when _remove().
>
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
> drivers/spi/designware_spi.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 42 insertions(+)
>
> diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
> index d8b73ea..b73ec38 100644
> --- a/drivers/spi/designware_spi.c
> +++ b/drivers/spi/designware_spi.c
> @@ -17,6 +17,7 @@
> #include <malloc.h>
> #include <spi.h>
> #include <fdtdec.h>
> +#include <reset.h>
> #include <linux/compat.h>
> #include <linux/iopoll.h>
> #include <asm/io.h>
> @@ -111,6 +112,8 @@ struct dw_spi_priv {
> void *tx_end;
> void *rx;
> void *rx_end;
> +
> + struct reset_ctl_bulk resets;
> };
>
> static inline u32 dw_read(struct dw_spi_priv *priv, u32 offset)
> @@ -231,6 +234,33 @@ err_rate:
> return -EINVAL;
> }
>
> +static int dw_spi_reset(struct udevice *bus)
> +{
> + int ret;
> + struct dw_spi_priv *priv = dev_get_priv(bus);
> +
> + ret = reset_get_bulk(bus, &priv->resets);
> + if (ret) {
> + /* Return 0 if error due to !CONFIG_DM_RESET and reset
> + * DT property is not present.
Multiline comment style.
Otherwise
Acked-by: Marek Vasut <marex@denx.de>
I'll let Jagan pick it for next.
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] spi: designware_spi: Add reset ctrl to driver
2018-09-06 14:22 [U-Boot] [PATCH] spi: designware_spi: Add reset ctrl to driver Ley Foon Tan
2018-09-06 10:06 ` Marek Vasut
@ 2018-09-06 14:13 ` Jagan Teki
1 sibling, 0 replies; 3+ messages in thread
From: Jagan Teki @ 2018-09-06 14:13 UTC (permalink / raw)
To: u-boot
On Thu, Sep 6, 2018 at 7:52 PM, Ley Foon Tan <ley.foon.tan@intel.com> wrote:
> Add code to reset all reset signals as in SPI DT node. A reset property
> is an optional feature, so only print out a warning and do not fail if a
> reset property is not present.
>
> If a reset property is discovered, then use it to deassert, thus
> bringing the IP out of reset.
>
> Release reset when _remove().
>
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] spi: designware_spi: Add reset ctrl to driver
@ 2018-09-06 14:22 Ley Foon Tan
2018-09-06 10:06 ` Marek Vasut
2018-09-06 14:13 ` Jagan Teki
0 siblings, 2 replies; 3+ messages in thread
From: Ley Foon Tan @ 2018-09-06 14:22 UTC (permalink / raw)
To: u-boot
Add code to reset all reset signals as in SPI DT node. A reset property
is an optional feature, so only print out a warning and do not fail if a
reset property is not present.
If a reset property is discovered, then use it to deassert, thus
bringing the IP out of reset.
Release reset when _remove().
Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
---
drivers/spi/designware_spi.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c
index d8b73ea..b73ec38 100644
--- a/drivers/spi/designware_spi.c
+++ b/drivers/spi/designware_spi.c
@@ -17,6 +17,7 @@
#include <malloc.h>
#include <spi.h>
#include <fdtdec.h>
+#include <reset.h>
#include <linux/compat.h>
#include <linux/iopoll.h>
#include <asm/io.h>
@@ -111,6 +112,8 @@ struct dw_spi_priv {
void *tx_end;
void *rx;
void *rx_end;
+
+ struct reset_ctl_bulk resets;
};
static inline u32 dw_read(struct dw_spi_priv *priv, u32 offset)
@@ -231,6 +234,33 @@ err_rate:
return -EINVAL;
}
+static int dw_spi_reset(struct udevice *bus)
+{
+ int ret;
+ struct dw_spi_priv *priv = dev_get_priv(bus);
+
+ ret = reset_get_bulk(bus, &priv->resets);
+ if (ret) {
+ /* Return 0 if error due to !CONFIG_DM_RESET and reset
+ * DT property is not present.
+ */
+ if (ret == -ENOENT || ret == -ENOTSUPP)
+ return 0;
+
+ dev_warn(bus, "Can't get reset: %d\n", ret);
+ return ret;
+ }
+
+ ret = reset_deassert_bulk(&priv->resets);
+ if (ret) {
+ reset_release_bulk(&priv->resets);
+ dev_err(bus, "Failed to reset: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
static int dw_spi_probe(struct udevice *bus)
{
struct dw_spi_platdata *plat = dev_get_platdata(bus);
@@ -244,6 +274,10 @@ static int dw_spi_probe(struct udevice *bus)
if (ret)
return ret;
+ ret = dw_spi_reset(bus);
+ if (ret)
+ return ret;
+
/* Currently only bits_per_word == 8 supported */
priv->bits_per_word = 8;
@@ -478,6 +512,13 @@ static int dw_spi_set_mode(struct udevice *bus, uint mode)
return 0;
}
+static int dw_spi_remove(struct udevice *bus)
+{
+ struct dw_spi_priv *priv = dev_get_priv(bus);
+
+ return reset_release_bulk(&priv->resets);
+}
+
static const struct dm_spi_ops dw_spi_ops = {
.xfer = dw_spi_xfer,
.set_speed = dw_spi_set_speed,
@@ -502,4 +543,5 @@ U_BOOT_DRIVER(dw_spi) = {
.platdata_auto_alloc_size = sizeof(struct dw_spi_platdata),
.priv_auto_alloc_size = sizeof(struct dw_spi_priv),
.probe = dw_spi_probe,
+ .remove = dw_spi_remove,
};
--
2.2.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-06 14:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06 14:22 [U-Boot] [PATCH] spi: designware_spi: Add reset ctrl to driver Ley Foon Tan
2018-09-06 10:06 ` Marek Vasut
2018-09-06 14:13 ` Jagan Teki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.