add delay after download SIANO firmware to fix the bug of initialized
authorroot <root@zyc-desktop.(none)>
Thu, 30 Sep 2010 07:59:37 +0000 (15:59 +0800)
committerroot <root@zyc-desktop.(none)>
Thu, 7 Oct 2010 09:44:06 +0000 (17:44 +0800)
failure.

drivers/cmmb/siano/smscoreapi.c
drivers/cmmb/siano/smsspicommon.c
drivers/cmmb/siano/smsspiphy_rk.c

index c62124756a3a3a9887dedb01bc17e06a8e297335..af777a60bc879c929255fcfea0c5027f475349be 100755 (executable)
@@ -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 "
index c374af8844b2b1be07615ff7b44895339f171434..1f6924c0442401c7a4997a0ed90e725a0add25d9 100755 (executable)
@@ -22,6 +22,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #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)
 {
index 82181e863b5cd9deb4a1677b8b860615bd036a62..5e6aaf8dfd761d442449530398dee5158759370b 100755 (executable)
@@ -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;