Return-Path: From: "G, Jaya P" To: "'linux-bluetooth@vger.kernel.org'" , "Marcel@holtmann.org" CC: "An, Tedd" Subject: Please review and upstream to bluetooth-next Date: Fri, 15 Jul 2016 06:33:50 +0000 Message-ID: References: Content-Type: multipart/alternative; boundary="_000_DAC39EC0A5DE12469D14E5A0B14E6CF505473770BGSMSX108garcor_" MIME-Version: 1.0 List-ID: --_000_DAC39EC0A5DE12469D14E5A0B14E6CF505473770BGSMSX108garcor_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, Patch is for creating a kobject file from btusb which creates a file under = kobject Which exposes HW Variant, FW Variant and Patch number for Intel specific SK= U's Which is required to differentiate different chips from intel manufacturer. Please review and upstream the Patch to bluetooth-next. >From 01e904148f4de6d8d48d61b01b08da7a771fe998 Mon Sep 17 00:00:00 2001 From: Jaya Praveen G Date: Fri, 15 Jul 2016 17:25:31 +0530 Subject: [PATCH] btusb: Export the Intel HW/FW/Patch variants to /sysfs Intel will have different SKU and version with the same VID/PID. Different SKU use different BT version this means different HW and FW. To check this, we have read version for the intel SKU which is unique, the same data is put in a file create with kobject in /sys/kernel/intel_hw_version_kobject/ with the name /intel_hw_version where it shows the HW variant, FW variant and Patch number which will different for each SKU. Signed-off-by: Jaya Praveen G --- drivers/bluetooth/btusb.c | 57 ++++++++++++++++++++++++++++++++++++++++++++= +-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 811f9b9..720f14f 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -24,6 +24,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -42,6 +46,30 @@ static bool reset =3D true; static struct usb_driver btusb_driver; +static struct kobject *intel_hw_version_kobject; +struct intel_version ver; + +/* + * This file which is under /sys/kernel/intel_hw_version_kobject kobject w= hich has the file name as intel_hw_version + * contains the intel FW version in terms of HW variant, FW variant and Pa= tch number which are different for + * different SKU's. + */ +static ssize_t intel_hw_showrev(struct kobject *k, struct attribute *a, ch= ar *buf) +{ + return sprintf(buf, "HW_Variant: 0x%02x%02x%02x\nFW_variant: 0x%02= x%02x%02x%02x%02x\nPatch Num: 0x%02x\n",ver.hw_platform, ver.hw_variant, ve= r.hw_revision, + ver.fw_variant, ver.fw_revision, ver.fw_build= _num, + ver.fw_build_ww, ver.fw_build_yy, ver.fw_patch= _num); +} + +/* Sysfs attributes made as user readable and writable*/ +static const struct { + struct attribute attr; + ssize_t (*show)(struct kobject *k, struct attribute *a, char = *buf); +} intel_hw_version_attr =3D { + .attr =3D { .name =3D "intel_hw_version", .mode =3D S_IWUSR |= S_IRUSR}, + .show =3D intel_hw_showrev, +}; + #define BTUSB_IGNORE 0x01 #define BTUSB_DIGIANSWER 0x02 #define BTUSB_CSR 0x04 @@ -1655,7 +1683,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) const struct firmware *fw; const u8 *fw_ptr; int disable_patch, err; - struct intel_version ver; + int error =3D 0; BT_DBG("%s", hdev->name); @@ -1690,6 +1718,19 @@ static int btusb_setup_intel(struct hci_dev *hdev) ver.fw_variant, ver.fw_revision, ver.fw_build= _num, ver.fw_build_ww, ver.fw_build_yy, ver.fw_patch= _num); + /* Create a kobject with the name "intel_hw_version_kobject", loca= ted + * under /sys/kernel/. + */ + intel_hw_version_kobject =3D kobject_create_and_add("intel_hw_vers= ion_kobject", kernel_kobj); + if(!intel_hw_version_kobject) + return -ENOMEM; + + /* Create a file associated with the kobject */ + error =3D sysfs_create_file(intel_hw_version_kobject, &intel_hw_ve= rsion_attr.attr); + if(error) { + BT_DBG("failed to create the version file in /sys/kernel/int= el_hw_version_kobject \n"); + } + /* fw_patch_num indicates the version of patch the device cur= rently * have. If there is no patch data in the device, it is alway= s 0x00. * So, if it is other than 0x00, no need to patch the device = again. @@ -1974,7 +2015,6 @@ static int btusb_setup_intel_new(struct hci_dev *hdev= ) = 0x00, 0x08, 0x04, 0x00 }; struct btusb_data *data =3D hci_get_drvdata(hdev); struct sk_buff *skb; - struct intel_version ver; struct intel_boot_params *params; const struct firmware *fw; const u8 *fw_ptr; @@ -1983,6 +2023,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev= ) ktime_t calltime, delta, rettime; unsigned long long duration; int err; + int error =3D 0; BT_DBG("%s", hdev->name); @@ -1996,6 +2037,18 @@ static int btusb_setup_intel_new(struct hci_dev *hde= v) if (err) return err; + /* Create a kobject with the name "intel_hw_version_kobject", loca= ted + * under /sys/kernel/. + */ + intel_hw_version_kobject =3D kobject_create_and_add("intel_hw_vers= ion_kobject", kernel_kobj); + if(!intel_hw_version_kobject) + return -ENOMEM; + + /* Create a file associated with the kobject */ + error =3D sysfs_create_file(intel_hw_version_kobject, &intel_hw_ve= rsion_attr.attr); + if(error) { + BT_DBG("failed to create the version file in /sys/kernel/int= el_hw_version_kobject \n"); + } /* The hardware platform number has a fixed value of 0x37 and * for now only accept this single value. */ -- 1.9.1 Regards, Jaya Praveen G --_000_DAC39EC0A5DE12469D14E5A0B14E6CF505473770BGSMSX108garcor_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi,<= /p>

 

