Mistake on this page?
Report an issue in GitHub or email us
synopGMAC_plat.h
Go to the documentation of this file.
1 /* ===================================================================================
2  * Copyright (c) <2009> Synopsys, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy of
5  * this software annotated with this license and associated documentation files
6  * (the "Software"), to deal in the Software without restriction, including without
7  * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all
12  * copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
19  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20  *
21  * =================================================================================== */
22 
23 /**\file
24  * This file serves as the wrapper for the platform/OS dependent functions
25  * It is needed to modify these functions accordingly based on the platform and the
26  * OS. Whenever the synopsys GMAC driver ported on to different platform, this file
27  * should be handled at most care.
28  * The corresponding function definitions for non-inline functions are available in
29  * synopGMAC_plat.c file.
30  * \internal
31  * -------------------------------------REVISION HISTORY---------------------------
32  * Synopsys 01/Aug/2007 Created
33  */
34 
35 
36 #ifndef SYNOP_GMAC_PLAT_H
37 #define SYNOP_GMAC_PLAT_H 1
38 
39 #include <stdio.h>
40 #include "NuMicro.h"
41 
42 #define TR0(fmt, args...) printf("SynopGMAC: " fmt, ##args)
43 
44 //#define DEBUG
45 #ifdef DEBUG
46 #undef TR
47 # define TR(fmt, args...) printf("SynopGMAC: " fmt, ##args)
48 #else
49 # define TR(fmt, args...) /* not debugging: nothing */
50 #endif
51 
52 typedef unsigned char u8; ///< Define 8-bit unsigned data type
53 typedef unsigned short u16; ///< Define 16-bit unsigned data type
54 typedef unsigned int u32; ///< Define 32-bit unsigned data type
55 typedef signed int s32; ///< Define 32-bit signed data type
56 //typedef unsigned long long u64;
57 typedef unsigned int u64;
58 
59 
60 typedef int bool;
61 enum synopGMAC_boolean {
62  false = 0,
63  true = 1
64 };
65 
66 #define DEFAULT_DELAY_VARIABLE 10
67 #define DEFAULT_LOOP_VARIABLE 10000
68 
69 /* There are platform related endian conversions
70  *
71  */
72 
73 #define LE32_TO_CPU __le32_to_cpu
74 #define BE32_TO_CPU __be32_to_cpu
75 #define CPU_TO_LE32 __cpu_to_le32
76 
77 /* Error Codes */
78 #define ESYNOPGMACNOERR 0
79 #define ESYNOPGMACNOMEM 1
80 #define ESYNOPGMACPHYERR 2
81 #define ESYNOPGMACBUSY 3
82 
83 
84 /**
85  * These are the wrapper function prototypes for OS/platform related routines
86  */
87 
88 extern void plat_delay(uint32_t ticks);
89 
90 
91 /**
92  * The Low level function to read register contents from Hardware.
93  *
94  * @param[in] pointer to the base of register map
95  * @param[in] Offset from the base
96  * \return Returns the register contents
97  */
98 static u32 __INLINE synopGMACReadReg(u32 *RegBase, u32 RegOffset)
99 {
100 
101  u64 addr = (u64)RegBase + RegOffset;
102  u32 data = inp32((void *)addr);
103  return data;
104 
105 }
106 
107 /**
108  * The Low level function to write to a register in Hardware.
109  *
110  * @param[in] pointer to the base of register map
111  * @param[in] Offset from the base
112  * @param[in] Data to be written
113  * \return void
114  */
115 static void __INLINE synopGMACWriteReg(u32 *RegBase, u32 RegOffset, u32 RegData)
116 {
117 
118  u64 addr = (u64)RegBase + RegOffset;
119  if(RegOffset == 0)
120  plat_delay(1);
121  outp32((void *)addr, RegData);
122  return;
123 }
124 
125 /**
126  * The Low level function to set bits of a register in Hardware.
127  *
128  * @param[in] pointer to the base of register map
129  * @param[in] Offset from the base
130  * @param[in] Bit mask to set bits to logical 1
131  * \return void
132  */
133 static void __INLINE synopGMACSetBits(u32 *RegBase, u32 RegOffset, u32 BitPos)
134 {
135  u64 addr = (u64)RegBase + RegOffset;
136  u32 data = inp32((void *)addr);
137  data |= BitPos;
138 
139  outp32((void *)addr, data);
140 
141  return;
142 }
143 
144 
145 /**
146  * The Low level function to clear bits of a register in Hardware.
147  *
148  * @param[in] pointer to the base of register map
149  * @param[in] Offset from the base
150  * @param[in] Bit mask to clear bits to logical 0
151  * \return void
152  */
153 static void __INLINE synopGMACClearBits(u32 *RegBase, u32 RegOffset, u32 BitPos)
154 {
155  u64 addr = (u64)RegBase + RegOffset;
156  u32 data = inp32((void *)addr);
157  data &= (~BitPos);
158 
159  outp32((void *)addr, data);
160  return;
161 }
162 
163 /**
164  * The Low level function to Check the setting of the bits.
165  *
166  * @param[in] pointer to the base of register map
167  * @param[in] Offset from the base
168  * @param[in] Bit mask to set bits to logical 1
169  * \return returns TRUE if set to '1' returns FALSE if set to '0'. Result undefined there are no bit set in the BitPos argument.
170  *
171  */
172 static bool __INLINE synopGMACCheckBits(u32 *RegBase, u32 RegOffset, u32 BitPos)
173 {
174  u64 addr = (u64)RegBase + RegOffset;
175  u32 data = inp32((void *)addr);
176  data &= BitPos;
177  if(data) return true;
178  else return false;
179 
180 }
181 
182 
183 #endif
static void __INLINE synopGMACWriteReg(u32 *RegBase, u32 RegOffset, u32 RegData)
The Low level function to write to a register in Hardware.
static void __INLINE synopGMACClearBits(u32 *RegBase, u32 RegOffset, u32 BitPos)
The Low level function to clear bits of a register in Hardware.
signed int s32
Define 32-bit signed data type.
unsigned char u8
Define 8-bit unsigned data type.
static bool __INLINE synopGMACCheckBits(u32 *RegBase, u32 RegOffset, u32 BitPos)
The Low level function to Check the setting of the bits.
unsigned short u16
Define 16-bit unsigned data type.
static u32 __INLINE synopGMACReadReg(u32 *RegBase, u32 RegOffset)
The Low level function to read register contents from Hardware.
unsigned int u32
Define 32-bit unsigned data type.
void plat_delay(uint32_t ticks)
These are the wrapper function prototypes for OS/platform related routines.
static void __INLINE synopGMACSetBits(u32 *RegBase, u32 RegOffset, u32 BitPos)
The Low level function to set bits of a register in Hardware.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.