Beispiel #1
0
/*
 * 20100111,HSL@RK,use LUN to dicide call at task or irq.
 * lun==0: at irq , other at task.
 */
static int rkusb_function_call_callback( struct rkusb_dev *dev )
{
         int     ret;
         rk28printk("%s::cmd=%s,crash=%d\n" , __func__ , (char*) dev->req_out->buf , rk28_system_crash );
         if( !__rkusb_write_enable() ) {
                //if( !strcmp((char*) dev->req_out->buf , rkusb_en_read) ) {
                //        rk28_system_crash = 2;
                //        rkusb_send_csw_result( dev , rk28_system_crash);
                //        return RKUSB_CB_OK_NONE;
                //}
                if( !strcmp((char*) dev->req_out->buf , rkusb_en_write) ) {
                        rk28_system_crash = RKDBG_WRITE;
                        rkusb_send_csw_result( dev , rk28_system_crash);
                        return RKUSB_CB_OK_NONE;
                }
                return RKUSB_CB_FAILD;
        }
        if( DEV_LUN(dev) == 0 ) {
                ret = __rk28_scu_parse_cmd((char*) dev->req_out->buf);
                rk28printk("cmd ret = 0x%x(%d)" , ret ,ret );
                rkusb_send_csw_result( dev , ret );
        } else {
                rkusb_wakeup_thread( dev );
        }
        return RKUSB_CB_OK_NONE;
}
Beispiel #2
0
static int rkusb_write_sdram( struct rkusb_dev *dev )
{
        int pid;
        if( __rkusb_write_enable() ) {
                int max_len;
                if( DEV_OFFSET(dev) >= 0xc0000000 ) {
                        rkusb_normal_data_xfer( dev , NULL ); 
                        return RKUSB_CB_OK_NONE;
                }
                max_len = DEV_RWBUF_LENGTH( dev );
                if( max_len < DEV_LENGTH(dev) ) {
                            return RKUSB_CB_FAILD;
                }
                pid = DEV_PID( dev );
                if( pid ) {
                        dev->slave_task = find_task_by_pid( pid );
                        if(!dev->slave_task )
                                return RKUSB_CB_FAILD;
                        //rk28printk("%s::pid=%d,task=%s\n" , __func__ , pid , dev->slave_task->comm );
                } else {
                        dev->slave_task = current ;
                }
                /* bakeup real offset and length */
                dev->private_tmp = (void*)DEV_OFFSET(dev);
                dev->buf_nfill = DEV_LENGTH(dev);
                __rkusb_set_dest_or_source( dev , __rkusb_rwbuffer_start( dev ) );
                rkusb_normal_data_xfer( dev , rkusb_write_sdram_cb);
                return RKUSB_CB_OK_NONE;
        }
        return RKUSB_CB_FAILD;
}
Beispiel #3
0
static int rkusb_usb_command( struct rkusb_dev *dev )
{
        int r = RKUSB_CB_FAILD;
        rk28printk("%s::func=%d,len=%d\n" , __func__ , DEV_FUNC(dev),DEV_LENGTH(dev));
        switch( DEV_FUNC(dev) ) {
                case FUNC_UCMD_DEVREADY:
                        r = RKUSB_CB_OK_CSW;
                        break;
                case FUNC_UCMD_DISCONNECTMSC:
                        rk28_msc_switch( 0 );
                        r = RKUSB_CB_OK_CSW;
                        break;
                case FUNC_UCMD_SYSTEMINFO:
                        {
                        unsigned int off_len[2];
                        off_len[0] = (unsigned int)system_type;
                        off_len[1] = strlen(system_type)+1;
                        rkusb_normal_data_xfer_onetime(dev , off_len );
                        r = RKUSB_CB_OK_NONE;
                        }
                        break;
                case FUNC_UCMD_RESTART:
                        rk28printk("get restart cmd,lun=%d\n" , DEV_LUN(dev));
                        if( DEV_LUN(dev) == 0 ) { /* normal restart */
                                rk28_restart(0);
                        } else if( DEV_LUN(dev) == 1 ) { /* to loader rkusb */
                                rk28_restart(1);
                        }
                        break;
                case FUNC_UCMD_GETVERSION:
                        r = rkusb_ucmd_get_version( dev );
                        break;
                case FUNC_UCMD_GETCHIPINFO:
                        {
                        unsigned int off_len[2];
                        off_len[1] = kld_get_tag_data( 0X524B0000 , (void**)&off_len );
                        rkusb_normal_data_xfer_onetime(dev , off_len );
                        r = RKUSB_CB_OK_NONE;
                        }
                        break;
                case FUNC_UCMD_GETSN:
                        {
                        unsigned int off_len[2];
                        off_len[1] = kld_get_tag_data( 0X524B0006 , (void**)&off_len );
                        rkusb_normal_data_xfer_onetime(dev , off_len );
                        r = RKUSB_CB_OK_NONE;
                        }
                        break;
                case FUNC_UCMD_DEBUGINFO:
                        {
                        RKDEBUG_INFO      *dbi = DEV_FAST_ALLOC(dev,RKDEBUG_INFO);
                        dbi->size = sizeof(RKDEBUG_INFO);
                        dbi->adb_support = adb_support;
                        dbi->dbg_level = __rkusb_write_enable(dev)?2:(__rkusb_read_enable(dev)?1:0);
                        dbi->tr_length = dev->req_buf_length;
                        dbi->save_length = dev->buf_length;
                        dbi->save_buf = (unsigned long)__rkusb_rwbuffer_start(dev);
                        if( dev->fsg )
                                strcpy(dbi->cur_device,"msc");
                        else
                                strcpy(dbi->cur_device,"adb");
                        strcpy( dbi->cur_version,RKUSB_KVERSION);
                        #if 0
                        dbi->cmds[0]=K_FW_SDRAM_READ_10;
                        dbi->cmds[1]=K_FW_SDRAM_WRITE_10;
                        dbi->cmds[2]=K_FW_TRACE;
                        dbi->cmds[3]=K_FW_GETLOG;
                        dbi->cmds[4]=K_FW_FUNCALL;
                        dbi->cmds[5]=K_FW_GETSYMB;
                        dbi->cmds[6]=K_FW_GETRESULT;
                        dbi->cmds[7]=K_FW_USBCMD;
                        #endif
                        rkusb_normal_data_xfer_onetime(dev , dbi );
                        r = RKUSB_CB_OK_NONE;
                        }
                        break;
                 case FUNC_UCMD_OPENADB:
                        {
                        /* lun:0 close,1: open */
                        adb_function_enable(DEV_LUN(dev));
                        usb_vbus_status = 0; /* force to reconnect! */
                        r = RKUSB_CB_OK_CSW;
                        }
                        break;
                default:
                        break ;
        }
        return r;
}