Skip to content

Commit 2938090

Browse files
lynxeye-devShawn Guo
authored andcommitted
ARM: imx6: disable deeper idle states when FEC is active w/o HW workaround
The i.MX6 Q/DL has an erratum (ERR006687) that prevents the FEC from waking the CPUs when they are in wait(unclocked) state. As the hardware workaround isn't applicable to all boards, disable the deeper idle state when the workaround isn't present and the FEC is in use. This allows to safely run a kernel with CPUidle enabled on all i.MX6 boards. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Acked-by: David S. Miller <davem@davemloft.net> (for network changes) Signed-off-by: Shawn Guo <shawnguo@kernel.org>
1 parent ac4bbb4 commit 2938090

5 files changed

Lines changed: 58 additions & 0 deletions

File tree

‎Documentation/devicetree/bindings/net/fsl-fec.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ Optional properties:
2727
number to 1.
2828
- fsl,magic-packet : If present, indicates that the hardware supports waking
2929
up via magic packet.
30+
- fsl,err006687-workaround-present: If present indicates that the system has
31+
the hardware workaround for ERR006687 applied and does not need a software
32+
workaround.
3033

3134
Optional subnodes:
3235
- mdio : specifies the mdio bus in the FEC, used as a container for phy nodes

‎arch/arm/mach-imx/cpuidle-imx6q.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ static struct cpuidle_driver imx6q_cpuidle_driver = {
6262
.safe_state_index = 0,
6363
};
6464

65+
/*
66+
* i.MX6 Q/DL has an erratum (ERR006687) that prevents the FEC from waking the
67+
* CPUs when they are in wait(unclocked) state. As the hardware workaround isn't
68+
* applicable to all boards, disable the deeper idle state when the workaround
69+
* isn't present and the FEC is in use.
70+
*/
71+
void imx6q_cpuidle_fec_irqs_used(void)
72+
{
73+
imx6q_cpuidle_driver.states[1].disabled = true;
74+
}
75+
76+
void imx6q_cpuidle_fec_irqs_unused(void)
77+
{
78+
imx6q_cpuidle_driver.states[1].disabled = false;
79+
}
80+
6581
int __init imx6q_cpuidle_init(void)
6682
{
6783
/* Set INT_MEM_CLK_LPM bit to get a reliable WAIT mode support */

‎drivers/net/ethernet/freescale/fec.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ struct bufdesc_ex {
442442
#define FEC_QUIRK_SINGLE_MDIO (1 << 11)
443443
/* Controller supports RACC register */
444444
#define FEC_QUIRK_HAS_RACC (1 << 12)
445+
/* Interrupt doesn't wake CPU from deep idle */
446+
#define FEC_QUIRK_ERR006687 (1 << 13)
445447

446448
struct bufdesc_prop {
447449
int qid;

‎drivers/net/ethernet/freescale/fec_main.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include <linux/if_vlan.h>
6161
#include <linux/pinctrl/consumer.h>
6262
#include <linux/prefetch.h>
63+
#include <soc/imx/cpuidle.h>
6364

6465
#include <asm/cacheflush.h>
6566

@@ -2820,6 +2821,9 @@ fec_enet_open(struct net_device *ndev)
28202821
if (ret)
28212822
goto err_enet_mii_probe;
28222823

2824+
if (fep->quirks & FEC_QUIRK_ERR006687)
2825+
imx6q_cpuidle_fec_irqs_used();
2826+
28232827
napi_enable(&fep->napi);
28242828
phy_start(ndev->phydev);
28252829
netif_tx_start_all_queues(ndev);
@@ -2855,6 +2859,9 @@ fec_enet_close(struct net_device *ndev)
28552859

28562860
phy_disconnect(ndev->phydev);
28572861

2862+
if (fep->quirks & FEC_QUIRK_ERR006687)
2863+
imx6q_cpuidle_fec_irqs_unused();
2864+
28582865
fec_enet_clk_enable(ndev, false);
28592866
pinctrl_pm_select_sleep_state(&fep->pdev->dev);
28602867
pm_runtime_mark_last_busy(&fep->pdev->dev);
@@ -3294,6 +3301,11 @@ fec_probe(struct platform_device *pdev)
32943301

32953302
platform_set_drvdata(pdev, ndev);
32963303

3304+
if ((of_machine_is_compatible("fsl,imx6q") ||
3305+
of_machine_is_compatible("fsl,imx6dl")) &&
3306+
!of_property_read_bool(np, "fsl,err006687-workaround-present"))
3307+
fep->quirks |= FEC_QUIRK_ERR006687;
3308+
32973309
if (of_get_property(np, "fsl,magic-packet", NULL))
32983310
fep->wol_flag |= FEC_WOL_HAS_MAGIC_PACKET;
32993311

‎include/soc/imx/cpuidle.h‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2016 Pengutronix, <kernel@pengutronix.de>
3+
*
4+
* This program is free software; you can redistribute it and/or modify it
5+
* under the terms and conditions of the GNU General Public License,
6+
* version 2, as published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope it will be useful, but WITHOUT
9+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11+
* more details.
12+
*/
13+
14+
#ifndef __SOC_IMX_CPUIDLE_H__
15+
#define __SOC_IMX_CPUIDLE_H__
16+
17+
#if defined(CONFIG_CPU_IDLE) && defined(CONFIG_SOC_IMX6Q)
18+
void imx6q_cpuidle_fec_irqs_used(void);
19+
void imx6q_cpuidle_fec_irqs_unused(void);
20+
#else
21+
void imx6q_cpuidle_fec_irqs_used(void) { }
22+
void imx6q_cpuidle_fec_irqs_unused(void) { }
23+
#endif
24+
25+
#endif /* __SOC_IMX_CPUIDLE_H__ */

0 commit comments

Comments
 (0)