Ejemplo n.º 1
0
static int rfkill_init(struct platform_device *sdev)
{
	/* add rfkill */
	int retval;

	/* keep the hardware wireless state */
	get_wireless_state_ec_standard();

	rfk_bluetooth = rfkill_alloc("msi-bluetooth", &sdev->dev,
				RFKILL_TYPE_BLUETOOTH,
				&rfkill_bluetooth_ops, NULL);
	if (!rfk_bluetooth) {
		retval = -ENOMEM;
		goto err_bluetooth;
	}
	retval = rfkill_register(rfk_bluetooth);
	if (retval)
		goto err_bluetooth;

	rfk_wlan = rfkill_alloc("msi-wlan", &sdev->dev, RFKILL_TYPE_WLAN,
				&rfkill_wlan_ops, NULL);
	if (!rfk_wlan) {
		retval = -ENOMEM;
		goto err_wlan;
	}
	retval = rfkill_register(rfk_wlan);
	if (retval)
		goto err_wlan;

	if (threeg_exists) {
		rfk_threeg = rfkill_alloc("msi-threeg", &sdev->dev,
				RFKILL_TYPE_WWAN, &rfkill_threeg_ops, NULL);
		if (!rfk_threeg) {
			retval = -ENOMEM;
			goto err_threeg;
		}
		retval = rfkill_register(rfk_threeg);
		if (retval)
			goto err_threeg;
	}

	/* schedule to run rfkill state initial */
	if (quirks->ec_delay) {
		schedule_delayed_work(&msi_rfkill_init,
			round_jiffies_relative(1 * HZ));
	} else
		schedule_work(&msi_rfkill_work);

	return 0;

err_threeg:
	rfkill_destroy(rfk_threeg);
	if (rfk_wlan)
		rfkill_unregister(rfk_wlan);
err_wlan:
	rfkill_destroy(rfk_wlan);
	if (rfk_bluetooth)
		rfkill_unregister(rfk_bluetooth);
err_bluetooth:
	rfkill_destroy(rfk_bluetooth);

	return retval;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
static int __init crespo_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_BT_EN, "GPB");
	if (ret < 0) {
		pr_err("[BT] Failed to request GPIO_BT_EN!\n");
		goto err_req_gpio_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,
			"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_err("********ERROR IN REGISTERING THE bt_rfk********\n");
		goto err_register;
	}

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

#ifdef BT_SLEEP_ENABLE
	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

	return ret;

