Ejemplo n.º 1
0
static ssize_t crt_register_store(struct kobject *kobj, struct kobj_attribute *attr,
		const char *buf, size_t count)
{

	sscanf(buf, "0x%08X 0x%08X", &register_addr,&register_val);

	if(register_addr == 0x1234abcd)
		register_password = 1;

	if(register_addr == 0xabcd1234)
		register_password = 0;

	if((register_password == 1) && (register_val !=0))
	{
		rtd_outl(register_addr, register_val);
		register_val = 0;
	}


	return count;
}
Ejemplo n.º 2
0
/*------------------------------------------------------------------
 * Func : mars_scd_open
 *
 * Desc : open a mars scd device
 *
 * Parm : id  : channel id
 *         
 * Retn : handle of mars scd
 *------------------------------------------------------------------*/
mars_scd* mars_scd_open(unsigned char id)
{           
    mars_scd* p_this;
    
    if (id >= 2) return NULL;
        
#if 1              
    rtd_outl(0xb8000364, rtd_inl(0xb8000364) | 0x00003000); // Set Pin MUX        	 
#endif                     
        
    p_this = (mars_scd*) kmalloc(sizeof(mars_scd), GFP_KERNEL);    
    
    if (p_this)
    {
        memset(p_this, 0, sizeof(mars_scd));        
  
        p_this->id               = id;
        p_this->fsm              = IFD_FSM_UNKNOWN;
        p_this->atr.length       = 0;        
        init_completion(&p_this->card_detect_completion);                        
        
        // configurations ---
    	p_this->clock_div        = 1;         
    	p_this->pre_clock_div    = 8;
    	p_this->baud_div1        = 12;        // default etu = 372 = 31 * 12        
    	p_this->baud_div2        = 31;           
        p_this->parity           = 1;      
                
        // operations ---
        p_this->enable           = mars_scd_enable;                
        p_this->set_clock        = mars_scd_set_clock;
        p_this->get_clock        = mars_scd_get_clock;        
        p_this->set_etu          = mars_scd_set_etu;
        p_this->get_etu          = mars_scd_get_etu;        
        p_this->set_parity       = mars_scd_set_parity;                
        p_this->get_parity       = mars_scd_get_parity;        
        p_this->activate         = mars_scd_activate;
        p_this->deactivate       = mars_scd_deactivate;  
        p_this->reset            = mars_scd_reset;        
        p_this->get_atr          = mars_scd_get_atr;                
        p_this->xmit             = mars_scd_xmit;
        p_this->read             = mars_scd_read;             
        p_this->get_card_status  = mars_scd_card_detect;
        p_this->poll_card_status = mars_scd_poll_card_status;   	                			                                        
        
                        
        // Set All Register to the initial value         
        SET_SCFP  (id, SC_CLK_EN(1)    | 
                       SC_CLKDIV((p_this->clock_div-1))|                        
                       SC_BAUDDIV2(0)  |                    // fixed to 31
                       SC_BAUDDIV1((p_this->baud_div1-1))|                        
                       SC_PRE_CLKDIV((p_this->pre_clock_div-1)));        
                       
        SET_SCCR  (id, SC_FIFO_RST(1)  | 
                       SC_SCEN(1)      | 
                       SC_AUTO_ATR(1)  |
                       SC_CONV(0)      |
                       SC_PS(0));        
                       
        SET_SCPCR (id, SC_TXGRDT(0)    | 
                       SC_CWI(0)       | 
                       SC_BWI(0)       |  
                       SC_WWI(0)       | 
                       SC_BGT(0x16)    |  
                       SC_EDC_EN(0)    | 
                       SC_CRC(0)       |
                       SC_PROTOCOL_T(0)| 
                       SC_T0RTY(0)     |
                       SC_T0RTY_CNT(0) );        
                       
        SET_SCIRER(id, 0);                      
        
        SET_SCIRSR(id, 0xFFFFFFFF);                                                          
        
        // Set Interrupt or IRQ
        
#ifdef ISR_POLLING        
        init_timer(&p_this->timer);
        p_this->timer.data     = (unsigned long)p_this;
        p_this->timer.function = mars_scd_timer;
        p_this->timer.expires  = jiffies + ISR_POLLING_INTERVAL;
        add_timer(&p_this->timer);      // register timer
#else     
        SC_INFO("Request IRQ #%d\n", MISC_IRQ);	    	    
    
        if (request_irq(MISC_IRQ, mars_scd_isr, SA_INTERRUPT | SA_SHIRQ, "MARS SCD", p_this) < 0) 
        {
            SC_WARNING("scd : open mars scd failed, unable to request irq#%d\n", MISC_IRQ);	    		
            return -1;
        }        
#endif                
        
        mars_scd_set_state(p_this, IFD_FSM_DISABLE);
    }        

    return p_this;
}