Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8432838f authored by Alok Chauhan's avatar Alok Chauhan
Browse files

msm: emac: Add wake lock for link detection/un-detection



Add wake lock support in EMAC driver. EMAC driver should
not go into suspend when Ethernet link is connected to
avoid transfer to fail.  For this reason wake lock is
acquired when Ethernet link is detected and it will hold
the system to go into suspend as long as link is connected.
Once Ethernet link is disconnected then EMAC driver will
release the wake lock and allow system to go into suspend.

Change-Id: I6ffafbd085608d0a96d96fc5b87695a9ff5198ce
Signed-off-by: default avatarAlok Chauhan <alokc@codeaurora.org>
parent 1468823d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <linux/netdevice.h>
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/wakelock.h>
#include "emac_phy.h"

/* Device IDs */
@@ -726,6 +727,7 @@ struct emac_adapter {
	struct pinctrl_state	*pins_sleep;
	int	(*gpio_on)(struct emac_adapter *adpt);
	int	(*gpio_off)(struct emac_adapter *adpt);
	struct wakeup_source link_wlock;
};

static inline struct emac_adapter *emac_hw_get_adap(struct emac_hw *hw)
+8 −0
Original line number Diff line number Diff line
@@ -2340,6 +2340,10 @@ static void emac_link_task_routine(struct emac_adapter *adpt)
			goto link_task_done;

		pm_runtime_get_sync(netdev->dev.parent);
		/* Acquire wake lock if link is detected to avoid device going
		 * into suspend
		 */
		__pm_stay_awake(&adpt->link_wlock);
		emac_info(adpt, timer, "NIC Link is Up %s\n", link_desc);

		phy->ops.tx_clk_set_rate(adpt);
@@ -2361,6 +2365,8 @@ static void emac_link_task_routine(struct emac_adapter *adpt)
		netif_carrier_off(netdev);

		emac_hw_stop_mac(hw);
		/* Release wake lock if link is disconnected */
		__pm_relax(&adpt->link_wlock);
		pm_runtime_put_sync(netdev->dev.parent);
	}

@@ -3281,6 +3287,7 @@ static int emac_probe(struct platform_device *pdev)
	skb_queue_head_init(&adpt->hwtxtstamp_pending_queue);
	skb_queue_head_init(&adpt->hwtxtstamp_ready_queue);
	INIT_WORK(&adpt->hwtxtstamp_task, emac_hwtxtstamp_task_routine);
	wakeup_source_init(&adpt->link_wlock, dev_name(&pdev->dev));

	SET_FLAG(hw, HW_VLANSTRIP_EN);
	SET_FLAG(adpt, ADPT_STATE_DOWN);
@@ -3328,6 +3335,7 @@ static int emac_remove(struct platform_device *pdev)
	pr_info("exiting %s\n", emac_drv_name);

	unregister_netdev(netdev);
	wakeup_source_trash(&adpt->link_wlock);
	if (TEST_FLAG(hw, HW_PTP_CAP))
		emac_ptp_remove(netdev);