ksz8463_driver.h File Reference

KSZ8463 Ethernet switch. More...

#include "core/nic.h"

Go to the source code of this file.

Macros

#define KSZ8463_PORT1   1
 
#define KSZ8463_PORT2   2
 
#define KSZ8463_SPI_CMD_READ   0x0000
 
#define KSZ8463_SPI_CMD_WRITE   0x8000
 
#define KSZ8463_SPI_CMD_ADDR   0x7FC0
 
#define KSZ8463_SPI_CMD_B3   0x0020
 
#define KSZ8463_SPI_CMD_B2   0x0010
 
#define KSZ8463_SPI_CMD_B1   0x0008
 
#define KSZ8463_SPI_CMD_B0   0x0004
 
#define KSZ8463_PHY_REG_BMCR   0x00
 
#define KSZ8463_PHY_REG_BMSR   0x01
 
#define KSZ8463_PHY_REG_PHYIDR1   0x02
 
#define KSZ8463_PHY_REG_PHYIDR2   0x03
 
#define KSZ8463_PHY_REG_ANAR   0x04
 
#define KSZ8463_PHY_REG_ANLPAR   0x05
 
#define KSZ8463_PHY_REG_LINKMDCS   0x1D
 
#define KSZ8463_PHY_REG_PHYSCS   0x1F
 
#define BMCR_LOOPBACK   (1 << 14)
 
#define BMCR_FORCE_100   (1 << 13)
 
#define BMCR_AN_EN   (1 << 12)
 
#define BMCR_POWER_DOWN   (1 << 11)
 
#define BMCR_ISOLATE   (1 << 10)
 
#define BMCR_RESTART_AN   (1 << 9)
 
#define BMCR_FORCE_FULL_DUPLEX   (1 << 8)
 
#define BMCR_COL_TEST   (1 << 7)
 
#define BMCR_HP_MDIX   (1 << 5)
 
#define BMCR_FORCE_MDI   (1 << 4)
 
#define BMCR_DIS_AUTO_MDIX   (1 << 3)
 
#define BMCR_DIS_FAR_END_FAULT   (1 << 2)
 
#define BMCR_DIS_TRANSMIT   (1 << 1)
 
#define BMCR_DIS_LED   (1 << 0)
 
#define BMSR_100BT4   (1 << 15)
 
#define BMSR_100BTX_FD   (1 << 14)
 
#define BMSR_100BTX   (1 << 13)
 
#define BMSR_10BT_FD   (1 << 12)
 
#define BMSR_10BT   (1 << 11)
 
#define BMSR_NO_PREAMBLE   (1 << 6)
 
#define BMSR_AN_COMPLETE   (1 << 5)
 
#define BMSR_FAR_END_FAULT   (1 << 4)
 
#define BMSR_AN_ABLE   (1 << 3)
 
#define BMSR_LINK_STATUS   (1 << 2)
 
#define BMSR_JABBER_TEST   (1 << 1)
 
#define BMSR_EXTENDED_CAP   (1 << 0)
 
#define ANAR_NEXT_PAGE   (1 << 15)
 
#define ANAR_REMOTE_FAULT   (1 << 13)
 
#define ANAR_PAUSE   (1 << 10)
 
#define ANAR_100BTX_FD   (1 << 8)
 
#define ANAR_100BTX   (1 << 7)
 
#define ANAR_10BT_FD   (1 << 6)
 
#define ANAR_10BT   (1 << 5)
 
#define ANAR_SELECTOR4   (1 << 4)
 
#define ANAR_SELECTOR3   (1 << 3)
 
#define ANAR_SELECTOR2   (1 << 2)
 
#define ANAR_SELECTOR1   (1 << 1)
 
#define ANAR_SELECTOR0   (1 << 0)
 
#define ANLPAR_NEXT_PAGE   (1 << 15)
 
#define ANLPAR_LP_ACK   (1 << 14)
 
#define ANLPAR_REMOTE_FAULT   (1 << 13)
 
#define ANLPAR_PAUSE   (1 << 10)
 
#define ANLPAR_100BTX_FD   (1 << 8)
 
#define ANLPAR_100BTX   (1 << 7)
 
#define ANLPAR_10BT_FD   (1 << 6)
 
#define ANLPAR_10BT   (1 << 5)
 
#define LINKMDCS_CDT_EN   (1 << 15)
 
#define LINKMDCS_CDT_RESULT1   (1 << 14)
 
#define LINKMDCS_CDT_RESULT0   (1 << 13)
 
#define LINKMDCS_CDT_10M_SHORT   (1 << 12)
 
#define LINKMDCS_CDT_FAULT_COUNT8   (1 << 8)
 
#define LINKMDCS_CDT_FAULT_COUNT7   (1 << 7)
 
