/*HEADER**********************************************************************
Copyright (c)
All rights reserved
This software embodies materials and concepts that are confidential to Redpine
Signals and is made available solely pursuant to the terms of a written license
agreement with Redpine Signals

Project name : Ganges
Module name  : LINUX SDIO driver
File Name    : ganges_nic.h

File Description:

List of functions:

Author :

Rev History:
Ver  By    date       Description
---------------------------------------------------------
1.1  Anji  1 Aug06     Initial version
1.2  Anji  15 Aug06    WiFi fixes from PP driver added
1.3  Anji  26 Aug06    SDIO clock parameter added in adapter struct
---------------------------------------------------------
*END**************************************************************************/
#ifndef __GANGES_NIC__
#define __GANGES_NIC__

#include <linux/netdevice.h>
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/etherdevice.h>
#include <linux/if.h>
#include <linux/wireless.h>
#include <linux/version.h>
#include <linux/vmalloc.h>

#include "../ganges_faf.h"
#include "ganges_client.h"

#ifdef RSI_CONFIG_CFG80211
#include <net/cfg80211.h>
#endif

#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18))&& \
   (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)))
#include <linux/sdio/ctsystem.h>
#include <linux/sdio/sdio_busdriver.h>
#include <linux/sdio/_sdio_defs.h>
#include <linux/sdio/sdio_lib.h>
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
#include <linux/mmc/card.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/host.h>
#include <linux/mmc/sdio_func.h>
#include <linux/mmc/sdio_ids.h>
#include <linux/mmc/sdio.h>
#include <linux/mmc/sd.h>
#include <linux/mmc/sdio_ids.h>
#endif

#define TEXT(arg) KERN_DEBUG arg
/* Kernel version between and including a & b */
#define KERNEL_VERSION_BTWN_2_6_(a,b) \
 ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,a)) && \
  (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,b)))

#define KERNEL_VERSION_EQUALS_2_6_(a) \
 (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,a))

/* Kernel version greater than equals */
#define KERNEL_VERSION_GREATER_THAN_2_6_(a)  \
 (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,a))

#define DEVINIT                       __devinit
#define DEVEXIT                       __devexit
#define INIT                          __init
#define EXIT                          __exit

typedef struct _RSI_ADAPTER
{
  struct net_device *dev;
#ifdef RSI_CONFIG_CFG80211
  struct wireless_dev *wdev;
#endif
  struct iw_statistics  iw_stats;
  struct net_device_stats stats;
  struct sk_buff_head EapPacket;
  struct sk_buff_head list[4];
  struct workqueue_struct *workqueue;
  void*  intr_read_sem;
  void*  lock_irq;
  void*  spi_dev_sem;
  void*  txrx_sem;
  void*  transmit_event;
  void*  PwrSaveEvent;
  void*  StatsEvent;
  void*  ReadEvent;
  void*  PerEvent;
  void*  RSSIEvent;

#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18))&& \
   (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)))
  PSDDEVICE pDevice;
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
  struct  sdio_func *pfunction;
  struct task_struct    *in_sdio_litefi_irq;
#endif
  struct work_struct handler;
  struct task_struct *txTask;
  struct completion txThreadComplete;
  PGANGES_CLIENT gangesClient;
} RSI_ADAPTER, *PRSI_ADAPTER;

/* prototypes */
void ganges_lock_bh(spinlock_t *lock);
void ganges_unlock_bh(spinlock_t *lock);
void ganges_lock_irqsave(spinlock_t *lock,unsigned long flags);
void ganges_unlock_irqrestore(spinlock_t *lock,unsigned long flags);
struct sk_buff *ganges_alloc_skb(UINT32);
struct sk_buff * ganges_intf_alloc_skb(UINT32 Len);
PUCHAR ganges_skb_put(PUCHAR *skb, UINT32 len);
VOID ganges_queue_tail(PUCHAR *skbhead, PUCHAR *newskb);
netbuf_ctrl_block_t* ganges_rcv_ccx_pkt(PGANGES_CLIENT Adapter,
                PUCHAR DataRcvPacket, UINT32 pktLen, UINT8 flag);
VOID   ganges_kfree_skb(struct sk_buff *skb);
struct net_device* ganges_allocdev(INT32 sizeof_priv);
INT32  ganges_registerdev( struct net_device *dev );
VOID   ganges_unregisterdev(struct net_device *dev);
INT32  ganges_open(struct net_device *dev);
INT32  ganges_stop(struct net_device *dev);
struct net_device_stats *ganges_get_stats( struct net_device *dev);
#ifdef RSI_CONFIG_CFG80211
struct net_device* ganges_netdevice_op(struct sdio_func *pfunction);
#else
struct net_device* ganges_netdevice_op(struct device *pdev);
#endif
void * ganges_netdevice_op2 ( PRSI_ADAPTER Adapter );
int ganges_register_driver(void);
void ganges_unregister_driver(void);
int ganges_remove(void);
#endif
