Commit cdf6ecc5 authored by Wolfram Sang's avatar Wolfram Sang Committed by Greg Kroah-Hartman

staging: ks7010: indent ks7010_sdio.c

Unlike the previous patches which are plain indent outcomes, this has
some manual fixups to be not overly strict with the 80 char limit.
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 79c2df58
...@@ -30,31 +30,32 @@ ...@@ -30,31 +30,32 @@
static int reg_net = 0; static int reg_net = 0;
static const struct sdio_device_id if_sdio_ids[] = { static const struct sdio_device_id if_sdio_ids[] = {
{ SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010) }, {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010)},
{ SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010) }, {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010)},
{ /* all zero */ } { /* all zero */ }
}; };
struct ks_sdio_model { struct ks_sdio_model {
int model; int model;
const char *firmware; const char *firmware;
}; };
static struct ks_sdio_model ks_sdio_models[] = { static struct ks_sdio_model ks_sdio_models[] = {
{ {
/* ks7010 */ /* ks7010 */
.model = 0x10, .model = 0x10,
.firmware = "ks7010sd.rom", .firmware = "ks7010sd.rom",
}, },
}; };
static int ks7910_sdio_probe(struct sdio_func *function, const struct sdio_device_id *device); static int ks7910_sdio_probe(struct sdio_func *function,
const struct sdio_device_id *device);
static void ks7910_sdio_remove(struct sdio_func *function); static void ks7910_sdio_remove(struct sdio_func *function);
static void ks7010_rw_function(struct work_struct *work); static void ks7010_rw_function(struct work_struct *work);
static int ks7010_sdio_read( struct ks_wlan_private *priv, unsigned int address, static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address,
unsigned char *buffer, int length ); unsigned char *buffer, int length);
static int ks7010_sdio_write( struct ks_wlan_private *priv, unsigned int address, static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,
unsigned char *buffer, int length ); unsigned char *buffer, int length);
/* macro */ /* macro */
#define inc_txqhead(priv) \ #define inc_txqhead(priv) \
...@@ -79,25 +80,25 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) ...@@ -79,25 +80,25 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)
DPRINTK(4, "\n"); DPRINTK(4, "\n");
/* clear request */ /* clear request */
atomic_set(&priv->sleepstatus.doze_request,0); atomic_set(&priv->sleepstatus.doze_request, 0);
if( atomic_read(&priv->sleepstatus.status) == 0){ if (atomic_read(&priv->sleepstatus.status) == 0) {
rw_data = GCR_B_DOZE; rw_data = GCR_B_DOZE;
retval = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); retval =
if(retval){ ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data));
if (retval) {
DPRINTK(1, " error : GCR_B=%02X\n", rw_data); DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
goto out; goto out;
} }
DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data); DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data);
DPRINTK(3,"sleep_mode=SLP_SLEEP\n"); DPRINTK(3, "sleep_mode=SLP_SLEEP\n");
atomic_set(&priv->sleepstatus.status, 1); atomic_set(&priv->sleepstatus.status, 1);
priv->last_doze = jiffies; priv->last_doze = jiffies;
} } else {
else{ DPRINTK(1, "sleep_mode=%d\n", priv->sleep_mode);
DPRINTK(1,"sleep_mode=%d\n",priv->sleep_mode);
} }
out: out:
priv->sleep_mode = atomic_read(&priv->sleepstatus.status); priv->sleep_mode = atomic_read(&priv->sleepstatus.status);
return; return;
} }
...@@ -110,110 +111,126 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv) ...@@ -110,110 +111,126 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)
DPRINTK(4, "\n"); DPRINTK(4, "\n");
/* clear request */ /* clear request */
atomic_set(&priv->sleepstatus.wakeup_request,0); atomic_set(&priv->sleepstatus.wakeup_request, 0);
if( atomic_read(&priv->sleepstatus.status) == 1){ if (atomic_read(&priv->sleepstatus.status) == 1) {
rw_data = WAKEUP_REQ; rw_data = WAKEUP_REQ;
retval = ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); retval =
if(retval){ ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data));
if (retval) {
DPRINTK(1, " error : WAKEUP=%02X\n", rw_data); DPRINTK(1, " error : WAKEUP=%02X\n", rw_data);
goto out; goto out;
} }
DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data); DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data);
atomic_set(&priv->sleepstatus.status, 0); atomic_set(&priv->sleepstatus.status, 0);
priv->last_wakeup = jiffies; priv->last_wakeup = jiffies;
++priv->wakeup_count; ++priv->wakeup_count;
} } else {
else{ DPRINTK(1, "sleep_mode=%d\n", priv->sleep_mode);
DPRINTK(1,"sleep_mode=%d\n",priv->sleep_mode);
} }
out: out:
priv->sleep_mode = atomic_read(&priv->sleepstatus.status); priv->sleep_mode = atomic_read(&priv->sleepstatus.status);
return; return;
} }
void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv) void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)
{ {
unsigned char rw_data; unsigned char rw_data;
int retval; int retval;
DPRINTK(4, "\n"); DPRINTK(4, "\n");
if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
rw_data = WAKEUP_REQ; rw_data = WAKEUP_REQ;
retval = ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); retval =
if(retval){ ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data));
if (retval) {
DPRINTK(1, " error : WAKEUP=%02X\n", rw_data); DPRINTK(1, " error : WAKEUP=%02X\n", rw_data);
} }
DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data); DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data);
priv->last_wakeup = jiffies; priv->last_wakeup = jiffies;
++priv->wakeup_count; ++priv->wakeup_count;
} } else {
else{ DPRINTK(1, "psstatus=%d\n",
DPRINTK(1,"psstatus=%d\n",atomic_read(&priv->psstatus.status)); atomic_read(&priv->psstatus.status));
} }
} }
int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) int _ks_wlan_hw_power_save(struct ks_wlan_private *priv)
{ {
int rc=0; int rc = 0;
unsigned char rw_data; unsigned char rw_data;
int retval; int retval;
if(priv->reg.powermgt == POWMGT_ACTIVE_MODE) if (priv->reg.powermgt == POWMGT_ACTIVE_MODE)
return rc; return rc;
if(priv->reg.operation_mode == MODE_INFRASTRUCTURE && if (priv->reg.operation_mode == MODE_INFRASTRUCTURE &&
(priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ (priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
//DPRINTK(1,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status)); //DPRINTK(1,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status));
if (priv->dev_state == DEVICE_STATE_SLEEP) { if (priv->dev_state == DEVICE_STATE_SLEEP) {
switch(atomic_read(&priv->psstatus.status)){ switch (atomic_read(&priv->psstatus.status)) {
case PS_SNOOZE: /* 4 */ case PS_SNOOZE: /* 4 */
break; break;
default: default:
DPRINTK(5,"\n\ DPRINTK(5, "\npsstatus.status=%d\npsstatus.confirm_wait=%d\npsstatus.snooze_guard=%d\ncnt_txqbody=%d\n",
psstatus.status=%d\n\ atomic_read(&priv->psstatus.status),
psstatus.confirm_wait=%d\n\ atomic_read(&priv->psstatus.confirm_wait),
psstatus.snooze_guard=%d\n\ atomic_read(&priv->psstatus.snooze_guard),
cnt_txqbody=%d\n", cnt_txqbody(priv));
atomic_read(&priv->psstatus.status),
atomic_read(&priv->psstatus.confirm_wait), if (!atomic_read(&priv->psstatus.confirm_wait)
atomic_read(&priv->psstatus.snooze_guard), && !atomic_read(&priv->psstatus.snooze_guard)
cnt_txqbody(priv)); && !cnt_txqbody(priv)) {
retval =
if(!atomic_read(&priv->psstatus.confirm_wait)&& ks7010_sdio_read(priv, INT_PENDING,
!atomic_read(&priv->psstatus.snooze_guard)&& &rw_data,
!cnt_txqbody(priv)){ sizeof(rw_data));
retval = ks7010_sdio_read(priv, INT_PENDING, &rw_data, sizeof(rw_data)); if (retval) {
if(retval){ DPRINTK(1,
DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data); " error : INT_PENDING=%02X\n",
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); rw_data);
break; queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
} &priv->ks_wlan_hw.rw_wq, 1);
if(!rw_data){
rw_data = GCR_B_DOZE;
retval = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data));
if(retval){
DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1);
break; break;
} }
DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data); if (!rw_data) {
atomic_set(&priv->psstatus.status, PS_SNOOZE); rw_data = GCR_B_DOZE;
DPRINTK(3,"psstatus.status=PS_SNOOZE\n"); retval =
} ks7010_sdio_write(priv,
else{ GCR_B,
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); &rw_data,
sizeof(rw_data));
if (retval) {
DPRINTK(1,
" error : GCR_B=%02X\n",
rw_data);
queue_delayed_work
(priv->ks_wlan_hw.ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq, 1);
break;
}
DPRINTK(4,
"PMG SET!! : GCR_B=%02X\n",
rw_data);
atomic_set(&priv->psstatus.
status, PS_SNOOZE);
DPRINTK(3,
"psstatus.status=PS_SNOOZE\n");
} else {
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq, 1);
}
} else {
queue_delayed_work(priv->ks_wlan_hw.
ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq,
0);
} }
break;
} }
else{
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0);
}
break;
} }
}
} }
...@@ -222,7 +239,8 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) ...@@ -222,7 +239,8 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv)
int ks_wlan_hw_power_save(struct ks_wlan_private *priv) int ks_wlan_hw_power_save(struct ks_wlan_private *priv)
{ {
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq, 1);
return 0; return 0;
} }
...@@ -234,16 +252,16 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, ...@@ -234,16 +252,16 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address,
card = priv->ks_wlan_hw.sdio_card; card = priv->ks_wlan_hw.sdio_card;
if (length == 1) /* CMD52 */ if (length == 1) /* CMD52 */
*buffer = sdio_readb(card->func, address, &rc); *buffer = sdio_readb(card->func, address, &rc);
else /* CMD53 multi-block transfer */ else /* CMD53 multi-block transfer */
rc = sdio_memcpy_fromio(card->func, buffer, address, length); rc = sdio_memcpy_fromio(card->func, buffer, address, length);
if(rc != 0){ if (rc != 0) {
printk("sdio error erorr=%d size=%d\n", rc, length); printk("sdio error erorr=%d size=%d\n", rc, length);
++priv->sdio_error_count; ++priv->sdio_error_count;
}else{ } else {
priv->sdio_error_count=0; priv->sdio_error_count = 0;
} }
return rc; return rc;
...@@ -257,40 +275,42 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, ...@@ -257,40 +275,42 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,
card = priv->ks_wlan_hw.sdio_card; card = priv->ks_wlan_hw.sdio_card;
if (length == 1) /* CMD52 */ if (length == 1) /* CMD52 */
sdio_writeb(card->func, *buffer, (unsigned int) address, &rc); sdio_writeb(card->func, *buffer, (unsigned int)address, &rc);
else /* CMD53 */ else /* CMD53 */
rc = sdio_memcpy_toio(card->func, (unsigned int) address, buffer, length); rc = sdio_memcpy_toio(card->func, (unsigned int)address, buffer,
length);
if(rc != 0){ if (rc != 0) {
printk("sdio error erorr=%d size=%d\n", rc, length); printk("sdio error erorr=%d size=%d\n", rc, length);
++priv->sdio_error_count; ++priv->sdio_error_count;
}else{ } else {
priv->sdio_error_count=0; priv->sdio_error_count = 0;
} }
return rc; return rc;
} }
static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, unsigned long size, static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,
void (*complete_handler)(void *arg1, void *arg2), unsigned long size,
void *arg1, void *arg2 ) void (*complete_handler) (void *arg1, void *arg2),
void *arg1, void *arg2)
{ {
struct tx_device_buffer *sp; struct tx_device_buffer *sp;
if (priv->dev_state < DEVICE_STATE_BOOT) { if (priv->dev_state < DEVICE_STATE_BOOT) {
kfree(p); kfree(p);
if (complete_handler != NULL) if (complete_handler != NULL)
(*complete_handler)(arg1, arg2); (*complete_handler) (arg1, arg2);
return 1; return 1;
} }
if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) { if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) {
/* in case of buffer overflow */ /* in case of buffer overflow */
DPRINTK(1,"tx buffer overflow\n"); DPRINTK(1, "tx buffer overflow\n");
kfree(p); kfree(p);
if (complete_handler != NULL) if (complete_handler != NULL)
(*complete_handler)(arg1, arg2); (*complete_handler) (arg1, arg2);
return 1; return 1;
} }
...@@ -306,29 +326,31 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, unsigne ...@@ -306,29 +326,31 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, unsigne
} }
/* write data */ /* write data */
static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, unsigned long size ) static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
unsigned long size)
{ {
int rc,retval; int rc, retval;
unsigned char rw_data; unsigned char rw_data;
struct hostif_hdr *hdr; struct hostif_hdr *hdr;
hdr = (struct hostif_hdr *)buffer; hdr = (struct hostif_hdr *)buffer;
rc=0; rc = 0;
DPRINTK(4,"size=%d\n", hdr->size); DPRINTK(4, "size=%d\n", hdr->size);
if(hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event){ if (hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event) {
DPRINTK(1,"unknown event=%04X\n",hdr->event); DPRINTK(1, "unknown event=%04X\n", hdr->event);
return 0; return 0;
} }
retval = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size); retval = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size);
if(retval){ if (retval) {
DPRINTK(1, " write error : retval=%d\n", retval); DPRINTK(1, " write error : retval=%d\n", retval);
return -4; return -4;
} }
rw_data = WRITE_STATUS_BUSY; rw_data = WRITE_STATUS_BUSY;
retval = ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data)); retval =
if(retval){ ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data));
if (retval) {
DPRINTK(1, " error : WRITE_STATUS=%02X\n", rw_data); DPRINTK(1, " error : WRITE_STATUS=%02X\n", rw_data);
return -3; return -3;
} }
...@@ -339,74 +361,80 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, ...@@ -339,74 +361,80 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer,
static void tx_device_task(void *dev) static void tx_device_task(void *dev)
{ {
struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;
struct tx_device_buffer *sp; struct tx_device_buffer *sp;
int rc = 0; int rc = 0;
DPRINTK(4, "\n"); DPRINTK(4, "\n");
if(cnt_txqbody(priv)>0 && atomic_read(&priv->psstatus.status) != PS_SNOOZE){ if (cnt_txqbody(priv) > 0
&& atomic_read(&priv->psstatus.status) != PS_SNOOZE) {
sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];
if(priv->dev_state >= DEVICE_STATE_BOOT){ if (priv->dev_state >= DEVICE_STATE_BOOT) {
rc = write_to_device(priv, sp->sendp, sp->size); rc = write_to_device(priv, sp->sendp, sp->size);
if(rc){ if (rc) {
DPRINTK(1, "write_to_device error !!(%d)\n", rc); DPRINTK(1, "write_to_device error !!(%d)\n",
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); rc);
queue_delayed_work(priv->ks_wlan_hw.
ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq, 1);
return; return;
} }
} }
kfree(sp->sendp); /* allocated memory free */ kfree(sp->sendp); /* allocated memory free */
if(sp->complete_handler != NULL) /* TX Complete */ if (sp->complete_handler != NULL) /* TX Complete */
(*sp->complete_handler)(sp->arg1, sp->arg2); (*sp->complete_handler) (sp->arg1, sp->arg2);
inc_txqhead(priv); inc_txqhead(priv);
if(cnt_txqbody(priv)>0){ if (cnt_txqbody(priv) > 0) {
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq, 0);
} }
} }
return; return;
} }
int ks_wlan_hw_tx( struct ks_wlan_private *priv, void *p, unsigned long size, int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,
void (*complete_handler)(void *arg1, void *arg2), void (*complete_handler) (void *arg1, void *arg2),
void *arg1, void *arg2 ) void *arg1, void *arg2)
{ {
int result=0; int result = 0;
struct hostif_hdr *hdr; struct hostif_hdr *hdr;
hdr = (struct hostif_hdr *)p; hdr = (struct hostif_hdr *)p;
if(hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event){ if (hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event) {
DPRINTK(1,"unknown event=%04X\n",hdr->event); DPRINTK(1, "unknown event=%04X\n", hdr->event);
return 0; return 0;
} }
/* add event to hostt buffer */ /* add event to hostt buffer */
priv->hostt.buff[priv->hostt.qtail] = hdr->event; priv->hostt.buff[priv->hostt.qtail] = hdr->event;
priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE;
DPRINTK(4, "event=%04X\n",hdr->event); DPRINTK(4, "event=%04X\n", hdr->event);
spin_lock(&priv->tx_dev.tx_dev_lock); spin_lock(&priv->tx_dev.tx_dev_lock);
result = enqueue_txdev(priv, p, size, complete_handler, arg1, arg2); result = enqueue_txdev(priv, p, size, complete_handler, arg1, arg2);
spin_unlock(&priv->tx_dev.tx_dev_lock); spin_unlock(&priv->tx_dev.tx_dev_lock);
if(cnt_txqbody(priv)>0){ if (cnt_txqbody(priv) > 0) {
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq, 0);
} }
return result; return result;
} }
static void rx_event_task(unsigned long dev) static void rx_event_task(unsigned long dev)
{ {
struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;
struct rx_device_buffer *rp; struct rx_device_buffer *rp;
DPRINTK(4,"\n"); DPRINTK(4, "\n");
if(cnt_rxqbody(priv) > 0 && priv->dev_state >= DEVICE_STATE_BOOT){ if (cnt_rxqbody(priv) > 0 && priv->dev_state >= DEVICE_STATE_BOOT) {
rp = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qhead]; rp = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qhead];
hostif_receive(priv, rp->data, rp->size); hostif_receive(priv, rp->data, rp->size);
inc_rxqhead(priv); inc_rxqhead(priv);
if(cnt_rxqbody(priv) > 0){ if (cnt_rxqbody(priv) > 0) {
tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task); tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task);
} }
} }
...@@ -420,35 +448,40 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) ...@@ -420,35 +448,40 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
int retval; int retval;
struct rx_device_buffer *rx_buffer; struct rx_device_buffer *rx_buffer;
struct hostif_hdr *hdr; struct hostif_hdr *hdr;
unsigned char read_status; unsigned char read_status;
unsigned short event=0; unsigned short event = 0;
DPRINTK(4,"\n"); DPRINTK(4, "\n");
/* receive data */ /* receive data */
if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE-1)) { if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE - 1)) {
/* in case of buffer overflow */ /* in case of buffer overflow */
DPRINTK(1,"rx buffer overflow \n"); DPRINTK(1, "rx buffer overflow \n");
goto error_out; goto error_out;
} }
rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail]; rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail];
retval = ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0], hif_align_size(size)); retval =
if(retval){ ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0],
hif_align_size(size));
if (retval) {
goto error_out; goto error_out;
} }
/* length check */ /* length check */
if(size > 2046 || size == 0){ if (size > 2046 || size == 0) {
#ifdef KS_WLAN_DEBUG #ifdef KS_WLAN_DEBUG
if (KS_WLAN_DEBUG > 5) if (KS_WLAN_DEBUG > 5)
print_hex_dump_bytes("INVALID DATA dump: ", DUMP_PREFIX_OFFSET, print_hex_dump_bytes("INVALID DATA dump: ",
DUMP_PREFIX_OFFSET,
rx_buffer->data, 32); rx_buffer->data, 32);
#endif #endif
/* rx_status update */ /* rx_status update */
read_status = READ_STATUS_IDLE; read_status = READ_STATUS_IDLE;
retval = ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); retval =
if(retval){ ks7010_sdio_write(priv, READ_STATUS, &read_status,
sizeof(read_status));
if (retval) {
DPRINTK(1, " error : READ_STATUS=%02X\n", read_status); DPRINTK(1, " error : READ_STATUS=%02X\n", read_status);
} }
goto error_out; goto error_out;
...@@ -461,14 +494,16 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) ...@@ -461,14 +494,16 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
/* read status update */ /* read status update */
read_status = READ_STATUS_IDLE; read_status = READ_STATUS_IDLE;
retval = ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); retval =
if(retval){ ks7010_sdio_write(priv, READ_STATUS, &read_status,
sizeof(read_status));
if (retval) {
DPRINTK(1, " error : READ_STATUS=%02X\n", read_status); DPRINTK(1, " error : READ_STATUS=%02X\n", read_status);
} }
DPRINTK(4, "READ_STATUS=%02X\n", read_status); DPRINTK(4, "READ_STATUS=%02X\n", read_status);
if(atomic_read(&priv->psstatus.confirm_wait)){ if (atomic_read(&priv->psstatus.confirm_wait)) {
if(IS_HIF_CONF(event)){ if (IS_HIF_CONF(event)) {
DPRINTK(4, "IS_HIF_CONF true !!\n"); DPRINTK(4, "IS_HIF_CONF true !!\n");
atomic_dec(&priv->psstatus.confirm_wait); atomic_dec(&priv->psstatus.confirm_wait);
} }
...@@ -477,7 +512,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) ...@@ -477,7 +512,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
/* rx_event_task((void *)priv); */ /* rx_event_task((void *)priv); */
tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task); tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task);
error_out: error_out:
return; return;
} }
...@@ -491,71 +526,74 @@ static void ks7010_rw_function(struct work_struct *work) ...@@ -491,71 +526,74 @@ static void ks7010_rw_function(struct work_struct *work)
hw = container_of(work, struct hw_info_t, rw_wq.work); hw = container_of(work, struct hw_info_t, rw_wq.work);
priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw); priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw);
DPRINTK(4,"\n"); DPRINTK(4, "\n");
/* wiat after DOZE */ /* wiat after DOZE */
if(time_after(priv->last_doze + ((30*HZ)/1000), jiffies )){ if (time_after(priv->last_doze + ((30 * HZ) / 1000), jiffies)) {
DPRINTK(4, "wait after DOZE \n"); DPRINTK(4, "wait after DOZE \n");
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq, 1);
return; return;
} }
/* wiat after WAKEUP */ /* wiat after WAKEUP */
while(time_after(priv->last_wakeup + ((30*HZ)/1000), jiffies )){ while (time_after(priv->last_wakeup + ((30 * HZ) / 1000), jiffies)) {
DPRINTK(4, "wait after WAKEUP \n"); DPRINTK(4, "wait after WAKEUP \n");
/* queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, /* queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq,
(priv->last_wakeup + ((30*HZ)/1000) - jiffies));*/ (priv->last_wakeup + ((30*HZ)/1000) - jiffies));*/
printk("wake: %lu %lu\n", priv->last_wakeup + (30* HZ)/1000, jiffies); printk("wake: %lu %lu\n", priv->last_wakeup + (30 * HZ) / 1000,
jiffies);
msleep(30); msleep(30);
} }
sdio_claim_host(priv->ks_wlan_hw.sdio_card->func); sdio_claim_host(priv->ks_wlan_hw.sdio_card->func);
/* power save wakeup */ /* power save wakeup */
if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
if(cnt_txqbody(priv)>0){ if (cnt_txqbody(priv) > 0) {
ks_wlan_hw_wakeup_request(priv); ks_wlan_hw_wakeup_request(priv);
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq, 1);
} }
goto err_out; goto err_out;
} }
/* sleep mode doze */ /* sleep mode doze */
if(atomic_read(&priv->sleepstatus.doze_request)==1){ if (atomic_read(&priv->sleepstatus.doze_request) == 1) {
ks_wlan_hw_sleep_doze_request(priv); ks_wlan_hw_sleep_doze_request(priv);
goto err_out; goto err_out;
} }
/* sleep mode wakeup */ /* sleep mode wakeup */
if(atomic_read(&priv->sleepstatus.wakeup_request)==1){ if (atomic_read(&priv->sleepstatus.wakeup_request) == 1) {
ks_wlan_hw_sleep_wakeup_request(priv); ks_wlan_hw_sleep_wakeup_request(priv);
goto err_out; goto err_out;
} }
/* read (WriteStatus/ReadDataSize FN1:00_0014) */ /* read (WriteStatus/ReadDataSize FN1:00_0014) */
retval = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data)); retval =
if(retval){ ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data));
DPRINTK(1, " error : WSTATUS_RSIZE=%02X psstatus=%d\n", rw_data,atomic_read(&priv->psstatus.status)); if (retval) {
DPRINTK(1, " error : WSTATUS_RSIZE=%02X psstatus=%d\n", rw_data,
atomic_read(&priv->psstatus.status));
goto err_out; goto err_out;
} }
DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data); DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data);
if(rw_data&RSIZE_MASK){ /* Read schedule */ if (rw_data & RSIZE_MASK) { /* Read schedule */
ks_wlan_hw_rx((void *)priv, (uint16_t)(((rw_data&RSIZE_MASK)<<4))); ks_wlan_hw_rx((void *)priv,
(uint16_t) (((rw_data & RSIZE_MASK) << 4)));
} }
if((rw_data&WSTATUS_MASK)){ if ((rw_data & WSTATUS_MASK)) {
tx_device_task((void *)priv); tx_device_task((void *)priv);
} }
_ks_wlan_hw_power_save(priv); _ks_wlan_hw_power_save(priv);
err_out: err_out:
sdio_release_host(priv->ks_wlan_hw.sdio_card->func); sdio_release_host(priv->ks_wlan_hw.sdio_card->func);
return; return;
} }
static void ks_sdio_interrupt(struct sdio_func *func) static void ks_sdio_interrupt(struct sdio_func *func)
{ {
int retval; int retval;
...@@ -567,10 +605,12 @@ static void ks_sdio_interrupt(struct sdio_func *func) ...@@ -567,10 +605,12 @@ static void ks_sdio_interrupt(struct sdio_func *func)
priv = card->priv; priv = card->priv;
DPRINTK(4, "\n"); DPRINTK(4, "\n");
if(priv->dev_state >= DEVICE_STATE_BOOT){ if (priv->dev_state >= DEVICE_STATE_BOOT) {
retval = ks7010_sdio_read(priv, INT_PENDING, &status, sizeof(status)); retval =
if(retval){ ks7010_sdio_read(priv, INT_PENDING, &status,
DPRINTK(1, "read INT_PENDING Failed!!(%d)\n",retval); sizeof(status));
if (retval) {
DPRINTK(1, "read INT_PENDING Failed!!(%d)\n", retval);
goto intr_out; goto intr_out;
} }
DPRINTK(4, "INT_PENDING=%02X\n", rw_data); DPRINTK(4, "INT_PENDING=%02X\n", rw_data);
...@@ -580,70 +620,89 @@ static void ks_sdio_interrupt(struct sdio_func *func) ...@@ -580,70 +620,89 @@ static void ks_sdio_interrupt(struct sdio_func *func)
/* read (General Communication B register) */ /* read (General Communication B register) */
/* bit5 -> Write Status Idle */ /* bit5 -> Write Status Idle */
/* bit2 -> Read Status Busy */ /* bit2 -> Read Status Busy */
if(status&INT_GCR_B || atomic_read(&priv->psstatus.status)==PS_SNOOZE){ if (status & INT_GCR_B
retval = ks7010_sdio_read(priv, GCR_B, &rw_data, sizeof(rw_data)); || atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
if(retval){ retval =
ks7010_sdio_read(priv, GCR_B, &rw_data,
sizeof(rw_data));
if (retval) {
DPRINTK(1, " error : GCR_B=%02X\n", rw_data); DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
goto intr_out; goto intr_out;
} }
/* DPRINTK(1, "GCR_B=%02X\n", rw_data); */ /* DPRINTK(1, "GCR_B=%02X\n", rw_data); */
if(rw_data == GCR_B_ACTIVE){ if (rw_data == GCR_B_ACTIVE) {
if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ if (atomic_read(&priv->psstatus.status) ==
atomic_set(&priv->psstatus.status, PS_WAKEUP); PS_SNOOZE) {
priv->wakeup_count=0; atomic_set(&priv->psstatus.status,
PS_WAKEUP);
priv->wakeup_count = 0;
} }
complete(&priv->psstatus.wakeup_wait); complete(&priv->psstatus.wakeup_wait);
} }
} }
do{ do {
/* read (WriteStatus/ReadDataSize FN1:00_0014) */ /* read (WriteStatus/ReadDataSize FN1:00_0014) */
retval = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data)); retval =
if(retval){ ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data,
DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n", rw_data); sizeof(rw_data));
if (retval) {
DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n",
rw_data);
goto intr_out; goto intr_out;
} }
DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data); DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data);
rsize=rw_data&RSIZE_MASK; rsize = rw_data & RSIZE_MASK;
if(rsize){ /* Read schedule */ if (rsize) { /* Read schedule */
ks_wlan_hw_rx((void *)priv, (uint16_t)(((rsize)<<4))); ks_wlan_hw_rx((void *)priv,
(uint16_t) (((rsize) << 4)));
} }
if(rw_data&WSTATUS_MASK){ if (rw_data & WSTATUS_MASK) {
#if 0 #if 0
if(status&INT_WRITE_STATUS && !cnt_txqbody(priv)){ if (status & INT_WRITE_STATUS
&& !cnt_txqbody(priv)) {
/* dummy write for interrupt clear */ /* dummy write for interrupt clear */
rw_data =0; rw_data = 0;
retval = ks7010_sdio_write(priv, DATA_WINDOW, &rw_data, sizeof(rw_data)); retval =
ks7010_sdio_write(priv, DATA_WINDOW,
&rw_data,
sizeof(rw_data));
if (retval) { if (retval) {
DPRINTK(1, "write DATA_WINDOW Failed!!(%d)\n",retval); DPRINTK(1,
"write DATA_WINDOW Failed!!(%d)\n",
retval);
} }
status &= ~INT_WRITE_STATUS; status &= ~INT_WRITE_STATUS;
} } else {
else{
#endif #endif
if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
if(cnt_txqbody(priv)){ if (cnt_txqbody(priv)) {
ks_wlan_hw_wakeup_request(priv); ks_wlan_hw_wakeup_request(priv);
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq, 1); queue_delayed_work
(priv->ks_wlan_hw.
ks7010sdio_wq,
&priv->ks_wlan_hw.
rw_wq, 1);
return; return;
} }
} } else {
else{
tx_device_task((void *)priv); tx_device_task((void *)priv);
} }
// } #if 0
}
#endif
} }
}while(rsize); } while (rsize);
} }
intr_out: intr_out:
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
&priv->ks_wlan_hw.rw_wq, 0);
return; return;
} }
static int trx_device_init( struct ks_wlan_private *priv ) static int trx_device_init(struct ks_wlan_private *priv)
{ {
/* initialize values (tx) */ /* initialize values (tx) */
priv->tx_dev.qtail = priv->tx_dev.qhead = 0; priv->tx_dev.qtail = priv->tx_dev.qhead = 0;
...@@ -655,21 +714,22 @@ static int trx_device_init( struct ks_wlan_private *priv ) ...@@ -655,21 +714,22 @@ static int trx_device_init( struct ks_wlan_private *priv )
spin_lock_init(&priv->tx_dev.tx_dev_lock); spin_lock_init(&priv->tx_dev.tx_dev_lock);
spin_lock_init(&priv->rx_dev.rx_dev_lock); spin_lock_init(&priv->rx_dev.rx_dev_lock);
tasklet_init(&priv->ks_wlan_hw.rx_bh_task, rx_event_task, (unsigned long)priv); tasklet_init(&priv->ks_wlan_hw.rx_bh_task, rx_event_task,
(unsigned long)priv);
return 0; return 0;
} }
static void trx_device_exit( struct ks_wlan_private *priv ) static void trx_device_exit(struct ks_wlan_private *priv)
{ {
struct tx_device_buffer *sp; struct tx_device_buffer *sp;
/* tx buffer clear */ /* tx buffer clear */
while (cnt_txqbody(priv)>0) { while (cnt_txqbody(priv) > 0) {
sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];
kfree(sp->sendp); /* allocated memory free */ kfree(sp->sendp); /* allocated memory free */
if (sp->complete_handler != NULL) /* TX Complete */ if (sp->complete_handler != NULL) /* TX Complete */
(*sp->complete_handler)(sp->arg1, sp->arg2); (*sp->complete_handler) (sp->arg1, sp->arg2);
inc_txqhead(priv); inc_txqhead(priv);
} }
...@@ -677,24 +737,35 @@ static void trx_device_exit( struct ks_wlan_private *priv ) ...@@ -677,24 +737,35 @@ static void trx_device_exit( struct ks_wlan_private *priv )
return; return;
} }
static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)
{ {
int rc=0; int rc = 0;
int retval; int retval;
unsigned char *data_buf; unsigned char *data_buf;
data_buf = NULL; data_buf = NULL;
data_buf = kmalloc(sizeof(u32), GFP_KERNEL); data_buf = kmalloc(sizeof(u32), GFP_KERNEL);
if(!data_buf){ rc = 1; goto error_out; } if (!data_buf) {
rc = 1;
goto error_out;
}
memcpy(data_buf, &index, sizeof(index)); memcpy(data_buf, &index, sizeof(index));
retval = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index)); retval = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index));
if(retval){ rc = 2; goto error_out; } if (retval) {
rc = 2;
goto error_out;
}
retval = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index)); retval = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index));
if(retval){ rc = 3; goto error_out; } if (retval) {
error_out: rc = 3;
if(data_buf) kfree(data_buf); goto error_out;
}
error_out:
if (data_buf)
kfree(data_buf);
return rc; return rc;
} }
...@@ -702,30 +773,41 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) ...@@ -702,30 +773,41 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)
static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,
unsigned char *data, unsigned int size) unsigned char *data, unsigned int size)
{ {
int rc=0; int rc = 0;
int retval; int retval;
unsigned char *read_buf; unsigned char *read_buf;
read_buf = NULL; read_buf = NULL;
read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
if(!read_buf){ rc = 1; goto error_out; } if (!read_buf) {
rc = 1;
goto error_out;
}
retval = ks7010_sdio_read(priv, address, read_buf, size); retval = ks7010_sdio_read(priv, address, read_buf, size);
if(retval){ rc = 2; goto error_out; } if (retval) {
rc = 2;
goto error_out;
}
retval = memcmp(data, read_buf, size); retval = memcmp(data, read_buf, size);
if(retval){ if (retval) {
DPRINTK(0, "data compare error (%d) \n",retval); rc = 3; goto error_out; DPRINTK(0, "data compare error (%d) \n", retval);
rc = 3;
goto error_out;
} }
error_out: error_out:
if(read_buf) kfree(read_buf); if (read_buf)
kfree(read_buf);
return rc; return rc;
} }
#include <linux/firmware.h> #include <linux/firmware.h>
static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_card *card) static int ks79xx_upload_firmware(struct ks_wlan_private *priv,
struct ks_sdio_card *card)
{ {
unsigned int size, offset, n = 0; unsigned int size, offset, n = 0;
unsigned char *rom_buf; unsigned char *rom_buf;
unsigned char rw_data =0; unsigned char rw_data = 0;
int retval, rc=0; int retval, rc = 0;
int length; int length;
const struct firmware *fw_entry = NULL; const struct firmware *fw_entry = NULL;
...@@ -733,76 +815,99 @@ static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_c ...@@ -733,76 +815,99 @@ static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_c
/* buffer allocate */ /* buffer allocate */
rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
if(!rom_buf){ rc = 3; goto error_out0; } if (!rom_buf) {
rc = 3;
goto error_out0;
}
sdio_claim_host(card->func); sdio_claim_host(card->func);
/* Firmware running ? */ /* Firmware running ? */
retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data));
if(rw_data == GCR_A_RUN){ if (rw_data == GCR_A_RUN) {
DPRINTK( 0, "MAC firmware running ...\n"); DPRINTK(0, "MAC firmware running ...\n");
rc = 0; rc = 0;
goto error_out0; goto error_out0;
} }
if(request_firmware(&fw_entry, priv->reg.rom_file, &priv->ks_wlan_hw.sdio_card->func->dev)!=0){ if (request_firmware
DPRINTK(1,"error request_firmware() file=%s\n", priv->reg.rom_file); (&fw_entry, priv->reg.rom_file,
&priv->ks_wlan_hw.sdio_card->func->dev) != 0) {
DPRINTK(1, "error request_firmware() file=%s\n",
priv->reg.rom_file);
return 1; return 1;
} }
DPRINTK(4,"success request_firmware() file=%s size=%zu\n", priv->reg.rom_file, fw_entry->size); DPRINTK(4, "success request_firmware() file=%s size=%zu\n",
priv->reg.rom_file, fw_entry->size);
length = fw_entry->size; length = fw_entry->size;
/* Load Program */ /* Load Program */
n = 0; n = 0;
do { do {
if(length >= ROM_BUFF_SIZE){ if (length >= ROM_BUFF_SIZE) {
size = ROM_BUFF_SIZE; size = ROM_BUFF_SIZE;
length = length - ROM_BUFF_SIZE; length = length - ROM_BUFF_SIZE;
} else {
size = length;
length = 0;
} }
else{ DPRINTK(4, "size = %d\n", size);
size=length; if (size == 0)
length=0; break;
} memcpy(rom_buf, fw_entry->data + n, size);
DPRINTK(4, "size = %d\n",size);
if(size == 0) break;
memcpy(rom_buf,fw_entry->data+n,size);
/* Update write index */ /* Update write index */
offset = n; offset = n;
retval = ks7010_sdio_update_index(priv, KS7010_IRAM_ADDRESS+offset); retval =
if(retval){ rc = 6; goto error_out1; } ks7010_sdio_update_index(priv,
KS7010_IRAM_ADDRESS + offset);
if (retval) {
rc = 6;
goto error_out1;
}
/* Write data */ /* Write data */
retval = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size); retval = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size);
if(retval){ rc = 8; goto error_out1; } if (retval) {
rc = 8;
goto error_out1;
}
/* compare */ /* compare */
retval = ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size); retval =
if(retval){ rc = 9; goto error_out1; } ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size);
if (retval) {
rc = 9;
goto error_out1;
}
n += size; n += size;
}while(size); } while (size);
/* Remap request */ /* Remap request */
rw_data = GCR_A_REMAP; rw_data = GCR_A_REMAP;
retval = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data)); retval = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data));
if(retval){ if (retval) {
rc = 11; rc = 11;
goto error_out1; goto error_out1;
} }
DPRINTK( 4, " REMAP Request : GCR_A=%02X\n", rw_data); DPRINTK(4, " REMAP Request : GCR_A=%02X\n", rw_data);
/* Firmware running check */ /* Firmware running check */
for (n = 0; n < 50; ++n) { for (n = 0; n < 50; ++n) {
mdelay(10);/* wait_ms(10); */ mdelay(10); /* wait_ms(10); */
retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); retval =
if(retval){ rc = 11; goto error_out1; } ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data));
if(rw_data == GCR_A_RUN) break; if (retval) {
rc = 11;
goto error_out1;
}
if (rw_data == GCR_A_RUN)
break;
} }
DPRINTK(4, "firmware wakeup (%d)!!!!\n",n); DPRINTK(4, "firmware wakeup (%d)!!!!\n", n);
if ((50) <= n) { if ((50) <= n) {
DPRINTK(1, "firmware can't start\n"); DPRINTK(1, "firmware can't start\n");
rc = 12; rc = 12;
goto error_out1; goto error_out1;
} }
...@@ -812,30 +917,31 @@ static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_c ...@@ -812,30 +917,31 @@ static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_c
release_firmware(fw_entry); release_firmware(fw_entry);
error_out0: error_out0:
sdio_release_host(card->func); sdio_release_host(card->func);
if(rom_buf) if (rom_buf)
kfree(rom_buf); kfree(rom_buf);
return rc; return rc;
} }
static void ks7010_card_init(struct ks_wlan_private *priv) static void ks7010_card_init(struct ks_wlan_private *priv)
{ {
DPRINTK(5,"\ncard_init_task()\n"); DPRINTK(5, "\ncard_init_task()\n");
/* init_waitqueue_head(&priv->confirm_wait); */ /* init_waitqueue_head(&priv->confirm_wait); */
init_completion(&priv->confirm_wait); init_completion(&priv->confirm_wait);
DPRINTK(5,"init_completion()\n"); DPRINTK(5, "init_completion()\n");
/* get mac address & firmware version */ /* get mac address & firmware version */
hostif_sme_enqueue(priv, SME_START); hostif_sme_enqueue(priv, SME_START);
DPRINTK(5,"hostif_sme_enqueu()\n"); DPRINTK(5, "hostif_sme_enqueu()\n");
if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,5*HZ)){ if (!wait_for_completion_interruptible_timeout
DPRINTK(1,"wait time out!! SME_START\n"); (&priv->confirm_wait, 5 * HZ)) {
DPRINTK(1, "wait time out!! SME_START\n");
} }
if(priv->mac_address_valid && priv->version_size){ if (priv->mac_address_valid && priv->version_size) {
priv->dev_state = DEVICE_STATE_PREINIT; priv->dev_state = DEVICE_STATE_PREINIT;
} }
...@@ -858,57 +964,56 @@ static void ks7010_card_init(struct ks_wlan_private *priv) ...@@ -858,57 +964,56 @@ static void ks7010_card_init(struct ks_wlan_private *priv)
hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST); hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST);
hostif_sme_enqueue(priv, SME_START_REQUEST); hostif_sme_enqueue(priv, SME_START_REQUEST);
if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,5*HZ)){ if (!wait_for_completion_interruptible_timeout
DPRINTK(1,"wait time out!! wireless parameter set\n"); (&priv->confirm_wait, 5 * HZ)) {
DPRINTK(1, "wait time out!! wireless parameter set\n");
} }
if(priv->dev_state >= DEVICE_STATE_PREINIT){ if (priv->dev_state >= DEVICE_STATE_PREINIT) {
DPRINTK(1, "DEVICE READY!!\n"); DPRINTK(1, "DEVICE READY!!\n");
priv->dev_state = DEVICE_STATE_READY; priv->dev_state = DEVICE_STATE_READY;
reg_net = register_netdev (priv->net_dev); reg_net = register_netdev(priv->net_dev);
DPRINTK(3, "register_netdev=%d\n",reg_net); DPRINTK(3, "register_netdev=%d\n", reg_net);
} } else {
else { DPRINTK(1, "dev_state=%d\n", priv->dev_state);
DPRINTK(1, "dev_state=%d\n",priv->dev_state);
} }
} }
static struct sdio_driver ks7010_sdio_driver = { static struct sdio_driver ks7010_sdio_driver = {
.name = "ks7910_sdio", .name = "ks7910_sdio",
.id_table = if_sdio_ids, .id_table = if_sdio_ids,
.probe = ks7910_sdio_probe, .probe = ks7910_sdio_probe,
.remove = ks7910_sdio_remove, .remove = ks7910_sdio_remove,
}; };
extern int ks_wlan_net_start(struct net_device *dev); extern int ks_wlan_net_start(struct net_device *dev);
extern int ks_wlan_net_stop(struct net_device *dev); extern int ks_wlan_net_stop(struct net_device *dev);
static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id *device) static int ks7910_sdio_probe(struct sdio_func *func,
const struct sdio_device_id *device)
{ {
struct ks_wlan_private *priv; struct ks_wlan_private *priv;
struct ks_sdio_card *card; struct ks_sdio_card *card;
struct net_device *netdev; struct net_device *netdev;
unsigned char rw_data; unsigned char rw_data;
int i=0, ret; int i = 0, ret;
DPRINTK(5, "ks7910_sdio_probe()\n"); DPRINTK(5, "ks7910_sdio_probe()\n");
priv = NULL; priv = NULL;
netdev=NULL; netdev = NULL;
/* initilize ks_sdio_card */ /* initilize ks_sdio_card */
card = kzalloc(sizeof(struct ks_sdio_card), GFP_KERNEL); card = kzalloc(sizeof(struct ks_sdio_card), GFP_KERNEL);
if (!card) if (!card)
return -ENOMEM; return -ENOMEM;
card->func = func; card->func = func;
card->model = 0x10; card->model = 0x10;
spin_lock_init(&card->lock); spin_lock_init(&card->lock);
/* select model */ /* select model */
for (i = 0;i < ARRAY_SIZE(ks_sdio_models);i++) { for (i = 0; i < ARRAY_SIZE(ks_sdio_models); i++) {
if (card->model == ks_sdio_models[i].model) if (card->model == ks_sdio_models[i].model)
break; break;
} }
...@@ -920,7 +1025,6 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id ...@@ -920,7 +1025,6 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id
card->firmware = ks_sdio_models[i].firmware; card->firmware = ks_sdio_models[i].firmware;
/*** Initialize SDIO ***/ /*** Initialize SDIO ***/
sdio_claim_host(func); sdio_claim_host(func);
...@@ -929,7 +1033,8 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id ...@@ -929,7 +1033,8 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id
/* function blocksize set */ /* function blocksize set */
ret = sdio_set_block_size(func, KS7010_IO_BLOCK_SIZE); ret = sdio_set_block_size(func, KS7010_IO_BLOCK_SIZE);
DPRINTK(5, "multi_block=%d sdio_set_block_size()=%d %d\n", func->card->cccr.multi_block, func->cur_blksize, ret); DPRINTK(5, "multi_block=%d sdio_set_block_size()=%d %d\n",
func->card->cccr.multi_block, func->cur_blksize, ret);
/* Allocate the slot current */ /* Allocate the slot current */
...@@ -940,10 +1045,10 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id ...@@ -940,10 +1045,10 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id
goto error_free_card; goto error_free_card;
/* interrupt disable */ /* interrupt disable */
sdio_writeb(func, 0, INT_ENABLE, &ret); sdio_writeb(func, 0, INT_ENABLE, &ret);
if (ret) if (ret)
goto error_free_card; goto error_free_card;
sdio_writeb(func, 0xff, INT_PENDING, &ret); sdio_writeb(func, 0xff, INT_PENDING, &ret);
if (ret) if (ret)
goto error_disable_func; goto error_disable_func;
...@@ -957,18 +1062,16 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id ...@@ -957,18 +1062,16 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id
sdio_set_drvdata(func, card); sdio_set_drvdata(func, card);
DPRINTK(5, "class = 0x%X, vendor = 0x%X, " DPRINTK(5, "class = 0x%X, vendor = 0x%X, "
"device = 0x%X\n", "device = 0x%X\n", func->class, func->vendor, func->device);
func->class, func->vendor, func->device);
/* private memory allocate */ /* private memory allocate */
netdev = alloc_etherdev(sizeof(*priv)); netdev = alloc_etherdev(sizeof(*priv));
if (netdev == NULL) { if (netdev == NULL) {
printk (KERN_ERR "ks79xx : Unable to alloc new net device\n"); printk(KERN_ERR "ks79xx : Unable to alloc new net device\n");
goto error_release_irq; goto error_release_irq;
} }
if (dev_alloc_name(netdev, netdev->name) < 0) { if (dev_alloc_name(netdev, netdev->name) < 0) {
printk (KERN_ERR "ks79xx : Couldn't get name!\n"); printk(KERN_ERR "ks79xx : Couldn't get name!\n");
goto error_free_netdev; goto error_free_netdev;
} }
...@@ -982,7 +1085,7 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id ...@@ -982,7 +1085,7 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id
init_completion(&priv->ks_wlan_hw.ks7010_sdio_wait); init_completion(&priv->ks_wlan_hw.ks7010_sdio_wait);
priv->ks_wlan_hw.read_buf = NULL; priv->ks_wlan_hw.read_buf = NULL;
priv->ks_wlan_hw.read_buf = kmalloc(RX_DATA_SIZE, GFP_KERNEL); priv->ks_wlan_hw.read_buf = kmalloc(RX_DATA_SIZE, GFP_KERNEL);
if(!priv->ks_wlan_hw.read_buf){ if (!priv->ks_wlan_hw.read_buf) {
goto error_free_netdev; goto error_free_netdev;
} }
priv->dev_state = DEVICE_STATE_PREBOOT; priv->dev_state = DEVICE_STATE_PREBOOT;
...@@ -995,25 +1098,29 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id ...@@ -995,25 +1098,29 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id
memset(&priv->wstats, 0, sizeof(priv->wstats)); memset(&priv->wstats, 0, sizeof(priv->wstats));
/* sleep mode */ /* sleep mode */
atomic_set(&priv->sleepstatus.doze_request,0); atomic_set(&priv->sleepstatus.doze_request, 0);
atomic_set(&priv->sleepstatus.wakeup_request,0); atomic_set(&priv->sleepstatus.wakeup_request, 0);
atomic_set(&priv->sleepstatus.wakeup_request,0); atomic_set(&priv->sleepstatus.wakeup_request, 0);
trx_device_init(priv); trx_device_init(priv);
hostif_init(priv); hostif_init(priv);
ks_wlan_net_start(netdev); ks_wlan_net_start(netdev);
/* Read config file */ /* Read config file */
ret = ks_wlan_read_config_file(priv); ret = ks_wlan_read_config_file(priv);
if (ret) { if (ret) {
printk(KERN_ERR "ks79xx: read configuration file failed !! retern code = %d\n", ret); printk(KERN_ERR
"ks79xx: read configuration file failed !! retern code = %d\n",
ret);
goto error_free_read_buf; goto error_free_read_buf;
} }
/* Upload firmware */ /* Upload firmware */
ret = ks79xx_upload_firmware(priv, card); /* firmware load */ ret = ks79xx_upload_firmware(priv, card); /* firmware load */
if(ret){ if (ret) {
printk(KERN_ERR "ks79xx: firmware load failed !! retern code = %d\n", ret); printk(KERN_ERR
"ks79xx: firmware load failed !! retern code = %d\n",
ret);
goto error_free_read_buf; goto error_free_read_buf;
} }
...@@ -1023,25 +1130,24 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id ...@@ -1023,25 +1130,24 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id
sdio_claim_host(func); sdio_claim_host(func);
ret = ks7010_sdio_write(priv, INT_PENDING, &rw_data, sizeof(rw_data)); ret = ks7010_sdio_write(priv, INT_PENDING, &rw_data, sizeof(rw_data));
sdio_release_host(func); sdio_release_host(func);
if(ret){ if (ret) {
DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data); DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data);
} }
DPRINTK(4, " clear Interrupt : INT_PENDING=%02X\n", rw_data); DPRINTK(4, " clear Interrupt : INT_PENDING=%02X\n", rw_data);
/* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */ /* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */
rw_data = (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS); rw_data = (INT_GCR_B | INT_READ_STATUS | INT_WRITE_STATUS);
sdio_claim_host(func); sdio_claim_host(func);
ret = ks7010_sdio_write(priv, INT_ENABLE, &rw_data, sizeof(rw_data)); ret = ks7010_sdio_write(priv, INT_ENABLE, &rw_data, sizeof(rw_data));
sdio_release_host(func); sdio_release_host(func);
if(ret){ if (ret) {
DPRINTK(1, " error : INT_ENABLE=%02X\n", rw_data); DPRINTK(1, " error : INT_ENABLE=%02X\n", rw_data);
} }
DPRINTK(4, " enable Interrupt : INT_ENABLE=%02X\n", rw_data); DPRINTK(4, " enable Interrupt : INT_ENABLE=%02X\n", rw_data);
priv->dev_state = DEVICE_STATE_BOOT; priv->dev_state = DEVICE_STATE_BOOT;
priv->ks_wlan_hw.ks7010sdio_wq = create_workqueue("ks7010sdio_wq"); priv->ks_wlan_hw.ks7010sdio_wq = create_workqueue("ks7010sdio_wq");
if(!priv->ks_wlan_hw.ks7010sdio_wq){ if (!priv->ks_wlan_hw.ks7010sdio_wq) {
DPRINTK(1, "create_workqueue failed !!\n"); DPRINTK(1, "create_workqueue failed !!\n");
goto error_free_read_buf; goto error_free_read_buf;
} }
...@@ -1051,22 +1157,22 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id ...@@ -1051,22 +1157,22 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id
return 0; return 0;
error_free_read_buf: error_free_read_buf:
kfree(priv->ks_wlan_hw.read_buf); kfree(priv->ks_wlan_hw.read_buf);
priv->ks_wlan_hw.read_buf = NULL; priv->ks_wlan_hw.read_buf = NULL;
error_free_netdev: error_free_netdev:
free_netdev(priv->net_dev); free_netdev(priv->net_dev);
card->priv = NULL; card->priv = NULL;
error_release_irq: error_release_irq:
sdio_claim_host(func); sdio_claim_host(func);
sdio_release_irq(func); sdio_release_irq(func);
error_disable_func: error_disable_func:
sdio_disable_func(func); sdio_disable_func(func);
error_free_card: error_free_card:
sdio_release_host(func); sdio_release_host(func);
sdio_set_drvdata(func, NULL); sdio_set_drvdata(func, NULL);
kfree(card); kfree(card);
error: error:
return -ENODEV; return -ENODEV;
} }
...@@ -1080,56 +1186,62 @@ static void ks7910_sdio_remove(struct sdio_func *func) ...@@ -1080,56 +1186,62 @@ static void ks7910_sdio_remove(struct sdio_func *func)
card = sdio_get_drvdata(func); card = sdio_get_drvdata(func);
if(card == NULL) if (card == NULL)
return; return;
DPRINTK(1, "priv = card->priv\n"); DPRINTK(1, "priv = card->priv\n");
priv = card->priv; priv = card->priv;
netdev = priv->net_dev; netdev = priv->net_dev;
if(priv){ if (priv) {
ks_wlan_net_stop(netdev); ks_wlan_net_stop(netdev);
DPRINTK(1, "ks_wlan_net_stop\n"); DPRINTK(1, "ks_wlan_net_stop\n");
/* interrupt disable */ /* interrupt disable */
sdio_claim_host(func); sdio_claim_host(func);
sdio_writeb(func, 0, INT_ENABLE, &ret); sdio_writeb(func, 0, INT_ENABLE, &ret);
sdio_writeb(func, 0xff, INT_PENDING, &ret); sdio_writeb(func, 0xff, INT_PENDING, &ret);
sdio_release_host(func); sdio_release_host(func);
DPRINTK(1, "interrupt disable\n"); DPRINTK(1, "interrupt disable\n");
/* send stop request to MAC */ /* send stop request to MAC */
{ {
struct hostif_stop_request_t *pp; struct hostif_stop_request_t *pp;
pp = (struct hostif_stop_request_t *)kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL ); pp = (struct hostif_stop_request_t *)
if (pp==NULL) { kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL);
DPRINTK(3,"allocate memory failed..\n"); if (pp == NULL) {
return; /* to do goto ni suru*/ DPRINTK(3, "allocate memory failed..\n");
return; /* to do goto ni suru */
} }
pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); pp->header.size =
pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ); cpu_to_le16((uint16_t)
(sizeof(*pp) -
sizeof(pp->header.size)));
pp->header.event = cpu_to_le16((uint16_t) HIF_STOP_REQ);
sdio_claim_host(func); sdio_claim_host(func);
write_to_device(priv, (unsigned char *) pp, hif_align_size(sizeof(*pp))); write_to_device(priv, (unsigned char *)pp,
hif_align_size(sizeof(*pp)));
sdio_release_host(func); sdio_release_host(func);
kfree(pp); kfree(pp);
} }
DPRINTK(1, "STOP Req\n"); DPRINTK(1, "STOP Req\n");
if(priv->ks_wlan_hw.ks7010sdio_wq){ if (priv->ks_wlan_hw.ks7010sdio_wq) {
flush_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); flush_workqueue(priv->ks_wlan_hw.ks7010sdio_wq);
destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq);
} }
DPRINTK(1, "destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq);\n"); DPRINTK(1,
"destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq);\n");
hostif_exit(priv); hostif_exit(priv);
DPRINTK(1, "hostif_exit\n"); DPRINTK(1, "hostif_exit\n");
if(!reg_net) if (!reg_net)
unregister_netdev(netdev); unregister_netdev(netdev);
DPRINTK(1, "unregister_netdev\n"); DPRINTK(1, "unregister_netdev\n");
trx_device_exit(priv); trx_device_exit(priv);
if(priv->ks_wlan_hw.read_buf){ if (priv->ks_wlan_hw.read_buf) {
kfree(priv->ks_wlan_hw.read_buf); kfree(priv->ks_wlan_hw.read_buf);
} }
free_netdev(priv->net_dev); free_netdev(priv->net_dev);
...@@ -1148,26 +1260,27 @@ static void ks7910_sdio_remove(struct sdio_func *func) ...@@ -1148,26 +1260,27 @@ static void ks7910_sdio_remove(struct sdio_func *func)
kfree(card); kfree(card);
DPRINTK(1, "kfree()\n"); DPRINTK(1, "kfree()\n");
DPRINTK(5, " Bye !!\n");
DPRINTK(5," Bye !!\n");
return; return;
} }
static int __init ks7010_sdio_init( void ) static int __init ks7010_sdio_init(void)
{ {
int status; int status;
/* register with bus driver core */ /* register with bus driver core */
status = sdio_register_driver(&ks7010_sdio_driver); status = sdio_register_driver(&ks7010_sdio_driver);
if(status != 0){ if (status != 0) {
DPRINTK(1,"ks79xx_sdio : failed to register with bus driver, %d\n", status ); DPRINTK(1,
"ks79xx_sdio : failed to register with bus driver, %d\n",
status);
} }
return status; return status;
} }
static void __exit ks7010_sdio_exit( void ) static void __exit ks7010_sdio_exit(void)
{ {
DPRINTK(5," \n"); DPRINTK(5, " \n");
sdio_unregister_driver(&ks7010_sdio_driver); sdio_unregister_driver(&ks7010_sdio_driver);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment