drivers: ethernet: phy: add dt prop for default speeds
add dt prop for default speeds, that the phy is configured on init by default. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
parent
5170a4daac
commit
dfb5a31b3e
2 changed files with 27 additions and 7 deletions
|
@ -26,6 +26,7 @@ struct phy_mii_dev_config {
|
||||||
bool no_reset;
|
bool no_reset;
|
||||||
bool fixed;
|
bool fixed;
|
||||||
int fixed_speed;
|
int fixed_speed;
|
||||||
|
enum phy_link_speed default_speeds;
|
||||||
const struct device * const mdio;
|
const struct device * const mdio;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -610,13 +611,8 @@ static int phy_mii_initialize_dynamic_link(const struct device *dev)
|
||||||
k_work_init_delayable(&data->monitor_work, monitor_work_handler);
|
k_work_init_delayable(&data->monitor_work, monitor_work_handler);
|
||||||
k_work_init_delayable(&data->autoneg_work, autoneg_work_handler);
|
k_work_init_delayable(&data->autoneg_work, autoneg_work_handler);
|
||||||
|
|
||||||
/* Advertise all speeds */
|
/* Advertise default speeds */
|
||||||
phy_mii_cfg_link(dev, LINK_HALF_10BASE |
|
phy_mii_cfg_link(dev, cfg->default_speeds);
|
||||||
LINK_FULL_10BASE |
|
|
||||||
LINK_HALF_100BASE |
|
|
||||||
LINK_FULL_100BASE |
|
|
||||||
LINK_HALF_1000BASE |
|
|
||||||
LINK_FULL_1000BASE);
|
|
||||||
|
|
||||||
monitor_work_handler(&data->monitor_work.work);
|
monitor_work_handler(&data->monitor_work.work);
|
||||||
|
|
||||||
|
@ -636,12 +632,24 @@ static DEVICE_API(ethphy, phy_mii_driver_api) = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define PHY_MII_GENERATE_DEFAULT_SPEEDS(n) \
|
||||||
|
((DT_INST_ENUM_HAS_VALUE(n, default_speeds, 10base_half_duplex) ? LINK_HALF_10BASE : 0) | \
|
||||||
|
(DT_INST_ENUM_HAS_VALUE(n, default_speeds, 10base_full_duplex) ? LINK_FULL_10BASE : 0) | \
|
||||||
|
(DT_INST_ENUM_HAS_VALUE(n, default_speeds, 100base_half_duplex) ? LINK_HALF_100BASE : 0) | \
|
||||||
|
(DT_INST_ENUM_HAS_VALUE(n, default_speeds, 100base_full_duplex) ? LINK_FULL_100BASE : 0) | \
|
||||||
|
(DT_INST_ENUM_HAS_VALUE(n, default_speeds, 1000base_half_duplex) ? LINK_HALF_1000BASE : 0) | \
|
||||||
|
(DT_INST_ENUM_HAS_VALUE(n, default_speeds, 1000base_full_duplex) ? LINK_FULL_1000BASE : 0))
|
||||||
|
|
||||||
#define PHY_MII_CONFIG(n) \
|
#define PHY_MII_CONFIG(n) \
|
||||||
|
BUILD_ASSERT(PHY_MII_GENERATE_DEFAULT_SPEEDS(n) != 0, \
|
||||||
|
"At least one valid speed must be configured for this driver"); \
|
||||||
|
\
|
||||||
static const struct phy_mii_dev_config phy_mii_dev_config_##n = { \
|
static const struct phy_mii_dev_config phy_mii_dev_config_##n = { \
|
||||||
.phy_addr = DT_INST_REG_ADDR(n), \
|
.phy_addr = DT_INST_REG_ADDR(n), \
|
||||||
.no_reset = DT_INST_PROP(n, no_reset), \
|
.no_reset = DT_INST_PROP(n, no_reset), \
|
||||||
.fixed = IS_FIXED_LINK(n), \
|
.fixed = IS_FIXED_LINK(n), \
|
||||||
.fixed_speed = DT_INST_ENUM_IDX_OR(n, fixed_link, 0), \
|
.fixed_speed = DT_INST_ENUM_IDX_OR(n, fixed_link, 0), \
|
||||||
|
.default_speeds = PHY_MII_GENERATE_DEFAULT_SPEEDS(n), \
|
||||||
.mdio = UTIL_AND(UTIL_NOT(IS_FIXED_LINK(n)), \
|
.mdio = UTIL_AND(UTIL_NOT(IS_FIXED_LINK(n)), \
|
||||||
DEVICE_DT_GET(DT_INST_BUS(n))) \
|
DEVICE_DT_GET(DT_INST_BUS(n))) \
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,3 +26,15 @@ properties:
|
||||||
- "100BASE-T Full-Duplex"
|
- "100BASE-T Full-Duplex"
|
||||||
- "1000BASE-T Half-Duplex"
|
- "1000BASE-T Half-Duplex"
|
||||||
- "1000BASE-T Full-Duplex"
|
- "1000BASE-T Full-Duplex"
|
||||||
|
default-speeds:
|
||||||
|
type: string-array
|
||||||
|
description: The selected speeds are used to configure the PHY during initialization
|
||||||
|
enum:
|
||||||
|
- "10BASE Half-Duplex"
|
||||||
|
- "10BASE Full-Duplex"
|
||||||
|
- "100BASE Half-Duplex"
|
||||||
|
- "100BASE Full-Duplex"
|
||||||
|
- "1000BASE Half-Duplex"
|
||||||
|
- "1000BASE Full-Duplex"
|
||||||
|
default: ["10BASE Half-Duplex", "10BASE Full-Duplex", "100BASE Half-Duplex",
|
||||||
|
"100BASE Full-Duplex", "1000BASE Half-Duplex", "1000BASE Full-Duplex"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue