Webserver+3d print

Dependents:   Nucleo

Committer:
Sergunb
Date:
Sat Feb 04 18:15:49 2017 +0000
Revision:
0:8918a71cdbe9
nothing else

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sergunb 0:8918a71cdbe9 1 /**
Sergunb 0:8918a71cdbe9 2 * @file ksz8873.h
Sergunb 0:8918a71cdbe9 3 * @brief KSZ8873 Ethernet switch
Sergunb 0:8918a71cdbe9 4 *
Sergunb 0:8918a71cdbe9 5 * @section License
Sergunb 0:8918a71cdbe9 6 *
Sergunb 0:8918a71cdbe9 7 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
Sergunb 0:8918a71cdbe9 8 *
Sergunb 0:8918a71cdbe9 9 * This file is part of CycloneTCP Open.
Sergunb 0:8918a71cdbe9 10 *
Sergunb 0:8918a71cdbe9 11 * This program is free software; you can redistribute it and/or
Sergunb 0:8918a71cdbe9 12 * modify it under the terms of the GNU General Public License
Sergunb 0:8918a71cdbe9 13 * as published by the Free Software Foundation; either version 2
Sergunb 0:8918a71cdbe9 14 * of the License, or (at your option) any later version.
Sergunb 0:8918a71cdbe9 15 *
Sergunb 0:8918a71cdbe9 16 * This program is distributed in the hope that it will be useful,
Sergunb 0:8918a71cdbe9 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Sergunb 0:8918a71cdbe9 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Sergunb 0:8918a71cdbe9 19 * GNU General Public License for more details.
Sergunb 0:8918a71cdbe9 20 *
Sergunb 0:8918a71cdbe9 21 * You should have received a copy of the GNU General Public License
Sergunb 0:8918a71cdbe9 22 * along with this program; if not, write to the Free Software Foundation,
Sergunb 0:8918a71cdbe9 23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Sergunb 0:8918a71cdbe9 24 *
Sergunb 0:8918a71cdbe9 25 * @author Oryx Embedded SARL (www.oryx-embedded.com)
Sergunb 0:8918a71cdbe9 26 * @version 1.7.6
Sergunb 0:8918a71cdbe9 27 **/
Sergunb 0:8918a71cdbe9 28
Sergunb 0:8918a71cdbe9 29 #ifndef _KSZ8873_H
Sergunb 0:8918a71cdbe9 30 #define _KSZ8873_H
Sergunb 0:8918a71cdbe9 31
Sergunb 0:8918a71cdbe9 32 //Dependencies
Sergunb 0:8918a71cdbe9 33 #include "core/nic.h"
Sergunb 0:8918a71cdbe9 34
Sergunb 0:8918a71cdbe9 35 //KSZ8873 ports
Sergunb 0:8918a71cdbe9 36 #define KSZ8873_PORT1 1
Sergunb 0:8918a71cdbe9 37 #define KSZ8873_PORT2 2
Sergunb 0:8918a71cdbe9 38
Sergunb 0:8918a71cdbe9 39 //KSZ8873 registers
Sergunb 0:8918a71cdbe9 40 #define KSZ8873_PHY_REG_BMCR 0x00
Sergunb 0:8918a71cdbe9 41 #define KSZ8873_PHY_REG_BMSR 0x01
Sergunb 0:8918a71cdbe9 42 #define KSZ8873_PHY_REG_PHYIDR1 0x02
Sergunb 0:8918a71cdbe9 43 #define KSZ8873_PHY_REG_PHYIDR2 0x03
Sergunb 0:8918a71cdbe9 44 #define KSZ8873_PHY_REG_ANAR 0x04
Sergunb 0:8918a71cdbe9 45 #define KSZ8873_PHY_REG_ANLPAR 0x05
Sergunb 0:8918a71cdbe9 46 #define KSZ8873_PHY_REG_LINKMDCS 0x1D
Sergunb 0:8918a71cdbe9 47 #define KSZ8873_PHY_REG_PHYSCS 0x1F
Sergunb 0:8918a71cdbe9 48
Sergunb 0:8918a71cdbe9 49 //BMCR register
Sergunb 0:8918a71cdbe9 50 #define BMCR_SOFT_RESET (1 << 15)
Sergunb 0:8918a71cdbe9 51 #define BMCR_LOOPBACK (1 << 14)
Sergunb 0:8918a71cdbe9 52 #define BMCR_FORCE_100 (1 << 13)
Sergunb 0:8918a71cdbe9 53 #define BMCR_AN_EN (1 << 12)
Sergunb 0:8918a71cdbe9 54 #define BMCR_POWER_DOWN (1 << 11)
Sergunb 0:8918a71cdbe9 55 #define BMCR_ISOLATE (1 << 10)
Sergunb 0:8918a71cdbe9 56 #define BMCR_RESTART_AN (1 << 9)
Sergunb 0:8918a71cdbe9 57 #define BMCR_FORCE_FULL_DUPLEX (1 << 8)
Sergunb 0:8918a71cdbe9 58 #define BMCR_COL_TEST (1 << 7)
Sergunb 0:8918a71cdbe9 59 #define BMCR_HP_MDIX (1 << 5)
Sergunb 0:8918a71cdbe9 60 #define BMCR_FORCE_MDI (1 << 4)
Sergunb 0:8918a71cdbe9 61 #define BMCR_DIS_AUTO_MDIX (1 << 3)
Sergunb 0:8918a71cdbe9 62 #define BMCR_DIS_FAR_END_FAULT (1 << 2)
Sergunb 0:8918a71cdbe9 63 #define BMCR_DIS_TRANSMIT (1 << 1)
Sergunb 0:8918a71cdbe9 64 #define BMCR_DIS_LED (1 << 0)
Sergunb 0:8918a71cdbe9 65
Sergunb 0:8918a71cdbe9 66 //BMSR register
Sergunb 0:8918a71cdbe9 67 #define BMSR_100BT4 (1 << 15)
Sergunb 0:8918a71cdbe9 68 #define BMSR_100BTX_FD (1 << 14)
Sergunb 0:8918a71cdbe9 69 #define BMSR_100BTX (1 << 13)
Sergunb 0:8918a71cdbe9 70 #define BMSR_10BT_FD (1 << 12)
Sergunb 0:8918a71cdbe9 71 #define BMSR_10BT (1 << 11)
Sergunb 0:8918a71cdbe9 72 #define BMSR_NO_PREAMBLE (1 << 6)
Sergunb 0:8918a71cdbe9 73 #define BMSR_AN_COMPLETE (1 << 5)
Sergunb 0:8918a71cdbe9 74 #define BMSR_FAR_END_FAULT (1 << 4)
Sergunb 0:8918a71cdbe9 75 #define BMSR_AN_ABLE (1 << 3)
Sergunb 0:8918a71cdbe9 76 #define BMSR_LINK_STATUS (1 << 2)
Sergunb 0:8918a71cdbe9 77 #define BMSR_JABBER_TEST (1 << 1)
Sergunb 0:8918a71cdbe9 78 #define BMSR_EXTENDED_CAP (1 << 0)
Sergunb 0:8918a71cdbe9 79
Sergunb 0:8918a71cdbe9 80 //ANAR register
Sergunb 0:8918a71cdbe9 81 #define ANAR_NEXT_PAGE (1 << 15)
Sergunb 0:8918a71cdbe9 82 #define ANAR_REMOTE_FAULT (1 << 13)
Sergunb 0:8918a71cdbe9 83 #define ANAR_PAUSE (1 << 10)
Sergunb 0:8918a71cdbe9 84 #define ANAR_100BTX_FD (1 << 8)
Sergunb 0:8918a71cdbe9 85 #define ANAR_100BTX (1 << 7)
Sergunb 0:8918a71cdbe9 86 #define ANAR_10BT_FD (1 << 6)
Sergunb 0:8918a71cdbe9 87 #define ANAR_10BT (1 << 5)
Sergunb 0:8918a71cdbe9 88 #define ANAR_SELECTOR4 (1 << 4)
Sergunb 0:8918a71cdbe9 89 #define ANAR_SELECTOR3 (1 << 3)
Sergunb 0:8918a71cdbe9 90 #define ANAR_SELECTOR2 (1 << 2)
Sergunb 0:8918a71cdbe9 91 #define ANAR_SELECTOR1 (1 << 1)
Sergunb 0:8918a71cdbe9 92 #define ANAR_SELECTOR0 (1 << 0)
Sergunb 0:8918a71cdbe9 93
Sergunb 0:8918a71cdbe9 94 //ANLPAR register
Sergunb 0:8918a71cdbe9 95 #define ANLPAR_NEXT_PAGE (1 << 15)
Sergunb 0:8918a71cdbe9 96 #define ANLPAR_LP_ACK (1 << 14)
Sergunb 0:8918a71cdbe9 97 #define ANLPAR_REMOTE_FAULT (1 << 13)
Sergunb 0:8918a71cdbe9 98 #define ANLPAR_PAUSE (1 << 10)
Sergunb 0:8918a71cdbe9 99 #define ANLPAR_100BTX_FD (1 << 8)
Sergunb 0:8918a71cdbe9 100 #define ANLPAR_100BTX (1 << 7)
Sergunb 0:8918a71cdbe9 101 #define ANLPAR_10BT_FD (1 << 6)
Sergunb 0:8918a71cdbe9 102 #define ANLPAR_10BT (1 << 5)
Sergunb 0:8918a71cdbe9 103
Sergunb 0:8918a71cdbe9 104 //LINKMDCS register
Sergunb 0:8918a71cdbe9 105 #define LINKMDCS_VCT_EN (1 << 15)
Sergunb 0:8918a71cdbe9 106 #define LINKMDCS_VCT_RESULT1 (1 << 14)
Sergunb 0:8918a71cdbe9 107 #define LINKMDCS_VCT_RESULT0 (1 << 13)
Sergunb 0:8918a71cdbe9 108 #define LINKMDCS_VCT_10M_SHORT (1 << 12)
Sergunb 0:8918a71cdbe9 109 #define LINKMDCS_VCT_FAULT_COUNT8 (1 << 8)
Sergunb 0:8918a71cdbe9 110 #define LINKMDCS_VCT_FAULT_COUNT7 (1 << 7)
Sergunb 0:8918a71cdbe9 111 #define LINKMDCS_VCT_FAULT_COUNT6 (1 << 6)
Sergunb 0:8918a71cdbe9 112 #define LINKMDCS_VCT_FAULT_COUNT5 (1 << 5)
Sergunb 0:8918a71cdbe9 113 #define LINKMDCS_VCT_FAULT_COUNT4 (1 << 4)
Sergunb 0:8918a71cdbe9 114 #define LINKMDCS_VCT_FAULT_COUNT3 (1 << 3)
Sergunb 0:8918a71cdbe9 115 #define LINKMDCS_VCT_FAULT_COUNT2 (1 << 2)
Sergunb 0:8918a71cdbe9 116 #define LINKMDCS_VCT_FAULT_COUNT1 (1 << 1)
Sergunb 0:8918a71cdbe9 117 #define LINKMDCS_VCT_FAULT_COUNT0 (1 << 0)
Sergunb 0:8918a71cdbe9 118
Sergunb 0:8918a71cdbe9 119 //PHYSCS register
Sergunb 0:8918a71cdbe9 120 #define PHYSCS_POLRVS (1 << 5)
Sergunb 0:8918a71cdbe9 121 #define PHYSCS_MDIX_STATUS (1 << 4)
Sergunb 0:8918a71cdbe9 122 #define PHYSCS_FORCE_LINK (1 << 3)
Sergunb 0:8918a71cdbe9 123 #define PHYSCS_PWRSAVE (1 << 2)
Sergunb 0:8918a71cdbe9 124 #define PHYSCS_REMOTE_LOOPBACK (1 << 1)
Sergunb 0:8918a71cdbe9 125
Sergunb 0:8918a71cdbe9 126 //KSZ8873 Ethernet switch driver
Sergunb 0:8918a71cdbe9 127 extern const PhyDriver ksz8873PhyDriver;
Sergunb 0:8918a71cdbe9 128
Sergunb 0:8918a71cdbe9 129 //KSZ8873 related functions
Sergunb 0:8918a71cdbe9 130 error_t ksz8873Init(NetInterface *interface);
Sergunb 0:8918a71cdbe9 131
Sergunb 0:8918a71cdbe9 132 bool_t ksz8873GetLinkState(NetInterface *interface, uint8_t port);
Sergunb 0:8918a71cdbe9 133
Sergunb 0:8918a71cdbe9 134 void ksz8873Tick(NetInterface *interface);
Sergunb 0:8918a71cdbe9 135
Sergunb 0:8918a71cdbe9 136 void ksz8873EnableIrq(NetInterface *interface);
Sergunb 0:8918a71cdbe9 137 void ksz8873DisableIrq(NetInterface *interface);
Sergunb 0:8918a71cdbe9 138
Sergunb 0:8918a71cdbe9 139 void ksz8873EventHandler(NetInterface *interface);
Sergunb 0:8918a71cdbe9 140
Sergunb 0:8918a71cdbe9 141 void ksz8873WritePhyReg(NetInterface *interface,
Sergunb 0:8918a71cdbe9 142 uint8_t port, uint8_t address, uint16_t data);
Sergunb 0:8918a71cdbe9 143
Sergunb 0:8918a71cdbe9 144 uint16_t ksz8873ReadPhyReg(NetInterface *interface,
Sergunb 0:8918a71cdbe9 145 uint8_t port, uint8_t address);
Sergunb 0:8918a71cdbe9 146
Sergunb 0:8918a71cdbe9 147 void ksz8873DumpPhyReg(NetInterface *interface, uint8_t port);
Sergunb 0:8918a71cdbe9 148
Sergunb 0:8918a71cdbe9 149 #endif
Sergunb 0:8918a71cdbe9 150