ksz8895_driver.h File Reference

KSZ8895 Ethernet switch. More...

#include "core/nic.h"

Go to the source code of this file.

Macros

#define KSZ8895_PORT1   1
 
#define KSZ8895_PORT2   2
 
#define KSZ8895_PORT3   3
 
#define KSZ8895_PORT4   4
 
#define KSZ8895_PHY_REG_BMCR   0x00
 
#define KSZ8895_PHY_REG_BMSR   0x01
 
#define KSZ8895_PHY_REG_PHYIDR1   0x02
 
#define KSZ8895_PHY_REG_PHYIDR2   0x03
 
#define KSZ8895_PHY_REG_ANAR   0x04
 
#define KSZ8895_PHY_REG_ANLPAR   0x05
 
#define KSZ8895_PHY_REG_LINKMDCS   0x1D
 
#define KSZ8895_PHY_REG_PHYSCS   0x1F
 
#define BMCR_SOFT_RESET   (1 << 15)
 
#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_VCT_EN   (1 << 15)
 
#define LINKMDCS_VCT_RESULT1   (1 << 14)
 
#define LINKMDCS_VCT_RESULT0   (1 << 13)
 
#define LINKMDCS_VCT_10M_SHORT   (1 << 12)
 
#define LINKMDCS_VCT_FAULT_COUNT8   (1 << 8)
 
#define LINKMDCS_VCT_FAULT_COUNT7   (1 << 7)
 
#define LINKMDCS_VCT_FAULT_COUNT6   (1 << 6)
 
#define LINKMDCS_VCT_FAULT_COUNT5   (1 << 5)
 
#define LINKMDCS_VCT_FAULT_COUNT4   (1 << 4)
 
#define LINKMDCS_VCT_FAULT_COUNT3   (1 << 3)
 
#define LINKMDCS_VCT_FAULT_COUNT2   (1 << 2)
 
#define LINKMDCS_VCT_FAULT_COUNT1   (1 << 1)
 
#define LINKMDCS_VCT_FAULT_COUNT0   (1 << 0)
 
#define PHYSCS_OP_MODE2   (1 << 10)
 
#define PHYSCS_OP_MODE1   (1 << 9)
 
#define PHYSCS_OP_MODE0   (1 << 8)
 
#define PHYSCS_POLRVS   (1 << 5)
 
#define PHYSCS_MDIX_STATUS   (1 << 4)
 
#define PHYSCS_FORCE_LINK   (1 << 3)
 
#define PHYSCS_PWRSAVE   (1 << 2)
 
#define PHYSCS_REMOTE_LOOPBACK   (1 << 1)
 
#define PHYSCS_OP_MODE_MASK   (7 << 8)
 
#define PHYSCS_OP_MODE_AN   (0 << 8)
 
#define PHYSCS_OP_MODE_10BT   (1 << 8)
 
#define PHYSCS_OP_MODE_100BTX   (2 << 8)
 
#define PHYSCS_OP_MODE_10BT_FD   (5 << 8)
 
#define PHYSCS_OP_MODE_100BTX_FD   (6 << 8)
 

Functions

error_t ksz8895Init (NetInterface *interface)
 KSZ8895 Ethernet switch initialization. More...
 
bool_t ksz8895GetLinkState (NetInterface *interface, uint8_t port)
 Get link state. More...
 
void ksz8895Tick (NetInterface *interface)
 KSZ8895 timer handler. More...
 
void ksz8895EnableIrq (NetInterface *interface)
 Enable interrupts. More...
 
void ksz8895DisableIrq (NetInterface *interface)
 Disable interrupts. More...
 
void ksz8895EventHandler (NetInterface *interface)
 KSZ8895 event handler. More...
 
void ksz8895WritePhyReg (NetInterface *interface, uint8_t port, uint8_t address, uint16_t data)
 Write PHY register. More...
 
uint16_t ksz8895ReadPhyReg (NetInterface *interface, uint8_t port, uint8_t address)
 Read PHY register. More...
 
