Esempio n. 1
0
/*! 
 * mxc91231_tcs_mod_exit() - de-initialize
 * This is called from mx2-ocd.c
 */
void mxc91231_tcd_mod_exit (void)
{
        struct otg_instance *otg = tcd_instance->otg;
        TRACE_MSG0(TCD, "MX2_MOD_TCD_EXIT");

	mxc_iomux_gpio_mc13783_reset ();
#if 0 
        #if defined(CONFIG_ARCH_MXC91231)
        iomux_config_mux(SP_USB_TXOE_B, OUTPUTCONFIG_FUNC2, INPUTCONFIG_FUNC2);
        iomux_config_mux(SP_USB_DAT_VP, OUTPUTCONFIG_FUNC2, INPUTCONFIG_FUNC2);
        iomux_config_mux(SP_USB_SE0_VM, OUTPUTCONFIG_FUNC2, INPUTCONFIG_FUNC2);
        iomux_config_mux(SP_USB_RXD,    OUTPUTCONFIG_FUNC2, INPUTCONFIG_FUNC2);
        #endif
        
        #if defined(CONFIG_MACH_I30030EVB) || defined(CONFIG_ARCH_I30030EVB)
        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_ARCH_I30030EVB */
#endif										
        
        mxc_mc13783_mod_exit();       
        mxc91231_tcd_instance = otg_set_tcd_ops(NULL);

}
Esempio n. 2
0
/*!
 * zasevb_modexit() - This is used as module exit, and as cleanup if modinit fails.
 */
static void zasevb_modexit (void)
{
        struct otg_instance *otg = ocd_instance->otg;
        //struct pcd_instance *pcd = (struct pcd_instance *)otg->pcd;
        //struct usbd_bus_instance *bus= pcd->bus;

        TRACE_MSG0(ZAS, "Modules exit!");

        if (otg) otg_exit(otg);

        mxc_procfs_exit();

        /* Disable GPT
         */
        #if defined(CONFIG_OTG_GPTR)
        mxc_gptcr_mod_exit();
        #endif /* defined(CONFIG_OTG_GPTR) */

        #if defined(CONFIG_OTG_HRT)
        mxc_hrt_mod_exit();
        #endif /* defined(CONFIG_OTG_GPTR) */

        #ifdef OTG_USE_I2C
        TRACE_MSG0(ZAS, "0. I2C");
        i2c_mod_exit(otg);
        #endif

        #if !defined(CONFIG_USB_HOST)
        if (pcd_ops.mod_exit) pcd_ops.mod_exit(otg);
        REMOVE_pcd_instance = otg_set_pcd_ops(otg, NULL);
        #else /* !defined(CONFIG_USB_HOST) */
        printk(KERN_INFO"%s: PCD DRIVER N/A\n", __FUNCTION__);
        #endif /* !defined(CONFIG_USB_HOST) */


        #if defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE)
        if (hcd_ops.mod_exit) hcd_ops.mod_exit(otg);
        hcd_instance = otg_set_hcd_ops(otg, NULL);
        //HCD = otg_trace_invalidate_tag(HCD);
        #else /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */
        printk(KERN_INFO"%s: HCD DRIVER N/A\n", __FUNCTION__);
        #endif /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */


        if (tcd_ops.mod_exit) tcd_ops.mod_exit(otg);
        printk(KERN_INFO"%s: set_tcd_ops\n", __FUNCTION__);
        REMOVE_tcd_instance = otg_set_tcd_ops(otg, NULL);
        //REMOVE_TCD = otg_trace_invalidate_tag(REMOVE_TCD);

        if (ocd_ops.mod_exit) ocd_ops.mod_exit(otg);
        ocd_instance = otg_set_ocd_ops(otg, NULL);


        ZAS = otg_trace_invalidate_tag(ZAS);


        otg_destroy(otg);
}
/*! 
 * mxc91231_tcd_mod_exit() - de-initialize
 * This is called from mx2-ocd.c
 */
