void mxc_mc13783_mod_exit(void)
{
					
        while (PENDING_WORK_ITEM(mc13783_work_bh)) {
                printk(KERN_ERR"%s: waiting for mc13783_work_bh\n", __FUNCTION__);
                schedule_timeout(10 * HZ);
        }
        while (PENDING_WORK_ITEM(mc13783_otg_wq)) {
                printk(KERN_ERR"%s: waiting for mc13783_otg_wq\n", __FUNCTION__);
                schedule_timeout(10 * HZ);
        }

/* Investigate if these exist
	mc13783_convity_set_interface_mode(IM_RS232_1);
	mc13783_convity_set_var_disconnect(TRUE);

	mc13783_convity_set_udp_auto_connect (FALSE);
        mc13783_convity_set_udp_pull (FALSE);
	mc13783_convity_set_pull_down_switch(PD_PU, FALSE);
        mc13783_convity_set_pull_down_switch(PD_UPD_15, FALSE);
        mc13783_convity_set_pull_down_switch(PD_UDM_15, FALSE);
								
	
        mc13783_convity_event_unsub(IT_CONVITY_USBI, mc13783_usbi_handler);
        mc13783_convity_event_unsub(IT_CONVITY_IDI, mc13783_idi_handler);
        mc13783_convity_event_unsub(IT_CONVITY_SE1I, mc13783_se1i_handler);
			
*/								
// Remove the following lines if above are needed. 	
	power_ic_periph_set_usb_pull_up(FALSE);
	power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_UDPPD, FALSE); 
	power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_UDMPD, FALSE);
		
}
/*! mc13783_bh
 *  */
void mc13783_bh(void *arg)
{
	TRACE_MSG0(TCD, "--");
	global_flag = global_flag_array[start_flag];
	if (global_flag & PUDP_FLAG_SET){	//set DP pullup
    	//mc13783_convity_set_speed_mode (FALSE); //set high speed
                //mc13783_convity_set_pull_down_switch(PD_PU, TRUE);  //variable 1.5K pull-up switch in
		power_ic_periph_set_usb_pull_up(TRUE);
	}
	if (global_flag & PUDP_FLAG_RESET){	//reset DP pullup
		//mc13783_convity_set_speed_mode (FALSE); //set high speed
                //mc13783_convity_set_pull_down_switch(PD_PU, FALSE);  //variable 1.5K pull-up switch off
		power_ic_periph_set_usb_pull_up(FALSE); // Turn off the USB pullup
	}
        if (global_flag & PUDM_FLAG_SET){	//set DM pullup
                //mc13783_convity_set_speed_mode (TRUE); //set low speed
                //mc13783_convity_set_pull_down_switch(PD_PU, TRUE);   //variable 1.5K pull-up switch in
		power_ic_periph_set_usb_pull_up(TRUE);
        }		
        if (global_flag & PUDM_FLAG_RESET){	//reset DM pullup
                //mc13783_convity_set_speed_mode (TRUE); //set low speed
                //mc13783_convity_set_pull_down_switch(PD_PU, FALSE);   //variable 1.5K pull-up switch off
                power_ic_periph_set_usb_pull_up(FALSE); // Turn off the USB pullup
        }
	if (global_flag & UPD_FLAG_SET){	//set DP pulldown
		power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_UDPPD, TRUE);
                //mc13783_convity_set_pull_down_switch(PD_UPD_15, TRUE);   //DP pull down switch is on
	}
	if (global_flag & UPD_FLAG_RESET){	//reset DP pulldown
		power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_UDPPD, FALSE);
                //mc13783_convity_set_pull_down_switch(PD_UPD_15, FALSE);  //DP pull down switch is off
	}
	if (global_flag & UDM_FLAG_SET){	//set DM pulldown
		power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_UDMPD, TRUE); 
                //mc13783_convity_set_pull_down_switch(PD_UDM_15, TRUE);   //DP pull down switch is on
	}
	if (global_flag & UDM_FLAG_RESET){	//reset DM pulldown
		power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_UDMPD, FALSE);
                //mc13783_convity_set_pull_down_switch(PD_UDM_15, FALSE);  //DP pull down switch is off
	}
