00001 /* ---------------------------------------------------------------------------- */ 00002 /* Atmel Microcontroller Software Support */ 00003 /* SAM Software Package License */ 00004 /* ---------------------------------------------------------------------------- */ 00005 /* Copyright (c) 2015, Atmel Corporation */ 00006 /* */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without */ 00010 /* modification, are permitted provided that the following condition is met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, */ 00013 /* this list of conditions and the disclaimer below. */ 00014 /* */ 00015 /* Atmel's name may not be used to endorse or promote products derived from */ 00016 /* this software without specific prior written permission. */ 00017 /* */ 00018 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */ 00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ 00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */ 00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */ 00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ 00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ 00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ 00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */ 00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00028 /* ---------------------------------------------------------------------------- */ 00029 00030 /** \file */ 00031 00032 /** \addtogroup gmacb_module Ethernet GMACB Driver 00033 *@{ 00034 * Implement GEMAC PHY driver, that initialize the PHY to prepare for 00035 * Ethernet transfer. 00036 * 00037 * \section Usage 00038 * -# EMAC related pins and Driver should be initialized at first. 00039 * -# Initialize GMACB Driver instance by invoking GMACB_Init(). 00040 * -# Initialize PHY connected via GMACB_InitPhy(), PHY address is 00041 * automatically adjusted by attempt to read. 00042 * -# Perform PHY auto negotiate through GMACB_AutoNegotiate(), so 00043 * connection established. 00044 * 00045 * 00046 * Related files:\n 00047 * \ref gmacb.h\n 00048 * \ref gmacb.c\n 00049 * \ref gmii.h.\n 00050 * 00051 */ 00052 /**@}*/ 00053 00054 #ifndef _GMACB_PHY_H 00055 #define _GMACB_PHY_H 00056 00057 00058 /*--------------------------------------------------------------------------- 00059 * Headers 00060 *---------------------------------------------------------------------------*/ 00061 00062 #include "board.h" 00063 00064 /*--------------------------------------------------------------------------- 00065 * Definitions 00066 *---------------------------------------------------------------------------*/ 00067 00068 /** The reset length setting for external reset configuration */ 00069 #define GMACB_RESET_LENGTH 0xD 00070 00071 /*--------------------------------------------------------------------------- 00072 * Types 00073 *---------------------------------------------------------------------------*/ 00074 00075 00076 /** The DM9161 instance */ 00077 typedef struct _GMacb { 00078 /**< Driver */ 00079 sGmacd *pGmacd; 00080 /** The retry & timeout settings */ 00081 uint32_t retryMax; 00082 /** PHY address (pre-defined by pins on reset) */ 00083 uint8_t phyAddress; 00084 } GMacb; 00085 00086 /*--------------------------------------------------------------------------- 00087 * Exported functions 00088 *---------------------------------------------------------------------------*/ 00089 extern void GMACB_SetupTimeout(GMacb *pMacb, uint32_t toMax); 00090 00091 extern void GMACB_Init(GMacb *pMacb, sGmacd *pGmacd, uint8_t phyAddress); 00092 00093 extern uint8_t GMACB_InitPhy( 00094 GMacb *pMacb, 00095 uint32_t mck, 00096 const Pin *pResetPins, 00097 uint32_t nbResetPins, 00098 const Pin *pEmacPins, 00099 uint32_t nbEmacPins); 00100 00101 extern uint8_t GMACB_AutoNegotiate(GMacb *pMacb); 00102 00103 extern uint8_t GMACB_GetLinkSpeed(GMacb *pMacb, uint8_t applySettings); 00104 00105 extern uint8_t GMACB_Send(GMacb *pMacb, void *pBuffer, uint32_t size); 00106 00107 extern uint32_t GMACB_Poll(GMacb *pMacb, uint8_t *pBuffer, uint32_t size); 00108 00109 extern void GMACB_DumpRegisters(GMacb *pMacb); 00110 00111 extern uint8_t GMACB_ResetPhy(GMacb *pMacb); 00112 00113 #endif // #ifndef _GMACB_H 00114