#define LINKMDCS_CDT_FAULT_COUNT6   (1 << 6)
 
#define LINKMDCS_CDT_FAULT_COUNT5   (1 << 5)
 
#define LINKMDCS_CDT_FAULT_COUNT4   (1 << 4)
 
#define LINKMDCS_CDT_FAULT_COUNT3   (1 << 3)
 
#define LINKMDCS_CDT_FAULT_COUNT2   (1 << 2)
 
#define LINKMDCS_CDT_FAULT_COUNT1   (1 << 1)
 
#define LINKMDCS_CDT_FAULT_COUNT0   (1 << 0)
 
#define PHYSCS_POL_REVERSE   (1 << 5)
 
#define PHYSCS_MDIX_STATUS   (1 << 4)
 
#define PHYSCS_FORCE_LINK   (1 << 3)
 
#define PHYSCS_EEE_EN   (1 << 2)
 
#define PHYSCS_REMOTE_LOOPBACK   (1 << 1)
 
#define KSZ8463_SW_REG_PORT_CTRL2(n)   (0x006E + (((n) - 1) * 0x18))
 
#define KSZ8463_SW_REG_PORT_STAT(n)   (0x0080 + (((n) - 1) * 0x18))
 
#define KSZ8463_SW_REG_GLOBAL_CTRL8   0x00AC
 
#define PORT_CTRL2_INGRESS_VLAN_FILT   (1 << 14)
 
#define PORT_CTRL2_DISCARD_NON_PVID_PACKETS   (1 << 13)
 
#define PORT_CTRL2_FORCE_FLOW_CTRL   (1 << 12)
 
#define PORT_CTRL2_BACK_PRESSURE_EN   (1 << 11)
 
#define PORT_CTRL2_TRANSMIT_EN   (1 << 10)
 
#define PORT_CTRL2_RECEIVE_EN   (1 << 9)
 
#define PORT_CTRL2_LEARNING_DIS   (1 << 8)
 
#define PORT_CTRL2_SNIFFER_PORT   (1 << 7)
 
#define PORT_CTRL2_RECEIVE_SNIFF   (1 << 6)
 
#define PORT_CTRL2_TRANSMIT_SNIFF   (1 << 5)
 
#define PORT_CTRL2_USER_PRIO_CEILING   (1 << 3)
 
#define PORT_CTRL2_PORT_VLAN_MEMBERSHIP2   (1 << 2)
 
#define PORT_CTRL2_PORT_VLAN_MEMBERSHIP1   (1 << 1)
 
#define PORT_CTRL2_PORT_VLAN_MEMBERSHIP0   (1 << 0)
 
#define PORT_STAT_HP_MDIX   (1 << 15)
 
#define PORT_STAT_POL_REVERSE   (1 << 13)
 
#define PORT_STAT_TX_FLOW_CTRL_EN   (1 << 12)
 
#define PORT_STAT_RX_FLOW_CTRL_EN   (1 << 11)
 
#define PORT_STAT_OP_SPEED   (1 << 10)
 
#define PORT_STAT_OP_MODE   (1 << 9)
 
#define PORT_STAT_FAR_END_FAULT   (1 << 8)
 
#define PORT_STAT_MDIX_STATUS   (1 << 7)
 
#define PORT_STAT_AN_DONE   (1 << 6)
 
#define PORT_STAT_LINK_STATUS   (1 << 5)
 
#define PORT_STAT_LP_FLOW_CTRL_CAPABLE   (1 << 4)
 
#define PORT_STAT_100BTX_FD_CAPABLE   (1 << 3)
 
#define PORT_STAT_100BTX_HF_CAPABLE   (1 << 2)
 
#define PORT_STAT_10BT_FD_CAPABLE   (1 << 1)
 
#define PORT_STAT_10BT_HD_CAPABLE   (1 << 0)
 
#define GLOBAL_CTRL8_QUEUE_PRIO_MAPPING1   (1 << 15)
 
#define GLOBAL_CTRL8_QUEUE_PRIO_MAPPING0   (1 << 14)
 
#define GLOBAL_CTRL8_FLUSH_DYNAMIC_MAC_TABLE   (1 << 10)
 
#define GLOBAL_CTRL8_FLUSH_STATIC_MAC_TABLE   (1 << 9)
 
#define GLOBAL_CTRL8_TAIL_TAG_EN   (1 << 8)
 
#define GLOBAL_CTRL8_PAUSE_OFF_TIME7   (1 << 7)
 
#define GLOBAL_CTRL8_PAUSE_OFF_TIME6   (1 << 6)
 
#define GLOBAL_CTRL8_PAUSE_OFF_TIME5   (1 << 5)
 
#define GLOBAL_CTRL8_PAUSE_OFF_TIME4   (1 << 4)
 