/*  Used for OTG
	if (global_flag & DRV_VBUS_SET){	//enable vbus voltage
//		mc13783_convity_set_output (FALSE, FALSE);     //disable VUSB
		mc13783_convity_set_output (TRUE, TRUE);     //enable VBUS
	}
	if (global_flag & DRV_VBUS_RESET){	//disable vbus voltage
//		mc13783_convity_set_output (FALSE, FALSE);     //disable VUSB
		mc13783_convity_set_output (TRUE, FALSE);     //disable VBUS
	}
	if (global_flag & CHRG_VBUS_SET){	//enable vbus
#ifndef VBUS_TIMER		
		mc13783_convity_set_output (TRUE, TRUE);     //enable VBUS
#else		
		mc13783_convity_set_vbus_reg (3);         //set VBUS on for 30 ms
#endif		
	}
	if (global_flag & CHRG_VBUS_RESET){	//disable vbus
		mc13783_convity_set_output (TRUE, FALSE);     //disable VBUS
	}
	if (global_flag & DISCHRG_VBUS_SET){	//discharge vbus
		mc13783_convity_set_output (TRUE, FALSE);     //disable VBUS
	        mc13783_convity_set_vusb_voltage (TRUE);  //set the VUSB voltage to 3.3
	        mc13783_convity_set_output (FALSE, TRUE);     //enable VUSB
	}
	if (global_flag & DISCHRG_VBUS_RESET){    //discharge vbus disable
		mc13783_convity_set_output (TRUE, FALSE);     //disable VBUS
		mc13783_convity_set_output (FALSE, TRUE);     //enable VUSB
//		mc13783convity_set_output (FALSE, FALSE);     //disable VUSB
	}
*/ 
	
	TRACE_MSG3 (TCD, "gloabl flag %d start_flag %d end_flag %d", global_flag, start_flag, end_flag);

	global_flag = 0;
	global_flag_array[start_flag] = 0;
        if (start_flag ++ > 15)
                start_flag = 0;
	if (start_flag != end_flag)
		SCHEDULE_WORK(mc13783_work_bh);		
	
}
示例#3
0
static int do_ioctl(struct inode * inode, struct file *filp,
		    u_int cmd, u_long arg)
{
	struct apm_user *	as;
	struct pm_dev *		pm;
	struct ipm_config	conf;

	as = filp->private_data;
	if (check_apm_user(as, "ioctl"))
		return -EIO;

	memset(&conf, 0, sizeof(conf));

	switch (cmd) {
        case APM_IOC_SUSPEND:
		pm_do_suspend(CPUMODE_SLEEP);
		break;
        case APM_IOC_SET_WAKEUP:
		if ((pm = pm_find((pm_dev_t)arg,NULL)) == NULL)
			return -EINVAL;
		pm_send(pm,PM_SET_WAKEUP,NULL);
		break;
	case APM_IOC_SLEEP:
		pm_go_sleep(arg);
		break;
	case APM_IOC_SET_SPROF_WIN:
		sleep_to = arg * HZ;
		APM_DPRINTK("do_ioctl: sleep timeout %ld\n", arg);
		break;
	case APM_IOC_WAKEUP_ENABLE:
		PWER |= arg;
		APM_DPRINTK("do_ioctl: enable wakeup source:PWER=0x%x\n", PWER);
		break;
	case APM_IOC_WAKEUP_DISABLE:
		PWER &= ~arg;
		APM_DPRINTK("do_ioctl: disable wakeup source:PWER=0x%x\n", PWER);
		break;
	case APM_IOC_POWEROFF:
		APM_DPRINTK("do_ioctl: do power off\n");
		/* here all device should response ok */
		pm_send_all(PM_SUSPEND, (void *)3);
		pm_do_poweroff();
		pm_send_all(PM_RESUME, (void *)0);
		break;
	case APM_IOC_RESET_BP:
		APM_DPRINTK("do_ioctl: reset bp\n");
		GPCR(GPIO_BB_RESET) = GPIO_bit(GPIO_BB_RESET);
		mdelay(1);
		GPSR(GPIO_BB_RESET) = GPIO_bit(GPIO_BB_RESET);
		break;
	case APM_IOC_USEROFF_ENABLE:
		APM_DPRINTK("do_ioctl: useroff support enable\n");
		user_off_available = (int)arg;
		break;
	case APM_IOC_NOTIFY_BP:
                break;
        case APM_IOC_REFLASH:
                cpu_proc_fin();
                *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = REFLASH_FLAG;

//		power_ic_periph_set_usb_pull_up(0);
//LIN           mdelay(1000);
//LIN let GPIO control the connectivity
#include <linux/power_ic.h>
		set_GPIO_mode(GPIO_USB_READY|GPIO_OUT);
		clr_GPIO(GPIO_USB_READY);
		power_ic_periph_set_usb_pull_up(0);
		mdelay(10);
		power_ic_set_reg_bit(POWER_IC_REG_EOC_CONN_CONTROL,19,1);//LIN set USB_CNTRL(bit19) to disable emu control
		mdelay(1000);
//LIN		power_ic_periph_set_usb_pull_up(1);

                /* Initialize the watchdog and let it fire */
                OWER = OWER_WME;
                OSSR = OSSR_M3;
		OSMR3 = OSCR + CLOCK_TICK_RATE/100;	/* ... in 10 ms */
                MDREFR |= MDREFR_SLFRSH;
		while(1);
                break;
        case APM_IOC_PASSTHRU:
                cpu_proc_fin();
                *(unsigned long *)(phys_to_virt(FLAG_ADDR)) = PASS_THRU_FLAG;

		power_ic_periph_set_usb_pull_up(0);
                mdelay(1000);
		power_ic_periph_set_usb_pull_up(1);

                /* Initialize the watchdog and let it fire */
                OWER = OWER_WME;
                OSSR = OSSR_M3;
		OSMR3 = OSCR + CLOCK_TICK_RATE/100;	/* ... in 10 ms */
                MDREFR |= MDREFR_SLFRSH;
		while(1);
                break;
	case APM_IOC_SET_IPROF_WIN:
		/* set profile window size */
		break;
	case APM_IOC_STARTPMU:
		if( pipm_start_pmu !=NULL )
			pipm_start_pmu();
		break;
	case APM_IOC_GET_IPM_CONFIG:
		get_ipm_config(&conf);
		return (copy_to_user((void *)arg, &conf,sizeof(conf)))? -EFAULT:0;
		break;
	case APM_IOC_SET_IPM_CONFIG:
		if(copy_from_user(&conf,(void *)arg,sizeof(conf)))
			return -EFAULT;
		
		return set_ipm_config(&conf);
		break;
	default:
		return -EINVAL;
	}
	return 0;
}
/*!
 * mxc91231_tcd_mod_init() - initial tcd setup
 * This performs the platform specific hardware setup for the MX2ADS.
 */
