aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/smc911x.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/smc911x.h')
-rw-r--r--drivers/net/smc911x.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
index 271a3e8cf683..266232271a72 100644
--- a/drivers/net/smc911x.h
+++ b/drivers/net/smc911x.h
@@ -29,6 +29,7 @@
29#ifndef _SMC911X_H_ 29#ifndef _SMC911X_H_
30#define _SMC911X_H_ 30#define _SMC911X_H_
31 31
32#include <linux/smc911x.h>
32/* 33/*
33 * Use the DMA feature on PXA chips 34 * Use the DMA feature on PXA chips
34 */ 35 */
@@ -42,6 +43,12 @@
42 #define SMC_USE_16BIT 0 43 #define SMC_USE_16BIT 0
43 #define SMC_USE_32BIT 1 44 #define SMC_USE_32BIT 1
44 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW 45 #define SMC_IRQ_SENSE IRQF_TRIGGER_LOW
46#else
47/*
48 * Default configuration
49 */
50
51#define SMC_DYNAMIC_BUS_CONFIG
45#endif 52#endif
46 53
47/* store this information for the driver.. */ 54/* store this information for the driver.. */
@@ -92,12 +99,84 @@ struct smc911x_local {
92 struct device *dev; 99 struct device *dev;
93#endif 100#endif
94 void __iomem *base; 101 void __iomem *base;
102#ifdef SMC_DYNAMIC_BUS_CONFIG
103 struct smc911x_platdata cfg;
104#endif
95}; 105};
96 106
97/* 107/*
98 * Define the bus width specific IO macros 108 * Define the bus width specific IO macros
99 */ 109 */
100 110
111#ifdef SMC_DYNAMIC_BUS_CONFIG
112static inline unsigned int SMC_inl(struct smc911x_local *lp, int reg)
113{
114 void __iomem *ioaddr = lp->base + reg;
115
116 if (lp->cfg.flags & SMC911X_USE_32BIT)
117 return readl(ioaddr);
118
119 if (lp->cfg.flags & SMC911X_USE_16BIT)
120 return readw(ioaddr) | (readw(ioaddr + 2) << 16);
121
122 BUG();
123}
124
125static inline void SMC_outl(unsigned int value, struct smc911x_local *lp,
126 int reg)
127{
128 void __iomem *ioaddr = lp->base + reg;
129
130 if (lp->cfg.flags & SMC911X_USE_32BIT) {
131 writel(value, ioaddr);
132 return;
133 }
134
135 if (lp->cfg.flags & SMC911X_USE_16BIT) {
136 writew(value & 0xffff, ioaddr);
137 writew(value >> 16, ioaddr + 2);
138 return;
139 }
140
141 BUG();
142}
143
144static inline void SMC_insl(struct smc911x_local *lp, int reg,
145 void *addr, unsigned int count)
146{
147 void __iomem *ioaddr = lp->base + reg;
148
149 if (lp->cfg.flags & SMC911X_USE_32BIT) {
150 readsl(ioaddr, addr, count);
151 return;
152 }
153
154 if (lp->cfg.flags & SMC911X_USE_16BIT) {
155 readsw(ioaddr, addr, count * 2);
156 return;
157 }
158
159 BUG();
160}
161
162static inline void SMC_outsl(struct smc911x_local *lp, int reg,
163 void *addr, unsigned int count)
164{
165 void __iomem *ioaddr = lp->base + reg;
166
167 if (lp->cfg.flags & SMC911X_USE_32BIT) {
168 writesl(ioaddr, addr, count);
169 return;
170 }
171
172 if (lp->cfg.flags & SMC911X_USE_16BIT) {
173 writesw(ioaddr, addr, count * 2);
174 return;
175 }
176
177 BUG();
178}
179#else
101#if SMC_USE_16BIT 180#if SMC_USE_16BIT
102#define SMC_inl(lp, r) ((readw((lp)->base + (r)) & 0xFFFF) + (readw((lp)->base + (r) + 2) << 16)) 181#define SMC_inl(lp, r) ((readw((lp)->base + (r)) & 0xFFFF) + (readw((lp)->base + (r) + 2) << 16))
103#define SMC_outl(v, lp, r) \ 182#define SMC_outl(v, lp, r) \
@@ -115,6 +194,8 @@ struct smc911x_local {
115#define SMC_outsl(lp, r, p, l) writesl((int*)((lp)->base + (r)), p, l) 194#define SMC_outsl(lp, r, p, l) writesl((int*)((lp)->base + (r)), p, l)
116 195
117#endif /* SMC_USE_16BIT */ 196#endif /* SMC_USE_16BIT */
197#endif /* SMC_DYNAMIC_BUS_CONFIG */
198
118 199
119#ifdef SMC_USE_PXA_DMA 200#ifdef SMC_USE_PXA_DMA
120#define SMC_USE_DMA 201#define SMC_USE_DMA