diff options
author | Olof Johansson <olof@lixom.net> | 2012-03-08 08:53:14 -0800 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2012-03-08 08:53:14 -0800 |
commit | d60d506e6baaf423148c458df3ece0c1d440dce4 (patch) | |
tree | c25c44e70ebaaddcbe39559df5c5cd260e956be4 /arch/arm/mach-s3c24xx/h1940-bluetooth.c | |
parent | 62f383435932ea3d271bee6b957de048452c1b16 (diff) | |
parent | 2e5ac9436645bb9fd2097868e228321f303c9c75 (diff) | |
download | blackbird-op-linux-d60d506e6baaf423148c458df3ece0c1d440dce4.tar.gz blackbird-op-linux-d60d506e6baaf423148c458df3ece0c1d440dce4.zip |
Merge branch 'next/cleanup-s3c24xx' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung into next/cleanup
* 'next/cleanup-s3c24xx' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung: (24 commits)
ARM: S3C24XX: remove call to s3c24xx_setup_clocks
ARM: S3C24XX: add get_rate for clk_p on S3C2416/2443
ARM: S3C24XX: add get_rate for clk_h on S3C2416/2443
ARM: S3C24XX: remove XXX_setup_clocks method from S3C2443
ARM: S3C24XX: remove obsolete S3C2416_DMA option
ARM: S3C24XX: Reuse S3C2443 dma for S3C2416
ARM: S3C24XX: Fix indentation of dma-s3c2443
ARM: S3C24XX: Move device setup files to mach directory
ARM: S3C24XX: Consolidate Simtec extensions
ARM: S3C24XX: move simtec-specific code to mach directory
ARM: S3C24XX: Move common-smdk code to mach directory
ARM: S3C24XX: Move s3c2443-clock.c to mach-s3c24xx
ARM: s3c2410_defconfig: update s3c2410_defconfig
ARM: S3C2443: move mach-s3c2443/* into mach-s3c24xx/
ARM: S3C2440: move mach-s3c2440/* into mach-s3c24xx/
ARM: S3C2416: move mach-s3c2416/* into mach-s3c24xx/
ARM: S3C2412: move mach-s3c2412/* into mach-s3c24xx/
ARM: S3C2410: move mach-s3c2410/* into mach-s3c24xx/
ARM: S3C24XX: change the ARCH_S3C2410 to ARCH_S3C24XX
ARM: S3C2410: move s3c2410_baseclk_add to clock.h
...
Diffstat (limited to 'arch/arm/mach-s3c24xx/h1940-bluetooth.c')
-rw-r--r-- | arch/arm/mach-s3c24xx/h1940-bluetooth.c | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c24xx/h1940-bluetooth.c b/arch/arm/mach-s3c24xx/h1940-bluetooth.c new file mode 100644 index 000000000000..a5eeb62ce1c2 --- /dev/null +++ b/arch/arm/mach-s3c24xx/h1940-bluetooth.c @@ -0,0 +1,157 @@ +/* + * 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> +#include <linux/gpio.h> +#include <linux/rfkill.h> + +#include <mach/regs-gpio.h> +#include <mach/hardware.h> +#include <mach/h1940-latch.h> +#include <mach/h1940.h> + +#define DRV_NAME "h1940-bt" + +/* Bluetooth control */ +static void h1940bt_enable(int on) +{ + if (on) { + /* Power on the chip */ + gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 1); + /* Reset the chip */ + mdelay(10); + + gpio_set_value(S3C2410_GPH(1), 1); + mdelay(10); + gpio_set_value(S3C2410_GPH(1), 0); + + h1940_led_blink_set(-EINVAL, GPIO_LED_BLINK, NULL, NULL); + } + else { + gpio_set_value(S3C2410_GPH(1), 1); + mdelay(10); + gpio_set_value(S3C2410_GPH(1), 0); + mdelay(10); + gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0); + + h1940_led_blink_set(-EINVAL, GPIO_LED_NO_BLINK_LOW, NULL, NULL); + } +} + +static int h1940bt_set_block(void *data, bool blocked) +{ + h1940bt_enable(!blocked); + return 0; +} + +static const struct rfkill_ops h1940bt_rfkill_ops = { + .set_block = h1940bt_set_block, +}; + +static int __devinit h1940bt_probe(struct platform_device *pdev) +{ + struct rfkill *rfk; + int ret = 0; + + ret = gpio_request(S3C2410_GPH(1), dev_name(&pdev->dev)); + if (ret) { + 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"); + return ret; + } + + /* Configures BT serial port GPIOs */ + s3c_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0); + s3c_gpio_setpull(S3C2410_GPH(0), S3C_GPIO_PULL_NONE); + s3c_gpio_cfgpin(S3C2410_GPH(1), S3C2410_GPIO_OUTPUT); + s3c_gpio_setpull(S3C2410_GPH(1), S3C_GPIO_PULL_NONE); + s3c_gpio_cfgpin(S3C2410_GPH(2), S3C2410_GPH2_TXD0); + s3c_gpio_setpull(S3C2410_GPH(2), S3C_GPIO_PULL_NONE); + s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0); + s3c_gpio_setpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE); + + 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; + +err_rfkill: + rfkill_destroy(rfk); +err_rfk_alloc: + return ret; +} + +static int h1940bt_remove(struct platform_device *pdev) +{ + struct rfkill *rfk = platform_get_drvdata(pdev); + + platform_set_drvdata(pdev, NULL); + gpio_free(S3C2410_GPH(1)); + + if (rfk) { + rfkill_unregister(rfk); + rfkill_destroy(rfk); + } + rfk = NULL; + + h1940bt_enable(0); + + return 0; +} + + +static struct platform_driver h1940bt_driver = { + .driver = { + .name = DRV_NAME, + }, + .probe = h1940bt_probe, + .remove = h1940bt_remove, +}; + + +static int __init h1940bt_init(void) +{ + return platform_driver_register(&h1940bt_driver); +} + +static void __exit h1940bt_exit(void) +{ + platform_driver_unregister(&h1940bt_driver); +} + +module_init(h1940bt_init); +module_exit(h1940bt_exit); + +MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); +MODULE_DESCRIPTION("Driver for the iPAQ H1940 bluetooth chip"); +MODULE_LICENSE("GPL"); |