Skip to content

Commit 25b80b7

Browse files
claudiubezneasre
authored andcommitted
power: reset: at91-reset: introduce args member in at91_reset_data
Introduce args member in struct at91_reset_data. It stores the value that needs to be written in mode register so that the reboot actions to happen. With these changes samx7_restart() could be removed. Signed-off-by: Claudiu Beznea <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent a5bbad2 commit 25b80b7

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

drivers/power/reset/at91-reset.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ enum reset_type {
5252
struct at91_reset_data {
5353
int (*notifier_call)(struct notifier_block *this, unsigned long mode,
5454
void *cmd);
55+
u32 args;
5556
};
5657

5758
struct at91_reset {
5859
void __iomem *rstc_base;
5960
void __iomem *ramc_base[2];
6061
struct clk *sclk;
6162
struct notifier_block nb;
63+
u32 args;
6264
};
6365

6466
/*
@@ -90,7 +92,7 @@ static int at91sam9260_restart(struct notifier_block *this, unsigned long mode,
9092
"r" (reset->rstc_base),
9193
"r" (1),
9294
"r" cpu_to_le32(AT91_SDRAMC_LPCB_POWER_DOWN),
93-
"r" cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST));
95+
"r" (reset->args));
9496

9597
return NOTIFY_DONE;
9698
}
@@ -135,7 +137,7 @@ static int at91sam9g45_restart(struct notifier_block *this, unsigned long mode,
135137
"r" (reset->rstc_base),
136138
"r" (1),
137139
"r" cpu_to_le32(AT91_DDRSDRC_LPCB_POWER_DOWN),
138-
"r" cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST)
140+
"r" (reset->args)
139141
: "r0");
140142

141143
return NOTIFY_DONE;
@@ -146,19 +148,7 @@ static int sama5d3_restart(struct notifier_block *this, unsigned long mode,
146148
{
147149
struct at91_reset *reset = container_of(this, struct at91_reset, nb);
148150

149-
writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST),
150-
reset->rstc_base);
151-
152-
return NOTIFY_DONE;
153-
}
154-
155-
static int samx7_restart(struct notifier_block *this, unsigned long mode,
156-
void *cmd)
157-
{
158-
struct at91_reset *reset = container_of(this, struct at91_reset, nb);
159-
160-
writel(cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PROCRST),
161-
reset->rstc_base);
151+
writel(reset->args, reset->rstc_base);
162152

163153
return NOTIFY_DONE;
164154
}
@@ -210,18 +200,22 @@ static const struct of_device_id at91_ramc_of_match[] = {
210200

211201
static const struct at91_reset_data at91sam9260_reset_data = {
212202
.notifier_call = at91sam9260_restart,
203+
.args = AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST,
213204
};
214205

215206
static const struct at91_reset_data at91sam9g45_reset_data = {
216207
.notifier_call = at91sam9g45_restart,
208+
.args = AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST,
217209
};
218210

219211
static const struct at91_reset_data sama5d3_reset_data = {
220212
.notifier_call = sama5d3_restart,
213+
.args = AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST,
221214
};
222215

223216
static const struct at91_reset_data samx7_reset_data = {
224-
.notifier_call = samx7_restart,
217+
.notifier_call = sama5d3_restart,
218+
.args = AT91_RSTC_KEY | AT91_RSTC_PROCRST,
225219
};
226220

227221
static const struct of_device_id at91_reset_of_match[] = {
@@ -284,6 +278,7 @@ static int __init at91_reset_probe(struct platform_device *pdev)
284278
reset_data = match->data;
285279
reset->nb.notifier_call = reset_data->notifier_call;
286280
reset->nb.priority = 192;
281+
reset->args = reset_data->args;
287282

288283
reset->sclk = devm_clk_get(&pdev->dev, NULL);
289284
if (IS_ERR(reset->sclk))

0 commit comments

Comments
 (0)