Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ksz8873.h Source File

ksz8873.h

Go to the documentation of this file.
00001 /**
00002  * @file ksz8873.h
00003  * @brief KSZ8873 Ethernet switch
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneTCP Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _KSZ8873_H
00030 #define _KSZ8873_H
00031 
00032 //Dependencies
00033 #include "core/nic.h"
00034 
00035 //KSZ8873 ports
00036 #define KSZ8873_PORT1               1
00037 #define KSZ8873_PORT2               2
00038 
00039 //KSZ8873 registers
00040 #define KSZ8873_PHY_REG_BMCR        0x00
00041 #define KSZ8873_PHY_REG_BMSR        0x01
00042 #define KSZ8873_PHY_REG_PHYIDR1     0x02
00043 #define KSZ8873_PHY_REG_PHYIDR2     0x03
00044 #define KSZ8873_PHY_REG_ANAR        0x04
00045 #define KSZ8873_PHY_REG_ANLPAR      0x05
00046 #define KSZ8873_PHY_REG_LINKMDCS    0x1D
00047 #define KSZ8873_PHY_REG_PHYSCS      0x1F
00048 
00049 //BMCR register
00050 #define BMCR_SOFT_RESET             (1 << 15)
00051 #define BMCR_LOOPBACK               (1 << 14)
00052 #define BMCR_FORCE_100              (1 << 13)
00053 #define BMCR_AN_EN                  (1 << 12)
00054 #define BMCR_POWER_DOWN             (1 << 11)
00055 #define BMCR_ISOLATE                (1 << 10)
00056 #define BMCR_RESTART_AN             (1 << 9)
00057 #define BMCR_FORCE_FULL_DUPLEX      (1 << 8)
00058 #define BMCR_COL_TEST               (1 << 7)
00059 #define BMCR_HP_MDIX                (1 << 5)
00060 #define BMCR_FORCE_MDI              (1 << 4)
00061 #define BMCR_DIS_AUTO_MDIX          (1 << 3)
00062 #define BMCR_DIS_FAR_END_FAULT      (1 << 2)
00063 #define BMCR_DIS_TRANSMIT           (1 << 1)
00064 #define BMCR_DIS_LED                (1 << 0)
00065 
00066 //BMSR register
00067 #define BMSR_100BT4                 (1 << 15)
00068 #define BMSR_100BTX_FD              (1 << 14)
00069 #define BMSR_100BTX                 (1 << 13)
00070 #define BMSR_10BT_FD                (1 << 12)
00071 #define BMSR_10BT                   (1 << 11)
00072 #define BMSR_NO_PREAMBLE            (1 << 6)
00073 #define BMSR_AN_COMPLETE            (1 << 5)
00074 #define BMSR_FAR_END_FAULT          (1 << 4)
00075 #define BMSR_AN_ABLE                (1 << 3)
00076 #define BMSR_LINK_STATUS            (1 << 2)
00077 #define BMSR_JABBER_TEST            (1 << 1)
00078 #define BMSR_EXTENDED_CAP           (1 << 0)
00079 
00080 //ANAR register
00081 #define ANAR_NEXT_PAGE              (1 << 15)
00082 #define ANAR_REMOTE_FAULT           (1 << 13)
00083 #define ANAR_PAUSE                  (1 << 10)
00084 #define ANAR_100BTX_FD              (1 << 8)
00085 #define ANAR_100BTX                 (1 << 7)
00086 #define ANAR_10BT_FD                (1 << 6)
00087 #define ANAR_10BT                   (1 << 5)
00088 #define ANAR_SELECTOR4              (1 << 4)
00089 #define ANAR_SELECTOR3              (1 << 3)
00090 #define ANAR_SELECTOR2              (1 << 2)
00091 #define ANAR_SELECTOR1              (1 << 1)
00092 #define ANAR_SELECTOR0              (1 << 0)
00093 
00094 //ANLPAR register
00095 #define ANLPAR_NEXT_PAGE            (1 << 15)
00096 #define ANLPAR_LP_ACK               (1 << 14)
00097 #define ANLPAR_REMOTE_FAULT         (1 << 13)
00098 #define ANLPAR_PAUSE                (1 << 10)
00099 #define ANLPAR_100BTX_FD            (1 << 8)
00100 #define ANLPAR_100BTX               (1 << 7)
00101 #define ANLPAR_10BT_FD              (1 << 6)
00102 #define ANLPAR_10BT                 (1 << 5)
00103 
00104 //LINKMDCS register
00105 #define LINKMDCS_VCT_EN             (1 << 15)
00106 #define LINKMDCS_VCT_RESULT1        (1 << 14)
00107 #define LINKMDCS_VCT_RESULT0        (1 << 13)
00108 #define LINKMDCS_VCT_10M_SHORT      (1 << 12)
00109 #define LINKMDCS_VCT_FAULT_COUNT8   (1 << 8)
00110 #define LINKMDCS_VCT_FAULT_COUNT7   (1 << 7)
00111 #define LINKMDCS_VCT_FAULT_COUNT6   (1 << 6)
00112 #define LINKMDCS_VCT_FAULT_COUNT5   (1 << 5)
00113 #define LINKMDCS_VCT_FAULT_COUNT4   (1 << 4)
00114 #define LINKMDCS_VCT_FAULT_COUNT3   (1 << 3)
00115 #define LINKMDCS_VCT_FAULT_COUNT2   (1 << 2)
00116 #define LINKMDCS_VCT_FAULT_COUNT1   (1 << 1)
00117 #define LINKMDCS_VCT_FAULT_COUNT0   (1 << 0)
00118 
00119 //PHYSCS register
00120 #define PHYSCS_POLRVS               (1 << 5)
00121 #define PHYSCS_MDIX_STATUS          (1 << 4)
00122 #define PHYSCS_FORCE_LINK           (1 << 3)
00123 #define PHYSCS_PWRSAVE              (1 << 2)
00124 #define PHYSCS_REMOTE_LOOPBACK      (1 << 1)
00125 
00126 //KSZ8873 Ethernet switch driver
00127 extern const PhyDriver ksz8873PhyDriver;
00128 
00129 //KSZ8873 related functions
00130 error_t ksz8873Init(NetInterface *interface);
00131 
00132 bool_t ksz8873GetLinkState(NetInterface *interface, uint8_t port);
00133 
00134 void ksz8873Tick(NetInterface *interface);
00135 
00136 void ksz8873EnableIrq(NetInterface *interface);
00137 void ksz8873DisableIrq(NetInterface *interface);
00138 
00139 void ksz8873EventHandler(NetInterface *interface);
00140 
00141 void ksz8873WritePhyReg(NetInterface *interface,
00142    uint8_t port, uint8_t address, uint16_t data);
00143 
00144 uint16_t ksz8873ReadPhyReg(NetInterface *interface,
00145    uint8_t port, uint8_t address);
00146 
00147 void ksz8873DumpPhyReg(NetInterface *interface, uint8_t port);
00148 
00149 #endif
00150