Пример #1
0
int init_module(void)
{
    int ret;

	printk("[## BT ##] init_module\n");
    ret = register_chrdev(BT_DEV_MAJOR_NUM, DEV_NAME, &tcc_bt_dev_ops);

	bt_dev_class = class_create(THIS_MODULE, DEV_NAME);
	device_create(bt_dev_class, NULL, MKDEV(BT_DEV_MAJOR_NUM, BT_DEV_MINOR_NUM), NULL, DEV_NAME);

#if 0  //  moved to arch/arm/mach-tcc8920/board-tcc-bluetooth.c
	if(machine_is_tcc8900()){
	    gpio_request(TCC_GPB(25), "bt_power");
	    gpio_request(TCC_GPEXT2(9), "bt_reset");
		gpio_direction_output(TCC_GPB(25), 0); // output
		gpio_direction_output(TCC_GPEXT2(9), 0);
	}else if(machine_is_tcc9300() || machine_is_tcc8800()|| machine_is_tcc8920()) {      // #elif defined (CONFIG_MACH_TCC9300)
			//gpio_set_value(TCC_GPEXT1(7), 0);   /* BT-ON Disable */
		gpio_request(TCC_GPEXT3(2), "bt_wake");
	    gpio_request(TCC_GPEXT2(4), "bt_reset");
		gpio_direction_output(TCC_GPEXT3(2), 0); // output
		gpio_direction_output(TCC_GPEXT2(4), 0);
#if defined(CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT) && defined(CONFIG_TCC_CSR_HOST_WAKE_UP)
		tcc_gpio_config(TCC_GPB(31), GPIO_FN(0));
		gpio_request(TCC_GPEXT3(3), "bt_hwake");
		gpio_direction_input(TCC_GPEXT3(3));
#endif // for CSR Bluetooth host wake up
	}
	else if(machine_is_m801_88() || machine_is_m803())
	{
		#if defined(CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
		gpio_request(TCC_GPA(13), "LDO_ON");
		tcc_gpio_config(TCC_GPA(13), GPIO_FN(0));
		gpio_direction_output(TCC_GPA(13), 0);
		#else
		gpio_request(TCC_GPA(13), "bt_reset");
		gpio_request(TCC_GPB(22), "BT WAKE");
		gpio_direction_output(TCC_GPA(13), 0); // output
		gpio_direction_output(TCC_GPB(22), 0); // output
		#endif

	}
	else if(machine_is_tcc8800st())
	{
		gpio_request(TCC_GPC(31), "bt_power");
		gpio_request(TCC_GPD(12), "bt_reset");
		gpio_direction_output(TCC_GPC(31), 0); // output
		gpio_direction_output(TCC_GPD(12), 0); // output
	}
#endif

    if(ret < 0){
        printk("[## BT ##] [%d]fail to register the character device\n", ret);
        return ret;
    }

    return 0;
}
void RDA_bt_Power_Off(void)
{
	volatile PGPIO pGPIO = (volatile PGPIO)tcc_p2v(HwGPIO_BASE);

	if (machine_is_tcc8800()|| machine_is_tcc8920()) {	   // #elif defined (CONFIG_MACH_TCC9300)
		//gpio_set_value(TCC_GPEXT1(7), 0);   /* BT-ON Disable */
		gpio_set_value(TCC_GPEXT3(2), 0);	/* BT_WAKE Disable */
		gpio_set_value(TCC_GPEXT2(4), 0);	/* reset */
	}
	else if (machine_is_m801_88() || machine_is_m803())
	{
		gpio_set_value(TCC_GPA(13),0);
		//msleep(1);
	}
}
static int tcc_bluetooth_probe(struct platform_device *pdev)
{
	int rc = 0;
	int ret = 0;

	printk("[## BT ##] tcc_bluetooth_probe\n");
	if( machine_is_tcc8800()|| machine_is_tcc8920()) {      // #elif defined (CONFIG_MACH_TCC9300)
			//gpio_set_value(TCC_GPEXT1(7), 0);   /* BT-ON Disable */
		gpio_request(TCC_GPEXT3(2), "bt_wake");
	       gpio_request(TCC_GPEXT2(4), "bt_reset");
		gpio_direction_output(TCC_GPEXT3(2), 0); // output
		gpio_direction_output(TCC_GPEXT2(4), 0);
#if defined(CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT) && defined(CONFIG_TCC_CSR_HOST_WAKE_UP)
		tcc_gpio_config(TCC_GPB(31), GPIO_FN(0));
		gpio_request(TCC_GPEXT3(3), "bt_hwake");
		gpio_direction_input(TCC_GPEXT3(3));
#endif // for CSR Bluetooth host wake up
	}
	else if(machine_is_m801_88() || machine_is_m803())
	{
		#if defined(CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
		gpio_request(TCC_GPA(13), "LDO_ON");
		tcc_gpio_config(TCC_GPA(13), GPIO_FN(0));
		gpio_direction_output(TCC_GPA(13), 0);
		#else
		gpio_request(TCC_GPA(13), "bt_reset");
		gpio_request(TCC_GPB(22), "BT WAKE");
		gpio_direction_output(TCC_GPA(13), 0); // output
		gpio_direction_output(TCC_GPB(22), 0); // output
		#endif

	}
	else if(machine_is_tcc8800st())
	{
		gpio_request(TCC_GPC(31), "bt_power");
		gpio_request(TCC_GPD(12), "bt_reset");
		gpio_direction_output(TCC_GPC(31), 0); // output
		gpio_direction_output(TCC_GPD(12), 0); // output
	}
/*
	rc = gpio_request(BT_RESET_GPIO, "bcm4330_nreset_gpip");
	if (unlikely(rc)) {
		return rc;
	}

	rc = gpio_request(BT_REG_GPIO, "bcm4330_nshutdown_gpio");
	if (unlikely(rc)) {
		gpio_free(BT_RESET_GPIO);
		return rc;
	}
*/
	bt_rfkill = rfkill_alloc("Telechips Bluetooth", &pdev->dev,
				RFKILL_TYPE_BLUETOOTH, &tcc_bt_rfkill_ops,
				NULL);

	if (unlikely(!bt_rfkill)) {
		//gpio_free(BT_RESET_GPIO);
		//gpio_free(BT_REG_GPIO);
		printk("[## BT ##] rfkill_alloc failed \n");
		return -ENOMEM;
	}

	rc = rfkill_register(bt_rfkill);

	if (unlikely(rc)) {
		printk("[## BT ##] rfkill_register failed \n");
		rfkill_destroy(bt_rfkill);
		//gpio_free(BT_RESET_GPIO);
		//gpio_free(BT_REG_GPIO);
		return -1;
	}

	printk("[## BT ##] rfkill_register Telechips Bluetooth \n");

	rfkill_set_states(bt_rfkill, true, false);
	tcc_bt_rfkill_set_power(NULL, true);

#if defined (CONFIG_TCC_BRCM_BCM4330_MODULE_SUPPORT)
	ret = bcm_bt_lpm_init(pdev);
	if (ret) {
		rfkill_unregister(bt_rfkill);
		rfkill_destroy(bt_rfkill);

		//gpio_free(BT_RESET_GPIO);
		//gpio_free(BT_REG_GPIO);
	}
#endif

	return ret;
}
static int tcc_bt_rfkill_set_power(void *data, bool blocked)
{
	// rfkill_ops callback. Turn transmitter on when blocked is false

	printk("[## BT ##] tcc_bt_rfkill_set_power [%d]\n", blocked);
	
	if (!blocked && (bt_enable_flag == 0)) {
	      bt_enable_flag = 1;
              if (machine_is_tcc8800() || machine_is_tcc8920()) {      // #elif defined (CONFIG_MACH_TCC9300)
			#if defined (CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT)|| defined(CONFIG_TCC_ATHEROS_AR3002_MODULE_SUPPORT)
			//gpio_set_value(TCC_GPEXT1(7), 1);   /* BT-ON Enable */
			gpio_set_value(TCC_GPEXT3(2), 1);   /* BT_WAKE Enable , pwr_ctrl*/
			gpio_set_value(TCC_GPEXT2(4), 0);   /* reset */
			msleep(500);
			gpio_set_value(TCC_GPEXT2(4), 1);   /* reset */
			#elif defined (CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
			RDA_bt_Power_On();
			#endif	
		}
		else if (machine_is_m801_88() || machine_is_m803())
		{
			#if defined (CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT)
			gpio_set_value(TCC_GPB(22),1); // BT WAKE
			gpio_set_value(TCC_GPA(13),0); // reset
			msleep(500);
			gpio_set_value(TCC_GPA(13),1); // reset
			#elif defined (CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
			RDA_bt_Power_On();
			#endif	
		}
		else if(machine_is_tcc8800st())
		{
			gpio_set_value(TCC_GPC(31), 1); 		// BT pwr enable
			gpio_set_value(TCC_GPD(12), 0);			// BT rst 0
			msleep(500);
			gpio_set_value(TCC_GPD(12), 1);
		}
	} else if(blocked && (bt_enable_flag == 1)) {
		bt_enable_flag = 0;
		if (machine_is_tcc8800() || machine_is_tcc8920()) {      // #elif defined (CONFIG_MACH_TCC9300)
			#if defined (CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT)|| defined(CONFIG_TCC_ATHEROS_AR3002_MODULE_SUPPORT)
			//gpio_set_value(TCC_GPEXT1(7), 0);   /* BT-ON Disable */
			gpio_set_value(TCC_GPEXT3(2), 0);   /* BT_WAKE Disable */
			gpio_set_value(TCC_GPEXT2(4), 0);   /* reset */
			#elif defined (CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
			RDA_bt_Power_Off();
			#endif			
		}
		else if (machine_is_m801_88() || machine_is_m803())
		{
			#if defined (CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT)
			gpio_set_value(TCC_GPB(22), 0); // BT WAKE
			gpio_set_value(TCC_GPA(13), 0); // reset
			#elif defined (CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
			RDA_bt_Power_Off();
			#endif			
		}
		else if(machine_is_tcc8800st())
		{
			gpio_set_value(TCC_GPC(31), 0); 		// BT pwr enable
			gpio_set_value(TCC_GPD(12), 0);			// BT rst 0
		}

	}

	bt_enabled = !blocked;

	return 0;
}
Пример #5
0
static int hdmi1280x720_probe(struct platform_device *pdev)
{

	printk("%s\n", __func__);
	
	mutex_init(&panel_lock);

	hdmi1280x720_panel.dev = &pdev->dev;
	tccfb_register_panel(&hdmi1280x720_panel);

	#if 1
	//David added: Test PCA9555 driver
	gpio_request(TCC_GPEXT2(0), "LED_0");
	gpio_request(TCC_GPEXT2(1), "LED_1");
	gpio_request(TCC_GPEXT2(2), "LED_2");
	gpio_request(TCC_GPEXT2(3), "INVERT_ON");
	gpio_request(TCC_GPEXT2(4), "HDMI_USB_PWREN");
	gpio_request(TCC_GPEXT2(5), "USB20H_VBUSEN");

	gpio_request(TCC_GPEXT2(15), "AUDIO_AMP_OFF");

	gpio_request(TCC_GPEXT3(2), "CTP_INT1#_MASK");
	gpio_request(TCC_GPEXT3(3), "ALSPRX_INT2#_MASK");
	gpio_request(TCC_GPEXT3(4), "GSEN_INT3#_MASK");
	gpio_request(TCC_GPEXT3(5), "RFID_INT4#_MASK");
	gpio_request(TCC_GPEXT3(6), "RTC_ALARM_INT5_MASK");
	gpio_request(TCC_GPEXT3(7), "4IN1_ALL_INT6#_MASK");
	gpio_request(TCC_GPEXT3(14), "PWRPLL_CTL");
	gpio_request(TCC_GPEXT3(15), "IOD1_PWREN");

	gpio_direction_output(TCC_GPEXT2(0), 1);
	gpio_direction_output(TCC_GPEXT2(1), 1);
	gpio_direction_output(TCC_GPEXT2(2), 1);
	gpio_direction_output(TCC_GPEXT2(3), 1);
	gpio_direction_output(TCC_GPEXT2(4), 1);
	gpio_direction_output(TCC_GPEXT2(5), 1);

	gpio_direction_output(TCC_GPEXT2(15), 0);

	gpio_direction_output(TCC_GPEXT3(2), 1);
	gpio_direction_output(TCC_GPEXT3(3), 1);
	gpio_direction_output(TCC_GPEXT3(4), 1);
	gpio_direction_output(TCC_GPEXT3(5), 1);
	gpio_direction_output(TCC_GPEXT3(6), 1);
	gpio_direction_output(TCC_GPEXT3(7), 1);
	gpio_direction_output(TCC_GPEXT3(14), 1);
	gpio_direction_output(TCC_GPEXT3(15), 1);

	gpio_free(TCC_GPEXT2(0));
	gpio_free(TCC_GPEXT2(1));
	gpio_free(TCC_GPEXT2(2));
	gpio_free(TCC_GPEXT2(3));
	gpio_free(TCC_GPEXT2(4));
	gpio_free(TCC_GPEXT2(5));

	gpio_free(TCC_GPEXT2(15));	

	gpio_free(TCC_GPEXT3(2));
	gpio_free(TCC_GPEXT3(3));
	gpio_free(TCC_GPEXT3(4));
	gpio_free(TCC_GPEXT3(5));
	gpio_free(TCC_GPEXT3(6));
	gpio_free(TCC_GPEXT3(7));
	gpio_free(TCC_GPEXT3(14));
	gpio_free(TCC_GPEXT3(15));
	#endif
	return 0;
}
Пример #6
0
int tcc_bt_power_control(int on_off)
{
	volatile PGPIO pGPIO = (volatile PGPIO)tcc_p2v(HwGPIO_BASE);
    
	printk("[## BT ##] tcc_bt_power_control input[%d]\n", on_off);
	
	if(on_off == BT_DEV_ON)
	{	    
  	      if (machine_is_tcc8900()) {
            // power on
			gpio_set_value(TCC_GPB(25), 1);			/* bt_power, mapped on BT_WAKE */
			msleep(500);

            // reset
			gpio_set_value(TCC_GPEXT2(9), 0); /* /reset, mapped on BT_HWAKE */
			msleep(500);
			gpio_set_value(TCC_GPEXT2(9), 1);

			msleep(300);
		}
		else if (machine_is_tcc9300() || machine_is_tcc8800() || machine_is_tcc8920()) {      // #elif defined (CONFIG_MACH_TCC9300)
			#if defined (CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT)|| defined(CONFIG_TCC_ATHEROS_AR3002_MODULE_SUPPORT)
			//gpio_set_value(TCC_GPEXT1(7), 1);   /* BT-ON Enable */
			gpio_set_value(TCC_GPEXT3(2), 1);   /* BT_WAKE Enable , pwr_ctrl*/
			gpio_set_value(TCC_GPEXT2(4), 0);   /* reset */
			msleep(500);
			gpio_set_value(TCC_GPEXT2(4), 1);   /* reset */
			#elif defined (CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
			RDA_bt_Power_On();
			#endif	
		}
		else if (machine_is_m801_88() || machine_is_m803())
		{
			#if defined (CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT)
			gpio_set_value(TCC_GPB(22),1); // BT WAKE
			gpio_set_value(TCC_GPA(13),0); // reset
			msleep(500);
			gpio_set_value(TCC_GPA(13),1); // reset
			#elif defined (CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
			RDA_bt_Power_On();
			#endif	
		}
		else if(machine_is_tcc8800st())
		{
			gpio_set_value(TCC_GPC(31), 1); 		// BT pwr enable
			gpio_set_value(TCC_GPD(12), 0);			// BT rst 0
			msleep(500);
			gpio_set_value(TCC_GPD(12), 1);
		}
		else if (0/*machine_is_tcc9300ST()*/) {//#elif defined (CONFIG_MACH_TCC9300ST)
#if 0
			pGPIO->GPFEN	|= Hw1|Hw0;		   
			pGPIO->GPFDAT	|= Hw0;			/* BT-On Enbale */
			pGPIO->GPFDAT	&= ~Hw1;		/* BT_HWAKE Enable, reset */
			msleep(500);
			pGPIO->GPFDAT	|= Hw1;			/* BT_HWAKE Enable, reset */	
#endif
		}

	}
	else if(on_off == BT_DEV_OFF)
	{

  	      if (machine_is_tcc8900()) {
			// power off
			gpio_set_value(TCC_GPB(25), 0);			/* bt_power, mapped on BT_WAKE */
			msleep(500);

            // reset
			//gpio_direction_output(TCC_GPEXT2(9), 0);
		}else if (machine_is_tcc9300() || machine_is_tcc8800() || machine_is_tcc8920()) {      // #elif defined (CONFIG_MACH_TCC9300)
			#if defined (CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT)|| defined(CONFIG_TCC_ATHEROS_AR3002_MODULE_SUPPORT)
			//gpio_set_value(TCC_GPEXT1(7), 0);   /* BT-ON Disable */
			gpio_set_value(TCC_GPEXT3(2), 0);   /* BT_WAKE Disable */
			gpio_set_value(TCC_GPEXT2(4), 0);   /* reset */
			#elif defined (CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
			RDA_bt_Power_Off();
			#endif			
		}
		else if (machine_is_m801_88() || machine_is_m803())
		{
			#if defined (CONFIG_TCC_CSR_BC0406_MODULE_SUPPORT)
			gpio_set_value(TCC_GPB(22), 0); // BT WAKE
			gpio_set_value(TCC_GPA(13), 0); // reset
			#elif defined (CONFIG_TCC_RDA_587X_MODULE_SUPPORT)
			RDA_bt_Power_Off();
			#endif			
		}
		else if(machine_is_tcc8800st())
		{
			gpio_set_value(TCC_GPC(31), 0); 		// BT pwr enable
			gpio_set_value(TCC_GPD(12), 0);			// BT rst 0
		}
		else if (0/*machine_is_tcc9300ST()*/) {      // #elif defined (CONFIG_MACH_TCC9300ST)
#if 0
			pGPIO->GPFEN    |= Hw1|Hw0;
			pGPIO->GPFDAT   &= ~Hw0;                /* BT-On Enbale */
			pGPIO->GPFDAT   &= ~Hw1;                /* BT_HWAKE Enable, reset */
#endif
		}

	}
	else
	{
		printk("[## BT_ERR ##] input_error On[%d] Off[%d]\n", BT_DEV_ON, BT_DEV_OFF);
	}

	return 0;
}