void mxc91231_tcd_mod_exit (void)
{
        struct otg_instance *otg = tcd_instance->otg;
        TRACE_MSG0(TCD, "MX2_MOD_TCD_EXIT");

    	mxc_iomux_gpio_mc13783_reset ();

        mxc_mc13783_mod_exit();       
        mxc91231_tcd_instance = otg_set_tcd_ops(NULL);

}
Esempio n. 4
0
/*! 
 * zasevb_tcd_mod_exit() - de-initialize
 * This is called from mx2-ocd.c
 */
void zasevb_tcd_mod_exit (void)
{
        struct otg_instance *otg = tcd_instance->otg;
        TRACE_MSG0(TCD, "MX2_MOD_TCD_EXIT");
	isp1301_mod_exit();
	mxc_disable_interrupts();
//	gpio_free_irq (ZGPIO_PORT, ZGPIO_PIN, GPIO_HIGH_PRIO);
	mxc_iomux_gpio_isp1301_reset();
        zasevb_tcd_instance = otg_set_tcd_ops(NULL);
        isp1301_exit();
}
/*!
 * 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;
}
Esempio n. 6
0
/*!
 * zasevb_tcd_mod_init() - initial tcd setup
 * This performs the platform specific hardware setup for the MX2ADS.
 */
int zasevb_tcd_mod_init (void)
{
	int i2c = 1;
        int gpio = 1;

        /* ------------------------------------------------------------------------ */
	#ifdef CONFIG_OTG_ZASEVB_DIFFERENTIAL_UNIDIRECTIONAL
        int hwmode = XCVR_D_SE0_NEW;   
	int newmode = XCVR_D_D;		
	isp1301_tx_mode_t tx_mode = vp_vm_unidirectional;	// MXC91231 ok
	printk (KERN_INFO"Current setting is DIFFERENTIAL UNIDIRECTIONAL\n");

        /* ------------------------------------------------------------------------ */
	#elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_UNIDIRECTIONAL
        int hwmode = XCVR_SE0_D_NEW;   
	int newmode = XCVR_SE0_D_NEW;
        isp1301_tx_mode_t tx_mode = dat_se0_unidirectional;     //  MXC91331 ok
	printk (KERN_INFO"Current setting is SINGLE ENDED UNIDIRECTIONAL\n");

        /* ------------------------------------------------------------------------ */
	#elif CONFIG_OTG_ZASEVB_DIFFERENTIAL_BIDIRECTIONAL
	int hwmode = XCVR_D_D;
        int newmode = XCVR_D_D;
	isp1301_tx_mode_t tx_mode = vp_vm_bidirectional;       // MXC91331 ok
        printk (KERN_INFO"Current setting is DIFFERENTIAL BIDIRECTIONAL\n");

        /* ------------------------------------------------------------------------ */
	#elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_BIDIRECTIONAL
        int hwmode = XCVR_SE0_SE0;   
	int newmode = XCVR_SE0_SE0;
        isp1301_tx_mode_t tx_mode = dat_se0_bidirectional;	//MXC91231 ok
	printk (KERN_INFO"Current setting is SINGLE ENDED BIDIRECTIONAL\n");

        /* ------------------------------------------------------------------------ */
        #else
        #error Please Configure Transceiver Mode
	#endif /* CONFIG_OTG_ZASEVB_.... */
        /* ------------------------------------------------------------------------ */
	

        TRACE_MSG0(TCD, "1. I2C setup");

	THROW_IF ((i2c = i2c_configure(ADAPTER_NAME, ISP1301_I2C_ADDR_HIGH)), error);

        TRACE_MSG0(TCD, "2. ISP1301 module setup");
//        isp1301_mod_init(&zasevb_isp1301_bh);

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

        TRACE_MSG0(TCD, "4. ISP1301 device setup");

	mxc_iomux_gpio_isp1301_set (hwmode);
	 

        #ifdef CONFIG_ARCH_MXC91131
        writel (0x00000051, PLL2_DP_HFSOP);
        writel (0x00000051, PLL2_DP_OP);
        #endif /* CONFIG_ARCH_MXC91131 */
			
        /* ------------------------------------------------------------------------ */
        TRACE_MSG0(TCD, "7. SET HWMODE");
        isp1301_configure(tx_mode, spd_susp_reg);        
        mxc_main_clock_on();
        //mxc_host_clock_on();
        //mxc_func_clock_on();
	mxc_set_transceiver_mode(newmode);

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

        CATCH(error) {
                printk(KERN_INFO"%s: failed\n", __FUNCTION__);
                UNLESS (i2c) i2c_close();
//                UNLESS (gpio) gpio_free_irq (ZGPIO_PORT, ZGPIO_PIN, GPIO_HIGH_PRIO);
                return -EINVAL;
        }
        TRACE_MSG0(TCD, "MX2_MOD_TCD_INIT FINISHED");
        return 0;
}
Esempio n. 7
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 0	
        #ifdef CONFIG_OTG_ZASEVB_DIFFERENTIAL_UNIDIRECTIONAL
        int mode = XCVR_D_D;
        #elif CONFIG_OTG_ZASEVB_DIFFERENTIAL_BIDIRECTIONAL
        #elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_UNIDIRECTIONAL
        #elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_BIDIRECTIONAL
        int mode = XCVR_SE0_SE0;
        #endif /* CONFIG_OTG_ZASEVB_.... */
