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 bcm4335_bluetooth_probe(struct platform_device *pdev) { int rc = 0; int ret; rc = gpio_request(GPIO_BT_EN, "bcm4335_bten_gpio"); if (unlikely(rc)) { pr_err("[BT] GPIO_BT_EN request failed.\n"); return rc; } rc = gpio_request(GPIO_BT_WAKE, "bcm4335_btwake_gpio"); if (unlikely(rc)) { pr_err("[BT] GPIO_BT_WAKE request failed.\n"); gpio_free(GPIO_BT_EN); return rc; } rc = gpio_request(GPIO_BT_HOST_WAKE, "bcm4335_bthostwake_gpio"); if (unlikely(rc)) { pr_err("[BT] GPIO_BT_HOST_WAKE request failed.\n"); gpio_free(GPIO_BT_WAKE); gpio_free(GPIO_BT_EN); return rc; } s3c_gpio_setpull(GPIO_BT_HOST_WAKE, S3C_GPIO_PULL_NONE); gpio_direction_input(GPIO_BT_HOST_WAKE); gpio_direction_output(GPIO_BT_WAKE, 0); gpio_direction_output(GPIO_BT_EN, 0); bt_rfkill = rfkill_alloc("bcm4335 Bluetooth", &pdev->dev, RFKILL_TYPE_BLUETOOTH, &bcm4335_bt_rfkill_ops, NULL); if (unlikely(!bt_rfkill)) { pr_err("[BT] bt_rfkill alloc failed.\n"); gpio_free(GPIO_BT_HOST_WAKE); gpio_free(GPIO_BT_WAKE); gpio_free(GPIO_BT_EN); return -ENOMEM; } rfkill_init_sw_state(bt_rfkill, 0); rc = rfkill_register(bt_rfkill); if (unlikely(rc)) { pr_err("[BT] bt_rfkill register failed.\n"); rfkill_destroy(bt_rfkill); gpio_free(GPIO_BT_HOST_WAKE); gpio_free(GPIO_BT_WAKE); gpio_free(GPIO_BT_EN); return -1; } rfkill_set_sw_state(bt_rfkill, true); #ifdef BT_LPM_ENABLE ret = bcm_bt_lpm_init(pdev); if (ret) { rfkill_unregister(bt_rfkill); rfkill_destroy(bt_rfkill); gpio_free(GPIO_BT_HOST_WAKE); gpio_free(GPIO_BT_WAKE); gpio_free(GPIO_BT_EN); } #endif return rc; }
static int bcm43455_bluetooth_probe(struct platform_device *pdev) { int rc = 0; #ifdef BT_LPM_ENABLE int ret; #endif pr_err("[BT] bcm43455_bluetooth_probe.\n"); bt_gpio.bt_en = of_get_gpio(pdev->dev.of_node, 0); if (!gpio_is_valid(bt_gpio.bt_en)) { pr_err("[BT] bt_gpio.bt_en get gpio failed.\n"); return -EINVAL; } rc = gpio_request(bt_gpio.bt_en, "bten_gpio"); if (unlikely(rc)) { pr_err("[BT] bt_gpio.bt_en request failed.\n"); return rc; } bt_gpio.bt_wake =of_get_gpio(pdev->dev.of_node, 1); if (!gpio_is_valid(bt_gpio.bt_wake)) { pr_err("[BT] bt_gpio.bt_wake get gpio failed.\n"); return -EINVAL; } rc = gpio_request(bt_gpio.bt_wake, "btwake_gpio"); if (unlikely(rc)) { pr_err("[BT] bt_gpio.bt_wake request failed.\n"); gpio_free(bt_gpio.bt_en); return rc; } bt_gpio.bt_hostwake =of_get_gpio(pdev->dev.of_node, 2); if (!gpio_is_valid(bt_gpio.bt_hostwake)) { pr_err("[BT] bt_gpio.bt_hostwake get gpio failed.\n"); return -EINVAL; } rc = gpio_request(bt_gpio.bt_hostwake,"bthostwake_gpio"); if (unlikely(rc)) { pr_err("[BT] bt_gpio.bt_hostwake request failed.\n"); gpio_free(bt_gpio.bt_wake); gpio_free(bt_gpio.bt_en); return rc; } gpio_direction_input(bt_gpio.bt_hostwake); gpio_direction_output(bt_gpio.bt_wake, 0); gpio_direction_output(bt_gpio.bt_en, 0); bt_rfkill = rfkill_alloc("bcm43455 Bluetooth", &pdev->dev, RFKILL_TYPE_BLUETOOTH, &bcm43455_bt_rfkill_ops, NULL); if (unlikely(!bt_rfkill)) { pr_err("[BT] bt_rfkill alloc failed.\n"); gpio_free(bt_gpio.bt_hostwake); gpio_free(bt_gpio.bt_wake); gpio_free(bt_gpio.bt_en); return -ENOMEM; } rfkill_init_sw_state(bt_rfkill, 0); rc = rfkill_register(bt_rfkill); if (unlikely(rc)) { pr_err("[BT] bt_rfkill register failed.\n"); rfkill_destroy(bt_rfkill); gpio_free(bt_gpio.bt_hostwake); gpio_free(bt_gpio.bt_wake); gpio_free(bt_gpio.bt_en); return -1; } rfkill_set_sw_state(bt_rfkill, true); #ifdef BT_LPM_ENABLE ret = bcm_bt_lpm_init(pdev); if (ret) { rfkill_unregister(bt_rfkill); rfkill_destroy(bt_rfkill); gpio_free(bt_gpio.bt_hostwake); gpio_free(bt_gpio.bt_wake); gpio_free(bt_gpio.bt_en); } #endif pr_info("[BT] bcm43455_bluetooth_probe End \n"); return rc; }
static int bcm43xx_bluetooth_probe(struct platform_device *pdev) { bool default_state = true; /* off */ int ret = 0; int_handler_enabled = false; #ifdef CONFIG_ACPI if (ACPI_HANDLE(&pdev->dev)) { /* * acpi specific probe */ pr_debug("%s for ACPI device %s\n", __func__, dev_name(&pdev->dev)); if (bcm_bt_lpm_acpi_probe(pdev) < 0) ret = -EINVAL; } else ret = -ENODEV; #else ret = bcm43xx_bluetooth_pdata_probe(pdev); #endif if (ret < 0) { pr_err("%s: Cannot register platform data\n", __func__); goto err_data_probe; } ret = gpio_request(bt_lpm.gpio_enable_bt, pdev->name); if (ret < 0) { pr_err("%s: Unable to request gpio %d\n", __func__, bt_lpm.gpio_enable_bt); goto err_gpio_enable_req; } ret = gpio_direction_output(bt_lpm.gpio_enable_bt, 0); if (ret < 0) { pr_err("%s: Unable to set int direction for gpio %d\n", __func__, bt_lpm.gpio_enable_bt); goto err_gpio_enable_dir; } #ifdef LPM_ON ret = gpio_request(bt_lpm.gpio_host_wake, pdev->name); if (ret < 0) { pr_err("%s: Unable to request gpio %d\n", __func__, bt_lpm.gpio_host_wake); goto err_gpio_host_wake_req; } ret = gpio_direction_input(bt_lpm.gpio_host_wake); if (ret < 0) { pr_err("%s: Unable to set direction for gpio %d\n", __func__, bt_lpm.gpio_host_wake); goto err_gpio_host_wake_dir; } ret = gpio_request(bt_lpm.gpio_wake, pdev->name); if (ret < 0) { pr_err("%s: Unable to request gpio %d\n", __func__, bt_lpm.gpio_wake); goto err_gpio_wake_req; } ret = gpio_direction_output(bt_lpm.gpio_wake, 0); if (ret < 0) { pr_err("%s: Unable to set direction for gpio %d\n", __func__, bt_lpm.gpio_wake); goto err_gpio_wake_dir; } pr_debug("%s: gpio_enable=%d, gpio_wake=%d, gpio_host_wake=%d\n", __func__, bt_lpm.gpio_enable_bt, bt_lpm.gpio_wake, bt_lpm.gpio_host_wake); #endif bt_rfkill = rfkill_alloc("bcm43xx Bluetooth", &pdev->dev, RFKILL_TYPE_BLUETOOTH, &bcm43xx_bt_rfkill_ops, NULL); if (unlikely(!bt_rfkill)) { ret = -ENOMEM; goto err_rfkill_alloc; } bcm43xx_bt_rfkill_set_power(NULL, default_state); rfkill_init_sw_state(bt_rfkill, default_state); ret = rfkill_register(bt_rfkill); if (unlikely(ret)) goto err_rfkill_register; #ifdef LPM_ON ret = bcm_bt_lpm_init(pdev); if (ret) goto err_lpm_init; #endif return ret; err_lpm_init: rfkill_unregister(bt_rfkill); err_rfkill_register: rfkill_destroy(bt_rfkill); err_rfkill_alloc: #ifdef LPM_ON err_gpio_wake_dir: gpio_free(bt_lpm.gpio_wake); err_gpio_wake_req: err_gpio_host_wake_dir: gpio_free(bt_lpm.gpio_host_wake); err_gpio_host_wake_req: #endif err_gpio_enable_dir: gpio_free(bt_lpm.gpio_enable_bt); err_gpio_enable_req: err_data_probe: return ret; }
static int bcm2076_bluetooth_probe(struct platform_device *pdev) { int rc = 0; int ret = 0; pr_debug( "%s: TOP\n",__FUNCTION__); #if 1 pr_debug( "%s: skipping gpio_request(BT_RESET and BT_REG_GPIO). was done in boardconfig\n",__FUNCTION__); #else rc = gpio_request(BT_RESET_GPIO, "bcm2076"); if (unlikely(rc)) { return rc; } rc = gpio_request(BT_REG_GPIO, "bcm2076"); if (unlikely(rc)) { gpio_free(BT_RESET_GPIO); return rc; } #endif //att already done in board config #if 1 pr_debug( "%s: clk32kaudio always on. No need to call regulator_get()\n",__FUNCTION__); #else clk32kaudio_reg = regulator_get(0, "clk32kaudio"); if (IS_ERR(clk32kaudio_reg)) { pr_err("clk32kaudio reg not found!\n"); clk32kaudio_reg = NULL; } #endif #if 1 pr_debug( "%s skipping powering on BT_REG_GPIO, already done in board config\n",__FUNCTION__); #else gpio_direction_output(BT_REG_GPIO, 1); gpio_direction_output(BT_RESET_GPIO, 1); #endif bt_rfkill = rfkill_alloc("bcm2076 Bluetooth", &pdev->dev, RFKILL_TYPE_BLUETOOTH, &bcm2076_bt_rfkill_ops, NULL); if (unlikely(!bt_rfkill)) { pr_debug( "%s: rfkill_alloc('bcm2076_Bluetooth') failed, bt_rfkill=%d\n",__FUNCTION__,(int)bt_rfkill); return -ENOMEM; } rc = rfkill_register(bt_rfkill); if (unlikely(rc)) { pr_debug( "%s: rfkill_register(bt_rfkill) failed, rc=%d\n",__FUNCTION__,rc); rfkill_destroy(bt_rfkill); return -1; } rfkill_set_states(bt_rfkill, true, false); bcm2076_bt_rfkill_set_power(NULL, true); ret = bcm_bt_lpm_init(pdev); if (ret) { pr_debug( "%s: bcm_bt_lpm_init failed, ret=%d\n",__FUNCTION__,ret); rfkill_unregister(bt_rfkill); rfkill_destroy(bt_rfkill); } pr_debug( "%s: END ret = %d\n",__FUNCTION__,ret); return ret; }