void ksz8895DumpPhyReg (NetInterface *interface, uint8_t port)
 Dump PHY registers for debugging purpose. More...
 

Variables

const PhyDriver ksz8895PhyDriver
 KSZ8895 Ethernet switch driver. More...
 

Detailed Description

KSZ8895 Ethernet switch.

License

Copyright (C) 2010-2018 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.0

Definition in file ksz8895_driver.h.

Macro Definition Documentation

◆ ANAR_100BTX

#define ANAR_100BTX   (1 << 7)

Definition at line 87 of file ksz8895_driver.h.

◆ ANAR_100BTX_FD

#define ANAR_100BTX_FD   (1 << 8)

Definition at line 86 of file ksz8895_driver.h.

◆ ANAR_10BT

#define ANAR_10BT   (1 << 5)

Definition at line 89 of file ksz8895_driver.h.

◆ ANAR_10BT_FD

#define ANAR_10BT_FD   (1 << 6)

Definition at line 88 of file ksz8895_driver.h.

◆ ANAR_NEXT_PAGE

#define ANAR_NEXT_PAGE   (1 << 15)

Definition at line 83 of file ksz8895_driver.h.

◆ ANAR_PAUSE

#define ANAR_PAUSE   (1 << 10)

Definition at line 85 of file ksz8895_driver.h.

◆ ANAR_REMOTE_FAULT

#define ANAR_REMOTE_FAULT   (1 << 13)

Definition at line 84 of file ksz8895_driver.h.

◆ ANAR_SELECTOR0

#define ANAR_SELECTOR0   (1 << 0)

Definition at line 94 of file ksz8895_driver.h.

◆ ANAR_SELECTOR1

#define ANAR_SELECTOR1   (1 << 1)

Definition at line 93 of file ksz8895_driver.h.

◆ ANAR_SELECTOR2

#define ANAR_SELECTOR2   (1 << 2)

Definition at line 92 of file ksz8895_driver.h.

◆ ANAR_SELECTOR3

#define ANAR_SELECTOR3   (1 << 3)

Definition at line 91 of file ksz8895_driver.h.

◆ ANAR_SELECTOR4

#define ANAR_SELECTOR4   (1 << 4)

Definition at line 90 of file ksz8895_driver.h.

◆ ANLPAR_100BTX

#define ANLPAR_100BTX   (1 << 7)

Definition at line 102 of file ksz8895_driver.h.

◆ ANLPAR_100BTX_FD

#define ANLPAR_100BTX_FD   (1 << 8)

Definition at line 101 of file ksz8895_driver.h.

◆ ANLPAR_10BT

#define ANLPAR_10BT   (1 << 5)

Definition at line 104 of file ksz8895_driver.h.

◆ ANLPAR_10BT_FD

#define ANLPAR_10BT_FD   (1 << 6)

Definition at line 103 of file ksz8895_driver.h.

◆ ANLPAR_LP_ACK

#define ANLPAR_LP_ACK   (1 << 14)

Definition at line 98 of file ksz8895_driver.h.

◆ ANLPAR_NEXT_PAGE

#define ANLPAR_NEXT_PAGE   (1 << 15)

Definition at line 97 of file ksz8895_driver.h.

◆ ANLPAR_PAUSE

#define ANLPAR_PAUSE   (1 << 10)

Definition at line 100 of file ksz8895_driver.h.

◆ ANLPAR_REMOTE_FAULT

#define ANLPAR_REMOTE_FAULT   (1 << 13)

Definition at line 99 of file ksz8895_driver.h.

◆ BMCR_AN_EN

#define BMCR_AN_EN   (1 << 12)

Definition at line 55 of file ksz8895_driver.h.

◆ BMCR_COL_TEST

#define BMCR_COL_TEST   (1 << 7)

Definition at line 60 of file ksz8895_driver.h.

◆ BMCR_DIS_AUTO_MDIX

#define BMCR_DIS_AUTO_MDIX   (1 << 3)

Definition at line 63 of file ksz8895_driver.h.

◆ BMCR_DIS_FAR_END_FAULT

#define BMCR_DIS_FAR_END_FAULT   (1 << 2)

Definition at line 64 of file ksz8895_driver.h.

◆ BMCR_DIS_LED

#define BMCR_DIS_LED   (1 << 0)

Definition at line 66 of file ksz8895_driver.h.

◆ BMCR_DIS_TRANSMIT

#define BMCR_DIS_TRANSMIT   (1 << 1)

Definition at line 65 of file ksz8895_driver.h.

◆ BMCR_FORCE_100

#define BMCR_FORCE_100   (1 << 13)

Definition at line 54 of file ksz8895_driver.h.

◆ BMCR_FORCE_FULL_DUPLEX

#define BMCR_FORCE_FULL_DUPLEX   (1 << 8)

Definition at line 59 of file ksz8895_driver.h.

◆ BMCR_FORCE_MDI

#define BMCR_FORCE_MDI   (1 << 4)

Definition at line 62 of file ksz8895_driver.h.

◆ BMCR_HP_MDIX

#define BMCR_HP_MDIX   (1 << 5)

Definition at line 61 of file ksz8895_driver.h.

◆ BMCR_ISOLATE

#define BMCR_ISOLATE   (1 << 10)

Definition at line 57 of file ksz8895_driver.h.

◆ BMCR_LOOPBACK

#define BMCR_LOOPBACK   (1 << 14)

Definition at line 53 of file ksz8895_driver.h.

◆ BMCR_POWER_DOWN

#define BMCR_POWER_DOWN   (1 << 11)

Definition at line 56 of file ksz8895_driver.h.

◆ BMCR_RESTART_AN

#define BMCR_RESTART_AN   (1 << 9)

Definition at line 58 of file ksz8895_driver.h.

◆ BMCR_SOFT_RESET

#define BMCR_SOFT_RESET   (1 << 15)

Definition at line 52 of file ksz8895_driver.h.

◆ BMSR_100BT4

#define BMSR_100BT4   (1 << 15)

Definition at line 69 of file ksz8895_driver.h.

◆ BMSR_100BTX

#define BMSR_100BTX   (1 << 13)

Definition at line 71 of file ksz8895_driver.h.

◆ BMSR_100BTX_FD

#define BMSR_100BTX_FD   (1 << 14)

Definition at line 70 of file ksz8895_driver.h.

◆ BMSR_10BT

#define BMSR_10BT   (1 << 11)

Definition at line 73 of file ksz8895_driver.h.

◆ BMSR_10BT_FD

#define BMSR_10BT_FD   (1 << 12)

Definition at line 72 of file ksz8895_driver.h.

◆ BMSR_AN_ABLE

#define BMSR_AN_ABLE   (1 << 3)

Definition at line 77 of file ksz8895_driver.h.

◆ BMSR_AN_COMPLETE

#define BMSR_AN_COMPLETE   (1 << 5)

Definition at line 75 of file ksz8895_driver.h.

◆ BMSR_EXTENDED_CAP

#define BMSR_EXTENDED_CAP   (1 << 0)

Definition at line 80 of file ksz8895_driver.h.

◆ BMSR_FAR_END_FAULT

#define BMSR_FAR_END_FAULT   (1 << 4)

Definition at line 76 of file ksz8895_driver.h.

◆ BMSR_JABBER_TEST

#define BMSR_JABBER_TEST   (1 << 1)

Definition at line 79 of file ksz8895_driver.h.

◆ BMSR_LINK_STATUS

#define BMSR_LINK_STATUS   (1 << 2)

Definition at line 78 of file ksz8895_driver.h.

◆ BMSR_NO_PREAMBLE

#define BMSR_NO_PREAMBLE   (1 << 6)

Definition at line 74 of file ksz8895_driver.h.

◆ KSZ8895_PHY_REG_ANAR

#define KSZ8895_PHY_REG_ANAR   0x04

Definition at line 46 of file ksz8895_driver.h.

