diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-12 18:11:33 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-12 18:11:33 -0700 |
commit | f7d02ae76ebbf5b8a9531fe150c49e126a397704 (patch) | |
tree | bcfdcab6e70658d55a3c843694e04e938bf9168f /arch/arm/mach-s3c2410/h1940-bluetooth.c | |
parent | 78db2ad6f4df9145bfd6aab1c0f1c56d615288ec (diff) | |
parent | 158304ef09a28c7f2dd37d78f536a4e09ba084a1 (diff) |
Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (30 commits)
[ARM] Use new get_irqnr_preamble
[ARM] Ensure machine class menu is sorted alphabetically
[ARM] 4333/2: KS8695: Micrel Development board
[ARM] 4332/2: KS8695: Serial driver
[ARM] 4331/3: Support for Micrel/Kendin KS8695 processor
[ARM] 4371/1: AT91: Support for Atmel AT91SAM9RL-EK development board
[ARM] 4372/1: Define byte sizes in asm-arm/sizes.h
[ARM] 4370/3: AT91: Support for Atmel AT91SAM9RL processors.
[ARM] Update mach-types
[ARM] export symbol csum_partial_copy_from_user
[ARM] iop13xx: msi support
[ARM] stacktrace fix
[ARM] Spinlock initializer cleanup
[ARM] remove useless config option GENERIC_BUST_SPINLOCK
[ARM] 4303/3: base kernel support for TI DaVinci
[ARM] 4369/1: AT91: Fix circular dependency in header files
[ARM] 4368/1: S3C24xx: build fix
[ARM] 4364/1: AT91: LEDS on AT91SAM9261-EK
[ARM] Fix iop32x/iop33x build
[ARM] EBSA110: fix build errors caused by missing "const"
...
Diffstat (limited to 'arch/arm/mach-s3c2410/h1940-bluetooth.c')
-rw-r--r-- | arch/arm/mach-s3c2410/h1940-bluetooth.c | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c new file mode 100644 index 00000000000..3c48886521e --- /dev/null +++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c @@ -0,0 +1,142 @@ +/* + * 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 <asm/arch/regs-gpio.h> +#include <asm/hardware.h> +#include <asm/arch/h1940-latch.h> + +#define DRV_NAME "h1940-bt" + +#ifdef CONFIG_LEDS_H1940 +DEFINE_LED_TRIGGER(bt_led_trigger); +#endif + +static int state; + +/* Bluetooth control */ +static void h1940bt_enable(int on) +{ + if (on) { +#ifdef CONFIG_LEDS_H1940 + /* flashing Blue */ + led_trigger_event(bt_led_trigger, LED_HALF); +#endif + + /* Power on the chip */ + h1940_latch_control(0, H1940_LATCH_BLUETOOTH_POWER); + /* Reset the chip */ + mdelay(10); + s3c2410_gpio_setpin(S3C2410_GPH1, 1); + mdelay(10); + s3c2410_gpio_setpin(S3C2410_GPH1, 0); + + state = 1; + } + else { +#ifdef CONFIG_LEDS_H1940 + led_trigger_event(bt_led_trigger, 0); +#endif + + s3c2410_gpio_setpin(S3C2410_GPH1, 1); + mdelay(10); + s3c2410_gpio_setpin(S3C2410_GPH1, 0); + mdelay(10); + h1940_latch_control(H1940_LATCH_BLUETOOTH_POWER, 0); + + state = 0; + } +} + +static ssize_t h1940bt_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", state); +} + +static ssize_t h1940bt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) +{ + int new_state; + char *endp; + + new_state = simple_strtoul(buf, &endp, 0); + if (*endp && !isspace(*endp)) + return -EINVAL; + + h1940bt_enable(new_state); + + return count; +} +static DEVICE_ATTR(enable, 0644, + h1940bt_show, + h1940bt_store); + +static int __init h1940bt_probe(struct platform_device *pdev) +{ + /* Configures BT serial port GPIOs */ + s3c2410_gpio_cfgpin(S3C2410_GPH0, S3C2410_GPH0_nCTS0); + s3c2410_gpio_pullup(S3C2410_GPH0, 1); + s3c2410_gpio_cfgpin(S3C2410_GPH1, S3C2410_GPH1_OUTP); + s3c2410_gpio_pullup(S3C2410_GPH1, 1); + s3c2410_gpio_cfgpin(S3C2410_GPH2, S3C2410_GPH2_TXD0); + s3c2410_gpio_pullup(S3C2410_GPH2, 1); + s3c2410_gpio_cfgpin(S3C2410_GPH3, S3C2410_GPH3_RXD0); + s3c2410_gpio_pullup(S3C2410_GPH3, 1); + +#ifdef CONFIG_LEDS_H1940 + led_trigger_register_simple("h1940-bluetooth", &bt_led_trigger); +#endif + + /* disable BT by default */ + h1940bt_enable(0); + + return device_create_file(&pdev->dev, &dev_attr_enable); +} + +static int h1940bt_remove(struct platform_device *pdev) +{ +#ifdef CONFIG_LEDS_H1940 + led_trigger_unregister_simple(bt_led_trigger); +#endif + 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"); |