summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1ecbb07)
raw | patch | inline | side by side (parent: 1ecbb07)
author | Eyal Reizer <eyalr@ti.com> | |
Wed, 11 Mar 2015 09:52:28 +0000 (11:52 +0200) | ||
committer | Eyal Reizer <eyalr@ti.com> | |
Wed, 11 Mar 2015 09:52:28 +0000 (11:52 +0200) |
* Add a mechanism allowing to store kernel and driver patches for
known kernels and apply them during the script activation
* Add a patch set adding wilink8 support for the imx6q-sabresd
platform when using the imx-3.10.53 kernel from the 1.1.0_ga release
* Add installation of bluetooth init scripts to the file system
* Add building of the user space agent (uim) for the ti shared transport
layer in the kernel
Signed-off-by: Eyal Reizer <eyalr@ti.com>
known kernels and apply them during the script activation
* Add a patch set adding wilink8 support for the imx6q-sabresd
platform when using the imx-3.10.53 kernel from the 1.1.0_ga release
* Add installation of bluetooth init scripts to the file system
* Add building of the user space agent (uim) for the ti shared transport
layer in the kernel
Signed-off-by: Eyal Reizer <eyalr@ti.com>
12 files changed:
diff --git a/build_wl18xx.sh b/build_wl18xx.sh
index 200636807b4a1456380cdaec100648764854ba52..b02d13b07e1dbb7693957aae8b04e65c0fa3d98a 100755 (executable)
--- a/build_wl18xx.sh
+++ b/build_wl18xx.sh
echo " openssl [ Clean & Build openssll ] "
echo " libnl [ Clean & Build libnl ] "
echo " crda [ Clean & Build crda ] "
-
+ echo " patch_kernel [ Apply provided kernel patches ] "
+ echo " uim [ Clean & Build uim ] "
+ echo " bt-firmware [ Install Bluetooth init scripts ] "
exit 1
}
{
mkdir -p `path filesystem`/usr/bin
mkdir -p `path filesystem`/etc
+ mkdir -p `path filesystem`/etc/init.d
+ mkdir -p `path filesystem`/etc/rcS.d
mkdir -p `path filesystem`/usr/lib/crda
mkdir -p `path filesystem`/lib/firmware/ti-connectivity
mkdir -p `path filesystem`/usr/share/wl18xx
{
generate_compat
cd_repo compat_wireless
+ if [ -d "$PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT" ]; then
+ for i in $PATH__ROOT/patches/driver_patches/$KERNEL_VARIANT/*.patch; do
+ print_highlight "Applying driver patch: $i"
+ patch -p1 < $i;
+ assert_no_error
+ done
+ fi
if [ -z $NO_CLEAN ]; then
make clean
fi
cp `repo_path fw_download`/*.bin `path filesystem`/lib/firmware/ti-connectivity
}
+function patch_kernel()
+{
+ [ ! -d $KERNEL_PATH ] && echo "Error KERNEL_PATH: $KERNEL_PATH dir does not exist" && exit 1
+ cd $KERNEL_PATH
+ echo "using kernel: $KERNEL_PATH"
+ if [ -d "$PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT" ]; then
+ read -p "Branch name to use? (will be created if doesn't exist)" -e branchname
+ if git show-ref --verify --quiet "refs/heads/$branchname"; then
+ echo "Branch name $branchname already exists, trying to use it..."
+ git checkout $branchname
+ else
+ echo "Creating branch $branchname and switching to it"
+ git checkout -b $branchname
+ fi
+ assert_no_error
+ for i in $PATH__ROOT/patches/kernel_patches/$KERNEL_VARIANT/*.patch; do
+ git am $i;
+ assert_no_error
+ done
+ fi
+ assert_no_error
+ cd_back
+}
+
+function build_uim()
+{
+ cd_repo uim
+ [ -z $NO_CLEAN ] && NFSROOT=`path filesystem` make clean
+ [ -z $NO_CLEAN ] && assert_no_error
+ make CC=${CROSS_COMPILE}gcc
+ assert_no_error
+ install -m 0755 uim `path filesystem`/usr/bin
+ install -m 0755 `repo_path uim`/scripts/uim-sysfs `path filesystem`/etc/init.d/
+ cd `path filesystem`/etc/rcS.d/
+ ln -sf ../init.d/uim-sysfs S03uim-sysfs
+ assert_no_error
+ cd_back
+}
+
+function build_bt_firmware()
+{
+ cd_repo bt-firmware
+ for i in `repo_path bt-firmware`/*.bts; do
+ echo "Installing bluetooth init script: $i"
+ install -m 0755 $i `path filesystem`/lib/firmware/
+ assert_no_error
+ done
+}
function build_scripts_download()
{
cd_back
# Copy kernel files only if default kernel is used(for now)
- if [ "$DEFAULT_KERNEL" -eq 1 ]
+ if [[ "$KERNEL_PATH" == "DEFAULT" ]]
then
if [ "$KERNEL_VERSION" -eq 3 ] && [ "$KERNEL_PATCHLEVEL" -eq 2 ]
then
build_wlconf
build_fw_download
build_scripts_download
+ build_uim
+ build_bt_firmware
fi
[ -z $NO_VERIFY ] && verify_skeleton
;;
'crda')
- print_highlight " building only CRDA "
+ print_highlight " building only CRDA "
build_crda
;;
print_highlight " Copying scripts "
build_scripts_download
;;
-
+
'utils')
print_highlight " building only ti-utils "
build_calibrator
build_wlconf
- ;;
+ ;;
+
'firmware')
- print_highlight " building only firmware"
- build_fw_download
- ;;
+ print_highlight " building only firmware"
+ build_fw_download
+ ;;
+
+ 'patch_kernel')
+ print_highlight " only patching kernel $2 without performing an actual build!"
+ NO_BUILD=1
+ patch_kernel
+ ;;
+
+ 'uim')
+ print_highlight " building only uim "
+ build_uim
+ ;;
+
+ 'bt-firmware')
+ print_highlight " Only installing bluetooth init scripts "
+ build_bt_firmware
+ ;;
############################################################
'get_tag')
get_tag
diff --git a/configuration.sh b/configuration.sh
index 8b224210ccc3e90cce0bd1d262365d0bde264e7b..e583c1421a09b7c532a17e056d0331dcb94c1de3 100755 (executable)
--- a/configuration.sh
+++ b/configuration.sh
iw
git://git.kernel.org/pub/scm/linux/kernel/git/jberg/iw.git
v3.15
+
+uim
+git://git.ti.com/ti-bt/uim.git
+master
+
+bt-firmware
+git://git.ti.com/ti-bt/service-packs.git
+master
)
diff --git a/patches/driver_patches/imx-3.10.53/0001-completion-remove-reinit_completion-decleration.patch b/patches/driver_patches/imx-3.10.53/0001-completion-remove-reinit_completion-decleration.patch
--- /dev/null
@@ -0,0 +1,38 @@
+From da226aa1fd87531f596c2c351dd41fbab3dd44cb Mon Sep 17 00:00:00 2001
+From: Eyal Reizer <eyalr@ti.com>
+Date: Mon, 9 Mar 2015 10:07:44 +0200
+Subject: [PATCH] completion: remove reinit_completion decleration
+
+This api is already backported into the imx 3.10.53 kernel
+
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+---
+ backport-include/linux/completion.h | 14 --------------
+ 1 file changed, 14 deletions(-)
+
+diff --git a/backport-include/linux/completion.h b/backport-include/linux/completion.h
+index 399430d..f3734ef 100644
+--- a/backport-include/linux/completion.h
++++ b/backport-include/linux/completion.h
+@@ -3,18 +3,4 @@
+ #include_next <linux/completion.h>
+ #include <linux/version.h>
+
+-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
+-/**
+- * reinit_completion - reinitialize a completion structure
+- * @x: pointer to completion structure that is to be reinitialized
+- *
+- * This inline function should be used to reinitialize a completion structure so it can
+- * be reused. This is especially important after complete_all() is used.
+- */
+-static inline void reinit_completion(struct completion *x)
+-{
+- x->done = 0;
+-}
+-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) */
+-
+ #endif /* __BACKPORT_COMPLETION_H */
+--
+1.7.9.5
+
diff --git a/patches/kernel_patches/imx-3.10.53/0001-imx6q-sabresd-add-support-for-wilink8-wlan-and-bluet.patch b/patches/kernel_patches/imx-3.10.53/0001-imx6q-sabresd-add-support-for-wilink8-wlan-and-bluet.patch
--- /dev/null
+++ b/patches/kernel_patches/imx-3.10.53/0001-imx6q-sabresd-add-support-for-wilink8-wlan-and-bluet.patch
@@ -0,0 +1,126 @@
+From e53032e6ab7e3498e8d9f6539a96f3cda6f35aa8 Mon Sep 17 00:00:00 2001
+From: Eyal Reizer <eyalr@ti.com>
+Date: Wed, 4 Mar 2015 14:08:59 +0200
+Subject: [PATCH 1/7] imx6q-sabresd: add support for wilink8 wlan and
+ bluetooth
+
+* enable uart5 used for bluetooth with wilink8 with flow control
+* configure SD2 to be used for sdio communication to wilink8 wlan
+* configure gpios used for wlan/bt enables and wlan_irq
+* setup voltage regulator used for wl8 wlan power control
+* disable SPI1 as it pins are routed to J13 for connecting to wilink8
+
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+---
+ arch/arm/boot/dts/imx6qdl-sabresd.dtsi | 56 ++++++++++++++++++++++++++++++--
+ 1 file changed, 53 insertions(+), 3 deletions(-)
+
+diff --git a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
+index b5394f3..57b468a 100644
+--- a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
++++ b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
+@@ -22,6 +22,32 @@
+ reg = <0x10000000 0x40000000>;
+ };
+
++ wlan_en_reg: fixedregulator@2 {
++ compatible = "regulator-fixed";
++ regulator-name = "wlan-en-regulator";
++ regulator-min-microvolt = <1800000>;
++ regulator-max-microvolt = <1800000>;
++
++ /* WLAN_EN GPIO for this board – Bank4, pin7 */
++ gpio = <&gpio4 7 0>;
++
++ /* WLAN card specific delay */
++ startup-delay-us = <70000>;
++ enable-active-high;
++ };
++
++ kim {
++ compatible = "kim";
++ nshutdown_gpio = <2>; /* GPIO_2 */
++ dev_name = "/dev/ttymxc4";
++ flow_cntrl = <1>;
++ baud_rate = <3000000>;
++ };
++
++ btwilink {
++ compatible = "btwilink";
++ };
++
+ battery: max8903@0 {
+ compatible = "fsl,max8903-charger";
+ pinctrl-names = "default";
+@@ -253,6 +279,7 @@
+ pu-supply = <&pu_dummy>; /* use pu_dummy if VDDSOC share with VDDPU */
+ };
+
++/* the spi pins (inctrl_ecspi1_2) are used for connecting to WL8 using J13 so we disable it
+ &ecspi1 {
+ fsl,spi-num-chipselects = <1>;
+ cs-gpios = <&gpio4 9 0>;
+@@ -268,6 +295,7 @@
+ reg = <0>;
+ };
+ };
++*/
+
+ &fec {
+ pinctrl-names = "default";
+@@ -506,6 +534,8 @@
+ MX6QDL_PAD_GPIO_1__WDOG2_B 0x80000000
+ MX6QDL_PAD_GPIO_2__GPIO1_IO02 0x80000000
+ MX6QDL_PAD_SD1_CMD__GPIO1_IO18 0x80000000
++ MX6QDL_PAD_KEY_ROW0__GPIO4_IO07 0x13059 // reserve two pins wl8 gpio, this is pulled low at reset for WL_EN
++ MX6QDL_PAD_KEY_COL0__GPIO4_IO06 0x13059 // this is for WL_IRQ which driver will configure as an input with a pull down
+ >;
+ };
+ };
+@@ -611,6 +641,15 @@
+ status = "okay";
+ };
+
++&uart5 {
++ pinctrl-names = "default";
++ pinctrl-0 = <&pinctrl_uart5_1>;
++ status = "okay";
++
++ /* enable rts/cts usage on uart5 */
++ fsl,uart-has-rtscts;
++};
++
+ &usbh1 {
+ vbus-supply = <®_usb_h1_vbus>;
+ status = "okay";
+@@ -626,13 +665,24 @@
+
+ &usdhc2 {
+ pinctrl-names = "default";
+- pinctrl-0 = <&pinctrl_usdhc2_1>;
+- cd-gpios = <&gpio2 2 0>;
+- wp-gpios = <&gpio2 3 0>;
++ pinctrl-0 = <&pinctrl_usdhc2_2>;
+ no-1-8-v;
+ keep-power-in-suspend;
+ enable-sdio-wakeup;
++ vmmc-supply = <&wlan_en_reg>;
++ non-removable; /* non-removable is not a variable, the fact it is */
++ /* listed is all that is used by driver */
++ cap-power-off-card;
+ status = "okay";
++ #address-cells = <1>;
++ #size-cells = <0>;
++ wlcore: wlcore@0 {
++ compatible = "ti,wlcore";
++ reg = <2>;
++ interrupt-parent = <&gpio4>;
++ interrupts = <6 0>;
++ platform-quirks = <1>;
++ };
+ };
+
+ &usdhc3 {
+--
+1.7.9.5
+
diff --git a/patches/kernel_patches/imx-3.10.53/0002-Bluetooth-Add-tty-HCI-driver.patch b/patches/kernel_patches/imx-3.10.53/0002-Bluetooth-Add-tty-HCI-driver.patch
--- /dev/null
@@ -0,0 +1,603 @@
+From c55f8870f94fef8a588358e4e2ff6eb368eb21bd Mon Sep 17 00:00:00 2001
+From: Pavan Savoy <pavan_savoy@ti.com>
+Date: Mon, 15 Oct 2012 17:47:35 -0500
+Subject: [PATCH 2/7] Bluetooth: Add tty HCI driver
+
+tty_hci driver exposes a /dev/hci_tty character device node, that intends to
+emulate a generic /dev/ttyX device that would be used by the user-space
+Bluetooth stacks to send/receive data to/from the WL combo-connectivity
+chipsets.
+
+The device driver has no internal logic of its own to intrepret data & all
+such logic is handled by the user-space stack.
+
+Change-Id: Ifa3860bbc7e252af210fde710bce14143239b552
+Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
+ [Fixed checkpatch warnings]
+Signed-off-by: Vishal Mahaveer <vishalm@ti.com>
+ [Fixed checkpatch --strict warnings]
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+---
+ drivers/misc/ti-st/Kconfig | 8 +
+ drivers/misc/ti-st/Makefile | 1 +
+ drivers/misc/ti-st/tty_hci.c | 542 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 551 insertions(+)
+ create mode 100644 drivers/misc/ti-st/tty_hci.c
+
+diff --git a/drivers/misc/ti-st/Kconfig b/drivers/misc/ti-st/Kconfig
+index f34dcc5..f2df2c7 100644
+--- a/drivers/misc/ti-st/Kconfig
++++ b/drivers/misc/ti-st/Kconfig
+@@ -14,4 +14,12 @@ config TI_ST
+ are returned to relevant protocol drivers based on their
+ packet types.
+
++config ST_HCI
++ tristate "HCI TTY emulation driver for Bluetooth"
++ depends on TI_ST
++ help
++ This enables the TTY device like emulation for HCI used by
++ user-space Bluetooth stacks.
++ It will provide a character device for user space Bluetooth stack to
++ send/receive data over shared transport.
+ endmenu
+diff --git a/drivers/misc/ti-st/Makefile b/drivers/misc/ti-st/Makefile
+index 78d7ebb..4546219 100644
+--- a/drivers/misc/ti-st/Makefile
++++ b/drivers/misc/ti-st/Makefile
+@@ -4,3 +4,4 @@
+ #
+ obj-$(CONFIG_TI_ST) += st_drv.o
+ st_drv-objs := st_core.o st_kim.o st_ll.o
++obj-$(CONFIG_ST_HCI) += tty_hci.o
+diff --git a/drivers/misc/ti-st/tty_hci.c b/drivers/misc/ti-st/tty_hci.c
+new file mode 100644
+index 0000000..5b27b04
+--- /dev/null
++++ b/drivers/misc/ti-st/tty_hci.c
+@@ -0,0 +1,542 @@
++/*
++ * TTY emulation for user-space Bluetooth stacks over HCI-H4
++ * Copyright (C) 2011-2012 Texas Instruments
++ * Author: Pavan Savoy <pavan_savoy@ti.com>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ */
++
++/** define one of the following for debugging
++#define DEBUG
++#define VERBOSE
++*/
++
++#define pr_fmt(fmt) "(hci_tty): " fmt
++#include <linux/module.h>
++#include <linux/cdev.h>
++#include <linux/fs.h>
++#include <linux/device.h>
++
++#include <linux/uaccess.h>
++#include <linux/tty.h>
++#include <linux/sched.h>
++
++#include <linux/delay.h>
++#include <linux/firmware.h>
++#include <linux/platform_device.h>
++#include <linux/poll.h>
++#include <linux/skbuff.h>
++#include <linux/interrupt.h>
++
++#include <linux/ti_wilink_st.h>
++
++/* Number of seconds to wait for registration completion
++ * when ST returns PENDING status.
++ */
++#define BT_REGISTER_TIMEOUT 6000 /* 6 sec */
++
++/**
++ * struct ti_st - driver operation structure
++ * @hdev: hci device pointer which binds to bt driver
++ * @reg_status: ST registration callback status
++ * @st_write: write function provided by the ST driver
++ * to be used by the driver during send_frame.
++ * @wait_reg_completion - completion sync between ti_st_open
++ * and st_reg_completion_cb.
++ */
++struct ti_st {
++ struct hci_dev *hdev;
++ char reg_status;
++ long (*st_write)(struct sk_buff *);
++ struct completion wait_reg_completion;
++ wait_queue_head_t data_q;
++ struct sk_buff_head rx_list;
++};
++
++#define DEVICE_NAME "hci_tty"
++
++/***********Functions called from ST driver**********************************/
++/* Called by Shared Transport layer when receive data is
++ * available */
++static long st_receive(void *priv_data, struct sk_buff *skb)
++{
++ struct ti_st *hst = (void *)priv_data;
++
++ pr_debug("@ %s", __func__);
++#ifdef VERBOSE
++ print_hex_dump(KERN_INFO, ">rx>", DUMP_PREFIX_NONE,
++ 16, 1, skb->data, skb->len, 0);
++#endif
++ skb_queue_tail(&hst->rx_list, skb);
++ wake_up_interruptible(&hst->data_q);
++ return 0;
++}
++
++/* Called by ST layer to indicate protocol registration completion
++ * status.ti_st_open() function will wait for signal from this
++ * API when st_register() function returns ST_PENDING.
++ */
++static void st_reg_completion_cb(void *priv_data, char data)
++{
++ struct ti_st *lhst = (void *)priv_data;
++
++ pr_info("@ %s\n", __func__);
++ /* Save registration status for use in ti_st_open() */
++ lhst->reg_status = data;
++ /* complete the wait in ti_st_open() */
++ complete(&lhst->wait_reg_completion);
++}
++
++/* protocol structure registered with shared transport */
++#define MAX_BT_CHNL_IDS 3
++static struct st_proto_s ti_st_proto[MAX_BT_CHNL_IDS] = {
++ {
++ .chnl_id = 0x04, /* HCI Events */
++ .hdr_len = 2,
++ .offset_len_in_hdr = 1,
++ .len_size = 1, /* sizeof(plen) in struct hci_event_hdr */
++ .reserve = 8,
++ },
++ {
++ .chnl_id = 0x02, /* ACL */
++ .hdr_len = 4,
++ .offset_len_in_hdr = 2,
++ .len_size = 2, /* sizeof(dlen) in struct hci_acl_hdr */
++ .reserve = 8,
++ },
++ {
++ .chnl_id = 0x03, /* SCO */
++ .hdr_len = 3,
++ .offset_len_in_hdr = 2,
++ .len_size = 1, /* sizeof(dlen) in struct hci_sco_hdr */
++ .reserve = 8,
++ },
++};
++/** hci_tty_open Function
++ * This function will perform an register on ST driver.
++ *
++ * Parameters :
++ * @file : File pointer for BT char driver
++ * @inod :
++ * Returns 0 - on success
++ * else suitable error code
++ */
++int hci_tty_open(struct inode *inod, struct file *file)
++{
++ int i = 0, err = 0;
++ unsigned long timeleft;
++ struct ti_st *hst;
++
++ pr_info("inside %s (%p, %p)\n", __func__, inod, file);
++
++ hst = kzalloc(sizeof(*hst), GFP_KERNEL);
++ file->private_data = hst;
++ hst = file->private_data;
++
++ for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
++ ti_st_proto[i].priv_data = hst;
++ ti_st_proto[i].max_frame_size = 1026;
++ ti_st_proto[i].recv = st_receive;
++ ti_st_proto[i].reg_complete_cb = st_reg_completion_cb;
++
++ /* Prepare wait-for-completion handler */
++ init_completion(&hst->wait_reg_completion);
++ /* Reset ST registration callback status flag,
++ * this value will be updated in
++ * st_reg_completion_cb()
++ * function whenever it called from ST driver.
++ */
++ hst->reg_status = -EINPROGRESS;
++
++ err = st_register(&ti_st_proto[i]);
++ if (!err)
++ goto done;
++
++ if (err != -EINPROGRESS) {
++ pr_err("st_register failed %d", err);
++ goto error;
++ }
++
++ /* ST is busy with either protocol
++ * registration or firmware download.
++ */
++ pr_debug("waiting for registration completion signal from ST");
++ timeleft = wait_for_completion_timeout
++ (&hst->wait_reg_completion,
++ msecs_to_jiffies(BT_REGISTER_TIMEOUT));
++ if (!timeleft) {
++ pr_err("Timeout(%d sec),didn't get reg completion signal from ST",
++ BT_REGISTER_TIMEOUT / 1000);
++ err = -ETIMEDOUT;
++ goto error;
++ }
++
++ /* Is ST registration callback
++ * called with ERROR status? */
++ if (hst->reg_status != 0) {
++ pr_err("ST registration completed with invalid status %d",
++ hst->reg_status);
++ err = -EAGAIN;
++ goto error;
++ }
++
++done:
++ hst->st_write = ti_st_proto[i].write;
++ if (!hst->st_write) {
++ pr_err("undefined ST write function");
++ for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
++ /* Undo registration with ST */
++ err = st_unregister(&ti_st_proto[i]);
++ if (err)
++ pr_err("st_unregister() failed with error %d",
++ err);
++ hst->st_write = NULL;
++ }
++ return -EIO;
++ }
++ }
++
++ skb_queue_head_init(&hst->rx_list);
++ init_waitqueue_head(&hst->data_q);
++
++ return 0;
++
++error:
++ kfree(hst);
++ return err;
++}
++
++/** hci_tty_release Function
++ * This function will un-registers from the ST driver.
++ *
++ * Parameters :
++ * @file : File pointer for BT char driver
++ * @inod :
++ * Returns 0 - on success
++ * else suitable error code
++ */
++int hci_tty_release(struct inode *inod, struct file *file)
++{
++ int err, i;
++ struct ti_st *hst = file->private_data;
++
++ pr_info("inside %s (%p, %p)\n", __func__, inod, file);
++
++ for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
++ err = st_unregister(&ti_st_proto[i]);
++ if (err)
++ pr_err("st_unregister(%d) failed with error %d",
++ ti_st_proto[i].chnl_id, err);
++ }
++
++ hst->st_write = NULL;
++ skb_queue_purge(&hst->rx_list);
++ kfree(hst);
++ return err;
++}
++
++/** hci_tty_read Function
++ *
++ * Parameters :
++ * @file : File pointer for BT char driver
++ * @data : Data which needs to be passed to APP
++ * @size : Length of the data passesd
++ * offset :
++ * Returns Size of packet received - on success
++ * else suitable error code
++ */
++ssize_t hci_tty_read(struct file *file, char __user *data, size_t size,
++ loff_t *offset)
++{
++ int len = 0, tout;
++ struct sk_buff *skb = NULL, *rskb = NULL;
++ struct ti_st *hst;
++
++ pr_debug("inside %s (%p, %p, %u, %p)\n",
++ __func__, file, data, size, offset);
++
++ /* Validate input parameters */
++ if ((NULL == file) || (((NULL == data) || (0 == size)))) {
++ pr_err("Invalid input params passed to %s", __func__);
++ return -EINVAL;
++ }
++
++ hst = file->private_data;
++
++ /* cannot come here if poll-ed before reading
++ * if not poll-ed wait on the same wait_q
++ */
++ tout = wait_event_interruptible_timeout(hst->data_q,
++ !skb_queue_empty(&hst->rx_list),
++ msecs_to_jiffies(1000));
++ /* Check for timed out condition */
++ if (0 == tout) {
++ pr_err("Device Read timed out\n");
++ return -ETIMEDOUT;
++ }
++
++ /* hst->rx_list not empty skb already present */
++ skb = skb_dequeue(&hst->rx_list);
++ if (!skb) {
++ pr_err("dequed skb is null?\n");
++ return -EIO;
++ }
++
++#ifdef VERBOSE
++ print_hex_dump(KERN_INFO, ">in>", DUMP_PREFIX_NONE,
++ 16, 1, skb->data, skb->len, 0);
++#endif
++
++ /* Forward the data to the user */
++ if (skb->len >= size) {
++ pr_err("FIONREAD not done before read\n");
++ return -ENOMEM;
++ } else {
++ /* returning skb */
++ rskb = alloc_skb(size, GFP_KERNEL);
++ if (!rskb) {
++ pr_err("alloc_skb error\n");
++ return -ENOMEM;
++ }
++
++ /* cb[0] has the pkt_type 0x04 or 0x02 or 0x03 */
++ memcpy(skb_put(rskb, 1), &skb->cb[0], 1);
++ memcpy(skb_put(rskb, skb->len), skb->data, skb->len);
++
++ if (copy_to_user(data, rskb->data, rskb->len)) {
++ pr_err("unable to copy to user space\n");
++ /* Queue the skb back to head */
++ skb_queue_head(&hst->rx_list, skb);
++ kfree_skb(rskb);
++ return -EIO;
++ }
++ }
++
++ len = rskb->len; /* len of returning skb */
++ kfree_skb(skb);
++ kfree_skb(rskb);
++ pr_debug("total size read= %d\n", len);
++ return len;
++}
++
++/* hci_tty_write Function
++ *
++ * Parameters :
++ * @file : File pointer for BT char driver
++ * @data : packet data from BT application
++ * @size : Size of the packet data
++ * @offset :
++ * Returns Size of packet on success
++ * else suitable error code
++ */
++ssize_t hci_tty_write(struct file *file, const char __user *data,
++ size_t size, loff_t *offset)
++{
++ struct ti_st *hst = file->private_data;
++ struct sk_buff *skb;
++
++ pr_debug("inside %s (%p, %p, %u, %p)\n",
++ __func__, file, data, size, offset);
++
++ if (!hst->st_write) {
++ pr_err(" Can't write to ST, hhci_tty->st_write null ?");
++ return -EINVAL;
++ }
++
++ skb = alloc_skb(size, GFP_KERNEL);
++ /* Validate Created SKB */
++ if (NULL == skb) {
++ pr_err("Error aaloacting SKB");
++ return -ENOMEM;
++ }
++
++ /* Forward the data from the user space to ST core */
++ if (copy_from_user(skb_put(skb, size), data, size)) {
++ pr_err(" Unable to copy from user space");
++ kfree_skb(skb);
++ return -EIO;
++ }
++
++#ifdef VERBOSE
++ pr_debug("start data..");
++ print_hex_dump(KERN_INFO, "<out<", DUMP_PREFIX_NONE,
++ 16, 1, skb->data, size, 0);
++ pr_debug("\n..end data");
++#endif
++
++ hst->st_write(skb);
++ return size;
++}
++
++/** hci_tty_ioctl Function
++ * This will peform the functions as directed by the command and command
++ * argument.
++ *
++ * Parameters :
++ * @file : File pointer for BT char driver
++ * @cmd : IOCTL Command
++ * @arg : Command argument for IOCTL command
++ * Returns 0 on success
++ * else suitable error code
++ */
++static long hci_tty_ioctl(struct file *file,
++ unsigned int cmd, unsigned long arg)
++{
++ struct sk_buff *skb = NULL;
++ int retcode = 0;
++ struct ti_st *hst;
++
++ pr_debug("inside %s (%p, %u, %lx)", __func__, file, cmd, arg);
++
++ /* Validate input parameters */
++ if ((NULL == file) || (0 == cmd)) {
++ pr_err("invalid input parameters passed to %s", __func__);
++ return -EINVAL;
++ }
++
++ hst = file->private_data;
++
++ switch (cmd) {
++ case FIONREAD:
++ /* Deque the SKB from the head if rx_list is not empty
++ * update the argument with skb->len to provide amount of data
++ * available in the available SKB +1 for the PKT_TYPE
++ * field not provided in data by TI-ST.
++ */
++ skb = skb_dequeue(&hst->rx_list);
++ if (skb != NULL) {
++ *(unsigned int *)arg = skb->len + 1;
++ /* Re-Store the SKB for furtur Read operations */
++ skb_queue_head(&hst->rx_list, skb);
++ } else {
++ *(unsigned int *)arg = 0;
++ }
++ pr_debug("returning %d\n", *(unsigned int *)arg);
++ break;
++ default:
++ pr_debug("Un-Identified IOCTL %d", cmd);
++ retcode = 0;
++ break;
++ }
++
++ return retcode;
++}
++
++/** hci_tty_poll Function
++ * This function will wait till some data is received to the hci_tty driver from ST
++ *
++ * Parameters :
++ * @file : File pointer for BT char driver
++ * @wait : POLL wait information
++ * Returns status of POLL on success
++ * else suitable error code
++ */
++static unsigned int hci_tty_poll(struct file *file, poll_table *wait)
++{
++ struct ti_st *hst = file->private_data;
++ unsigned long mask = 0;
++
++ pr_debug("@ %s\n", __func__);
++
++ /* wait to be completed by st_receive */
++ poll_wait(file, &hst->data_q, wait);
++ pr_debug("poll broke\n");
++
++ if (!skb_queue_empty(&hst->rx_list)) {
++ pr_debug("rx list que !empty\n");
++ mask |= POLLIN; /* TODO: check app for mask */
++ }
++
++ return mask;
++}
++
++/* BT Char driver function pointers
++ * These functions are called from USER space by pefroming File Operations
++ * on /dev/hci_tty node exposed by this driver during init
++ */
++const struct file_operations hci_tty_chrdev_ops = {
++ .owner = THIS_MODULE,
++ .open = hci_tty_open,
++ .read = hci_tty_read,
++ .write = hci_tty_write,
++ .unlocked_ioctl = hci_tty_ioctl,
++ .poll = hci_tty_poll,
++ .release = hci_tty_release,
++};
++
++/*********Functions called during insmod and delmod****************************/
++
++static int hci_tty_major; /* major number */
++static struct class *hci_tty_class; /* class during class_create */
++static struct device *hci_tty_dev; /* dev during device_create */
++/** hci_tty_init Function
++ * This function Initializes the hci_tty driver parametes and exposes
++ * /dev/hci_tty node to user space
++ *
++ * Parameters : NULL
++ * Returns 0 on success
++ * else suitable error code
++ */
++static int __init hci_tty_init(void)
++{
++ pr_info("inside %s\n", __func__);
++
++ /* Expose the device DEVICE_NAME to user space
++ * And obtain the major number for the device
++ */
++ hci_tty_major = register_chrdev(0, DEVICE_NAME, &hci_tty_chrdev_ops);
++
++ if (0 > hci_tty_major) {
++ pr_err("Error when registering to char dev");
++ return hci_tty_major;
++ }
++
++ /* udev */
++ hci_tty_class = class_create(THIS_MODULE, DEVICE_NAME);
++ if (IS_ERR(hci_tty_class)) {
++ pr_err("Something went wrong in class_create");
++ unregister_chrdev(hci_tty_major, DEVICE_NAME);
++ return -1;
++ }
++
++ hci_tty_dev =
++ device_create(hci_tty_class, NULL, MKDEV(hci_tty_major, 0),
++ NULL, DEVICE_NAME);
++ if (IS_ERR(hci_tty_dev)) {
++ pr_err("Error in device create");
++ unregister_chrdev(hci_tty_major, DEVICE_NAME);
++ class_destroy(hci_tty_class);
++ return -1;
++ }
++ pr_info("allocated %d, %d\n", hci_tty_major, 0);
++ return 0;
++}
++
++/** hci_tty_exit Function
++ * This function Destroys the hci_tty driver parametes and /dev/hci_tty node
++ *
++ * Parameters : NULL
++ * Returns NULL
++ */
++static void __exit hci_tty_exit(void)
++{
++ pr_info("inside %s\n", __func__);
++ pr_info("bye.. freeing up %d\n", hci_tty_major);
++
++ device_destroy(hci_tty_class, MKDEV(hci_tty_major, 0));
++ class_destroy(hci_tty_class);
++ unregister_chrdev(hci_tty_major, DEVICE_NAME);
++}
++
++module_init(hci_tty_init);
++module_exit(hci_tty_exit);
++
++MODULE_AUTHOR("Pavan Savoy <pavan_savoy@ti.com>");
++MODULE_LICENSE("GPL");
+--
+1.7.9.5
+
diff --git a/patches/kernel_patches/imx-3.10.53/0003-imx_v7_defconfig-enable-Wilink8-related-switches.patch b/patches/kernel_patches/imx-3.10.53/0003-imx_v7_defconfig-enable-Wilink8-related-switches.patch
--- /dev/null
+++ b/patches/kernel_patches/imx-3.10.53/0003-imx_v7_defconfig-enable-Wilink8-related-switches.patch
@@ -0,0 +1,84 @@
+From fe548307100be21e83157e61d1dd55ffef4029bb Mon Sep 17 00:00:00 2001
+From: Eyal Reizer <eyalr@ti.com>
+Date: Wed, 4 Mar 2015 14:13:15 +0200
+Subject: [PATCH 3/7] imx_v7_defconfig: enable Wilink8 related switches
+
+* Disable internal mac80211 and cfg80211 as we are building wilink8
+ drivers using backport and loading as modules
+* enable wlan and hci related switches
+
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+---
+ arch/arm/configs/imx_v7_defconfig | 37 +++++++++++++++++++++++++++++++------
+ 1 file changed, 31 insertions(+), 6 deletions(-)
+
+diff --git a/arch/arm/configs/imx_v7_defconfig b/arch/arm/configs/imx_v7_defconfig
+index d71f731..64e265d 100644
+--- a/arch/arm/configs/imx_v7_defconfig
++++ b/arch/arm/configs/imx_v7_defconfig
+@@ -66,9 +66,8 @@ CONFIG_LLC2=y
+ CONFIG_CAN=y
+ CONFIG_CAN_FLEXCAN=y
+ CONFIG_CAN_M_CAN=y
+-CONFIG_CFG80211=y
+-CONFIG_CFG80211_WEXT=y
+-CONFIG_MAC80211=y
++# CONFIG_CFG80211 is not set
++# CONFIG_MAC80211 is not set
+
+ CONFIG_BT=y
+ CONFIG_BT_RFCOMM=y
+@@ -77,7 +76,7 @@ CONFIG_BT_BNEP=y
+ CONFIG_BT_BNEP_MC_FILTER=y
+ CONFIG_BT_BNEP_PROTO_FILTER=y
+ CONFIG_BT_HIDP=y
+-
++CONFIG_BT_WILINK=y
+ #
+ # Bluetooth device drivers
+ #
+@@ -87,7 +86,7 @@ CONFIG_BT_HCIUART=y
+ CONFIG_BT_HCIUART_H4=y
+ CONFIG_BT_HCIUART_BCSP=y
+ CONFIG_BT_HCIUART_ATH3K=y
+-# CONFIG_BT_HCIUART_LL is not set
++CONFIG_BT_HCIUART_LL=y
+ # CONFIG_BT_HCIUART_3WIRE is not set
+ CONFIG_BT_HCIBCM203X=y
+ # CONFIG_BT_HCIBPA10X is not set
+@@ -400,5 +399,31 @@ CONFIG_CRYPTO_DEV_FSL_CAAM_SM_TEST=y
+ CONFIG_CRYPTO_DEV_FSL_CAAM_SECVIO=y
+ CONFIG_CRC_CCITT=m
+ CONFIG_CRC_T10DIF=y
+-CONFIG_CRC7=m
++CONFIG_CRC7=y
+ CONFIG_LIBCRC32C=m
++#TI add for WL8
++CONFIG_WLAN=y
++CONFIG_CRYPTO_ARC4=y
++CONFIG_CRYPTO_AES=y
++CONFIG_NETFILTER=y
++CONFIG_NETFILTER_ADVANCED=y
++CONFIG_NF_CONNTRACK=y
++CONFIG_NETFILTER_XTABLES=y
++CONFIG_NF_DEFRAG_IPV4=y
++CONFIG_NF_CONNTRACK_IPV4=y
++CONFIG_NF_CONNTRACK_PROC_COMPAT=y
++CONFIG_IP_NF_IPTABLES=y
++CONFIG_IP_NF_FILTER=y
++CONFIG_IP_NF_TARGET_LOG=y
++CONFIG_NF_NAT=y
++CONFIG_NF_NAT_NEEDED=y
++CONFIG_IP_NF_TARGET_MASQUERADE=y
++CONFIG_INPUT_UINPUT=y
++CONFIG_AVERAGE=y
++CONFIG_PROC_DEVICETREE=y
++# enable dynamic debug for wl8
++CONFIG_DYNAMIC_DEBUG=y
++#enable ti shared transport support support
++CONFIG_TI_ST=y
++CONFIG_ST_HCI=y
++
+--
+1.7.9.5
+
diff --git a/patches/kernel_patches/imx-3.10.53/0004-st_kim-do-not-use-debugfs-functions-if-not-enabled.patch b/patches/kernel_patches/imx-3.10.53/0004-st_kim-do-not-use-debugfs-functions-if-not-enabled.patch
--- /dev/null
+++ b/patches/kernel_patches/imx-3.10.53/0004-st_kim-do-not-use-debugfs-functions-if-not-enabled.patch
@@ -0,0 +1,37 @@
+From 3bc3ac098de1c999020e40601d2db99ae5e1b2f0 Mon Sep 17 00:00:00 2001
+From: Eyal Reizer <eyalr@ti.com>
+Date: Wed, 29 Jan 2014 09:24:06 +0200
+Subject: [PATCH 4/7] st_kim: do not use debugfs functions if not enabled
+
+the probe function was using debugfs apis without checking if
+CONFIG_DEBUG_FS was enabled resulting with runtime errors.
+Fix this so these apis will only be used if the switch is active.
+
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+---
+ drivers/misc/ti-st/st_kim.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
+index 83269f1..fbf4dfd 100644
+--- a/drivers/misc/ti-st/st_kim.c
++++ b/drivers/misc/ti-st/st_kim.c
+@@ -778,6 +778,7 @@ static int kim_probe(struct platform_device *pdev)
+ kim_gdata->baud_rate = pdata->baud_rate;
+ pr_info("sysfs entries created\n");
+
++#ifdef CONFIG_DEBUG_FS
+ kim_debugfs_dir = debugfs_create_dir("ti-st", NULL);
+ if (IS_ERR(kim_debugfs_dir)) {
+ pr_err(" debugfs entries creation failed ");
+@@ -794,6 +795,7 @@ static int kim_probe(struct platform_device *pdev)
+
+ err_debugfs_dir:
+ sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp);
++#endif
+
+ err_sysfs_group:
+ st_core_exit(kim_gdata->core_data);
+--
+1.7.9.5
+
diff --git a/patches/kernel_patches/imx-3.10.53/0005-st_kim-allow-suspend-if-callback-is-not-registered.patch b/patches/kernel_patches/imx-3.10.53/0005-st_kim-allow-suspend-if-callback-is-not-registered.patch
--- /dev/null
+++ b/patches/kernel_patches/imx-3.10.53/0005-st_kim-allow-suspend-if-callback-is-not-registered.patch
@@ -0,0 +1,39 @@
+From 9f77068002ef057a1e01496f612853a6b35dde00 Mon Sep 17 00:00:00 2001
+From: Eyal Reizer <eyalr@ti.com>
+Date: Wed, 29 Jan 2014 09:03:41 +0200
+Subject: [PATCH 5/7] st_kim: allow suspend if callback is not registered
+
+Suspend/resume was failing if callbacks were not registered.
+As it is ok not to do anything when suspending fix this
+so it soen't return an error and allow the system to suspend.
+
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+---
+ drivers/misc/ti-st/st_kim.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
+index fbf4dfd..dbd22e3 100644
+--- a/drivers/misc/ti-st/st_kim.c
++++ b/drivers/misc/ti-st/st_kim.c
+@@ -839,7 +839,7 @@ static int kim_suspend(struct platform_device *pdev, pm_message_t state)
+ if (pdata->suspend)
+ return pdata->suspend(pdev, state);
+
+- return -EOPNOTSUPP;
++ return 0;
+ }
+
+ static int kim_resume(struct platform_device *pdev)
+@@ -849,7 +849,7 @@ static int kim_resume(struct platform_device *pdev)
+ if (pdata->resume)
+ return pdata->resume(pdev);
+
+- return -EOPNOTSUPP;
++ return 0;
+ }
+
+ /**********************************************************************/
+--
+1.7.9.5
+
diff --git a/patches/kernel_patches/imx-3.10.53/0006-btwilink-add-minimal-device-tree-support.patch b/patches/kernel_patches/imx-3.10.53/0006-btwilink-add-minimal-device-tree-support.patch
--- /dev/null
@@ -0,0 +1,53 @@
+From 83e32f317a02df2419bda2b4be614ce31e7bc1e3 Mon Sep 17 00:00:00 2001
+From: Eyal Reizer <eyalr@ti.com>
+Date: Thu, 23 May 2013 17:15:21 +0300
+Subject: [PATCH 6/7] btwilink: add minimal device tree support
+
+Add minimal device tree support to the btwilink driver that is used
+for binding bluetooth with the ti-st shared transport driver.
+
+Change-Id: I301c49d29046f20f8868bebb14347e82c12c8140
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+Signed-off-by: bvijay <bvijay@ti.com>
+---
+ drivers/bluetooth/btwilink.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
+index 60abf59..12595c9 100644
+--- a/drivers/bluetooth/btwilink.c
++++ b/drivers/bluetooth/btwilink.c
+@@ -30,6 +30,7 @@
+
+ #include <linux/ti_wilink_st.h>
+ #include <linux/module.h>
++#include <linux/of.h>
+
+ /* Bluetooth Driver Version */
+ #define VERSION "1.0"
+@@ -291,6 +292,14 @@ static int ti_st_send_frame(struct sk_buff *skb)
+ return 0;
+ }
+
++static const struct of_device_id btwilink_of_match[] = {
++{
++ .compatible = "btwilink",
++ },
++ {}
++};
++MODULE_DEVICE_TABLE(of, btwilink_of_match);
++
+ static int bt_ti_probe(struct platform_device *pdev)
+ {
+ static struct ti_st *hst;
+@@ -355,6 +364,7 @@ static struct platform_driver btwilink_driver = {
+ .driver = {
+ .name = "btwilink",
+ .owner = THIS_MODULE,
++ .of_match_table = of_match_ptr(btwilink_of_match),
+ },
+ };
+
+--
+1.7.9.5
+
diff --git a/patches/kernel_patches/imx-3.10.53/0007-ti-st-add-device-tree-support.patch b/patches/kernel_patches/imx-3.10.53/0007-ti-st-add-device-tree-support.patch
--- /dev/null
@@ -0,0 +1,256 @@
+From 78403fb3232ba53c9f8d9499879edbba60a29cc8 Mon Sep 17 00:00:00 2001
+From: Eyal Reizer <eyalr@ti.com>
+Date: Thu, 23 May 2013 17:11:14 +0300
+Subject: [PATCH 7/7] ti-st: add device tree support
+
+When using device tree, driver configuration data need to be read from
+device node.
+Add support for getting the platform data information from the device
+tree information stored in the .dtb file in case it exists.
+
+Change-Id: I74f7f869fc257a057edb9f35c5fd8cbafb810164
+Signed-off-by: Eyal Reizer <eyalr@ti.com>
+Signed-off-by: bvijay <bvijay@ti.com>
+---
+ drivers/misc/ti-st/st_kim.c | 96 ++++++++++++++++++++++++++++++++++++++----
+ drivers/misc/ti-st/st_ll.c | 17 +++++++-
+ include/linux/ti_wilink_st.h | 1 +
+ 3 files changed, 104 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
+index dbd22e3..8cb48b1 100644
+--- a/drivers/misc/ti-st/st_kim.c
++++ b/drivers/misc/ti-st/st_kim.c
+@@ -36,7 +36,8 @@
+ #include <linux/skbuff.h>
+ #include <linux/ti_wilink_st.h>
+ #include <linux/module.h>
+-
++#include <linux/of.h>
++#include <linux/of_device.h>
+
+ #define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */
+ static struct platform_device *st_kim_devices[MAX_ST_DEVICES];
+@@ -44,6 +45,9 @@ static struct platform_device *st_kim_devices[MAX_ST_DEVICES];
+ /**********************************************************************/
+ /* internal functions */
+
++struct ti_st_plat_data *dt_pdata;
++static struct ti_st_plat_data *get_platform_data(struct device *dev);
++
+ /**
+ * st_get_plat_device -
+ * function which returns the reference to the platform device
+@@ -461,7 +465,12 @@ long st_kim_start(void *kim_data)
+ struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
+
+ pr_info(" %s", __func__);
+- pdata = kim_gdata->kim_pdev->dev.platform_data;
++ if (kim_gdata->kim_pdev->dev.of_node) {
++ pr_debug("use device tree data");
++ pdata = dt_pdata;
++ } else {
++ pdata = kim_gdata->kim_pdev->dev.platform_data;
++ }
+
+ do {
+ /* platform specific enabling code here */
+@@ -521,12 +530,18 @@ long st_kim_stop(void *kim_data)
+ {
+ long err = 0;
+ struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
+- struct ti_st_plat_data *pdata =
+- kim_gdata->kim_pdev->dev.platform_data;
++ struct ti_st_plat_data *pdata;
+ struct tty_struct *tty = kim_gdata->core_data->tty;
+
+ INIT_COMPLETION(kim_gdata->ldisc_installed);
+
++ if (kim_gdata->kim_pdev->dev.of_node) {
++ pr_debug("use device tree data");
++ pdata = dt_pdata;
++ } else
++ pdata = kim_gdata->kim_pdev->dev.platform_data;
++
++
+ if (tty) { /* can be called before ldisc is installed */
+ /* Flush any pending characters in the driver and discipline. */
+ tty_ldisc_flush(tty);
+@@ -715,13 +730,53 @@ static const struct file_operations list_debugfs_fops = {
+ * board-*.c file
+ */
+
++static const struct of_device_id kim_of_match[] = {
++{
++ .compatible = "kim",
++ },
++ {}
++};
++MODULE_DEVICE_TABLE(of, kim_of_match);
++
++static struct ti_st_plat_data *get_platform_data(struct device *dev)
++{
++ struct device_node *np = dev->of_node;
++ const u32 *dt_property;
++ int len;
++
++ dt_pdata = kzalloc(sizeof(*dt_pdata), GFP_KERNEL);
++
++ if (!dt_pdata)
++ pr_err("Can't allocate device_tree platform data\n");
++
++ dt_property = of_get_property(np, "dev_name", &len);
++ if (dt_property)
++ memcpy(&dt_pdata->dev_name, dt_property, len);
++ of_property_read_u32(np, "nshutdown_gpio",
++ (u32 *)&dt_pdata->nshutdown_gpio);
++ of_property_read_u32(np, "flow_cntrl", (u32 *)&dt_pdata->flow_cntrl);
++ of_property_read_u32(np, "baud_rate", (u32 *)&dt_pdata->baud_rate);
++
++ return dt_pdata;
++}
++
+ static struct dentry *kim_debugfs_dir;
+ static int kim_probe(struct platform_device *pdev)
+ {
+ struct kim_data_s *kim_gdata;
+- struct ti_st_plat_data *pdata = pdev->dev.platform_data;
++ struct ti_st_plat_data *pdata;
+ int err;
+
++ if (pdev->dev.of_node)
++ pdata = get_platform_data(&pdev->dev);
++ else
++ pdata = pdev->dev.platform_data;
++
++ if (pdata == NULL) {
++ dev_err(&pdev->dev, "Platform Data is missing\n");
++ return -ENXIO;
++ }
++
+ if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) {
+ /* multiple devices could exist */
+ st_kim_devices[pdev->id] = pdev;
+@@ -809,9 +864,16 @@ err_core_init:
+ static int kim_remove(struct platform_device *pdev)
+ {
+ /* free the GPIOs requested */
+- struct ti_st_plat_data *pdata = pdev->dev.platform_data;
++ struct ti_st_plat_data *pdata;
+ struct kim_data_s *kim_gdata;
+
++ if (pdev->dev.of_node) {
++ pr_debug("use device tree data");
++ pdata = dt_pdata;
++ } else {
++ pdata = pdev->dev.platform_data;
++ }
++
+ kim_gdata = dev_get_drvdata(&pdev->dev);
+
+ /* Free the Bluetooth/FM/GPIO
+@@ -829,12 +891,22 @@ static int kim_remove(struct platform_device *pdev)
+
+ kfree(kim_gdata);
+ kim_gdata = NULL;
++ kfree(dt_pdata);
++ dt_pdata = NULL;
++
+ return 0;
+ }
+
+ static int kim_suspend(struct platform_device *pdev, pm_message_t state)
+ {
+- struct ti_st_plat_data *pdata = pdev->dev.platform_data;
++ struct ti_st_plat_data *pdata;
++
++ if (pdev->dev.of_node) {
++ pr_debug("use device tree data");
++ pdata = dt_pdata;
++ } else {
++ pdata = pdev->dev.platform_data;
++ }
+
+ if (pdata->suspend)
+ return pdata->suspend(pdev, state);
+@@ -844,7 +916,14 @@ static int kim_suspend(struct platform_device *pdev, pm_message_t state)
+
+ static int kim_resume(struct platform_device *pdev)
+ {
+- struct ti_st_plat_data *pdata = pdev->dev.platform_data;
++ struct ti_st_plat_data *pdata;
++
++ if (pdev->dev.of_node) {
++ pr_debug("use device tree data");
++ pdata = dt_pdata;
++ } else {
++ pdata = pdev->dev.platform_data;
++ }
+
+ if (pdata->resume)
+ return pdata->resume(pdev);
+@@ -862,6 +941,7 @@ static struct platform_driver kim_platform_driver = {
+ .driver = {
+ .name = "kim",
+ .owner = THIS_MODULE,
++ .of_match_table = of_match_ptr(kim_of_match),
+ },
+ };
+
+diff --git a/drivers/misc/ti-st/st_ll.c b/drivers/misc/ti-st/st_ll.c
+index 93b4d67..518e1b7 100644
+--- a/drivers/misc/ti-st/st_ll.c
++++ b/drivers/misc/ti-st/st_ll.c
+@@ -26,6 +26,7 @@
+ #include <linux/ti_wilink_st.h>
+
+ /**********************************************************************/
++
+ /* internal functions */
+ static void send_ll_cmd(struct st_data_s *st_data,
+ unsigned char cmd)
+@@ -53,7 +54,13 @@ static void ll_device_want_to_sleep(struct st_data_s *st_data)
+
+ /* communicate to platform about chip asleep */
+ kim_data = st_data->kim_data;
+- pdata = kim_data->kim_pdev->dev.platform_data;
++ if (kim_data->kim_pdev->dev.of_node) {
++ pr_debug("use device tree data");
++ pdata = dt_pdata;
++ } else {
++ pdata = kim_data->kim_pdev->dev.platform_data;
++ }
++
+ if (pdata->chip_asleep)
+ pdata->chip_asleep(NULL);
+ }
+@@ -86,7 +93,13 @@ static void ll_device_want_to_wakeup(struct st_data_s *st_data)
+
+ /* communicate to platform about chip wakeup */
+ kim_data = st_data->kim_data;
+- pdata = kim_data->kim_pdev->dev.platform_data;
++ if (kim_data->kim_pdev->dev.of_node) {
++ pr_debug("use device tree data");
++ pdata = dt_pdata;
++ } else {
++ pdata = kim_data->kim_pdev->dev.platform_data;
++ }
++
+ if (pdata->chip_awake)
+ pdata->chip_awake(NULL);
+ }
+diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
+index 932b763..39e577c 100644
+--- a/include/linux/ti_wilink_st.h
++++ b/include/linux/ti_wilink_st.h
+@@ -86,6 +86,7 @@ struct st_proto_s {
+ extern long st_register(struct st_proto_s *);
+ extern long st_unregister(struct st_proto_s *);
+
++extern struct ti_st_plat_data *dt_pdata;
+
+ /*
+ * header information used by st_core.c
+--
+1.7.9.5
+
diff --git a/patches/kernel_patches/imx-3.10.53/Readme.txt b/patches/kernel_patches/imx-3.10.53/Readme.txt
--- /dev/null
@@ -0,0 +1,11 @@
+Adding wilink8 support to the freescale imx6q-sabresd board
+===========================================================
+
+This patchset adds wilink8 support for the imx 3.10.53 kernel available with the freescale "1.1.0_ga" release
+
+Kernel base tage used is "rel_imx_3.10.53_1.1.0_ga"
+
+See the following link:
+http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tag/?h=imx_3.10.53_1.1.0_ga&id=rel_imx_3.10.53_1.1.0_ga
+
+
diff --git a/setup-env.sample b/setup-env.sample
index e96b0f30d819151cc3cf12f2831397c3fac581ec..3d877ba4d2424b6ee56867e9466bfb9c143bcdde 100644 (file)
--- a/setup-env.sample
+++ b/setup-env.sample
# if DEFAULT toolchain path is set toolchain will be downloaded to ./toolchain.
export TOOLCHAIN_PATH=DEFAULT
+
# if DEFAULT path to root filesystem is set ./fs folder will be used.
export ROOTFS=DEFAULT
+
#if DEFAULT kernel path is set - kernel will be downloaded (set branch to match kernel version)
export KERNEL_PATH=DEFAULT
+# if KERNEL_VARIANT below is set the build script will look for kernel specific
+# patches under the patches directory:
+# - patches under the pathces/driver_patches/$KERNEL_VARIANT directory would be
+# applied during "modules" build.
+# - patches under the patches/kernel_patches/$/$KERNEL_VARIANT directory would
+# be applied to the kernel pointed by KERNEL_PATH in case the "patch_kernel"
+# command is used.
+# Note: the kernel is not built automatically after the patches are applied
+export KERNEL_VARIANT=DEFAULT
+
export CROSS_COMPILE=arm-linux-gnueabihf-
export ARCH=arm
[ "$TOOLCHAIN_PATH" != "DEFAULT" ] && export PATH=$TOOLCHAIN_PATH:$PATH