eth_phy_get_partner_pause_enable_func emac_phy_get_partner_pause_enable;
eth_phy_power_enable_func emac_phy_power_enable;
uint32_t reset_timeout_ms;
+ bool promiscuous_enable;
};
enum emac_post_type {
REG_CLR_BIT(EMAC_GMACCONFIG_REG, EMAC_EMACFESPEED);
REG_SET_BIT(EMAC_GMACFF_REG, EMAC_PAM);
}
+
+void emac_enable_promiscuous(void)
+{
+ REG_SET_BIT(EMAC_GMACFF_REG, EMAC_PMODE);
+}
+
+void emac_disable_promiscuous(void)
+{
+ REG_CLR_BIT(EMAC_GMACFF_REG, EMAC_PMODE);
+}
void emac_enable_flowctrl(void);
void emac_disable_flowctrl(void);
void emac_mac_enable_txrx(void);
+void emac_enable_promiscuous(void);
+void emac_disable_promiscuous(void);
static inline uint32_t emac_read_tx_cur_reg(void)
{
#endif
emac_config.emac_phy_get_partner_pause_enable = config->phy_get_partner_pause_enable;
emac_config.emac_phy_power_enable = config->phy_power_enable;
+ emac_config.promiscuous_enable = config->promiscuous_enable;
}
static void emac_enable_intr()
emac_mac_init();
+ /* check if enable promiscuous mode */
+ if(emac_config.promiscuous_enable){
+ emac_enable_promiscuous();
+ }else{
+ emac_disable_promiscuous();
+ }
+
emac_enable_intr();
emac_config.emac_status = EMAC_RUNTIME_START;
esp_err_t res1, res2;
ESP_LOGD(TAG, "phy_ip101_init()");
phy_ip101_dump_registers();
+
+ esp_eth_smi_write(MII_BASIC_MODE_CONTROL_REG, MII_SOFTWARE_RESET);
+
do {
// Call esp_eth_smi_wait_value() with a timeout so it prints an error periodically
res1 = esp_eth_smi_wait_value(MII_PHY_IDENTIFIER_1_REG, IP101_PHY_ID1, UINT16_MAX, 1000);
res2 = esp_eth_smi_wait_value(MII_PHY_IDENTIFIER_2_REG, IP101_PHY_ID2, IP101_PHY_ID2_MASK, 1000);
} while (res1 != ESP_OK || res2 != ESP_OK);
+
+ uint32_t data = esp_eth_smi_read(MII_BASIC_MODE_CONTROL_REG);
+ data |= MII_AUTO_NEGOTIATION_ENABLE | MII_RESTART_AUTO_NEGOTIATION;
+ esp_eth_smi_write(MII_BASIC_MODE_CONTROL_REG, data);
+
ets_delay_us(300);
// TODO: only do this if config.flow_ctrl_enable == true
phy_mii_enable_flow_ctrl();
.phy_get_duplex_mode = phy_ip101_get_duplex_mode,
.phy_get_partner_pause_enable = phy_mii_get_partner_pause_enable,
.phy_power_enable = phy_ip101_power_enable,
+ .reset_timeout_ms = 1000,
+ .promiscuous_enable = false,
};
void phy_ip101_dump_registers()
.phy_get_speed_mode = phy_lan8720_get_speed_mode,
.phy_get_duplex_mode = phy_lan8720_get_duplex_mode,
.phy_get_partner_pause_enable = phy_mii_get_partner_pause_enable,
- .reset_timeout_ms = 1000
+ .reset_timeout_ms = 1000,
+ .promiscuous_enable = false,
};
void phy_lan8720_dump_registers()
.phy_get_duplex_mode = phy_tlk110_get_duplex_mode,
.phy_get_partner_pause_enable = phy_mii_get_partner_pause_enable,
.phy_power_enable = phy_tlk110_power_enable,
- .reset_timeout_ms = 1000
+ .reset_timeout_ms = 1000,
+ .promiscuous_enable = false,
};
void phy_tlk110_dump_registers()
eth_phy_get_partner_pause_enable_func phy_get_partner_pause_enable; /*!< get partner pause enable */
eth_phy_power_enable_func phy_power_enable; /*!< enable or disable phy power */
uint32_t reset_timeout_ms; /*!< timeout value for reset emac */
+ bool promiscuous_enable; /*!< set true to enable promiscuous mode */
} eth_config_t;
/**