static int incrediblec_rfkill_remove(struct platform_device *dev) { rfkill_unregister(bt_rfk); rfkill_free(bt_rfk); return 0; }
static int bluetooth_power_rfkill_probe(struct platform_device *pdev) { struct rfkill *rfkill; int ret; /* force Bluetooth off during init to allow for user control */ ret = rfkill_set_default(RFKILL_TYPE_BLUETOOTH, RFKILL_STATE_SOFT_BLOCKED); if (ret) { printk(KERN_DEBUG "%s: rfkill set default failed=%d\n", __func__, ret); return ret; } rfkill = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!rfkill) { dev_err(&pdev->dev, "rfkill allocate failed\n"); return -ENOMEM; } rfkill->name = "bt_power"; rfkill->toggle_radio = bluetooth_toggle_radio; rfkill->data = pdev->dev.platform_data; ret = rfkill_register(rfkill); if (ret) { dev_err(&pdev->dev, "rfkill register failed=%d\n", ret); rfkill_free(rfkill); return ret; } platform_set_drvdata(pdev, rfkill); return 0; }
static int gta02_bt_remove(struct platform_device *pdev) { struct gta02_pm_bt_data *bt_data = dev_get_drvdata(&pdev->dev); struct regulator *regulator; sysfs_remove_group(&pdev->dev.kobj, >a02_bt_attr_group); if (bt_data->rfkill) { rfkill_unregister(bt_data->rfkill); rfkill_free(bt_data->rfkill); } if (!bt_data || !bt_data->regulator) return 0; regulator = bt_data->regulator; /* Make sure regulator is disabled before calling regulator_put */ if (regulator_is_enabled(regulator)) regulator_disable(regulator); regulator_put(regulator); kfree(bt_data); return 0; }
static int __init smdk6410_btsleep_probe(struct platform_device *pdev) #endif /* #ifdef CONFIG_MACH_JET */ #endif /* #ifdef CONFIG_MACH_SPICA */ #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ { int rc = 0; bt_sleep = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!bt_sleep) return -ENOMEM; bt_sleep->name = bt_name; bt_sleep->state = RFKILL_STATE_UNBLOCKED; /* userspace cannot take exclusive control */ bt_sleep->user_claim_unsupported = 1; bt_sleep->user_claim = 0; bt_sleep->data = NULL; // user data bt_sleep->toggle_radio = bluetooth_set_sleep; rc = rfkill_register(bt_sleep); if (rc) rfkill_free(bt_sleep); #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] rfkill_force_state(bt_sleep, RFKILL_STATE_UNBLOCKED) \n"); #else printk(KERN_DEBUG "[BT] rfkill_force_state(bt_sleep, RFKILL_STATE_UNBLOCKED) \n"); #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ rfkill_force_state(bt_sleep, RFKILL_STATE_UNBLOCKED); bluetooth_set_sleep(NULL, RFKILL_STATE_UNBLOCKED); return rc; }
static int __init socle_rfkill_probe(struct platform_device *pdev) { int rc = 0; /* default to bluetooth off */ rfkill_switch_all(RFKILL_TYPE_BLUETOOTH, RFKILL_STATE_SOFT_BLOCKED); bluetooth_set_power(NULL, RFKILL_STATE_SOFT_BLOCKED); bt_rfk = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!bt_rfk) return -ENOMEM; bt_rfk->name = bt_name; bt_rfk->state = RFKILL_STATE_SOFT_BLOCKED; /* userspace cannot take exclusive control */ bt_rfk->user_claim_unsupported = 1; bt_rfk->user_claim = 0; bt_rfk->data = NULL; // user data bt_rfk->toggle_radio = bluetooth_set_power; rc = rfkill_register(bt_rfk); if (rc) rfkill_free(bt_rfk); return rc; }
static int legend_rfkill_probe(struct platform_device *pdev) { int rc = 0; enum rfkill_state default_state = RFKILL_STATE_SOFT_BLOCKED; /* off */ /* force BT on and off to do GPIO setting when initiate */ bluetooth_set_power(NULL, RFKILL_STATE_UNBLOCKED); legend_config_bt_init(); /* bt gpio initial config */ rfkill_set_default(RFKILL_TYPE_BLUETOOTH, default_state); bluetooth_set_power(NULL, default_state); bt_rfk = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!bt_rfk) return -ENOMEM; bt_rfk->name = bt_name; bt_rfk->state = default_state; /* userspace cannot take exclusive control */ bt_rfk->user_claim_unsupported = 1; bt_rfk->user_claim = 0; bt_rfk->data = NULL; /* user data */ bt_rfk->toggle_radio = bluetooth_set_power; rc = rfkill_register(bt_rfk); if (rc) rfkill_free(bt_rfk); return rc; }
static int liberty_rfkill_probe(struct platform_device *pdev) { int rc = 0; enum rfkill_state default_state = RFKILL_STATE_SOFT_BLOCKED; liberty_config_bt_init(); /* bt gpio initial config */ rfkill_set_default(RFKILL_TYPE_BLUETOOTH, default_state); bluetooth_set_power(NULL, default_state); bt_rfk = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!bt_rfk) return -ENOMEM; bt_rfk->name = bt_name; bt_rfk->state = default_state; /* userspace cannot take exclusive control */ bt_rfk->user_claim_unsupported = 1; bt_rfk->user_claim = 0; bt_rfk->data = NULL; bt_rfk->toggle_radio = bluetooth_set_power; rc = rfkill_register(bt_rfk); if (rc) goto err_rfkill_reg; return 0; err_rfkill_reg: rfkill_free(bt_rfk); return rc; }
static int sapphire_rfkill_remove(struct platform_device *dev) { rfkill_unregister(bt_rfk); rfkill_free(bt_rfk); return 0; }
static int __init jupiter_btsleep_probe(struct platform_device *pdev) { int rc = 0; bt_sleep = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!bt_sleep) return -ENOMEM; bt_sleep->name = "bt_sleep"; bt_sleep->state = 1; bt_sleep->state = RFKILL_STATE_SOFT_BLOCKED; /* userspace cannot take exclusive control */ bt_sleep->user_claim_unsupported = 1; bt_sleep->user_claim = 0; bt_sleep->data = NULL; // user data bt_sleep->toggle_radio = bluetooth_set_sleep; rc = rfkill_register(bt_sleep); if (rc) rfkill_free(bt_sleep); printk(KERN_DEBUG "[BT] rfkill_force_state(bt_sleep, RFKILL_STATE_UNBLOCKED) \n"); rfkill_force_state(bt_sleep, RFKILL_STATE_UNBLOCKED); bluetooth_set_sleep(NULL, RFKILL_STATE_UNBLOCKED); return rc; }
void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) { if (!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->flags)) return; cancel_delayed_work_sync(&rt2x00dev->rfkill_work); rfkill_free(rt2x00dev->rfkill); rt2x00dev->rfkill = NULL; }
static int fxn_rfkill_remove(struct platform_device *pdev) { struct fxn_rfkill_platform_data *pdata = pdev->dev.platform_data; //printk(">>> fxn_rfkill_remove\n"); #ifdef CONFIG_RFKILL_WIFI if (pdata->wifi_reset_gpio >= 0) { rfkill_unregister(pdata->rfkill[FXN_WIFI]); rfkill_free(pdata->rfkill[FXN_WIFI]); gpio_free(pdata->wifi_reset_gpio); } //&*&*&*BC1_110513:add the wifi suspend wakelock to avoid wifi or system crash wake_lock_destroy(&wifi_lock); //&*&*&*BC2_110513:add the wifi suspend wakelock to avoid wifi or system crash #endif // BT #ifdef CONFIG_RFKILL_BT if(DBG) printk("<RFKILL_BT>\n"); if (pdata->bt_reset_gpio >= 0) { rfkill_unregister(pdata->rfkill[FXN_BT]); rfkill_free(pdata->rfkill[FXN_BT]); gpio_free(pdata->bt_reset_gpio); } #endif // GPS #ifdef CONFIG_RFKILL_GPS if(DBG) printk("<RFKILL_GPS>\n"); if (pdata->gps_pwr_en_gpio >= 0) { rfkill_unregister(pdata->rfkill[FXN_GPS]); rfkill_free(pdata->rfkill[FXN_GPS]); gpio_free(pdata->gps_pwr_en_gpio); } #endif //printk("<<< fxn_rfkill_remove\n"); return 0; }
static int __init smdk6410_rfkill_probe(struct platform_device *pdev) #endif /* #ifdef CONFIG_MACH_JET */ #endif /* #ifdef CONFIG_MACH_SPICA */ #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ { int rc = 0; int irq,ret; //Initialize wake locks wake_lock_init(&rfkill_wake_lock, WAKE_LOCK_SUSPEND, "board-rfkill"); wake_lock_init(&bt_wake_lock, WAKE_LOCK_SUSPEND, "bt-rfkill"); //BT Host Wake IRQ irq = IRQ_BT_HOST_WAKE; ret = request_irq(irq, bt_host_wake_irq_handler, 0, "bt_host_wake_irq_handler", NULL); if(ret < 0) #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] Request_irq failed \n"); #else printk(KERN_DEBUG "[BT] Request_irq failed \n"); #endif /* #else #ifdef CONFIG_MACH_INSTINCTQ */ set_irq_type(irq, IRQ_TYPE_EDGE_BOTH); enable_irq(IRQ_EINT(22)); //RFKILL init - default to bluetooth off rfkill_switch_all(RFKILL_TYPE_BLUETOOTH, RFKILL_STATE_SOFT_BLOCKED); bt_rfk = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!bt_rfk) return -ENOMEM; bt_rfk->name = bt_name; bt_rfk->state = RFKILL_STATE_SOFT_BLOCKED; /* userspace cannot take exclusive control */ bt_rfk->user_claim_unsupported = 1; bt_rfk->user_claim = 0; bt_rfk->data = NULL; // user data bt_rfk->toggle_radio = bluetooth_set_power; #ifdef CONFIG_MACH_INSTINCTQ printk("[BT] rfkill_register(bt_rfk) \n"); #else printk(KERN_DEBUG "[BT] rfkill_register(bt_rfk) \n"); #endif /* #ifdef CONFIG_MACH_INSTINCTQ */ rc = rfkill_register(bt_rfk); if (rc) rfkill_free(bt_rfk); bluetooth_set_power(NULL, RFKILL_STATE_SOFT_BLOCKED); return rc; }
static int __init jupiter_rfkill_probe(struct platform_device *pdev) { int rc = 0; int irq,ret; //Initialize wake locks wake_lock_init(&rfkill_wake_lock, WAKE_LOCK_SUSPEND, "board-rfkill"); wake_lock_init(&bt_wake_lock, WAKE_LOCK_SUSPEND, "bt-rfkill"); //BT Host Wake IRQ irq = IRQ_BT_HOST_WAKE; set_irq_type(irq, IRQ_TYPE_EDGE_BOTH); ret = request_irq(irq, bt_host_wake_irq_handler, 0, "bt_host_wake_irq_handler", NULL); if(ret < 0) printk(KERN_ERR "[BT] Request_irq failed \n"); set_irq_type(irq, IRQ_TYPE_EDGE_BOTH); // enable_irq(IRQ_EINT(22)); //RFKILL init - default to bluetooth off rfkill_switch_all(RFKILL_TYPE_BLUETOOTH, RFKILL_STATE_SOFT_BLOCKED); bt_rfk = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!bt_rfk) return -ENOMEM; bt_rfk->name = bt_name; bt_rfk->state = RFKILL_STATE_SOFT_BLOCKED; /* userspace cannot take exclusive control */ bt_rfk->user_claim_unsupported = 1; bt_rfk->user_claim = 0; bt_rfk->data = NULL; // user data bt_rfk->toggle_radio = bluetooth_set_power; printk(KERN_DEBUG "[BT] rfkill_register(bt_rfk) \n"); rc = rfkill_register(bt_rfk); if (rc) { printk (KERN_ERR "***********ERROR IN REGISTERING THE RFKILL***********\n"); rfkill_free(bt_rfk); } bluetooth_set_power(NULL, RFKILL_STATE_SOFT_BLOCKED); rfkill_force_state(bt_rfk, RFKILL_STATE_SOFT_BLOCKED); return rc; }
static int lensl_radio_new_rfkill(struct lensl_radio *radio, struct rfkill **rfk, bool sw_blocked, bool hw_blocked) { int res; *rfk = rfkill_allocate(&lensl_pdev->dev, radio->rfktype); if (!*rfk) { vdbg_printk(LENSL_ERR, "Failed to allocate memory for rfkill class\n"); return -ENOMEM; } (*rfk)->name = radio->rfkname; (*rfk)->get_state = lensl_radio_rfkill_get_state; (*rfk)->toggle_radio = lensl_radio_rfkill_toggle_radio; (*rfk)->data = radio; if (hw_blocked) (*rfk)->state = RFKILL_STATE_HARD_BLOCKED; else if (sw_blocked) (*rfk)->state = RFKILL_STATE_SOFT_BLOCKED; else (*rfk)->state = RFKILL_STATE_UNBLOCKED; res = rfkill_register(*rfk); if (res < 0) { vdbg_printk(LENSL_ERR, "Failed to register %s rfkill switch: %d\n", radio->rfkname, res); rfkill_free(*rfk); *rfk = NULL; return res; } return 0; }
static int lensl_new_rfkill(const unsigned int id, struct rfkill **rfk, const enum rfkill_type rfktype, const char *name, int (*toggle_radio)(void *, enum rfkill_state), int (*get_state)(void *, enum rfkill_state *)) { int res; enum rfkill_state initial_state; *rfk = rfkill_allocate(&lensl_pdev->dev, rfktype); if (!*rfk) { vdbg_printk(LENSL_ERR, "Failed to allocate memory for rfkill class\n"); return -ENOMEM; } (*rfk)->name = name; (*rfk)->get_state = get_state; (*rfk)->toggle_radio = toggle_radio; if (!get_state(NULL, &initial_state)) (*rfk)->state = initial_state; res = rfkill_register(*rfk); if (res < 0) { vdbg_printk(LENSL_ERR, "Failed to register %s rfkill switch: %d\n", name, res); rfkill_free(*rfk); *rfk = NULL; return res; } return 0; }
static int fxn_rfkill_probe(struct platform_device *pdev) { int rc = 0; struct fxn_rfkill_platform_data *pdata = pdev->dev.platform_data; enum rfkill_state default_state = RFKILL_STATE_UNBLOCKED; //printk(">>> fxn_rfkill_probe\n"); // WiFi #ifdef CONFIG_RFKILL_WIFI if(DBG) printk("<RFKILL_WIFI>\n"); if (pdata->wifi_reset_gpio >= 0) { rfkill_set_default(RFKILL_TYPE_WLAN, RFKILL_STATE_UNBLOCKED); pdata->rfkill[FXN_WIFI] = rfkill_allocate(&pdev->dev, RFKILL_TYPE_WLAN); if (unlikely(!pdata->rfkill[FXN_WIFI])) { return -ENOMEM; } // printk(" WL_RST_N GPIO %d to HIGH\n", (void *)pdata->wifi_reset_gpio); fxn_rfkill_set_power_wifi((void *)pdata->wifi_reset_gpio, RFKILL_STATE_UNBLOCKED); pdata->rfkill[FXN_WIFI]->name = "fxn_wifi"; pdata->rfkill[FXN_WIFI]->state = default_state; /* userspace cannot take exclusive control */ pdata->rfkill[FXN_WIFI]->user_claim_unsupported = 1; pdata->rfkill[FXN_WIFI]->user_claim = 0; pdata->rfkill[FXN_WIFI]->data = (void *)pdata->wifi_reset_gpio; pdata->rfkill[FXN_WIFI]->toggle_radio = fxn_rfkill_set_power_wifi; rc = rfkill_register(pdata->rfkill[FXN_WIFI]); if (unlikely(rc)) { rfkill_free(pdata->rfkill[FXN_WIFI]); return rc; } } //&*&*&*BC1_110513:add the wifi suspend wakelock to avoid wifi or system crash wake_lock_init(&wifi_lock, WAKE_LOCK_SUSPEND, "wifi_wake_lock"); //&*&*&*BC2_110513:add the wifi suspend wakelock to avoid wifi or system crash #endif // Bluetooth #ifdef CONFIG_RFKILL_BT if(DBG) printk("<RFKILL_BT>\n"); if (pdata->bt_reset_gpio >= 0) { rfkill_set_default(RFKILL_TYPE_BLUETOOTH, RFKILL_STATE_SOFT_BLOCKED); // printk(" BT_RST_N to LOW\n"); fxn_rfkill_set_power_bt((void *)pdata->bt_reset_gpio, RFKILL_STATE_SOFT_BLOCKED); pdata->rfkill[FXN_BT] = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (unlikely(!pdata->rfkill[FXN_BT])) { return -ENOMEM; } pdata->rfkill[FXN_BT]->name = "fxn_bt"; pdata->rfkill[FXN_BT]->state = default_state; /* userspace cannot take exclusive control */ pdata->rfkill[FXN_BT]->user_claim_unsupported = 1; pdata->rfkill[FXN_BT]->user_claim = 0; pdata->rfkill[FXN_BT]->data = (void *)pdata->bt_reset_gpio; pdata->rfkill[FXN_BT]->toggle_radio = fxn_rfkill_set_power_bt; rc = rfkill_register(pdata->rfkill[FXN_BT]); if (unlikely(rc)) { rfkill_free(pdata->rfkill[FXN_BT]); return rc; } } #endif // GPS #ifdef CONFIG_RFKILL_GPS if(DBG) printk("<RFKILL_GPS>\n"); rc = 0; if (pdata->gps_pwr_en_gpio >= 0) { rfkill_set_default(RFKILL_TYPE_GPS, RFKILL_STATE_SOFT_BLOCKED); // GPS_PWR_EN if(DBG) printk(" GPS_PWR_EN to high\n"); gpio_direction_output(FXN_GPIO_GPS_PWR_EN, 1); udelay(100); // GPS_RST if(DBG) printk(" GPS_RST to high\n"); gpio_direction_output(FXN_GPIO_GPS_RST, 1); msleep(100); // GPS_ON_OFF if(DBG) printk(" GPS_ON_OFF to low\n"); gpio_direction_output(FXN_GPIO_GPS_ON_OFF, 0); pdata->rfkill[FXN_GPS] = rfkill_allocate(&pdev->dev, RFKILL_TYPE_GPS); if (unlikely(!pdata->rfkill[FXN_GPS])) { return -ENOMEM; } // set BLOCKED as default fxn_rfkill_set_power_gps((void *)pdata->gps_pwr_en_gpio, RFKILL_STATE_SOFT_BLOCKED); pdata->rfkill[FXN_GPS]->name = "fxn_gps"; pdata->rfkill[FXN_GPS]->state = default_state; /* userspace cannot take exclusive control */ pdata->rfkill[FXN_GPS]->user_claim_unsupported = 1; pdata->rfkill[FXN_GPS]->user_claim = 0; pdata->rfkill[FXN_GPS]->data = (void *)pdata->gps_pwr_en_gpio; pdata->rfkill[FXN_GPS]->toggle_radio = fxn_rfkill_set_power_gps; rc = rfkill_register(pdata->rfkill[FXN_GPS]); if (unlikely(rc)) { rfkill_free(pdata->rfkill[FXN_GPS]); return rc; } } #endif //printk("<<< fxn_rfkill_probe\n"); return 0; }
static void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) { rfkill_free(rt2x00dev->rfkill); rt2x00dev->rfkill = NULL; }
static int __init apollo_rfkill_probe(struct platform_device *pdev) { int ret; s5p_config_gpio_alive_table(ARRAY_SIZE(bt_gpio_table), bt_gpio_table); /* Host Wake IRQ */ wake_lock_init(&bt_host_wakelock, WAKE_LOCK_SUSPEND, "bt_host_wake"); bt_rfkill = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!bt_rfkill) goto err_rfkill; bt_rfkill->name = "bt_rfkill"; /* userspace cannot take exclusive control */ bt_rfkill->user_claim_unsupported = 1; bt_rfkill->user_claim = 0; bt_rfkill->data = pdev; /* user data */ bt_rfkill->toggle_radio = bluetooth_set_power; /* set bt_rfkill default state to off */ rfkill_set_default(RFKILL_TYPE_BLUETOOTH, RFKILL_STATE_SOFT_BLOCKED); ret = rfkill_register(bt_rfkill); if (ret) { rfkill_free(bt_rfkill); goto err_rfkill; } #ifdef BT_SLEEP_ENABLE wake_lock_init(&bt_wakelock, WAKE_LOCK_SUSPEND, "bt_wake"); bt_sleep = rfkill_allocate(&pdev->dev, RFKILL_TYPE_BLUETOOTH); if (!bt_sleep) goto err_sleep; bt_sleep->name = "bt_sleep"; /* userspace cannot take exclusive control */ bt_sleep->user_claim_unsupported = 1; bt_sleep->user_claim = 0; bt_sleep->data = NULL; /* user data */ bt_sleep->toggle_radio = bluetooth_set_sleep; ret = rfkill_register(bt_sleep); if (ret) { rfkill_free(bt_sleep); goto err_sleep; } /* set bt_sleep default state to wake_unlock */ rfkill_force_state(bt_sleep, RFKILL_STATE_UNBLOCKED); #endif /* BT_SLEEP_ENABLE */ return 0; err_sleep: wake_lock_destroy(&bt_wakelock); rfkill_unregister(bt_rfkill); err_rfkill: wake_lock_destroy(&bt_host_wakelock); return ret; }