1 // SPDX-License-Identifier: GPL-1.0
3 // Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
5 // S3C2410 bluetooth "driver"
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>
16 #include <plat/gpio-cfg.h>
17 #include <mach/hardware.h>
18 #include <mach/regs-gpio.h>
19 #include <mach/gpio-samsung.h>
23 #define DRV_NAME "h1940-bt"
25 /* Bluetooth control */
26 static void h1940bt_enable(int on
)
29 /* Power on the chip */
30 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER
, 1);
34 gpio_set_value(S3C2410_GPH(1), 1);
36 gpio_set_value(S3C2410_GPH(1), 0);
38 h1940_led_blink_set(NULL
, GPIO_LED_BLINK
, NULL
, NULL
);
41 gpio_set_value(S3C2410_GPH(1), 1);
43 gpio_set_value(S3C2410_GPH(1), 0);
45 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER
, 0);
47 h1940_led_blink_set(NULL
, GPIO_LED_NO_BLINK_LOW
, NULL
, NULL
);
51 static int h1940bt_set_block(void *data
, bool blocked
)
53 h1940bt_enable(!blocked
);
57 static const struct rfkill_ops h1940bt_rfkill_ops
= {
58 .set_block
= h1940bt_set_block
,
61 static int h1940bt_probe(struct platform_device
*pdev
)
66 ret
= gpio_request(S3C2410_GPH(1), dev_name(&pdev
->dev
));
68 dev_err(&pdev
->dev
, "could not get GPH1\n");
72 ret
= gpio_request(H1940_LATCH_BLUETOOTH_POWER
, dev_name(&pdev
->dev
));
74 gpio_free(S3C2410_GPH(1));
75 dev_err(&pdev
->dev
, "could not get BT_POWER\n");
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
);
89 rfk
= rfkill_alloc(DRV_NAME
, &pdev
->dev
, RFKILL_TYPE_BLUETOOTH
,
90 &h1940bt_rfkill_ops
, NULL
);
96 ret
= rfkill_register(rfk
);
100 platform_set_drvdata(pdev
, rfk
);
110 static int h1940bt_remove(struct platform_device
*pdev
)
112 struct rfkill
*rfk
= platform_get_drvdata(pdev
);
114 platform_set_drvdata(pdev
, NULL
);
115 gpio_free(S3C2410_GPH(1));
118 rfkill_unregister(rfk
);
129 static struct platform_driver h1940bt_driver
= {
133 .probe
= h1940bt_probe
,
134 .remove
= h1940bt_remove
,
137 module_platform_driver(h1940bt_driver
);
139 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
140 MODULE_DESCRIPTION("Driver for the iPAQ H1940 bluetooth chip");
141 MODULE_LICENSE("GPL");