◆ KSZ8895_PHY_REG_ANLPAR

#define KSZ8895_PHY_REG_ANLPAR   0x05

Definition at line 47 of file ksz8895_driver.h.

◆ KSZ8895_PHY_REG_BMCR

#define KSZ8895_PHY_REG_BMCR   0x00

Definition at line 42 of file ksz8895_driver.h.

◆ KSZ8895_PHY_REG_BMSR

#define KSZ8895_PHY_REG_BMSR   0x01

Definition at line 43 of file ksz8895_driver.h.

◆ KSZ8895_PHY_REG_LINKMDCS

#define KSZ8895_PHY_REG_LINKMDCS   0x1D

Definition at line 48 of file ksz8895_driver.h.

◆ KSZ8895_PHY_REG_PHYIDR1

#define KSZ8895_PHY_REG_PHYIDR1   0x02

Definition at line 44 of file ksz8895_driver.h.

◆ KSZ8895_PHY_REG_PHYIDR2

#define KSZ8895_PHY_REG_PHYIDR2   0x03

Definition at line 45 of file ksz8895_driver.h.

◆ KSZ8895_PHY_REG_PHYSCS

#define KSZ8895_PHY_REG_PHYSCS   0x1F

Definition at line 49 of file ksz8895_driver.h.

◆ KSZ8895_PORT1

#define KSZ8895_PORT1   1

Definition at line 36 of file ksz8895_driver.h.

◆ KSZ8895_PORT2

#define KSZ8895_PORT2   2

Definition at line 37 of file ksz8895_driver.h.

◆ KSZ8895_PORT3

#define KSZ8895_PORT3   3

Definition at line 38 of file ksz8895_driver.h.

◆ KSZ8895_PORT4

#define KSZ8895_PORT4   4

Definition at line 39 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_10M_SHORT

#define LINKMDCS_VCT_10M_SHORT   (1 << 12)

Definition at line 110 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_EN

#define LINKMDCS_VCT_EN   (1 << 15)

Definition at line 107 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_FAULT_COUNT0

#define LINKMDCS_VCT_FAULT_COUNT0   (1 << 0)

Definition at line 119 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_FAULT_COUNT1

#define LINKMDCS_VCT_FAULT_COUNT1   (1 << 1)

Definition at line 118 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_FAULT_COUNT2

#define LINKMDCS_VCT_FAULT_COUNT2   (1 << 2)

Definition at line 117 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_FAULT_COUNT3

#define LINKMDCS_VCT_FAULT_COUNT3   (1 << 3)

Definition at line 116 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_FAULT_COUNT4

#define LINKMDCS_VCT_FAULT_COUNT4   (1 << 4)

Definition at line 115 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_FAULT_COUNT5

#define LINKMDCS_VCT_FAULT_COUNT5   (1 << 5)

Definition at line 114 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_FAULT_COUNT6

#define LINKMDCS_VCT_FAULT_COUNT6   (1 << 6)

Definition at line 113 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_FAULT_COUNT7

#define LINKMDCS_VCT_FAULT_COUNT7   (1 << 7)

Definition at line 112 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_FAULT_COUNT8

#define LINKMDCS_VCT_FAULT_COUNT8   (1 << 8)

Definition at line 111 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_RESULT0

#define LINKMDCS_VCT_RESULT0   (1 << 13)

Definition at line 109 of file ksz8895_driver.h.

◆ LINKMDCS_VCT_RESULT1

#define LINKMDCS_VCT_RESULT1   (1 << 14)

Definition at line 108 of file ksz8895_driver.h.

◆ PHYSCS_FORCE_LINK

#define PHYSCS_FORCE_LINK   (1 << 3)

Definition at line 127 of file ksz8895_driver.h.

◆ PHYSCS_MDIX_STATUS

#define PHYSCS_MDIX_STATUS   (1 << 4)

Definition at line 126 of file ksz8895_driver.h.

◆ PHYSCS_OP_MODE0

#define PHYSCS_OP_MODE0   (1 << 8)

