Esempio n. 1
0
static int ts_startup(struct ft5x06_ts *ts)
{
	int ret = 0;
	if (ts == NULL)
		return -EIO;

	if (down_interruptible(&ts->sem))
		return -EINTR;

	if (ts->use_count++ != 0)
		goto out;

	if (ts->rtask)
		panic("ft5x06tsd: rtask running?");

	ret = request_irq(ts->irq, &ts_interrupt, IRQF_TRIGGER_FALLING,
			  client_name, ts);
	if (ret) {
		printk(KERN_ERR "%s: request_irq failed, irq:%i\n",
		       client_name, ts->irq);
		goto out;
	}

#ifdef DEBUG
	set_mode(ts, FACTORY_MODE);
	dumpRegs(ts, 0x4c, 0x4C);
	write_reg(ts, 0x4C, 0x05);
	dumpRegs(ts, 0, 0x4C);
#endif
	set_mode(ts, WORK_MODE);
#ifdef DEBUG
	dumpRegs(ts, 0x3b, 0x3b);
	dumpRegs(ts, 0x6a, 0x6a);
	dumpRegs(ts, ID_G_THGROUP, ID_G_PERIODMONITOR);
	dumpRegs(ts, FT5X0X_REG_HEIGHT_B, FT5X0X_REG_K_Y_LOW);
	dumpRegs(ts, ID_G_AUTO_CLB, ID_G_B_AREA_TH);
#endif
	set_mode(ts, WORK_MODE);

	init_completion(&ts->init_exit);
	ret = kernel_thread(ts_thread, ts, CLONE_KERNEL);
	if (ret >= 0) {
		wait_for_completion(&ts->init_exit);
		ret = 0;
	} else {
		free_irq(ts->irq, ts);
	}

 out:
	if (ret)
		ts->use_count--;
	up(&ts->sem);
	return ret;
}
Esempio n. 2
0
/*
 * Perform some operations at the "top" of the interpreter loop.
 * This stuff is required to support debugging and profiling.
 *
 * Using" __attribute__((noinline))" seems to do more harm than good.  This
 * is best when inlined due to the large number of parameters, most of
 * which are local vars in the main interp loop.
 */
static void checkDebugAndProf(const u2* pc, const u4* fp, Thread* self,
    const Method* method, bool* pIsMethodEntry)
{
    /* check to see if we've run off end of method */
    assert(pc >= method->insns && pc <
            method->insns + dvmGetMethodInsnsSize(method));

#if 0
    /*
     * When we hit a specific method, enable verbose instruction logging.
     * Sometimes it's helpful to use the debugger attach as a trigger too.
     */
    if (*pIsMethodEntry) {
        static const char* cd = "Landroid/test/Arithmetic;";
        static const char* mn = "shiftTest2";
        static const char* sg = "()V";

        if (/*gDvm.debuggerActive &&*/
            strcmp(method->clazz->descriptor, cd) == 0 &&
            strcmp(method->name, mn) == 0 &&
            strcmp(method->shorty, sg) == 0)
        {
            LOGW("Reached %s.%s, enabling verbose mode\n",
                method->clazz->descriptor, method->name);
            android_setMinPriority(LOG_TAG"i", ANDROID_LOG_VERBOSE);
            dumpRegs(method, fp, true);
        }

        if (!gDvm.debuggerActive)
            *pIsMethodEntry = false;
    }
#endif

    /*
     * If the debugger is attached, check for events.  If the profiler is
     * enabled, update that too.
     *
     * This code is executed for every instruction we interpret, so for
     * performance we use a couple of #ifdef blocks instead of runtime tests.
     */
#ifdef WITH_PROFILER
    /* profiler and probably debugger */
    bool isEntry = *pIsMethodEntry;
    if (isEntry) {
        *pIsMethodEntry = false;
        TRACE_METHOD_ENTER(self, method);
    }
    if (gDvm.debuggerActive) {
        updateDebugger(method, pc, fp, isEntry, self);
    }
    if (gDvm.instructionCountEnableCount != 0) {
        /*
         * Count up the #of executed instructions.  This isn't synchronized
         * for thread-safety; if we need that we should make this
         * thread-local and merge counts into the global area when threads
         * exit (perhaps suspending all other threads GC-style and pulling
         * the data out of them).
         */
        int inst = *pc & 0xff;
        gDvm.executedInstrCounts[inst]++;
    }
#else
    /* debugger only */
    if (gDvm.debuggerActive) {
        bool isEntry = *pIsMethodEntry;
        updateDebugger(method, pc, fp, isEntry, self);
        if (isEntry)
            *pIsMethodEntry = false;
    }
#endif
}
Esempio n. 3
0
static bool read( char     *data,   // out
                  unsigned &len )   // in+out
{
   unsigned const max = len ;
   len = 0 ;

   WRITEREG(ICR,ICR_RESET); // 
   WRITEREG(ISR,0x7ff);    // ack interrupts
   usleep(1000);

   WRITEREG(ICR,ICR_SLENABLE);
   CLRREGBIT(ICR,ICR_UR_BIT);

   bool worked = false ;
   for( unsigned i = 0 ; !worked && ( i < 1 ); i++ ){
      long long start = tickMs();
      do {
         unsigned long isr = READREG(ISR);
         if( isr & ISR_SAD ){
            if( isr & ISR_MASTER_RX ){
               printf( "Master rx\n" );
               break ;
            }
   
            if( isr & ISR_SSD ){
   //            SETREGBIT(ISR,ISR_SSD_BIT);
               printf( "Slave stop: no data\n" );
               return true ;
            }
   
            if( isr & ISR_ACKNAK ){
   //            SETREGBIT(ISR,ISR_SSD_BIT);
               printf( "nak waiting for slave\n" );
               SETREGBIT(ISR,ISR_ACKNAKBIT);
               return true ;
            }

            SETREGBIT(ISR,9);

            worked = true ;
            break ;
         }
         else if( isr & ISR_BED ){
            printf( "bus error\n" );
            break ;
         }
   
         long long now = tickMs();
         if( now-start > 2000 ){
            printf( "timeout waiting for slave\n" );
            dumpRegs();
            break ;
         }
      } while( 1 );
      if( !worked ){
         printf( "retry\n" );
         WRITEREG(ICR,ICR_RESET); // 
         usleep((i+1)*1000);
      
         CLRREGBIT(ICR,ICR_UR_BIT);
         usleep((i+1)*1000);
         
         WRITEREG(ICR,ICR_SLENABLE);
      }
   }

   do {
      SETREGBIT(ICR,ICR_TB_BIT);
      long long start = tickMs();
      do { // wait for rx
         unsigned long isr = READREG(ISR);
         if( isr & ISR_IRF ){
            char const byte = READREG(IDBR);
            data[len++] = byte ;
            SETREGBIT(ISR,ISR_IRF_BIT); // ack
            if( isr & ISR_SSD ){
//               SETREGBIT(ISR,ISR_SSD_BIT);
               return true ;
            }
            break ;
         } else if( isr & ISR_SSD ){
               return true ;
         }
         long long now = tickMs();
         if( now-start > 2000 ){
            printf( "timeout waiting for data\n" );
            return false ;
         }
      } while( 1 );
   } while( 1 );

   return true ;
}