#define GLOBAL_CTRL8_PAUSE_OFF_TIME3   (1 << 3)
 
#define GLOBAL_CTRL8_PAUSE_OFF_TIME2   (1 << 2)
 
#define GLOBAL_CTRL8_PAUSE_OFF_TIME1   (1 << 1)
 
#define GLOBAL_CTRL8_PAUSE_OFF_TIME0   (1 << 0)
 
#define KSZ8463_TAIL_TAG_ENCODE(port)   ((port) & 0x03)
 
#define KSZ8463_TAIL_TAG_DECODE(tag)   (((tag) & 0x01) + 1)
 

Functions

error_t ksz8463Init (NetInterface *interface)
 KSZ8463 Ethernet switch initialization. More...
 
bool_t ksz8463GetLinkState (NetInterface *interface, uint8_t port)
 Get link state. More...
 
void ksz8463Tick (NetInterface *interface)
 KSZ8463 timer handler. More...
 
void ksz8463EnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void ksz8463DisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void ksz8463EventHandler (NetInterface *interface)
 KSZ8463 event handler. More...
 
error_t ksz8463TagFrame (NetInterface *interface, NetBuffer *buffer, size_t *offset, uint8_t port, uint16_t *type)
 Add tail tag to Ethernet frame. More...
 
error_t ksz8463UntagFrame (NetInterface *interface, uint8_t **frame, size_t *length, uint8_t *port)
 Decode tail tag from incoming Ethernet frame. More...
 
void ksz8463WritePhyReg (NetInterface *interface, uint8_t port, uint8_t address, uint16_t data)
 Write PHY register. More...
 
uint16_t ksz8463ReadPhyReg (NetInterface *interface, uint8_t port, uint8_t address)
 Read PHY register. More...
 
void ksz8463DumpPhyReg (NetInterface *interface, uint8_t port)
 Dump PHY registers for debugging purpose. More...
 
void ksz8463WriteSwitchReg (NetInterface *interface, uint16_t address, uint16_t data)
 Write switch register. More...
 
uint16_t ksz8463ReadSwitchReg (NetInterface *interface, uint16_t address)
 Read switch register. More...
 
void ksz8463DumpSwitchReg (NetInterface *interface)
 Dump switch registers for debugging purpose. More...
 

Variables

const PhyDriver ksz8463PhyDriver
 KSZ8463 Ethernet switch driver. More...
 

Detailed Description

KSZ8463 Ethernet switch.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.2

Definition in file ksz8463_driver.h.

Macro Definition Documentation

◆ ANAR_100BTX

#define ANAR_100BTX   (1 << 7)

Definition at line 95 of file ksz8463_driver.h.

◆ ANAR_100BTX_FD

#define ANAR_100BTX_FD   (1 << 8)

Definition at line 94 of file ksz8463_driver.h.

◆ ANAR_10BT

#define ANAR_10BT   (1 << 5)

Definition at line 97 of file ksz8463_driver.h.

◆ ANAR_10BT_FD

#define ANAR_10BT_FD   (1 << 6)

Definition at line 96 of file ksz8463_driver.h.

◆ ANAR_NEXT_PAGE

#define ANAR_NEXT_PAGE   (1 << 15)

Definition at line 91 of file ksz8463_driver.h.

◆ ANAR_PAUSE

#define ANAR_PAUSE   (1 << 10)

Definition at line 93 of file ksz8463_driver.h.

◆ ANAR_REMOTE_FAULT

#define ANAR_REMOTE_FAULT   (1 << 13)

Definition at line 92 of file ksz8463_driver.h.

◆ ANAR_SELECTOR0

#define ANAR_SELECTOR0   (1 << 0)

Definition at line 102 of file ksz8463_driver.h.

◆ ANAR_SELECTOR1

#define ANAR_SELECTOR1   (1 << 1)

Definition at line 101 of file ksz8463_driver.h.

◆ ANAR_SELECTOR2

#define ANAR_SELECTOR2   (1 << 2)

Definition at line 100 of file ksz8463_driver.h.

◆ ANAR_SELECTOR3

#define ANAR_SELECTOR3   (1 << 3)

Definition at line 99 of file ksz8463_driver.h.

◆ ANAR_SELECTOR4

#define ANAR_SELECTOR4   (1 << 4)

Definition at line 98 of file ksz8463_driver.h.

◆ ANLPAR_100BTX

#define ANLPAR_100BTX   (1 << 7)

Definition at line 110 of file ksz8463_driver.h.

◆ ANLPAR_100BTX_FD

#define ANLPAR_100BTX_FD   (1 << 8)

Definition at line 109 of file ksz8463_driver.h.

◆ ANLPAR_10BT

