linux/drivers/staging/ath6kl/hif/sdio/linux_sdio/include/hif_internal.h
<<
>>
Prefs
   1//------------------------------------------------------------------------------
   2// <copyright file="hif_internal.h" company="Atheros">
   3//    Copyright (c) 2004-2010 Atheros Corporation.  All rights reserved.
   4// 
   5//
   6// Permission to use, copy, modify, and/or distribute this software for any
   7// purpose with or without fee is hereby granted, provided that the above
   8// copyright notice and this permission notice appear in all copies.
   9//
  10// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17//
  18//
  19//------------------------------------------------------------------------------
  20//==============================================================================
  21// internal header file for hif layer
  22//
  23// Author(s): ="Atheros"
  24//==============================================================================
  25#ifndef _HIF_INTERNAL_H_
  26#define _HIF_INTERNAL_H_
  27
  28#include "a_config.h"
  29#include "athdefs.h"
  30#include "a_types.h"
  31#include "a_osapi.h"
  32#include "hif.h"
  33#include "../../../common/hif_sdio_common.h"
  34#include <linux/scatterlist.h>
  35#define HIF_LINUX_MMC_SCATTER_SUPPORT
  36
  37#define BUS_REQUEST_MAX_NUM                64
  38
  39#define SDIO_CLOCK_FREQUENCY_DEFAULT       25000000
  40#define SDWLAN_ENABLE_DISABLE_TIMEOUT      20
  41#define FLAGS_CARD_ENAB                    0x02
  42#define FLAGS_CARD_IRQ_UNMSK               0x04
  43
  44#define HIF_MBOX_BLOCK_SIZE                HIF_DEFAULT_IO_BLOCK_SIZE
  45#define HIF_MBOX0_BLOCK_SIZE               1
  46#define HIF_MBOX1_BLOCK_SIZE               HIF_MBOX_BLOCK_SIZE
  47#define HIF_MBOX2_BLOCK_SIZE               HIF_MBOX_BLOCK_SIZE
  48#define HIF_MBOX3_BLOCK_SIZE               HIF_MBOX_BLOCK_SIZE
  49
  50struct _HIF_SCATTER_REQ_PRIV;
  51
  52typedef struct bus_request {
  53    struct bus_request *next;       /* link list of available requests */
  54    struct bus_request *inusenext;  /* link list of in use requests */
  55    struct semaphore sem_req;
  56    A_UINT32 address;               /* request data */
  57    A_UCHAR *buffer;
  58    A_UINT32 length;
  59    A_UINT32 request;
  60    void *context;
  61    A_STATUS status;
  62    struct _HIF_SCATTER_REQ_PRIV *pScatterReq;      /* this request is a scatter request */
  63} BUS_REQUEST;
  64
  65struct hif_device {
  66    struct sdio_func *func;
  67    spinlock_t asynclock;
  68    struct task_struct* async_task;             /* task to handle async commands */
  69    struct semaphore sem_async;                 /* wake up for async task */
  70    int    async_shutdown;                      /* stop the async task */
  71    struct completion async_completion;          /* thread completion */
  72    BUS_REQUEST   *asyncreq;                    /* request for async tasklet */
  73    BUS_REQUEST *taskreq;                       /*  async tasklet data */
  74    spinlock_t lock;
  75    BUS_REQUEST *s_busRequestFreeQueue;         /* free list */
  76    BUS_REQUEST busRequest[BUS_REQUEST_MAX_NUM]; /* available bus requests */
  77    void     *claimedContext;
  78    HTC_CALLBACKS htcCallbacks;
  79    A_UINT8     *dma_buffer;
  80    DL_LIST      ScatterReqHead;                /* scatter request list head */
  81    A_BOOL       scatter_enabled;               /* scatter enabled flag */
  82    A_BOOL   is_suspend;
  83    A_BOOL   is_disabled;
  84    atomic_t   irqHandling;
  85    HIF_DEVICE_POWER_CHANGE_TYPE powerConfig;
  86    const struct sdio_device_id *id;
  87};
  88
  89#define HIF_DMA_BUFFER_SIZE (32 * 1024)
  90#define CMD53_FIXED_ADDRESS 1
  91#define CMD53_INCR_ADDRESS  2
  92
  93BUS_REQUEST *hifAllocateBusRequest(HIF_DEVICE *device);
  94void hifFreeBusRequest(HIF_DEVICE *device, BUS_REQUEST *busrequest);
  95void AddToAsyncList(HIF_DEVICE *device, BUS_REQUEST *busrequest);
  96
  97#ifdef HIF_LINUX_MMC_SCATTER_SUPPORT
  98
  99#define MAX_SCATTER_REQUESTS             4
 100#define MAX_SCATTER_ENTRIES_PER_REQ      16
 101#define MAX_SCATTER_REQ_TRANSFER_SIZE    32*1024
 102
 103typedef struct _HIF_SCATTER_REQ_PRIV {
 104    HIF_SCATTER_REQ     *pHifScatterReq;  /* HIF scatter request with allocated entries */   
 105    HIF_DEVICE          *device;          /* this device */
 106    BUS_REQUEST         *busrequest;      /* request associated with request */
 107        /* scatter list for linux */    
 108    struct scatterlist  sgentries[MAX_SCATTER_ENTRIES_PER_REQ];   
 109} HIF_SCATTER_REQ_PRIV;
 110
 111#define ATH_DEBUG_SCATTER  ATH_DEBUG_MAKE_MODULE_MASK(0)
 112
 113A_STATUS SetupHIFScatterSupport(HIF_DEVICE *device, HIF_DEVICE_SCATTER_SUPPORT_INFO *pInfo);
 114void CleanupHIFScatterResources(HIF_DEVICE *device);
 115A_STATUS DoHifReadWriteScatter(HIF_DEVICE *device, BUS_REQUEST *busrequest);
 116
 117#else  // HIF_LINUX_MMC_SCATTER_SUPPORT
 118
 119static inline A_STATUS SetupHIFScatterSupport(HIF_DEVICE *device, HIF_DEVICE_SCATTER_SUPPORT_INFO *pInfo) 
 120{
 121    return A_ENOTSUP;
 122}
 123
 124static inline A_STATUS DoHifReadWriteScatter(HIF_DEVICE *device, BUS_REQUEST *busrequest) 
 125{
 126    return A_ENOTSUP;
 127}
 128
 129#define CleanupHIFScatterResources(d) { }
 130
 131#endif // HIF_LINUX_MMC_SCATTER_SUPPORT
 132
 133#endif // _HIF_INTERNAL_H_
 134
 135