int mxc91231_tcd_mod_init (void)
{
        int i2c = 1;
        int gpio = 1;
        bool res;
        unsigned int reg_value;
        int i;

#if 1
        #ifdef CONFIG_OTG_BRASSBOARD_DIFFERENTIAL_BIDIRECTIONAL
        int hwmode = XCVR_D_D;
        int newmode = XCVR_D_D;
        #elif CONFIG_OTG_BRASSBOARD_DIFFERENTIAL_UNIDIRECTIONAL
        int hwmode = XCVR_D_SE0_NEW;
    	int newmode = XCVR_D_D;
        #elif CONFIG_OTG_BRASSBOARD_SINGLE_ENDED_UNIDIRECTIONAL
        int hwmode = XCVR_SE0_D_NEW;
        int newmode = XCVR_SE0_D_NEW;
        #elif CONFIG_OTG_BRASSBOARD_SINGLE_ENDED_BIDIRECTIONAL
        int hwmode = XCVR_SE0_SE0;
        int newmode = XCVR_SE0_SE0;
        #else
        #error Please Configure Transceiver Mode
        #endif /* CONFIG_OTG_BRASSBOARD_.... */
#endif		
        		
        printk(KERN_INFO"%s: AAAA22\n",__FUNCTION__);

        TRACE_MSG0(TCD, "1. mc13783 Connectivity");

        mxc_mc13783_mod_init();

        TRACE_MSG0(TCD, "2. Transceiver setup");

        switch(hwmode) {
        case XCVR_D_D:
        case XCVR_SE0_D_NEW:
        case XCVR_D_SE0_NEW:
                break;

        case XCVR_SE0_SE0:
                // this works with XCVR_SE0_SE0 if AP_GPIO_AP_C16 not configured
                //isp1301_configure(dat_se0_bidirectional, spd_susp_reg);        // XCVR_SEO_SE0
                // XXX configure mc13783 transceiver here
                break;
        }

        //isp1301_configure(vp_vm_bidirectional, spd_susp_reg);        // XCVR_D_D

        TRACE_MSG0(TCD, "5. SET TCD OPS");
        THROW_UNLESS(mxc91231_tcd_instance = otg_set_tcd_ops(&tcd_ops), error);

	mxc_iomux_gpio_mc13783_set (hwmode);
	
#if 0
	
        /*
         *
         *  Default
         *      USB_TXEO_B      OE      (9 OE)          
         *      USB_DAT_VP      DAT_VP  (14 DAT/VP)
         *      USB_SE0_VM      SE0_VM  (13 SE0/VM)
         *
         *      USB_RXD         RCV     (12 RCV)
         *
         *      USB_VP          VP      (11 VP)
         *      USB_VM          VM      (10 VM)
         *
         *  AR_USB_VP           GP_AP_C16       MUX3 - USB_VP1          AP_GPIO_AP_C16
         *  AR_USB_VM           GP_AP_C17       MUX3 - USB_VM1          AP_GPIO_AP_C17
         */
        TRACE_MSG0(OCD, "6. Setup USBOTG IOMUX");

        #if defined(CONFIG_ARCH_MXC91231) 
        
        printk(KERN_INFO"IOMUX setting for MXC91231\n");
        iomux_config_mux(SP_USB_TXOE_B, OUTPUTCONFIG_FUNC1, INPUTCONFIG_FUNC1);
        iomux_config_mux(SP_USB_DAT_VP, OUTPUTCONFIG_FUNC1, INPUTCONFIG_FUNC1);
        iomux_config_mux(SP_USB_SE0_VM, OUTPUTCONFIG_FUNC1, INPUTCONFIG_FUNC1);
        iomux_config_mux(SP_USB_RXD,    OUTPUTCONFIG_FUNC1, INPUTCONFIG_FUNC1);
	
	#endif

        #if defined(CONFIG_MACH_ARGONLVPHONE)
        printk(KERN_INFO"IOMUX setting for MXC91331 and MXC91321\n");
        iomux_config_mux(PIN_USB_XRXD,  OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_VMOUT, OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_VPOUT, OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_VPIN,  OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_TXENB, OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);
        iomux_config_mux(PIN_USB_VMIN,  OUTPUTCONFIG_FUNC, INPUTCONFIG_FUNC);

	#endif /* CONFIG_MACH_ARGONLVPHONE */
								
#endif
	
        switch(hwmode) {
        case XCVR_D_SE0_NEW:
                TRACE_MSG0(TCD, "D_D - vp_vm_bidirectional");
                printk(KERN_INFO"%s: D_D - Differential Unidirectional\n", __FUNCTION__);
//                #if defined(CONFIG_ARCH_MXC91231) 
//                iomux_config_mux(AP_GPIO_AP_C16,OUTPUTCONFIG_FUNC3, INPUTCONFIG_FUNC3);
//                iomux_config_mux(AP_GPIO_AP_C17,OUTPUTCONFIG_FUNC3, INPUTCONFIG_FUNC3);
//                #endif
//                mc13783_convity_set_single_ended_mode(FALSE);
//                mc13783_convity_set_directional_mode(FALSE);
   	        power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_DATSE0, FALSE);
	        power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_BIDIR, FALSE);
                break;
        case XCVR_SE0_D_NEW:
                TRACE_MSG0(TCD, "SE0_D");
                printk(KERN_INFO"%s: SE0_D - Single Ended Unidirectional\n", __FUNCTION__);
