2007-05-09 22:41:03 +02:00
|
|
|
/*
|
|
|
|
* arch/arm/mach-s3c2410/h1940-bluetooth.c
|
|
|
|
* Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file COPYING in the main directory of this archive for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* S3C2410 bluetooth "driver"
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/leds.h>
|
2009-05-13 23:52:24 +02:00
|
|
|
#include <linux/gpio.h>
|
2009-11-17 14:54:59 +01:00
|
|
|
#include <linux/rfkill.h>
|
2009-05-13 23:52:24 +02:00
|
|
|
|
2014-01-14 15:05:22 +01:00
|
|
|
#include <plat/gpio-cfg.h>
|
2008-08-05 17:14:15 +02:00
|
|
|
#include <mach/hardware.h>
|
2013-01-02 19:18:58 +01:00
|
|
|
#include <mach/regs-gpio.h>
|
2014-01-14 14:24:24 +01:00
|
|
|
#include <mach/gpio-samsung.h>
|
2013-01-02 19:18:58 +01:00
|
|
|
|
|
|
|
#include "h1940.h"
|
2007-05-09 22:41:03 +02:00
|
|
|
|
2011-01-06 20:52:48 +01:00
|
|
|
#define DRV_NAME "h1940-bt"
|
2007-05-09 22:41:03 +02:00
|
|
|
|
|
|
|
/* Bluetooth control */
|
|
|
|
static void h1940bt_enable(int on)
|
|
|
|
{
|
|
|
|
if (on) {
|
|
|
|
/* Power on the chip */
|
2010-09-08 11:39:46 +02:00
|
|
|
gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 1);
|
2007-05-09 22:41:03 +02:00
|
|
|
/* Reset the chip */
|
|
|
|
mdelay(10);
|
2010-05-04 04:23:05 +02:00
|
|
|
|
|
|
|
gpio_set_value(S3C2410_GPH(1), 1);
|
2007-05-09 22:41:03 +02:00
|
|
|
mdelay(10);
|
2010-05-04 04:23:05 +02:00
|
|
|
gpio_set_value(S3C2410_GPH(1), 0);
|
2011-01-06 20:52:48 +01:00
|
|
|
|
2014-10-31 12:40:58 +01:00
|
|
|
h1940_led_blink_set(NULL, GPIO_LED_BLINK, NULL, NULL);
|
2007-05-09 22:41:03 +02:00
|
|
|
}
|
|
|
|
else {
|
2010-05-04 04:23:05 +02:00
|
|
|
gpio_set_value(S3C2410_GPH(1), 1);
|
2007-05-09 22:41:03 +02:00
|
|
|
mdelay(10);
|
2010-05-04 04:23:05 +02:00
|
|
|
gpio_set_value(S3C2410_GPH(1), 0);
|
2007-05-09 22:41:03 +02:00
|
|
|
mdelay(10);
|
2010-09-08 11:39:46 +02:00
|
|
|
gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0);
|
2011-01-06 20:52:48 +01:00
|
|
|
|
2014-10-31 12:40:58 +01:00
|
|
|
h1940_led_blink_set(NULL, GPIO_LED_NO_BLINK_LOW, NULL, NULL);
|
2007-05-09 22:41:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-17 14:54:59 +01:00
|
|
|
static int h1940bt_set_block(void *data, bool blocked)
|
2007-05-09 22:41:03 +02:00
|
|
|
{
|
2009-11-17 14:54:59 +01:00
|
|
|
h1940bt_enable(!blocked);
|
|
|
|
return 0;
|
2007-05-09 22:41:03 +02:00
|
|
|
}
|
|
|
|
|
2009-11-17 14:54:59 +01:00
|
|
|
static const struct rfkill_ops h1940bt_rfkill_ops = {
|
|
|
|
.set_block = h1940bt_set_block,
|
|
|
|
};
|
2007-05-09 22:41:03 +02:00
|
|
|
|
2012-12-21 23:02:24 +01:00
|
|
|
static int h1940bt_probe(struct platform_device *pdev)
|
2007-05-09 22:41:03 +02:00
|
|
|
{
|
2009-11-17 14:54:59 +01:00
|
|
|
struct rfkill *rfk;
|
|
|
|
int ret = 0;
|
|
|
|
|
2010-05-04 04:23:05 +02:00
|
|
|
ret = gpio_request(S3C2410_GPH(1), dev_name(&pdev->dev));
|
|
|
|
if (ret) {
|
2010-09-08 11:39:46 +02:00
|
|
|
dev_err(&pdev->dev, "could not get GPH1\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = gpio_request(H1940_LATCH_BLUETOOTH_POWER, dev_name(&pdev->dev));
|
|
|
|
if (ret) {
|
|
|
|
gpio_free(S3C2410_GPH(1));
|
|
|
|
dev_err(&pdev->dev, "could not get BT_POWER\n");
|
2010-05-04 04:23:05 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-05-09 22:41:03 +02:00
|
|
|
/* Configures BT serial port GPIOs */
|
2010-05-04 07:38:49 +02:00
|
|
|
s3c_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0);
|
2010-11-16 10:11:59 +01:00
|
|
|
s3c_gpio_setpull(S3C2410_GPH(0), S3C_GPIO_PULL_NONE);
|
2010-05-04 07:38:49 +02:00
|
|
|
s3c_gpio_cfgpin(S3C2410_GPH(1), S3C2410_GPIO_OUTPUT);
|
2010-11-16 10:11:59 +01:00
|
|
|
s3c_gpio_setpull(S3C2410_GPH(1), S3C_GPIO_PULL_NONE);
|
2010-05-04 07:38:49 +02:00
|
|
|
s3c_gpio_cfgpin(S3C2410_GPH(2), S3C2410_GPH2_TXD0);
|
2010-11-16 10:11:59 +01:00
|
|
|
s3c_gpio_setpull(S3C2410_GPH(2), S3C_GPIO_PULL_NONE);
|
2010-05-04 07:38:49 +02:00
|
|
|
s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0);
|
2010-11-16 10:11:59 +01:00
|
|
|
s3c_gpio_setpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE);
|
2007-05-09 22:41:03 +02:00
|
|
|
|
2009-11-17 14:54:59 +01:00
|
|
|
rfk = rfkill_alloc(DRV_NAME, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
|
|
|
|
&h1940bt_rfkill_ops, NULL);
|
|
|
|
if (!rfk) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_rfk_alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = rfkill_register(rfk);
|
|
|
|
if (ret)
|
|
|
|
goto err_rfkill;
|
|
|
|
|
|
|
|
platform_set_drvdata(pdev, rfk);
|
|
|
|
|
|
|
|
return 0;
|
2007-05-09 22:41:03 +02:00
|
|
|
|
2009-11-17 14:54:59 +01:00
|
|
|
err_rfkill:
|
|
|
|
rfkill_destroy(rfk);
|
|
|
|
err_rfk_alloc:
|
|
|
|
return ret;
|
2007-05-09 22:41:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int h1940bt_remove(struct platform_device *pdev)
|
|
|
|
{
|
2009-11-17 14:54:59 +01:00
|
|
|
struct rfkill *rfk = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
platform_set_drvdata(pdev, NULL);
|
2010-05-04 04:23:05 +02:00
|
|
|
gpio_free(S3C2410_GPH(1));
|
2009-11-17 14:54:59 +01:00
|
|
|
|
|
|
|
if (rfk) {
|
|
|
|
rfkill_unregister(rfk);
|
|
|
|
rfkill_destroy(rfk);
|
|
|
|
}
|
|
|
|
rfk = NULL;
|
|
|
|
|
|
|
|
h1940bt_enable(0);
|
|
|
|
|
2007-05-09 22:41:03 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct platform_driver h1940bt_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
},
|
|
|
|
.probe = h1940bt_probe,
|
|
|
|
.remove = h1940bt_remove,
|
|
|
|
};
|
|
|
|
|
2012-09-06 23:33:24 +02:00
|
|
|
module_platform_driver(h1940bt_driver);
|
2007-05-09 22:41:03 +02:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
|
|
|
|
MODULE_DESCRIPTION("Driver for the iPAQ H1940 bluetooth chip");
|
|
|
|
MODULE_LICENSE("GPL");
|