#endif

#if 1 
        #ifdef CONFIG_OTG_ZASEVB_DIFFERENTIAL_BIDIRECTIONAL
        int hwmode = XCVR_D_D;
        int newmode = XCVR_D_D;
        #elif CONFIG_OTG_ZASEVB_DIFFERENTIAL_UNIDIRECTIONAL
        int hwmode = XCVR_D_SE0_NEW;
	int newmode = XCVR_D_D;
        #elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_UNIDIRECTIONAL
        int hwmode = XCVR_SE0_D_NEW;
        int newmode = XCVR_SE0_D_NEW;
        #elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_BIDIRECTIONAL
        int hwmode = XCVR_SE0_SE0;
        int newmode = XCVR_SE0_SE0;
        #else
        #error Please Configure Transceiver Mode
        #endif /* CONFIG_OTG_ZASEVB_.... */
#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_I30030EVB) || defined(CONFIG_ARCH_I30030EVB)

        printk(KERN_INFO"IOMUX setting for I30030EVB\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_ARCH_I30030EVB */
								
#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);
                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);
                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);
                break;

        case XCVR_SE0_SE0:
        	TRACE_MSG0(TCD, "SE0_SE0 - SEO_bidirectional");
                printk(KERN_INFO"%s: SE0_SE0 - Single Ended Bidirectional\n", __FUNCTION__);
                mc13783_convity_set_single_ended_mode(TRUE);
                mc13783_convity_set_directional_mode(TRUE);
        	break;
        }


        TRACE_MSG0(TCD, "7. SET HWMODE");
        mxc_set_transceiver_mode(newmode);
        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

#if 1	
        
        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


#if 0	//test for interrupt on changing DP

	iomux_config_mux(AP_GPIO_AP_C16,OUTPUTCONFIG_DEFAULT, INPUTCONFIG_NONE);
	iomux_config_mux(AP_GPIO_AP_C17,OUTPUTCONFIG_DEFAULT, INPUTCONFIG_NONE);
				
        gpio_config(2, 16, false, GPIO_INT_RISE_EDGE);
        gpio = gpio_request_irq(2, 16, GPIO_HIGH_PRIO, gpio_c16_int_hndlr,
		                        SA_SHIRQ, "VP1", NULL);
        THROW_IF(gpio, error);
	gpio_config_int_en(2, 16, TRUE);  // XXX this might not be needed

	gpio_config(2, 17, false, GPIO_INT_RISE_EDGE);
        gpio = gpio_request_irq(2, 17, GPIO_HIGH_PRIO, gpio_c17_int_hndlr,
                                        SA_SHIRQ, "VP1", NULL);
        THROW_IF(gpio, error);
        gpio_config_int_en(2, 17, TRUE);  // XXX this might not be needed
				
	
	while (1){
		udelay(1000);
	}
