Lines Matching +full:dsa +full:- +full:slave +full:- +full:ports
4 * SPDX-License-Identifier: Apache-2.0
7 #define LOG_MODULE_NAME dsa
45 #define PRV_DATA(ctx) ((struct ksz8xxx_data *const)(ctx)->prv_data)
66 spi_write_dt(&pdev->spi, &tx); in dsa_ksz8xxx_write_reg()
98 if (!spi_transceive_dt(&pdev->spi, &tx, &rx)) { in dsa_ksz8xxx_read_reg()
139 * Wait for SPI of KSZ8794 being fully operational - up to 10 ms in dsa_ksz8xxx_probe()
142 tmp != KSZ8XXX_CHIP_ID0_ID_DEFAULT && timeout > 0; timeout--) { in dsa_ksz8xxx_probe()
149 return -ENODEV; in dsa_ksz8xxx_probe()
163 return -ENODEV; in dsa_ksz8xxx_probe()
176 * According to KSZ8794 manual - write to static mac address table in dsa_ksz8xxx_write_static_mac_table()
234 * According to KSZ8794 manual - read from static mac address table in dsa_ksz8xxx_read_static_mac_table()
269 * Loop through ports - The same setup when tail tagging is enabled or in dsa_ksz8xxx_switch_setup()
308 * Loop through ports - The same setup when tail tagging is enabled or in dsa_ksz8xxx_switch_setup()
353 * https://microchipsupport.force.com/s/article/Solution-for-Short-Cable-
354 * Problems-with-the-KSZ8795-Family
359 * 2) There may be a link-up issue in the capacitor AC coupling mode for port
368 * When using some type of short cable (for example, CAT-6 cable with low
369 * attenuation to high frequencies signal vs. CAT-5 cable) or board to board
371 * is amplified too much and cause the link-up failed with same boost setting in
384 * The indirect DSP register (0x3c) is an 8-bit register, the bits describe as
389 * 7-5 Reserved RO 000 000
394 * 3-1 Cpu_EQ_CP_Points Control of EQ training is
395 * over-boosted or
396 * [2:0] under-boosted, that means to
412 * Ethernet short cables like CAT-5, CAT-5e without any problem.
432 * Solution for Using CAT-5E or CAT-6 Short Cable with a Link Issue for the
436 * Solution for Using CAT-5E or CAT-6 Short Cable with a Link Issue for the
438 * https://microchipsupport.force.com/s/article/Solution-for-Using-CAT-5E-or
439 * -CAT-6-Short-Cable- with-a-Link-Issue-for-the-KSZ8795-Family
445 * short CAT-5E or CAT-6 cable (about <=30 meter). The failure rate may be about
446 * 2-5%.
450 * Basically, KSZ8795 10/100 Ethernet switch family was designed based on CAT-5
452 * cables of CAT-5E and CAT-6, both cables have wider bandwidth that has
453 * different frequency characteristics than CAT-5 cable. More higher frequency
454 * component of the CAT-5E or CAT-6 will be amplified in the receiving amplifier
456 * components receiving signal amplitude and cause the link-up failure with
463 * range when using CAT-5E and CAT-6 cable.
466 * Format is w [Register address] [8-bit data]
476 * solve the link issue if using CAT-5E and CAT-6 short cables.
478 * The indirect register (0x4C) is an 8-bit register. The bits [7:6] are
484 * 7-6 RX BW control Low pass filter bandwidth R/W 00 01
489 * 5 Enable Near-end loopback R/W 0 0
490 * 4-3 BTRT Additional reduce R/W 00 00
492 * 1-0 FXD reference setting 1.7V, 2V,
498 * For the wider bandwidth cables or on-board capacitor AC coupling
502 * short cable or on-board capacitors AC coupling application.
505 * Format is w [Register address] [8-bit data]
510 * or connect two ports directly through capacitors for a capacitor
513 * The indirect DSP register (0x08) is an 8-bit register. The bits [5:0] are
520 * 5-0 Cpu_EQ_Index Equalizer index control
524 * Due to CAT-5E and CAT-6 cable having wider bandwidth, more high frequency
528 * reduce the high frequency components to meet CAT-5E and CAT-6 short cable
529 * link issue and doesn’t affect CAT-5 cable because CAT-5 is not a wider
535 * using very short cable or an on-board direct connection like capacitors AC
553 LOG_INF("apply workarkound 0x02 link issue CAT-5E/6 on KSZ8794"); in dsa_ksz8794_phy_workaround_0x02()
566 LOG_INF("apply workarkound 0x04 link issue CAT-5E/6 on KSZ8794"); in dsa_ksz8794_phy_workaround_0x04()
622 ret = -1; in dsa_ksz8794_set_lowspeed_drivestrength()
629 /* set Low-Speed Interface Drive Strength for MII and RMMI */ in dsa_ksz8794_set_lowspeed_drivestrength()
650 return -ENODEV; in dsa_ksz8xxx_gpio_reset()
661 /* Low level initialization code for DSA PHY */
666 if (pdev->is_init) { in dsa_hw_init()
679 if (!spi_is_ready_dt(&pdev->spi)) { in dsa_hw_init()
681 pdev->spi.bus->name); in dsa_hw_init()
682 return -ENODEV; in dsa_hw_init()
709 pdev->is_init = true; in dsa_hw_init()
724 /* Skip Switch <-> CPU Port */ in dsa_delayed_work()
730 if (link_state && !context->link_up[i]) { in dsa_delayed_work()
731 LOG_INF("DSA port: %d link UP!", i); in dsa_delayed_work()
732 net_eth_carrier_on(context->iface_slave[i]); in dsa_delayed_work()
733 } else if (!link_state && context->link_up[i]) { in dsa_delayed_work()
734 LOG_INF("DSA port: %d link DOWN!", i); in dsa_delayed_work()
735 net_eth_carrier_off(context->iface_slave[i]); in dsa_delayed_work()
737 context->link_up[i] = link_state; in dsa_delayed_work()
740 k_work_reschedule(&context->dsa_work, DSA_STATUS_PERIOD_MS); in dsa_delayed_work()
745 struct dsa_context *data = dev->data; in dsa_port_init()
752 /* Generic implementation of writing value to DSA register */
756 struct dsa_context *data = dev->data; in dsa_ksz8xxx_sw_write_reg()
763 /* Generic implementation of reading value from DSA register */
767 struct dsa_context *data = dev->data; in dsa_ksz8xxx_sw_read_reg()
775 * @brief Set entry to DSA MAC address table
777 * @param dev DSA device
791 struct dsa_context *data = dev->data; in dsa_ksz8xxx_set_mac_table_entry()
795 return -EINVAL; in dsa_ksz8xxx_set_mac_table_entry()
805 * @brief Get DSA MAC address table entry
807 * @param dev DSA device
817 struct dsa_context *data = dev->data; in dsa_ksz8xxx_get_mac_table_entry()
844 lladst.len = sizeof(hdr->dst.addr); in dsa_ksz8xxx_xmit_pkt()
845 lladst.addr = &hdr->dst.addr[0]; in dsa_ksz8xxx_xmit_pkt()
852 if (len < (DSA_MIN_L2_FRAME_SIZE - DSA_L2_FCS_SIZE)) { in dsa_ksz8xxx_xmit_pkt()
854 pad = DSA_MIN_L2_FRAME_SIZE - DSA_L2_FCS_SIZE - len; in dsa_ksz8xxx_xmit_pkt()
857 buf = net_buf_alloc_len(net_buf_pool_get(pkt->buffer->pool_id), in dsa_ksz8xxx_xmit_pkt()
860 LOG_ERR("DSA cannot allocate new data buffer"); in dsa_ksz8xxx_xmit_pkt()
868 dbuf = net_buf_simple_tail(&(buf->b)); in dsa_ksz8xxx_xmit_pkt()
872 * For master port (eth0) set the bit 7 to use look-up table to pass in dsa_ksz8xxx_xmit_pkt()
875 * For slave ports (lan1..3) just set the tag properly: in dsa_ksz8xxx_xmit_pkt()
876 * bit 0 -> eth1, bit 1 -> eth2. bit 2 -> eth3 in dsa_ksz8xxx_xmit_pkt()
885 port_idx = (1 << (ctx->dsa_port_idx)); in dsa_ksz8xxx_xmit_pkt()
888 NET_DBG("TT - port: 0x%x[%p] LEN: %d 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", in dsa_ksz8xxx_xmit_pkt()
899 net_buf_frag_add(pkt->buffer, buf); in dsa_ksz8xxx_xmit_pkt()
905 * @brief DSA function to get proper interface
907 * This is the function for assigning proper slave interface after receiving
914 * - Pointer to struct net_if
933 net_pkt_skip(pkt, plen - DSA_KSZ8794_EGRESS_TAG_LEN); in dsa_ksz8xxx_get_iface()
936 net_pkt_update_length(pkt, plen - DSA_KSZ8794_EGRESS_TAG_LEN); in dsa_ksz8xxx_get_iface()
951 NET_DBG("TT - plen: %d pnum: %d pos: 0x%p dsa_port_idx: %d", in dsa_ksz8xxx_get_iface()
952 plen - DSA_KSZ8794_EGRESS_TAG_LEN, pnum, in dsa_ksz8xxx_get_iface()
953 net_pkt_cursor_get_pos(pkt), ctx->dsa_port_idx); in dsa_ksz8xxx_get_iface()
962 net_if_get_device(iface)->config; in dsa_iface_init()
965 struct dsa_context *context = dev->data; in dsa_iface_init()
968 int i = pdev->iface_init_count; in dsa_iface_init()
971 if (context->iface_master == NULL) { in dsa_iface_init()
973 context->iface_master = net_if_lookup_by_dev(dm); in dsa_iface_init()
974 if (context->iface_master == NULL) { in dsa_iface_init()
975 LOG_ERR("DSA: Master iface NOT found!"); in dsa_iface_init()
980 * Provide pointer to DSA context to master's eth interface in dsa_iface_init()
983 ctx_master = net_if_l2_data(context->iface_master); in dsa_iface_init()
984 ctx_master->dsa_ctx = context; in dsa_iface_init()
987 if (context->iface_slave[i] == NULL) { in dsa_iface_init()
988 context->iface_slave[i] = iface; in dsa_iface_init()
989 net_if_set_link_addr(iface, cfg->mac_addr, in dsa_iface_init()
990 sizeof(cfg->mac_addr), in dsa_iface_init()
992 ctx->dsa_port_idx = i; in dsa_iface_init()
993 ctx->dsa_ctx = context; in dsa_iface_init()
1002 pdev->iface_init_count++; in dsa_iface_init()
1006 * Start DSA work to monitor status of ports (read from switch IC) in dsa_iface_init()
1007 * only when carrier_work is properly initialized for all slave in dsa_iface_init()
1010 if (pdev->iface_init_count == context->num_slave_ports) { in dsa_iface_init()
1011 k_work_init_delayable(&context->dsa_work, dsa_delayed_work); in dsa_iface_init()
1012 k_work_reschedule(&context->dsa_work, DSA_STATUS_PERIOD_MS); in dsa_iface_init()
1044 * To make the code simpler - the special care needs to be put on
1045 * the proper placement of eth0, lan1, lan2, lan3, etc - to avoid
1050 * available for use - let's use it.
1054 * objdump -dst ./zephyr/CMakeFiles/zephyr.dir/drivers/ethernet/eth_mcux.c.obj\
1065 #define NET_SLAVE_DEVICE_INIT_INSTANCE(slave, n) \ argument
1066 const struct dsa_slave_config dsa_0_slave_##slave##_config = { \
1067 .mac_addr = DT_PROP_OR(slave, local_mac_address, {0}) \
1069 NET_DEVICE_INIT_INSTANCE(CONCAT(dsa_slave_port_, slave), \
1075 &dsa_0_slave_##slave##_config, \
1082 #define NET_SLAVE_DEVICE_0_INIT_INSTANCE(slave) \ argument
1083 NET_SLAVE_DEVICE_INIT_INSTANCE(slave, 0)
1084 #define NET_SLAVE_DEVICE_1_INIT_INSTANCE(slave) \ argument
1085 NET_SLAVE_DEVICE_INIT_INSTANCE(slave, 1)
1086 #define NET_SLAVE_DEVICE_2_INIT_INSTANCE(slave) \ argument
1087 NET_SLAVE_DEVICE_INIT_INSTANCE(slave, 2)
1088 #define NET_SLAVE_DEVICE_3_INIT_INSTANCE(slave) \ argument
1089 NET_SLAVE_DEVICE_INIT_INSTANCE(slave, 3)
1090 #define NET_SLAVE_DEVICE_4_INIT_INSTANCE(slave) \ argument
1091 NET_SLAVE_DEVICE_INIT_INSTANCE(slave, 4)