Definition at line 124 of file ksz8895_driver.h.

◆ PHYSCS_OP_MODE1

#define PHYSCS_OP_MODE1   (1 << 9)

Definition at line 123 of file ksz8895_driver.h.

◆ PHYSCS_OP_MODE2

#define PHYSCS_OP_MODE2   (1 << 10)

Definition at line 122 of file ksz8895_driver.h.

◆ PHYSCS_OP_MODE_100BTX

#define PHYSCS_OP_MODE_100BTX   (2 << 8)

Definition at line 135 of file ksz8895_driver.h.

◆ PHYSCS_OP_MODE_100BTX_FD

#define PHYSCS_OP_MODE_100BTX_FD   (6 << 8)

Definition at line 137 of file ksz8895_driver.h.

◆ PHYSCS_OP_MODE_10BT

#define PHYSCS_OP_MODE_10BT   (1 << 8)

Definition at line 134 of file ksz8895_driver.h.

◆ PHYSCS_OP_MODE_10BT_FD

#define PHYSCS_OP_MODE_10BT_FD   (5 << 8)

Definition at line 136 of file ksz8895_driver.h.

◆ PHYSCS_OP_MODE_AN

#define PHYSCS_OP_MODE_AN   (0 << 8)

Definition at line 133 of file ksz8895_driver.h.

◆ PHYSCS_OP_MODE_MASK

#define PHYSCS_OP_MODE_MASK   (7 << 8)

Definition at line 132 of file ksz8895_driver.h.

◆ PHYSCS_POLRVS

#define PHYSCS_POLRVS   (1 << 5)

Definition at line 125 of file ksz8895_driver.h.

◆ PHYSCS_PWRSAVE

#define PHYSCS_PWRSAVE   (1 << 2)

Definition at line 128 of file ksz8895_driver.h.

◆ PHYSCS_REMOTE_LOOPBACK

#define PHYSCS_REMOTE_LOOPBACK   (1 << 1)

Definition at line 129 of file ksz8895_driver.h.

Function Documentation

◆ ksz8895DisableIrq()

void ksz8895DisableIrq ( NetInterface interface)

Disable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 185 of file ksz8895_driver.c.

◆ ksz8895DumpPhyReg()

void ksz8895DumpPhyReg ( NetInterface interface,
uint8_t  port 
)

Dump PHY registers for debugging purpose.

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

Definition at line 278 of file ksz8895_driver.c.

◆ ksz8895EnableIrq()

void ksz8895EnableIrq ( NetInterface interface)

Enable interrupts.

Parameters
[in]interfaceUnderlying network interface

Definition at line 175 of file ksz8895_driver.c.

◆ ksz8895EventHandler()

void ksz8895EventHandler ( NetInterface interface)

KSZ8895 event handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 195 of file ksz8895_driver.c.

◆ ksz8895GetLinkState()

bool_t ksz8895GetLinkState ( NetInterface interface,
uint8_t  port 
)

Get link state.

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

Definition at line 91 of file ksz8895_driver.c.

◆ ksz8895Init()

error_t ksz8895Init ( NetInterface interface)

KSZ8895 Ethernet switch initialization.

Parameters
[in]interfaceUnderlying network interface
Returns
Error code

Definition at line 58 of file ksz8895_driver.c.

◆ ksz8895ReadPhyReg()

uint16_t ksz8895ReadPhyReg ( 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 264 of file ksz8895_driver.c.

◆ ksz8895Tick()

void ksz8895Tick ( NetInterface interface)

KSZ8895 timer handler.

Parameters
[in]interfaceUnderlying network interface

Definition at line 125 of file ksz8895_driver.c.

◆ ksz8895WritePhyReg()

void ksz8895WritePhyReg ( 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 248 of file ksz8895_driver.c.

Variable Documentation

◆ ksz8895PhyDriver

const PhyDriver ksz8895PhyDriver

KSZ8895 Ethernet switch driver.

Definition at line 42 of file ksz8895_driver.c.