/*************************************************
Function:       bluetooth_power_rfkill_probe
Description:    rfkill init function
Calls:              rfkill_alloc()
                    rfkill_init_sw_state()
                    rfkill_register()
                    rfkill_destroy()
Input:          platform_device *pdev
                bluetooth_power_private_data *p_dev_data
Output:         
Return:         int ret
Others:         NA
*************************************************/
static int bluetooth_power_rfkill_probe(struct platform_device *pdev, 
                struct bluetooth_power_private_data *p_dev_data)
{
	int ret = 0;

	printk(KERN_INFO "bluetooth_power_rfkill_probe in \n");

	/* alloc memery for rfkill */
	p_dev_data->rfkill = rfkill_alloc("bt_power", 
	&pdev->dev, RFKILL_TYPE_BLUETOOTH, &bluetooth_power_rfkill_ops, pdev);
	if(!p_dev_data->rfkill){
		dev_err(&pdev->dev,	"bluetooth rfkill allocate failed\n");
		return -ENOMEM;
	}

	/* force Bluetooth off during init to allow	for	user control */
	rfkill_init_sw_state( p_dev_data->rfkill, 1);
	p_dev_data->previous =	1;

	ret	= rfkill_register( p_dev_data->rfkill );
	if (ret) {
		dev_err(&pdev->dev,	"rfkill	register failed=%d\n", ret);
		goto rfkill_failed;
	}

	printk(KERN_INFO "bluetooth_power_rfkill_probe out \n");

	return ret;

rfkill_failed:
	rfkill_destroy( p_dev_data->rfkill );
	return ret;
}
Example #2
0
static int bluetooth_power_rfkill_probe(struct platform_device *pdev)
{
	struct rfkill *rfkill;
	int ret;

	 printk("%s\n",__func__);

	rfkill = rfkill_alloc("bt_power", &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			      &bluetooth_power_rfkill_ops,
			      pdev->dev.platform_data);

	if (!rfkill) {
		dev_err(&pdev->dev, "rfkill allocate failed\n");
		return -ENOMEM;
	}

	/* force Bluetooth off during init to allow for user control */
	rfkill_init_sw_state(rfkill, 1);

	ret = rfkill_register(rfkill);
	if (ret) {
		dev_err(&pdev->dev, "rfkill register failed=%d\n", ret);
		rfkill_destroy(rfkill);
		return ret;
	}

	platform_set_drvdata(pdev, rfkill);

#ifdef BTLD_CONTROL_WAKE_GPIO
	bluesleep_rfkill_alloc();
#endif

	return 0;
}
Example #3
0
static int bluetooth_power_rfkill_probe(struct platform_device *pdev)
{
	struct rfkill *rfkill;
	int ret;
	BT_DBG("");
	rfkill = rfkill_alloc("bt_power", &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			      &bluetooth_power_rfkill_ops,
			      pdev->dev.platform_data);

	if (!rfkill) {
		dev_err(&pdev->dev, "rfkill allocate failed\n");
		return -ENOMEM;
	}

	/* force Bluetooth off during init to allow for user control */
	rfkill_init_sw_state(rfkill, 1);
	previous = 1;

	ret = rfkill_register(rfkill);
	if (ret) {
		dev_err(&pdev->dev, "rfkill register failed=%d\n", ret);
		rfkill_destroy(rfkill);
		return ret;
	}

	platform_set_drvdata(pdev, rfkill);

	return 0;
}
static int rfkill_bluetooth_probe(struct platform_device *pdev)
{

	int rc = 0;
	bool default_state = true;

	printk(KERN_INFO "-->%s\n", __func__);
	getIoResource(pdev);

	bt_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
	   &rfkill_bluetooth_ops, NULL);
	if (!bt_rfk) {
	 rc = -ENOMEM;
	 goto err_rfkill_alloc;
	}
        rfkill_gpio_init();
	/* userspace cannot take exclusive control */
	rfkill_init_sw_state(bt_rfk,false);
	rc = rfkill_register(bt_rfk);
	if (rc)
		goto err_rfkill_reg;

	rfkill_set_sw_state(bt_rfk,true);
	bluetooth_set_power(NULL, default_state);

	printk(KERN_INFO "<--%s\n", __func__);
	return 0;

err_rfkill_reg:
	rfkill_destroy(bt_rfk);