#define ANLPAR_10BT   (1 << 5)

Definition at line 112 of file ksz8463_driver.h.

◆ ANLPAR_10BT_FD

#define ANLPAR_10BT_FD   (1 << 6)

Definition at line 111 of file ksz8463_driver.h.

◆ ANLPAR_LP_ACK

#define ANLPAR_LP_ACK   (1 << 14)

Definition at line 106 of file ksz8463_driver.h.

◆ ANLPAR_NEXT_PAGE

#define ANLPAR_NEXT_PAGE   (1 << 15)

Definition at line 105 of file ksz8463_driver.h.

◆ ANLPAR_PAUSE

#define ANLPAR_PAUSE   (1 << 10)

Definition at line 108 of file ksz8463_driver.h.

◆ ANLPAR_REMOTE_FAULT

#define ANLPAR_REMOTE_FAULT   (1 << 13)

Definition at line 107 of file ksz8463_driver.h.

◆ BMCR_AN_EN

#define BMCR_AN_EN   (1 << 12)

Definition at line 63 of file ksz8463_driver.h.

◆ BMCR_COL_TEST

#define BMCR_COL_TEST   (1 << 7)

Definition at line 68 of file ksz8463_driver.h.

◆ BMCR_DIS_AUTO_MDIX

#define BMCR_DIS_AUTO_MDIX   (1 << 3)

Definition at line 71 of file ksz8463_driver.h.

◆ BMCR_DIS_FAR_END_FAULT

#define BMCR_DIS_FAR_END_FAULT   (1 << 2)

Definition at line 72 of file ksz8463_driver.h.

◆ BMCR_DIS_LED

#define BMCR_DIS_LED   (1 << 0)

Definition at line 74 of file ksz8463_driver.h.

◆ BMCR_DIS_TRANSMIT

#define BMCR_DIS_TRANSMIT   (1 << 1)

Definition at line 73 of file ksz8463_driver.h.

◆ BMCR_FORCE_100

#define BMCR_FORCE_100   (1 << 13)

Definition at line 62 of file ksz8463_driver.h.

◆ BMCR_FORCE_FULL_DUPLEX

#define BMCR_FORCE_FULL_DUPLEX   (1 << 8)

Definition at line 67 of file ksz8463_driver.h.

◆ BMCR_FORCE_MDI

#define BMCR_FORCE_MDI   (1 << 4)

Definition at line 70 of file ksz8463_driver.h.

◆ BMCR_HP_MDIX

#define BMCR_HP_MDIX   (1 << 5)

Definition at line 69 of file ksz8463_driver.h.

◆ BMCR_ISOLATE

#define BMCR_ISOLATE   (1 << 10)

Definition at line 65 of file ksz8463_driver.h.

◆ BMCR_LOOPBACK

#define BMCR_LOOPBACK   (1 << 14)

Definition at line 61 of file ksz8463_driver.h.

◆ BMCR_POWER_DOWN

#define BMCR_POWER_DOWN   (1 << 11)

Definition at line 64 of file ksz8463_driver.h.

◆ BMCR_RESTART_AN

#define BMCR_RESTART_AN   (1 << 9)

Definition at line 66 of file ksz8463_driver.h.

◆ BMSR_100BT4

#define BMSR_100BT4   (1 << 15)

Definition at line 77 of file ksz8463_driver.h.

◆ BMSR_100BTX

#define BMSR_100BTX   (1 << 13)

Definition at line 79 of file ksz8463_driver.h.

◆ BMSR_100BTX_FD

#define BMSR_100BTX_FD   (1 << 14)

Definition at line 78 of file ksz8463_driver.h.

◆ BMSR_10BT

#define BMSR_10BT   (1 << 11)

Definition at line 81 of file ksz8463_driver.h.

◆ BMSR_10BT_FD

#define BMSR_10BT_FD   (1 << 12)

Definition at line 80 of file ksz8463_driver.h.

◆ BMSR_AN_ABLE

#define BMSR_AN_ABLE   (1 << 3)

Definition at line 85 of file ksz8463_driver.h.

◆ BMSR_AN_COMPLETE

#define BMSR_AN_COMPLETE   (1 << 5)

Definition at line 83 of file ksz8463_driver.h.

◆ BMSR_EXTENDED_CAP

#define BMSR_EXTENDED_CAP   (1 << 0)

Definition at line 88 of file ksz8463_driver.h.

◆ BMSR_FAR_END_FAULT

#define BMSR_FAR_END_FAULT   (1 << 4)

Definition at line 84 of file ksz8463_driver.h.

◆ BMSR_JABBER_TEST

#define BMSR_JABBER_TEST   (1 << 1)

Definition at line 87 of file ksz8463_driver.h.

◆ BMSR_LINK_STATUS

