Skip to content

Commit

Permalink
HACK net: fec: Add interconnect path request
Browse files Browse the repository at this point in the history
Only for testing.

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
  • Loading branch information
cdleonard committed Mar 26, 2020
1 parent 12a609d commit 4377276
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/ethernet/freescale/fec.h
Expand Up @@ -544,6 +544,9 @@ struct fec_enet_private {
int wol_flag;
u32 quirks;

struct icc_path *icc_path;
s32 icc_path_bw;

struct napi_struct napi;
int csum_flags;

Expand Down
50 changes: 50 additions & 0 deletions drivers/net/ethernet/freescale/fec_main.c
Expand Up @@ -62,6 +62,7 @@
#include <linux/if_vlan.h>
#include <linux/pinctrl/consumer.h>
#include <linux/prefetch.h>
#include <linux/interconnect.h>
#include <soc/imx/cpuidle.h>

#include <asm/cacheflush.h>
Expand Down Expand Up @@ -156,6 +157,10 @@ static unsigned char macaddr[ETH_ALEN];
module_param_array(macaddr, byte, NULL, 0);
MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");

/* Pass fec.needs_icc=0 on kernel cmdline */
static bool fec_needs_icc = true;
module_param_named(needs_icc, fec_needs_icc, bool, 0644);

#if defined(CONFIG_M5272)
/*
* Some hardware gets it MAC address out of local flash memory.
Expand Down Expand Up @@ -3398,6 +3403,39 @@ static int fec_enet_get_irq_cnt(struct platform_device *pdev)
return irq_cnt;
}

static int fec_init_icc(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
struct fec_enet_private *fep = netdev_priv(ndev);

if (!fec_needs_icc) {
pr_info("fec icc hack disabled!\n");
return 0;
}

/* Optional interconnect request */
fep->icc_path = of_icc_get(&pdev->dev, NULL);
if (PTR_ERR(fep->icc_path) == -EPROBE_DEFER) {
return -EPROBE_DEFER;
} else if (IS_ERR(fep->icc_path))
fep->icc_path = NULL;

/* Optional interconnect request */
/* Gigabit Ethernet in KBps */
//fep->icc_path_bw = 125000;
/* Force DDRC med: */
fep->icc_path_bw = 1599999;

/* Force DDRC high on imx8mq: */
fep->icc_path_bw = 678900;

/* Force DDRC high: */
//fep->icc_path_bw = 2000000;
icc_set_bw(fep->icc_path, 0, fep->icc_path_bw);

return 0;
}

static int
fec_probe(struct platform_device *pdev)
{
Expand Down Expand Up @@ -3464,6 +3502,10 @@ fec_probe(struct platform_device *pdev)
if (of_get_property(np, "fsl,magic-packet", NULL))
fep->wol_flag |= FEC_WOL_HAS_MAGIC_PACKET;

ret = fec_init_icc(pdev);
if (ret)
goto failed_icc;

phy_node = of_parse_phandle(np, "phy-handle", 0);
if (!phy_node && of_phy_is_fixed_link(np)) {
ret = of_phy_register_fixed_link(np);
Expand Down Expand Up @@ -3633,6 +3675,8 @@ fec_probe(struct platform_device *pdev)
of_phy_deregister_fixed_link(np);
of_node_put(phy_node);
failed_phy:
icc_put(fep->icc_path);
failed_icc:
dev_id--;
failed_ioremap:
free_netdev(ndev);
Expand Down Expand Up @@ -3662,6 +3706,7 @@ fec_drv_remove(struct platform_device *pdev)
if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
of_node_put(fep->phy_node);
icc_put(fep->icc_path);
free_netdev(ndev);

clk_disable_unprepare(fep->clk_ahb);
Expand Down Expand Up @@ -3758,6 +3803,8 @@ static int __maybe_unused fec_runtime_suspend(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev);
struct fec_enet_private *fep = netdev_priv(ndev);

icc_set_bw(fep->icc_path, 0, 0);

clk_disable_unprepare(fep->clk_ahb);
clk_disable_unprepare(fep->clk_ipg);

Expand All @@ -3777,6 +3824,9 @@ static int __maybe_unused fec_runtime_resume(struct device *dev)
if (ret)
goto failed_clk_ipg;

if (fec_needs_icc)
icc_set_bw(fep->icc_path, 0, fep->icc_path_bw);

return 0;

failed_clk_ipg:
Expand Down

0 comments on commit 4377276

Please sign in to comment.