Skip to content

Commit d763fce

Browse files
authored
Merge pull request #2851 from cesanta/tm4c
Update TM4C driver init + nits
2 parents 1b75017 + 15c8ba5 commit d763fce

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

mongoose.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17192,10 +17192,11 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) {
1719217192
if (id1 == MG_PHY_DP83x && id2 != MG_PHY_DP83867) {
1719317193
phy->write_reg(phy_addr, MG_PHY_DP83x_REG_RCSR, MG_BIT(7) | MG_BIT(0));
1719417194
} else if (id1 == MG_PHY_KSZ8x) {
17195-
phy->write_reg(
17196-
phy_addr, MG_PHY_REG_BCR, // Disable isolation (override hw)
17195+
// Disable isolation (override hw, it doesn't make sense at this point)
17196+
phy->write_reg( // #2848, some NXP boards set ISO, even though
17197+
phy_addr, MG_PHY_REG_BCR, // docs say they don't
1719717198
phy->read_reg(phy_addr, MG_PHY_REG_BCR) & (uint16_t) ~MG_BIT(10));
17198-
phy->write_reg(phy_addr, MG_PHY_KSZ8x_REG_PC2R,
17199+
phy->write_reg(phy_addr, MG_PHY_KSZ8x_REG_PC2R, // now do clock stuff
1719917200
MG_BIT(15) | MG_BIT(8) | MG_BIT(7));
1720017201
} else if (id1 == MG_PHY_LAN87x) {
1720117202
// nothing to do

mongoose.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,6 +3052,21 @@ struct mg_tcpip_driver_tm4c_data {
30523052
#define MG_DRIVER_MDC_CR 1
30533053
#endif
30543054

3055+
#define MG_TCPIP_DRIVER_INIT(mgr) \
3056+
do { \
3057+
static struct mg_tcpip_driver_tm4c_data driver_data_; \
3058+
static struct mg_tcpip_if mif_; \
3059+
driver_data_.mdc_cr = MG_DRIVER_MDC_CR; \
3060+
mif_.ip = MG_TCPIP_IP; \
3061+
mif_.mask = MG_TCPIP_MASK; \
3062+
mif_.gw = MG_TCPIP_GW; \
3063+
mif_.driver = &mg_tcpip_driver_tm4c; \
3064+
mif_.driver_data = &driver_data_; \
3065+
MG_SET_MAC_ADDRESS(mif_.mac); \
3066+
mg_tcpip_init(mgr, &mif_); \
3067+
MG_INFO(("Driver: tm4c, MAC: %M", mg_print_mac, mif_.mac)); \
3068+
} while (0)
3069+
30553070
#endif
30563071

30573072

src/drivers/phy.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) {
7070
if (id1 == MG_PHY_DP83x && id2 != MG_PHY_DP83867) {
7171
phy->write_reg(phy_addr, MG_PHY_DP83x_REG_RCSR, MG_BIT(7) | MG_BIT(0));
7272
} else if (id1 == MG_PHY_KSZ8x) {
73-
phy->write_reg(
74-
phy_addr, MG_PHY_REG_BCR, // Disable isolation (override hw)
73+
// Disable isolation (override hw, it doesn't make sense at this point)
74+
phy->write_reg( // #2848, some NXP boards set ISO, even though
75+
phy_addr, MG_PHY_REG_BCR, // docs say they don't
7576
phy->read_reg(phy_addr, MG_PHY_REG_BCR) & (uint16_t) ~MG_BIT(10));
76-
phy->write_reg(phy_addr, MG_PHY_KSZ8x_REG_PC2R,
77+
phy->write_reg(phy_addr, MG_PHY_KSZ8x_REG_PC2R, // now do clock stuff
7778
MG_BIT(15) | MG_BIT(8) | MG_BIT(7));
7879
} else if (id1 == MG_PHY_LAN87x) {
7980
// nothing to do

src/drivers/tm4c.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,19 @@ struct mg_tcpip_driver_tm4c_data {
1919
#define MG_DRIVER_MDC_CR 1
2020
#endif
2121

22+
#define MG_TCPIP_DRIVER_INIT(mgr) \
23+
do { \
24+
static struct mg_tcpip_driver_tm4c_data driver_data_; \
25+
static struct mg_tcpip_if mif_; \
26+
driver_data_.mdc_cr = MG_DRIVER_MDC_CR; \
27+
mif_.ip = MG_TCPIP_IP; \
28+
mif_.mask = MG_TCPIP_MASK; \
29+
mif_.gw = MG_TCPIP_GW; \
30+
mif_.driver = &mg_tcpip_driver_tm4c; \
31+
mif_.driver_data = &driver_data_; \
32+
MG_SET_MAC_ADDRESS(mif_.mac); \
33+
mg_tcpip_init(mgr, &mif_); \
34+
MG_INFO(("Driver: tm4c, MAC: %M", mg_print_mac, mif_.mac)); \
35+
} while (0)
36+
2237
#endif

0 commit comments

Comments
 (0)