mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-08-26 04:47:45 +00:00

Add PM suspend/resume callbacks for RZ/G3E SMARC EVK. The PM deep entry is executed by pressing the SLEEP button and exit from entry is by pressing the power button. Logs: root@smarc-rzg3e:~# PM: suspend entry (deep) Filesystems sync: 0.115 seconds Freezing user space processes Freezing user space processes completed (elapsed 0.002 seconds) OOM killer disabled. Freezing remaining freezable tasks Freezing remaining freezable tasks completed (elapsed 0.001 seconds) printk: Suspending console(s) (use no_console_suspend to debug) NOTICE: BL2: v2.10.5(release):2.10.5/rz_soc_dev-162-g7148ba838 NOTICE: BL2: Built : 14:23:58, Jul 5 2025 NOTICE: BL2: SYS_LSI_MODE: 0x13e06 NOTICE: BL2: SYS_LSI_DEVID: 0x8679447 NOTICE: BL2: SYS_LSI_PRR: 0x0 NOTICE: BL2: Booting BL31 renesas-gbeth 15c30000.ethernet end0: Link is Down Disabling non-boot CPUs ... psci: CPU3 killed (polled 0 ms) psci: CPU2 killed (polled 0 ms) psci: CPU1 killed (polled 0 ms) Enabling non-boot CPUs ... Detected VIPT I-cache on CPU1 GICv3: CPU1: found redistributor 100 region 0:0x0000000014960000 CPU1: Booted secondary processor 0x0000000100 [0x412fd050] CPU1 is up Detected VIPT I-cache on CPU2 GICv3: CPU2: found redistributor 200 region 0:0x0000000014980000 CPU2: Booted secondary processor 0x0000000200 [0x412fd050] CPU2 is up Detected VIPT I-cache on CPU3 GICv3: CPU3: found redistributor 300 region 0:0x00000000149a0000 CPU3: Booted secondary processor 0x0000000300 [0x412fd050] CPU3 is up dwmac4: Master AXI performs fixed burst length 15c30000.ethernet end0: No Safety Features support found 15c30000.ethernet end0: IEEE 1588-2008 Advanced Timestamp supported 15c30000.ethernet end0: configuring for phy/rgmii-id link mode dwmac4: Master AXI performs fixed burst length 15c40000.ethernet end1: No Safety Features support found 15c40000.ethernet end1: IEEE 1588-2008 Advanced Timestamp supported 15c40000.ethernet end1: configuring for phy/rgmii-id link mode OOM killer enabled. Restarting tasks: Starting Restarting tasks: Done random: crng reseeded on system resumption PM: suspend exit 15c30000.ethernet end0: Link is Up - 1Gbps/Full - flow control rx/tx root@smarc-rzg3e:~# ifconfig end0 192.168.10.7 up root@smarc-rzg3e:~# ping 192.168.10.1 PING 192.168.10.1 (192.168.10.1) 56(84) bytes of data. 64 bytes from 192.168.10.1: icmp_seq=1 ttl=64 time=2.05 ms 64 bytes from 192.168.10.1: icmp_seq=2 ttl=64 time=0.928 ms Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://patch.msgid.link/20250717071109.8213-1-biju.das.jz@bp.renesas.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
148 lines
3.8 KiB
C
148 lines
3.8 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* dwmac-renesas-gbeth.c - DWMAC Specific Glue layer for Renesas GBETH
|
|
*
|
|
* The Rx and Tx clocks are supplied as follows for the GBETH IP.
|
|
*
|
|
* Rx / Tx
|
|
* -------+------------- on / off -------
|
|
* |
|
|
* | Rx-180 / Tx-180
|
|
* +---- not ---- on / off -------
|
|
*
|
|
* Copyright (C) 2025 Renesas Electronics Corporation
|
|
*/
|
|
|
|
#include <linux/clk.h>
|
|
#include <linux/device.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/reset.h>
|
|
|
|
#include "stmmac_platform.h"
|
|
|
|
struct renesas_gbeth {
|
|
struct plat_stmmacenet_data *plat_dat;
|
|
struct reset_control *rstc;
|
|
struct device *dev;
|
|
};
|
|
|
|
static const char *const renesas_gbeth_clks[] = {
|
|
"tx", "tx-180", "rx", "rx-180",
|
|
};
|
|
|
|
static int renesas_gbeth_init(struct platform_device *pdev, void *priv)
|
|
{
|
|
struct plat_stmmacenet_data *plat_dat;
|
|
struct renesas_gbeth *gbeth = priv;
|
|
int ret;
|
|
|
|
plat_dat = gbeth->plat_dat;
|
|
|
|
ret = reset_control_deassert(gbeth->rstc);
|
|
if (ret) {
|
|
dev_err(gbeth->dev, "Reset deassert failed\n");
|
|
return ret;
|
|
}
|
|
|
|
ret = clk_bulk_prepare_enable(plat_dat->num_clks,
|
|
plat_dat->clks);
|
|
if (ret)
|
|
reset_control_assert(gbeth->rstc);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void renesas_gbeth_exit(struct platform_device *pdev, void *priv)
|
|
{
|
|
struct plat_stmmacenet_data *plat_dat;
|
|
struct renesas_gbeth *gbeth = priv;
|
|
int ret;
|
|
|
|
plat_dat = gbeth->plat_dat;
|
|
|
|
clk_bulk_disable_unprepare(plat_dat->num_clks, plat_dat->clks);
|
|
|
|
ret = reset_control_assert(gbeth->rstc);
|
|
if (ret)
|
|
dev_err(gbeth->dev, "Reset assert failed\n");
|
|
}
|
|
|
|
static int renesas_gbeth_probe(struct platform_device *pdev)
|
|
{
|
|
struct plat_stmmacenet_data *plat_dat;
|
|
struct stmmac_resources stmmac_res;
|
|
struct device *dev = &pdev->dev;
|
|
struct renesas_gbeth *gbeth;
|
|
unsigned int i;
|
|
int err;
|
|
|
|
err = stmmac_get_platform_resources(pdev, &stmmac_res);
|
|
if (err)
|
|
return dev_err_probe(dev, err,
|
|
"failed to get resources\n");
|
|
|
|
plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
|
|
if (IS_ERR(plat_dat))
|
|
return dev_err_probe(dev, PTR_ERR(plat_dat),
|
|
"dt configuration failed\n");
|
|
|
|
gbeth = devm_kzalloc(dev, sizeof(*gbeth), GFP_KERNEL);
|
|
if (!gbeth)
|
|
return -ENOMEM;
|
|
|
|
plat_dat->num_clks = ARRAY_SIZE(renesas_gbeth_clks);
|
|
plat_dat->clks = devm_kcalloc(dev, plat_dat->num_clks,
|
|
sizeof(*plat_dat->clks), GFP_KERNEL);
|
|
if (!plat_dat->clks)
|
|
return -ENOMEM;
|
|
|
|
for (i = 0; i < plat_dat->num_clks; i++)
|
|
plat_dat->clks[i].id = renesas_gbeth_clks[i];
|
|
|
|
err = devm_clk_bulk_get(dev, plat_dat->num_clks, plat_dat->clks);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
plat_dat->clk_tx_i = stmmac_pltfr_find_clk(plat_dat, "tx");
|
|
if (!plat_dat->clk_tx_i)
|
|
return dev_err_probe(dev, -EINVAL,
|
|
"error finding tx clock\n");
|
|
|
|
gbeth->rstc = devm_reset_control_get_exclusive(dev, NULL);
|
|
if (IS_ERR(gbeth->rstc))
|
|
return PTR_ERR(gbeth->rstc);
|
|
|
|
gbeth->dev = dev;
|
|
gbeth->plat_dat = plat_dat;
|
|
plat_dat->bsp_priv = gbeth;
|
|
plat_dat->set_clk_tx_rate = stmmac_set_clk_tx_rate;
|
|
plat_dat->init = renesas_gbeth_init;
|
|
plat_dat->exit = renesas_gbeth_exit;
|
|
plat_dat->flags |= STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY |
|
|
STMMAC_FLAG_EN_TX_LPI_CLK_PHY_CAP |
|
|
STMMAC_FLAG_SPH_DISABLE;
|
|
|
|
return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
|
|
}
|
|
|
|
static const struct of_device_id renesas_gbeth_match[] = {
|
|
{ .compatible = "renesas,rzv2h-gbeth", },
|
|
{ /* Sentinel */ }
|
|
};
|
|
MODULE_DEVICE_TABLE(of, renesas_gbeth_match);
|
|
|
|
static struct platform_driver renesas_gbeth_driver = {
|
|
.probe = renesas_gbeth_probe,
|
|
.driver = {
|
|
.name = "renesas-gbeth",
|
|
.pm = &stmmac_pltfr_pm_ops,
|
|
.of_match_table = renesas_gbeth_match,
|
|
},
|
|
};
|
|
module_platform_driver(renesas_gbeth_driver);
|
|
|
|
MODULE_AUTHOR("Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>");
|
|
MODULE_DESCRIPTION("Renesas GBETH DWMAC Specific Glue layer");
|
|
MODULE_LICENSE("GPL");
|