]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/staging/brcm80211/include/osl.h
Merge tag 'v2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[mv-sheeva.git] / drivers / staging / brcm80211 / include / osl.h
index c0ebb3d97220e6825c37a727a1d6099127a1c8de..b28235618d8b9e7599bb691f8802b0007769590e 100644 (file)
 #define _osl_h_
 
 /* osl handle type forward declaration */
-typedef struct osl_info osl_t;
+struct osl_info {
+       uint pktalloced;        /* Number of allocated packet buffers */
+       bool mmbus;             /* Bus supports memory-mapped registers */
+       uint magic;
+       void *pdev;
+       uint bustype;
+};
+
 typedef struct osl_dmainfo osldma_t;
 
-#define OSL_PKTTAG_SZ  32      /* Size of PktTag */
 
-/* Drivers use PKTFREESETCB to register a callback function when a packet is freed by OSL */
-typedef void (*pktfree_cb_fn_t) (void *ctx, void *pkt, unsigned int status);
+extern struct osl_info *osl_attach(void *pdev, uint bustype);
+extern void osl_detach(struct osl_info *osh);
 
-#ifdef BCMSDIO
-/* Drivers use REGOPSSET() to register register read/write funcitons */
-typedef unsigned int (*osl_rreg_fn_t) (void *ctx, void *reg, unsigned int size);
-typedef void (*osl_wreg_fn_t) (void *ctx, void *reg, unsigned int val,
-                              unsigned int size);
-#endif
+extern u32 g_assert_type;
 
-#include <linux_osl.h>
+#if defined(BCMDBG_ASSERT)
+#define ASSERT(exp) \
+         do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
+extern void osl_assert(char *exp, char *file, int line);
+#else
+#define ASSERT(exp)    do {} while (0)
+#endif  /* defined(BCMDBG_ASSERT) */
 
-/* --------------------------------------------------------------------------
-** Register manipulation macros.
-*/
+/* PCI device bus # and slot # */
+#define OSL_PCI_BUS(osh)       osl_pci_bus(osh)
+#define OSL_PCI_SLOT(osh)      osl_pci_slot(osh)
+extern uint osl_pci_bus(struct osl_info *osh);
+extern uint osl_pci_slot(struct osl_info *osh);
 
-#define        SET_REG(osh, r, mask, val)      W_REG((osh), (r), ((R_REG((osh), r) & ~(mask)) | (val)))
+#define BUS_SWAP32(v)          (v)
 
-#ifndef AND_REG
-#define AND_REG(osh, r, v)             W_REG(osh, (r), R_REG(osh, r) & (v))
-#endif                         /* !AND_REG */
+extern void *osl_dma_alloc_consistent(struct osl_info *osh, uint size,
+                                     u16 align, uint *tot, unsigned long *pap);
+
+#ifdef BRCM_FULLMAC
+#define        DMA_ALLOC_CONSISTENT(osh, size, pap, dmah, alignbits) \
+       osl_dma_alloc_consistent((osh), (size), (0), (tot), (pap))
+#else
+#define        DMA_ALLOC_CONSISTENT(osh, size, align, tot, pap, dmah) \
+       osl_dma_alloc_consistent((osh), (size), (align), (tot), (pap))
+#endif /* BRCM_FULLMAC */
 
-#ifndef OR_REG
-#define OR_REG(osh, r, v)              W_REG(osh, (r), R_REG(osh, r) | (v))
-#endif                         /* !OR_REG */
+#define        DMA_FREE_CONSISTENT(osh, va, size, pa, dmah) \
+       osl_dma_free_consistent((osh), (void *)(va), (size), (pa))
+extern void osl_dma_free_consistent(struct osl_info *osh, void *va,
+                                   uint size, unsigned long pa);
+
+/* map/unmap direction */
+#define        DMA_TX  1               /* TX direction for DMA */
+#define        DMA_RX  2               /* RX direction for DMA */
+
+/* map/unmap shared (dma-able) memory */
+#define        DMA_MAP(osh, va, size, direction, p, dmah) \
+       osl_dma_map((osh), (va), (size), (direction))
+#define        DMA_UNMAP(osh, pa, size, direction, p, dmah) \
+       osl_dma_unmap((osh), (pa), (size), (direction))
+extern uint osl_dma_map(struct osl_info *osh, void *va, uint size,
+                       int direction);
+extern void osl_dma_unmap(struct osl_info *osh, uint pa, uint size,
+                         int direction);
+
+/* register access macros */
+#if defined(BCMSDIO)
+#ifdef BRCM_FULLMAC
+#include <bcmsdh.h>
+#endif
+#define OSL_WRITE_REG(osh, r, v) \
+               (bcmsdh_reg_write(NULL, (unsigned long)(r), sizeof(*(r)), (v)))
+#define OSL_READ_REG(osh, r) \
+               (bcmsdh_reg_read(NULL, (unsigned long)(r), sizeof(*(r))))
+#endif
 
