From c35786036bb3cb85a4d51e9dd3edffc5f0188ac5 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 30 Sep 2010 15:59:37 +0800 Subject: [PATCH] add delay after download SIANO firmware to fix the bug of initialized failure. --- drivers/cmmb/siano/smscoreapi.c | 48 ++++++++++++++++++++++++++----- drivers/cmmb/siano/smsspicommon.c | 9 ++++++ drivers/cmmb/siano/smsspiphy_rk.c | 34 ++++++++++++++++------ 3 files changed, 75 insertions(+), 16 deletions(-) diff --git a/drivers/cmmb/siano/smscoreapi.c b/drivers/cmmb/siano/smscoreapi.c index c62124756a3a..af777a60bc87 100755 --- a/drivers/cmmb/siano/smscoreapi.c +++ b/drivers/cmmb/siano/smscoreapi.c @@ -57,6 +57,7 @@ int sms_debug =0; //hzb 0526 // for loopback char g_LbResBuf[256]={0}; // +volatile bool g_libdownload = false; module_param_named(debug, sms_debug, int, 0644); MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))"); @@ -541,7 +542,7 @@ static int smscore_sendrequest_and_wait(struct smscore_device_t *coredev, } return wait_for_completion_timeout(completion, - msecs_to_jiffies(10000)) ? 0 : -ETIME;//10000 + msecs_to_jiffies(30000)) ? 0 : -ETIME;//10000 } static int smscore_load_firmware_family2(struct smscore_device_t *coredev, @@ -592,7 +593,10 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev, //mdelay(5); } }//hzb test 0527 - + // msleep(200); + // g_libdownload = true; + + // msleep(200); while (size && rc >= 0) { struct SmsDataDownload_ST *DataMsg = (struct SmsDataDownload_ST *) msg; @@ -610,14 +614,35 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev, (coredev->mode == DEVICE_MODE_NONE)) rc = coredev->sendrequest_handler(coredev->context,DataMsg,DataMsg->xMsgHeader.msgLength); else + { + +// complete(&coredev->data_download_done); +// msleep(200); +// g_libdownload = false; + +// msleep(200); rc = smscore_sendrequest_and_wait(coredev, DataMsg,DataMsg->xMsgHeader.msgLength,&coredev->data_download_done); - + } payload += payload_size; size -= payload_size; mem_address += payload_size; + + sms_debug("size=%d \n", size); } + + sms_info("transfer over!!!!!!!!!!!!!!!!!!\n"); + +// complete(&coredev->data_download_done); +// msleep(200); +// g_libdownload = false; +// msleep(200); +// ¼ÓÈëÑÓʱ£¬·ÀÖ¹³õʼ»¯Ê§°Ü£¬ZYC + msleep(2000); +//printk("firmware is downloaded\n!!!!"); +//msleep(1000); if (rc >= 0) { + sms_info("firmware is loaded over 1111111111\n"); if (coredev->mode == DEVICE_MODE_NONE) { struct SmsMsgData_ST *TriggerMsg = (struct SmsMsgData_ST *) msg; @@ -635,16 +660,20 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev, smsendian_handle_tx_message((struct SmsMsgHdr_ST *)msg); if (coredev->device_flags & SMS_ROM_NO_RESPONSE) { + + sms_info("firmware is loaded over , but no response,222222222\n"); rc = coredev->sendrequest_handler(coredev-> context, TriggerMsg, TriggerMsg->xMsgHeader.msgLength); - msleep(100); + msleep(300); } else rc = smscore_sendrequest_and_wait(coredev, TriggerMsg, TriggerMsg->xMsgHeader.msgLength, &coredev->trigger_done); } else { + sms_info("firmware is loaded over , but mode is none,333333333333\n"); + SMS_INIT_MSG(msg, MSG_SW_RELOAD_EXEC_REQ, sizeof(struct SmsMsgHdr_ST)); smsendian_handle_tx_message((struct SmsMsgHdr_ST *)msg); @@ -654,6 +683,9 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev, msleep(500); } + else + sms_info("firmware is not loaded over , it is wrong,4444444444444\n"); + sms_debug("rc=%d, postload=%p ", rc, coredev->postload_handler); kfree(msg); @@ -763,7 +795,7 @@ void smscore_unregister_device(struct smscore_device_t *coredev) sms_info("waiting for %d buffer(s)", coredev->num_buffers - num_buffers); - msleep(100); + msleep(300); } sms_info("freed %d buffers", num_buffers); @@ -948,12 +980,14 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode) SMS_INIT_MSG(&msg->xMsgHeader, MSG_SMS_INIT_DEVICE_REQ, sizeof(struct SmsMsgData_ST)); msg->msgData[0] = mode; - + //for test,zyc + msleep(200); + smsendian_handle_tx_message((struct SmsMsgHdr_ST *)msg); rc = smscore_sendrequest_and_wait(coredev, msg, msg->xMsgHeader.msgLength, &coredev->init_device_done); - + sms_info("send MSG_SMS_INIT_DEVICE_REQ res = %d\n ",rc); kfree(buffer); } else { sms_err("Could not allocate buffer for " diff --git a/drivers/cmmb/siano/smsspicommon.c b/drivers/cmmb/siano/smsspicommon.c index c374af8844b2..1f6924c04424 100755 --- a/drivers/cmmb/siano/smsspicommon.c +++ b/drivers/cmmb/siano/smsspicommon.c @@ -22,6 +22,7 @@ along with this program. If not, see . #include "smsdbg_prn.h" #include "smscoreapi.h" +extern volatile bool g_libdownload; static struct _rx_buffer_st *smsspi_handle_unused_bytes_buf( @@ -342,7 +343,13 @@ void smsspi_common_transfer_msg(struct _spi_dev *dev, struct _spi_msg *txmsg, dev->cb.transfer_data_cb(dev->phy_context,(unsigned char *)txbuf,tx_phy_addr,NULL,NULL,len); } else #endif + { + +// sms_info("g_libdownload == %d!!!!!!!!!!!!!!!!!\n",g_libdownload); + //if(g_libdownload == false) + { +// sms_info("g_libdownload == false!!!!!!!!!!!!!!!!!\n"); len = 0; if (!dev->cb.transfer_data_cb) { sms_err("function called while module is not initialized.\n"); @@ -438,6 +445,8 @@ void smsspi_common_transfer_msg(struct _spi_dev *dev, struct _spi_msg *txmsg, } } +} + int smsspicommon_init(struct _spi_dev *dev, void *context, void *phy_context, struct _spi_dev_cb_st *cb) { diff --git a/drivers/cmmb/siano/smsspiphy_rk.c b/drivers/cmmb/siano/smsspiphy_rk.c index 82181e863b5c..5e6aaf8dfd76 100755 --- a/drivers/cmmb/siano/smsspiphy_rk.c +++ b/drivers/cmmb/siano/smsspiphy_rk.c @@ -237,7 +237,9 @@ void smsspibus_xfer(void *context, unsigned char *txbuf, #if SIANO_HALFDUPLEX if(txbuf) { - //sms_debug("tx_buf:%x,%x,%x,%x,%x,%x", txbuf[0], txbuf[1], txbuf[2], txbuf[3], txbuf[4],txbuf[5]); + // sms_debug("tx_buf:%x,%x,%x,%x,%x,%x", txbuf[0], txbuf[1], txbuf[2], txbuf[3], txbuf[4],txbuf[5]); + sms_debug("rxbuf 4, 5,6,7,8, 9,10,11=%x,%x,%x,%x",rxbuf[4],rxbuf[5],rxbuf[6],rxbuf[7]); + sms_debug(",%x,%x,%x,%x\n",rxbuf[8],rxbuf[9],rxbuf[10],rxbuf[11]); ret = spi_write(spiphy_dev->Smsdevice, txbuf, len); } else { if ((rxbuf)&&(len != 16)) @@ -254,7 +256,8 @@ void smsspibus_xfer(void *context, unsigned char *txbuf, ret = spi_read(spiphy_dev->Smsdevice, rxbuf, len); #endif - //sms_debug("rxbuf 4, 5,8,9=%x,%x,%x,%x\n",rxbuf[4],rxbuf[5],rxbuf[8],rxbuf[9]); + //sms_debug("rxbuf 4, 5,6,7,8, 9,10,11=%x,%x,%x,%x",rxbuf[4],rxbuf[5],rxbuf[6],rxbuf[7]); + // sms_debug(",%x,%x,%x,%x\n",rxbuf[8],rxbuf[9],rxbuf[10],rxbuf[11]); //printk("len=%x,rxbuf 4, 5,8,9Mlen=%x,%x,%x,%x,%x,%x\n",len,rxbuf[4],rxbuf[5],rxbuf[8],rxbuf[9],rxbuf[13],rxbuf[12]); } @@ -312,16 +315,19 @@ static void chip_poweron() gpio_direction_output(CMMB_1186_POWER_DOWN,0); // GPIOSetPinDirection(CMMB_1186_POWER_ENABLE,1); - gpio_direction_output(CMMB_1186_POWER_ENABLE,0); - mdelay(100); + mdelay(100); gpio_direction_output(CMMB_1186_POWER_ENABLE,1); - mdelay(100); - +// gpio_set_value(CMMB_1186_POWER_ENABLE,GPIO_HIGH); + mdelay(500); +// gpio_set_value(CMMB_1186_POWER_DOWN,GPIO_HIGH); gpio_direction_output(CMMB_1186_POWER_DOWN,1); - mdelay(100); + + mdelay(500); +// gpio_set_value(CMMB_1186_POWER_RESET,GPIO_HIGH); gpio_direction_output(CMMB_1186_POWER_RESET,1); - mdelay(200); + mdelay(500); + printk("cmmb chip_poweron !!!!\n"); } @@ -348,8 +354,16 @@ static void chip_powerdown() //1186 cmmb power down #if 1 // GPIOSetPinDirection(CMMB_1186_POWER_ENABLE,1); + gpio_direction_output(CMMB_1186_POWER_RESET,0); + + mdelay(200); + gpio_direction_output(CMMB_1186_POWER_DOWN,0); + gpio_direction_output(CMMB_1186_POWER_ENABLE,0); - mdelay(300); +// gpio_set_value(CMMB_1186_POWER_RESET,GPIO_LOW); +// gpio_set_value(CMMB_1186_POWER_DOWN,GPIO_LOW); +// gpio_set_value(CMMB_1186_POWER_ENABLE,GPIO_LOW); + //mdelay(00); //set the CS0 as gpio mode // rk2818_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME,0); @@ -459,8 +473,10 @@ void *smsspiphy_init(void *context, void (*smsspi_interruptHandler) (void *), //root@zyc-desktop:/usr/android_source/android_cmmb_dev/kernel/kernel/drivers/cmmb/siano# // //1186_SPIIRQ, (pFunc)spibus_interrupt, GPIOEdgelRising, spiphy_dev); + request_irq(gpio_to_irq(CMMB_1186_SPIIRQ),spibus_interrupt,IRQF_TRIGGER_RISING,"inno_irq",spiphy_dev); + if(ret<0){ printk("siano 1186 request irq failed !!\n"); ret = -EBUSY; -- 2.34.1