#define BMSR_LINK_STATUS   (1 << 2)

Definition at line 86 of file ksz8463_driver.h.

◆ BMSR_NO_PREAMBLE

#define BMSR_NO_PREAMBLE   (1 << 6)

Definition at line 82 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_FLUSH_DYNAMIC_MAC_TABLE

#define GLOBAL_CTRL8_FLUSH_DYNAMIC_MAC_TABLE   (1 << 10)

Definition at line 177 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_FLUSH_STATIC_MAC_TABLE

#define GLOBAL_CTRL8_FLUSH_STATIC_MAC_TABLE   (1 << 9)

Definition at line 178 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_PAUSE_OFF_TIME0

#define GLOBAL_CTRL8_PAUSE_OFF_TIME0   (1 << 0)

Definition at line 187 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_PAUSE_OFF_TIME1

#define GLOBAL_CTRL8_PAUSE_OFF_TIME1   (1 << 1)

Definition at line 186 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_PAUSE_OFF_TIME2

#define GLOBAL_CTRL8_PAUSE_OFF_TIME2   (1 << 2)

Definition at line 185 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_PAUSE_OFF_TIME3

#define GLOBAL_CTRL8_PAUSE_OFF_TIME3   (1 << 3)

Definition at line 184 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_PAUSE_OFF_TIME4

#define GLOBAL_CTRL8_PAUSE_OFF_TIME4   (1 << 4)

Definition at line 183 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_PAUSE_OFF_TIME5

#define GLOBAL_CTRL8_PAUSE_OFF_TIME5   (1 << 5)

Definition at line 182 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_PAUSE_OFF_TIME6

#define GLOBAL_CTRL8_PAUSE_OFF_TIME6   (1 << 6)

Definition at line 181 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_PAUSE_OFF_TIME7

#define GLOBAL_CTRL8_PAUSE_OFF_TIME7   (1 << 7)

Definition at line 180 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_QUEUE_PRIO_MAPPING0

#define GLOBAL_CTRL8_QUEUE_PRIO_MAPPING0   (1 << 14)

Definition at line 176 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_QUEUE_PRIO_MAPPING1

#define GLOBAL_CTRL8_QUEUE_PRIO_MAPPING1   (1 << 15)

Definition at line 175 of file ksz8463_driver.h.

◆ GLOBAL_CTRL8_TAIL_TAG_EN

#define GLOBAL_CTRL8_TAIL_TAG_EN   (1 << 8)

Definition at line 179 of file ksz8463_driver.h.

◆ KSZ8463_PHY_REG_ANAR

#define KSZ8463_PHY_REG_ANAR   0x04

Definition at line 55 of file ksz8463_driver.h.

◆ KSZ8463_PHY_REG_ANLPAR

#define KSZ8463_PHY_REG_ANLPAR   0x05

Definition at line 56 of file ksz8463_driver.h.

◆ KSZ8463_PHY_REG_BMCR

#define KSZ8463_PHY_REG_BMCR   0x00

Definition at line 51 of file ksz8463_driver.h.

◆ KSZ8463_PHY_REG_BMSR

#define KSZ8463_PHY_REG_BMSR   0x01

Definition at line 52 of file ksz8463_driver.h.

◆ KSZ8463_PHY_REG_LINKMDCS

#define KSZ8463_PHY_REG_LINKMDCS   0x1D

Definition at line 57 of file ksz8463_driver.h.

◆ KSZ8463_PHY_REG_PHYIDR1

#define KSZ8463_PHY_REG_PHYIDR1   0x02

Definition at line 53 of file ksz8463_driver.h.

◆ KSZ8463_PHY_REG_PHYIDR2

#define KSZ8463_PHY_REG_PHYIDR2   0x03

Definition at line 54 of file ksz8463_driver.h.

◆ KSZ8463_PHY_REG_PHYSCS

#define KSZ8463_PHY_REG_PHYSCS   0x1F

Definition at line 58 of file ksz8463_driver.h.

◆ KSZ8463_PORT1

#define KSZ8463_PORT1   1

Definition at line 38 of file ksz8463_driver.h.

◆ KSZ8463_PORT2

#define KSZ8463_PORT2   2

Definition at line 39 of file ksz8463_driver.h.

◆ KSZ8463_SPI_CMD_ADDR

#define KSZ8463_SPI_CMD_ADDR   0x7FC0

Definition at line 44 of file ksz8463_driver.h.

◆ KSZ8463_SPI_CMD_B0

#define KSZ8463_SPI_CMD_B0   0x0004

Definition at line 48 of file ksz8463_driver.h.

◆ KSZ8463_SPI_CMD_B1

#define KSZ8463_SPI_CMD_B1   0x0008

Definition at line 47 of file ksz8463_driver.h.

◆ KSZ8463_SPI_CMD_B2

#define KSZ8463_SPI_CMD_B2   0x0010

Definition at line 46 of file ksz8463_driver.h.

◆ KSZ8463_SPI_CMD_B3

#define KSZ8463_SPI_CMD_B3   0x0020

Definition at line 45 of file ksz8463_driver.h.

◆ KSZ8463_SPI_CMD_READ

#define KSZ8463_SPI_CMD_READ   0x0000

Definition at line 42 of file ksz8463_driver.h.

◆ KSZ8463_SPI_CMD_WRITE

#define KSZ8463_SPI_CMD_WRITE   0x8000

Definition at line 43 of file ksz8463_driver.h.

◆ KSZ8463_SW_REG_GLOBAL_CTRL8

#define KSZ8463_SW_REG_GLOBAL_CTRL8   0x00AC

Definition at line 139 of file ksz8463_driver.h.

◆ KSZ8463_SW_REG_PORT_CTRL2

#define KSZ8463_SW_REG_PORT_CTRL2 (   n)    (0x006E + (((n) - 1) * 0x18))

Definition at line 137 of file ksz8463_driver.h.

◆ KSZ8463_SW_REG_PORT_STAT

#define KSZ8463_SW_REG_PORT_STAT (   n)    (0x0080 + (((n) - 1) * 0x18))

Definition at line 138 of file ksz8463_driver.h.

◆ KSZ8463_TAIL_TAG_DECODE

#define KSZ8463_TAIL_TAG_DECODE (   tag)    (((tag) & 0x01) + 1)

Definition at line 192 of file ksz8463_driver.h.

◆ KSZ8463_TAIL_TAG_ENCODE

#define KSZ8463_TAIL_TAG_ENCODE (   port)    ((port) & 0x03)

Definition at line 190 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_10M_SHORT

#define LINKMDCS_CDT_10M_SHORT   (1 << 12)

Definition at line 118 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_EN

#define LINKMDCS_CDT_EN   (1 << 15)

Definition at line 115 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_FAULT_COUNT0

#define LINKMDCS_CDT_FAULT_COUNT0   (1 << 0)

Definition at line 127 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_FAULT_COUNT1

#define LINKMDCS_CDT_FAULT_COUNT1   (1 << 1)

Definition at line 126 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_FAULT_COUNT2

#define LINKMDCS_CDT_FAULT_COUNT2   (1 << 2)

Definition at line 125 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_FAULT_COUNT3

#define LINKMDCS_CDT_FAULT_COUNT3   (1 << 3)

Definition at line 124 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_FAULT_COUNT4

#define LINKMDCS_CDT_FAULT_COUNT4   (1 << 4)

Definition at line 123 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_FAULT_COUNT5

#define LINKMDCS_CDT_FAULT_COUNT5   (1 << 5)

Definition at line 122 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_FAULT_COUNT6

#define LINKMDCS_CDT_FAULT_COUNT6   (1 << 6)

Definition at line 121 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_FAULT_COUNT7

#define LINKMDCS_CDT_FAULT_COUNT7   (1 << 7)

Definition at line 120 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_FAULT_COUNT8

#define LINKMDCS_CDT_FAULT_COUNT8   (1 << 8)

Definition at line 119 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_RESULT0

#define LINKMDCS_CDT_RESULT0   (1 << 13)

Definition at line 117 of file ksz8463_driver.h.

◆ LINKMDCS_CDT_RESULT1

#define LINKMDCS_CDT_RESULT1   (1 << 14)

Definition at line 116 of file ksz8463_driver.h.

◆ PHYSCS_EEE_EN

#define PHYSCS_EEE_EN   (1 << 2)

Definition at line 133 of file ksz8463_driver.h.

◆ PHYSCS_FORCE_LINK

#define PHYSCS_FORCE_LINK   (1 << 3)

Definition at line 132 of file ksz8463_driver.h.

◆ PHYSCS_MDIX_STATUS

#define PHYSCS_MDIX_STATUS   (1 << 4)

Definition at line 131 of file ksz8463_driver.h.

◆ PHYSCS_POL_REVERSE

#define PHYSCS_POL_REVERSE   (1 << 5)

Definition at line 130 of file ksz8463_driver.h.

◆ PHYSCS_REMOTE_LOOPBACK

#define PHYSCS_REMOTE_LOOPBACK   (1 << 1)

Definition at line 134 of file ksz8463_driver.h.

◆ PORT_CTRL2_BACK_PRESSURE_EN

#define PORT_CTRL2_BACK_PRESSURE_EN   (1 << 11)

Definition at line 145 of file ksz8463_driver.h.

◆ PORT_CTRL2_DISCARD_NON_PVID_PACKETS

