00001 /* ---------------------------------------------------------------------------- 00002 * SAM Software Package License 00003 * ---------------------------------------------------------------------------- 00004 * Copyright (c) 2012, Atmel Corporation 00005 * 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * 00011 * - Redistributions of source code must retain the above copyright notice, 00012 * this list of conditions and the disclaimer below. 00013 * 00014 * Atmel's name may not be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00019 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00020 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00022 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00023 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00024 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00025 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00026 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 * ---------------------------------------------------------------------------- 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