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

Commit 855bcee9 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: emac: Fix pll lock issue on mdm9607"

parents 5ada5d9b 9faf1b00
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2,7 +2,9 @@ Qualcomm MSM Ethernet Controller (EMAC)

Required properties:
- cell-index : EMAC controller instance number.
- compatible : Should be "qcom,emac".
- compatible : Should be "qcom,mdm9607-emac" for mdm9607 based EMAC driver
	       Should be "qcom,emac" for other targets based EMAC driver

- reg : Offset and length of the register regions for the device
- reg-names : Register region names referenced in 'reg' above.
	Required register resource entries are:
+2 −1
Original line number Diff line number Diff line
@@ -5,4 +5,5 @@
obj-$(CONFIG_QCOM_EMAC) += qcom_emac.o

qcom_emac-objs := emac_main.o emac_hw.o emac_ethtool.o emac_ptp.o
qcom_emac-objs += emac_rgmii.o emac_sgmii_v1.o
qcom_emac-objs += emac_phy.o emac_rgmii.o
qcom_emac-objs += emac_sgmii.o emac_sgmii_v1.o emac_sgmii_v2.o
+2 −46
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 "emac_phy.h"

/* Device IDs */
#define EMAC_DEV_ID                0x0040
@@ -119,15 +120,6 @@ enum emac_dma_req_block {
	emac_dma_req_4096 = 5
};

/* Flow Control Settings */
enum emac_fc_mode {
	emac_fc_none = 0,
	emac_fc_rx_pause,
	emac_fc_tx_pause,
	emac_fc_full,
	emac_fc_default
};

