2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 /* osl handle type forward declaration */
22 uint pktalloced
; /* Number of allocated packet buffers */
23 bool mmbus
; /* Bus supports memory-mapped registers */
29 typedef struct osl_dmainfo osldma_t
;
32 extern struct osl_info
*osl_attach(void *pdev
, uint bustype
);
33 extern void osl_detach(struct osl_info
*osh
);
35 extern u32 g_assert_type
;
37 #if defined(BCMDBG_ASSERT)
39 do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
40 extern void osl_assert(char *exp
, char *file
, int line
);
42 #define ASSERT(exp) do {} while (0)
43 #endif /* defined(BCMDBG_ASSERT) */
45 /* PCI device bus # and slot # */
46 #define OSL_PCI_BUS(osh) osl_pci_bus(osh)
47 #define OSL_PCI_SLOT(osh) osl_pci_slot(osh)
48 extern uint
osl_pci_bus(struct osl_info
*osh
);
49 extern uint
osl_pci_slot(struct osl_info
*osh
);
51 #define BUS_SWAP32(v) (v)
53 extern void *osl_dma_alloc_consistent(struct osl_info
*osh
, uint size
,
54 u16 align
, uint
*tot
, unsigned long *pap
);
57 #define DMA_ALLOC_CONSISTENT(osh, size, pap, dmah, alignbits) \
58 osl_dma_alloc_consistent((osh), (size), (0), (tot), (pap))
60 #define DMA_ALLOC_CONSISTENT(osh, size, align, tot, pap, dmah) \
61 osl_dma_alloc_consistent((osh), (size), (align), (tot), (pap))
62 #endif /* BRCM_FULLMAC */
64 #define DMA_FREE_CONSISTENT(osh, va, size, pa, dmah) \
65 osl_dma_free_consistent((osh), (void *)(va), (size), (pa))
66 extern void osl_dma_free_consistent(struct osl_info
*osh
, void *va
,
67 uint size
, unsigned long pa
);
69 /* map/unmap direction */
70 #define DMA_TX 1 /* TX direction for DMA */
71 #define DMA_RX 2 /* RX direction for DMA */
73 /* register access macros */
78 #define OSL_WRITE_REG(osh, r, v) \
79 (bcmsdh_reg_write(NULL, (unsigned long)(r), sizeof(*(r)), (v)))
80 #define OSL_READ_REG(osh, r) \
81 (bcmsdh_reg_read(NULL, (unsigned long)(r), sizeof(*(r))))
85 #define SELECT_BUS_WRITE(osh, mmap_op, bus_op) \
88 #define SELECT_BUS_READ(osh, mmap_op, bus_op) \
89 ((osh)->mmbus) ? mmap_op : bus_op
91 #define SELECT_BUS_WRITE(osh, mmap_op, bus_op) mmap_op
92 #define SELECT_BUS_READ(osh, mmap_op, bus_op) mmap_op
95 /* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
98 #define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ))
100 #include <linux/kernel.h> /* for vsn/printf's */
101 #include <linux/string.h> /* for mem*, str* */
104 /* register access macros */
107 #define R_REG(osh, r) (\
108 SELECT_BUS_READ(osh, sizeof(*(r)) == sizeof(u8) ? \
109 readb((volatile u8*)(r)) : \
110 sizeof(*(r)) == sizeof(u16) ? readw((volatile u16*)(r)) : \
111 readl((volatile u32*)(r)), OSL_READ_REG(osh, r)) \
114 #define R_REG(osh, r) (\
115 SELECT_BUS_READ(osh, \
117 __typeof(*(r)) __osl_v; \
118 __asm__ __volatile__("sync"); \
119 switch (sizeof(*(r))) { \
121 __osl_v = readb((volatile u8*)(r)); \
124 __osl_v = readw((volatile u16*)(r)); \
128 readl((volatile u32*)(r)); \
131 __asm__ __volatile__("sync"); \
135 __typeof(*(r)) __osl_v; \
136 __asm__ __volatile__("sync"); \
137 __osl_v = OSL_READ_REG(osh, r); \
138 __asm__ __volatile__("sync"); \
142 #endif /* __mips__ */
144 #define W_REG(osh, r, v) do { \
145 SELECT_BUS_WRITE(osh, \
146 switch (sizeof(*(r))) { \
148 writeb((u8)(v), (volatile u8*)(r)); break; \
150 writew((u16)(v), (volatile u16*)(r)); break; \
152 writel((u32)(v), (volatile u32*)(r)); break; \
154 (OSL_WRITE_REG(osh, r, v))); \
156 #else /* IL_BIGENDIAN */
157 #define R_REG(osh, r) (\
158 SELECT_BUS_READ(osh, \
160 __typeof(*(r)) __osl_v; \
161 switch (sizeof(*(r))) { \
164 readb((volatile u8*)((r)^3)); \
168 readw((volatile u16*)((r)^2)); \
171 __osl_v = readl((volatile u32*)(r)); \
176 OSL_READ_REG(osh, r)) \
178 #define W_REG(osh, r, v) do { \
179 SELECT_BUS_WRITE(osh, \
180 switch (sizeof(*(r))) { \
183 (volatile u8*)((r)^3)); break; \
186 (volatile u16*)((r)^2)); break; \
189 (volatile u32*)(r)); break; \
191 (OSL_WRITE_REG(osh, r, v))); \
193 #endif /* IL_BIGENDIAN */
195 /* packet primitives */
196 extern struct sk_buff
*pkt_buf_get_skb(struct osl_info
*osh
, uint len
);
197 extern void pkt_buf_free_skb(struct osl_info
*osh
, struct sk_buff
*skb
, bool send
);
This page took 0.046241 seconds and 6 git commands to generate.