//                mc13783_convity_set_single_ended_mode(TRUE);
//                mc13783_convity_set_directional_mode(FALSE);
	        power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_DATSE0, TRUE);
	        power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_BIDIR, FALSE);
                break;
        case XCVR_D_D:
                TRACE_MSG0(TCD, "D_SE0");
                printk(KERN_INFO"%s: D_SE0 - Differential Bidirectional\n", __FUNCTION__);
//                mc13783_convity_set_single_ended_mode(FALSE);
//                mc13783_convity_set_directional_mode(TRUE);
//                iomux_config_mux(AP_GPIO_AP_C16,OUTPUTCONFIG_FUNC3, INPUTCONFIG_FUNC3);
//                iomux_config_mux(AP_GPIO_AP_C17,OUTPUTCONFIG_FUNC3, INPUTCONFIG_FUNC3);
        	power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_DATSE0, FALSE);
	        power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_BIDIR, TRUE);
                break;
        case XCVR_SE0_SE0:
	  	TRACE_MSG0(TCD, "SE0_SE0 - SEO_bidirectional");
		printk(KERN_INFO"%s: SE0_SE0 - Single Ended Bidirectional\n", __FUNCTION__);
		printk("OTG_DEBUG: set GPIO 16 and 17 to defaults, config BIT_DATSE0 and BIT_BIDIR for 3 wire\n");
