dts: ksz8974: rename driver to ksz8xxxx

Renamed driver to reflect that it supports different KSZ8 series chips.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
This commit is contained in:
Arvin Farahmand 2021-05-05 18:17:09 -04:00 committed by Christopher Friedt
parent b0e4886dfa
commit 9cb353a97e
3 changed files with 109 additions and 110 deletions

View file

@ -26,7 +26,7 @@ zephyr_sources_ifdef(CONFIG_ETH_SMSC911X eth_smsc911x.c)
zephyr_sources_ifdef(CONFIG_ETH_STM32_HAL eth_stm32_hal.c)
zephyr_sources_ifdef(CONFIG_ETH_LITEETH eth_liteeth.c)
zephyr_sources_ifdef(CONFIG_ETH_W5500 eth_w5500.c)
zephyr_sources_ifdef(CONFIG_DSA_KSZ8794 dsa_ksz8794.c)
zephyr_sources_ifdef(CONFIG_DSA_KSZ8XXX dsa_ksz8xxx.c)
if(CONFIG_ETH_NATIVE_POSIX)
zephyr_library()

View file

@ -13,13 +13,18 @@ menuconfig NET_DSA
if NET_DSA
config DSA_KSZ8XXX
bool
config DSA_KSZ8794
bool "Enable support for KSZ8794"
select DSA_KSZ8XXX
help
Add support for KSZ8794 DSA device driver.
config DSA_KSZ8863
bool "Enable support for KSZ8863"
select DSA_KSZ8XXX
help
Add support for KSZ8863 DSA device driver.

View file

