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 /* map/unmap direction */
54 #define DMA_TX 1 /* TX direction for DMA */
55 #define DMA_RX 2 /* RX direction for DMA */
57 /* register access macros */
62 #define OSL_WRITE_REG(r, v) \
63 (bcmsdh_reg_write(NULL, (unsigned long)(r), sizeof(*(r)), (v)))
64 #define OSL_READ_REG(r) \
65 (bcmsdh_reg_read(NULL, (unsigned long)(r), sizeof(*(r))))
69 #define SELECT_BUS_WRITE(mmap_op, bus_op) bus_op
70 #define SELECT_BUS_READ(mmap_op, bus_op) bus_op
72 #define SELECT_BUS_WRITE(mmap_op, bus_op) mmap_op
73 #define SELECT_BUS_READ(mmap_op, bus_op) mmap_op
76 /* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
79 #define OSL_SYSUPTIME() ((u32)jiffies * (1000 / HZ))
81 #include <linux/kernel.h> /* for vsn/printf's */
82 #include <linux/string.h> /* for mem*, str* */
85 /* register access macros */
89 SELECT_BUS_READ(sizeof(*(r)) == sizeof(u8) ? \
90 readb((volatile u8*)(r)) : \
91 sizeof(*(r)) == sizeof(u16) ? readw((volatile u16*)(r)) : \
92 readl((volatile u32*)(r)), OSL_READ_REG(r)) \
98 __typeof(*(r)) __osl_v; \
99 __asm__ __volatile__("sync"); \
100 switch (sizeof(*(r))) { \
102 __osl_v = readb((volatile u8*)(r)); \
105 __osl_v = readw((volatile u16*)(r)); \
109 readl((volatile u32*)(r)); \
112 __asm__ __volatile__("sync"); \
116 __typeof(*(r)) __osl_v; \
117 __asm__ __volatile__("sync"); \
118 __osl_v = OSL_READ_REG(r); \
119 __asm__ __volatile__("sync"); \
123 #endif /* __mips__ */
125 #define W_REG(r, v) do { \
127 switch (sizeof(*(r))) { \
129 writeb((u8)(v), (volatile u8*)(r)); break; \
131 writew((u16)(v), (volatile u16*)(r)); break; \
133 writel((u32)(v), (volatile u32*)(r)); break; \
135 (OSL_WRITE_REG(r, v))); \
137 #else /* IL_BIGENDIAN */
141 __typeof(*(r)) __osl_v; \
142 switch (sizeof(*(r))) { \
145 readb((volatile u8*)((r)^3)); \
149 readw((volatile u16*)((r)^2)); \
152 __osl_v = readl((volatile u32*)(r)); \
159 #define W_REG(r, v) do { \
161 switch (sizeof(*(r))) { \
164 (volatile u8*)((r)^3)); break; \
167 (volatile u16*)((r)^2)); break; \
170 (volatile u32*)(r)); break; \
172 (OSL_WRITE_REG(r, v))); \
174 #endif /* IL_BIGENDIAN */
This page took 0.034538 seconds and 6 git commands to generate.