Patch is for creating = a kobject file from btusb which creates a file under kobject

Which exposes HW Varia= nt, FW Variant and Patch number for Intel specific SKU’s

Which is required to d= ifferentiate different chips from intel manufacturer.

 

Please review and upst= ream the Patch to bluetooth-next.

 

From 01e904148f4de6d8d= 48d61b01b08da7a771fe998 Mon Sep 17 00:00:00 2001

From: Jaya Praveen G &= lt;jaya.p.g@intel.com>

Date: Fri, 15 Jul 2016= 17:25:31 +0530

Subject: [PATCH] btusb= : Export the Intel HW/FW/Patch variants to /sysfs

 

Intel will have differ= ent SKU and version with the same

VID/PID. Different SKU= use different BT version this means

different HW and FW. T= o check this, we have read version

for the intel SKU whic= h is unique, the same data is put in

a file create with kob= ject in /sys/kernel/intel_hw_version_kobject/

with the name /intel_h= w_version where it shows the HW variant,

FW variant and Patch n= umber which will different for each SKU.

 

Signed-off-by: Jaya Pr= aveen G <jaya.p.g@intel.com>

---<= /p>

drivers/bluetooth/btus= b.c | 57 +++++++++++++&= #43;++++++++++++++&= #43;++++++++++++++&= #43;+--

1 file changed, 55 ins= ertions(+), 2 deletions(-)

 

diff --git a/drivers/b= luetooth/btusb.c b/drivers/bluetooth/btusb.c

index 811f9b9..720f14f= 100644

--- a/drivers/bluetoot= h/btusb.c

+++ b/driv= ers/bluetooth/btusb.c

@@ -24,6 +24,10 @@=

#include <linux/mod= ule.h>

#include <linux/usb= .h>

#include <linux/fir= mware.h>

+#include <linu= x/kobject.h>

+#include <linu= x/sysfs.h>

+#include <linu= x/fs.h>

+#include <linu= x/string.h>

#include <asm/unali= gned.h>

 #include <net= /bluetooth/bluetooth.h>

@@ -42,6 +46,30 @@= static bool reset =3D true;

 static struct us= b_driver btusb_driver;

+static struct kob= ject *intel_hw_version_kobject;

+struct intel_vers= ion ver;

+

+/*

+ * This file whic= h is under /sys/kernel/intel_hw_version_kobject kobject which has the file = name as intel_hw_version

+ * contains the i= ntel FW version in terms of HW variant, FW variant and Patch number which a= re different for

+ * different SKU'= s.

+ */

+static ssize_t in= tel_hw_showrev(struct kobject *k, struct attribute *a, char *buf)

+{

+   = ;     return sprintf(buf, "HW_Variant: 0x%02x%02x%= 02x\nFW_variant: 0x%02x%02x%02x%02x%02x\nPatch Num: 0x%02x\n",ver.hw_p= latform, ver.hw_variant, ver.hw_revision,

+   = ;            &n= bsp;            ver.= fw_variant,  ver.fw_revision, ver.fw_build_num,

+   = ;            &n= bsp;            ver.= fw_build_ww, ver.fw_build_yy, ver.fw_patch_num);

+}

+

+/* Sysfs attribut= es made as user readable and writable*/

