Skip to content

Commit a4f06df

Browse files
claudiubezneasre
authored andcommitted
power: reset: at91-poweroff: introduce struct shdwc_reg_config
This driver uses AT91_PMC_MCKR in poweroff() function. But the SAM9X60's PMC versions maps AT91_PMC_MCKR functionality at different offset compared to the SAMA5D2's one. This patch prepares the field so that different AT91_PMC_MCKR's offsets to be introduced in struct reg_config so that proper offset to be used for AT91_PMC_MCKR based on compatible string. Signed-off-by: Claudiu Beznea <[email protected]> Acked-by: Nicolas Ferre <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 46aa27e commit a4f06df

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

drivers/power/reset/at91-sama5d2_shdwc.c

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,20 @@
6666

6767
#define SHDW_CFG_NOT_USED (32)
6868

69-
struct shdwc_config {
69+
struct shdwc_reg_config {
7070
u8 wkup_pin_input;
7171
u8 mr_rtcwk_shift;
7272
u8 mr_rttwk_shift;
7373
u8 sr_rtcwk_shift;
7474
u8 sr_rttwk_shift;
7575
};
7676

77+
struct reg_config {
78+
struct shdwc_reg_config shdwc;
79+
};
80+
7781
struct shdwc {
78-
const struct shdwc_config *cfg;
82+
const struct reg_config *rcfg;
7983
struct clk *sclk;
8084
void __iomem *shdwc_base;
8185
void __iomem *mpddrc_base;
@@ -95,6 +99,7 @@ static const unsigned long long sdwc_dbc_period[] = {
9599
static void __init at91_wakeup_status(struct platform_device *pdev)
96100
{
97101
struct shdwc *shdw = platform_get_drvdata(pdev);
102+
const struct reg_config *rcfg = shdw->rcfg;
98103
u32 reg;
99104
char *reason = "unknown";
100105

@@ -106,11 +111,11 @@ static void __init at91_wakeup_status(struct platform_device *pdev)
106111
if (!reg)
107112
return;
108113

109-
if (SHDW_WK_PIN(reg, shdw->cfg))
114+
if (SHDW_WK_PIN(reg, &rcfg->shdwc))
110115
reason = "WKUP pin";
111-
else if (SHDW_RTCWK(reg, shdw->cfg))
116+
else if (SHDW_RTCWK(reg, &rcfg->shdwc))
112117
reason = "RTC";
113-
else if (SHDW_RTTWK(reg, shdw->cfg))
118+
else if (SHDW_RTTWK(reg, &rcfg->shdwc))
114119
reason = "RTT";
115120

116121
pr_info("AT91: Wake-Up source: %s\n", reason);
@@ -215,6 +220,7 @@ static u32 at91_shdwc_get_wakeup_input(struct platform_device *pdev,
215220
static void at91_shdwc_dt_configure(struct platform_device *pdev)
216221
{
217222
struct shdwc *shdw = platform_get_drvdata(pdev);
223+
const struct reg_config *rcfg = shdw->rcfg;
218224
struct device_node *np = pdev->dev.of_node;
219225
u32 mode = 0, tmp, input;
220226

@@ -227,10 +233,10 @@ static void at91_shdwc_dt_configure(struct platform_device *pdev)
227233
mode |= AT91_SHDW_WKUPDBC(at91_shdwc_debouncer_value(pdev, tmp));
228234

229235
if (of_property_read_bool(np, "atmel,wakeup-rtc-timer"))
230-
mode |= SHDW_RTCWKEN(shdw->cfg);
236+
mode |= SHDW_RTCWKEN(&rcfg->shdwc);
231237

232238
if (of_property_read_bool(np, "atmel,wakeup-rtt-timer"))
233-
mode |= SHDW_RTTWKEN(shdw->cfg);
239+
mode |= SHDW_RTTWKEN(&rcfg->shdwc);
234240

235241
dev_dbg(&pdev->dev, "%s: mode = %#x\n", __func__, mode);
236242
writel(mode, shdw->shdwc_base + AT91_SHDW_MR);
@@ -239,30 +245,34 @@ static void at91_shdwc_dt_configure(struct platform_device *pdev)
239245
writel(input, shdw->shdwc_base + AT91_SHDW_WUIR);
240246
}
241247

242-
static const struct shdwc_config sama5d2_shdwc_config = {
243-
.wkup_pin_input = 0,
244-
.mr_rtcwk_shift = 17,
245-
.mr_rttwk_shift = SHDW_CFG_NOT_USED,
246-
.sr_rtcwk_shift = 5,
247-
.sr_rttwk_shift = SHDW_CFG_NOT_USED,
248+
static const struct reg_config sama5d2_reg_config = {
249+
.shdwc = {
250+
.wkup_pin_input = 0,
251+
.mr_rtcwk_shift = 17,
252+
.mr_rttwk_shift = SHDW_CFG_NOT_USED,
253+
.sr_rtcwk_shift = 5,
254+
.sr_rttwk_shift = SHDW_CFG_NOT_USED,
255+
},
248256
};
249257

250-
static const struct shdwc_config sam9x60_shdwc_config = {
251-
.wkup_pin_input = 0,
252-
.mr_rtcwk_shift = 17,
253-
.mr_rttwk_shift = 16,
254-
.sr_rtcwk_shift = 5,
255-
.sr_rttwk_shift = 4,
258+
static const struct reg_config sam9x60_reg_config = {
259+
.shdwc = {
260+
.wkup_pin_input = 0,
261+
.mr_rtcwk_shift = 17,
262+
.mr_rttwk_shift = 16,
263+
.sr_rtcwk_shift = 5,
264+
.sr_rttwk_shift = 4,
265+
},
256266
};
257267

258268
static const struct of_device_id at91_shdwc_of_match[] = {
259269
{
260270
.compatible = "atmel,sama5d2-shdwc",
261-
.data = &sama5d2_shdwc_config,
271+
.data = &sama5d2_reg_config,
262272
},
263273
{
264274
.compatible = "microchip,sam9x60-shdwc",
265-
.data = &sam9x60_shdwc_config,
275+
.data = &sam9x60_reg_config,
266276
}, {
267277
/*sentinel*/
268278
}
@@ -303,7 +313,7 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
303313
}
304314

305315
match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
306-
at91_shdwc->cfg = match->data;
316+
at91_shdwc->rcfg = match->data;
307317

308318
at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
309319
if (IS_ERR(at91_shdwc->sclk))

0 commit comments

Comments
 (0)