Skip to content

Commit 596e795

Browse files
Faiz-Abbastmlind
authored andcommitted
bus: ti-sysc: Add support for software reset
Add support for the software reset of a target interconnect module using its sysconfig and sysstatus registers. Signed-off-by: Faiz Abbas <faiz_abbas@ti.com> [tony@atomide.com: updated to check if sysconfig exists] Signed-off-by: Tony Lindgren <tony@atomide.com>
1 parent 7f35e63 commit 596e795

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

‎drivers/bus/ti-sysc.c‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323
#include <linux/of_address.h>
2424
#include <linux/of_platform.h>
2525
#include <linux/slab.h>
26+
#include <linux/iopoll.h>
2627

2728
#include <linux/platform_data/ti-sysc.h>
2829

2930
#include <dt-bindings/bus/ti-sysc.h>
3031

32+
#define MAX_MODULE_SOFTRESET_WAIT 10000
33+
3134
static const char * const reg_names[] = { "rev", "sysc", "syss", };
3235

3336
enum sysc_clocks {
@@ -88,6 +91,11 @@ struct sysc {
8891
struct delayed_work idle_work;
8992
};
9093

94+
void sysc_write(struct sysc *ddata, int offset, u32 value)
95+
{
96+
writel_relaxed(value, ddata->module_va + offset);
97+
}
98+
9199
static u32 sysc_read(struct sysc *ddata, int offset)
92100
{
93101
if (ddata->cfg.quirks & SYSC_QUIRK_16BIT) {
@@ -943,6 +951,36 @@ static void sysc_init_revision_quirks(struct sysc *ddata)
943951
}
944952
}
945953

954+
static int sysc_reset(struct sysc *ddata)
955+
{
956+
int offset = ddata->offsets[SYSC_SYSCONFIG];
957+
int val;
958+
959+
if (ddata->legacy_mode || offset < 0 ||
960+
ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)
961+
return 0;
962+
963+
/*
964+
* Currently only support reset status in sysstatus.
965+
* Warn and return error in all other cases
966+
*/
967+
if (!ddata->cfg.syss_mask) {
968+
dev_err(ddata->dev, "No ti,syss-mask. Reset failed\n");
969+
return -EINVAL;
970+
}
971+
972+
val = sysc_read(ddata, offset);
973+
val |= (0x1 << ddata->cap->regbits->srst_shift);
974+
sysc_write(ddata, offset, val);
975+
976+
/* Poll on reset status */
977+
offset = ddata->offsets[SYSC_SYSSTATUS];
978+
979+
return readl_poll_timeout(ddata->module_va + offset, val,
980+
(val & ddata->cfg.syss_mask) == 0x0,
981+
100, MAX_MODULE_SOFTRESET_WAIT);
982+
}
983+
946984
/* At this point the module is configured enough to read the revision */
947985
static int sysc_init_module(struct sysc *ddata)
948986
{
@@ -960,6 +998,14 @@ static int sysc_init_module(struct sysc *ddata)
960998
return 0;
961999
}
9621000

1001+
error = sysc_reset(ddata);
1002+
if (error) {
1003+
dev_err(ddata->dev, "Reset failed with %d\n", error);
1004+
pm_runtime_put_sync(ddata->dev);
1005+
1006+
return error;
1007+
}
1008+
9631009
ddata->revision = sysc_read_revision(ddata);
9641010
pm_runtime_put_sync(ddata->dev);
9651011

0 commit comments

Comments
 (0)