#ifdef BT_SLEEP_ENABLE
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_BT_EN);

 err_req_gpio_bt_en:
	return ret;
}
Ejemplo n.º 4
0
static int pico_rfkill_remove(struct platform_device *dev)
{
    rfkill_unregister(bt_rfk);
    rfkill_destroy(bt_rfk);
    return 0;
}
/* ----- Initialization/removal -------------------------------------------- */
static int __init shuttle_wlan_probe(struct platform_device *pdev)
{
	/* default-on */
	const int default_blocked_state = 0;
	
	struct rfkill *rfkill;
	struct regulator *regulator[2];
	struct shuttle_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"); /* 1.8v */
	if (IS_ERR(regulator[0])) {
		dev_err(&pdev->dev, "unable to get regulator 0 (1.8v)\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"); /* 1.2v */
	if (IS_ERR(regulator[1])) {
		dev_err(&pdev->dev, "unable to get regulator 1 (1.2v)\n");
		regulator_put(regulator[0]);
		kfree(wlan_data);
		dev_set_drvdata(&pdev->dev, NULL);
		return -ENODEV;
	}
	wlan_data->regulator[1] = regulator[1];
	
	/* Init io pins */
	gpio_request(SHUTTLE_WLAN_POWER, "wlan_power");
	gpio_direction_output(SHUTTLE_WLAN_POWER, 0);

	gpio_request(SHUTTLE_WLAN_RESET, "wlan_reset");
	gpio_direction_output(SHUTTLE_WLAN_RESET, 0);
	
	rfkill = rfkill_alloc(pdev->name, &pdev->dev, RFKILL_TYPE_WLAN,
							&shuttle_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;

	/* Tell the SDIO stack the card is not there... otherwise, it could 
	   be using a non powered card not properly initialized */
	shuttle_wlan_set_carddetect(&pdev->dev,0);
		
	/* Set the default state */
	rfkill_init_sw_state(rfkill, default_blocked_state);
	shuttle_wlan_set_carddetect(&pdev->dev, !default_blocked_state);

	ret = rfkill_register(rfkill);
	if (ret) {
		dev_err(&pdev->dev, "Failed to register rfkill\n");
		rfkill_destroy(rfkill);		
		regulator_put(regulator[1]);
		regulator_put(regulator[0]);
		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, &shuttle_wlan_attr_group);
}
static int __init smba1002_bt_probe(struct platform_device *pdev)
{
	struct rfkill *rfkill;
	struct regulator *regulator;
	struct clk *clk;
	struct smba1002_pm_bt_data *bt_data;
	int ret;

	dev_dbg(&pdev->dev, "starting\n");

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

	regulator = regulator_get(&pdev->dev, "vddhostif_bt");
	if (IS_ERR(regulator)) {
		dev_err(&pdev->dev, "Failed to get regulator\n");
		ret = -ENODEV;
		goto err4;
	}
	bt_data->regulator = regulator;
	
	clk = clk_get(&pdev->dev, "blink");
	if (IS_ERR(clk)) {
		dev_err(&pdev->dev, "Failed to get clock\n");
		ret = -ENODEV;
		goto err3;
	}
	bt_data->clk = clk;

	/* Init io pins */
	gpio_request(SMBA1002_BT_RESET, "bluetooth_reset");
	gpio_direction_output(SMBA1002_BT_RESET, 0);
	
	rfkill = rfkill_alloc(pdev->name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
                            &smba1002_bt_rfkill_ops, &pdev->dev);

	if (!rfkill) {
		dev_err(&pdev->dev, "Failed to allocate rfkill\n");
		ret = -ENOMEM;
		goto err2;
	}
	bt_data->rfkill = rfkill;

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

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

	dev_info(&pdev->dev, "Bluetooth RFKill driver registered\n");	
	
	return sysfs_create_group(&pdev->dev.kobj, &smba1002_bt_attr_group);
	
err1:
	rfkill_destroy(rfkill);
	bt_data->rfkill = NULL;
err2:
	clk_put(clk);
	bt_data->clk = NULL;
err3:
	regulator_put(regulator);
	bt_data->regulator = NULL;
err4:
	kfree(bt_data);
	dev_set_drvdata(&pdev->dev, NULL);
	return ret;
}
Ejemplo n.º 7
0
static int wl127x_rfkill_probe(struct platform_device *pdev)
{
	int rc = 0;
	struct wl127x_rfkill_platform_data *pdata = pdev->dev.platform_data;

	if (pdata->bt_nshutdown_gpio >= 0) {
		bool default_blocked = true;  /* power off */
		rc = gpio_request(pdata->bt_nshutdown_gpio,
				  "wl127x_bt_nshutdown_gpio");
		if (unlikely(rc))
			return rc;

		rc = gpio_direction_output(pdata->bt_nshutdown_gpio, 0);
		if (unlikely(rc))
			return rc;

		if (pdata->bt_hw_init)
			rc = pdata->bt_hw_init();
		if (unlikely(rc))
			return rc;

		wl127x_bt_rfkill_set_power((void *)pdata, default_blocked);

		pdata->rfkill[WL127X_BLUETOOTH] = rfkill_alloc(
				"wl127x Bluetooth", &pdev->dev,
				RFKILL_TYPE_BLUETOOTH, &wl127x_bt_rfkill_ops,
				(void *)pdata);
		if (unlikely(!pdata->rfkill[WL127X_BLUETOOTH]))
			return -ENOMEM;

		rfkill_set_states(pdata->rfkill[WL127X_BLUETOOTH],
				default_blocked, false);

		rc = rfkill_register(pdata->rfkill[WL127X_BLUETOOTH]);
		if (unlikely(rc)) {
			rfkill_destroy(pdata->rfkill[WL127X_BLUETOOTH]);
			return rc;
		}
	}

	if (pdata->pwr_ctl >= 0) {
		bool default_blocked = true;  /* power off */

		pdata->rfkill[WL127X_PWR_CTL] = rfkill_alloc(
				"wl127x Power_Control", &pdev->dev,
				RFKILL_TYPE_PWR_CTL, &wl127x_pwr_ctl_rfkill_ops,
				(void *)pdata);
		if (unlikely(!pdata->rfkill[WL127X_PWR_CTL]))
			return -ENOMEM;

		rfkill_set_states(pdata->rfkill[WL127X_PWR_CTL],
			default_blocked, false);

		rc = rfkill_register(pdata->rfkill[WL127X_PWR_CTL]);
		if (unlikely(rc)) {
			rfkill_destroy(pdata->rfkill[WL127X_PWR_CTL]);
			return rc;
		}
	}

	if (pdata->fm_enable_gpio >= 0) {
		bool default_blocked = true;  /* power off */
		rc = gpio_request(pdata->fm_enable_gpio,
				  "wl127x_fm_enable_gpio");
		if (unlikely(rc))
			return rc;

		rc = gpio_direction_output(pdata->fm_enable_gpio, 0);
		if (unlikely(rc))
			return rc;

		wl127x_fm_rfkill_set_power((void *)pdata->fm_enable_gpio,
				default_blocked);

		pdata->rfkill[WL127X_FM] = rfkill_alloc("wl127x FM Radio",
				&pdev->dev, RFKILL_TYPE_FM,
				&wl127x_fm_rfkill_ops,
				(void *)pdata->fm_enable_gpio);
		if (unlikely(!pdata->rfkill[WL127X_FM]))
			return -ENOMEM;

		rfkill_set_states(pdata->rfkill[WL127X_FM], default_blocked,
				false);

		rc = rfkill_register(pdata->rfkill[WL127X_FM]);
		if (unlikely(rc)) {
			rfkill_destroy(pdata->rfkill[WL127X_FM]);
			return rc;
		}
	}

	return 0;
}
Ejemplo n.º 8
0
static int __init m8_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");

#if 0
	ret = gpio_request(GPIO_WLAN_BT_EN, "GPK");
	if (ret < 0) {
		printk(KERN_ERR"[BT] Failed to request GPIO_WLAN_BT_EN!\n");//pr_error
		goto err_req_gpio_wlan_bt_en;
	}

	ret = gpio_request(GPIO_BT_nRST, "GPM");
	if (ret < 0) {
		printk(KERN_ERR"[BT] Failed to request GPIO_BT_nRST!\n");//pr_error
		goto err_req_gpio_bt_nrst;
	}
#endif

	/* BT Host Wake IRQ */
	irq = IRQ_WLAN_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) {
		printk(KERN_ERR"[BT] bt_rfk : rfkill_alloc is failed\n");//pr_error
		ret = -ENOMEM;
		goto err_alloc;
	}

	rfkill_init_sw_state(bt_rfk, 0);

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

	ret = rfkill_register(bt_rfk);
	if (ret) {
		printk("********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);

	loaded = 1;

	return ret;

 err_register:
	rfkill_destroy(bt_rfk);

 err_alloc:
	free_irq(irq, NULL);

 err_req_irq:
#if 0
	gpio_free(GPIO_BT_nRST);

 err_req_gpio_bt_nrst:
	gpio_free(GPIO_WLAN_BT_EN);

 err_req_gpio_wlan_bt_en:
#endif
	return ret;
}
Ejemplo n.º 9
0
static int rfkill_gpio_probe(struct platform_device *pdev)
{
	struct rfkill_gpio_data *rfkill;
	struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data;
	int ret = 0;
	int len = 0;

	if (!pdata) {
		pr_warn("%s: No platform data specified\n", __func__);
		return -EINVAL;
	}

	/*                                                       
                                          */
	if (!pdata->name || (!gpio_is_valid(pdata->reset_gpio) &&
		!gpio_is_valid(pdata->shutdown_gpio))) {
		pr_warn("%s: invalid platform data\n", __func__);
		return -EINVAL;
	}

	rfkill = kzalloc(sizeof(*rfkill), GFP_KERNEL);
	if (!rfkill)
		return -ENOMEM;

	if (pdata->gpio_runtime_setup) {
		ret = pdata->gpio_runtime_setup(pdev);
		if (ret) {
			pr_warn("%s: can't set up gpio\n", __func__);
			goto fail_alloc;
		}
	}

	rfkill->pdata = pdata;

	len = strlen(pdata->name);
	rfkill->reset_name = kzalloc(len + 7, GFP_KERNEL);
	if (!rfkill->reset_name) {
		ret = -ENOMEM;
		goto fail_alloc;
	}

	rfkill->shutdown_name = kzalloc(len + 10, GFP_KERNEL);
	if (!rfkill->shutdown_name) {
		ret = -ENOMEM;
		goto fail_reset_name;
	}

	snprintf(rfkill->reset_name, len + 6 , "%s_reset", pdata->name);
	snprintf(rfkill->shutdown_name, len + 9, "%s_shutdown", pdata->name);

	if (pdata->power_clk_name) {
		rfkill->pwr_clk = clk_get(&pdev->dev, pdata->power_clk_name);
		if (IS_ERR(rfkill->pwr_clk)) {
			pr_warn("%s: can't find pwr_clk.\n", __func__);
			goto fail_shutdown_name;
		}
	}

	if (gpio_is_valid(pdata->reset_gpio)) {
		ret = gpio_request(pdata->reset_gpio, rfkill->reset_name);
		if (ret) {
			pr_warn("%s: failed to get reset gpio.\n", __func__);
			goto fail_clock;
		}
	}

	if (gpio_is_valid(pdata->shutdown_gpio)) {
		ret = gpio_request(pdata->shutdown_gpio, rfkill->shutdown_name);
		if (ret) {
			pr_warn("%s: failed to get shutdown gpio.\n", __func__);
			goto fail_reset;
		}
	}

	rfkill->rfkill_dev = rfkill_alloc(pdata->name, &pdev->dev, pdata->type,
				&rfkill_gpio_ops, rfkill);
	if (!rfkill->rfkill_dev)
		goto fail_shutdown;

	ret = rfkill_register(rfkill->rfkill_dev);
	if (ret < 0)
		goto fail_rfkill;

	platform_set_drvdata(pdev, rfkill);

	dev_info(&pdev->dev, "%s device registered.\n", pdata->name);

	return 0;

fail_rfkill:
	rfkill_destroy(rfkill->rfkill_dev);
fail_shutdown:
	if (gpio_is_valid(pdata->shutdown_gpio))
		gpio_free(pdata->shutdown_gpio);
fail_reset:
	if (gpio_is_valid(pdata->reset_gpio))
		gpio_free(pdata->reset_gpio);
fail_clock:
	if (rfkill->pwr_clk)
		clk_put(rfkill->pwr_clk);
fail_shutdown_name:
	kfree(rfkill->shutdown_name);
fail_reset_name:
	kfree(rfkill->reset_name);
fail_alloc:
	kfree(rfkill);

	return ret;
}
Ejemplo n.º 10
0
static int bcm4343_bluetooth_probe(struct platform_device *pdev)
{
	int rc = 0;
#ifdef BT_LPM_ENABLE
	int ret;
#endif
	pr_info("[BT] bcm4343_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("bcm4343 Bluetooth", &pdev->dev,
				RFKILL_TYPE_BLUETOOTH, &bcm4343_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] bcm4343_bluetooth_probe End \n");
	return rc;
}
Ejemplo n.º 11
0
static int rfkill_regulator_probe(struct platform_device *pdev)
{
	struct rfkill_regulator_platform_data *pdata = pdev->dev.platform_data;
	struct rfkill_regulator_data *rfkill_data;
	struct regulator *vcc;
	struct rfkill *rf_kill;
	int ret = 0;

	if (pdata == NULL) {
		dev_err(&pdev->dev, "no platform data\n");
		return -ENODEV;
	}

	if (pdata->name == NULL || pdata->type == 0) {
		dev_err(&pdev->dev, "invalid name or type in platform data\n");
		return -EINVAL;
	}

	vcc = regulator_get_exclusive(&pdev->dev, "vrfkill");
	if (IS_ERR(vcc)) {
		dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name);
		ret = PTR_ERR(vcc);
		goto out;
	}

	rfkill_data = kzalloc(sizeof(*rfkill_data), GFP_KERNEL);
	if (rfkill_data == NULL) {
		ret = -ENOMEM;
		goto err_data_alloc;
	}

	rf_kill = rfkill_alloc(pdata->name, &pdev->dev,
				pdata->type,
				&rfkill_regulator_ops, rfkill_data);
	if (rf_kill == NULL) {
		ret = -ENOMEM;
		goto err_rfkill_alloc;
	}

	if (regulator_is_enabled(vcc)) {
		dev_dbg(&pdev->dev, "Regulator already enabled\n");
		rfkill_data->reg_enabled = true;
	}
	rfkill_data->vcc = vcc;
	rfkill_data->rf_kill = rf_kill;

	ret = rfkill_register(rf_kill);
	if (ret) {
		dev_err(&pdev->dev, "Cannot register rfkill device\n");
		goto err_rfkill_register;
	}

	platform_set_drvdata(pdev, rfkill_data);
	dev_info(&pdev->dev, "%s initialized\n", pdata->name);

	return 0;

err_rfkill_register:
	rfkill_destroy(rf_kill);
err_rfkill_alloc:
	kfree(rfkill_data);
err_data_alloc:
	regulator_put(vcc);
out:
	return ret;
}
Ejemplo n.º 12
0
static int lbee9qmb_rfkill_btwake_probe(struct platform_device *pdev)
{
	struct lbee9qmb_platform_data *plat = pdev->dev.platform_data;
	struct rfkill *rfkill;

	int rc;
	int irq;
	int ret;
	int host_wake;

	if (!plat) {
		dev_err(&pdev->dev, "no platform data\n");
		return -ENOSYS;
	}
	
	wake_lock_init(&bt_lpm.bt_wake_lock, WAKE_LOCK_SUSPEND,
				"bt_wake");
#ifdef BRCM_HOST_WAKE
	wake_lock_init(&bt_lpm.host_wake_lock, WAKE_LOCK_SUSPEND,
				"host_wake");
	bt_lpm.gpio_host_wake=plat->gpio_hostwake;
	//spin_lock_init(&bt_lpm.bt_lock);
	INIT_WORK(&bt_lpm.host_wake_work, brcm_host_wake_work_func);
#endif

	rc = gpio_request(plat->gpio_btwake, "lbee9qmb_reset_btwake");
	if (rc < 0) {
		dev_err(&pdev->dev, "gpio_request failed\n");
		return rc;
	}

	rfkill = rfkill_alloc("lbee9qmb-rfkill_btwake", &pdev->dev,
			RFKILL_TYPE_BLUETOOTH, &lbee9qmb_rfkill_btwake_ops, pdev);
	if (!rfkill) {
		rc = -ENOMEM;
		goto fail_gpio;
	}
	platform_set_drvdata(pdev, rfkill);
	gpio_direction_output(plat->gpio_btwake, 1);
	
	rc = rfkill_register(rfkill);
	if (rc < 0)
		goto fail_alloc;

#ifdef BRCM_HOST_WAKE
	rc = gpio_request(plat->gpio_hostwake, "lbee9qmb_reset_hostwake");
	gpio_direction_input(plat->gpio_hostwake);
	host_wake=gpio_get_value(bt_lpm.gpio_host_wake);
	irq = gpio_to_irq(plat->gpio_hostwake);
	bt_lpm.host_wake_irq=irq;
#ifdef BRCM_WAKELOCKTIMEOUT
	hrtimer_init(&bt_lpm.check_hostwakeup_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	bt_lpm.check_hostwakeup_delay = ktime_set(5, 0);  /* 5 sec */
	bt_lpm.check_hostwakeup_timer.function = check_hostwakeup;

	set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
	
	ret = request_irq(irq, host_wake_isr, 0,
			"bt host_wake", NULL);
#else
	ret = request_irq(irq, host_wake_isr, IRQF_TRIGGER_HIGH,
			"bt host_wake", NULL);
#endif			
	
	printk(KERN_ERR "BRCM_LPM: irq=%d ret=%d HOST_WAKE=%d\n",irq,ret,host_wake);
#endif

	return 0;

fail_alloc:
	rfkill_destroy(rfkill);
fail_gpio:
	gpio_free(plat->gpio_btwake);

	return rc;
		
}
static int __init shuttle_gsm_probe(struct platform_device *pdev)
{
	/* default-on */
	const int default_blocked_state = 0;

	struct rfkill *rfkill;
	struct regulator *regulator[2];
	struct shuttle_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]);
		kfree(gsm_data);
		dev_set_drvdata(&pdev->dev, NULL);
		return -ENODEV;
	}
	gsm_data->regulator[1] = regulator[1];
	
	/* Init control pins */
	shuttle_3g_gps_init();

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

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

	/* Set the default state */
	rfkill_init_sw_state(rfkill, default_blocked_state);
	__shuttle_pm_gsm_toggle_radio(&pdev->dev, !default_blocked_state);

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

	dev_info(&pdev->dev, "GSM/UMTS RFKill driver loaded\n");
	
	return sysfs_create_group(&pdev->dev.kobj, &shuttle_gsm_attr_group);
}
Ejemplo n.º 14
0
static int bcm43xx_bluetooth_probe(struct platform_device *pdev)
{
	bool default_state = true;	/* off */
	int ret = 0;
#ifdef LPM_ON
	int_handler_enabled = false;
#endif

	printk("[Progress][bcm_bt_lpm] Probe starts\n");

#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

	printk("[Progress][bcm_bt_lpm] Probe ends\n");

	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 bcm4334_bluetooth_probe(struct platform_device *pdev)
{
	int rc = 0;
	int ret;

	rc = gpio_request(GPIO_BT_EN, "bcm4334_bten_gpio");
	if (unlikely(rc)) {
		pr_err("[BT] GPIO_BT_EN request failed.\n");
		return rc;
	}
	rc = gpio_request(gpio_rev(GPIO_BT_WAKE), "bcm4334_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, "bcm4334_bthostwake_gpio");
	if (unlikely(rc)) {
		pr_err("[BT] GPIO_BT_HOST_WAKE request failed.\n");
		gpio_free(gpio_rev(GPIO_BT_WAKE));
		gpio_free(GPIO_BT_EN);
		return rc;
	}
	gpio_direction_input(GPIO_BT_HOST_WAKE);
	gpio_direction_output(gpio_rev(GPIO_BT_WAKE), 0);
	gpio_direction_output(GPIO_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_BT_HOST_WAKE);
		gpio_free(gpio_rev(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_rev(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_rev(GPIO_BT_WAKE));
		gpio_free(GPIO_BT_EN);
	}
#endif
	return rc;
}
static int __init smba1002_gsm_probe(struct platform_device *pdev)
{
	struct rfkill *rfkill;
	struct regulator *regulator[2];
	struct smba1002_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(SMBA1002_3G_DISABLE, "gsm_disable");
	gpio_direction_output(SMBA1002_3G_DISABLE, 1);
//	smba1002_3g_gps_init();

	/* register rfkill interface */
	rfkill = rfkill_alloc(pdev->name, &pdev->dev, RFKILL_TYPE_WWAN,
                            &smba1002_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, &smba1002_gsm_attr_group);
}
static int __devinit bcm4329_rfkill_probe(struct platform_device *pdev)
{
	int rc = 0;
	bool default_state = true;
	
	DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);
	
	/* default to bluetooth off */
 	bcm4329_set_block(NULL, default_state); /* blocked -> bt off */
	 
	gBtCtrl.bt_rfk = rfkill_alloc(bt_name, 
                NULL, 
                RFKILL_TYPE_BLUETOOTH, 
                &bcm4329_rfk_ops, 
                NULL);

	if (!gBtCtrl.bt_rfk)
	{
		printk("fail to rfkill_allocate************\n");
		return -ENOMEM;
	}
	
	rfkill_set_states(gBtCtrl.bt_rfk, default_state, false);

	rc = rfkill_register(gBtCtrl.bt_rfk);
	if (rc)
	{
		printk("failed to rfkill_register,rc=0x%x\n",rc);
		rfkill_destroy(gBtCtrl.bt_rfk);
	}
	
	gpio_request(BT_GPIO_POWER, NULL);
	gpio_request(BT_GPIO_RESET, NULL);
	gpio_request(BT_GPIO_WAKE_UP, NULL);

#if BT_WAKE_HOST_SUPPORT
    init_timer(&(gBtCtrl.tl));
    gBtCtrl.tl.expires = jiffies + BT_WAKE_LOCK_TIMEOUT*HZ;        
    gBtCtrl.tl.function = timer_hostSleep;        
    add_timer(&(gBtCtrl.tl));
    gBtCtrl.b_HostWake = false;
    
	wake_lock_init(&(gBtCtrl.bt_wakelock), WAKE_LOCK_SUSPEND, "bt_wake");
	
	rc = gpio_request(BT_GPIO_WAKE_UP_HOST, "bt_wake");
	if (rc) {
		printk("%s:failed to request RAHO_BT_WAKE_UP_HOST\n",__FUNCTION__);
	}
	
	IOMUX_BT_GPIO_WAKE_UP_HOST();
	gpio_pull_updown(BT_GPIO_WAKE_UP_HOST,GPIOPullUp);
	rc = request_irq(gpio_to_irq(BT_GPIO_WAKE_UP_HOST),bcm4329_wake_host_irq,IRQF_TRIGGER_FALLING,NULL,NULL);
	if(rc)
	{
		printk("%s:failed to request RAHO_BT_WAKE_UP_HOST irq\n",__FUNCTION__);
		gpio_free(BT_GPIO_WAKE_UP_HOST);
	}
	enable_irq_wake(gpio_to_irq(BT_GPIO_WAKE_UP_HOST)); // so RAHO_BT_WAKE_UP_HOST can wake up system

	printk(KERN_INFO "bcm4329 module has been initialized,rc=0x%x\n",rc);
 #endif
 
	return rc;

	
}
Ejemplo n.º 18
0
static int toshiba_acpi_add(struct acpi_device *acpi_dev)
{
	struct toshiba_acpi_dev *dev;
	const char *hci_method;
	u32 dummy;
	bool bt_present;
	int ret = 0;

	if (toshiba_acpi)
		return -EBUSY;

	pr_info("Toshiba Laptop ACPI Extras version %s\n",
	       TOSHIBA_ACPI_VERSION);

	hci_method = find_hci_method(acpi_dev->handle);
	if (!hci_method) {
		pr_err("HCI interface not found\n");
		return -ENODEV;
	}

	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
	if (!dev)
		return -ENOMEM;
	dev->acpi_dev = acpi_dev;
	dev->method_hci = hci_method;
	acpi_dev->driver_data = dev;

	if (toshiba_acpi_setup_keyboard(dev))
		pr_info("Unable to activate hotkeys\n");

	mutex_init(&dev->mutex);

	ret = toshiba_acpi_setup_backlight(dev);
	if (ret)
		goto error;

	/* Register rfkill switch for Bluetooth */
	if (hci_get_bt_present(dev, &bt_present) == HCI_SUCCESS && bt_present) {
		dev->bt_rfk = rfkill_alloc("Toshiba Bluetooth",
					   &acpi_dev->dev,
					   RFKILL_TYPE_BLUETOOTH,
					   &toshiba_rfk_ops,
					   dev);
		if (!dev->bt_rfk) {
			pr_err("unable to allocate rfkill device\n");
			ret = -ENOMEM;
			goto error;
		}

		ret = rfkill_register(dev->bt_rfk);
		if (ret) {
			pr_err("unable to register rfkill device\n");
			rfkill_destroy(dev->bt_rfk);
			goto error;
		}
	}

	if (toshiba_illumination_available(dev)) {
		dev->led_dev.name = "toshiba::illumination";
		dev->led_dev.max_brightness = 1;
		dev->led_dev.brightness_set = toshiba_illumination_set;
		dev->led_dev.brightness_get = toshiba_illumination_get;
		if (!led_classdev_register(&acpi_dev->dev, &dev->led_dev))
			dev->illumination_supported = 1;
	}

	/* Determine whether or not BIOS supports fan and video interfaces */

	ret = get_video_status(dev, &dummy);
	dev->video_supported = !ret;

	ret = get_fan_status(dev, &dummy);
	dev->fan_supported = !ret;

	create_toshiba_proc_entries(dev);

	toshiba_acpi = dev;

	return 0;

error:
	toshiba_acpi_remove(acpi_dev);
	return ret;
}
Ejemplo n.º 19
0
static int bluedroid_pm_probe(struct platform_device *pdev)
{
	static struct bluedroid_pm_data *bluedroid_pm;
	struct rfkill *rfkill;
	struct resource *res;
	int ret;
	bool enable = false;  /* off */
	bool default_sw_block_state;

	bluedroid_pm = kzalloc(sizeof(*bluedroid_pm), GFP_KERNEL);
	if (!bluedroid_pm)
		return -ENOMEM;
/*sunzizhi delate regulator not used 
	bluedroid_pm->vdd_3v3 = regulator_get(&pdev->dev, "vdd_bt_3v3");
	if (IS_ERR_OR_NULL(bluedroid_pm->vdd_3v3)) {
		pr_warn("%s: regulator vdd_bt_3v3 not available\n", __func__);
		bluedroid_pm->vdd_3v3 = NULL;
	}
	bluedroid_pm->vdd_1v8 = regulator_get(&pdev->dev, "vddio_bt_1v8");
	if (IS_ERR_OR_NULL(bluedroid_pm->vdd_1v8)) {
		pr_warn("%s: regulator vddio_bt_1v8 not available\n", __func__);
		bluedroid_pm->vdd_1v8 = NULL;
	}
*///sunzizhi delate
	res = platform_get_resource_byname(pdev, IORESOURCE_IO, "reset_gpio");
	if (res) {
		bluedroid_pm->gpio_reset = res->start;
		ret = gpio_request(bluedroid_pm->gpio_reset, "reset_gpio");
		if (ret) {
			pr_err("%s: Failed to get reset gpio\n", __func__);
			goto free_res;
		}
		gpio_direction_output(bluedroid_pm->gpio_reset, enable);
	} else {
		pr_debug("%s: Reset gpio not registered.\n", __func__);
		bluedroid_pm->gpio_reset = 0;
	}

	res = platform_get_resource_byname(pdev, IORESOURCE_IO,
						"shutdown_gpio");
	if (res) {
		bluedroid_pm->gpio_shutdown = res->start;
		//ret = gpio_request(bluedroid_pm->gpio_shutdown,
			//			"shutdown_gpio");
		//if (ret) {
		//	pr_err("%s: Failed to get shutdown gpio\n", __func__);
		//	goto free_res;
		//}
		gpio_direction_output(bluedroid_pm->gpio_shutdown, enable);
	} else {
		pr_debug("%s: shutdown gpio not registered\n", __func__);
		bluedroid_pm->gpio_shutdown = 0;
	}

	/*
	 * make sure at-least one of the GPIO or regulators avaiable to
	 * register with rfkill is defined
	 */
		/*sunzizhi modify*/
	//if (bluedroid_pm->gpio_reset || bluedroid_pm->gpio_shutdown ||
		//bluedroid_pm->vdd_1v8 || bluedroid_pm->vdd_3v3) {
		if (bluedroid_pm->gpio_reset || bluedroid_pm->gpio_shutdown ) {
		rfkill = rfkill_alloc(pdev->name, &pdev->dev,
				RFKILL_TYPE_BLUETOOTH, &bluedroid_pm_rfkill_ops,
				bluedroid_pm);

		if (unlikely(!rfkill))
			goto free_res;

		default_sw_block_state = !enable;
		rfkill_set_states(rfkill, default_sw_block_state, false);

		ret = rfkill_register(rfkill);

		if (unlikely(ret)) {
			rfkill_destroy(rfkill);
			kfree(rfkill);
			goto free_res;
		}
		bluedroid_pm->rfkill = rfkill;
	}

#if 0
	res = platform_get_resource_byname(pdev, IORESOURCE_IO,
				"gpio_host_wake");
	if (res) {
		bluedroid_pm->host_wake = res->start;
		//ret = gpio_request(bluedroid_pm->host_wake, "bt_host_wake");
		//if (ret) {
		//	pr_err("%s: Failed to get host_wake gpio\n", __func__);
		//	goto free_res;
		//}
		/* configure host_wake as input */
		gpio_direction_input(bluedroid_pm->host_wake);
	} else {
		pr_debug("%s: gpio_host_wake not registered\n", __func__);
		bluedroid_pm->host_wake = 0;
	}

	res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "host_wake");
	if (res) {
		pr_err("%s : found host_wake irq\n", __func__);
#if 0
			bt_lpm.host_wake = 0;
		wake_lock_init(&bt_lpm.host_wake_lock, WAKE_LOCK_SUSPEND,
			 "BTHostWakeLowPower");
#endif
		bluedroid_pm->host_wake_irq = res->start;
		ret = request_irq(bluedroid_pm->host_wake_irq,
					bluedroid_pm_hostwake_isr,
					IRQF_DISABLED | IRQF_TRIGGER_RISING,
					"bluetooth hostwake", bluedroid_pm);
		if (ret) {
			pr_err("%s: Failed to get host_wake irq\n", __func__);
			goto free_res;
		}
	} else {
		pr_debug("%s: host_wake not registered\n", __func__);
		bluedroid_pm->host_wake_irq = 0;
	}

	res = platform_get_resource_byname(pdev, IORESOURCE_IO,
				"gpio_ext_wake");
	if (res) {
		bluedroid_pm->ext_wake = res->start;
		//ret = gpio_request(bluedroid_pm->ext_wake, "bt_ext_wake");
		//if (ret) {
		//	pr_err("%s: Failed to get ext_wake gpio\n", __func__);
			//goto free_res;
		//}
		/* configure ext_wake as output mode*/
		gpio_direction_output(bluedroid_pm->ext_wake, 0);
		if (create_bt_proc_interface(bluedroid_pm)) {
			pr_err("%s: Failed to create proc interface", __func__);
			goto free_res;
		}
	} else {
		pr_debug("%s: gpio_ext_wake not registered\n", __func__);
		bluedroid_pm->ext_wake = 0;
	}
#endif

	platform_set_drvdata(pdev, bluedroid_pm);
	pr_debug("RFKILL BT driver successfully registered");
	return 0;

free_res:
	//if (bluedroid_pm->vdd_3v3)     sunzizhi delate
		//regulator_put(bluedroid_pm->vdd_3v3);
	//if (bluedroid_pm->vdd_1v8)
	//	regulator_put(bluedroid_pm->vdd_1v8);
	if (bluedroid_pm->gpio_shutdown)
		gpio_free(bluedroid_pm->gpio_shutdown);
	if (bluedroid_pm->gpio_reset)
		gpio_free(bluedroid_pm->gpio_reset);
#if 0
	if (bluedroid_pm->ext_wake)
		gpio_free(bluedroid_pm->ext_wake);
	if (bluedroid_pm->host_wake)
		gpio_free(bluedroid_pm->host_wake);
#endif

	if (bluedroid_pm->rfkill) {
		rfkill_unregister(bluedroid_pm->rfkill);
		rfkill_destroy(bluedroid_pm->rfkill);
		kfree(bluedroid_pm->rfkill);
	}
	kfree(bluedroid_pm);
	return -ENODEV;
}
Ejemplo n.º 20
0
static int bluetooth_pm_probe(struct platform_device *pdev)
{
	int ret;
	bool default_state = true;  /* off */

	struct bluetooth_pm_device_info *bdev;
	struct pinctrl *bt_pinctrl;
	struct pinctrl_state *gpio_state_active;

	printk("%s:  bluetooth_pm_probe is called \n", __func__);
	bsi = kzalloc(sizeof(struct bluetooth_pm_data), GFP_KERNEL);
	if (!bsi) {
		printk("%s:  bsi is null \n", __func__);
		return -ENOMEM;
	}

	if (pdev->dev.of_node) {
		pdev->dev.platform_data = bsi;
		ret = bluetooth_pm_parse_dt(&pdev->dev);
		if (ret < 0) {
			printk("%s: failed to parse device tree\n",__func__);
			goto free_res;
		}
	} else {
		printk("%s: No Device Node\n", __func__);
		goto free_res;
	}

	if(!bsi) {
		printk("%s: no bluetooth_pm_data \n", __func__);
		return -ENODEV;
	}

	bdev = kzalloc(sizeof(struct bluetooth_pm_device_info), GFP_KERNEL);
	if (!bdev) {
		printk("%s: bdev is null  \n", __func__);
		return -ENOMEM;
	}

	bdev->gpio_bt_reset = bsi->bt_reset;
	bdev->gpio_bt_host_wake = bsi->host_wake;
	bdev->gpio_bt_ext_wake = bsi->ext_wake;
	
	platform_set_drvdata(pdev, bdev);
	
	//BT_RESET
	ret = gpio_request_one(bdev->gpio_bt_reset, GPIOF_OUT_INIT_LOW, "bt_reset");
	if (ret) {
		pr_err("%s: failed to request gpio(%d)\n", __func__, bdev->gpio_bt_reset);
		goto free_res;
	}

	//BT_HOST_WAKE
	ret = gpio_request_one(bdev->gpio_bt_host_wake, GPIOF_IN, "bt_host_wake");
	if (ret) {
		pr_err("%s: failed to request gpio(%d)\n", __func__, bdev->gpio_bt_host_wake);
		goto free_res;
	}
	bt_pinctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR_OR_NULL(bt_pinctrl)) {
		pr_err("%s: target does not use pinctrl for host wake \n", __func__);
		return -ENODEV;
	}
	gpio_state_active = pinctrl_lookup_state(bt_pinctrl, "bt_active" );
	if (IS_ERR_OR_NULL(gpio_state_active)) {
		pr_err("%s: can't get gpio_state_active for host wake  \n", __func__);
		return -ENODEV;
	}
	if (pinctrl_select_state(bt_pinctrl, gpio_state_active))
		pr_err("%s: error on pinctrl_select_state for host wake \n", __func__);
	else
		printk("%s: success to set pinctrl_select_state for host wake \n", __func__);
	//BT_EXT_WAKE
	ret = gpio_request_one(bdev->gpio_bt_ext_wake, GPIOF_OUT_INIT_LOW, "bt_ext_wake");
	if (ret) {
		pr_err("%s: failed to request gpio(%d)\n", __func__, bdev->gpio_bt_ext_wake);
		goto free_res;
	}

	bluetooth_pm_rfkill_set_power(bdev, default_state);

	bdev->rfk = rfkill_alloc(pdev->name, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&bluetooth_pm_rfkill_ops, bsi);
	if(unlikely(!bdev->rfk)) {
		pr_err("%s:  failed to alloc rfkill \n", __func__);
		ret = -ENOMEM;
		goto free_res;
	}
	
	rfkill_set_states(bdev->rfk, default_state, false);

	ret = rfkill_register(bdev->rfk);
	
	if (unlikely(ret)) {
		pr_err("%s:  failed to register rfkill \n", __func__);
		rfkill_destroy(bdev->rfk);
		kfree(bdev->rfk);
		goto free_res;
	}
	bsi->rfkill = bdev->rfk;

	bsi->host_wake_irq = platform_get_irq_byname(pdev, "host_wake_interrupt");
	if (bsi->host_wake_irq < 0) {
		pr_err("%s: Couldn't find host_wake irq \n",__func__);
	}


	printk("%s :  hostwake GPIO : %d(%u),  btwake GPIO : %d(%u) \n",__func__, 
			bsi->host_wake,gpio_get_value(bsi->host_wake),bsi->ext_wake,gpio_get_value(bsi->ext_wake));
	printk("%s: bsi->host_wake_irq: %d \n", __func__,bsi->host_wake_irq);
	ret = bt_enable_pinctrl_init(&pdev->dev, bdev);
	if (ret) {
		pr_err("%s: failed to init pinctrl\n", __func__);
		goto free_res;
	}
#ifdef UART_CONTROL_MSM
	bsi->uport = NULL;//msm_hs_get_bt_uport(BT_PORT_NUM);
#endif/*UART_CONTROL_MSM*/

#ifdef QOS_REQUEST_MSM
		bsi->dma_qos_request = NOT_REQUESTED;
#endif /* QOS_REQUEST_MSM */

#ifdef QOS_REQUEST_TEGRA
		bsi->resume_min_frequency = 204000;
#endif/*QOS_REQUEST_TEGRA*/

	
	wake_lock_init(&bsi->wake_lock, WAKE_LOCK_SUSPEND, "bluetooth_pm");

	bluetooth_pm_create_bt_proc_interface(); 

	return 0;

free_res:	
	if(bsi->ext_wake)
		gpio_free(bsi->ext_wake);
	if(bsi->host_wake)
		gpio_free(bsi->host_wake);
	if(bsi->bt_reset)
		gpio_free(bsi->bt_reset);
	if (bsi->rfkill) {
		rfkill_unregister(bsi->rfkill);
		rfkill_destroy(bsi->rfkill);
		kfree(bsi->rfkill);
	}
	kfree(bsi);
	return ret;
}