/* IEEE1588 */
enum emac_ptp_clk_mode {
	emac_ptp_clk_mode_oc_two_step,
@@ -223,31 +215,11 @@ enum emac_adapter_flags {
#define TEST_N_SET_FLAG(OBJ, FLAG) \
			test_and_set_bit(EMAC_FLAG_ ## FLAG,  &((OBJ)->flags))

struct emac_adapter;
struct emac_hw;

struct emac_phy_ops {
	int  (*config)(struct platform_device *pdev, struct emac_adapter *adpt);
	int  (*up)(struct emac_adapter *adpt);
	void (*down)(struct emac_adapter *adpt);
	int  (*init)(struct emac_adapter *adpt);
	void (*reset)(struct emac_adapter *adpt);
	int  (*init_ephy)(struct emac_hw *hw);
	int  (*link_setup_no_ephy)(struct emac_adapter *adpt, u32 speed,
				   bool autoneg);
	int  (*link_check_no_ephy)(struct emac_adapter *adpt, u32 *speed,
				   bool *link_up);
	void (*tx_clk_set_rate)(struct emac_adapter *adpt);
	void (*periodic_task)(struct emac_adapter *adpt);
};

struct emac_hw {
	void __iomem *reg_addr[NUM_EMAC_REG_BASES];

	u16     devid;
	u16     revid;
	struct emac_phy_ops	ops;
	void			*private;

	/* ring parameter */
	u8      tpd_burst;
@@ -258,25 +230,11 @@ struct emac_hw {
	enum emac_dma_req_block   dmaw_block;
	enum emac_dma_order       dma_order;

	/* PHY parameter */
	u32             phy_addr;
	u16             phy_id[2];
	bool            autoneg;
	u32             autoneg_advertised;
	u32             link_speed;
	bool            link_up;
	spinlock_t      mdio_lock; /* sync access to mdio bus */

	/* MAC parameter */
	u8      mac_addr[ETH_ALEN];
	u8      mac_perm_addr[ETH_ALEN];
	u32     mtu;

	/* flow control parameter */
	enum emac_fc_mode   cur_fc_mode; /* FC mode in effect */
	enum emac_fc_mode   req_fc_mode; /* FC mode requested by caller */
	bool                disable_fc_autoneg; /* Do not autonegotiate FC */

	/* RSS parameter */
	u8      rss_hstype;
	u8      rss_base_cpu;
@@ -742,6 +700,7 @@ struct emac_adapter {

	u32 rxbuf_size;

	struct emac_phy phy;
	struct emac_hw hw;
	struct emac_hw_stats hw_stats;

@@ -757,9 +716,6 @@ struct emac_adapter {
	unsigned long	link_jiffies;

	bool            tstamp_en;
	int             phy_mode;
	bool            no_ephy;
	bool            no_mdio_gpio;
	u32             wol;
	u16             msg_enable;
	unsigned long   flags;
+8 −0
Original line number Diff line number Diff line
@@ -410,6 +410,9 @@
/* EMAC_QSERDES_COM_RESETSM_CNTRL */
#define FRQ_TUNE_MODE                                              0x10

/* EMAC_QSERDES_COM_BGTC */
#define BGTC							   0x7

/* EMAC_QSERDES_COM_PLLLOCK_CMP_EN */
#define PLLLOCK_CMP_EN                                             0x01

@@ -471,6 +474,11 @@
#define PLL_TXCLK_EN                                               0x02
#define PLL_RXCLK_EN                                               0x01

/* EMAC_QSERDES_COM_PLL_VCOTAIL_EN */
#define PLL_VCO_TAIL_MUX					   0x80
#define PLL_VCO_TAIL						   0x7c
#define PLL_EN_VCOTAIL_EN					   0x1

/* EMAC_SGMII_PHY_RX_PWR_CTRL */
#define L0_RX_SIGDET_EN                                            0x80
#define L0_RX_TERM_MODE_BMSK                                       0x30
+39 −38
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ static int emac_get_settings(struct net_device *netdev,
			     struct ethtool_cmd *ecmd)
{
	struct emac_adapter *adpt = netdev_priv(netdev);
	struct emac_hw *hw = &adpt->hw;
	struct emac_phy *phy = &adpt->phy;

	ecmd->supported = (SUPPORTED_10baseT_Half   |
			   SUPPORTED_10baseT_Full   |
@@ -89,20 +89,20 @@ static int emac_get_settings(struct net_device *netdev,
			   SUPPORTED_TP);

	ecmd->advertising = ADVERTISED_TP;
	if (hw->autoneg) {
	if (phy->autoneg) {
		ecmd->advertising |= ADVERTISED_Autoneg;
		ecmd->advertising |= hw->autoneg_advertised;
		ecmd->advertising |= phy->autoneg_advertised;
		ecmd->autoneg = AUTONEG_ENABLE;
	} else {
		ecmd->autoneg = AUTONEG_DISABLE;
	}

	ecmd->port = PORT_TP;
	ecmd->phy_address = hw->phy_addr;
	ecmd->phy_address = phy->addr;
	ecmd->transceiver = XCVR_INTERNAL;

	if (hw->link_up) {
		switch (hw->link_speed) {
	if (phy->link_up) {
		switch (phy->link_speed) {
		case EMAC_LINK_SPEED_10_HALF:
			ecmd->speed = SPEED_10;
			ecmd->duplex = DUPLEX_HALF;
@@ -140,7 +140,7 @@ static int emac_set_settings(struct net_device *netdev,
			     struct ethtool_cmd *ecmd)
{
	struct emac_adapter *adpt = netdev_priv(netdev);
	struct emac_hw *hw = &adpt->hw;
	struct emac_phy *phy = &adpt->phy;
	u32 advertised, old;
	int retval = 0;
	bool autoneg;
@@ -152,7 +152,7 @@ static int emac_set_settings(struct net_device *netdev,
	while (TEST_N_SET_FLAG(adpt, ADPT_STATE_RESETTING))
		msleep(20); /* Reset might take few 10s of ms */

	old = hw->autoneg_advertised;
	old = phy->autoneg_advertised;
	advertised = 0;
	if (ecmd->autoneg == AUTONEG_ENABLE) {
		advertised = EMAC_LINK_SPEED_DEFAULT;
@@ -182,26 +182,27 @@ static int emac_set_settings(struct net_device *netdev,
		}
	}

	if ((hw->autoneg == autoneg) && (hw->autoneg_advertised == advertised))
	if ((phy->autoneg == autoneg) &&
	    (phy->autoneg_advertised == advertised))
		goto done;

	/* If there is no EPHY, the EMAC internal PHY may get reset in
	 * emac_setup_phy_link_speed. Reset the MAC to avoid the memory
	 * emac_phy_setup_link_speed. Reset the MAC to avoid the memory
	 * corruption.
	 */
	if (adpt->no_ephy && if_running)
	if (!phy->external && if_running)
		emac_down(adpt, EMAC_HW_CTRL_RESET_MAC);

	retval = emac_setup_phy_link_speed(hw, advertised, autoneg,
					   !hw->disable_fc_autoneg);
	retval = emac_phy_setup_link_speed(adpt, advertised, autoneg,
					   !phy->disable_fc_autoneg);
	if (retval) {
		emac_setup_phy_link_speed(hw, old, autoneg,
					  !hw->disable_fc_autoneg);
		emac_phy_setup_link_speed(adpt, old, autoneg,
					  !phy->disable_fc_autoneg);
	}

	if (if_running) {
		/* If there is no EPHY, bring up the interface */
		if (adpt->no_ephy)
		if (!phy->external)
			emac_up(adpt);
	}

@@ -214,18 +215,18 @@ static void emac_get_pauseparam(struct net_device *netdev,
				struct ethtool_pauseparam *pause)
{
	struct emac_adapter *adpt = netdev_priv(netdev);
	struct emac_hw *hw = &adpt->hw;
	struct emac_phy *phy = &adpt->phy;

	if (hw->disable_fc_autoneg)
	if (phy->disable_fc_autoneg)
		pause->autoneg = 0;
	else
		pause->autoneg = 1;

	if (hw->cur_fc_mode == emac_fc_rx_pause) {
	if (phy->cur_fc_mode == EMAC_FC_RX_PAUSE) {
		pause->rx_pause = 1;
	} else if (hw->cur_fc_mode == emac_fc_tx_pause) {
	} else if (phy->cur_fc_mode == EMAC_FC_TX_PAUSE) {
		pause->tx_pause = 1;
	} else if (hw->cur_fc_mode == emac_fc_full) {
	} else if (phy->cur_fc_mode == EMAC_FC_FULL) {
		pause->rx_pause = 1;
		pause->tx_pause = 1;
	}
@@ -235,16 +236,16 @@ static int emac_set_pauseparam(struct net_device *netdev,
			       struct ethtool_pauseparam *pause)
{
	struct emac_adapter *adpt = netdev_priv(netdev);
	struct emac_hw *hw = &adpt->hw;
	enum emac_fc_mode req_fc_mode;
	struct emac_phy *phy = &adpt->phy;
	enum emac_flow_ctrl req_fc_mode;
	bool disable_fc_autoneg;
	int retval = 0;

	while (TEST_N_SET_FLAG(adpt, ADPT_STATE_RESETTING))
		msleep(20); /* Reset might take few 10s of ms */

	req_fc_mode        = hw->req_fc_mode;
	disable_fc_autoneg = hw->disable_fc_autoneg;
	req_fc_mode        = phy->req_fc_mode;
	disable_fc_autoneg = phy->disable_fc_autoneg;

	if (pause->autoneg != AUTONEG_ENABLE)
		disable_fc_autoneg = true;
@@ -252,29 +253,29 @@ static int emac_set_pauseparam(struct net_device *netdev,
		disable_fc_autoneg = false;

	if (pause->rx_pause && pause->tx_pause) {
		req_fc_mode = emac_fc_full;
		req_fc_mode = EMAC_FC_FULL;
	} else if (pause->rx_pause && !pause->tx_pause) {
		req_fc_mode = emac_fc_rx_pause;
		req_fc_mode = EMAC_FC_RX_PAUSE;
	} else if (!pause->rx_pause && pause->tx_pause) {
		req_fc_mode = emac_fc_tx_pause;
		req_fc_mode = EMAC_FC_TX_PAUSE;
	} else if (!pause->rx_pause && !pause->tx_pause) {
		req_fc_mode = emac_fc_none;
		req_fc_mode = EMAC_FC_NONE;
	} else {
		CLR_FLAG(adpt, ADPT_STATE_RESETTING);
		return -EINVAL;
	}

	if ((hw->req_fc_mode != req_fc_mode) ||
	    (hw->disable_fc_autoneg != disable_fc_autoneg)) {
		hw->req_fc_mode = req_fc_mode;
		hw->disable_fc_autoneg = disable_fc_autoneg;
		if (!adpt->no_ephy)
			retval = emac_setup_phy_link(hw,
						     hw->autoneg_advertised,
						     hw->autoneg,
	if ((phy->req_fc_mode != req_fc_mode) ||
	    (phy->disable_fc_autoneg != disable_fc_autoneg)) {
		phy->req_fc_mode	= req_fc_mode;
		phy->disable_fc_autoneg	= disable_fc_autoneg;
		if (phy->external)
			retval = emac_phy_setup_link(adpt,
						     phy->autoneg_advertised,
						     phy->autoneg,
						     !disable_fc_autoneg);
		if (!retval)
			emac_hw_config_fc(hw);
			emac_phy_config_fc(adpt);
	}

	CLR_FLAG(adpt, ADPT_STATE_RESETTING);
Loading