#define PORT_CTRL2_DISCARD_NON_PVID_PACKETS   (1 << 13)

Definition at line 143 of file ksz8463_driver.h.

◆ PORT_CTRL2_FORCE_FLOW_CTRL

#define PORT_CTRL2_FORCE_FLOW_CTRL   (1 << 12)

Definition at line 144 of file ksz8463_driver.h.

◆ PORT_CTRL2_INGRESS_VLAN_FILT

#define PORT_CTRL2_INGRESS_VLAN_FILT   (1 << 14)

Definition at line 142 of file ksz8463_driver.h.

◆ PORT_CTRL2_LEARNING_DIS

#define PORT_CTRL2_LEARNING_DIS   (1 << 8)

Definition at line 148 of file ksz8463_driver.h.

◆ PORT_CTRL2_PORT_VLAN_MEMBERSHIP0

#define PORT_CTRL2_PORT_VLAN_MEMBERSHIP0   (1 << 0)

Definition at line 155 of file ksz8463_driver.h.

◆ PORT_CTRL2_PORT_VLAN_MEMBERSHIP1

#define PORT_CTRL2_PORT_VLAN_MEMBERSHIP1   (1 << 1)

Definition at line 154 of file ksz8463_driver.h.

◆ PORT_CTRL2_PORT_VLAN_MEMBERSHIP2

#define PORT_CTRL2_PORT_VLAN_MEMBERSHIP2   (1 << 2)

Definition at line 153 of file ksz8463_driver.h.

◆ PORT_CTRL2_RECEIVE_EN

#define PORT_CTRL2_RECEIVE_EN   (1 << 9)

Definition at line 147 of file ksz8463_driver.h.

◆ PORT_CTRL2_RECEIVE_SNIFF

#define PORT_CTRL2_RECEIVE_SNIFF   (1 << 6)

Definition at line 150 of file ksz8463_driver.h.

◆ PORT_CTRL2_SNIFFER_PORT

#define PORT_CTRL2_SNIFFER_PORT   (1 << 7)

Definition at line 149 of file ksz8463_driver.h.

◆ PORT_CTRL2_TRANSMIT_EN

#define PORT_CTRL2_TRANSMIT_EN   (1 << 10)

Definition at line 146 of file ksz8463_driver.h.

◆ PORT_CTRL2_TRANSMIT_SNIFF

#define PORT_CTRL2_TRANSMIT_SNIFF   (1 << 5)

Definition at line 151 of file ksz8463_driver.h.

◆ PORT_CTRL2_USER_PRIO_CEILING

#define PORT_CTRL2_USER_PRIO_CEILING   (1 << 3)

Definition at line 152 of file ksz8463_driver.h.

◆ PORT_STAT_100BTX_FD_CAPABLE

#define PORT_STAT_100BTX_FD_CAPABLE   (1 << 3)

Definition at line 169 of file ksz8463_driver.h.

◆ PORT_STAT_100BTX_HF_CAPABLE

#define PORT_STAT_100BTX_HF_CAPABLE   (1 << 2)

Definition at line 170 of file ksz8463_driver.h.

◆ PORT_STAT_10BT_FD_CAPABLE

#define PORT_STAT_10BT_FD_CAPABLE   (1 << 1)

Definition at line 171 of file ksz8463_driver.h.

◆ PORT_STAT_10BT_HD_CAPABLE

#define PORT_STAT_10BT_HD_CAPABLE   (1 << 0)

Definition at line 172 of file ksz8463_driver.h.

◆ PORT_STAT_AN_DONE

#define PORT_STAT_AN_DONE   (1 << 6)

Definition at line 166 of file ksz8463_driver.h.

◆ PORT_STAT_FAR_END_FAULT

#define PORT_STAT_FAR_END_FAULT   (1 << 8)

Definition at line 164 of file ksz8463_driver.h.

◆ PORT_STAT_HP_MDIX

#define PORT_STAT_HP_MDIX   (1 << 15)

Definition at line 158 of file ksz8463_driver.h.

◆ PORT_STAT_LINK_STATUS

#define PORT_STAT_LINK_STATUS   (1 << 5)

Definition at line 167 of file ksz8463_driver.h.

◆ PORT_STAT_LP_FLOW_CTRL_CAPABLE

#define PORT_STAT_LP_FLOW_CTRL_CAPABLE   (1 << 4)

Definition at line 168 of file ksz8463_driver.h.

◆ PORT_STAT_MDIX_STATUS

#define PORT_STAT_MDIX_STATUS   (1 << 7)

Definition at line 165 of file ksz8463_driver.h.

◆ PORT_STAT_OP_MODE

#define PORT_STAT_OP_MODE   (1 << 9)

Definition at line 163 of file ksz8463_driver.h.