//                mc13783_convity_set_single_ended_mode(TRUE);
//

		#if defined(CONFIG_ARCH_MXC91231) 
       		iomux_config_mux(AP_GPIO_AP_C16,OUTPUTCONFIG_DEFAULT, INPUTCONFIG_DEFAULT);
        	iomux_config_mux(AP_GPIO_AP_C17,OUTPUTCONFIG_DEFAULT, INPUTCONFIG_DEFAULT);
		#endif
	    	power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_DATSE0, TRUE);
	    	power_ic_set_reg_bit(POWER_IC_REG_ATLAS_USB_0, BIT_BIDIR, TRUE);
            // debugging stuff
            // unsigned int reg_value;
            // power_ic_read_reg(POWER_IC_REG_ATLAS_USB_0, &reg_value);
            // printk("OTG_DEBUG: Atlas POWER_IC_REG_ATLAS_USB_0 register value is: %#8X\n", reg_value);

            break;
        }


        TRACE_MSG0(TCD, "7. SET HWMODE");
        mxc_set_transceiver_mode(newmode);

#if 0 
// Need to test if the following lines are needed
        mc13783_convity_set_var_disconnect (TRUE); // variable 1k5 and UDP/UDM pull-down are disconnected. (PULLOVER)
	mc13783__convity_set_usb_transceiver (TRUE); //USB transceiver is disabled (USBXCVREN) 
	mc13783__convity_set_udp_auto_connect (FALSE); //variable UDP is not automatically connected (SE0CONN)
	mc13783__convity_set_pull_down_switch (PD_UDP_150, FALSE); //150K UDP pull-up switch is out (DP150KPU)
	mc13783__convity_set_udp_pull(FALSE); //1.5K UDP pull-up and USB xcver is controlled by SPI bits.(USBCNTRL)
	mc13783__convity_set_output (TRUE, FALSE);	//disable vbus
	mc13783__convity_set_output (FALSE, FALSE);	//disable vusb
	mc13783__convity_set_output (FALSE, TRUE);        //enable vusb
#endif

#if 0 // Need to turn this on just find power_ic call to replace mc13783 with	
        
        for (i=48; i<51; i++){
                   mc13783_read_reg (PRIO_CONN, i, &reg_value);
                   printk (KERN_INFO"Register %d = %8X\n", i, reg_value);
        }
#endif

        /* Success! */
	


        TRACE_MSG0(TCD, "8. Success!");

        CATCH(error) {
                printk(KERN_INFO"%s: failed\n", __FUNCTION__);
        	UNLESS (i2c) i2c_close();
        	//SHP
                //UNLESS (gpio) gpio_free_irq (3, GPIO_PIN, GPIO_HIGH_PRIO);
                return -EINVAL;
        }
        TRACE_MSG0(TCD, "MX2_MOD_TCD_INIT FINISHED");
        return 0;
}
示例#5
0
void power_ic_periph_set_usb_pull_up (int on)
{
    /* Set the USB pull-up bit in the EMU One Chip register */
    (void)power_ic_set_reg_bit (USB_PU_REG, USB_PU_INDEX, (on) ? 1 : 0);
}