err_rfkill_alloc:
	return rc;
}
static int bluetooth_power_rfkill_probe(struct platform_device *pdev)
{
	struct rfkill *rfkill;
	int ret;
#if defined (CONFIG_MACH_LGE_I_BOARD)
		bluetooth_power_rfkill_ops.set_block = bt_platform_data->bluetooth_toggle_radio;
#endif

	rfkill = rfkill_alloc("bt_power", &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			      &bluetooth_power_rfkill_ops,
			      pdev->dev.platform_data);

	if (!rfkill) {
		dev_err(&pdev->dev, "rfkill allocate failed\n");
		return -ENOMEM;
	}

	/* force Bluetooth off during init to allow for user control */
	rfkill_init_sw_state(rfkill, 1);
#if !defined (CONFIG_MACH_LGE_I_BOARD)	
	previous = 1;
#endif

	ret = rfkill_register(rfkill);
	if (ret) {
		dev_err(&pdev->dev, "rfkill register failed=%d\n", ret);
		rfkill_destroy(rfkill);
		return ret;
	}

	platform_set_drvdata(pdev, rfkill);

	return 0;
}
static int bluetooth_power_rfkill_probe(struct platform_device *pdev)
{
	struct rfkill *rfkill;
	int ret;

	rfkill = rfkill_alloc("bt_power", &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			      &bluetooth_power_rfkill_ops,
			      pdev->dev.platform_data);

	if (!rfkill) {
		dev_err(&pdev->dev, "rfkill allocate failed\n");
		return -ENOMEM;
	}

	/* add file into rfkill0 to handle LDO27 */
	ret = device_create_file(&pdev->dev, &dev_attr_extldo);
	if (ret < 0)
		BT_PWR_ERR("device create file error!");

	/* force Bluetooth off during init to allow for user control */
	rfkill_init_sw_state(rfkill, 1);
	previous = 1;

	ret = rfkill_register(rfkill);
	if (ret) {
		dev_err(&pdev->dev, "rfkill register failed=%d\n", ret);
		rfkill_destroy(rfkill);
		return ret;
	}

	platform_set_drvdata(pdev, rfkill);

	return 0;
}
Example #7
0
static int wifi_rfkill_probe(struct platform_device *pdev)
{
	int ret = -ENOMEM;

	g_WifiRfkill = rfkill_alloc("wifi_ar6k", &pdev->dev, RFKILL_TYPE_WLAN,
			&wifi_power_rfkill_ops,
			NULL);

	if (!g_WifiRfkill) {
		printk(KERN_DEBUG
				"%s: wifi rfkill register failed=%d\n", __func__,
				ret);
		return -ENOMEM;
	}

	/* force Bluetooth off during init to allow for user control */
	rfkill_init_sw_state(g_WifiRfkill, 1);

	ret = rfkill_register(g_WifiRfkill);
	if (ret) {
		printk(KERN_DEBUG
				"%s: rfkill register failed=%d\n", __func__,
				ret);
		rfkill_destroy(g_WifiRfkill);
		return ret;
	}
	return ret;
}
Example #8
0
static int bcmbt_rfkill_probe(struct platform_device *pdev)
{
	int rc = 0;
	struct bcmbt_rfkill_platform_data *pdata = pdev->dev.platform_data;

	gpio_request(pdata->vreg_gpio, "rfkill_vreg_gpio");
#if 0
	pr_err("bcmbt_rfkill_probe:  Set vreg_gpio: %d, level: %s\n",
	       pdata->vreg_gpio,
	       gpio_get_value(pdata->vreg_gpio) ? "High" : "Low");
#endif
	gpio_export(pdata->vreg_gpio, false);
	gpio_direction_output(pdata->vreg_gpio, BCMBT_VREG_OFF);

	/* JIRA case --> HW4334-336*/
	gpio_set_value(pdata->vreg_gpio, BCMBT_VREG_ON);
	msleep(REG_ON_SLEEP);
	gpio_set_value(pdata->vreg_gpio, BCMBT_VREG_OFF);

	if (BCMBT_UNUSED_GPIO != pdata->n_reset_gpio) {
		gpio_request(pdata->n_reset_gpio, "rfkill_reset_gpio");
		gpio_direction_output(pdata->n_reset_gpio, BCMBT_N_RESET_ON);
		pr_err("bcmblt_probe: n_reset: %s\n",
		       gpio_get_value(pdata->
				      n_reset_gpio) ? "High [chip out of reset]"
		       : "Low [put into reset]");
	}
	if (BCMBT_UNUSED_GPIO != pdata->aux0_gpio) {	/* CLK32 */
		gpio_request(pdata->aux0_gpio, "rfkill_aux0_gpio");
		gpio_direction_output(pdata->aux0_gpio, BCMBT_AUX0_OFF);
		pr_err("bcmbt_probe:  aux0: %s\n",
		       gpio_get_value(pdata->aux0_gpio) ? "High" : "Low");
	}

	if (BCMBT_UNUSED_GPIO != pdata->aux1_gpio) {	/* UARTB_SEL */
		gpio_request(pdata->aux1_gpio, "rfkill_aux1_gpio");
		gpio_direction_output(pdata->aux1_gpio, BCMBT_AUX1_OFF);
		pr_err("bcmbt_probe:  aux1: %s\n",
		       gpio_get_value(pdata->aux1_gpio) ? "High" : "Low");
	}

	pdata->rfkill =
	    rfkill_alloc("bcmbt", &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			 &bcmbt_rfkill_ops, pdata);

	if (unlikely(!pdata->rfkill))
		return -ENOMEM;

	/* Keep BT Blocked by default as per above init */
	rfkill_init_sw_state(pdata->rfkill, true);

	rc = rfkill_register(pdata->rfkill);

	if (unlikely(rc))
		rfkill_destroy(pdata->rfkill);

	return 0;
}
static int bcm4335_bluetooth_probe(struct platform_device *pdev)
{
	int rc = 0;

    #ifdef BT_UART_CFG
    int pin = 0;
    #endif

#if defined(CONFIG_BCM4335) || defined(CONFIG_BCM4335_MODULE)
	bt_is_running = 0;
#endif
    /* temporailiy set HOST_WAKE OUT direction until FPGA work finishs */
	/* if setting HOST_WAKE to NO PULL, BT would not be turned on. */
	/* By guideline of BRCM, it is needed to determine pull status */
	#ifndef BT_LPM_ENABLE
	gpio_tlmm_config(GPIO_CFG(get_gpio_hwrev(GPIO_BT_HOST_WAKE), 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_PULL_UP, GPIO_CFG_8MA), GPIO_CFG_ENABLE);
	gpio_set_value(get_gpio_hwrev(GPIO_BT_HOST_WAKE), 1);
	#endif

    #ifdef BT_UART_CFG
    for (pin = 0; pin < ARRAY_SIZE(bt_uart_off_table); pin++) {
        rc = gpio_tlmm_config(bt_uart_off_table[pin], GPIO_CFG_ENABLE);
        if (rc < 0)
            pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
                    __func__, bt_uart_off_table[pin], rc);
    }
    #endif

	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(ice_gpiox_get(FPGA_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(ice_gpiox_get(FPGA_GPIO_BT_EN));
		return rc;
	}


	rfkill_set_sw_state(bt_rfkill, true);

	return rc;
}
Example #10
0
static int ste_rfkill_probe(struct platform_device *pdev)
{
	struct ste_rfkill_data *rfkill;
	struct rfkill *rfkdev;
	int ret = 0;

	dev_dbg(&pdev->dev, "%s\n", __func__);

	rfkill = kzalloc(sizeof(*rfkill), GFP_KERNEL);
	if (!rfkill) {
		dev_err(&pdev->dev,
			"%s: no memory to alloc driver data\n", __func__);
		ret = -ENOMEM;
		goto error0;
	}

	platform_set_drvdata(pdev, rfkill);

	/* WWAN rfkill device registration */
	rfkill->rfkdev = rfkill_alloc(pdev->name,
					&pdev->dev,
					RFKILL_TYPE_WWAN,
					&ste_rfkill_ops,
					pdev);
	rfkdev = rfkill->rfkdev;
	if (!rfkdev) {
		dev_err(&pdev->dev,
			"%s: Error allocating modem rfkdev\n", __func__);
		ret = -ENOMEM;
		goto error1;
	}

	/* S/W blocked by default, persistent */
	rfkill_init_sw_state(rfkdev, 1);
	ret = rfkill_register(rfkdev);
	if (ret) {
		dev_err(&pdev->dev,
			"%s: Error registering modem rfkdev: %d\n",
			__func__, ret);
		ret = -EINVAL;
		goto error2;
	}

	/* hardware unblocked */
	if (rfkill->rfkdev)
		rfkill_set_hw_state(rfkdev, 0);

	return 0;

error2:
	rfkill_destroy(rfkdev);
error1:
	kfree(rfkill);
error0:
	return ret;
}
Example #11
0
static int __init gta02_bt_probe(struct platform_device *pdev)
{
	struct rfkill *rfkill;
	struct regulator *regulator;
	struct gta02_pm_bt_data *bt_data;
	int ret;

	dev_info(&pdev->dev, DRVMSG ": starting\n");

	bt_data = kzalloc(sizeof(*bt_data), GFP_KERNEL);
	dev_set_drvdata(&pdev->dev, bt_data);

	regulator = regulator_get(&pdev->dev, "BT_3V2");
	if (IS_ERR(regulator))
		return -ENODEV;

	bt_data->regulator = regulator;

	/* this tests the true physical state of the regulator... */
	if (regulator_is_enabled(regulator)) {
		/*
		 * but these only operate on the logical state of the
		 * regulator... so we need to logicaly "adopt" it on
		 * to turn it off
		 */
		regulator_enable(regulator);
		regulator_disable(regulator);
	}

	/* we pull reset to low to make sure that the chip doesn't
	 * drain power through the reset line */
	s3c2410_gpio_setpin(GTA02_GPIO_BT_EN, 0);

	rfkill = rfkill_alloc(pdev->name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
                            &gta02_bt_rfkill_ops, &pdev->dev);

	if (!rfkill) {
		dev_err(&pdev->dev, "Failed to allocate rfkill\n");
		return -ENOMEM;
	}

    rfkill_init_sw_state(rfkill, 0);

	ret = rfkill_register(rfkill);
	if (ret) {
		rfkill_destroy(rfkill);
		dev_err(&pdev->dev, "Failed to register rfkill\n");
		return ret;
	}

	bt_data->rfkill = rfkill;

	return sysfs_create_group(&pdev->dev.kobj, &gta02_bt_attr_group);
}
Example #12
0
static int bcm4334_bluetooth_probe(struct platform_device *pdev)
{
	int rc = 0;

	rc = gpio_request(gpio_rev(BT_EN), "bcm4334_bten_gpio");
	if (unlikely(rc)) {
		pr_err("[BT] GPIO_BT_EN request failed.\n");
		return rc;
	}

	gpio_tlmm_config(GPIO_CFG(GPIO_BT_UART_RTS, 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_tlmm_config(GPIO_CFG(GPIO_BT_UART_CTS, 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_tlmm_config(GPIO_CFG(GPIO_BT_UART_RXD, 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_tlmm_config(GPIO_CFG(GPIO_BT_UART_TXD, 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

	gpio_tlmm_config(GPIO_CFG(gpio_rev(BT_EN), 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), GPIO_CFG_ENABLE);

	gpio_direction_output(gpio_rev(BT_EN), 0);

	bt_rfkill = rfkill_alloc("bcm4334 Bluetooth", &pdev->dev,
				RFKILL_TYPE_BLUETOOTH, &bcm4334_bt_rfkill_ops,
				NULL);

	if (unlikely(!bt_rfkill)) {
		pr_err("[BT] bt_rfkill alloc failed.\n");
		gpio_free(gpio_rev(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_rev(BT_EN));
		return -1;
	}

	rfkill_set_sw_state(bt_rfkill, true);

	return rc;
}
Example #13
0
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");
#ifdef BT_SLEEP_ENABLER
	wake_lock_init(&bt_wake_lock, WAKE_LOCK_SUSPEND, "bt-rfkill");
#endif

	//BT Host Wake IRQ
	irq = IRQ_BT_HOST_WAKE;

	s3c_gpio_cfgpin(GPIO_BT_HOST_WAKE, S3C_GPIO_SFN(GPIO_BT_HOST_WAKE_AF));
	s3c_gpio_setpull(S5PV210_GPH2(5), S3C_GPIO_PULL_DOWN);
	set_irq_type(IRQ_EINT(21), IRQ_TYPE_EDGE_BOTH);

	set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
	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");

//	enable_irq(IRQ_BT_HOST_WAKE);

	//RFKILL init - default to bluetooth off
	//rfkill_switch_all(RFKILL_TYPE_BLUETOOTH, RFKILL_USER_STATE_SOFT_BLOCKED);

	bt_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH, &bt_rfkill_ops, NULL);
	if (!bt_rfk)
		return -ENOMEM;

	rfkill_init_sw_state(bt_rfk, 0);

	printk(KERN_DEBUG "[BT] rfkill_register(bt_rfk) \n");

	rc = rfkill_register(bt_rfk);
	if (rc)
	{
		printk ("***********ERROR IN REGISTERING THE RFKILL***********\n");
		rfkill_destroy(bt_rfk);
	}

	rfkill_set_sw_state(bt_rfk, 1);
	bluetooth_set_power(NULL, RFKILL_USER_STATE_SOFT_BLOCKED);

	return rc;
}
Example #14
0
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");
#ifdef BT_SLEEP_ENABLER
	wake_lock_init(&bt_wake_lock, WAKE_LOCK_SUSPEND, "bt-rfkill");
#endif

	//BT Host Wake IRQ
	irq = IRQ_BT_HOST_WAKE;
	
	// p9p9 2010.11.12 Merged from Victory [When AP is in sleep, AP is not waken up by BT_HOST_WAKE]
	set_irq_type(irq, IRQ_TYPE_EDGE_BOTH ); //set_irq_type(irq, IRQ_TYPE_EDGE_RISING);

	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 ret=%d %d<-->%d\n", ret, IRQ_EINT(4), IRQ_EINT4);

//	enable_irq(IRQ_BT_HOST_WAKE);

	//RFKILL init - default to bluetooth off
	//rfkill_switch_all(RFKILL_TYPE_BLUETOOTH, RFKILL_USER_STATE_SOFT_BLOCKED);

	bt_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH, &bt_rfkill_ops, NULL);
	if (!bt_rfk)
		return -ENOMEM;

	rfkill_init_sw_state(bt_rfk, 0);

	printk(KERN_DEBUG "[BT] rfkill_register(bt_rfk) \n");

	rc = rfkill_register(bt_rfk);
	if (rc)
	{
		printk ("***********ERROR IN REGISTERING THE RFKILL***********\n");
		rfkill_destroy(bt_rfk);
	}

	rfkill_set_sw_state(bt_rfk, 1);
	bluetooth_set_power(NULL, RFKILL_USER_STATE_SOFT_BLOCKED);

	return rc;
}
Example #15
0
static int __init bt_probe(struct platform_device *pdev)
{
    int rc = 0;
    struct rfkill *bt_rfk;

#if 0
    INIT_DELAYED_WORK(&btwork, bt_reset_workqueue);
#endif
    /* default to bluetooth off */
    //rfkill_switch_all(RFKILL_TYPE_BLUETOOTH, 1);
    if (NULL != bt_dev.bt_dev_off) {
        bt_dev.bt_dev_off();
    }

    bt_rfk = rfkill_alloc("bt-dev", &pdev->dev, RFKILL_TYPE_BLUETOOTH,
                          &bt_rfkill_ops, NULL);

    if (!bt_rfk) {
        printk("rfk alloc fail\n");
        rc = -ENOMEM;
        goto err_rfk_alloc;
    }
    /* if not set false, the bt_set_block will call when rfkill class resume */
    rfkill_init_sw_state(bt_rfk, false);      //we want to reset bt when system resume
    rc = rfkill_register(bt_rfk);
    if (rc) {
        printk("rfkill_register fail\n");
        goto err_rfkill;
    }
    platform_set_drvdata(pdev, bt_rfk);
#ifdef CONFIG_HAS_EARLYSUSPEND
    bt_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
    bt_early_suspend.suspend = bt_earlysuspend;
    bt_early_suspend.resume = bt_lateresume;
    bt_early_suspend.param = pdev;
    register_early_suspend(&bt_early_suspend);
#endif

    return 0;

err_rfkill:
    rfkill_destroy(bt_rfk);
err_rfk_alloc:
    return rc;

}
Example #16
0
static struct rfkill *oaktrail_rfkill_new(char *name, enum rfkill_type type,
					  unsigned long mask)
{
	struct rfkill *rfkill_dev;
	u8 value;
	int err;

	rfkill_dev = rfkill_alloc(name, &oaktrail_device->dev, type,
				  &oaktrail_rfkill_ops, (void *)mask);
	if (!rfkill_dev)
		return ERR_PTR(-ENOMEM);

	ec_read(OT_EC_DEVICE_STATE_ADDRESS, &value);
	rfkill_init_sw_state(rfkill_dev, (value & mask) != 1);

	err = rfkill_register(rfkill_dev);
	if (err) {
		rfkill_destroy(rfkill_dev);
		return ERR_PTR(err);
	}

	return rfkill_dev;
}
static struct rfkill *sd8x_rfkill_register(struct device *parent,
					   enum rfkill_type type, char *name,
					   struct sd8x_rfkill_platform_data
					   *pdata)
{
	int err;
	struct rfkill *dev = NULL;
	struct rfkill_ops *ops = NULL;

	ops = kzalloc(sizeof(struct rfkill_ops), GFP_KERNEL);
	if (!ops)
		goto err_out;
	ops->set_block = sd8x_set_block;

	local_sd8x_data->type = type;
	local_sd8x_data->blocked = true;
	local_sd8x_data->pdata = pdata;

	dev = rfkill_alloc(name, parent, type, ops, local_sd8x_data);
	if (!dev)
		goto err_out;

	/* init device software states, and block it by default */
	rfkill_init_sw_state(dev, true);

	err = rfkill_register(dev);
	if (err)
		goto err_out;

	return dev;

err_out:
	kfree(ops);
	if (dev)
		rfkill_destroy(dev);
	return 0;
}
Example #18
0
/*
 * Register a new WiMAX device's RF Kill support
 *
 * WARNING: wimax_dev->mutex must be unlocked
 */
int wimax_rfkill_add(struct wimax_dev *wimax_dev)
{
	int result;
	struct rfkill *rfkill;
	struct device *dev = wimax_dev_to_dev(wimax_dev);

	d_fnstart(3, dev, "(wimax_dev %p)\n", wimax_dev);
	/* Initialize RF Kill */
	result = -ENOMEM;
	rfkill = rfkill_alloc(wimax_dev->name, dev, RFKILL_TYPE_WIMAX,
			      &wimax_rfkill_ops, wimax_dev);
	if (rfkill == NULL)
		goto error_rfkill_allocate;

	d_printf(1, dev, "rfkill %p\n", rfkill);

	wimax_dev->rfkill = rfkill;

	rfkill_init_sw_state(rfkill, 1);
	result = rfkill_register(wimax_dev->rfkill);
	if (result < 0)
		goto error_rfkill_register;

	/* If there is no SW toggle op, SW RFKill is always on */
	if (wimax_dev->op_rfkill_sw_toggle == NULL)
		wimax_dev->rf_sw = WIMAX_RF_ON;

	d_fnend(3, dev, "(wimax_dev %p) = 0\n", wimax_dev);
	return 0;

error_rfkill_register:
	rfkill_destroy(wimax_dev->rfkill);
error_rfkill_allocate:
	d_fnend(3, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
	return result;
}
Example #19
0
static int  bt_ctr_probe(struct platform_device *pdev)
{
	int irq;
	int ret;

	struct bt_gpio_info *bt_info;
	
	/* Initialize wake locks */
	wake_lock_init(&rfkill_wake_lock, WAKE_LOCK_SUSPEND, "bt_host_wake");

	/* request gpio */
	ret = gpio_request(BT_POWER, "GPB");
	if (ret < 0) {
		pr_err("[BT] Failed to request BT_POWER!\n");
		goto err_req_bt_power;
	}

	ret = gpio_request(BT_RESET, "GPB");
	if (ret < 0) {
		pr_err("[BT] Failed to request BT_RESET!\n");
		goto err_req_bt_reset;
	}

	/* BT Host Wake IRQ */
	irq = gpio_to_irq(BT_HOST_WAKE);
	
	ret = request_irq(irq, bt_host_wake_irq_handler,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"bt_host_wake_irq_handler", NULL);

	if (ret < 0) {
		pr_err("[BT] Request_irq failed\n");
		goto err_req_irq;
	}

	disable_irq(irq);

	/* init rfkill */
	bt_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&bt_rfkill_ops, NULL);

	if (!bt_rfk) {
		pr_err("[BT] bt_rfk : rfkill_alloc is failed\n");
		ret = -ENOMEM;
		goto err_alloc;
	}

	rfkill_init_sw_state(bt_rfk, 0);	

	ret = rfkill_register(bt_rfk);
	if (ret) {
		pr_debug("********ERROR IN REGISTERING THE RFKILL********\n");
		goto err_register;
	}

	rfkill_set_sw_state(bt_rfk, 1);
	
	/* init low power state*/
	ret = bt_lpm_init();
	if (ret < 0) {
		pr_debug("[BT]  set low power failed\n");
		goto err_register;
	}

	/* create sysfs attributes */
	bt_info = kzalloc(sizeof(struct bt_gpio_info), GFP_KERNEL);
	if(!bt_info) {
		pr_debug("[BT]  sysfs_create_group failed\n");
		goto err_register;
	}

	bt_info->bt_test_mode =0;     //bt   in normal mode
	bt_info->bt_enable = 0;
	bt_info->bt_wake = 0;
	mutex_init(&bt_info->bt_lock);	
	
	bt_info->dev = &pdev->dev;
	platform_set_drvdata(pdev, bt_info);

	ret = sysfs_create_group(&pdev->dev.kobj, &bcm_attribute_group);
	if (ret < 0) {
		pr_debug("[BT]  sysfs_create_group failed\n");
		goto err_register;
	}

	device_init_wakeup(&pdev->dev, 1);

	/* set init power state*/
	bt_set_power(NULL, RFKILL_USER_STATE_SOFT_BLOCKED);

	return ret;

 err_register:
	rfkill_destroy(bt_rfk);

 err_alloc:
	free_irq(irq, NULL);

 err_req_irq:
	gpio_free(BT_RESET);

 err_req_bt_reset:
	gpio_free(BT_POWER);

 err_req_bt_power:
	return ret;
}
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;
}
Example #21
0
static int bcm4751_rfkill_probe(struct platform_device *pdev)
{
	int ret = 0;
	struct bcm4751 *ddata;
	struct bcm4751_rfkill_platform_data *pdata = pdev->dev.platform_data;

	ddata = kzalloc(sizeof(*ddata), GFP_KERNEL);
	if (ddata == NULL) {
		return -ENOMEM;
	}

	ddata->lna_ldo = regulator_get(NULL, "vdd_ldo5");
	if (IS_ERR(ddata->lna_ldo)) {
		printk(KERN_ERR "%s: can't get GPS_LNA power rail\n", __func__);
		ret = PTR_ERR(ddata->lna_ldo);
		goto err_regulator_get;
	}

	ddata->pdev = pdev;
	ddata->gpio_nrst = pdata->gpio_nrst;
	ddata->gpio_pwr_en = pdata->gpio_pwr_en;

	ddata->rfkill0 = rfkill_alloc("bcm4751", &pdev->dev, RFKILL_TYPE_GPS, &bcm4751_rfkill0_ops, (void *)ddata);
	if (unlikely(!ddata->rfkill0)) {
		ret = -ENOMEM;
		goto err_rfkill0_alloc;
	}

	ddata->rfkill1 = rfkill_alloc("bcm4751", &pdev->dev, RFKILL_TYPE_GPS, &bcm4751_rfkill1_ops, (void *)ddata);
	if (unlikely(!ddata->rfkill1)) {
		ret = -ENOMEM;
		goto err_rfkill1_alloc;
	}

	rfkill_init_sw_state(ddata->rfkill0, (bool)true);
	rfkill_init_sw_state(ddata->rfkill1, (bool)false);

	ret = rfkill_register(ddata->rfkill0);
	if (unlikely(ret)) {
		ret = -ENODEV;
		goto err_rfkill0_register;
	}

	ret = rfkill_register(ddata->rfkill1);
	if (unlikely(ret)) {
		ret = -ENODEV;
		goto err_rfkill1_register;
	}

	mutex_init(&ddata->lock);
	platform_set_drvdata(pdev, ddata);

	return 0;

err_rfkill1_register:
	rfkill_unregister(ddata->rfkill0);
err_rfkill0_register:
	rfkill_destroy(ddata->rfkill1);
err_rfkill1_alloc:
	rfkill_destroy(ddata->rfkill0);
err_rfkill0_alloc:
	regulator_put(ddata->lna_ldo);
err_regulator_get:
	kfree(ddata);
	ddata = NULL;

	return ret;
}
static int __init smba_gsm_probe(struct platform_device *pdev)
{
	struct rfkill *rfkill;
	struct regulator *regulator[2];
	struct smba_pm_gsm_data *gsm_data;
	int ret;

	gsm_data = kzalloc(sizeof(*gsm_data), GFP_KERNEL);
	if (!gsm_data) {
		dev_err(&pdev->dev, "no memory for context\n");
		return -ENOMEM;
	}
	dev_set_drvdata(&pdev->dev, gsm_data);

	regulator[0] = regulator_get(&pdev->dev, "avdd_usb_pll");
	if (IS_ERR(regulator[0])) {
		dev_err(&pdev->dev, "unable to get regulator for usb pll\n");
		kfree(gsm_data);
		dev_set_drvdata(&pdev->dev, NULL);
		return -ENODEV;
	}
	gsm_data->regulator[0] = regulator[0];

	regulator[1] = regulator_get(&pdev->dev, "avdd_usb");
	if (IS_ERR(regulator[1])) {
		dev_err(&pdev->dev, "unable to get regulator for usb\n");
		regulator_put(regulator[0]);
		gsm_data->regulator[0] = NULL;
		kfree(gsm_data);
		dev_set_drvdata(&pdev->dev, NULL);
		return -ENODEV;
	}
	gsm_data->regulator[1] = regulator[1];
	
	/* Init control pins */
	gpio_request(SMBA9701_3G_DISABLE, "gsm_disable");
	gpio_direction_output(SMBA9701_3G_DISABLE, 1);
//	smba_3g_gps_init();

	/* register rfkill interface */
	rfkill = rfkill_alloc(pdev->name, &pdev->dev, RFKILL_TYPE_WWAN,
                            &smba_gsm_rfkill_ops, &pdev->dev);

	if (!rfkill) {
		dev_err(&pdev->dev, "Failed to allocate rfkill\n");
		regulator_put(regulator[1]);
		gsm_data->regulator[1] = NULL;
		regulator_put(regulator[0]);
		gsm_data->regulator[0] = NULL;
		kfree(gsm_data);
		dev_set_drvdata(&pdev->dev, NULL);
		return -ENOMEM;
	}
	gsm_data->rfkill = rfkill;

	/* Disable bluetooth */
    rfkill_init_sw_state(rfkill, 0);

	ret = rfkill_register(rfkill);
	if (ret) {
		rfkill_destroy(rfkill);
		dev_err(&pdev->dev, "Failed to register rfkill\n");
		return ret;
	}

	dev_info(&pdev->dev, "GSM/UMTS RFKill driver loaded\n");
	
	return sysfs_create_group(&pdev->dev.kobj, &smba_gsm_attr_group);
}
Example #23
0
static int __init aries_rfkill_probe(struct platform_device *pdev)
{

	int irq,ret;

	/* Initialize wake locks */
	wake_lock_init(&rfkill_wake_lock, WAKE_LOCK_SUSPEND, "bt_host_wake");

	ret = gpio_request(GPIO_WLAN_BT_EN, "GPB");
	if (ret < 0) {
		pr_err("[BT] Failed to request GPIO_WLAN_BT_EN!\n");
		goto err_req_gpio_wlan_bt_en;
	}

	ret = gpio_request(GPIO_BT_nRST, "GPB");
	if (ret < 0) {
		pr_err("[BT] Failed to request GPIO_BT_nRST!\n");
		goto err_req_gpio_bt_nrst;
	}
	//BT Host Wake IRQ
	irq = IRQ_BT_HOST_WAKE;

	ret = request_irq(irq, bt_host_wake_irq_handler,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"bt_host_wake_irq_handler", NULL);

	if (ret < 0) {
		pr_err("[BT] Request_irq failed\n");
		goto err_req_irq;
	}

	disable_irq(irq);

	bt_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&bt_rfkill_ops, NULL);

	if (!bt_rfk) {
		pr_err("[BT] bt_rfk : rfkill_alloc is failed\n");
		ret = -ENOMEM;
		goto err_alloc;
	}

	rfkill_init_sw_state(bt_rfk, 0);

	pr_debug("[BT] rfkill_register(bt_rfk)\n");

	ret = rfkill_register(bt_rfk);
	if (ret) {
		pr_debug("********ERROR IN REGISTERING THE RFKILL********\n");
		goto err_register;
	}

	rfkill_set_sw_state(bt_rfk, 1);
	bluetooth_set_power(NULL, RFKILL_USER_STATE_SOFT_BLOCKED);

#ifdef BT_SLEEP_ENABLER
	wake_lock_init(&bt_wake_lock, WAKE_LOCK_SUSPEND, "bt_wake");

	ret = gpio_request(GPIO_BT_WAKE, "gpio_bt_wake");
	if (ret < 0) {
		pr_err("[BT] Failed to request GPIO_BT_WAKE\n");
		goto err_req_gpio_bt_wake;
	}

	gpio_direction_output(GPIO_BT_WAKE, GPIO_LEVEL_LOW);

	bt_sleep_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&btsleep_rfkill_ops, NULL);

	if (!bt_sleep_rfk) {
		pr_err("[BT] bt_sleep_rfk : rfkill_alloc is failed\n");
		ret = -ENOMEM;
		goto err_sleep_alloc;
	}

	rfkill_set_sw_state(bt_sleep_rfk, 1);

	pr_debug("[BT] rfkill_register(bt_sleep_rfk)\n");

	ret = rfkill_register(bt_sleep_rfk);
	if (ret) {
		pr_err("********ERROR IN REGISTERING THE bt_sleep_rfk********\n");
		goto err_sleep_register;
	}
#endif

#ifdef USE_LOCK_DVFS
	bt_lock_dvfs_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&bt_lock_dvfs_rfkill_ops, NULL);

	if (!bt_lock_dvfs_rfk) {
		pr_err("[BT] bt_lock_dvfs_rfk : rfkill_alloc is failed\n");
		ret = -ENOMEM;
		goto err_dvfs_lock_alloc;
	}

	pr_debug("[BT] rfkill_register(bt_lock_dvfs_rfk)\n");

	ret = rfkill_register(bt_lock_dvfs_rfk);
	if (ret) {
		pr_err("********ERROR IN REGISTERING THE bt_lock_dvfs_rfk********\n");
		goto err_lock_dvfs_register;
	}

	bt_lock_dvfs_l2_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&bt_lock_dvfs_l2_rfkill_ops, NULL);

	if (!bt_lock_dvfs_l2_rfk) {
		pr_err("[BT] bt_lock_dvfs_l2_rfk : rfkill_alloc is failed\n");
		ret = -ENOMEM;
		goto err_dvfs_l2_lock_alloc;
	}

	pr_debug("[BT] rfkill_register(bt_lock_dvfs_l2_rfk)\n");

	ret = rfkill_register(bt_lock_dvfs_l2_rfk);
	if (ret) {
		pr_err("********ERROR IN REGISTERING THE bt_lock_dvfs_l2_rfk********\n");
		goto err_lock_dvfs_l2_register;
	}	
#endif
	return ret;

#ifdef USE_LOCK_DVFS
err_lock_dvfs_l2_register:
	rfkill_destroy(bt_lock_dvfs_l2_rfk);

err_dvfs_l2_lock_alloc:
	rfkill_unregister(bt_lock_dvfs_rfk);
	
err_lock_dvfs_register:
	rfkill_destroy(bt_lock_dvfs_rfk);

err_dvfs_lock_alloc:
	rfkill_unregister(bt_sleep_rfk);
#endif

#ifdef BT_SLEEP_ENABLER
err_sleep_register:
	rfkill_destroy(bt_sleep_rfk);

err_sleep_alloc:
	gpio_free(GPIO_BT_WAKE);
	
err_req_gpio_bt_wake:
	rfkill_unregister(bt_rfk);
#endif
 err_register:
	rfkill_destroy(bt_rfk);

 err_alloc:
	free_irq(irq, NULL);

 err_req_irq:
	gpio_free(GPIO_BT_nRST);

 err_req_gpio_bt_nrst:
	gpio_free(GPIO_WLAN_BT_EN);

 err_req_gpio_wlan_bt_en:
	return ret;
}
Example #24
0
static int bt_probe(struct platform_device *pdev)
{
	int ret = 0;
	struct rfkill *bt_rfk;
	struct bt_dev_data *pdata = NULL;
	struct bt_dev_runtime_data *prdata;

#ifdef CONFIG_OF
	//plat = aml_get_driver_data(pdev);
	if (pdev->dev.of_node) {
	    const char *str;
	    
	    printk(KERN_DEBUG "enter bt_probe of_node\n");
	    pdata = kzalloc(sizeof(struct bt_dev_data), GFP_KERNEL);
		ret = of_property_read_string(pdev->dev.of_node,"gpio_reset",&str);
		if(ret){
			printk(KERN_WARNING "not get gpio_reset\n");
			pdata->gpio_reset = 0;
		} else {
		    pdata->gpio_reset = amlogic_gpio_name_map_num(str);
		}
		
        ret = of_property_read_string(pdev->dev.of_node,"gpio_en",&str);
		if(ret){
			printk(KERN_WARNING "not get gpio_en\n");
			pdata->gpio_en = 0;
		} else {
		    pdata->gpio_en = amlogic_gpio_name_map_num(str);
		}
		
		ret = of_property_read_string(pdev->dev.of_node,"gpio_wake",&str);
		if(ret){
			printk(KERN_WARNING "not get gpio_wake\n");
			pdata->gpio_wake = 0;
		} else {
		    pdata->gpio_wake = amlogic_gpio_name_map_num(str);
		}
	}
#else
    pdata = (struct bt_dev_data *)(pdev->dev.platform_data);
#endif
    
    bt_device_init(pdata);
    /* default to bluetooth off */
    //rfkill_switch_all(RFKILL_TYPE_BLUETOOTH, 1);
    bt_device_off(pdata);
    
	bt_rfk = rfkill_alloc("bt-dev", &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&bt_rfkill_ops, pdata);
						   
	if (!bt_rfk) {
        printk("rfk alloc fail\n");
		ret = -ENOMEM;
		goto err_rfk_alloc;
	}
	/* if not set false, the bt_set_block will call when rfkill class resume */
    rfkill_init_sw_state(bt_rfk, false);      //we want to reset bt when system resume
	ret = rfkill_register(bt_rfk);
	if (ret){
        printk(KERN_ERR "rfkill_register fail\n");
		goto err_rfkill;
    }
    prdata = kmalloc(sizeof(struct bt_dev_runtime_data), GFP_KERNEL);
    if (!prdata) {
        printk(KERN_ERR  "bt_dev_runtime_data alloc fail\n");
		goto err_rfkill;
    }
#ifdef CONFIG_AM_WIFI_SD_MMC
    //setup 32k clock
    wifi_request_32k_clk(1, BT_RFKILL);
    msleep(100);
#endif
    
    prdata->bt_rfk = bt_rfk;
    prdata->pdata = pdata;
	platform_set_drvdata(pdev, prdata);
#ifdef CONFIG_HAS_EARLYSUSPEND                                                                                        
        bt_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
        bt_early_suspend.suspend = bt_earlysuspend;
        bt_early_suspend.resume = bt_lateresume;
        bt_early_suspend.param = pdev;
        register_early_suspend(&bt_early_suspend);
#endif

	bt_device_on(pdata);

	return 0;	
	
err_rfkill:
	rfkill_destroy(bt_rfk);
err_rfk_alloc:
    bt_device_deinit(pdata);
	return ret;
	
}
Example #25
0
static int __devinit bt_probe(struct platform_device *pdev)
{
	int ret = 0;
	struct bt_rfkill_info *bt_info;
	struct mx_rfkill_pd *pdata = pdev->dev.platform_data;

	if (pdata == NULL) {
		dev_err(&pdev->dev,"Failed to get platform data\n");
		return -ENOENT;
	}
	bt_info = kzalloc(sizeof(struct bt_rfkill_info), GFP_KERNEL);
	if(!bt_info) {
		ret = -ENOMEM;
		pr_debug("[BT]  sysfs_create_group failed\n");
		goto err_req_bt_mem;
	}

	bt_info->name = pdata->name;
	bt_info->gpio_bt_power = pdata->bt_power;
	bt_info->gpio_bt_reset = pdata->bt_reset;
	bt_info->gpio_bt_wake = pdata->bt_wake;
	bt_info->gpio_bt_host_wake = pdata->bt_host_wake;
	bt_info->gpio_wifi_power = pdata->wifi_power;
	bt_info->gpio_wifi_reset = pdata->wifi_reset;
	bt_info->dev = &pdev->dev;
	
	/* Initialize wake locks */
	wake_lock_init(&bt_info->rfk_lock, WAKE_LOCK_SUSPEND, "bt_host_wake");

	/* BT Host Wake IRQ */
	bt_info->wake_irq = gpio_to_irq(bt_info->gpio_bt_host_wake);
	ret = request_threaded_irq(bt_info->wake_irq, NULL, bt_host_wake_irq_handler,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"bt_host_wake_irq_handler", bt_info);

	if (ret < 0) {
		pr_err("[BT] Request_irq failed\n");
		goto err_req_irq;
	}

	disable_irq(bt_info->wake_irq);

	/* init rfkill */
	bt_info->bt_rfk = rfkill_alloc(bt_info->name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&bt_rfkill_ops, bt_info);

	if (!bt_info->bt_rfk) {
		pr_err("[BT] bt_rfk : rfkill_alloc is failed\n");
		ret = -ENOMEM;
		goto err_rfkill_alloc;
	}

	rfkill_init_sw_state(bt_info->bt_rfk, 0);	

	ret = rfkill_register(bt_info->bt_rfk);
	if (ret) {
		pr_debug("********ERROR IN REGISTERING THE RFKILL********\n");
		goto err_register;
	}

	rfkill_set_sw_state(bt_info->bt_rfk, 1);
	
	/* init low power state*/
	ret = bt_lpm_init(bt_info);
	if (ret < 0) {
		pr_debug("[BT]  set low power failed\n");
		goto err_register;
	}

	bt_info->bt_test_mode =0;     //bt   in normal mode
	bt_info->bt_enable = 0;
	bt_info->bt_wake = 0;
	mutex_init(&bt_info->bt_lock);

	/* create sysfs attributes */
	ret = sysfs_create_group(&pdev->dev.kobj, &bcm_attribute_group);
	if (ret < 0) {
		pr_debug("[BT]  sysfs_create_group failed\n");
		goto err_register;
	}

	device_init_wakeup(&pdev->dev, 1);

	/* set init power state*/
	bt_set_power(bt_info, RFKILL_USER_STATE_SOFT_BLOCKED);

	platform_set_drvdata(pdev, bt_info);
	g_bt_info = bt_info;

	pr_info("[BT] driver loaded!\n");
	return ret;

err_register:
	rfkill_destroy(bt_info->bt_rfk);

err_rfkill_alloc:
	free_irq(bt_info->wake_irq, NULL);

err_req_irq:
	wake_lock_destroy(&bt_info->rfk_lock);
	kfree(bt_info);

err_req_bt_mem:
	return ret;
}
Example #26
0
static int spica_bt_probe(struct platform_device *pdev)
{
	struct spica_bt_pdata *pdata = pdev->dev.platform_data;
	struct spica_bt *bt;
	int ret = 0;

	if (!pdata) {
		dev_err(&pdev->dev, "no platform data specified\n");
		return -EINVAL;
	}

	if (!gpio_is_valid(pdata->gpio_host_wake)) {
		dev_err(&pdev->dev, "invalid BT host wake GPIO\n");
		return -EINVAL;
	}

	bt = kzalloc(sizeof(struct spica_bt), GFP_KERNEL);
	if (!bt) {
		dev_err(&pdev->dev, "failed to allocate driver data\n");
		return -ENOMEM;
	}

	bt->pdata = pdata;
	bt->dev = &pdev->dev;
	wake_lock_init(&bt->wake_lock, WAKE_LOCK_SUSPEND, "bt_host_wake");

	WARN_ON(gpio_request(pdata->gpio_host_wake, "BT host wake") < 0);

	ret = gpio_to_irq(pdata->gpio_host_wake);
	if (ret < 0) {
		dev_err(&pdev->dev, "failed to get host wake IRQ number\n");
		goto err_gpio_irq;
	}
	bt->irq = ret;
	bt->blocked = true;

	ret = request_irq(bt->irq, spica_bt_host_wake_irq,
				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
				"BT host wake", bt);
	if (ret < 0) {
		dev_err(&pdev->dev, "failed to request bt host wake IRQ\n");
		goto err_irq;
	}

	disable_irq(bt->irq);

	bt->rfk = rfkill_alloc("bcm4329", &pdev->dev,
			RFKILL_TYPE_BLUETOOTH, &spica_bt_ops, bt);
	if (IS_ERR(bt->rfk)) {
		dev_err(&pdev->dev, "rfkill_alloc failed\n");
		ret = PTR_ERR(bt->rfk);
		goto err_alloc;
	}

	rfkill_init_sw_state(bt->rfk, true);

	ret = rfkill_register(bt->rfk);
	if (ret) {
		dev_err(&pdev->dev, "rfkill_register failed (%d)\n", ret);
		goto err_register;
	}

	return 0;

err_register:
	rfkill_destroy(bt->rfk);
err_alloc:
	free_irq(bt->irq, bt);
err_irq:
	gpio_free(pdata->gpio_host_wake);
err_gpio_irq:
	kfree(bt);
	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 __init herring_rfkill_probe(struct platform_device *pdev)
{
	int irq;
	int ret;
    
	/* Initialize wake locks */
	wake_lock_init(&rfkill_wake_lock, WAKE_LOCK_SUSPEND, "bt_host_wake");
    
	ret = gpio_request(GPIO_WLAN_BT_EN, "GPB");
	if (ret < 0) {
		pr_err("[BT] Failed to request GPIO_WLAN_BT_EN!\n");
		goto err_req_gpio_wlan_bt_en;
	}
    
	ret = gpio_request(GPIO_BT_nRST, "GPB");
	if (ret < 0) {
		pr_err("[BT] Failed to request GPIO_BT_nRST!\n");
		goto err_req_gpio_bt_nrst;
	}
    
	/* BT Host Wake IRQ */
	irq = IRQ_BT_HOST_WAKE;
    
	ret = request_irq(irq, bt_host_wake_irq_handler,
                      IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
                      "bt_host_wake_irq_handler", NULL);
    
	if (ret < 0) {
		pr_err("[BT] Request_irq failed\n");
		goto err_req_irq;
	}
    
	disable_irq(irq);
    
	bt_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
                          &bt_rfkill_ops, NULL);
    
	if (!bt_rfk) {
		pr_err("[BT] bt_rfk : rfkill_alloc is failed\n");
		ret = -ENOMEM;
		goto err_alloc;
	}
    
	rfkill_init_sw_state(bt_rfk, 0);
    
	pr_debug("[BT] rfkill_register(bt_rfk)\n");
    
	ret = rfkill_register(bt_rfk);
	if (ret) {
		pr_debug("********ERROR IN REGISTERING THE RFKILL********\n");
		goto err_register;
	}
    
	rfkill_set_sw_state(bt_rfk, 1);
	bluetooth_set_power(NULL, RFKILL_USER_STATE_SOFT_BLOCKED);
    
	return ret;
    
err_register:
	rfkill_destroy(bt_rfk);
    
err_alloc:
	free_irq(irq, NULL);
    
err_req_irq:
	gpio_free(GPIO_BT_nRST);
    
err_req_gpio_bt_nrst:
	gpio_free(GPIO_WLAN_BT_EN);
    
err_req_gpio_wlan_bt_en:
	return ret;
}
Example #29
0
/* ----- Initialization/removal -------------------------------------------- */
static int __init gtablet_wlan_probe(struct platform_device *pdev)
{
	/* default-on for now */
	const int default_state = 1;
	
	struct rfkill *rfkill;
	struct regulator *regulator[2];
	struct gtablet_pm_wlan_data *wlan_data;
	int ret;

	wlan_data = kzalloc(sizeof(*wlan_data), GFP_KERNEL);
	if (!wlan_data) {
		dev_err(&pdev->dev, "no memory for context\n");
		return -ENOMEM;
	}
	dev_set_drvdata(&pdev->dev, wlan_data);

	regulator[0] = regulator_get(&pdev->dev, "vddio_wlan");
	if (IS_ERR(regulator[0])) {
		dev_err(&pdev->dev, "unable to get regulator 0\n");
		kfree(wlan_data);
		dev_set_drvdata(&pdev->dev, NULL);
		return -ENODEV;
	}

	wlan_data->regulator[0] = regulator[0];

	regulator[1] = regulator_get(&pdev->dev, "vcore_wifi");
	if (IS_ERR(regulator[1])) {
		dev_err(&pdev->dev, "unable to get regulator 1\n");
		regulator_put(regulator[0]);
		kfree(wlan_data);
		dev_set_drvdata(&pdev->dev, NULL);
		return -ENODEV;
	}
	wlan_data->regulator[1] = regulator[1];
	
	wlan_data->wifi_32k_clk = clk_get_sys(NULL, "blink");
	if (IS_ERR(wlan_data->wifi_32k_clk)) {
                pr_err("%s: unable to get blink clock\n", __func__);
                return PTR_ERR(wlan_data->wifi_32k_clk);
        }

	/* Init io pins */
	gpio_request(GTABLET_WLAN_POWER, "wlan_power");
	gpio_direction_output(GTABLET_WLAN_POWER, 0);

	gpio_request(GTABLET_WLAN_POWER, "wlan_reset");
	gpio_direction_output(GTABLET_WLAN_POWER, 0);
	
	rfkill = rfkill_alloc("bcm4329", &pdev->dev, RFKILL_TYPE_WLAN,
							&gtablet_wlan_rfkill_ops, &pdev->dev);


	if (!rfkill) {
		dev_err(&pdev->dev, "Failed to allocate rfkill\n");
		regulator_put(regulator[1]);
		regulator_put(regulator[0]);
		kfree(wlan_data);
		dev_set_drvdata(&pdev->dev, NULL);
		return -ENOMEM;
	}
	wlan_data->rfkill = rfkill;
	
	rfkill_init_sw_state(rfkill, default_state);

	ret = rfkill_register(rfkill);
	if (ret) {
		dev_err(&pdev->dev, "Failed to register rfkill\n");
		regulator_put(regulator[1]);
		regulator_put(regulator[0]);
		rfkill_destroy(rfkill);
		kfree(wlan_data);
		dev_set_drvdata(&pdev->dev, NULL);
		return ret;
	}

	dev_info(&pdev->dev, "WLAN RFKill driver loaded\n");
	
	return sysfs_create_group(&pdev->dev.kobj, &gtablet_wlan_attr_group);
}
static int __init bluetooth_rfkill_probe(struct platform_device *pdev)
{
	int ret;

	/* Initialize wake locks */
	wake_lock_init(&rfkill_wake_lock, WAKE_LOCK_SUSPEND, "bt_host_wake");

	bt_dev = pdev;

	ret = gpio_request(OMAP_GPIO_BT_EN, "gpio_bt_en");
	if (ret < 0) {
		pr_err("[BT] Failed to request GPIO_BT_EN!\n");
		goto err_req_gpio_bt_en;
	}

	ret = gpio_request(OMAP_GPIO_BT_nRST, "gpio_bt_nrst");
	if (ret < 0) {
		pr_err("[BT] Failed to request GPIO_BT_nRST!\n");
		goto err_req_gpio_bt_nrst;
	}

	/* BT Host Wake IRQ */

	irq = gpio_to_irq(OMAP_GPIO_BT_HOST_WAKE);

	ret = request_irq(irq, bt_host_wake_irq_handler,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"bt_host_wake_irq_handler", NULL);

	if (ret < 0) {
		pr_err("[BT] Request_irq failed\n");
		goto err_req_irq;
	}

	disable_irq(irq);

	bt_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&bt_rfkill_ops, NULL);

	if (!bt_rfk) {
		pr_err("[BT] bt_rfk : rfkill_alloc is failed\n");
		ret = -ENOMEM;
		goto err_alloc;
	}

	rfkill_init_sw_state(bt_rfk, 0);

	pr_info("[BT] rfkill_register(bt_rfk)\n");

	ret = rfkill_register(bt_rfk);
	if (ret) {
		pr_err("********ERROR IN REGISTERING THE bt_rfk********\n");
		goto err_register;
	}

	rfkill_set_sw_state(bt_rfk, 1);