#endif	
	
#if 0 
	while(1){
//		mc13783_convity_set_var_disconnect (FALSE);
//		mc13783_convity_set_udp_pull (FALSE);
//		mc13783_convity_set_udp_auto_connect (TRUE);
//		mc13783_convity_set_speed_mode (TRUE);
//		mc13783_convity_set_pull_down_switch(PD_PU, FALSE);
		
	}
#endif
#if 0	//beautiful pulse between zero and 3.3 on DP 
	     mc13783_convity_set_speed_mode (FALSE); //set high speed
	while(1){
             mc13783_convity_set_pull_down_switch(PD_PU, TRUE);	//variable 1.5K pull-up switch in
             mc13783_convity_set_pull_down_switch(PD_UPD_15, FALSE);  //DP pull down switch is off
             udelay(1000);
	     mc13783_convity_set_pull_down_switch(PD_PU, FALSE);   //variable 1.5K pull-up switch off
             mc13783_convity_set_pull_down_switch(PD_UPD_15, TRUE);   //DP pull down switch is on 
             udelay(1000);
	}
#endif

#if 0 //beautiful pulse between zero and 3.3 on DM
	mc13783_convity_set_speed_mode (TRUE); //set low speed
	while(1){
             mc13783_convity_set_pull_down_switch(PD_PU, TRUE);   //variable 1.5K pull-up switch in
             mc13783_convity_set_pull_down_switch(PD_UDM_15, FALSE);  //DP pull down switch is off
             udelay(1000);
             mc13783_convity_set_pull_down_switch(PD_PU, FALSE);   //variable 1.5K pull-up switch off
             mc13783_convity_set_pull_down_switch(PD_UDM_15, TRUE);   //DP pull down switch is on
             udelay(1000);
	}
#endif

#if 0	//checking VBUS 
	mc13783_convity_set_output (TRUE, TRUE);	//enable VBUS
	udelay(1000);
//	mc13783_convity_set_output (TRUE, FALSE);     //disable VBUS
	while(1){
		udelay(1000);
	}
#endif	

#if 0
	while (1){
		mc13783_convity_set_vbus (FALSE);	//pull-down NMOS switch is on
	}
#endif	
	
#if 0 
	mc13783_convity_set_vusb_voltage (TRUE);	//set the VUSB voltage to 3.3
	mc13783_convity_set_output (FALSE, TRUE);     //enable VUSB
#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;
}
Esempio n. 8
0
/*!
 * zasevb_modinit() - linux module initialization
 *
 * This needs to initialize the hcd, pcd and tcd drivers. This includes tcd and possibly hcd
 * for some architectures.
 *
 */
