mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
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 <claudiu.beznea@microchip.com> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
46aa27e742
commit
a4f06df13d
1 changed files with 32 additions and 22 deletions
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
#define SHDW_CFG_NOT_USED (32)
|
#define SHDW_CFG_NOT_USED (32)
|
||||||
|
|
||||||
struct shdwc_config {
|
struct shdwc_reg_config {
|
||||||
u8 wkup_pin_input;
|
u8 wkup_pin_input;
|
||||||
u8 mr_rtcwk_shift;
|
u8 mr_rtcwk_shift;
|
||||||
u8 mr_rttwk_shift;
|
u8 mr_rttwk_shift;
|
||||||
|
@ -74,8 +74,12 @@ struct shdwc_config {
|
||||||
u8 sr_rttwk_shift;
|
u8 sr_rttwk_shift;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct reg_config {
|
||||||
|
struct shdwc_reg_config shdwc;
|
||||||
|
};
|
||||||
|
|
||||||
struct shdwc {
|
struct shdwc {
|
||||||
const struct shdwc_config *cfg;
|
const struct reg_config *rcfg;
|
||||||
struct clk *sclk;
|
struct clk *sclk;
|
||||||
void __iomem *shdwc_base;
|
void __iomem *shdwc_base;
|
||||||
void __iomem *mpddrc_base;
|
void __iomem *mpddrc_base;
|
||||||
|
@ -95,6 +99,7 @@ static const unsigned long long sdwc_dbc_period[] = {
|
||||||
static void __init at91_wakeup_status(struct platform_device *pdev)
|
static void __init at91_wakeup_status(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct shdwc *shdw = platform_get_drvdata(pdev);
|
struct shdwc *shdw = platform_get_drvdata(pdev);
|
||||||
|
const struct reg_config *rcfg = shdw->rcfg;
|
||||||
u32 reg;
|
u32 reg;
|
||||||
char *reason = "unknown";
|
char *reason = "unknown";
|
||||||
|
|
||||||
|
@ -106,11 +111,11 @@ static void __init at91_wakeup_status(struct platform_device *pdev)
|
||||||
if (!reg)
|
if (!reg)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (SHDW_WK_PIN(reg, shdw->cfg))
|
if (SHDW_WK_PIN(reg, &rcfg->shdwc))
|
||||||
reason = "WKUP pin";
|
reason = "WKUP pin";
|
||||||
else if (SHDW_RTCWK(reg, shdw->cfg))
|
else if (SHDW_RTCWK(reg, &rcfg->shdwc))
|
||||||
reason = "RTC";
|
reason = "RTC";
|
||||||
else if (SHDW_RTTWK(reg, shdw->cfg))
|
else if (SHDW_RTTWK(reg, &rcfg->shdwc))
|
||||||
reason = "RTT";
|
reason = "RTT";
|
||||||
|
|
||||||
pr_info("AT91: Wake-Up source: %s\n", reason);
|
pr_info("AT91: Wake-Up source: %s\n", reason);
|
||||||
|
@ -215,6 +220,7 @@ static u32 at91_shdwc_get_wakeup_input(struct platform_device *pdev,
|
||||||
static void at91_shdwc_dt_configure(struct platform_device *pdev)
|
static void at91_shdwc_dt_configure(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct shdwc *shdw = platform_get_drvdata(pdev);
|
struct shdwc *shdw = platform_get_drvdata(pdev);
|
||||||
|
const struct reg_config *rcfg = shdw->rcfg;
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
u32 mode = 0, tmp, input;
|
u32 mode = 0, tmp, input;
|
||||||
|
|
||||||
|
@ -227,10 +233,10 @@ static void at91_shdwc_dt_configure(struct platform_device *pdev)
|
||||||
mode |= AT91_SHDW_WKUPDBC(at91_shdwc_debouncer_value(pdev, tmp));
|
mode |= AT91_SHDW_WKUPDBC(at91_shdwc_debouncer_value(pdev, tmp));
|
||||||
|
|
||||||
if (of_property_read_bool(np, "atmel,wakeup-rtc-timer"))
|
if (of_property_read_bool(np, "atmel,wakeup-rtc-timer"))
|
||||||
mode |= SHDW_RTCWKEN(shdw->cfg);
|
mode |= SHDW_RTCWKEN(&rcfg->shdwc);
|
||||||
|
|
||||||
if (of_property_read_bool(np, "atmel,wakeup-rtt-timer"))
|
if (of_property_read_bool(np, "atmel,wakeup-rtt-timer"))
|
||||||
mode |= SHDW_RTTWKEN(shdw->cfg);
|
mode |= SHDW_RTTWKEN(&rcfg->shdwc);
|
||||||
|
|
||||||
dev_dbg(&pdev->dev, "%s: mode = %#x\n", __func__, mode);
|
dev_dbg(&pdev->dev, "%s: mode = %#x\n", __func__, mode);
|
||||||
writel(mode, shdw->shdwc_base + AT91_SHDW_MR);
|
writel(mode, shdw->shdwc_base + AT91_SHDW_MR);
|
||||||
|
@ -239,30 +245,34 @@ static void at91_shdwc_dt_configure(struct platform_device *pdev)
|
||||||
writel(input, shdw->shdwc_base + AT91_SHDW_WUIR);
|
writel(input, shdw->shdwc_base + AT91_SHDW_WUIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct shdwc_config sama5d2_shdwc_config = {
|
static const struct reg_config sama5d2_reg_config = {
|
||||||
.wkup_pin_input = 0,
|
.shdwc = {
|
||||||
.mr_rtcwk_shift = 17,
|
.wkup_pin_input = 0,
|
||||||
.mr_rttwk_shift = SHDW_CFG_NOT_USED,
|
.mr_rtcwk_shift = 17,
|
||||||
.sr_rtcwk_shift = 5,
|
.mr_rttwk_shift = SHDW_CFG_NOT_USED,
|
||||||
.sr_rttwk_shift = SHDW_CFG_NOT_USED,
|
.sr_rtcwk_shift = 5,
|
||||||
|
.sr_rttwk_shift = SHDW_CFG_NOT_USED,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct shdwc_config sam9x60_shdwc_config = {
|
static const struct reg_config sam9x60_reg_config = {
|
||||||
.wkup_pin_input = 0,
|
.shdwc = {
|
||||||
.mr_rtcwk_shift = 17,
|
.wkup_pin_input = 0,
|
||||||
.mr_rttwk_shift = 16,
|
.mr_rtcwk_shift = 17,
|
||||||
.sr_rtcwk_shift = 5,
|
.mr_rttwk_shift = 16,
|
||||||
.sr_rttwk_shift = 4,
|
.sr_rtcwk_shift = 5,
|
||||||
|
.sr_rttwk_shift = 4,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct of_device_id at91_shdwc_of_match[] = {
|
static const struct of_device_id at91_shdwc_of_match[] = {
|
||||||
{
|
{
|
||||||
.compatible = "atmel,sama5d2-shdwc",
|
.compatible = "atmel,sama5d2-shdwc",
|
||||||
.data = &sama5d2_shdwc_config,
|
.data = &sama5d2_reg_config,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.compatible = "microchip,sam9x60-shdwc",
|
.compatible = "microchip,sam9x60-shdwc",
|
||||||
.data = &sam9x60_shdwc_config,
|
.data = &sam9x60_reg_config,
|
||||||
}, {
|
}, {
|
||||||
/*sentinel*/
|
/*sentinel*/
|
||||||
}
|
}
|
||||||
|
@ -303,7 +313,7 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
|
match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
|
||||||
at91_shdwc->cfg = match->data;
|
at91_shdwc->rcfg = match->data;
|
||||||
|
|
||||||
at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
|
at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
|
||||||
if (IS_ERR(at91_shdwc->sclk))
|
if (IS_ERR(at91_shdwc->sclk))
|
||||||
|
|
Loading…
Reference in a new issue