+static const stru= ct {

+   = ;          struct attribute at= tr;

+   = ;          ssize_t (*show)(str= uct kobject *k, struct attribute *a, char *buf);

+} intel_hw_versio= n_attr =3D {

+   = ;          .attr =3D { .name = =3D "intel_hw_version", .mode =3D S_IWUSR | S_IRUSR},<= /span>

+   = ;          .show =3D intel_hw_= showrev,

+};

+

#define BTUSB_IGNORE&n= bsp;            = ;            &n= bsp;    0x01

#define BTUSB_DIGIANSW= ER      0x02

#define BTUSB_CSR = ;            &n= bsp;         0x04=

@@ -1655,7 +1683,7= @@ static int btusb_setup_intel(struct hci_dev *hdev)

   &nbs= p;          const struct firmw= are *fw;

   &nbs= p;          const u8 *fw_ptr;<= o:p>

   &nbs= p;          int disable_patch,= err;

-   &nb= sp;          struct intel_vers= ion ver;

+   = ;     int error =3D 0;

   &nbs= p;           BT_DBG("= ;%s", hdev->name);

@@ -1690,6 +1718,1= 9 @@ static int btusb_setup_intel(struct hci_dev *hdev)

   &nbs= p;            &= nbsp;            ver= .fw_variant,  ver.fw_revision, ver.fw_build_num,

   &nbs= p;            &= nbsp;            ver= .fw_build_ww, ver.fw_build_yy, ver.fw_patch_num);

+   = ;     /* Create a kobject with the name "intel_hw_= version_kobject", located

+   = ;      * under /sys/kernel/.

+   = ;      */

+   = ;     intel_hw_version_kobject =3D kobject_create_and_a= dd("intel_hw_version_kobject", kernel_kobj);

+   = ;     if(!intel_hw_version_kobject)

+   = ;            &n= bsp;  return -ENOMEM;

+

+   = ;     /* Create a file associated with the kobject */

+   = ;     error =3D sysfs_create_file(intel_hw_version_kobj= ect, &intel_hw_version_attr.attr);

+   = ;     if(error) {

+   = ;           BT_DBG("= failed to create the version file in /sys/kernel/intel_hw_version_kobject \= n");

+   = ;     }

+

   &nbs= p;          /* fw_patch_num in= dicates the version of patch the device currently

   &nbs= p;           * have. If t= here is no patch data in the device, it is always 0x00.

   &nbs= p;           * So, if it = is other than 0x00, no need to patch the device again.

@@ -1974,7 +2015,6= @@ static int btusb_setup_intel_new(struct hci_dev *hdev)

   &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;         0x00, 0x08, 0x04, 0x0= 0 };

   &nbs= p;          struct btusb_data = *data =3D hci_get_drvdata(hdev);

   &nbs= p;          struct sk_buff *sk= b;

-   &nb= sp;          struct intel_vers= ion ver;

   &nbs= p;          struct intel_boot_= params *params;

   &nbs= p;          const struct firmw= are *fw;

   &nbs= p;          const u8 *fw_ptr;<= o:p>

@@ -1983,6 +2023,7= @@ static int btusb_setup_intel_new(struct hci_dev *hdev)

   &nbs= p;          ktime_t calltime, = delta, rettime;

   &nbs= p;          unsigned long long= duration;

   &nbs= p;          int err;

+   = ;     int error =3D 0;

   &nbs= p;           BT_DBG("= ;%s", hdev->name);

@@ -1996,6 +2037,1= 8 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)

   &nbs= p;          if (err)

   &nbs= p;            &= nbsp;            ret= urn err;

+   = ;     /* Create a kobject with the name "intel_hw_= version_kobject", located

+   = ;      * under /sys/kernel/.

+   = ;      */

+   = ;     intel_hw_version_kobject =3D kobject_create_and_a= dd("intel_hw_version_kobject", kernel_kobj);

+   = ;     if(!intel_hw_version_kobject)

+   = ;            &n= bsp;  return -ENOMEM;

+

+   = ;     /* Create a file associated with the kobject */

+   = ;     error =3D sysfs_create_file(intel_hw_version_kobj= ect, &intel_hw_version_attr.attr);

+   = ;     if(error) {

+   = ;           BT_DBG("= failed to create the version file in /sys/kernel/intel_hw_version_kobject \= n");

+   = ;     }

   &nbs= p;          /* The hardware pl= atform number has a fixed value of 0x37 and

   &nbs= p;           * for now on= ly accept this single value.

   &nbs= p;           */

-- <= /p>

1.9.1

 

Regards,

Jaya Praveen G

--_000_DAC39EC0A5DE12469D14E5A0B14E6CF505473770BGSMSX108garcor_--