[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <4fef9725-7aea-43fb-b8ef-d20a4c6d9a68@app.fastmail.com>
Date: Thu, 03 Aug 2023 09:02:47 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Yinbo Zhu" <zhuyinbo@...ngson.cn>,
"Rob Herring" <robh+dt@...nel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@...aro.org>,
"Conor Dooley" <conor+dt@...nel.org>, linux-pm@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
soc@...nel.org, "Ulf Hansson" <ulf.hansson@...aro.org>
Cc: "Jianmin Lv" <lvjianmin@...ngson.cn>, wanghongliang@...ngson.cn,
"Liu Peibao" <liupeibao@...ngson.cn>,
loongson-kernel@...ts.loongnix.cn, loongarch@...ts.linux.dev,
"Liu Yun" <liuyun@...ngson.cn>
Subject: Re: [PATCH v6 2/2] soc: loongson2_pm: add power management support
On Thu, Aug 3, 2023, at 08:37, Yinbo Zhu wrote:
> The Loongson-2's power management controller was ACPI, supports ACPI
> S2Idle (Suspend To Idle), ACPI S3 (Suspend To RAM), ACPI S4 (Suspend To
> Disk), ACPI S5 (Soft Shutdown) and supports multiple wake-up methods
> (USB, GMAC, PWRBTN, etc.). This driver was to add power management
> controller support that base on dts for Loongson-2 series SoCs.
>
> Co-developed-by: Liu Yun <liuyun@...ngson.cn>
> Signed-off-by: Liu Yun <liuyun@...ngson.cn>
> Co-developed-by: Liu Peibao <liupeibao@...ngson.cn>
> Signed-off-by: Liu Peibao <liupeibao@...ngson.cn>
> Cc: soc@...nel.org
> Cc: Ulf Hansson <ulf.hansson@...aro.org>
> Signed-off-by: Yinbo Zhu <zhuyinbo@...ngson.cn>
I'm still waiting for Ulf to take a look here to see whether
this should be in drivers/genpd instead, but he might still
be on vacation.
A few minor comments from me in the meantime:
> +#define loongson2_pm_readw(reg) readw(loongson2_pm.base + reg)
> +#define loongson2_pm_readl(reg) readl(loongson2_pm.base + reg)
> +#define loongson2_pm_writew(val, reg) writew(val, loongson2_pm.base +
> reg)
> +#define loongson2_pm_writel(val, reg) writel(val, loongson2_pm.base +
> reg)
I would prefer these to be 'static inline' functions rather than
macros, or you can just open-code them, as each macro is only
used once at the moment.
> +static irqreturn_t loongson2_pm_irq_handler(int irq, void *dev_id)
> +{
> + u16 status = loongson2_pm_readw(LOONGSON2_PM1_STS_REG);
> +
> + if (!loongson2_pm.suspended && (status & LOONGSON2_PM1_PWRBTN_STS)) {
> + pr_info("Power Button pressed...\n");
The message is probably more appropriate as a pr_debug() than
pr_info().
> +static int __maybe_unused loongson2_pm_suspend(struct device *dev)
> +{
> + loongson2_pm.suspended = true;
> +
> + return 0;
> +}
> +
> +static int __maybe_unused loongson2_pm_resume(struct device *dev)
> +{
> + loongson2_pm.suspended = false;
> +
> + return 0;
> +}
> +static SIMPLE_DEV_PM_OPS(loongson2_pm_ops, loongson2_pm_suspend,
> loongson2_pm_resume);
Please change this to DEFINE_SIMPLE_DEV_PM_OPS() and remove the
__maybe_unused, this is what all drivers should have these days.
> +
> +static int loongson2_pm_probe(struct platform_device *pdev)
> +{
> + int irq, retval;
> + u64 suspend_addr;
> + struct device *dev = &pdev->dev;
> +
> + loongson2_pm.base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(loongson2_pm.base))
> + return PTR_ERR(loongson2_pm.base);
> +
> + irq = platform_get_irq(pdev, 0);
> + if (irq < 0)
> + return irq;
> +
> + if (!device_property_read_u64(dev, "loongson,suspend-address",
> &suspend_addr))
> + loongson_sysconf.suspend_addr = (u64)phys_to_virt(suspend_addr);
> + else
Having a custom "loongson,suspend-address" property here feels wrong
to me. Can't this be moved into the "regs" property that holds
the other mmio registers?
Arnd
Powered by blists - more mailing lists