@ -34,7 +34,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_ETHERNET_LOG_LEVEL);
#error "Unsupported KSZ chipset"
#endif
struct ksz8794_data {
struct ksz8xxx_data {
int iface_init_count;
bool is_init;
#if defined(CONFIG_DSA_SPI)
@ -44,15 +44,15 @@ struct ksz8794_data {
#endif
};
static struct ksz8794_data private_data = {
static struct ksz8xxx_data private_data = {
.iface_init_count = 0,
.is_init = false,
};
#define DEV_DATA(dev) ((struct dsa_context *const)(dev)->data)
#define PRV_DATA(ctx) ((struct ksz8794_data *const)(ctx)->prv_data)
#define PRV_DATA(ctx) ((struct ksz8xxx_data *const)(ctx)->prv_data)
static void dsa_ksz8794_write_reg(const struct ksz8794_data *pdev,
static void dsa_ksz8xxx_write_reg(const struct ksz8xxx_data *pdev,
uint16_t reg_addr, uint8_t value)
{
#if defined(CONFIG_DSA_SPI)
@ -75,7 +75,7 @@ static void dsa_ksz8794_write_reg(const struct ksz8794_data *pdev,
#endif
}
static void dsa_ksz8794_read_reg(const struct ksz8794_data *pdev,
static void dsa_ksz8xxx_read_reg(const struct ksz8xxx_data *pdev,
uint16_t reg_addr, uint8_t *value)
{
#if defined(CONFIG_DSA_SPI)
@ -112,7 +112,7 @@ static void dsa_ksz8794_read_reg(const struct ksz8794_data *pdev,
#endif
}
static bool dsa_ksz8794_port_link_status(struct ksz8794_data *pdev,
static bool dsa_ksz8xxx_port_link_status(struct ksz8xxx_data *pdev,
uint8_t port)
{
uint8_t tmp;
@ -122,23 +122,23 @@ static bool dsa_ksz8794_port_link_status(struct ksz8794_data *pdev,
return false;
}
dsa_ksz8794_read_reg(pdev, KSZ8XXX_STAT2_PORTn(port), &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_STAT2_PORTn(port), &tmp);
return tmp & KSZ8XXX_STAT2_LINK_GOOD;
}
#if !DT_INST_NODE_HAS_PROP(0, reset_gpios)
static void dsa_ksz8794_soft_reset(struct ksz8794_data *pdev)
static void dsa_ksz8xxx_soft_reset(struct ksz8xxx_data *pdev)
{
/* reset switch */
dsa_ksz8794_write_reg(pdev, KSZ8XXX_RESET_REG,
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_RESET_REG,
KSZ8XXX_RESET_SET);
k_busy_wait(KSZ8XXX_SOFT_RESET_DURATION);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_RESET_REG, KSZ8XXX_RESET_CLEAR);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_RESET_REG, KSZ8XXX_RESET_CLEAR);
}
#endif
static int dsa_ksz8794_probe(struct ksz8794_data *pdev)
static int dsa_ksz8xxx_probe(struct ksz8xxx_data *pdev)
{
uint16_t timeout = 100;
uint8_t val[2], tmp;
@ -148,7 +148,7 @@ static int dsa_ksz8794_probe(struct ksz8794_data *pdev)
*/
for (timeout = 100, tmp = 0;
tmp != KSZ8XXX_CHIP_ID0_ID_DEFAULT && timeout > 0; timeout--) {
dsa_ksz8794_read_reg(pdev, KSZ8XXX_CHIP_ID0, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_CHIP_ID0, &tmp);
k_busy_wait(100);
}
@ -157,8 +157,8 @@ static int dsa_ksz8794_probe(struct ksz8794_data *pdev)
return -ENODEV;
}
dsa_ksz8794_read_reg(pdev, KSZ8XXX_CHIP_ID0, &val[0]);
dsa_ksz8794_read_reg(pdev, KSZ8XXX_CHIP_ID1, &val[1]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_CHIP_ID0, &val[0]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_CHIP_ID1, &val[1]);
if (val[0] != KSZ8XXX_CHIP_ID0_ID_DEFAULT ||
val[1] != KSZ8XXX_CHIP_ID1_ID_DEFAULT) {
@ -177,7 +177,7 @@ static int dsa_ksz8794_probe(struct ksz8794_data *pdev)
return 0;
}
static int dsa_ksz8794_write_static_mac_table(struct ksz8794_data *pdev,
static int dsa_ksz8xxx_write_static_mac_table(struct ksz8xxx_data *pdev,
uint16_t entry_addr, uint8_t *p)
{
/*
@ -192,22 +192,22 @@ static int dsa_ksz8794_write_static_mac_table(struct ksz8794_data *pdev,
* Write to Register 111 with 0x0x (trigger the write operation, to
* table entry x)
*/
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_DATA_7, p[7]);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_DATA_6, p[6]);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_DATA_5, p[5]);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_DATA_4, p[4]);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_DATA_3, p[3]);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_DATA_2, p[2]);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_DATA_1, p[1]);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_DATA_0, p[0]);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_DATA_7, p[7]);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_DATA_6, p[6]);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_DATA_5, p[5]);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_DATA_4, p[4]);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_DATA_3, p[3]);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_DATA_2, p[2]);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_DATA_1, p[1]);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_DATA_0, p[0]);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_CTRL_0, 0x00);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_CTRL_1, entry_addr);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_CTRL_0, 0x00);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_CTRL_1, entry_addr);
return 0;
}
static int dsa_ksz8794_set_static_mac_table(struct ksz8794_data *pdev,
static int dsa_ksz8xxx_set_static_mac_table(struct ksz8xxx_data *pdev,
const uint8_t *mac, uint8_t fw_port,
uint16_t entry_idx)
{
@ -230,12 +230,12 @@ static int dsa_ksz8794_set_static_mac_table(struct ksz8794_data *pdev,
buf[6] |= KSZ8XXX_STATIC_MAC_TABLE_VALID;
buf[6] |= KSZ8XXX_STATIC_MAC_TABLE_OVRD;
dsa_ksz8794_write_static_mac_table(pdev, entry_idx, buf);
dsa_ksz8xxx_write_static_mac_table(pdev, entry_idx, buf);
return 0;
}
static int dsa_ksz8794_read_static_mac_table(struct ksz8794_data *pdev,
static int dsa_ksz8xxx_read_static_mac_table(struct ksz8xxx_data *pdev,
uint16_t entry_addr, uint8_t *p)
{
/*
@ -253,29 +253,23 @@ static int dsa_ksz8794_read_static_mac_table(struct ksz8794_data *pdev,
*
*/
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_CTRL_0, 0x10);
dsa_ksz8794_write_reg(pdev, KSZ8XXX_REG_IND_CTRL_1, entry_addr);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_CTRL_0, 0x10);
dsa_ksz8xxx_write_reg(pdev, KSZ8XXX_REG_IND_CTRL_1, entry_addr);
dsa_ksz8794_read_reg(pdev, KSZ8XXX_REG_IND_DATA_7, &p[7]);
dsa_ksz8794_read_reg(pdev, KSZ8XXX_REG_IND_DATA_6, &p[6]);
dsa_ksz8794_read_reg(pdev, KSZ8XXX_REG_IND_DATA_5, &p[5]);
dsa_ksz8794_read_reg(pdev, KSZ8XXX_REG_IND_DATA_4, &p[4]);
dsa_ksz8794_read_reg(pdev, KSZ8XXX_REG_IND_DATA_3, &p[3]);
dsa_ksz8794_read_reg(pdev, KSZ8XXX_REG_IND_DATA_2, &p[2]);
dsa_ksz8794_read_reg(pdev, KSZ8XXX_REG_IND_DATA_1, &p[1]);
dsa_ksz8794_read_reg(pdev, KSZ8XXX_REG_IND_DATA_0, &p[0]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_REG_IND_DATA_7, &p[7]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_REG_IND_DATA_6, &p[6]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_REG_IND_DATA_5, &p[5]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_REG_IND_DATA_4, &p[4]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_REG_IND_DATA_3, &p[3]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_REG_IND_DATA_2, &p[2]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_REG_IND_DATA_1, &p[1]);
dsa_ksz8xxx_read_reg(pdev, KSZ8XXX_REG_IND_DATA_0, &p[0]);
return 0;
}
static int dsa_ksz8794_get_static_mac_table(struct ksz8794_data *pdev,
uint8_t *buf, uint16_t entry_idx)
{
return dsa_ksz8794_read_static_mac_table(pdev, entry_idx, buf);
}
#if CONFIG_DSA_KSZ8863
static int dsa_ksz8794_switch_setup(const struct ksz8794_data *pdev)
static int dsa_ksz8xxx_switch_setup(const struct ksz8xxx_data *pdev)
{
uint8_t tmp, i;
@ -286,35 +280,35 @@ static int dsa_ksz8794_switch_setup(const struct ksz8794_data *pdev)
for (i = KSZ8XXX_FIRST_PORT; i <= KSZ8XXX_LAST_PORT; i++) {
/* Enable transmission, reception and switch address learning */
dsa_ksz8794_read_reg(pdev, KSZ8863_CTRL2_PORTn(i), &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8863_CTRL2_PORTn(i), &tmp);
tmp |= KSZ8863_CTRL2_TRANSMIT_EN;
tmp |= KSZ8863_CTRL2_RECEIVE_EN;
tmp &= ~KSZ8863_CTRL2_LEARNING_DIS;
dsa_ksz8794_write_reg(pdev, KSZ8863_CTRL2_PORTn(i), tmp);
dsa_ksz8xxx_write_reg(pdev, KSZ8863_CTRL2_PORTn(i), tmp);
}
#if defined(CONFIG_DSA_KSZ_TAIL_TAGGING)
/* Enable tail tag feature */
dsa_ksz8794_read_reg(pdev, KSZ8863_GLOBAL_CTRL10, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8863_GLOBAL_CTRL10, &tmp);
tmp |= KSZ8863_GLOBAL_CTRL1_TAIL_TAG_EN;
dsa_ksz8794_write_reg(pdev, KSZ8863_GLOBAL_CTRL10, tmp);
dsa_ksz8xxx_write_reg(pdev, KSZ8863_GLOBAL_CTRL10, tmp);
#else
/* Disable tail tag feature */
dsa_ksz8794_read_reg(pdev, KSZ8863_GLOBAL_CTRL1, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8863_GLOBAL_CTRL1, &tmp);
tmp &= ~KSZ8863_GLOBAL_CTRL1_TAIL_TAG_EN;
dsa_ksz8794_write_reg(pdev, KSZ8863_GLOBAL_CTRL1, tmp);
dsa_ksz8xxx_write_reg(pdev, KSZ8863_GLOBAL_CTRL1, tmp);
#endif
dsa_ksz8794_read_reg(pdev, KSZ8863_GLOBAL_CTRL2, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8863_GLOBAL_CTRL2, &tmp);
tmp &= ~KSZ8863_GLOBAL_CTRL2_LEG_MAX_PKT_SIZ_CHK_ENA;
dsa_ksz8794_write_reg(pdev, KSZ8863_GLOBAL_CTRL2, tmp);
dsa_ksz8xxx_write_reg(pdev, KSZ8863_GLOBAL_CTRL2, tmp);
return 0;
}
#endif
#if CONFIG_DSA_KSZ8794
static int dsa_ksz8794_switch_setup(struct ksz8794_data *pdev)
static int dsa_ksz8xxx_switch_setup(struct ksz8xxx_data *pdev)
{
uint8_t tmp, i;
@ -329,34 +323,34 @@ static int dsa_ksz8794_switch_setup(struct ksz8794_data *pdev)
}
/* Enable transmission, reception and switch address learning */
dsa_ksz8794_read_reg(pdev, KSZ8794_CTRL2_PORTn(i), &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8794_CTRL2_PORTn(i), &tmp);
tmp |= KSZ8794_CTRL2_TRANSMIT_EN;
tmp |= KSZ8794_CTRL2_RECEIVE_EN;
tmp &= ~KSZ8794_CTRL2_LEARNING_DIS;
dsa_ksz8794_write_reg(pdev, KSZ8794_CTRL2_PORTn(i), tmp);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_CTRL2_PORTn(i), tmp);
}
#if defined(DSA_KSZ_TAIL_TAGGING)
/* Enable tail tag feature */
dsa_ksz8794_read_reg(pdev, KSZ8794_GLOBAL_CTRL10, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8794_GLOBAL_CTRL10, &tmp);
tmp |= KSZ8794_GLOBAL_CTRL10_TAIL_TAG_EN;
dsa_ksz8794_write_reg(pdev, KSZ8794_GLOBAL_CTRL10, tmp);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_GLOBAL_CTRL10, tmp);
#else
/* Disable tail tag feature */
dsa_ksz8794_read_reg(pdev, KSZ8794_GLOBAL_CTRL10, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8794_GLOBAL_CTRL10, &tmp);
tmp &= ~KSZ8794_GLOBAL_CTRL10_TAIL_TAG_EN;
dsa_ksz8794_write_reg(pdev, KSZ8794_GLOBAL_CTRL10, tmp);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_GLOBAL_CTRL10, tmp);
#endif
dsa_ksz8794_read_reg(pdev, KSZ8794_PORT4_IF_CTRL6, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8794_PORT4_IF_CTRL6, &tmp);
LOG_DBG("KSZ8794: CONTROL6: 0x%x port4", tmp);
dsa_ksz8794_read_reg(pdev, KSZ8794_PORT4_CTRL2, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8794_PORT4_CTRL2, &tmp);
LOG_DBG("KSZ8794: CONTROL2: 0x%x port4", tmp);
dsa_ksz8794_read_reg(pdev, KSZ8794_GLOBAL_CTRL2, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8794_GLOBAL_CTRL2, &tmp);
tmp |= KSZ8794_GLOBAL_CTRL2_LEG_MAX_PKT_SIZ_CHK_DIS;
dsa_ksz8794_write_reg(pdev, KSZ8794_GLOBAL_CTRL2, tmp);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_GLOBAL_CTRL2, tmp);
return 0;
}
@ -433,15 +427,15 @@ static int dsa_ksz8794_switch_setup(struct ksz8794_data *pdev)
* for all corner cases of the short cable and short distance connection for
* port to port or board to board cases.
*/
static int dsa_ksz8794_phy_workaround_0x01(struct ksz8794_data *pdev)
static int dsa_ksz8794_phy_workaround_0x01(struct ksz8xxx_data *pdev)
{
uint8_t indirect_type = 0x0a;
uint8_t indirect_addr = 0x3c;
uint8_t indirect_data = 0x15;
dsa_ksz8794_write_reg(pdev, KSZ8794_REG_IND_CTRL_0, indirect_type);
dsa_ksz8794_write_reg(pdev, KSZ8794_REG_IND_CTRL_1, indirect_addr);
dsa_ksz8794_write_reg(pdev, KSZ8794_IND_BYTE, indirect_data);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_REG_IND_CTRL_0, indirect_type);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_REG_IND_CTRL_1, indirect_addr);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_IND_BYTE, indirect_data);
LOG_INF("apply workarkound 0x01 for short connections on KSZ8794");
return 0;
}
@ -560,33 +554,33 @@ static int dsa_ksz8794_phy_workaround_0x01(struct ksz8794_data *pdev)
* lengths.
*/
static int dsa_ksz8794_phy_workaround_0x02(struct ksz8794_data *pdev)
static int dsa_ksz8794_phy_workaround_0x02(struct ksz8xxx_data *pdev)
{
uint8_t indirect_type = 0x0a;
uint8_t indirect_addr = 0x4c;
uint8_t indirect_data = 0x40;
dsa_ksz8794_write_reg(pdev, KSZ8794_REG_IND_CTRL_0, indirect_type);
dsa_ksz8794_write_reg(pdev, KSZ8794_REG_IND_CTRL_1, indirect_addr);
dsa_ksz8794_write_reg(pdev, KSZ8794_IND_BYTE, indirect_data);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_REG_IND_CTRL_0, indirect_type);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_REG_IND_CTRL_1, indirect_addr);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_IND_BYTE, indirect_data);
LOG_INF("apply workarkound 0x02 link issue CAT-5E/6 on KSZ8794");
return 0;
}
static int dsa_ksz8794_phy_workaround_0x04(struct ksz8794_data *pdev)
static int dsa_ksz8794_phy_workaround_0x04(struct ksz8xxx_data *pdev)
{
uint8_t indirect_type = 0x0a;
uint8_t indirect_addr = 0x08;
uint8_t indirect_data = 0x00;
dsa_ksz8794_write_reg(pdev, KSZ8794_REG_IND_CTRL_0, indirect_type);
dsa_ksz8794_write_reg(pdev, KSZ8794_REG_IND_CTRL_1, indirect_addr);
dsa_ksz8794_write_reg(pdev, KSZ8794_IND_BYTE, indirect_data);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_REG_IND_CTRL_0, indirect_type);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_REG_IND_CTRL_1, indirect_addr);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_IND_BYTE, indirect_data);
LOG_INF("apply workarkound 0x04 link issue CAT-5E/6 on KSZ8794");
return 0;
}
static int dsa_ksz8794_apply_workarounds(struct ksz8794_data *pdev)
static int dsa_ksz8794_apply_workarounds(struct ksz8xxx_data *pdev)
{
int workaround = DT_INST_PROP(0, workaround);
@ -604,7 +598,7 @@ static int dsa_ksz8794_apply_workarounds(struct ksz8794_data *pdev)
#endif
#if DT_INST_NODE_HAS_PROP(0, mii_lowspeed_drivestrength)
static int dsa_ksz8794_set_lowspeed_drivestrength(struct ksz8794_data *pdev)
static int dsa_ksz8794_set_lowspeed_drivestrength(struct ksz8xxx_data *pdev)
{
int mii_lowspeed_drivestrength =
DT_INST_PROP(0, mii_lowspeed_drivestrength);
@ -646,11 +640,11 @@ static int dsa_ksz8794_set_lowspeed_drivestrength(struct ksz8794_data *pdev)
if (ret == 0) {
/* set Low-Speed Interface Drive Strength for MII and RMMI */
dsa_ksz8794_read_reg(pdev, KSZ8794_GLOBAL_CTRL20, &tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8794_GLOBAL_CTRL20, &tmp);
tmp &= ~KSZ8794_GLOBAL_CTRL20_LOWSPEED_MASK;
tmp |= val;
dsa_ksz8794_write_reg(pdev, KSZ8794_GLOBAL_CTRL20, tmp);
dsa_ksz8794_read_reg(pdev, KSZ8794_GLOBAL_CTRL20, &tmp);
dsa_ksz8xxx_write_reg(pdev, KSZ8794_GLOBAL_CTRL20, tmp);
dsa_ksz8xxx_read_reg(pdev, KSZ8794_GLOBAL_CTRL20, &tmp);
LOG_INF("KSZ8794: set drive strength %dmA",
mii_lowspeed_drivestrength);
}
@ -660,7 +654,7 @@ static int dsa_ksz8794_set_lowspeed_drivestrength(struct ksz8794_data *pdev)
#endif
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
static int dsa_ksz8794_gpio_reset(struct ksz8794_data *pdev)
static int dsa_ksz8xxx_gpio_reset(struct ksz8xxx_data *pdev)
{
const struct device *reset_dev =
device_get_binding(DT_INST_GPIO_LABEL(0, reset_gpios));
@ -681,7 +675,7 @@ static int dsa_ksz8794_gpio_reset(struct ksz8794_data *pdev)
}
#endif
static int dsa_ksz8794_configure_bus(struct ksz8794_data *pdev)
static int dsa_ksz8xxx_configure_bus(struct ksz8xxx_data *pdev)
{
#if defined(CONFIG_DSA_SPI)
/* SPI config */
@ -715,7 +709,7 @@ static int dsa_ksz8794_configure_bus(struct ksz8794_data *pdev)
}
/* Low level initialization code for DSA PHY */
int dsa_hw_init(struct ksz8794_data *pdev)
int dsa_hw_init(struct ksz8xxx_data *pdev)
{
int rc;
@ -725,31 +719,31 @@ int dsa_hw_init(struct ksz8794_data *pdev)
/* Hard reset */
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
dsa_ksz8794_gpio_reset(pdev);
dsa_ksz8xxx_gpio_reset(pdev);
/* Time needed for chip to completely power up (100ms) */
k_busy_wait(KSZ8XXX_HARD_RESET_WAIT);
#endif
/* Configure communication bus */
rc = dsa_ksz8794_configure_bus(pdev);
rc = dsa_ksz8xxx_configure_bus(pdev);
if (rc < 0) {
return rc;
}
/* Probe attached PHY */
rc = dsa_ksz8794_probe(pdev);
rc = dsa_ksz8xxx_probe(pdev);
if (rc < 0) {
return rc;
}
#if !DT_INST_NODE_HAS_PROP(0, reset_gpios)
/* Soft reset */
dsa_ksz8794_soft_reset(pdev);
dsa_ksz8xxx_soft_reset(pdev);
#endif
/* Setup KSZ8794 */
dsa_ksz8794_switch_setup(pdev);
dsa_ksz8xxx_switch_setup(pdev);
#if DT_INST_NODE_HAS_PROP(0, mii_lowspeed_drivestrength)
dsa_ksz8794_set_lowspeed_drivestrength(pdev);
@ -769,7 +763,7 @@ static void dsa_delayed_work(struct k_work *item)
{
struct dsa_context *context =
CONTAINER_OF(item, struct dsa_context, dsa_work);
struct ksz8794_data *pdev = PRV_DATA(context);
struct ksz8xxx_data *pdev = PRV_DATA(context);
bool link_state;
uint8_t i;
@ -779,7 +773,7 @@ static void dsa_delayed_work(struct k_work *item)
continue;
}
link_state = dsa_ksz8794_port_link_status(pdev, i);
link_state = dsa_ksz8xxx_port_link_status(pdev, i);
if (link_state && !context->link_up[i]) {
LOG_INF("DSA port: %d link UP!", i);
net_eth_carrier_on(context->iface_slave[i]);
@ -795,25 +789,25 @@ static void dsa_delayed_work(struct k_work *item)
int dsa_port_init(const struct device *dev)
{
struct ksz8794_data *pdev = PRV_DATA(DEV_DATA(dev));
struct ksz8xxx_data *pdev = PRV_DATA(DEV_DATA(dev));
dsa_hw_init(pdev);
return 0;
}
/* Generic implementation of writing value to DSA register */
static int dsa_ksz8794_sw_write_reg(int switch_id, uint16_t reg_addr,
static int dsa_ksz8xxx_sw_write_reg(int switch_id, uint16_t reg_addr,
uint8_t value)
{
dsa_ksz8794_write_reg(&private_data, reg_addr, value);
dsa_ksz8xxx_write_reg(&private_data, reg_addr, value);
return 0;
}
/* Generic implementation of reading value from DSA register */
static int dsa_ksz8794_sw_read_reg(int switch_id, uint16_t reg_addr,
static int dsa_ksz8xxx_sw_read_reg(int switch_id, uint16_t reg_addr,
uint8_t *value)
{
dsa_ksz8794_read_reg(&private_data, reg_addr, value);
dsa_ksz8xxx_read_reg(&private_data, reg_addr, value);
return 0;
}
@ -828,7 +822,7 @@ static int dsa_ksz8794_sw_read_reg(int switch_id, uint16_t reg_addr,
*
* @return 0 if ok, < 0 if error
*/
static int dsa_ksz8794_set_mac_table_entry(int switch_id, const uint8_t *mac,
static int dsa_ksz8xxx_set_mac_table_entry(int switch_id, const uint8_t *mac,
uint8_t fw_port,
uint16_t tbl_entry_idx,
uint16_t flags)
@ -837,7 +831,7 @@ static int dsa_ksz8794_set_mac_table_entry(int switch_id, const uint8_t *mac,
return -EINVAL;
}
dsa_ksz8794_set_static_mac_table(&private_data, mac, fw_port,
dsa_ksz8xxx_set_static_mac_table(&private_data, mac, fw_port,
tbl_entry_idx);
return 0;
@ -852,10 +846,10 @@ static int dsa_ksz8794_set_mac_table_entry(int switch_id, const uint8_t *mac,
*
* @return 0 if ok, < 0 if error
*/
static int dsa_ksz8794_get_mac_table_entry(int switch_id, uint8_t *buf,
static int dsa_ksz8xxx_get_mac_table_entry(int switch_id, uint8_t *buf,
uint16_t tbl_entry_idx)
{
dsa_ksz8794_get_static_mac_table(&private_data, buf, tbl_entry_idx);
dsa_ksz8xxx_read_static_mac_table(&private_data, tbl_entry_idx, buf);
return 0;
}
@ -870,7 +864,7 @@ static int dsa_ksz8794_get_mac_table_entry(int switch_id, uint8_t *buf,
#define DSA_MIN_L2_FRAME_SIZE 64
#define DSA_L2_FCS_SIZE 4
struct net_pkt *dsa_ksz8794_xmit_pkt(struct net_if *iface, struct net_pkt *pkt)
struct net_pkt *dsa_ksz8xxx_xmit_pkt(struct net_if *iface, struct net_pkt *pkt)
{
struct ethernet_context *ctx = net_if_l2_data(iface);
struct net_eth_hdr *hdr = NET_ETH_HDR(pkt);
@ -951,7 +945,7 @@ struct net_pkt *dsa_ksz8794_xmit_pkt(struct net_if *iface, struct net_pkt *pkt)
* Returns:
* - Pointer to struct net_if
*/
static struct net_if *dsa_ksz8794_get_iface(struct net_if *iface,
static struct net_if *dsa_ksz8xxx_get_iface(struct net_if *iface,
struct net_pkt *pkt)
{
struct ethernet_context *ctx;
@ -1001,7 +995,7 @@ static void dsa_iface_init(struct net_if *iface)
struct ethernet_context *ctx = net_if_l2_data(iface);
const struct device *dm, *dev = net_if_get_device(iface);
struct dsa_context *context = dev->data;
struct ksz8794_data *pdev = PRV_DATA(context);
struct ksz8xxx_data *pdev = PRV_DATA(context);
struct ethernet_context *ctx_master;
int i = pdev->iface_init_count;
@ -1068,13 +1062,13 @@ const struct ethernet_api dsa_eth_api_funcs = {
};
static struct dsa_api dsa_api_f = {
.switch_read = dsa_ksz8794_sw_read_reg,
.switch_write = dsa_ksz8794_sw_write_reg,
.switch_set_mac_table_entry = dsa_ksz8794_set_mac_table_entry,
.switch_get_mac_table_entry = dsa_ksz8794_get_mac_table_entry,
.switch_read = dsa_ksz8xxx_sw_read_reg,
.switch_write = dsa_ksz8xxx_sw_write_reg,
.switch_set_mac_table_entry = dsa_ksz8xxx_set_mac_table_entry,
.switch_get_mac_table_entry = dsa_ksz8xxx_get_mac_table_entry,
#if defined(DSA_KSZ_TAIL_TAGGING)
.dsa_xmit_pkt = dsa_ksz8794_xmit_pkt,
.dsa_get_iface = dsa_ksz8794_get_iface,
.dsa_xmit_pkt = dsa_ksz8xxx_xmit_pkt,
.dsa_get_iface = dsa_ksz8xxx_get_iface,
#endif
};