drivers: net: lan865x: Move PLCA configuration to dedicated structure
This change allows modification of the PLCA configuration in the lan865x driver. Values in this structure can be set via device tree as well as modified by the user program. Without this change the latter use case would not be possible as the struct lan865x_config structure is defined as read only and its data is only provided by device tree. Signed-off-by: Lukasz Majewski <lukma@denx.de>
This commit is contained in:
parent
07d04b0f40
commit
9d8100f43f
|
@ -337,11 +337,11 @@ static int lan865x_default_config(const struct device *dev, uint8_t silicon_rev)
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (cfg->plca_enable) {
|
||||
ret = lan865x_config_plca(dev, cfg->plca_node_id,
|
||||
cfg->plca_node_count,
|
||||
cfg->plca_burst_count,
|
||||
cfg->plca_burst_timer);
|
||||
if (cfg->plca->enable) {
|
||||
ret = lan865x_config_plca(dev, cfg->plca->node_id,
|
||||
cfg->plca->node_count,
|
||||
cfg->plca->burst_count,
|
||||
cfg->plca->burst_timer);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -540,17 +540,21 @@ static const struct ethernet_api lan865x_api_func = {
|
|||
};
|
||||
|
||||
#define LAN865X_DEFINE(inst) \
|
||||
static struct lan865x_config_plca lan865x_config_plca_##inst = { \
|
||||
.node_id = DT_INST_PROP(inst, plca_node_id), \
|
||||
.node_count = DT_INST_PROP(inst, plca_node_count), \
|
||||
.burst_count = DT_INST_PROP(inst, plca_burst_count), \
|
||||
.burst_timer = DT_INST_PROP(inst, plca_burst_timer), \
|
||||
.to_timer = DT_INST_PROP(inst, plca_to_timer), \
|
||||
.enable = DT_INST_PROP(inst, plca_enable), \
|
||||
}; \
|
||||
\
|
||||
static const struct lan865x_config lan865x_config_##inst = { \
|
||||
.spi = SPI_DT_SPEC_INST_GET(inst, SPI_WORD_SET(8), 0), \
|
||||
.interrupt = GPIO_DT_SPEC_INST_GET(inst, int_gpios), \
|
||||
.reset = GPIO_DT_SPEC_INST_GET(inst, rst_gpios), \
|
||||
.timeout = CONFIG_ETH_LAN865X_TIMEOUT, \
|
||||
.plca_node_id = DT_INST_PROP(inst, plca_node_id), \
|
||||
.plca_node_count = DT_INST_PROP(inst, plca_node_count), \
|
||||
.plca_burst_count = DT_INST_PROP(inst, plca_burst_count), \
|
||||
.plca_burst_timer = DT_INST_PROP(inst, plca_burst_timer), \
|
||||
.plca_to_timer = DT_INST_PROP(inst, plca_to_timer), \
|
||||
.plca_enable = DT_INST_PROP(inst, plca_enable), \
|
||||
.plca = &lan865x_config_plca_##inst, \
|
||||
}; \
|
||||
\
|
||||
struct oa_tc6 oa_tc6_##inst = { \
|
||||
|
|
|
@ -38,6 +38,15 @@
|
|||
/* Memory Map Sector (MMS) 10 (0xA) */
|
||||
#define LAN865x_DEVID MMS_REG(0xA, 0x094)
|
||||
|
||||
struct lan865x_config_plca {
|
||||
bool enable : 1; /* 1 - PLCA enable, 0 - CSMA/CD enable */
|
||||
uint8_t node_id /* PLCA node id range: 0 to 254 */;
|
||||
uint8_t node_count; /* PLCA node count range: 1 to 255 */
|
||||
uint8_t burst_count; /* PLCA burst count range: 0x0 to 0xFF */
|
||||
uint8_t burst_timer; /* PLCA burst timer */
|
||||
uint8_t to_timer; /* PLCA TO value */
|
||||
};
|
||||
|
||||
struct lan865x_config {
|
||||
struct spi_dt_spec spi;
|
||||
struct gpio_dt_spec interrupt;
|
||||
|
@ -45,12 +54,7 @@ struct lan865x_config {
|
|||
int32_t timeout;
|
||||
|
||||
/* PLCA */
|
||||
bool plca_enable : 1; /* 1 - PLCA enable, 0 - CSMA/CD enable */
|
||||
uint8_t plca_node_id /* PLCA node id range: 0 to 254 */;
|
||||
uint8_t plca_node_count; /* PLCA node count range: 1 to 255 */
|
||||
uint8_t plca_burst_count; /* PLCA burst count range: 0x0 to 0xFF */
|
||||
uint8_t plca_burst_timer; /* PLCA burst timer */
|
||||
uint8_t plca_to_timer; /* PLCA TO value */
|
||||
struct lan865x_config_plca *plca;
|
||||
|
||||
/* MAC */
|
||||
bool tx_cut_through_mode; /* 1 - tx cut through, 0 - Store and forward */
|
||||
|
|
Loading…
Reference in a new issue