Search
SailfishOS Open Build Service
>
Projects
>
home:dcthang:branches:nemo:devel:hw:ti:omap3:n900
>
kernel-adaptation-n900
> linux-2.6-Bluetooth-Add-sysfs-interface-for-hci_h4p-driver-to-.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File linux-2.6-Bluetooth-Add-sysfs-interface-for-hci_h4p-driver-to-.patch of Package kernel-adaptation-n900
From 2e456c145ca8276f2655c368a442625fb6b68b74 Mon Sep 17 00:00:00 2001 From: Tommi Keisala <ext-tommi.keisala@nokia.com> Date: Thu, 9 Dec 2010 15:15:39 +0200 Subject: [PATCH] Bluetooth: Add sysfs interface for hci_h4p driver to control MAC address Integrated from hci_h4p driver by Ville Tervo MAC address control for bluetooth interface. Signed-off-by: Tommi Keisala <ext-tommi.keisala@nokia.com> --- arch/arm/mach-omap2/board-rx51-peripherals.c | 52 +++++++++++++++++++++++++- drivers/bluetooth/hci_h4p/fw-bcm.c | 30 ++++++++++++--- drivers/bluetooth/hci_h4p/hci_h4p.h | 8 ++++ include/linux/bluetooth/hci_h4p.h | 1 + 4 files changed, 83 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c index 83c6d2d..5558335 100644 --- a/arch/arm/mach-omap2/board-rx51-peripherals.c +++ b/arch/arm/mach-omap2/board-rx51-peripherals.c @@ -1213,6 +1213,50 @@ static struct platform_device rx51_bt_device = { } }; +static ssize_t hci_h4p_store_bdaddr(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct hci_h4p_platform_data *bt_config = + rx51_bt_device.dev.platform_data; + unsigned int bdaddr[6]; + int ret, i; + + ret = sscanf(buf, "%2x:%2x:%2x:%2x:%2x:%2x\n", + &bdaddr[0], &bdaddr[1], &bdaddr[2], + &bdaddr[3], &bdaddr[4], &bdaddr[5]); + + if (ret != 6) + return -EINVAL; + + for (i = 0; i < 6; i++) + bt_config->bd_addr[i] = bdaddr[i] & 0xff; + + return count; +} + +static ssize_t hci_h4p_show_bdaddr(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct hci_h4p_platform_data *bt_config = + rx51_bt_device.dev.platform_data; + + return sprintf(buf, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", + bt_config->bd_addr[0], + bt_config->bd_addr[1], + bt_config->bd_addr[2], + bt_config->bd_addr[3], + bt_config->bd_addr[4], + bt_config->bd_addr[5]); +} + +static DEVICE_ATTR(bdaddr, S_IRUGO | S_IWUSR, hci_h4p_show_bdaddr, + hci_h4p_store_bdaddr); +int hci_h4p_sysfs_create_files(struct device *dev) +{ + return device_create_file(dev, &dev_attr_bdaddr); +} + void __init rx51_bt_init(void) { int err; @@ -1236,8 +1280,12 @@ void __init rx51_bt_init(void) bt_plat_data.uart_base = ioremap(OMAP3_UART2_BASE, SZ_2K); err = platform_device_register(&rx51_bt_device); - if (!err) - return; + if (!err) { + err = hci_h4p_sysfs_create_files(&rx51_bt_device.dev); + if(!err) + return; + platform_device_unregister(&rx51_bt_device); + } gpio_free(RX51_HCI_H4P_HOSTWU_GPIO); fail2: diff --git a/drivers/bluetooth/hci_h4p/fw-bcm.c b/drivers/bluetooth/hci_h4p/fw-bcm.c index a0c8558..3b77a93 100644 --- a/drivers/bluetooth/hci_h4p/fw-bcm.c +++ b/drivers/bluetooth/hci_h4p/fw-bcm.c @@ -24,6 +24,7 @@ #include <linux/skbuff.h> #include <linux/delay.h> #include <linux/serial_reg.h> +#include <linux/bluetooth/hci_h4p.h> #include "hci_h4p.h" @@ -32,6 +33,13 @@ static struct sk_buff_head *fw_q; static int inject_bdaddr(struct hci_h4p_info *info, struct sk_buff *skb) { unsigned int offset; + int i; + struct hci_h4p_platform_data *config; + + config = info->dev->platform_data; + + if (!config) + return -ENODEV; if (skb->len < 10) { dev_info(info->dev, "Valid bluetooth address not found.\n"); @@ -39,12 +47,22 @@ static int inject_bdaddr(struct hci_h4p_info *info, struct sk_buff *skb) } offset = 4; - skb->data[offset + 5] = 0x00; - skb->data[offset + 4] = 0x11; - skb->data[offset + 3] = 0x22; - skb->data[offset + 2] = 0x33; - skb->data[offset + 1] = 0x44; - skb->data[offset + 0] = 0x55; + skb->data[offset + 5] = config->bd_addr[0]; + skb->data[offset + 4] = config->bd_addr[1]; + skb->data[offset + 3] = config->bd_addr[2]; + skb->data[offset + 2] = config->bd_addr[3]; + skb->data[offset + 1] = config->bd_addr[4]; + skb->data[offset + 0] = config->bd_addr[5]; + + for (i = 0; i < 6; i++) { + if (config->bd_addr[i] != 0x00) + break; + } + + if (i > 5) { + dev_info(info->dev, "Valid bluetooth address not found.\n"); + return -ENODEV; + } return 0; } diff --git a/drivers/bluetooth/hci_h4p/hci_h4p.h b/drivers/bluetooth/hci_h4p/hci_h4p.h index 7ea10b8..370740e 100644 --- a/drivers/bluetooth/hci_h4p/hci_h4p.h +++ b/drivers/bluetooth/hci_h4p/hci_h4p.h @@ -193,6 +193,11 @@ struct hci_fw_event { u8 status; } __attribute__ ((packed)); +struct hci_bc4_set_bdaddr { + u8 type; + struct hci_command_hdr cmd_hdr; +} __attribute__ ((packed)); + int hci_h4p_send_alive_packet(struct hci_h4p_info *info); void hci_h4p_bcm_parse_fw_event(struct hci_h4p_info *info, @@ -214,6 +219,9 @@ int hci_h4p_read_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue); int hci_h4p_send_fw(struct hci_h4p_info *info, struct sk_buff_head *fw_queue); void hci_h4p_parse_fw_event(struct hci_h4p_info *info, struct sk_buff *skb); +int hci_h4p_sysfs_create_files(struct device *dev); +void hci_h4p_sysfs_remove_files(struct device *dev); + void hci_h4p_outb(struct hci_h4p_info *info, unsigned int offset, u8 val); u8 hci_h4p_inb(struct hci_h4p_info *info, unsigned int offset); void hci_h4p_set_rts(struct hci_h4p_info *info, int active); diff --git a/include/linux/bluetooth/hci_h4p.h b/include/linux/bluetooth/hci_h4p.h index ba1d764..d69673a 100644 --- a/include/linux/bluetooth/hci_h4p.h +++ b/include/linux/bluetooth/hci_h4p.h @@ -38,4 +38,5 @@ struct hci_h4p_platform_data { void (*bt_wu)(bool); void (*reset)(bool); unsigned int host_wu_gpio; + u8 bd_addr[6]; }; -- 1.7.0.4