#ifdef BT_SLEEP_ENABLE
	wake_lock_init(&bt_wake_lock, WAKE_LOCK_SUSPEND, "bt_wake");

	ret = gpio_request(OMAP_GPIO_BT_WAKE, "gpio_bt_wake");
	if (ret < 0) {
		pr_err("[BT] Failed to request GPIO_BT_WAKE\n");
		goto err_req_gpio_bt_wake;
	}

	gpio_direction_output(OMAP_GPIO_BT_WAKE, GPIO_LEVEL_LOW);

	bt_sleep_rfk = rfkill_alloc(bt_name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&btsleep_rfkill_ops, NULL);

	if (!bt_sleep_rfk) {
		pr_err("[BT] bt_sleep_rfk : rfkill_alloc is failed\n");
		ret = -ENOMEM;
		goto err_sleep_alloc;
	}

	rfkill_set_sw_state(bt_sleep_rfk, 1);

	pr_info("[BT] rfkill_register(bt_sleep_rfk)\n");

	ret = rfkill_register(bt_sleep_rfk);
	if (ret) {
		pr_err("********ERROR IN REGISTERING THE bt_sleep_rfk********\n");
		goto err_sleep_register;
	}
#endif

	return ret;

#ifdef BT_SLEEP_ENABLE
err_sleep_register:
	rfkill_destroy(bt_sleep_rfk);

err_sleep_alloc:
	gpio_free(OMAP_GPIO_BT_WAKE);
	
err_req_gpio_bt_wake:
	rfkill_unregister(bt_rfk);
#endif

 err_register:
	rfkill_destroy(bt_rfk);

 err_alloc:
	free_irq(irq, NULL);

 err_req_irq:
	gpio_free(OMAP_GPIO_BT_nRST);

 err_req_gpio_bt_nrst:
	gpio_free(OMAP_GPIO_BT_EN);

 err_req_gpio_bt_en:
	return ret;
}