| 1 | /* |
| 2 | * |
| 3 | * Driver for KeyStream, KS7010 based SDIO cards. |
| 4 | * |
| 5 | * ks7010_sdio.h |
| 6 | * $Id: ks7010_sdio.h 1019 2009-09-28 05:41:07Z sekine $ |
| 7 | * |
| 8 | * Copyright (C) 2006-2008 KeyStream Corp. |
| 9 | * Copyright (C) 2009 Renesas Technology Corp. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it undr the terms of the GNU General Public License version 2 as |
| 13 | * published by the Free Sotware Foundation. |
| 14 | */ |
| 15 | #ifndef _KS7010_SDIO_H |
| 16 | #define _KS7010_SDIO_H |
| 17 | |
| 18 | #ifdef DEVICE_ALIGNMENT |
| 19 | #undef DEVICE_ALIGNMENT |
| 20 | #endif |
| 21 | #define DEVICE_ALIGNMENT 32 |
| 22 | |
| 23 | /* SDIO KeyStream vendor and device */ |
| 24 | #define SDIO_VENDOR_ID_KS_CODE_A 0x005b |
| 25 | #define SDIO_VENDOR_ID_KS_CODE_B 0x0023 |
| 26 | #define SDIO_DEVICE_ID_KS_7010 0x7910 |
| 27 | |
| 28 | /* Read Status Register */ |
| 29 | #define READ_STATUS 0x000000 |
| 30 | #define READ_STATUS_BUSY 0 |
| 31 | #define READ_STATUS_IDLE 1 |
| 32 | |
| 33 | /* Read Index Register */ |
| 34 | #define READ_INDEX 0x000004 |
| 35 | |
| 36 | /* Read Data Size Register */ |
| 37 | #define READ_DATA_SIZE 0x000008 |
| 38 | |
| 39 | /* Write Status Register */ |
| 40 | #define WRITE_STATUS 0x00000C |
| 41 | #define WRITE_STATUS_BUSY 0 |
| 42 | #define WRITE_STATUS_IDLE 1 |
| 43 | |
| 44 | /* Write Index Register */ |
| 45 | #define WRITE_INDEX 0x000010 |
| 46 | |
| 47 | /* Write Status/Read Data Size Register |
| 48 | * for network packet (less than 2048 bytes data) |
| 49 | */ |
| 50 | #define WSTATUS_RSIZE 0x000014 |
| 51 | #define WSTATUS_MASK 0x80 /* Write Status Register value */ |
| 52 | #define RSIZE_MASK 0x7F /* Read Data Size Register value [10:4] */ |
| 53 | |
| 54 | /* ARM to SD interrupt Enable */ |
| 55 | #define INT_ENABLE 0x000020 |
| 56 | /* ARM to SD interrupt Pending */ |
| 57 | #define INT_PENDING 0x000024 |
| 58 | |
| 59 | #define INT_GCR_B (1<<7) |
| 60 | #define INT_GCR_A (1<<6) |
| 61 | #define INT_WRITE_STATUS (1<<5) |
| 62 | #define INT_WRITE_INDEX (1<<4) |
| 63 | #define INT_WRITE_SIZE (1<<3) |
| 64 | #define INT_READ_STATUS (1<<2) |
| 65 | #define INT_READ_INDEX (1<<1) |
| 66 | #define INT_READ_SIZE (1<<0) |
| 67 | |
| 68 | /* General Communication Register A */ |
| 69 | #define GCR_A 0x000028 |
| 70 | #define GCR_A_INIT 0 |
| 71 | #define GCR_A_REMAP 1 |
| 72 | #define GCR_A_RUN 2 |
| 73 | |
| 74 | /* General Communication Register B */ |
| 75 | #define GCR_B 0x00002C |
| 76 | #define GCR_B_ACTIVE 0 |
| 77 | #define GCR_B_DOZE 1 |
| 78 | |
| 79 | /* Wakeup Register */ |
| 80 | /* #define WAKEUP 0x008104 */ |
| 81 | /* #define WAKEUP_REQ 0x00 */ |
| 82 | #define WAKEUP 0x008018 |
| 83 | #define WAKEUP_REQ 0x5a |
| 84 | |
| 85 | /* AHB Data Window 0x010000-0x01FFFF */ |
| 86 | #define DATA_WINDOW 0x010000 |
| 87 | #define WINDOW_SIZE 64*1024 |
| 88 | |
| 89 | #define KS7010_IRAM_ADDRESS 0x06000000 |
| 90 | |
| 91 | |
| 92 | /* |
| 93 | * struct define |
| 94 | */ |
| 95 | struct hw_info_t { |
| 96 | struct ks_sdio_card *sdio_card; |
| 97 | struct completion ks7010_sdio_wait; |
| 98 | struct workqueue_struct *ks7010sdio_wq; |
| 99 | struct workqueue_struct *ks7010sdio_init; |
| 100 | struct work_struct init_task; |
| 101 | struct delayed_work rw_wq; |
| 102 | unsigned char *read_buf; |
| 103 | struct tasklet_struct rx_bh_task; |
| 104 | }; |
| 105 | |
| 106 | struct ks_sdio_packet { |
| 107 | struct ks_sdio_packet *next; |
| 108 | u16 nb; |
| 109 | u8 buffer[0] __attribute__((aligned(4))); |
| 110 | }; |
| 111 | |
| 112 | |
| 113 | struct ks_sdio_card { |
| 114 | struct sdio_func *func; |
| 115 | struct ks_wlan_private *priv; |
| 116 | int model; |
| 117 | const char *firmware; |
| 118 | spinlock_t lock; |
| 119 | }; |
| 120 | |
| 121 | |
| 122 | |
| 123 | /* Tx Device struct */ |
| 124 | #define TX_DEVICE_BUFF_SIZE 1024 |
| 125 | |
| 126 | struct tx_device_buffer { |
| 127 | unsigned char *sendp; /* pointer of send req data */ |
| 128 | unsigned int size; |
| 129 | void (*complete_handler)(void *arg1, void *arg2); |
| 130 | void *arg1; |
| 131 | void *arg2; |
| 132 | }; |
| 133 | |
| 134 | struct tx_device{ |
| 135 | struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE]; |
| 136 | unsigned int qhead; /* tx buffer queue first pointer */ |
| 137 | unsigned int qtail; /* tx buffer queue last pointer */ |
| 138 | spinlock_t tx_dev_lock; |
| 139 | }; |
| 140 | |
| 141 | /* Rx Device struct */ |
| 142 | #define RX_DATA_SIZE (2 + 2 + 2347 + 1) |
| 143 | #define RX_DEVICE_BUFF_SIZE 32 |
| 144 | |
| 145 | struct rx_device_buffer { |
| 146 | unsigned char data[RX_DATA_SIZE]; |
| 147 | unsigned int size; |
| 148 | }; |
| 149 | |
| 150 | struct rx_device{ |
| 151 | struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE]; |
| 152 | unsigned int qhead; /* rx buffer queue first pointer */ |
| 153 | unsigned int qtail; /* rx buffer queue last pointer */ |
| 154 | spinlock_t rx_dev_lock; |
| 155 | }; |
| 156 | #ifndef NO_FIRMWARE_CLASS |
| 157 | #define ROM_FILE "ks7010sd.rom" |
| 158 | #define CFG_FILE "ks79xx.cfg" |
| 159 | #else |
| 160 | #define ROM_FILE "/lib/firmware/ks7010sd.rom" |
| 161 | #define CFG_FILE "/lib/firmware/ks79xx.cfg" |
| 162 | #endif |
| 163 | #define KS_WLAN_DRIVER_VERSION_INFO "ks7010 sdio linux 007 ["__DATE__" "__TIME__"]" |
| 164 | |
| 165 | #endif /* _KS7010_SDIO_H */ |
| 166 | |