mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-30 21:18:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3566f7c7fe |
No files matched your search
+3
-2
@@ -33796,15 +33796,16 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) {
|
||||
|
||||
if (config & MG_PHY_RGMII) {
|
||||
if (id1 == MG_PHY_YT85x && id2 == MG_PHY_YT8531) {
|
||||
// assume PHY has been hardware strapped properly
|
||||
#if 0
|
||||
uint16_t value;
|
||||
// TODO (robertc2000): Autonegotiation remains disabled after PHY is reset
|
||||
// We temporarily force enabling autoneg, until a workaround is found.
|
||||
phy->write_reg(phy_addr, MG_PHY_REG_BCR, MG_BIT(12));
|
||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_ADDR, 0xa003);
|
||||
value = phy->read_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA);
|
||||
value &= (uint16_t) ~(MG_BIT(3) | MG_BIT(2) | MG_BIT(1) | MG_BIT(0));
|
||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA,
|
||||
(uint16_t) (value | MG_BIT(1))); // TXDLY: 2 * 150 ps
|
||||
#endif
|
||||
} else if (id1 == MG_PHY_DP83x && id2 == MG_PHY_DP83867) {
|
||||
phy->write_reg(phy_addr, 0x0d,
|
||||
0x1f); // write 0x10d to IO_MUX_CFG (0x0170)
|
||||
|
||||
+3
-2
@@ -87,15 +87,16 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) {
|
||||
|
||||
if (config & MG_PHY_RGMII) {
|
||||
if (id1 == MG_PHY_YT85x && id2 == MG_PHY_YT8531) {
|
||||
// assume PHY has been hardware strapped properly
|
||||
#if 0
|
||||
uint16_t value;
|
||||
// TODO (robertc2000): Autonegotiation remains disabled after PHY is reset
|
||||
// We temporarily force enabling autoneg, until a workaround is found.
|
||||
phy->write_reg(phy_addr, MG_PHY_REG_BCR, MG_BIT(12));
|
||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_ADDR, 0xa003);
|
||||
value = phy->read_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA);
|
||||
value &= (uint16_t) ~(MG_BIT(3) | MG_BIT(2) | MG_BIT(1) | MG_BIT(0));
|
||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA,
|
||||
(uint16_t) (value | MG_BIT(1))); // TXDLY: 2 * 150 ps
|
||||
#endif
|
||||
} else if (id1 == MG_PHY_DP83x && id2 == MG_PHY_DP83867) {
|
||||
phy->write_reg(phy_addr, 0x0d,
|
||||
0x1f); // write 0x10d to IO_MUX_CFG (0x0170)
|
||||
|
||||
@@ -21,7 +21,7 @@ SOURCES += cmsis_rt1186/devices/MIMXRT1186/drivers/fsl_ele_base_api.c
|
||||
SOURCES += cmsis_rt1186/devices/MIMXRT1186/drivers/fsl_s3mu.c
|
||||
SOURCES += cmsis_rt1186/devices/MIMXRT1186/drivers/fsl_trdc.c
|
||||
|
||||
CFLAGS += -D__ATOLLIC__ -D__STARTUP_CLEAR_BSS -DMG_HAL_DISABLE_RANDOM
|
||||
CFLAGS += -D__ATOLLIC__ -D__STARTUP_CLEAR_BSS -DMG_HAL_DISABLE_RANDOM -DMG_HAL_ENABLE_PHY_STRAP
|
||||
|
||||
all build: firmware.bin
|
||||
|
||||
|
||||
@@ -586,9 +586,6 @@ static inline void hal_netc_pins_init(void) {
|
||||
CLOCK_EnableClock(kCLOCK_Iomuxc1);
|
||||
CLOCK_EnableClock(kCLOCK_Iomuxc2);
|
||||
|
||||
hal_gpio_output(HAL_NETC_PHY0_RESET);
|
||||
hal_gpio_write(HAL_NETC_PHY0_RESET, true);
|
||||
|
||||
hal_gpio_mux_config(kIOMUXC_SW_MUX_CTL_PAD_GPIO_AD_30, 7U); // EMDC
|
||||
hal_gpio_pad_config(kIOMUXC_SW_PAD_CTL_PAD_GPIO_AD_30,
|
||||
HAL_GPIO_OTYPE_PUSH_PULL, HAL_GPIO_SPEED_HIGH,
|
||||
@@ -648,13 +645,27 @@ static inline bool hal_netc_ierb_init(void) {
|
||||
static inline void hal_ethernet_init(void) {
|
||||
hal_netc_trdc_init();
|
||||
CLOCK_EnableClock(kCLOCK_Netc);
|
||||
hal_netc_pins_init();
|
||||
if (!hal_netc_ierb_init()) return;
|
||||
|
||||
hal_gpio_output(HAL_NETC_PHY0_RESET);
|
||||
hal_gpio_write(HAL_NETC_PHY0_RESET, false);
|
||||
SDK_DelayAtLeastUs(10000U, SYS_FREQUENCY);
|
||||
#if MG_HAL_ENABLE_PHY_STRAP
|
||||
hal_gpio_output(PIN('3', 10)); // RX_CLK PHY ADDR1
|
||||
hal_gpio_output(PIN('3', 11)); // RX_DATA_2 CFG_MODE1
|
||||
hal_gpio_output(PIN('3', 12)); // RX_DATA_3 CFG_MODE2
|
||||
hal_gpio_output(PIN('3', 20)); // RX_DATA_1 CFG_MODE0
|
||||
hal_gpio_write(PIN('3', 10), false); // PHY ADDR b101 = 5
|
||||
hal_gpio_write(PIN('3', 12), false); // CFG_MODE 000: RGMII
|
||||
hal_gpio_write(PIN('3', 11), false); //
|
||||
hal_gpio_write(PIN('3', 20), false); //
|
||||
#endif
|
||||
SDK_DelayAtLeastUs(15000U, SYS_FREQUENCY);
|
||||
hal_gpio_write(HAL_NETC_PHY0_RESET, true);
|
||||
SDK_DelayAtLeastUs(150000U, SYS_FREQUENCY);
|
||||
__DSB(); // ensure pin config happens AFTER reset is released
|
||||
SDK_DelayAtLeastUs(10U, SYS_FREQUENCY); // provide some hold time
|
||||
hal_netc_pins_init(); // release straps, set as Ethernet pins
|
||||
if (!hal_netc_ierb_init())
|
||||
return;
|
||||
SDK_DelayAtLeastUs(15000U, SYS_FREQUENCY);
|
||||
|
||||
NVIC_EnableIRQ(MSGINTR1_IRQn);
|
||||
}
|
||||
|
||||
@@ -664,3 +675,4 @@ static inline void hal_rng_init(void) {
|
||||
static inline uint32_t hal_rng_read(void) {
|
||||
return 42;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user