◆ PORT_STAT_OP_SPEED

#define PORT_STAT_OP_SPEED   (1 << 10)

Definition at line 162 of file ksz8463_driver.h.

◆ PORT_STAT_POL_REVERSE

#define PORT_STAT_POL_REVERSE   (1 << 13)

Definition at line 159 of file ksz8463_driver.h.

◆ PORT_STAT_RX_FLOW_CTRL_EN

#define PORT_STAT_RX_FLOW_CTRL_EN   (1 << 11)

Definition at line 161 of file ksz8463_driver.h.

◆ PORT_STAT_TX_FLOW_CTRL_EN

#define PORT_STAT_TX_FLOW_CTRL_EN   (1 << 12)

Definition at line 160 of file ksz8463_driver.h.

Function Documentation

◆ ksz8463DisableIrq()

void ksz8463DisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 318 of file ksz8463_driver.c.

◆ ksz8463DumpPhyReg()

void ksz8463DumpPhyReg ( NetInterface interface,
uint8_t  port 
)

Dump PHY registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number

Definition at line 599 of file ksz8463_driver.c.

◆ ksz8463DumpSwitchReg()

void ksz8463DumpSwitchReg ( NetInterface interface)

Dump switch registers for debugging purpose.

Parameters
[in]interfaceUnderlying network interface

Definition at line 725 of file ksz8463_driver.c.

◆ ksz8463EnableIrq()

void ksz8463EnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 308 of file ksz8463_driver.c.

◆ ksz8463EventHandler()

void ksz8463EventHandler ( NetInterface interface)

KSZ8463 event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 328 of file ksz8463_driver.c.

◆ ksz8463GetLinkState()

bool_t ksz8463GetLinkState ( NetInterface interface,
uint8_t  port 
)

Get link state.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
Returns
Link state

Definition at line 159 of file ksz8463_driver.c.

◆ ksz8463Init()

error_t ksz8463Init ( NetInterface interface)

KSZ8463 Ethernet switch initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 75 of file ksz8463_driver.c.

◆ ksz8463ReadPhyReg()

uint16_t ksz8463ReadPhyReg ( NetInterface interface,
uint8_t  port,
uint8_t  address 
)

Read PHY register.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
[in]addressPHY register address
Returns
Register value

Definition at line 585 of file ksz8463_driver.c.

◆ ksz8463ReadSwitchReg()

uint16_t ksz8463ReadSwitchReg ( NetInterface interface,
uint16_t  address 
)

Read switch register.

Parameters
[in]interfaceUnderlying network interface
[in]addressPHY register address
Returns
Register value

Definition at line 673 of file ksz8463_driver.c.

◆ ksz8463TagFrame()

error_t ksz8463TagFrame ( NetInterface interface,
NetBuffer buffer,
size_t *  offset,
uint8_t  port,
uint16_t *  type 
)

Add tail tag to Ethernet frame.

Parameters
[in]interfaceUnderlying network interface
[in]bufferMulti-part buffer containing the payload
[in,out]offsetOffset to the first payload byte
[in]portSwitch port identifier
[in,out]typeEthernet type
Returns
Error code

Definition at line 472 of file ksz8463_driver.c.

◆ ksz8463Tick()

void ksz8463Tick ( NetInterface interface)

KSZ8463 timer handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 208 of file ksz8463_driver.c.

◆ ksz8463UntagFrame()

error_t ksz8463UntagFrame ( NetInterface interface,
uint8_t **  frame,
size_t *  length,
uint8_t *  port 
)

Decode tail tag from incoming Ethernet frame.

Parameters
[in]interfaceUnderlying network interface
[in,out]framePointer to the received Ethernet frame
[in,out]lengthLength of the frame, in bytes
[out]portSwitch port identifier
Returns
Error code

Definition at line 524 of file ksz8463_driver.c.

◆ ksz8463WritePhyReg()

void ksz8463WritePhyReg ( NetInterface interface,
uint8_t  port,
uint8_t  address,
uint16_t  data 
)

Write PHY register.

Parameters
[in]interfaceUnderlying network interface
[in]portPort number
[in]addressPHY register address
[in]dataRegister value

Definition at line 569 of file ksz8463_driver.c.

◆ ksz8463WriteSwitchReg()

void ksz8463WriteSwitchReg ( NetInterface interface,
uint16_t  address,
uint16_t  data 
)

Write switch register.

Parameters
[in]interfaceUnderlying network interface
[in]addressPHY register address
[in]dataRegister value

Definition at line 623 of file ksz8463_driver.c.

Variable Documentation

◆ ksz8463PhyDriver

const PhyDriver ksz8463PhyDriver

KSZ8463 Ethernet switch driver.

Definition at line 45 of file ksz8463_driver.c.