Exemple #1
0
static int imx_3stack_mach_probe(struct snd_soc_machine
				 *machine)
{
	struct snd_soc_codec *codec;
	struct snd_soc_pcm_link *pcm_link;
	int i, ret;

	pcm_link = list_first_entry(&machine->active_list,
				    struct snd_soc_pcm_link, active_list);

	wm8903_3stack_pcm_link = pcm_link;

	codec = pcm_link->codec;

	gpio_activate_audio_ports();
	codec->ops->io_probe(codec, machine);

	/* set unused imx_3stack WM8903 codec pins */
	snd_soc_dapm_set_endpoint(machine, "IN2R", 0);
	snd_soc_dapm_set_endpoint(machine, "IN1R", 0);

	/* Add imx_3stack specific widgets */
	for (i = 0; i < ARRAY_SIZE(imx_3stack_dapm_widgets); i++) {
		snd_soc_dapm_new_control(machine, codec,
					 &imx_3stack_dapm_widgets[i]);
	}

	for (i = 0; i < ARRAY_SIZE(imx_3stack_machine_controls); i++) {
		ret = snd_ctl_add(machine->card,
				  snd_soc_cnew(&imx_3stack_machine_controls[i],
					       codec, NULL));
		if (ret < 0)
			return ret;
	}

	/* set up imx_3stack specific audio path audio map */
	for (i = 0; audio_map[i][0] != NULL; i++) {
		snd_soc_dapm_connect_input(machine, audio_map[i][0],
					   audio_map[i][1], audio_map[i][2]);
	}

	imx_3stack_ext_control();

	snd_soc_dapm_set_policy(machine, SND_SOC_DAPM_POLICY_STREAM);
	snd_soc_dapm_sync_endpoints(machine);

	wm8903_hp_initialize_hp_detect(codec);
	wm8903_hp_status(codec);

	gpio_config(WM8903_IRQ_GPIO_PORT, WM8903_IRQ_GPIO_NUM,
		    false, GPIO_INT_RISE_EDGE);
	gpio_request_irq(WM8903_IRQ_GPIO_PORT, WM8903_IRQ_GPIO_NUM,
			 GPIO_LOW_PRIO,
			 imx_headphone_detect_handler, 0,
			 "headphone", pcm_link);

	/* register card with ALSA upper layers */
	ret = snd_soc_register_card(machine);
	if (ret < 0) {
		pr_err("%s: failed to register sound card\n", __func__);
		return ret;
	}

	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 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;
}