-#if !defined(OSL_SYSUPTIME)
-#define OSL_SYSUPTIME() (0)
-#define OSL_SYSUPTIME_SUPPORT false
+#if defined(BCMSDIO)
+#define SELECT_BUS_WRITE(osh, mmap_op, bus_op) \
+       if ((osh)->mmbus) \
+               mmap_op else bus_op
+#define SELECT_BUS_READ(osh, mmap_op, bus_op) \
+       ((osh)->mmbus) ?  mmap_op : bus_op
 #else
-#define OSL_SYSUPTIME_SUPPORT true
-#endif                         /* OSL_SYSUPTIME */
+#define SELECT_BUS_WRITE(osh, mmap_op, bus_op) mmap_op
+#define SELECT_BUS_READ(osh, mmap_op, bus_op) mmap_op
+#endif
+
+/* the largest reasonable packet buffer driver uses for ethernet MTU in bytes */
+#define        PKTBUFSZ        2048
+
+#define OSL_SYSUPTIME()                ((u32)jiffies * (1000 / HZ))
+#define        printf(fmt, args...)    printk(fmt , ## args)
+#ifdef BRCM_FULLMAC
+#include <linux/kernel.h>      /* for vsn/printf's */
+#include <linux/string.h>      /* for mem*, str* */
+#endif
+/* bcopy's: Linux kernel doesn't provide these (anymore) */
+#define        bcopy(src, dst, len)    memcpy((dst), (src), (len))
+
+/* register access macros */
+#ifndef IL_BIGENDIAN
+#ifndef __mips__
+#define R_REG(osh, r) (\
+       SELECT_BUS_READ(osh, sizeof(*(r)) == sizeof(u8) ? \
+       readb((volatile u8*)(r)) : \
+       sizeof(*(r)) == sizeof(u16) ? readw((volatile u16*)(r)) : \
+       readl((volatile u32*)(r)), OSL_READ_REG(osh, r)) \
+)
+#else                          /* __mips__ */
+#define R_REG(osh, r) (\
+       SELECT_BUS_READ(osh, \
+               ({ \
+                       __typeof(*(r)) __osl_v; \
+                       __asm__ __volatile__("sync"); \
+                       switch (sizeof(*(r))) { \
+                       case sizeof(u8): \
+                               __osl_v = readb((volatile u8*)(r)); \
+                               break; \
+                       case sizeof(u16): \
+                               __osl_v = readw((volatile u16*)(r)); \
+                               break; \
+                       case sizeof(u32): \
+                               __osl_v = \
+                               readl((volatile u32*)(r)); \
+                               break; \
+                       } \
+                       __asm__ __volatile__("sync"); \
+                       __osl_v; \
+               }), \
+               ({ \
+                       __typeof(*(r)) __osl_v; \
+                       __asm__ __volatile__("sync"); \
+                       __osl_v = OSL_READ_REG(osh, r); \
+                       __asm__ __volatile__("sync"); \
+                       __osl_v; \
+               })) \
+)
+#endif                         /* __mips__ */
+
+#define W_REG(osh, r, v) do { \
+       SELECT_BUS_WRITE(osh,  \
+               switch (sizeof(*(r))) { \
+               case sizeof(u8): \
+                       writeb((u8)(v), (volatile u8*)(r)); break; \
+               case sizeof(u16): \
+                       writew((u16)(v), (volatile u16*)(r)); break; \
+               case sizeof(u32): \
+                       writel((u32)(v), (volatile u32*)(r)); break; \
+               }, \
+               (OSL_WRITE_REG(osh, r, v))); \
+       } while (0)
+#else                          /* IL_BIGENDIAN */
+#define R_REG(osh, r) (\
+       SELECT_BUS_READ(osh, \
+               ({ \
+                       __typeof(*(r)) __osl_v; \
+                       switch (sizeof(*(r))) { \
+                       case sizeof(u8): \
+                               __osl_v = \
+                               readb((volatile u8*)((r)^3)); \
+                               break; \
+                       case sizeof(u16): \
+                               __osl_v = \
+                               readw((volatile u16*)((r)^2)); \
+                               break; \
+                       case sizeof(u32): \
+                               __osl_v = readl((volatile u32*)(r)); \
+                               break; \
+                       } \
+                       __osl_v; \
+               }), \
+               OSL_READ_REG(osh, r)) \
+)
+#define W_REG(osh, r, v) do { \
+       SELECT_BUS_WRITE(osh,  \
+               switch (sizeof(*(r))) { \
+               case sizeof(u8):        \
+                       writeb((u8)(v), \
+                       (volatile u8*)((r)^3)); break; \
+               case sizeof(u16):       \
+                       writew((u16)(v), \
+                       (volatile u16*)((r)^2)); break; \
+               case sizeof(u32):       \
+                       writel((u32)(v), \
+                       (volatile u32*)(r)); break; \
+               }, \
+               (OSL_WRITE_REG(osh, r, v))); \
+       } while (0)
+#endif                         /* IL_BIGENDIAN */
+
+#define        bcopy(src, dst, len)    memcpy((dst), (src), (len))
+
+/* packet primitives */
+extern struct sk_buff *pkt_buf_get_skb(struct osl_info *osh, uint len);
+extern void pkt_buf_free_skb(struct osl_info *osh, struct sk_buff *skb, bool send);
 
-#endif                         /* _osl_h_ */
+#endif /* _osl_h_ */