static int zasevb_modinit (void)
{
        struct otg_instance *otg = NULL;

        #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
        struct clk *clk = clk_get(NULL, "usb_clk");
        clk_enable(clk);
        clk_put(clk);
        #endif

        THROW_UNLESS((otg = otg_create()), error);

        mxc_pcd_ops_init();
        #if !defined(OTG_C99)
        pcd_global_init();
        fs_ocd_global_init();
        zasevb_tcd_global_init();
        fs_pcd_global_init();
        #endif /* !defined(OTG_C99) */

        ZAS = otg_trace_obtain_tag(otg, "zas");

        mxc_procfs_init();

        TRACE_MSG0(ZAS, "1. ZAS");

        #if 0
        /* ZAS EVB Platform setup
         */
        TRACE_MSG4(ZAS, "BCTRL Version: %04x Status: %04x 1: %04x 2: %04x",
                        readw(PBC_BASE_ADDRESS ),
                        readw(PBC_BASE_ADDRESS + PBC_BSTAT),
                        readw(PBC_BASE_ADDRESS + PBC_BCTRL1_SET),
                        readw(PBC_BASE_ADDRESS + PBC_BCTRL2_SET));

        #endif

        /* ZAS EVB Clock setup
         */

#if defined(CONFIG_ARCH_ARGONPLUS) || defined(CONFIG_ARCH_ARGONLV)
#define ZASEVB_MULTIPLIER       12
#define ZASEVB_DIVISOR          775             // ~10.
#else
#define ZASEVB_MULTIPLIER       12
#define ZASEVB_DIVISOR 155
#endif

        TRACE_MSG0(ZAS, "2. Setup GPT");

        THROW_UNLESS(ocd_instance = otg_set_ocd_ops(otg, &ocd_ops), error);
        REMOVE_OCD = ocd_instance->TAG;
        // XXX THROW_IF((ocd_ops.mod_init ? ocd_ops.mod_init() : 0), error);

        #if defined(CONFIG_OTG_GPTR)
        mxc_gptcr_mod_init(ZASEVB_DIVISOR, ZASEVB_MULTIPLIER);
        #endif /* defined(CONFIG_OTG_GPTR) */

        #if defined(CONFIG_OTG_HRT)
        mxc_hrt_mod_init(otg, ZASEVB_DIVISOR, ZASEVB_MULTIPLIER);
        #endif /* defined(CONFIG_OTG_GPTR) */


        #if !defined(CONFIG_USB_HOST)
        TRACE_MSG0(ZAS, "3. PCD");
        THROW_UNLESS(REMOVE_pcd_instance = otg_set_pcd_ops(otg, &pcd_ops), error);
        REMOVE_PCD = REMOVE_pcd_instance->TAG;
        // XXX THROW_IF((pcd_ops.mod_init ? pcd_ops.mod_init() : 0), error);
        #else /* !defined(CONFIG_USB_HOST) */
        printk(KERN_INFO"%s: PCD DRIVER N/A\n", __FUNCTION__);
        #endif /* !defined(CONFIG_USB_HOST) */


        TRACE_MSG0(ZAS, "4. TCD");
        THROW_UNLESS(REMOVE_tcd_instance = otg_set_tcd_ops(otg, &tcd_ops), error);
        REMOVE_TCD = REMOVE_tcd_instance->TAG;
        // XXX THROW_IF((tcd_ops.mod_init ? tcd_ops.mod_init() : 0), error);
#ifdef OTG_USE_I2C
        TRACE_MSG0(ZAS, "0. I2C");
        i2c_mod_init(otg);
#endif


        #if defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE)
        TRACE_MSG0(ZAS, "5. Host");
        THROW_UNLESS(hcd_instance = otg_set_hcd_ops(otg, &hcd_ops), error);
        HCD = hcd_instance->TAG;
        // XXX THROW_IF((hcd_ops.mod_init) ? hcd_ops.mod_init() : 0, error);
        #else /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */
        printk(KERN_INFO"%s: HCD DRIVER N/A\n", __FUNCTION__);
        #endif /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */



        TRACE_MSG0(ZAS, "6. Init & check");
        THROW_IF((ocd_ops.mod_init ? ocd_ops.mod_init(otg) : 0), error);

        #if !defined(CONFIG_USB_HOST)
        THROW_IF((pcd_ops.mod_init ? pcd_ops.mod_init(otg) : 0), error);
        #endif /* !defined(CONFIG_USB_HOST) */

        THROW_IF((tcd_ops.mod_init ? tcd_ops.mod_init(otg) : 0), error);

        #if defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE)
        THROW_IF((hcd_ops.mod_init) ? hcd_ops.mod_init(otg) : 0, error);
        #endif /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */

        THROW_UNLESS(ocd_instance && (otg = ocd_instance->otg), error);


        TRACE_MSG0(ZAS, "7. otg_init");
        if (MODPARM(serial_number_str) && strlen(MODPARM(serial_number_str))) {

                TRACE_MSG1(ZAS, "serial_number_str: %s", MODPARM(serial_number_str));
                otg_serial_number (otg, MODPARM(serial_number_str));
        }
        otg_init(otg);

        return 0;

        CATCH(error) {
                //zasevb_modexit();
                return -EINVAL;
        }

        return 0;
}