~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-s3c24xx/h1940-bluetooth.c

Version: ~ [ linux-5.10-rc5 ] ~ [ linux-5.9.10 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.79 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.159 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.208 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.245 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.245 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-1.0+
  2 //
  3 // Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
  4 //
  5 //          S3C2410 bluetooth "driver"
  6 
  7 #include <linux/module.h>
  8 #include <linux/platform_device.h>
  9 #include <linux/delay.h>
 10 #include <linux/string.h>
 11 #include <linux/ctype.h>
 12 #include <linux/leds.h>
 13 #include <linux/gpio.h>
 14 #include <linux/rfkill.h>
 15 
 16 #include <plat/gpio-cfg.h>
 17 #include <mach/hardware.h>
 18 #include <mach/regs-gpio.h>
 19 #include <mach/gpio-samsung.h>
 20 
 21 #include "h1940.h"
 22 
 23 #define DRV_NAME "h1940-bt"
 24 
 25 /* Bluetooth control */
 26 static void h1940bt_enable(int on)
 27 {
 28         if (on) {
 29                 /* Power on the chip */
 30                 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 1);
 31                 /* Reset the chip */
 32                 mdelay(10);
 33 
 34                 gpio_set_value(S3C2410_GPH(1), 1);
 35                 mdelay(10);
 36                 gpio_set_value(S3C2410_GPH(1), 0);
 37 
 38                 h1940_led_blink_set(NULL, GPIO_LED_BLINK, NULL, NULL);
 39         }
 40         else {
 41                 gpio_set_value(S3C2410_GPH(1), 1);
 42                 mdelay(10);
 43                 gpio_set_value(S3C2410_GPH(1), 0);
 44                 mdelay(10);
 45                 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0);
 46 
 47                 h1940_led_blink_set(NULL, GPIO_LED_NO_BLINK_LOW, NULL, NULL);
 48         }
 49 }
 50 
 51 static int h1940bt_set_block(void *data, bool blocked)
 52 {
 53         h1940bt_enable(!blocked);
 54         return 0;
 55 }
 56 
 57 static const struct rfkill_ops h1940bt_rfkill_ops = {
 58         .set_block = h1940bt_set_block,
 59 };
 60 
 61 static int h1940bt_probe(struct platform_device *pdev)
 62 {
 63         struct rfkill *rfk;
 64         int ret = 0;
 65 
 66         ret = gpio_request(S3C2410_GPH(1), dev_name(&pdev->dev));
 67         if (ret) {
 68                 dev_err(&pdev->dev, "could not get GPH1\n");
 69                 return ret;
 70         }
 71 
 72         ret = gpio_request(H1940_LATCH_BLUETOOTH_POWER, dev_name(&pdev->dev));
 73         if (ret) {
 74                 gpio_free(S3C2410_GPH(1));
 75                 dev_err(&pdev->dev, "could not get BT_POWER\n");
 76                 return ret;
 77         }
 78 
 79         /* Configures BT serial port GPIOs */
 80         s3c_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0);
 81         s3c_gpio_setpull(S3C2410_GPH(0), S3C_GPIO_PULL_NONE);
 82         s3c_gpio_cfgpin(S3C2410_GPH(1), S3C2410_GPIO_OUTPUT);
 83         s3c_gpio_setpull(S3C2410_GPH(1), S3C_GPIO_PULL_NONE);
 84         s3c_gpio_cfgpin(S3C2410_GPH(2), S3C2410_GPH2_TXD0);
 85         s3c_gpio_setpull(S3C2410_GPH(2), S3C_GPIO_PULL_NONE);
 86         s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0);
 87         s3c_gpio_setpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE);
 88 
 89         rfk = rfkill_alloc(DRV_NAME, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
 90                         &h1940bt_rfkill_ops, NULL);
 91         if (!rfk) {
 92                 ret = -ENOMEM;
 93                 goto err_rfk_alloc;
 94         }
 95 
 96         ret = rfkill_register(rfk);
 97         if (ret)
 98                 goto err_rfkill;
 99 
100         platform_set_drvdata(pdev, rfk);
101 
102         return 0;
103 
104 err_rfkill:
105         rfkill_destroy(rfk);
106 err_rfk_alloc:
107         return ret;
108 }
109 
110 static int h1940bt_remove(struct platform_device *pdev)
111 {
112         struct rfkill *rfk = platform_get_drvdata(pdev);
113 
114         platform_set_drvdata(pdev, NULL);
115         gpio_free(S3C2410_GPH(1));
116 
117         if (rfk) {
118                 rfkill_unregister(rfk);
119                 rfkill_destroy(rfk);
120         }
121         rfk = NULL;
122 
123         h1940bt_enable(0);
124 
125         return 0;
126 }
127 
128 
129 static struct platform_driver h1940bt_driver = {
130         .driver         = {
131                 .name   = DRV_NAME,
132         },
133         .probe          = h1940bt_probe,
134         .remove         = h1940bt_remove,
135 };
136 
137 module_platform_driver(h1940bt_driver);
138 
139 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
140 MODULE_DESCRIPTION("Driver for the iPAQ H1940 bluetooth chip");
141 MODULE_LICENSE("GPL");
142 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp