summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMandy Lavi <mandy.lavi@freescale.com>2014-02-24 14:32:47 (GMT)
committerJose Rivera <German.Rivera@freescale.com>2014-03-05 13:53:11 (GMT)
commit71fec8f799d4c5e5f5b4d96bb7e0ef6ffe912aae (patch)
tree3c210018f308d92f17f59b5e386ce25cbfe79fb6
parenta9f6a725ff63688481c9394ae5ef55ba55439e17 (diff)
downloadlinux-fsl-qoriq-71fec8f799d4c5e5f5b4d96bb7e0ef6ffe912aae.tar.xz
fmd: add wake-on-lan support
Change-Id: I1898186679983caccc4e51a8674ee7909955e346 Signed-off-by: Mandy Lavi <mandy.lavi@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/9076 Reviewed-by: Igal Liberman <Igal.Liberman@freescale.com> Reviewed-by: Jose Rivera <German.Rivera@freescale.com> Tested-by: Jose Rivera <German.Rivera@freescale.com> (cherry picked from commit 19640982a1c57f9f81508f9fa15dcc6ec1841cb4) Change-Id: I1898186679983caccc4e51a8674ee7909955e346 Reviewed-on: http://git.am.freescale.net:8181/9385 Reviewed-by: Jose Rivera <German.Rivera@freescale.com> Tested-by: Jose Rivera <German.Rivera@freescale.com>
-rw-r--r--drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/dtsec.c15
-rw-r--r--drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.c14
-rw-r--r--drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.h2
-rw-r--r--drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_dtsec.c13
-rw-r--r--drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_memac.c17
-rw-r--r--drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.c18
-rw-r--r--drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.h4
-rw-r--r--drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/tgec.c1
-rw-r--r--drivers/net/ethernet/freescale/fman/inc/Peripherals/fm_mac_ext.h17
-rw-r--r--drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_dtsec.h11
-rw-r--r--drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_memac.h6
11 files changed, 116 insertions, 2 deletions
diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/dtsec.c b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/dtsec.c
index ccaaaec..42c8e78 100644
--- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/dtsec.c
@@ -1074,6 +1074,20 @@ static t_Error DtsecSetStatistics(t_Handle h_Dtsec, e_FmMacStatisticsLevel stati
/* .............................................................................. */
+static t_Error DtsecSetWakeOnLan(t_Handle h_Dtsec, bool en)
+{
+ t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
+
+ SANITY_CHECK_RETURN_ERROR(p_Dtsec, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(!p_Dtsec->p_DtsecDriverParam, E_INVALID_STATE);
+
+ fman_dtsec_set_wol(p_Dtsec->p_MemMap, en);
+
+ return E_OK;
+}
+
+/* .............................................................................. */
+
static t_Error DtsecAdjustLink(t_Handle h_Dtsec, e_EnetSpeed speed, bool fullDuplex)
{
t_Dtsec *p_Dtsec = (t_Dtsec *)h_Dtsec;
@@ -1412,6 +1426,7 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous = DtsecSetPromiscuous;
p_FmMacControllerDriver->f_FM_MAC_AdjustLink = DtsecAdjustLink;
+ p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = DtsecSetWakeOnLan;
p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg = DtsecRestartAutoneg;
p_FmMacControllerDriver->f_FM_MAC_Enable1588TimeStamp = DtsecEnable1588TimeStamp;
diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.c b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.c
index 9050a77..e992f1a 100644
--- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.c
+++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.c
@@ -375,6 +375,20 @@ t_Error FM_MAC_SetRxIgnorePauseFrames (t_Handle h_FmMac, bool en)
/* ......................................................................... */
+t_Error FM_MAC_SetWakeOnLan (t_Handle h_FmMac, bool en)
+{
+ t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
+
+ SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
+
+ if (p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan)
+ return p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan(h_FmMac, en);
+
+ RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
+}
+
+/* ......................................................................... */
+
t_Error FM_MAC_ResetCounters (t_Handle h_FmMac)
{
t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.h b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.h
index 94f7b09..05ccd7e 100644
--- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.h
+++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fm_mac.h
@@ -116,6 +116,8 @@ typedef struct {
t_Error (*f_FM_MAC_AdjustLink) (t_Handle h_FmMac, e_EnetSpeed speed, bool fullDuplex);
t_Error (*f_FM_MAC_RestartAutoneg) (t_Handle h_FmMac);
+ t_Error (*f_FM_MAC_SetWakeOnLan) (t_Handle h_FmMac, bool en);
+
t_Error (*f_FM_MAC_GetId) (t_Handle h_FmMac, uint32_t *macId);
t_Error (*f_FM_MAC_GetVersion) (t_Handle h_FmMac, uint32_t *macVersion);
diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_dtsec.c
index 0915546..d88291e 100644
--- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_dtsec.c
@@ -96,6 +96,7 @@ void fman_dtsec_defconfig(struct dtsec_cfg *cfg)
cfg->back_to_back_ipg = DEFAULT_BACK_TO_BACK_IPG;
cfg->maximum_frame = DEFAULT_MAXIMUM_FRAME;
cfg->tbi_phy_addr = DEFAULT_TBI_PHY_ADDR;
+ cfg->wake_on_lan = DEFAULT_WAKE_ON_LAN;
}
int fman_dtsec_init(struct dtsec_regs *regs, struct dtsec_cfg *cfg,
@@ -439,6 +440,18 @@ int fman_dtsec_set_tbi_phy_addr(struct dtsec_regs *regs,
return 0;
}
+void fman_dtsec_set_wol(struct dtsec_regs *regs, bool en)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->maccfg2);
+ if (en)
+ tmp |= MACCFG2_MAGIC_PACKET_EN;
+ else
+ tmp &= ~MACCFG2_MAGIC_PACKET_EN;
+ iowrite32be(tmp, &regs->maccfg2);
+}
+
int fman_dtsec_adjust_link(struct dtsec_regs *regs,
enum enet_interface iface_mode,
enum enet_speed speed, bool full_dx)
diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_memac.c b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_memac.c
index 64295c5..f040be4 100644
--- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/fman_memac.c
@@ -184,6 +184,8 @@ int fman_memac_init(struct memac_regs *regs,
tmp |= CMD_CFG_SFD_ANY;
if (cfg->pad_enable)
tmp |= CMD_CFG_TX_PAD_EN;
+ if (cfg->wake_on_lan)
+ tmp |= CMD_CFG_MG;
tmp |= CMD_CFG_CRC_FWD;
@@ -313,6 +315,20 @@ void fman_memac_set_rx_ignore_pause_frames(struct memac_regs *regs,bool enabl
iowrite32be(tmp, &regs->command_config);
}
+void fman_memac_set_wol(struct memac_regs *regs, bool enable)
+{
+ uint32_t tmp;
+
+ tmp = ioread32be(&regs->command_config);
+
+ if (enable)
+ tmp |= CMD_CFG_MG;
+ else
+ tmp &= ~CMD_CFG_MG;
+
+ iowrite32be(tmp, &regs->command_config);
+}
+
#define GET_MEMAC_CNTR_64(bn) \
(ioread32be(&regs->bn ## _l) | \
((uint64_t)ioread32be(&regs->bn ## _u) << 32))
@@ -473,4 +489,5 @@ void fman_memac_defconfig(struct memac_cfg *cfg)
cfg->rx_pbl_fwd = FALSE;
cfg->tx_pbl_fwd = FALSE;
cfg->debug_mode = FALSE;
+ cfg->wake_on_lan = FALSE;
}
diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.c b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.c
index 2ae7eb80..a162510 100644
--- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.c
+++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.c
@@ -217,6 +217,8 @@ static void MemacErrException(t_Handle h_Memac)
p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_10G_1TX_ECC_ER);
if (event & MEMAC_IEVNT_RX_ECC_ER)
p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_10G_RX_ECC_ER);
+ if (event & MEMAC_IEVNT_MGI)
+ p_Memac->f_Exception(p_Memac->h_App, e_FM_MAC_EX_MAGIC_PACKET_INDICATION);
}
/* ......................................................................... */
@@ -485,6 +487,20 @@ static t_Error MemacSetRxIgnorePauseFrames(t_Handle h_Memac, bool en)
return E_OK;
}
+/* ......................................................................... */
+
+static t_Error MemacSetWakeOnLan(t_Handle h_Memac, bool en)
+{
+ t_Memac *p_Memac = (t_Memac *)h_Memac;
+
+ SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_STATE);
+ SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
+
+ fman_memac_set_wol(p_Memac->p_MemMap, en);
+
+ return E_OK;
+}
+
/* .............................................................................. */
static t_Error MemacEnable1588TimeStamp(t_Handle h_Memac)
@@ -1002,6 +1018,8 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = MemacSetTxPauseFrames;
p_FmMacControllerDriver->f_FM_MAC_SetRxIgnorePauseFrames = MemacSetRxIgnorePauseFrames;
+ p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = MemacSetWakeOnLan;
+
p_FmMacControllerDriver->f_FM_MAC_ResetCounters = MemacResetCounters;
p_FmMacControllerDriver->f_FM_MAC_GetStatistics = MemacGetStatistics;
diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.h b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.h
index 05a0b2a..4bb09d6 100644
--- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.h
+++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/memac.h
@@ -49,7 +49,7 @@
#define MEMAC_default_exceptions \
- ((uint32_t)(MEMAC_IMASK_TSECC_ER | MEMAC_IMASK_TECC_ER | MEMAC_IMASK_RECC_ER))
+ ((uint32_t)(MEMAC_IMASK_TSECC_ER | MEMAC_IMASK_TECC_ER | MEMAC_IMASK_RECC_ER | MEMAC_IMASK_MGI))
#define GET_EXCEPTION_FLAG(bitMask, exception) switch (exception){ \
case e_FM_MAC_EX_10G_1TX_ECC_ER: \
@@ -58,6 +58,8 @@
bitMask = MEMAC_IMASK_RECC_ER; break; \
case e_FM_MAC_EX_TS_FIFO_ECC_ERR: \
bitMask = MEMAC_IMASK_TSECC_ER; break; \
+ case e_FM_MAC_EX_MAGIC_PACKET_INDICATION: \
+ bitMask = MEMAC_IMASK_MGI; break; \
default: bitMask = 0;break;}
diff --git a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/tgec.c b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/tgec.c
index f4bace5..8089b46 100644
--- a/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/tgec.c
+++ b/drivers/net/ethernet/freescale/fman/Peripherals/FM/MAC/tgec.c
@@ -931,6 +931,7 @@ static void InitFmMacControllerDriver(t_FmMacControllerDriver *p_FmMacController
p_FmMacControllerDriver->f_FM_MAC_SetPromiscuous = TgecSetPromiscuous;
p_FmMacControllerDriver->f_FM_MAC_AdjustLink = NULL;
+ p_FmMacControllerDriver->f_FM_MAC_SetWakeOnLan = NULL;
p_FmMacControllerDriver->f_FM_MAC_RestartAutoneg = NULL;
p_FmMacControllerDriver->f_FM_MAC_Enable = TgecEnable;
diff --git a/drivers/net/ethernet/freescale/fman/inc/Peripherals/fm_mac_ext.h b/drivers/net/ethernet/freescale/fman/inc/Peripherals/fm_mac_ext.h
index 0411ec1..f90f2a7 100644
--- a/drivers/net/ethernet/freescale/fman/inc/Peripherals/fm_mac_ext.h
+++ b/drivers/net/ethernet/freescale/fman/inc/Peripherals/fm_mac_ext.h
@@ -103,6 +103,8 @@ typedef enum e_FmMacExceptions {
,e_FM_MAC_EX_1G_RX_MIB_CNT_OVFL /**< dTSEC MIB counter overflow */
,e_FM_MAC_EX_TS_FIFO_ECC_ERR /**< mEMAC Time-stamp FIFO ECC error interrupt;
not supported on T4240/B4860 rev1 chips */
+ ,e_FM_MAC_EX_MAGIC_PACKET_INDICATION = e_FM_MAC_EX_1G_MAG_PCKT
+ /**< mEMAC Magic Packet Indication Interrupt */
} e_FmMacExceptions;
/**************************************************************************//**
@@ -560,6 +562,21 @@ t_Error FM_MAC_SetTxPauseFrames(t_Handle h_FmMac,
t_Error FM_MAC_SetRxIgnorePauseFrames(t_Handle h_FmMac, bool en);
/**************************************************************************//**
+ @Function FM_MAC_SetWakeOnLan
+
+ @Description Enable/Disable Wake On Lan support
+
+ @Param[in] h_FmMac - A handle to a FM MAC Module.
+ @Param[in] en - boolean indicates whether to enable Wake On Lan
+ support or not.
+
+ @Return E_OK on success; Error code otherwise.
+
+ @Cautions Allowed only following FM_MAC_Init().
+*//***************************************************************************/
+t_Error FM_MAC_SetWakeOnLan(t_Handle h_FmMac, bool en);
+
+/**************************************************************************//**
@Function FM_MAC_ResetCounters
@Description reset all statistics counters
diff --git a/drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_dtsec.h b/drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_dtsec.h
index 0419d74..6004e47 100644
--- a/drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_dtsec.h
+++ b/drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_dtsec.h
@@ -245,6 +245,7 @@
#define DEFAULT_BACK_TO_BACK_IPG 0x60
#define DEFAULT_MAXIMUM_FRAME 0x600
#define DEFAULT_TBI_PHY_ADDR 5
+#define DEFAULT_WAKE_ON_LAN FALSE
/* register related defines (bits, field offsets..) */
#define DTSEC_ID1_ID 0xffff0000
@@ -730,6 +731,7 @@ struct dtsec_cfg {
uint32_t non_back_to_back_ipg2;
uint32_t min_ifg_enforcement;
uint32_t back_to_back_ipg;
+ bool wake_on_lan;
};
@@ -833,6 +835,15 @@ void fman_dtsec_get_mac_address(struct dtsec_regs *regs, uint8_t *macaddr);
void fman_dtsec_set_uc_promisc(struct dtsec_regs *regs, bool enable);
/**
+ * fman_dtsec_set_wol() - Enable/Disable wake on lan
+ * (magic packet support)
+ * @regs: Pointer to dTSEC register block
+ * @en: Enable Wake On Lan support in dTSEC
+ *
+ */
+void fman_dtsec_set_wol(struct dtsec_regs *regs, bool en);
+
+/**
* fman_dtsec_adjust_link() - Adjust dTSEC speed/duplex settings
* @regs: Pointer to dTSEC register block
* @iface_mode: dTSEC interface mode
diff --git a/drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_memac.h b/drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_memac.h
index b83390c..69cb22a 100644
--- a/drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_memac.h
+++ b/drivers/net/ethernet/freescale/fman/inc/flib/fsl_fman_memac.h
@@ -100,7 +100,8 @@
#define MEMAC_ALL_ERRS_IMASK \
((uint32_t)(MEMAC_IMASK_TSECC_ER | \
MEMAC_IMASK_TECC_ER | \
- MEMAC_IMASK_RECC_ER))
+ MEMAC_IMASK_RECC_ER | \
+ MEMAC_IMASK_MGI))
#define MEMAC_IEVNT_PCS 0x80000000 /* PCS (XG). Link sync (G) */
#define MEMAC_IEVNT_AN 0x40000000 /* Auto-negotiation */
@@ -325,6 +326,7 @@ struct memac_cfg {
bool rx_pbl_fwd;
bool tx_pbl_fwd;
bool debug_mode;
+ bool wake_on_lan;
uint16_t max_frame_length;
uint16_t pause_quanta;
uint32_t tx_ipg_length;
@@ -384,6 +386,8 @@ void fman_memac_set_hash_table(struct memac_regs *regs, uint32_t val);
void fman_memac_set_rx_ignore_pause_frames(struct memac_regs *regs,
bool enable);
+void fman_memac_set_wol(struct memac_regs *regs, bool enable);
+
uint32_t fman_memac_get_event(struct memac_regs *regs, uint32_t ev_mask);
void fman_memac_ack_event(struct memac_regs *regs, uint32_t ev_mask);