2018-12-21 01:20:14

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Hi,

This moves all remaining users of the legacy TI_ST driver to hcill (patches
1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
device driver with support for multiple instances. Patch 7 will result in
(userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
specific parts from wl128x-radio and adds the required infrastructure to use it
with the serdev hcill driver instead. The remaining patches 13 and 14 remove
the old TI_ST code.

The new code has been tested on the Motorola Droid 4. For testing the audio
should be configured to route Ext to Speaker or Headphone. Then you need to
plug headphone, since its cable is used as antenna. For testing there is a
'radio' utility packages in Debian. When you start the utility you need to
specify a frequency, since initial get_frequency returns an error:

$ radio -f 100.0

Merry Christmas!

-- Sebastian

Sebastian Reichel (14):
ARM: dts: LogicPD Torpedo: Add WiLink UART node
ARM: dts: IGEP: Add WiLink UART node
ARM: OMAP2+: pdata-quirks: drop TI_ST/KIM support
media: wl128x-radio: remove module version
media: wl128x-radio: remove global radio_disconnected
media: wl128x-radio: remove global radio_dev
media: wl128x-radio: convert to platform device
media: wl128x-radio: use device managed memory allocation
media: wl128x-radio: load firmware from ti-connectivity/
media: wl128x-radio: simplify fmc_prepare/fmc_release
media: wl128x-radio: fix skb debug printing
media: wl128x-radio: move from TI_ST to hci_ll driver
Bluetooth: btwilink: drop superseded driver
misc: ti-st: Drop superseded driver

.../boot/dts/logicpd-torpedo-37xx-devkit.dts | 8 +
arch/arm/boot/dts/omap3-igep0020-rev-f.dts | 8 +
arch/arm/boot/dts/omap3-igep0030-rev-g.dts | 8 +
arch/arm/mach-omap2/pdata-quirks.c | 52 -
drivers/bluetooth/Kconfig | 11 -
drivers/bluetooth/Makefile | 1 -
drivers/bluetooth/btwilink.c | 350 -------
drivers/bluetooth/hci_ll.c | 115 ++-
drivers/media/radio/wl128x/Kconfig | 2 +-
drivers/media/radio/wl128x/fmdrv.h | 5 +-
drivers/media/radio/wl128x/fmdrv_common.c | 211 ++--
drivers/media/radio/wl128x/fmdrv_common.h | 4 +-
drivers/media/radio/wl128x/fmdrv_v4l2.c | 55 +-
drivers/media/radio/wl128x/fmdrv_v4l2.h | 2 +-
drivers/misc/Kconfig | 1 -
drivers/misc/Makefile | 1 -
drivers/misc/ti-st/Kconfig | 18 -
drivers/misc/ti-st/Makefile | 6 -
drivers/misc/ti-st/st_core.c | 922 ------------------
drivers/misc/ti-st/st_kim.c | 868 -----------------
drivers/misc/ti-st/st_ll.c | 169 ----
include/linux/ti_wilink_st.h | 337 +------
22 files changed, 213 insertions(+), 2941 deletions(-)
delete mode 100644 drivers/bluetooth/btwilink.c
delete mode 100644 drivers/misc/ti-st/Kconfig
delete mode 100644 drivers/misc/ti-st/Makefile
delete mode 100644 drivers/misc/ti-st/st_core.c
delete mode 100644 drivers/misc/ti-st/st_kim.c
delete mode 100644 drivers/misc/ti-st/st_ll.c

--
2.19.2



2018-12-21 01:18:06

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 01/14] ARM: dts: LogicPD Torpedo: Add WiLink UART node

From: Sebastian Reichel <[email protected]>

Add a node for the UART part of WiLink chip.

Cc: Adam Ford <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>
---
This is compile tested only!
---
arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
index 9d5d53fbe9c0..2699da12dc2d 100644
--- a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
+++ b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
@@ -54,6 +54,14 @@
};
};

+&uart2 {
+ bluetooth {
+ compatible = "ti,wl1283-st";
+ enable-gpios = <&gpio6 2 GPIO_ACTIVE_HIGH>; /* gpio 162 */
+ max-speed = <3000000>;
+ };
+};
+
&omap3_pmx_core {
mmc3_pins: pinmux_mm3_pins {
pinctrl-single,pins = <
--
2.19.2


2018-12-21 01:18:15

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 02/14] ARM: dts: IGEP: Add WiLink UART node

From: Sebastian Reichel <[email protected]>

Add a node for the UART part of WiLink chip.

Cc: Enric Balletbo i Serra <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>
---
This is compile tested only!
---
arch/arm/boot/dts/omap3-igep0020-rev-f.dts | 8 ++++++++
arch/arm/boot/dts/omap3-igep0030-rev-g.dts | 8 ++++++++
2 files changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/omap3-igep0020-rev-f.dts b/arch/arm/boot/dts/omap3-igep0020-rev-f.dts
index 285681d7af49..8bb4298ca05e 100644
--- a/arch/arm/boot/dts/omap3-igep0020-rev-f.dts
+++ b/arch/arm/boot/dts/omap3-igep0020-rev-f.dts
@@ -52,3 +52,11 @@
interrupts = <17 IRQ_TYPE_EDGE_RISING>; /* gpio 177 */
};
};
+
+&uart2 {
+ bluetooth {
+ compatible = "ti,wl1835-st";
+ enable-gpios = <&gpio5 9 GPIO_ACTIVE_HIGH>; /* gpio 137 */
+ max-speed = <300000>;
+ };
+};
diff --git a/arch/arm/boot/dts/omap3-igep0030-rev-g.dts b/arch/arm/boot/dts/omap3-igep0030-rev-g.dts
index 1adc73bd2ca0..03be171e9de7 100644
--- a/arch/arm/boot/dts/omap3-igep0030-rev-g.dts
+++ b/arch/arm/boot/dts/omap3-igep0030-rev-g.dts
@@ -74,3 +74,11 @@
interrupts = <8 IRQ_TYPE_EDGE_RISING>; /* gpio 136 */
};
};
+
+&uart2 {
+ bluetooth {
+ compatible = "ti,wl1835-st";
+ enable-gpios = <&gpio5 9 GPIO_ACTIVE_HIGH>; /* gpio 137 */
+ max-speed = <300000>;
+ };
+};
--
2.19.2


2018-12-21 01:18:26

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 05/14] media: wl128x-radio: remove global radio_disconnected

From: Sebastian Reichel <[email protected]>

Move global radio_disconnected into device structure to
prepare converting this driver into a normal platform
device driver supporting multiple instances.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/media/radio/wl128x/fmdrv.h | 1 +
drivers/media/radio/wl128x/fmdrv_v4l2.c | 15 +++++++--------
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h
index 8ed7c0aeb8b9..fa89eef59295 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -201,6 +201,7 @@ struct fmdev {
struct v4l2_device v4l2_dev; /* V4L2 top level struct */
struct snd_card *card; /* Card which holds FM mixer controls */
u16 asci_id;
+ u8 radio_disconnected;
spinlock_t rds_buff_lock; /* To protect access to RDS buffer */
spinlock_t resp_skb_lock; /* To protect access to received SKB */

diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index e25fd4d4d280..f541b5802844 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -33,7 +33,6 @@
#include "fmdrv_tx.h"

static struct video_device gradio_dev;
-static u8 radio_disconnected;

/* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */

@@ -47,7 +46,7 @@ static ssize_t fm_v4l2_fops_read(struct file *file, char __user * buf,

fmdev = video_drvdata(file);

- if (!radio_disconnected) {
+ if (!fmdev->radio_disconnected) {
fmerr("FM device is already disconnected\n");
return -EIO;
}
@@ -126,14 +125,14 @@ static int fm_v4l2_fops_open(struct file *file)
int ret;
struct fmdev *fmdev = NULL;

+ fmdev = video_drvdata(file);
+
/* Don't allow multiple open */
- if (radio_disconnected) {
+ if (fmdev->radio_disconnected) {
fmerr("FM device is already opened\n");
return -EBUSY;
}

- fmdev = video_drvdata(file);
-
if (mutex_lock_interruptible(&fmdev->mutex))
return -ERESTARTSYS;
ret = fmc_prepare(fmdev);
@@ -149,7 +148,7 @@ static int fm_v4l2_fops_open(struct file *file)
fmerr("Unable to load FM RX firmware\n");
goto open_unlock;
}
- radio_disconnected = 1;
+ fmdev->radio_disconnected = 1;

open_unlock:
mutex_unlock(&fmdev->mutex);
@@ -162,7 +161,7 @@ static int fm_v4l2_fops_release(struct file *file)
struct fmdev *fmdev;

fmdev = video_drvdata(file);
- if (!radio_disconnected) {
+ if (!fmdev->radio_disconnected) {
fmdbg("FM device is already closed\n");
return 0;
}
@@ -179,7 +178,7 @@ static int fm_v4l2_fops_release(struct file *file)
fmerr("FM CORE release failed\n");
goto release_unlock;
}
- radio_disconnected = 0;
+ fmdev->radio_disconnected = 0;

release_unlock:
mutex_unlock(&fmdev->mutex);
--
2.19.2


2018-12-21 01:18:33

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 09/14] media: wl128x-radio: load firmware from ti-connectivity/

From: Sebastian Reichel <[email protected]>

All TI WiLink firmware files are loaded from the ti-connectivity
subdirectory, so let's also move the FM firmware.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/media/radio/wl128x/fmdrv_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index 3f189d093eeb..d584ca970556 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1347,7 +1347,7 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
fmdbg("ASIC ID: 0x%x , ASIC Version: %d\n",
be16_to_cpu(asic_id), be16_to_cpu(asic_ver));

- sprintf(fw_name, "%s_%x.%d.bts", FM_FMC_FW_FILE_START,
+ sprintf(fw_name, "ti-connectivity/%s_%x.%d.bts", FM_FMC_FW_FILE_START,
be16_to_cpu(asic_id), be16_to_cpu(asic_ver));

ret = fm_download_firmware(fmdev, fw_name);
@@ -1355,7 +1355,7 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
fmdbg("Failed to download firmware file %s\n", fw_name);
goto rel;
}
- sprintf(fw_name, "%s_%x.%d.bts", (mode == FM_MODE_RX) ?
+ sprintf(fw_name, "ti-connectivity/%s_%x.%d.bts", (mode == FM_MODE_RX) ?
FM_RX_FW_FILE_START : FM_TX_FW_FILE_START,
be16_to_cpu(asic_id), be16_to_cpu(asic_ver));

--
2.19.2


2018-12-21 01:18:43

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 13/14] Bluetooth: btwilink: drop superseded driver

From: Sebastian Reichel <[email protected]>

All users of this driver have been converted to the serdev based
hci_ll driver. The unused driver can be safely dropped now.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/bluetooth/Kconfig | 11 --
drivers/bluetooth/Makefile | 1 -
drivers/bluetooth/btwilink.c | 350 -----------------------------------
3 files changed, 362 deletions(-)
delete mode 100644 drivers/bluetooth/btwilink.c

diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 845b0314ce3a..c382ece74942 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -368,17 +368,6 @@ config BT_ATH3K
Say Y here to compile support for "Atheros firmware download driver"
into the kernel or say M to compile it as module (ath3k).

-config BT_WILINK
- tristate "Texas Instruments WiLink7 driver"
- depends on TI_ST
- help
- This enables the Bluetooth driver for Texas Instrument's BT/FM/GPS
- combo devices. This makes use of shared transport line discipline
- core driver to communicate with the BT core of the combo chip.
-
- Say Y here to compile support for Texas Instrument's WiLink7 driver
- into the kernel or say M to compile it as module (btwilink).
-
config BT_MTKUART
tristate "MediaTek HCI UART driver"
depends on SERIAL_DEV_BUS
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index b7e393cfc1e3..70167cdf9cc7 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -19,7 +19,6 @@ obj-$(CONFIG_BT_INTEL) += btintel.o
obj-$(CONFIG_BT_ATH3K) += ath3k.o
obj-$(CONFIG_BT_MRVL) += btmrvl.o
obj-$(CONFIG_BT_MRVL_SDIO) += btmrvl_sdio.o
-obj-$(CONFIG_BT_WILINK) += btwilink.o
obj-$(CONFIG_BT_MTKUART) += btmtkuart.o
obj-$(CONFIG_BT_QCOMSMD) += btqcomsmd.o
obj-$(CONFIG_BT_BCM) += btbcm.o
diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
deleted file mode 100644
index 5ef8000f90a9..000000000000
--- a/drivers/bluetooth/btwilink.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Texas Instrument's Bluetooth Driver For Shared Transport.
- *
- * Bluetooth Driver acts as interface between HCI core and
- * TI Shared Transport Layer.
- *
- * Copyright (C) 2009-2010 Texas Instruments
- * Author: Raja Mani <[email protected]>
- * Pavan Savoy <[email protected]>
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include <linux/platform_device.h>
-#include <net/bluetooth/bluetooth.h>
-#include <net/bluetooth/hci_core.h>
-#include <net/bluetooth/hci.h>
-
-#include <linux/ti_wilink_st.h>
-#include <linux/module.h>
-
-/* Bluetooth Driver Version */
-#define VERSION "1.0"
-#define MAX_BT_CHNL_IDS 3
-
-/* 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;
- int reg_status;
- long (*st_write) (struct sk_buff *);
- struct completion wait_reg_completion;
-};
-
-/* Increments HCI counters based on pocket ID (cmd,acl,sco) */
-static inline void ti_st_tx_complete(struct ti_st *hst, int pkt_type)
-{
- struct hci_dev *hdev = hst->hdev;
-
- /* Update HCI stat counters */
- switch (pkt_type) {
- case HCI_COMMAND_PKT:
- hdev->stat.cmd_tx++;
- break;
-
- case HCI_ACLDATA_PKT:
- hdev->stat.acl_tx++;
- break;
-
- case HCI_SCODATA_PKT:
- hdev->stat.sco_tx++;
- break;
- }
-}
-
-/* ------- Interfaces to Shared Transport ------ */
-
-/* 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, int data)
-{
- struct ti_st *lhst = priv_data;
-
- /* 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);
-}
-
-/* Called by Shared Transport layer when receive data is available */
-static long st_receive(void *priv_data, struct sk_buff *skb)
-{
- struct ti_st *lhst = priv_data;
- int err;
-
- if (!skb)
- return -EFAULT;
-
- if (!lhst) {
- kfree_skb(skb);
- return -EFAULT;
- }
-
- /* Forward skb to HCI core layer */
- err = hci_recv_frame(lhst->hdev, skb);
- if (err < 0) {
- BT_ERR("Unable to push skb to HCI core(%d)", err);
- return err;
- }
-
- lhst->hdev->stat.byte_rx += skb->len;
-
- return 0;
-}
-
-/* ------- Interfaces to HCI layer ------ */
-/* protocol structure registered with shared transport */
-static struct st_proto_s ti_st_proto[MAX_BT_CHNL_IDS] = {
- {
- .chnl_id = HCI_EVENT_PKT, /* HCI Events */
- .hdr_len = sizeof(struct hci_event_hdr),
- .offset_len_in_hdr = offsetof(struct hci_event_hdr, plen),
- .len_size = 1, /* sizeof(plen) in struct hci_event_hdr */
- .reserve = 8,
- },
- {
- .chnl_id = HCI_ACLDATA_PKT, /* ACL */
- .hdr_len = sizeof(struct hci_acl_hdr),
- .offset_len_in_hdr = offsetof(struct hci_acl_hdr, dlen),
- .len_size = 2, /* sizeof(dlen) in struct hci_acl_hdr */
- .reserve = 8,
- },
- {
- .chnl_id = HCI_SCODATA_PKT, /* SCO */
- .hdr_len = sizeof(struct hci_sco_hdr),
- .offset_len_in_hdr = offsetof(struct hci_sco_hdr, dlen),
- .len_size = 1, /* sizeof(dlen) in struct hci_sco_hdr */
- .reserve = 8,
- },
-};
-
-/* Called from HCI core to initialize the device */
-static int ti_st_open(struct hci_dev *hdev)
-{
- unsigned long timeleft;
- struct ti_st *hst;
- int err, i;
-
- BT_DBG("%s %p", hdev->name, hdev);
-
- /* provide contexts for callbacks from ST */
- hst = hci_get_drvdata(hdev);
-
- for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
- ti_st_proto[i].priv_data = hst;
- ti_st_proto[i].max_frame_size = HCI_MAX_FRAME_SIZE;
- 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) {
- BT_ERR("st_register failed %d", err);
- return err;
- }
-
- /* ST is busy with either protocol
- * registration or firmware download.
- */
- BT_DBG("waiting for registration "
- "completion signal from ST");
- timeleft = wait_for_completion_timeout
- (&hst->wait_reg_completion,
- msecs_to_jiffies(BT_REGISTER_TIMEOUT));
- if (!timeleft) {
- BT_ERR("Timeout(%d sec),didn't get reg "
- "completion signal from ST",
- BT_REGISTER_TIMEOUT / 1000);
- return -ETIMEDOUT;
- }
-
- /* Is ST registration callback
- * called with ERROR status?
- */
- if (hst->reg_status != 0) {
- BT_ERR("ST registration completed with invalid "
- "status %d", hst->reg_status);
- return -EAGAIN;
- }
-
-done:
- hst->st_write = ti_st_proto[i].write;
- if (!hst->st_write) {
- BT_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)
- BT_ERR("st_unregister() failed with "
- "error %d", err);
- hst->st_write = NULL;
- }
- return -EIO;
- }
- }
- return 0;
-}
-
-/* Close device */
-static int ti_st_close(struct hci_dev *hdev)
-{
- int err, i;
- struct ti_st *hst = hci_get_drvdata(hdev);
-
- for (i = MAX_BT_CHNL_IDS-1; i >= 0; i--) {
- err = st_unregister(&ti_st_proto[i]);
- if (err)
- BT_ERR("st_unregister(%d) failed with error %d",
- ti_st_proto[i].chnl_id, err);
- }
-
- hst->st_write = NULL;
-
- return err;
-}
-
-static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
-{
- struct ti_st *hst;
- long len;
- int pkt_type;
-
- hst = hci_get_drvdata(hdev);
-
- /* Prepend skb with frame type */
- memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
-
- BT_DBG("%s: type %d len %d", hdev->name, hci_skb_pkt_type(skb),
- skb->len);
-
- /* Insert skb to shared transport layer's transmit queue.
- * Freeing skb memory is taken care in shared transport layer,
- * so don't free skb memory here.
- */
- pkt_type = hci_skb_pkt_type(skb);
- len = hst->st_write(skb);
- if (len < 0) {
- BT_ERR("ST write failed (%ld)", len);
- /* Try Again, would only fail if UART has gone bad */
- return -EAGAIN;
- }
-
- /* ST accepted our skb. So, Go ahead and do rest */
- hdev->stat.byte_tx += len;
- ti_st_tx_complete(hst, pkt_type);
-
- return 0;
-}
-
-static int bt_ti_probe(struct platform_device *pdev)
-{
- struct ti_st *hst;
- struct hci_dev *hdev;
- int err;
-
- hst = devm_kzalloc(&pdev->dev, sizeof(struct ti_st), GFP_KERNEL);
- if (!hst)
- return -ENOMEM;
-
- /* Expose "hciX" device to user space */
- hdev = hci_alloc_dev();
- if (!hdev)
- return -ENOMEM;
-
- BT_DBG("hdev %p", hdev);
-
- hst->hdev = hdev;
- hdev->bus = HCI_UART;
- hci_set_drvdata(hdev, hst);
- hdev->open = ti_st_open;
- hdev->close = ti_st_close;
- hdev->flush = NULL;
- hdev->send = ti_st_send_frame;
-
- err = hci_register_dev(hdev);
- if (err < 0) {
- BT_ERR("Can't register HCI device error %d", err);
- hci_free_dev(hdev);
- return err;
- }
-
- BT_DBG("HCI device registered (hdev %p)", hdev);
-
- dev_set_drvdata(&pdev->dev, hst);
- return 0;
-}
-
-static int bt_ti_remove(struct platform_device *pdev)
-{
- struct hci_dev *hdev;
- struct ti_st *hst = dev_get_drvdata(&pdev->dev);
-
- if (!hst)
- return -EFAULT;
-
- BT_DBG("%s", hst->hdev->name);
-
- hdev = hst->hdev;
- ti_st_close(hdev);
- hci_unregister_dev(hdev);
-
- hci_free_dev(hdev);
-
- dev_set_drvdata(&pdev->dev, NULL);
- return 0;
-}
-
-static struct platform_driver btwilink_driver = {
- .probe = bt_ti_probe,
- .remove = bt_ti_remove,
- .driver = {
- .name = "btwilink",
- },
-};
-
-module_platform_driver(btwilink_driver);
-
-/* ------ Module Info ------ */
-
-MODULE_AUTHOR("Raja Mani <[email protected]>");
-MODULE_DESCRIPTION("Bluetooth Driver for TI Shared Transport" VERSION);
-MODULE_VERSION(VERSION);
-MODULE_LICENSE("GPL");
--
2.19.2


2018-12-21 01:18:55

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 14/14] misc: ti-st: Drop superseded driver

From: Sebastian Reichel <[email protected]>

This driver has been superseded by the serdev based Bluetooth
hci_ll driver, which is initialized from DT. All mainline users
have been converted and this driver can be safely dropped.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/misc/Kconfig | 1 -
drivers/misc/Makefile | 1 -
drivers/misc/ti-st/Kconfig | 18 -
drivers/misc/ti-st/Makefile | 6 -
drivers/misc/ti-st/st_core.c | 922 -----------------------------------
drivers/misc/ti-st/st_kim.c | 868 ---------------------------------
drivers/misc/ti-st/st_ll.c | 169 -------
include/linux/ti_wilink_st.h | 335 -------------
8 files changed, 2320 deletions(-)
delete mode 100644 drivers/misc/ti-st/Kconfig
delete mode 100644 drivers/misc/ti-st/Makefile
delete mode 100644 drivers/misc/ti-st/st_core.c
delete mode 100644 drivers/misc/ti-st/st_kim.c
delete mode 100644 drivers/misc/ti-st/st_ll.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 3726eacdf65d..a5cc07d33c74 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -516,7 +516,6 @@ config MISC_RTSX
source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig"
-source "drivers/misc/ti-st/Kconfig"
source "drivers/misc/lis3lv02d/Kconfig"
source "drivers/misc/altera-stapl/Kconfig"
source "drivers/misc/mei/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index af22bbc3d00c..31c1e3eb4952 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -39,7 +39,6 @@ obj-y += cb710/
obj-$(CONFIG_SPEAR13XX_PCIE_GADGET) += spear13xx_pcie_gadget.o
obj-$(CONFIG_VMWARE_BALLOON) += vmw_balloon.o
obj-$(CONFIG_PCH_PHUB) += pch_phub.o
-obj-y += ti-st/
obj-y += lis3lv02d/
obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o
obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/
diff --git a/drivers/misc/ti-st/Kconfig b/drivers/misc/ti-st/Kconfig
deleted file mode 100644
index 5bb92698bc80..000000000000
--- a/drivers/misc/ti-st/Kconfig
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# TI's shared transport line discipline and the protocol
-# drivers (BT, FM and GPS)
-#
-menu "Texas Instruments shared transport line discipline"
-config TI_ST
- tristate "Shared transport core driver"
- depends on NET && TTY
- depends on GPIOLIB || COMPILE_TEST
- select FW_LOADER
- help
- This enables the shared transport core driver for TI
- BT / FM and GPS combo chips. This enables protocol drivers
- to register themselves with core and send data, the responses
- are returned to relevant protocol drivers based on their
- packet types.
-
-endmenu
diff --git a/drivers/misc/ti-st/Makefile b/drivers/misc/ti-st/Makefile
deleted file mode 100644
index 78d7ebb14749..000000000000
--- a/drivers/misc/ti-st/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# Makefile for TI's shared transport line discipline
-# and its protocol drivers (BT, FM, GPS)
-#
-obj-$(CONFIG_TI_ST) += st_drv.o
-st_drv-objs := st_core.o st_kim.o st_ll.o
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
deleted file mode 100644
index eda8d407be28..000000000000
--- a/drivers/misc/ti-st/st_core.c
+++ /dev/null
@@ -1,922 +0,0 @@
-/*
- * Shared Transport Line discipline driver Core
- * This hooks up ST KIM driver and ST LL driver
- * Copyright (C) 2009-2010 Texas Instruments
- * Author: Pavan Savoy <[email protected]>
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#define pr_fmt(fmt) "(stc): " fmt
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/tty.h>
-
-#include <linux/seq_file.h>
-#include <linux/skbuff.h>
-
-#include <linux/ti_wilink_st.h>
-
-extern void st_kim_recv(void *, const unsigned char *, long);
-void st_int_recv(void *, const unsigned char *, long);
-/* function pointer pointing to either,
- * st_kim_recv during registration to receive fw download responses
- * st_int_recv after registration to receive proto stack responses
- */
-static void (*st_recv) (void *, const unsigned char *, long);
-
-/********************************************************************/
-static void add_channel_to_table(struct st_data_s *st_gdata,
- struct st_proto_s *new_proto)
-{
- pr_info("%s: id %d\n", __func__, new_proto->chnl_id);
- /* list now has the channel id as index itself */
- st_gdata->list[new_proto->chnl_id] = new_proto;
- st_gdata->is_registered[new_proto->chnl_id] = true;
-}
-
-static void remove_channel_from_table(struct st_data_s *st_gdata,
- struct st_proto_s *proto)
-{
- pr_info("%s: id %d\n", __func__, proto->chnl_id);
-/* st_gdata->list[proto->chnl_id] = NULL; */
- st_gdata->is_registered[proto->chnl_id] = false;
-}
-
-/*
- * called from KIM during firmware download.
- *
- * This is a wrapper function to tty->ops->write_room.
- * It returns number of free space available in
- * uart tx buffer.
- */
-int st_get_uart_wr_room(struct st_data_s *st_gdata)
-{
- struct tty_struct *tty;
- if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
- pr_err("tty unavailable to perform write");
- return -1;
- }
- tty = st_gdata->tty;
- return tty->ops->write_room(tty);
-}
-
-/* can be called in from
- * -- KIM (during fw download)
- * -- ST Core (during st_write)
- *
- * This is the internal write function - a wrapper
- * to tty->ops->write
- */
-int st_int_write(struct st_data_s *st_gdata,
- const unsigned char *data, int count)
-{
- struct tty_struct *tty;
- if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
- pr_err("tty unavailable to perform write");
- return -EINVAL;
- }
- tty = st_gdata->tty;
-#ifdef VERBOSE
- print_hex_dump(KERN_DEBUG, "<out<", DUMP_PREFIX_NONE,
- 16, 1, data, count, 0);
-#endif
- return tty->ops->write(tty, data, count);
-
-}
-
-/*
- * push the skb received to relevant
- * protocol stacks
- */
-static void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata)
-{
- pr_debug(" %s(prot:%d) ", __func__, chnl_id);
-
- if (unlikely
- (st_gdata == NULL || st_gdata->rx_skb == NULL
- || st_gdata->is_registered[chnl_id] == false)) {
- pr_err("chnl_id %d not registered, no data to send?",
- chnl_id);
- kfree_skb(st_gdata->rx_skb);
- return;
- }
- /* this cannot fail
- * this shouldn't take long
- * - should be just skb_queue_tail for the
- * protocol stack driver
- */
- if (likely(st_gdata->list[chnl_id]->recv != NULL)) {
- if (unlikely
- (st_gdata->list[chnl_id]->recv
- (st_gdata->list[chnl_id]->priv_data, st_gdata->rx_skb)
- != 0)) {
- pr_err(" proto stack %d's ->recv failed", chnl_id);
- kfree_skb(st_gdata->rx_skb);
- return;
- }
- } else {
- pr_err(" proto stack %d's ->recv null", chnl_id);
- kfree_skb(st_gdata->rx_skb);
- }
- return;
-}
-
-/**
- * st_reg_complete -
- * to call registration complete callbacks
- * of all protocol stack drivers
- * This function is being called with spin lock held, protocol drivers are
- * only expected to complete their waits and do nothing more than that.
- */
-static void st_reg_complete(struct st_data_s *st_gdata, int err)
-{
- unsigned char i = 0;
- pr_info(" %s ", __func__);
- for (i = 0; i < ST_MAX_CHANNELS; i++) {
- if (likely(st_gdata != NULL &&
- st_gdata->is_registered[i] == true &&
- st_gdata->list[i]->reg_complete_cb != NULL)) {
- st_gdata->list[i]->reg_complete_cb
- (st_gdata->list[i]->priv_data, err);
- pr_info("protocol %d's cb sent %d\n", i, err);
- if (err) { /* cleanup registered protocol */
- st_gdata->is_registered[i] = false;
- if (st_gdata->protos_registered)
- st_gdata->protos_registered--;
- }
- }
- }
-}
-
-static inline int st_check_data_len(struct st_data_s *st_gdata,
- unsigned char chnl_id, int len)
-{
- int room = skb_tailroom(st_gdata->rx_skb);
-
- pr_debug("len %d room %d", len, room);
-
- if (!len) {
- /* Received packet has only packet header and
- * has zero length payload. So, ask ST CORE to
- * forward the packet to protocol driver (BT/FM/GPS)
- */
- st_send_frame(chnl_id, st_gdata);
-
- } else if (len > room) {
- /* Received packet's payload length is larger.
- * We can't accommodate it in created skb.
- */
- pr_err("Data length is too large len %d room %d", len,
- room);
- kfree_skb(st_gdata->rx_skb);
- } else {
- /* Packet header has non-zero payload length and
- * we have enough space in created skb. Lets read
- * payload data */
- st_gdata->rx_state = ST_W4_DATA;
- st_gdata->rx_count = len;
- return len;
- }
-
- /* Change ST state to continue to process next
- * packet */
- st_gdata->rx_state = ST_W4_PACKET_TYPE;
- st_gdata->rx_skb = NULL;
- st_gdata->rx_count = 0;
- st_gdata->rx_chnl = 0;
-
- return 0;
-}
-
-/**
- * st_wakeup_ack - internal function for action when wake-up ack
- * received
- */
-static inline void st_wakeup_ack(struct st_data_s *st_gdata,
- unsigned char cmd)
-{
- struct sk_buff *waiting_skb;
- unsigned long flags = 0;
-
- spin_lock_irqsave(&st_gdata->lock, flags);
- /* de-Q from waitQ and Q in txQ now that the
- * chip is awake
- */
- while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq)))
- skb_queue_tail(&st_gdata->txq, waiting_skb);
-
- /* state forwarded to ST LL */
- st_ll_sleep_state(st_gdata, (unsigned long)cmd);
- spin_unlock_irqrestore(&st_gdata->lock, flags);
-
- /* wake up to send the recently copied skbs from waitQ */
- st_tx_wakeup(st_gdata);
-}
-
-/**
- * st_int_recv - ST's internal receive function.
- * Decodes received RAW data and forwards to corresponding
- * client drivers (Bluetooth,FM,GPS..etc).
- * This can receive various types of packets,
- * HCI-Events, ACL, SCO, 4 types of HCI-LL PM packets
- * CH-8 packets from FM, CH-9 packets from GPS cores.
- */
-void st_int_recv(void *disc_data,
- const unsigned char *data, long count)
-{
- char *ptr;
- struct st_proto_s *proto;
- unsigned short payload_len = 0;
- int len = 0;
- unsigned char type = 0;
- unsigned char *plen;
- struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
- unsigned long flags;
-
- ptr = (char *)data;
- /* tty_receive sent null ? */
- if (unlikely(ptr == NULL) || (st_gdata == NULL)) {
- pr_err(" received null from TTY ");
- return;
- }
-
- pr_debug("count %ld rx_state %ld"
- "rx_count %ld", count, st_gdata->rx_state,
- st_gdata->rx_count);
-
- spin_lock_irqsave(&st_gdata->lock, flags);
- /* Decode received bytes here */
- while (count) {
- if (st_gdata->rx_count) {
- len = min_t(unsigned int, st_gdata->rx_count, count);
- skb_put_data(st_gdata->rx_skb, ptr, len);
- st_gdata->rx_count -= len;
- count -= len;
- ptr += len;
-
- if (st_gdata->rx_count)
- continue;
-
- /* Check ST RX state machine , where are we? */
- switch (st_gdata->rx_state) {
- /* Waiting for complete packet ? */
- case ST_W4_DATA:
- pr_debug("Complete pkt received");
- /* Ask ST CORE to forward
- * the packet to protocol driver */
- st_send_frame(st_gdata->rx_chnl, st_gdata);
-
- st_gdata->rx_state = ST_W4_PACKET_TYPE;
- st_gdata->rx_skb = NULL;
- continue;
- /* parse the header to know details */
- case ST_W4_HEADER:
- proto = st_gdata->list[st_gdata->rx_chnl];
- plen =
- &st_gdata->rx_skb->data
- [proto->offset_len_in_hdr];
- pr_debug("plen pointing to %x\n", *plen);
- if (proto->len_size == 1)/* 1 byte len field */
- payload_len = *(unsigned char *)plen;
- else if (proto->len_size == 2)
- payload_len =
- __le16_to_cpu(*(unsigned short *)plen);
- else
- pr_info("%s: invalid length "
- "for id %d\n",
- __func__, proto->chnl_id);
- st_check_data_len(st_gdata, proto->chnl_id,
- payload_len);
- pr_debug("off %d, pay len %d\n",
- proto->offset_len_in_hdr, payload_len);
- continue;
- } /* end of switch rx_state */
- }
-
- /* end of if rx_count */
- /* Check first byte of packet and identify module
- * owner (BT/FM/GPS) */
- switch (*ptr) {
- case LL_SLEEP_IND:
- case LL_SLEEP_ACK:
- case LL_WAKE_UP_IND:
- pr_debug("PM packet");
- /* this takes appropriate action based on
- * sleep state received --
- */
- st_ll_sleep_state(st_gdata, *ptr);
- /* if WAKEUP_IND collides copy from waitq to txq
- * and assume chip awake
- */
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- if (st_ll_getstate(st_gdata) == ST_LL_AWAKE)
- st_wakeup_ack(st_gdata, LL_WAKE_UP_ACK);
- spin_lock_irqsave(&st_gdata->lock, flags);
-
- ptr++;
- count--;
- continue;
- case LL_WAKE_UP_ACK:
- pr_debug("PM packet");
-
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- /* wake up ack received */
- st_wakeup_ack(st_gdata, *ptr);
- spin_lock_irqsave(&st_gdata->lock, flags);
-
- ptr++;
- count--;
- continue;
- /* Unknow packet? */
- default:
- type = *ptr;
-
- /* Default case means non-HCILL packets,
- * possibilities are packets for:
- * (a) valid protocol - Supported Protocols within
- * the ST_MAX_CHANNELS.
- * (b) registered protocol - Checked by
- * "st_gdata->list[type] == NULL)" are supported
- * protocols only.
- * Rules out any invalid protocol and
- * unregistered protocols with channel ID < 16.
- */
-
- if ((type >= ST_MAX_CHANNELS) ||
- (st_gdata->list[type] == NULL)) {
- pr_err("chip/interface misbehavior: "
- "dropping frame starting "
- "with 0x%02x\n", type);
- goto done;
- }
-
- st_gdata->rx_skb = alloc_skb(
- st_gdata->list[type]->max_frame_size,
- GFP_ATOMIC);
- if (st_gdata->rx_skb == NULL) {
- pr_err("out of memory: dropping\n");
- goto done;
- }
-
- skb_reserve(st_gdata->rx_skb,
- st_gdata->list[type]->reserve);
- /* next 2 required for BT only */
- st_gdata->rx_skb->cb[0] = type; /*pkt_type*/
- st_gdata->rx_skb->cb[1] = 0; /*incoming*/
- st_gdata->rx_chnl = *ptr;
- st_gdata->rx_state = ST_W4_HEADER;
- st_gdata->rx_count = st_gdata->list[type]->hdr_len;
- pr_debug("rx_count %ld\n", st_gdata->rx_count);
- };
- ptr++;
- count--;
- }
-done:
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- pr_debug("done %s", __func__);
- return;
-}
-
-/**
- * st_int_dequeue - internal de-Q function.
- * If the previous data set was not written
- * completely, return that skb which has the pending data.
- * In normal cases, return top of txq.
- */
-static struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata)
-{
- struct sk_buff *returning_skb;
-
- pr_debug("%s", __func__);
- if (st_gdata->tx_skb != NULL) {
- returning_skb = st_gdata->tx_skb;
- st_gdata->tx_skb = NULL;
- return returning_skb;
- }
- return skb_dequeue(&st_gdata->txq);
-}
-
-/**
- * st_int_enqueue - internal Q-ing function.
- * Will either Q the skb to txq or the tx_waitq
- * depending on the ST LL state.
- * If the chip is asleep, then Q it onto waitq and
- * wakeup the chip.
- * txq and waitq needs protection since the other contexts
- * may be sending data, waking up chip.
- */
-static void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb)
-{
- unsigned long flags = 0;
-
- pr_debug("%s", __func__);
- spin_lock_irqsave(&st_gdata->lock, flags);
-
- switch (st_ll_getstate(st_gdata)) {
- case ST_LL_AWAKE:
- pr_debug("ST LL is AWAKE, sending normally");
- skb_queue_tail(&st_gdata->txq, skb);
- break;
- case ST_LL_ASLEEP_TO_AWAKE:
- skb_queue_tail(&st_gdata->tx_waitq, skb);
- break;
- case ST_LL_AWAKE_TO_ASLEEP:
- pr_err("ST LL is illegal state(%ld),"
- "purging received skb.", st_ll_getstate(st_gdata));
- kfree_skb(skb);
- break;
- case ST_LL_ASLEEP:
- skb_queue_tail(&st_gdata->tx_waitq, skb);
- st_ll_wakeup(st_gdata);
- break;
- default:
- pr_err("ST LL is illegal state(%ld),"
- "purging received skb.", st_ll_getstate(st_gdata));
- kfree_skb(skb);
- break;
- }
-
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- pr_debug("done %s", __func__);
- return;
-}
-
-/*
- * internal wakeup function
- * called from either
- * - TTY layer when write's finished
- * - st_write (in context of the protocol stack)
- */
-static void work_fn_write_wakeup(struct work_struct *work)
-{
- struct st_data_s *st_gdata = container_of(work, struct st_data_s,
- work_write_wakeup);
-
- st_tx_wakeup((void *)st_gdata);
-}
-void st_tx_wakeup(struct st_data_s *st_data)
-{
- struct sk_buff *skb;
- unsigned long flags; /* for irq save flags */
- pr_debug("%s", __func__);
- /* check for sending & set flag sending here */
- if (test_and_set_bit(ST_TX_SENDING, &st_data->tx_state)) {
- pr_debug("ST already sending");
- /* keep sending */
- set_bit(ST_TX_WAKEUP, &st_data->tx_state);
- return;
- /* TX_WAKEUP will be checked in another
- * context
- */
- }
- do { /* come back if st_tx_wakeup is set */
- /* woke-up to write */
- clear_bit(ST_TX_WAKEUP, &st_data->tx_state);
- while ((skb = st_int_dequeue(st_data))) {
- int len;
- spin_lock_irqsave(&st_data->lock, flags);
- /* enable wake-up from TTY */
- set_bit(TTY_DO_WRITE_WAKEUP, &st_data->tty->flags);
- len = st_int_write(st_data, skb->data, skb->len);
- skb_pull(skb, len);
- /* if skb->len = len as expected, skb->len=0 */
- if (skb->len) {
- /* would be the next skb to be sent */
- st_data->tx_skb = skb;
- spin_unlock_irqrestore(&st_data->lock, flags);
- break;
- }
- kfree_skb(skb);
- spin_unlock_irqrestore(&st_data->lock, flags);
- }
- /* if wake-up is set in another context- restart sending */
- } while (test_bit(ST_TX_WAKEUP, &st_data->tx_state));
-
- /* clear flag sending */
- clear_bit(ST_TX_SENDING, &st_data->tx_state);
-}
-
-/********************************************************************/
-/* functions called from ST KIM
-*/
-void kim_st_list_protocols(struct st_data_s *st_gdata, void *buf)
-{
- seq_printf(buf, "[%d]\nBT=%c\nFM=%c\nGPS=%c\n",
- st_gdata->protos_registered,
- st_gdata->is_registered[0x04] == true ? 'R' : 'U',
- st_gdata->is_registered[0x08] == true ? 'R' : 'U',
- st_gdata->is_registered[0x09] == true ? 'R' : 'U');
-}
-
-/********************************************************************/
-/*
- * functions called from protocol stack drivers
- * to be EXPORT-ed
- */
-long st_register(struct st_proto_s *new_proto)
-{
- struct st_data_s *st_gdata;
- long err = 0;
- unsigned long flags = 0;
-
- st_kim_ref(&st_gdata, 0);
- if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL
- || new_proto->reg_complete_cb == NULL) {
- pr_err("gdata/new_proto/recv or reg_complete_cb not ready");
- return -EINVAL;
- }
-
- if (new_proto->chnl_id >= ST_MAX_CHANNELS) {
- pr_err("chnl_id %d not supported", new_proto->chnl_id);
- return -EPROTONOSUPPORT;
- }
-
- if (st_gdata->is_registered[new_proto->chnl_id] == true) {
- pr_err("chnl_id %d already registered", new_proto->chnl_id);
- return -EALREADY;
- }
-
- /* can be from process context only */
- spin_lock_irqsave(&st_gdata->lock, flags);
-
- if (test_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state)) {
- pr_info(" ST_REG_IN_PROGRESS:%d ", new_proto->chnl_id);
- /* fw download in progress */
-
- add_channel_to_table(st_gdata, new_proto);
- st_gdata->protos_registered++;
- new_proto->write = st_write;
-
- set_bit(ST_REG_PENDING, &st_gdata->st_state);
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- return -EINPROGRESS;
- } else if (st_gdata->protos_registered == ST_EMPTY) {
- pr_info(" chnl_id list empty :%d ", new_proto->chnl_id);
- set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
- st_recv = st_kim_recv;
-
- /* enable the ST LL - to set default chip state */
- st_ll_enable(st_gdata);
-
- /* release lock previously held - re-locked below */
- spin_unlock_irqrestore(&st_gdata->lock, flags);
-
- /* this may take a while to complete
- * since it involves BT fw download
- */
- err = st_kim_start(st_gdata->kim_data);
- if (err != 0) {
- clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
- if ((st_gdata->protos_registered != ST_EMPTY) &&
- (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
- pr_err(" KIM failure complete callback ");
- spin_lock_irqsave(&st_gdata->lock, flags);
- st_reg_complete(st_gdata, err);
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- clear_bit(ST_REG_PENDING, &st_gdata->st_state);
- }
- return -EINVAL;
- }
-
- spin_lock_irqsave(&st_gdata->lock, flags);
-
- clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
- st_recv = st_int_recv;
-
- /* this is where all pending registration
- * are signalled to be complete by calling callback functions
- */
- if ((st_gdata->protos_registered != ST_EMPTY) &&
- (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
- pr_debug(" call reg complete callback ");
- st_reg_complete(st_gdata, 0);
- }
- clear_bit(ST_REG_PENDING, &st_gdata->st_state);
-
- /* check for already registered once more,
- * since the above check is old
- */
- if (st_gdata->is_registered[new_proto->chnl_id] == true) {
- pr_err(" proto %d already registered ",
- new_proto->chnl_id);
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- return -EALREADY;
- }
-
- add_channel_to_table(st_gdata, new_proto);
- st_gdata->protos_registered++;
- new_proto->write = st_write;
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- return err;
- }
- /* if fw is already downloaded & new stack registers protocol */
- else {
- add_channel_to_table(st_gdata, new_proto);
- st_gdata->protos_registered++;
- new_proto->write = st_write;
-
- /* lock already held before entering else */
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- return err;
- }
-}
-EXPORT_SYMBOL_GPL(st_register);
-
-/* to unregister a protocol -
- * to be called from protocol stack driver
- */
-long st_unregister(struct st_proto_s *proto)
-{
- long err = 0;
- unsigned long flags = 0;
- struct st_data_s *st_gdata;
-
- pr_debug("%s: %d ", __func__, proto->chnl_id);
-
- st_kim_ref(&st_gdata, 0);
- if (!st_gdata || proto->chnl_id >= ST_MAX_CHANNELS) {
- pr_err(" chnl_id %d not supported", proto->chnl_id);
- return -EPROTONOSUPPORT;
- }
-
- spin_lock_irqsave(&st_gdata->lock, flags);
-
- if (st_gdata->is_registered[proto->chnl_id] == false) {
- pr_err(" chnl_id %d not registered", proto->chnl_id);
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- return -EPROTONOSUPPORT;
- }
-
- if (st_gdata->protos_registered)
- st_gdata->protos_registered--;
-
- remove_channel_from_table(st_gdata, proto);
- spin_unlock_irqrestore(&st_gdata->lock, flags);
-
- if ((st_gdata->protos_registered == ST_EMPTY) &&
- (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
- pr_info(" all chnl_ids unregistered ");
-
- /* stop traffic on tty */
- if (st_gdata->tty) {
- tty_ldisc_flush(st_gdata->tty);
- stop_tty(st_gdata->tty);
- }
-
- /* all chnl_ids now unregistered */
- st_kim_stop(st_gdata->kim_data);
- /* disable ST LL */
- st_ll_disable(st_gdata);
- }
- return err;
-}
-
-/*
- * called in protocol stack drivers
- * via the write function pointer
- */
-long st_write(struct sk_buff *skb)
-{
- struct st_data_s *st_gdata;
- long len;
-
- st_kim_ref(&st_gdata, 0);
- if (unlikely(skb == NULL || st_gdata == NULL
- || st_gdata->tty == NULL)) {
- pr_err("data/tty unavailable to perform write");
- return -EINVAL;
- }
-
- pr_debug("%d to be written", skb->len);
- len = skb->len;
-
- /* st_ll to decide where to enqueue the skb */
- st_int_enqueue(st_gdata, skb);
- /* wake up */
- st_tx_wakeup(st_gdata);
-
- /* return number of bytes written */
- return len;
-}
-
-/* for protocols making use of shared transport */
-EXPORT_SYMBOL_GPL(st_unregister);
-
-/********************************************************************/
-/*
- * functions called from TTY layer
- */
-static int st_tty_open(struct tty_struct *tty)
-{
- int err = 0;
- struct st_data_s *st_gdata;
- pr_info("%s ", __func__);
-
- st_kim_ref(&st_gdata, 0);
- st_gdata->tty = tty;
- tty->disc_data = st_gdata;
-
- /* don't do an wakeup for now */
- clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-
- /* mem already allocated
- */
- tty->receive_room = 65536;
- /* Flush any pending characters in the driver and discipline. */
- tty_ldisc_flush(tty);
- tty_driver_flush_buffer(tty);
- /*
- * signal to UIM via KIM that -
- * installation of N_TI_WL ldisc is complete
- */
- st_kim_complete(st_gdata->kim_data);
- pr_debug("done %s", __func__);
- return err;
-}
-
-static void st_tty_close(struct tty_struct *tty)
-{
- unsigned char i = ST_MAX_CHANNELS;
- unsigned long flags = 0;
- struct st_data_s *st_gdata = tty->disc_data;
-
- pr_info("%s ", __func__);
-
- /* TODO:
- * if a protocol has been registered & line discipline
- * un-installed for some reason - what should be done ?
- */
- spin_lock_irqsave(&st_gdata->lock, flags);
- for (i = ST_BT; i < ST_MAX_CHANNELS; i++) {
- if (st_gdata->is_registered[i] == true)
- pr_err("%d not un-registered", i);
- st_gdata->list[i] = NULL;
- st_gdata->is_registered[i] = false;
- }
- st_gdata->protos_registered = 0;
- spin_unlock_irqrestore(&st_gdata->lock, flags);
- /*
- * signal to UIM via KIM that -
- * N_TI_WL ldisc is un-installed
- */
- st_kim_complete(st_gdata->kim_data);
- st_gdata->tty = NULL;
- /* Flush any pending characters in the driver and discipline. */
- tty_ldisc_flush(tty);
- tty_driver_flush_buffer(tty);
-
- spin_lock_irqsave(&st_gdata->lock, flags);
- /* empty out txq and tx_waitq */
- skb_queue_purge(&st_gdata->txq);
- skb_queue_purge(&st_gdata->tx_waitq);
- /* reset the TTY Rx states of ST */
- st_gdata->rx_count = 0;
- st_gdata->rx_state = ST_W4_PACKET_TYPE;
- kfree_skb(st_gdata->rx_skb);
- st_gdata->rx_skb = NULL;
- spin_unlock_irqrestore(&st_gdata->lock, flags);
-
- pr_debug("%s: done ", __func__);
-}
-
-static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
- char *tty_flags, int count)
-{
-#ifdef VERBOSE
- print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
- 16, 1, data, count, 0);
-#endif
-
- /*
- * if fw download is in progress then route incoming data
- * to KIM for validation
- */
- st_recv(tty->disc_data, data, count);
- pr_debug("done %s", __func__);
-}
-
-/* wake-up function called in from the TTY layer
- * inside the internal wakeup function will be called
- */
-static void st_tty_wakeup(struct tty_struct *tty)
-{
- struct st_data_s *st_gdata = tty->disc_data;
- pr_debug("%s ", __func__);
- /* don't do an wakeup for now */
- clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-
- /*
- * schedule the internal wakeup instead of calling directly to
- * avoid lockup (port->lock needed in tty->ops->write is
- * already taken here
- */
- schedule_work(&st_gdata->work_write_wakeup);
-}
-
-static void st_tty_flush_buffer(struct tty_struct *tty)
-{
- struct st_data_s *st_gdata = tty->disc_data;
- pr_debug("%s ", __func__);
-
- kfree_skb(st_gdata->tx_skb);
- st_gdata->tx_skb = NULL;
-
- tty_driver_flush_buffer(tty);
- return;
-}
-
-static struct tty_ldisc_ops st_ldisc_ops = {
- .magic = TTY_LDISC_MAGIC,
- .name = "n_st",
- .open = st_tty_open,
- .close = st_tty_close,
- .receive_buf = st_tty_receive,
- .write_wakeup = st_tty_wakeup,
- .flush_buffer = st_tty_flush_buffer,
- .owner = THIS_MODULE
-};
-
-/********************************************************************/
-int st_core_init(struct st_data_s **core_data)
-{
- struct st_data_s *st_gdata;
- long err;
-
- err = tty_register_ldisc(N_TI_WL, &st_ldisc_ops);
- if (err) {
- pr_err("error registering %d line discipline %ld",
- N_TI_WL, err);
- return err;
- }
- pr_debug("registered n_shared line discipline");
-
- st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL);
- if (!st_gdata) {
- pr_err("memory allocation failed");
- err = tty_unregister_ldisc(N_TI_WL);
- if (err)
- pr_err("unable to un-register ldisc %ld", err);
- err = -ENOMEM;
- return err;
- }
-
- /* Initialize ST TxQ and Tx waitQ queue head. All BT/FM/GPS module skb's
- * will be pushed in this queue for actual transmission.
- */
- skb_queue_head_init(&st_gdata->txq);
- skb_queue_head_init(&st_gdata->tx_waitq);
-
- /* Locking used in st_int_enqueue() to avoid multiple execution */
- spin_lock_init(&st_gdata->lock);
-
- err = st_ll_init(st_gdata);
- if (err) {
- pr_err("error during st_ll initialization(%ld)", err);
- kfree(st_gdata);
- err = tty_unregister_ldisc(N_TI_WL);
- if (err)
- pr_err("unable to un-register ldisc");
- return err;
- }
-
- INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup);
-
- *core_data = st_gdata;
- return 0;
-}
-
-void st_core_exit(struct st_data_s *st_gdata)
-{
- long err;
- /* internal module cleanup */
- err = st_ll_deinit(st_gdata);
- if (err)
- pr_err("error during deinit of ST LL %ld", err);
-
- if (st_gdata != NULL) {
- /* Free ST Tx Qs and skbs */
- skb_queue_purge(&st_gdata->txq);
- skb_queue_purge(&st_gdata->tx_waitq);
- kfree_skb(st_gdata->rx_skb);
- kfree_skb(st_gdata->tx_skb);
- /* TTY ldisc cleanup */
- err = tty_unregister_ldisc(N_TI_WL);
- if (err)
- pr_err("unable to un-register ldisc %ld", err);
- /* free the global data pointer */
- kfree(st_gdata);
- }
-}
diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
deleted file mode 100644
index 1874ac922166..000000000000
--- a/drivers/misc/ti-st/st_kim.c
+++ /dev/null
@@ -1,868 +0,0 @@
-/*
- * Shared Transport Line discipline driver Core
- * Init Manager module responsible for GPIO control
- * and firmware download
- * Copyright (C) 2009-2010 Texas Instruments
- * Author: Pavan Savoy <[email protected]>
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#define pr_fmt(fmt) "(stk) :" fmt
-#include <linux/platform_device.h>
-#include <linux/jiffies.h>
-#include <linux/firmware.h>
-#include <linux/delay.h>
-#include <linux/wait.h>
-#include <linux/gpio.h>
-#include <linux/debugfs.h>
-#include <linux/seq_file.h>
-#include <linux/sched.h>
-#include <linux/sysfs.h>
-#include <linux/tty.h>
-
-#include <linux/skbuff.h>
-#include <linux/ti_wilink_st.h>
-#include <linux/module.h>
-
-#define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */
-static struct platform_device *st_kim_devices[MAX_ST_DEVICES];
-
-/**********************************************************************/
-/* internal functions */
-
-/**
- * st_get_plat_device -
- * function which returns the reference to the platform device
- * requested by id. As of now only 1 such device exists (id=0)
- * the context requesting for reference can get the id to be
- * requested by a. The protocol driver which is registering or
- * b. the tty device which is opened.
- */
-static struct platform_device *st_get_plat_device(int id)
-{
- return st_kim_devices[id];
-}
-
-/**
- * validate_firmware_response -
- * function to return whether the firmware response was proper
- * in case of error don't complete so that waiting for proper
- * response times out
- */
-static void validate_firmware_response(struct kim_data_s *kim_gdata)
-{
- struct sk_buff *skb = kim_gdata->rx_skb;
- if (!skb)
- return;
-
- /* these magic numbers are the position in the response buffer which
- * allows us to distinguish whether the response is for the read
- * version info. command
- */
- if (skb->data[2] == 0x01 && skb->data[3] == 0x01 &&
- skb->data[4] == 0x10 && skb->data[5] == 0x00) {
- /* fw version response */
- memcpy(kim_gdata->resp_buffer,
- kim_gdata->rx_skb->data,
- kim_gdata->rx_skb->len);
- kim_gdata->rx_state = ST_W4_PACKET_TYPE;
- kim_gdata->rx_skb = NULL;
- kim_gdata->rx_count = 0;
- } else if (unlikely(skb->data[5] != 0)) {
- pr_err("no proper response during fw download");
- pr_err("data6 %x", skb->data[5]);
- kfree_skb(skb);
- return; /* keep waiting for the proper response */
- }
- /* becos of all the script being downloaded */
- complete_all(&kim_gdata->kim_rcvd);
- kfree_skb(skb);
-}
-
-/* check for data len received inside kim_int_recv
- * most often hit the last case to update state to waiting for data
- */
-static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len)
-{
- register int room = skb_tailroom(kim_gdata->rx_skb);
-
- pr_debug("len %d room %d", len, room);
-
- if (!len) {
- validate_firmware_response(kim_gdata);
- } else if (len > room) {
- /* Received packet's payload length is larger.
- * We can't accommodate it in created skb.
- */
- pr_err("Data length is too large len %d room %d", len,
- room);
- kfree_skb(kim_gdata->rx_skb);
- } else {
- /* Packet header has non-zero payload length and
- * we have enough space in created skb. Lets read
- * payload data */
- kim_gdata->rx_state = ST_W4_DATA;
- kim_gdata->rx_count = len;
- return len;
- }
-
- /* Change ST LL state to continue to process next
- * packet */
- kim_gdata->rx_state = ST_W4_PACKET_TYPE;
- kim_gdata->rx_skb = NULL;
- kim_gdata->rx_count = 0;
-
- return 0;
-}
-
-/**
- * kim_int_recv - receive function called during firmware download
- * firmware download responses on different UART drivers
- * have been observed to come in bursts of different
- * tty_receive and hence the logic
- */
-static void kim_int_recv(struct kim_data_s *kim_gdata,
- const unsigned char *data, long count)
-{
- const unsigned char *ptr;
- int len = 0;
- unsigned char *plen;
-
- pr_debug("%s", __func__);
- /* Decode received bytes here */
- ptr = data;
- if (unlikely(ptr == NULL)) {
- pr_err(" received null from TTY ");
- return;
- }
-
- while (count) {
- if (kim_gdata->rx_count) {
- len = min_t(unsigned int, kim_gdata->rx_count, count);
- skb_put_data(kim_gdata->rx_skb, ptr, len);
- kim_gdata->rx_count -= len;
- count -= len;
- ptr += len;
-
- if (kim_gdata->rx_count)
- continue;
-
- /* Check ST RX state machine , where are we? */
- switch (kim_gdata->rx_state) {
- /* Waiting for complete packet ? */
- case ST_W4_DATA:
- pr_debug("Complete pkt received");
- validate_firmware_response(kim_gdata);
- kim_gdata->rx_state = ST_W4_PACKET_TYPE;
- kim_gdata->rx_skb = NULL;
- continue;
- /* Waiting for Bluetooth event header ? */
- case ST_W4_HEADER:
- plen =
- (unsigned char *)&kim_gdata->rx_skb->data[1];
- pr_debug("event hdr: plen 0x%02x\n", *plen);
- kim_check_data_len(kim_gdata, *plen);
- continue;
- } /* end of switch */
- } /* end of if rx_state */
- switch (*ptr) {
- /* Bluetooth event packet? */
- case 0x04:
- kim_gdata->rx_state = ST_W4_HEADER;
- kim_gdata->rx_count = 2;
- break;
- default:
- pr_info("unknown packet");
- ptr++;
- count--;
- continue;
- }
- ptr++;
- count--;
- kim_gdata->rx_skb =
- alloc_skb(1024+8, GFP_ATOMIC);
- if (!kim_gdata->rx_skb) {
- pr_err("can't allocate mem for new packet");
- kim_gdata->rx_state = ST_W4_PACKET_TYPE;
- kim_gdata->rx_count = 0;
- return;
- }
- skb_reserve(kim_gdata->rx_skb, 8);
- kim_gdata->rx_skb->cb[0] = 4;
- kim_gdata->rx_skb->cb[1] = 0;
-
- }
- return;
-}
-
-static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
-{
- unsigned short version = 0, chip = 0, min_ver = 0, maj_ver = 0;
- const char read_ver_cmd[] = { 0x01, 0x01, 0x10, 0x00 };
- long timeout;
-
- pr_debug("%s", __func__);
-
- reinit_completion(&kim_gdata->kim_rcvd);
- if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) {
- pr_err("kim: couldn't write 4 bytes");
- return -EIO;
- }
-
- timeout = wait_for_completion_interruptible_timeout(
- &kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME));
- if (timeout <= 0) {
- pr_err(" waiting for ver info- timed out or received signal");
- return timeout ? -ERESTARTSYS : -ETIMEDOUT;
- }
- reinit_completion(&kim_gdata->kim_rcvd);
- /* the positions 12 & 13 in the response buffer provide with the
- * chip, major & minor numbers
- */
-
- version =
- MAKEWORD(kim_gdata->resp_buffer[12],
- kim_gdata->resp_buffer[13]);
- chip = (version & 0x7C00) >> 10;
- min_ver = (version & 0x007F);
- maj_ver = (version & 0x0380) >> 7;
-
- if (version & 0x8000)
- maj_ver |= 0x0008;
-
- sprintf(bts_scr_name, "ti-connectivity/TIInit_%d.%d.%d.bts",
- chip, maj_ver, min_ver);
-
- /* to be accessed later via sysfs entry */
- kim_gdata->version.full = version;
- kim_gdata->version.chip = chip;
- kim_gdata->version.maj_ver = maj_ver;
- kim_gdata->version.min_ver = min_ver;
-
- pr_info("%s", bts_scr_name);
- return 0;
-}
-
-static void skip_change_remote_baud(unsigned char **ptr, long *len)
-{
- unsigned char *nxt_action, *cur_action;
- cur_action = *ptr;
-
- nxt_action = cur_action + sizeof(struct bts_action) +
- ((struct bts_action *) cur_action)->size;
-
- if (((struct bts_action *) nxt_action)->type != ACTION_WAIT_EVENT) {
- pr_err("invalid action after change remote baud command");
- } else {
- *ptr = *ptr + sizeof(struct bts_action) +
- ((struct bts_action *)cur_action)->size;
- *len = *len - (sizeof(struct bts_action) +
- ((struct bts_action *)cur_action)->size);
- /* warn user on not commenting these in firmware */
- pr_warn("skipping the wait event of change remote baud");
- }
-}
-
-/**
- * download_firmware -
- * internal function which parses through the .bts firmware
- * script file intreprets SEND, DELAY actions only as of now
- */
-static long download_firmware(struct kim_data_s *kim_gdata)
-{
- long err = 0;
- long len = 0;
- unsigned char *ptr = NULL;
- unsigned char *action_ptr = NULL;
- unsigned char bts_scr_name[40] = { 0 }; /* 40 char long bts scr name? */
- int wr_room_space;
- int cmd_size;
- unsigned long timeout;
-
- err = read_local_version(kim_gdata, bts_scr_name);
- if (err != 0) {
- pr_err("kim: failed to read local ver");
- return err;
- }
- err =
- request_firmware(&kim_gdata->fw_entry, bts_scr_name,
- &kim_gdata->kim_pdev->dev);
- if (unlikely((err != 0) || (kim_gdata->fw_entry->data == NULL) ||
- (kim_gdata->fw_entry->size == 0))) {
- pr_err(" request_firmware failed(errno %ld) for %s", err,
- bts_scr_name);
- return -EINVAL;
- }
- ptr = (void *)kim_gdata->fw_entry->data;
- len = kim_gdata->fw_entry->size;
- /* bts_header to remove out magic number and
- * version
- */
- ptr += sizeof(struct bts_header);
- len -= sizeof(struct bts_header);
-
- while (len > 0 && ptr) {
- pr_debug(" action size %d, type %d ",
- ((struct bts_action *)ptr)->size,
- ((struct bts_action *)ptr)->type);
-
- switch (((struct bts_action *)ptr)->type) {
- case ACTION_SEND_COMMAND: /* action send */
- pr_debug("S");
- action_ptr = &(((struct bts_action *)ptr)->data[0]);
- if (unlikely
- (((struct hci_command *)action_ptr)->opcode ==
- 0xFF36)) {
- /* ignore remote change
- * baud rate HCI VS command */
- pr_warn("change remote baud"
- " rate command in firmware");
- skip_change_remote_baud(&ptr, &len);
- break;
- }
- /*
- * Make sure we have enough free space in uart
- * tx buffer to write current firmware command
- */
- cmd_size = ((struct bts_action *)ptr)->size;
- timeout = jiffies + msecs_to_jiffies(CMD_WR_TIME);
- do {
- wr_room_space =
- st_get_uart_wr_room(kim_gdata->core_data);
- if (wr_room_space < 0) {
- pr_err("Unable to get free "
- "space info from uart tx buffer");
- release_firmware(kim_gdata->fw_entry);
- return wr_room_space;
- }
- mdelay(1); /* wait 1ms before checking room */
- } while ((wr_room_space < cmd_size) &&
- time_before(jiffies, timeout));
-
- /* Timeout happened ? */
- if (time_after_eq(jiffies, timeout)) {
- pr_err("Timeout while waiting for free "
- "free space in uart tx buffer");
- release_firmware(kim_gdata->fw_entry);
- return -ETIMEDOUT;
- }
- /* reinit completion before sending for the
- * relevant wait
- */
- reinit_completion(&kim_gdata->kim_rcvd);
-
- /*
- * Free space found in uart buffer, call st_int_write
- * to send current firmware command to the uart tx
- * buffer.
- */
- err = st_int_write(kim_gdata->core_data,
- ((struct bts_action_send *)action_ptr)->data,
- ((struct bts_action *)ptr)->size);
- if (unlikely(err < 0)) {
- release_firmware(kim_gdata->fw_entry);
- return err;
- }
- /*
- * Check number of bytes written to the uart tx buffer
- * and requested command write size
- */
- if (err != cmd_size) {
- pr_err("Number of bytes written to uart "
- "tx buffer are not matching with "
- "requested cmd write size");
- release_firmware(kim_gdata->fw_entry);
- return -EIO;
- }
- break;
- case ACTION_WAIT_EVENT: /* wait */
- pr_debug("W");
- err = wait_for_completion_interruptible_timeout(
- &kim_gdata->kim_rcvd,
- msecs_to_jiffies(CMD_RESP_TIME));
- if (err <= 0) {
- pr_err("response timeout/signaled during fw download ");
- /* timed out */
- release_firmware(kim_gdata->fw_entry);
- return err ? -ERESTARTSYS : -ETIMEDOUT;
- }
- reinit_completion(&kim_gdata->kim_rcvd);
- break;
- case ACTION_DELAY: /* sleep */
- pr_info("sleep command in scr");
- action_ptr = &(((struct bts_action *)ptr)->data[0]);
- mdelay(((struct bts_action_delay *)action_ptr)->msec);
- break;
- }
- len =
- len - (sizeof(struct bts_action) +
- ((struct bts_action *)ptr)->size);
- ptr =
- ptr + sizeof(struct bts_action) +
- ((struct bts_action *)ptr)->size;
- }
- /* fw download complete */
- release_firmware(kim_gdata->fw_entry);
- return 0;
-}
-
-/**********************************************************************/
-/* functions called from ST core */
-/* called from ST Core, when REG_IN_PROGRESS (registration in progress)
- * can be because of
- * 1. response to read local version
- * 2. during send/recv's of firmware download
- */
-void st_kim_recv(void *disc_data, const unsigned char *data, long count)
-{
- struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
- struct kim_data_s *kim_gdata = st_gdata->kim_data;
-
- /* proceed to gather all data and distinguish read fw version response
- * from other fw responses when data gathering is complete
- */
- kim_int_recv(kim_gdata, data, count);
- return;
-}
-
-/* to signal completion of line discipline installation
- * called from ST Core, upon tty_open
- */
-void st_kim_complete(void *kim_data)
-{
- struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
- complete(&kim_gdata->ldisc_installed);
-}
-
-/**
- * st_kim_start - called from ST Core upon 1st registration
- * This involves toggling the chip enable gpio, reading
- * the firmware version from chip, forming the fw file name
- * based on the chip version, requesting the fw, parsing it
- * and perform download(send/recv).
- */
-long st_kim_start(void *kim_data)
-{
- long err = 0;
- long retry = POR_RETRY_COUNT;
- struct ti_st_plat_data *pdata;
- struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
-
- pr_info(" %s", __func__);
- pdata = kim_gdata->kim_pdev->dev.platform_data;
-
- do {
- /* platform specific enabling code here */
- if (pdata->chip_enable)
- pdata->chip_enable(kim_gdata);
-
- /* Configure BT nShutdown to HIGH state */
- gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_LOW);
- mdelay(5); /* FIXME: a proper toggle */
- gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_HIGH);
- mdelay(100);
- /* re-initialize the completion */
- reinit_completion(&kim_gdata->ldisc_installed);
- /* send notification to UIM */
- kim_gdata->ldisc_install = 1;
- pr_info("ldisc_install = 1");
- sysfs_notify(&kim_gdata->kim_pdev->dev.kobj,
- NULL, "install");
- /* wait for ldisc to be installed */
- err = wait_for_completion_interruptible_timeout(
- &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME));
- if (!err) {
- /* ldisc installation timeout,
- * flush uart, power cycle BT_EN */
- pr_err("ldisc installation timeout");
- err = st_kim_stop(kim_gdata);
- continue;
- } else {
- /* ldisc installed now */
- pr_info("line discipline installed");
- err = download_firmware(kim_gdata);
- if (err != 0) {
- /* ldisc installed but fw download failed,
- * flush uart & power cycle BT_EN */
- pr_err("download firmware failed");
- err = st_kim_stop(kim_gdata);
- continue;
- } else { /* on success don't retry */
- break;
- }
- }
- } while (retry--);
- return err;
-}
-
-/**
- * st_kim_stop - stop communication with chip.
- * This can be called from ST Core/KIM, on the-
- * (a) last un-register when chip need not be powered there-after,
- * (b) upon failure to either install ldisc or download firmware.
- * The function is responsible to (a) notify UIM about un-installation,
- * (b) flush UART if the ldisc was installed.
- * (c) reset BT_EN - pull down nshutdown at the end.
- * (d) invoke platform's chip disabling routine.
- */
-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 tty_struct *tty = kim_gdata->core_data->tty;
-
- reinit_completion(&kim_gdata->ldisc_installed);
-
- if (tty) { /* can be called before ldisc is installed */
- /* Flush any pending characters in the driver and discipline. */
- tty_ldisc_flush(tty);
- tty_driver_flush_buffer(tty);
- }
-
- /* send uninstall notification to UIM */
- pr_info("ldisc_install = 0");
- kim_gdata->ldisc_install = 0;
- sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install");
-
- /* wait for ldisc to be un-installed */
- err = wait_for_completion_interruptible_timeout(
- &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME));
- if (!err) { /* timeout */
- pr_err(" timed out waiting for ldisc to be un-installed");
- err = -ETIMEDOUT;
- }
-
- /* By default configure BT nShutdown to LOW state */
- gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_LOW);
- mdelay(1);
- gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_HIGH);
- mdelay(1);
- gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_LOW);
-
- /* platform specific disable */
- if (pdata->chip_disable)
- pdata->chip_disable(kim_gdata);
- return err;
-}
-
-/**********************************************************************/
-/* functions called from subsystems */
-/* called when debugfs entry is read from */
-
-static int show_version(struct seq_file *s, void *unused)
-{
- struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private;
- seq_printf(s, "%04X %d.%d.%d\n", kim_gdata->version.full,
- kim_gdata->version.chip, kim_gdata->version.maj_ver,
- kim_gdata->version.min_ver);
- return 0;
-}
-
-static int show_list(struct seq_file *s, void *unused)
-{
- struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private;
- kim_st_list_protocols(kim_gdata->core_data, s);
- return 0;
-}
-
-static ssize_t show_install(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct kim_data_s *kim_data = dev_get_drvdata(dev);
- return sprintf(buf, "%d\n", kim_data->ldisc_install);
-}
-
-#ifdef DEBUG
-static ssize_t store_dev_name(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
-{
- struct kim_data_s *kim_data = dev_get_drvdata(dev);
- pr_debug("storing dev name >%s<", buf);
- strncpy(kim_data->dev_name, buf, count);
- pr_debug("stored dev name >%s<", kim_data->dev_name);
- return count;
-}
-
-static ssize_t store_baud_rate(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
-{
- struct kim_data_s *kim_data = dev_get_drvdata(dev);
- pr_debug("storing baud rate >%s<", buf);
- sscanf(buf, "%ld", &kim_data->baud_rate);
- pr_debug("stored baud rate >%ld<", kim_data->baud_rate);
- return count;
-}
-#endif /* if DEBUG */
-
-static ssize_t show_dev_name(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct kim_data_s *kim_data = dev_get_drvdata(dev);
- return sprintf(buf, "%s\n", kim_data->dev_name);
-}
-
-static ssize_t show_baud_rate(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct kim_data_s *kim_data = dev_get_drvdata(dev);
- return sprintf(buf, "%d\n", kim_data->baud_rate);
-}
-
-static ssize_t show_flow_cntrl(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct kim_data_s *kim_data = dev_get_drvdata(dev);
- return sprintf(buf, "%d\n", kim_data->flow_cntrl);
-}
-
-/* structures specific for sysfs entries */
-static struct kobj_attribute ldisc_install =
-__ATTR(install, 0444, (void *)show_install, NULL);
-
-static struct kobj_attribute uart_dev_name =
-#ifdef DEBUG /* TODO: move this to debug-fs if possible */
-__ATTR(dev_name, 0644, (void *)show_dev_name, (void *)store_dev_name);
-#else
-__ATTR(dev_name, 0444, (void *)show_dev_name, NULL);
-#endif
-
-static struct kobj_attribute uart_baud_rate =
-#ifdef DEBUG /* TODO: move to debugfs */
-__ATTR(baud_rate, 0644, (void *)show_baud_rate, (void *)store_baud_rate);
-#else
-__ATTR(baud_rate, 0444, (void *)show_baud_rate, NULL);
-#endif
-
-static struct kobj_attribute uart_flow_cntrl =
-__ATTR(flow_cntrl, 0444, (void *)show_flow_cntrl, NULL);
-
-static struct attribute *uim_attrs[] = {
- &ldisc_install.attr,
- &uart_dev_name.attr,
- &uart_baud_rate.attr,
- &uart_flow_cntrl.attr,
- NULL,
-};
-
-static const struct attribute_group uim_attr_grp = {
- .attrs = uim_attrs,
-};
-
-/**
- * st_kim_ref - reference the core's data
- * This references the per-ST platform device in the arch/xx/
- * board-xx.c file.
- * This would enable multiple such platform devices to exist
- * on a given platform
- */
-void st_kim_ref(struct st_data_s **core_data, int id)
-{
- struct platform_device *pdev;
- struct kim_data_s *kim_gdata;
- /* get kim_gdata reference from platform device */
- pdev = st_get_plat_device(id);
- if (!pdev)
- goto err;
- kim_gdata = platform_get_drvdata(pdev);
- if (!kim_gdata)
- goto err;
-
- *core_data = kim_gdata->core_data;
- return;
-err:
- *core_data = NULL;
-}
-
-static int kim_version_open(struct inode *i, struct file *f)
-{
- return single_open(f, show_version, i->i_private);
-}
-
-static int kim_list_open(struct inode *i, struct file *f)
-{
- return single_open(f, show_list, i->i_private);
-}
-
-static const struct file_operations version_debugfs_fops = {
- /* version info */
- .open = kim_version_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-static const struct file_operations list_debugfs_fops = {
- /* protocols info */
- .open = kim_list_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-/**********************************************************************/
-/* functions called from platform device driver subsystem
- * need to have a relevant platform device entry in the platform's
- * board-*.c file
- */
-
-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;
- int err;
-
- if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) {
- /* multiple devices could exist */
- st_kim_devices[pdev->id] = pdev;
- } else {
- /* platform's sure about existence of 1 device */
- st_kim_devices[0] = pdev;
- }
-
- kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_KERNEL);
- if (!kim_gdata) {
- pr_err("no mem to allocate");
- return -ENOMEM;
- }
- platform_set_drvdata(pdev, kim_gdata);
-
- err = st_core_init(&kim_gdata->core_data);
- if (err != 0) {
- pr_err(" ST core init failed");
- err = -EIO;
- goto err_core_init;
- }
- /* refer to itself */
- kim_gdata->core_data->kim_data = kim_gdata;
-
- /* Claim the chip enable nShutdown gpio from the system */
- kim_gdata->nshutdown = pdata->nshutdown_gpio;
- err = gpio_request(kim_gdata->nshutdown, "kim");
- if (unlikely(err)) {
- pr_err(" gpio %d request failed ", kim_gdata->nshutdown);
- goto err_sysfs_group;
- }
-
- /* Configure nShutdown GPIO as output=0 */
- err = gpio_direction_output(kim_gdata->nshutdown, 0);
- if (unlikely(err)) {
- pr_err(" unable to configure gpio %d", kim_gdata->nshutdown);
- goto err_sysfs_group;
- }
- /* get reference of pdev for request_firmware
- */
- kim_gdata->kim_pdev = pdev;
- init_completion(&kim_gdata->kim_rcvd);
- init_completion(&kim_gdata->ldisc_installed);
-
- err = sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp);
- if (err) {
- pr_err("failed to create sysfs entries");
- goto err_sysfs_group;
- }
-
- /* copying platform data */
- strncpy(kim_gdata->dev_name, pdata->dev_name, UART_DEV_NAME_LEN);
- kim_gdata->flow_cntrl = pdata->flow_cntrl;
- kim_gdata->baud_rate = pdata->baud_rate;
- pr_info("sysfs entries created\n");
-
- kim_debugfs_dir = debugfs_create_dir("ti-st", NULL);
- if (!kim_debugfs_dir) {
- pr_err(" debugfs entries creation failed ");
- return 0;
- }
-
- debugfs_create_file("version", S_IRUGO, kim_debugfs_dir,
- kim_gdata, &version_debugfs_fops);
- debugfs_create_file("protocols", S_IRUGO, kim_debugfs_dir,
- kim_gdata, &list_debugfs_fops);
- return 0;
-
-err_sysfs_group:
- st_core_exit(kim_gdata->core_data);
-
-err_core_init:
- kfree(kim_gdata);
-
- return err;
-}
-
-static int kim_remove(struct platform_device *pdev)
-{
- /* free the GPIOs requested */
- struct ti_st_plat_data *pdata = pdev->dev.platform_data;
- struct kim_data_s *kim_gdata;
-
- kim_gdata = platform_get_drvdata(pdev);
-
- /* Free the Bluetooth/FM/GPIO
- * nShutdown gpio from the system
- */
- gpio_free(pdata->nshutdown_gpio);
- pr_info("nshutdown GPIO Freed");
-
- debugfs_remove_recursive(kim_debugfs_dir);
- sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp);
- pr_info("sysfs entries removed");
-
- kim_gdata->kim_pdev = NULL;
- st_core_exit(kim_gdata->core_data);
-
- kfree(kim_gdata);
- kim_gdata = 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;
-
- if (pdata->suspend)
- return pdata->suspend(pdev, state);
-
- return 0;
-}
-
-static int kim_resume(struct platform_device *pdev)
-{
- struct ti_st_plat_data *pdata = pdev->dev.platform_data;
-
- if (pdata->resume)
- return pdata->resume(pdev);
-
- return 0;
-}
-
-/**********************************************************************/
-/* entry point for ST KIM module, called in from ST Core */
-static struct platform_driver kim_platform_driver = {
- .probe = kim_probe,
- .remove = kim_remove,
- .suspend = kim_suspend,
- .resume = kim_resume,
- .driver = {
- .name = "kim",
- },
-};
-
-module_platform_driver(kim_platform_driver);
-
-MODULE_AUTHOR("Pavan Savoy <[email protected]>");
-MODULE_DESCRIPTION("Shared Transport Driver for TI BT/FM/GPS combo chips ");
-MODULE_LICENSE("GPL");
diff --git a/drivers/misc/ti-st/st_ll.c b/drivers/misc/ti-st/st_ll.c
deleted file mode 100644
index 93b4d67cc4a3..000000000000
--- a/drivers/misc/ti-st/st_ll.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Shared Transport driver
- * HCI-LL module responsible for TI proprietary HCI_LL protocol
- * Copyright (C) 2009-2010 Texas Instruments
- * Author: Pavan Savoy <[email protected]>
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#define pr_fmt(fmt) "(stll) :" fmt
-#include <linux/skbuff.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/ti_wilink_st.h>
-
-/**********************************************************************/
-/* internal functions */
-static void send_ll_cmd(struct st_data_s *st_data,
- unsigned char cmd)
-{
-
- pr_debug("%s: writing %x", __func__, cmd);
- st_int_write(st_data, &cmd, 1);
- return;
-}
-
-static void ll_device_want_to_sleep(struct st_data_s *st_data)
-{
- struct kim_data_s *kim_data;
- struct ti_st_plat_data *pdata;
-
- pr_debug("%s", __func__);
- /* sanity check */
- if (st_data->ll_state != ST_LL_AWAKE)
- pr_err("ERR hcill: ST_LL_GO_TO_SLEEP_IND"
- "in state %ld", st_data->ll_state);
-
- send_ll_cmd(st_data, LL_SLEEP_ACK);
- /* update state */
- st_data->ll_state = ST_LL_ASLEEP;
-
- /* communicate to platform about chip asleep */
- kim_data = st_data->kim_data;
- pdata = kim_data->kim_pdev->dev.platform_data;
- if (pdata->chip_asleep)
- pdata->chip_asleep(NULL);
-}
-
-static void ll_device_want_to_wakeup(struct st_data_s *st_data)
-{
- struct kim_data_s *kim_data;
- struct ti_st_plat_data *pdata;
-
- /* diff actions in diff states */
- switch (st_data->ll_state) {
- case ST_LL_ASLEEP:
- send_ll_cmd(st_data, LL_WAKE_UP_ACK); /* send wake_ack */
- break;
- case ST_LL_ASLEEP_TO_AWAKE:
- /* duplicate wake_ind */
- pr_err("duplicate wake_ind while waiting for Wake ack");
- break;
- case ST_LL_AWAKE:
- /* duplicate wake_ind */
- pr_err("duplicate wake_ind already AWAKE");
- break;
- case ST_LL_AWAKE_TO_ASLEEP:
- /* duplicate wake_ind */
- pr_err("duplicate wake_ind");
- break;
- }
- /* update state */
- st_data->ll_state = ST_LL_AWAKE;
-
- /* communicate to platform about chip wakeup */
- kim_data = st_data->kim_data;
- pdata = kim_data->kim_pdev->dev.platform_data;
- if (pdata->chip_awake)
- pdata->chip_awake(NULL);
-}
-
-/**********************************************************************/
-/* functions invoked by ST Core */
-
-/* called when ST Core wants to
- * enable ST LL */
-void st_ll_enable(struct st_data_s *ll)
-{
- ll->ll_state = ST_LL_AWAKE;
-}
-
-/* called when ST Core /local module wants to
- * disable ST LL */
-void st_ll_disable(struct st_data_s *ll)
-{
- ll->ll_state = ST_LL_INVALID;
-}
-
-/* called when ST Core wants to update the state */
-void st_ll_wakeup(struct st_data_s *ll)
-{
- if (likely(ll->ll_state != ST_LL_AWAKE)) {
- send_ll_cmd(ll, LL_WAKE_UP_IND); /* WAKE_IND */
- ll->ll_state = ST_LL_ASLEEP_TO_AWAKE;
- } else {
- /* don't send the duplicate wake_indication */
- pr_err(" Chip already AWAKE ");
- }
-}
-
-/* called when ST Core wants the state */
-unsigned long st_ll_getstate(struct st_data_s *ll)
-{
- pr_debug(" returning state %ld", ll->ll_state);
- return ll->ll_state;
-}
-
-/* called from ST Core, when a PM related packet arrives */
-unsigned long st_ll_sleep_state(struct st_data_s *st_data,
- unsigned char cmd)
-{
- switch (cmd) {
- case LL_SLEEP_IND: /* sleep ind */
- pr_debug("sleep indication recvd");
- ll_device_want_to_sleep(st_data);
- break;
- case LL_SLEEP_ACK: /* sleep ack */
- pr_err("sleep ack rcvd: host shouldn't");
- break;
- case LL_WAKE_UP_IND: /* wake ind */
- pr_debug("wake indication recvd");
- ll_device_want_to_wakeup(st_data);
- break;
- case LL_WAKE_UP_ACK: /* wake ack */
- pr_debug("wake ack rcvd");
- st_data->ll_state = ST_LL_AWAKE;
- break;
- default:
- pr_err(" unknown input/state ");
- return -EINVAL;
- }
- return 0;
-}
-
-/* Called from ST CORE to initialize ST LL */
-long st_ll_init(struct st_data_s *ll)
-{
- /* set state to invalid */
- ll->ll_state = ST_LL_INVALID;
- return 0;
-}
-
-/* Called from ST CORE to de-initialize ST LL */
-long st_ll_deinit(struct st_data_s *ll)
-{
- return 0;
-}
diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
index a9de5654b0cd..76a372bdf540 100644
--- a/include/linux/ti_wilink_st.h
+++ b/include/linux/ti_wilink_st.h
@@ -27,268 +27,9 @@

#include <linux/skbuff.h>

-/**
- * enum proto-type - The protocol on WiLink chips which share a
- * common physical interface like UART.
- */
-enum proto_type {
- ST_BT,
- ST_FM,
- ST_GPS,
- ST_MAX_CHANNELS = 16,
-};
-
-/**
- * struct st_proto_s - Per Protocol structure from BT/FM/GPS to ST
- * @type: type of the protocol being registered among the
- * available proto_type(BT, FM, GPS the protocol which share TTY).
- * @recv: the receiver callback pointing to a function in the
- * protocol drivers called by the ST driver upon receiving
- * relevant data.
- * @match_packet: reserved for future use, to make ST more generic
- * @reg_complete_cb: callback handler pointing to a function in protocol
- * handler called by ST when the pending registrations are complete.
- * The registrations are marked pending, in situations when fw
- * download is in progress.
- * @write: pointer to function in ST provided to protocol drivers from ST,
- * to be made use when protocol drivers have data to send to TTY.
- * @priv_data: privdate data holder for the protocol drivers, sent
- * from the protocol drivers during registration, and sent back on
- * reg_complete_cb and recv.
- * @chnl_id: channel id the protocol driver is interested in, the channel
- * id is nothing but the 1st byte of the packet in UART frame.
- * @max_frame_size: size of the largest frame the protocol can receive.
- * @hdr_len: length of the header structure of the protocol.
- * @offset_len_in_hdr: this provides the offset of the length field in the
- * header structure of the protocol header, to assist ST to know
- * how much to receive, if the data is split across UART frames.
- * @len_size: whether the length field inside the header is 2 bytes
- * or 1 byte.
- * @reserve: the number of bytes ST needs to reserve in the skb being
- * prepared for the protocol driver.
- */
-struct st_proto_s {
- enum proto_type type;
- long (*recv) (void *, struct sk_buff *);
- unsigned char (*match_packet) (const unsigned char *data);
- void (*reg_complete_cb) (void *, int data);
- long (*write) (struct sk_buff *skb);
- void *priv_data;
-
- unsigned char chnl_id;
- unsigned short max_frame_size;
- unsigned char hdr_len;
- unsigned char offset_len_in_hdr;
- unsigned char len_size;
- unsigned char reserve;
-};
-
-extern long st_register(struct st_proto_s *);
-extern long st_unregister(struct st_proto_s *);
-
void hci_ti_set_fm_handler(struct device *dev, void (*recv_handler) (void *, struct sk_buff *), void *drvdata);
int hci_ti_fm_send(struct device *dev, struct sk_buff *skb);

-/*
- * header information used by st_core.c
- */
-
-/* states of protocol list */
-#define ST_NOTEMPTY 1
-#define ST_EMPTY 0
-
-/*
- * possible st_states
- */
-#define ST_INITIALIZING 1
-#define ST_REG_IN_PROGRESS 2
-#define ST_REG_PENDING 3
-#define ST_WAITING_FOR_RESP 4
-
-/**
- * struct st_data_s - ST core internal structure
- * @st_state: different states of ST like initializing, registration
- * in progress, this is mainly used to return relevant err codes
- * when protocol drivers are registering. It is also used to track
- * the recv function, as in during fw download only HCI events
- * can occur , where as during other times other events CH8, CH9
- * can occur.
- * @tty: tty provided by the TTY core for line disciplines.
- * @tx_skb: If for some reason the tty's write returns lesser bytes written
- * then to maintain the rest of data to be written on next instance.
- * This needs to be protected, hence the lock inside wakeup func.
- * @tx_state: if the data is being written onto the TTY and protocol driver
- * wants to send more, queue up data and mark that there is
- * more data to send.
- * @list: the list of protocols registered, only MAX can exist, one protocol
- * can register only once.
- * @rx_state: states to be maintained inside st's tty receive
- * @rx_count: count to be maintained inside st's tty receieve
- * @rx_skb: the skb where all data for a protocol gets accumulated,
- * since tty might not call receive when a complete event packet
- * is received, the states, count and the skb needs to be maintained.
- * @rx_chnl: the channel ID for which the data is getting accumalated for.
- * @txq: the list of skbs which needs to be sent onto the TTY.
- * @tx_waitq: if the chip is not in AWAKE state, the skbs needs to be queued
- * up in here, PM(WAKEUP_IND) data needs to be sent and then the skbs
- * from waitq can be moved onto the txq.
- * Needs locking too.
- * @lock: the lock to protect skbs, queues, and ST states.
- * @protos_registered: count of the protocols registered, also when 0 the
- * chip enable gpio can be toggled, and when it changes to 1 the fw
- * needs to be downloaded to initialize chip side ST.
- * @ll_state: the various PM states the chip can be, the states are notified
- * to us, when the chip sends relevant PM packets(SLEEP_IND, WAKE_IND).
- * @kim_data: reference to the parent encapsulating structure.
- *
- */
-struct st_data_s {
- unsigned long st_state;
- struct sk_buff *tx_skb;
-#define ST_TX_SENDING 1
-#define ST_TX_WAKEUP 2
- unsigned long tx_state;
- struct st_proto_s *list[ST_MAX_CHANNELS];
- bool is_registered[ST_MAX_CHANNELS];
- unsigned long rx_state;
- unsigned long rx_count;
- struct sk_buff *rx_skb;
- unsigned char rx_chnl;
- struct sk_buff_head txq, tx_waitq;
- spinlock_t lock;
- unsigned char protos_registered;
- unsigned long ll_state;
- void *kim_data;
- struct tty_struct *tty;
- struct work_struct work_write_wakeup;
-};
-
-/*
- * wrapper around tty->ops->write_room to check
- * availability during firmware download
- */
-int st_get_uart_wr_room(struct st_data_s *st_gdata);
-/**
- * st_int_write -
- * point this to tty->driver->write or tty->ops->write
- * depending upon the kernel version
- */
-int st_int_write(struct st_data_s*, const unsigned char*, int);
-
-/**
- * st_write -
- * internal write function, passed onto protocol drivers
- * via the write function ptr of protocol struct
- */
-long st_write(struct sk_buff *);
-
-/* function to be called from ST-LL */
-void st_ll_send_frame(enum proto_type, struct sk_buff *);
-
-/* internal wake up function */
-void st_tx_wakeup(struct st_data_s *st_data);
-
-/* init, exit entry funcs called from KIM */
-int st_core_init(struct st_data_s **);
-void st_core_exit(struct st_data_s *);
-
-/* ask for reference from KIM */
-void st_kim_ref(struct st_data_s **, int);
-
-#define GPS_STUB_TEST
-#ifdef GPS_STUB_TEST
-int gps_chrdrv_stub_write(const unsigned char*, int);
-void gps_chrdrv_stub_init(void);
-#endif
-
-/*
- * header information used by st_kim.c
- */
-
-/* time in msec to wait for
- * line discipline to be installed
- */
-#define LDISC_TIME 1000
-#define CMD_RESP_TIME 800
-#define CMD_WR_TIME 5000
-#define MAKEWORD(a, b) ((unsigned short)(((unsigned char)(a)) \
- | ((unsigned short)((unsigned char)(b))) << 8))
-
-#define GPIO_HIGH 1
-#define GPIO_LOW 0
-
-/* the Power-On-Reset logic, requires to attempt
- * to download firmware onto chip more than once
- * since the self-test for chip takes a while
- */
-#define POR_RETRY_COUNT 5
-
-/**
- * struct chip_version - save the chip version
- */
-struct chip_version {
- unsigned short full;
- unsigned short chip;
- unsigned short min_ver;
- unsigned short maj_ver;
-};
-
-#define UART_DEV_NAME_LEN 32
-/**
- * struct kim_data_s - the KIM internal data, embedded as the
- * platform's drv data. One for each ST device in the system.
- * @uim_pid: KIM needs to communicate with UIM to request to install
- * the ldisc by opening UART when protocol drivers register.
- * @kim_pdev: the platform device added in one of the board-XX.c file
- * in arch/XX/ directory, 1 for each ST device.
- * @kim_rcvd: completion handler to notify when data was received,
- * mainly used during fw download, which involves multiple send/wait
- * for each of the HCI-VS commands.
- * @ldisc_installed: completion handler to notify that the UIM accepted
- * the request to install ldisc, notify from tty_open which suggests
- * the ldisc was properly installed.
- * @resp_buffer: data buffer for the .bts fw file name.
- * @fw_entry: firmware class struct to request/release the fw.
- * @rx_state: the rx state for kim's receive func during fw download.
- * @rx_count: the rx count for the kim's receive func during fw download.
- * @rx_skb: all of fw data might not come at once, and hence data storage for
- * whole of the fw response, only HCI_EVENTs and hence diff from ST's
- * response.
- * @core_data: ST core's data, which mainly is the tty's disc_data
- * @version: chip version available via a sysfs entry.
- *
- */
-struct kim_data_s {
- long uim_pid;
- struct platform_device *kim_pdev;
- struct completion kim_rcvd, ldisc_installed;
- char resp_buffer[30];
- const struct firmware *fw_entry;
- unsigned nshutdown;
- unsigned long rx_state;
- unsigned long rx_count;
- struct sk_buff *rx_skb;
- struct st_data_s *core_data;
- struct chip_version version;
- unsigned char ldisc_install;
- unsigned char dev_name[UART_DEV_NAME_LEN + 1];
- unsigned flow_cntrl;
- unsigned baud_rate;
-};
-
-/**
- * functions called when 1 of the protocol drivers gets
- * registered, these need to communicate with UIM to request
- * ldisc installed, read chip_version, download relevant fw
- */
-long st_kim_start(void *);
-long st_kim_stop(void *);
-
-void st_kim_complete(void *);
-void kim_st_list_protocols(struct st_data_s *, void *);
-void st_kim_recv(void *, const unsigned char *, long);
-
-
/*
* BTS headers
*/
@@ -355,47 +96,6 @@ struct hci_command {
u32 speed;
} __attribute__ ((packed));

-/*
- * header information used by st_ll.c
- */
-
-/* ST LL receiver states */
-#define ST_W4_PACKET_TYPE 0
-#define ST_W4_HEADER 1
-#define ST_W4_DATA 2
-
-/* ST LL state machines */
-#define ST_LL_ASLEEP 0
-#define ST_LL_ASLEEP_TO_AWAKE 1
-#define ST_LL_AWAKE 2
-#define ST_LL_AWAKE_TO_ASLEEP 3
-#define ST_LL_INVALID 4
-
-/* different PM notifications coming from chip */
-#define LL_SLEEP_IND 0x30
-#define LL_SLEEP_ACK 0x31
-#define LL_WAKE_UP_IND 0x32
-#define LL_WAKE_UP_ACK 0x33
-
-/* initialize and de-init ST LL */
-long st_ll_init(struct st_data_s *);
-long st_ll_deinit(struct st_data_s *);
-
-/**
- * enable/disable ST LL along with KIM start/stop
- * called by ST Core
- */
-void st_ll_enable(struct st_data_s *);
-void st_ll_disable(struct st_data_s *);
-
-/**
- * various funcs used by ST core to set/get the various PM states
- * of the chip.
- */
-unsigned long st_ll_getstate(struct st_data_s *);
-unsigned long st_ll_sleep_state(struct st_data_s *, unsigned char);
-void st_ll_wakeup(struct st_data_s *);
-
/*
* header information used by st_core.c for FM and GPS
* packet parsing, the bluetooth headers are already available
@@ -416,39 +116,4 @@ struct gps_event_hdr {
u16 plen;
} __attribute__ ((packed));

-/**
- * struct ti_st_plat_data - platform data shared between ST driver and
- * platform specific board file which adds the ST device.
- * @nshutdown_gpio: Host's GPIO line to which chip's BT_EN is connected.
- * @dev_name: The UART/TTY name to which chip is interfaced. (eg: /dev/ttyS1)
- * @flow_cntrl: Should always be 1, since UART's CTS/RTS is used for PM
- * purposes.
- * @baud_rate: The baud rate supported by the Host UART controller, this will
- * be shared across with the chip via a HCI VS command from User-Space Init
- * Mgr application.
- * @suspend:
- * @resume: legacy PM routines hooked to platform specific board file, so as
- * to take chip-host interface specific action.
- * @chip_enable:
- * @chip_disable: Platform/Interface specific mux mode setting, GPIO
- * configuring, Host side PM disabling etc.. can be done here.
- * @chip_asleep:
- * @chip_awake: Chip specific deep sleep states is communicated to Host
- * specific board-xx.c to take actions such as cut UART clocks when chip
- * asleep or run host faster when chip awake etc..
- *
- */
-struct ti_st_plat_data {
- u32 nshutdown_gpio;
- unsigned char dev_name[UART_DEV_NAME_LEN]; /* uart name */
- u32 flow_cntrl; /* flow control flag */
- u32 baud_rate;
- int (*suspend)(struct platform_device *, pm_message_t);
- int (*resume)(struct platform_device *);
- int (*chip_enable) (struct kim_data_s *);
- int (*chip_disable) (struct kim_data_s *);
- int (*chip_asleep) (struct kim_data_s *);
- int (*chip_awake) (struct kim_data_s *);
-};
-
#endif /* TI_WILINK_ST_H */
--
2.19.2


2018-12-21 01:19:16

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 12/14] media: wl128x-radio: move from TI_ST to hci_ll driver

From: Sebastian Reichel <[email protected]>

This updates the wl128x-radio driver to be used with hci_ll
instead of the deprecated TI_ST driver.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/bluetooth/hci_ll.c | 115 ++++++++++++++++++++--
drivers/media/radio/wl128x/Kconfig | 2 +-
drivers/media/radio/wl128x/fmdrv.h | 1 +
drivers/media/radio/wl128x/fmdrv_common.c | 101 ++-----------------
include/linux/ti_wilink_st.h | 2 +
5 files changed, 117 insertions(+), 104 deletions(-)

diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c
index 3e767f245ed5..6bcba57e9c9c 100644
--- a/drivers/bluetooth/hci_ll.c
+++ b/drivers/bluetooth/hci_ll.c
@@ -49,6 +49,7 @@
#include <linux/skbuff.h>
#include <linux/ti_wilink_st.h>
#include <linux/clk.h>
+#include <linux/platform_device.h>

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
@@ -62,6 +63,7 @@
#define HCI_VS_UPDATE_UART_HCI_BAUDRATE 0xff36

/* HCILL commands */
+#define HCILL_FM_RADIO 0x08
#define HCILL_GO_TO_SLEEP_IND 0x30
#define HCILL_GO_TO_SLEEP_ACK 0x31
#define HCILL_WAKE_UP_IND 0x32
@@ -81,6 +83,10 @@ struct ll_device {
struct gpio_desc *enable_gpio;
struct clk *ext_clk;
bdaddr_t bdaddr;
+
+ struct platform_device *fmdev;
+ void (*fm_handler) (void *, struct sk_buff *);
+ void *fm_drvdata;
};

struct ll_struct {
@@ -161,6 +167,35 @@ static int ll_flush(struct hci_uart *hu)
return 0;
}

+static int ll_register_fm(struct ll_device *lldev)
+{
+ struct device *dev = &lldev->serdev->dev;
+ int err;
+
+ if (!of_device_is_compatible(dev->of_node, "ti,wl1281-st") &&
+ !of_device_is_compatible(dev->of_node, "ti,wl1283-st") &&
+ !of_device_is_compatible(dev->of_node, "ti,wl1285-st"))
+ return -ENODEV;
+
+ lldev->fmdev = platform_device_register_data(dev, "wl128x-fm",
+ PLATFORM_DEVID_AUTO, NULL, 0);
+ err = PTR_ERR_OR_ZERO(lldev->fmdev);
+ if (err) {
+ dev_warn(dev, "cannot register FM radio subdevice: %d\n", err);
+ lldev->fmdev = NULL;
+ }
+
+ return err;
+}
+
+static void ll_unregister_fm(struct ll_device *lldev)
+{
+ if (!lldev->fmdev)
+ return;
+ platform_device_unregister(lldev->fmdev);
+ lldev->fmdev = NULL;
+}
+
/* Close protocol */
static int ll_close(struct hci_uart *hu)
{
@@ -178,6 +213,8 @@ static int ll_close(struct hci_uart *hu)
gpiod_set_value_cansleep(lldev->enable_gpio, 0);

clk_disable_unprepare(lldev->ext_clk);
+
+ ll_unregister_fm(lldev);
}

hu->priv = NULL;
@@ -313,18 +350,11 @@ static void ll_device_woke_up(struct hci_uart *hu)
hci_uart_tx_wakeup(hu);
}

-/* Enqueue frame for transmittion (padding, crc, etc) */
-/* may be called from two simultaneous tasklets */
-static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb)
+static int ll_enqueue_prefixed(struct hci_uart *hu, struct sk_buff *skb)
{
unsigned long flags = 0;
struct ll_struct *ll = hu->priv;

- BT_DBG("hu %p skb %p", hu, skb);
-
- /* Prepend skb with frame type */
- memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
-
/* lock hcill state */
spin_lock_irqsave(&ll->hcill_lock, flags);

@@ -361,6 +391,18 @@ static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb)
return 0;
}

+/* Enqueue frame for transmittion (padding, crc, etc) */
+/* may be called from two simultaneous tasklets */
+static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb)
+{
+ BT_DBG("hu %p skb %p", hu, skb);
+
+ /* Prepend skb with frame type */
+ memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
+
+ return ll_enqueue_prefixed(hu, skb);
+}
+
static int ll_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_uart *hu = hci_get_drvdata(hdev);
@@ -390,6 +432,32 @@ static int ll_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
return 0;
}

+static int ll_recv_radio(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ struct hci_uart *hu = hci_get_drvdata(hdev);
+ struct serdev_device *serdev = hu->serdev;
+ struct ll_device *lldev = serdev_device_get_drvdata(serdev);
+
+ if (!lldev->fm_handler) {
+ kfree_skb(skb);
+ return -EINVAL;
+ }
+
+ /* Prepend skb with frame type */
+ memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
+
+ lldev->fm_handler(lldev->fm_drvdata, skb);
+
+ return 0;
+}
+
+#define LL_RECV_FM_RADIO \
+ .type = HCILL_FM_RADIO, \
+ .hlen = 1, \
+ .loff = 0, \
+ .lsize = 1, \
+ .maxlen = 0xff
+
#define LL_RECV_SLEEP_IND \
.type = HCILL_GO_TO_SLEEP_IND, \
.hlen = 0, \
@@ -422,6 +490,7 @@ static const struct h4_recv_pkt ll_recv_pkts[] = {
{ H4_RECV_ACL, .recv = hci_recv_frame },
{ H4_RECV_SCO, .recv = hci_recv_frame },
{ H4_RECV_EVENT, .recv = hci_recv_frame },
+ { LL_RECV_FM_RADIO, .recv = ll_recv_radio },
{ LL_RECV_SLEEP_IND, .recv = ll_recv_frame },
{ LL_RECV_SLEEP_ACK, .recv = ll_recv_frame },
{ LL_RECV_WAKE_IND, .recv = ll_recv_frame },
@@ -669,11 +738,41 @@ static int ll_setup(struct hci_uart *hu)
}
}

+ /* We intentionally ignore failures and proceed without FM device */
+ ll_register_fm(lldev);
+
return 0;
}

static const struct hci_uart_proto llp;

+void hci_ti_set_fm_handler(struct device *dev, void (*recv_handler) (void *, struct sk_buff *), void *drvdata)
+{
+ struct serdev_device *serdev = to_serdev_device(dev);
+ struct ll_device *lldev = serdev_device_get_drvdata(serdev);
+
+ lldev->fm_drvdata = drvdata;
+ lldev->fm_handler = recv_handler;
+}
+EXPORT_SYMBOL_GPL(hci_ti_set_fm_handler);
+
+int hci_ti_fm_send(struct device *dev, struct sk_buff *skb)
+{
+ struct serdev_device *serdev = to_serdev_device(dev);
+ struct ll_device *lldev = serdev_device_get_drvdata(serdev);
+ struct hci_uart *hu = &lldev->hu;
+ int ret;
+
+ hci_skb_pkt_type(skb) = HCILL_FM_RADIO;
+ ret = ll_enqueue_prefixed(hu, skb);
+
+ if (!ret)
+ hci_uart_tx_wakeup(hu);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(hci_ti_fm_send);
+
static int hci_ti_probe(struct serdev_device *serdev)
{
struct hci_uart *hu;
diff --git a/drivers/media/radio/wl128x/Kconfig b/drivers/media/radio/wl128x/Kconfig
index 64b66bbdae72..847b3ed92639 100644
--- a/drivers/media/radio/wl128x/Kconfig
+++ b/drivers/media/radio/wl128x/Kconfig
@@ -4,7 +4,7 @@
menu "Texas Instruments WL128x FM driver (ST based)"
config RADIO_WL128X
tristate "Texas Instruments WL128x FM Radio"
- depends on VIDEO_V4L2 && RFKILL && TTY && TI_ST
+ depends on VIDEO_V4L2 && RFKILL && TTY && BT_HCIUART_LL
depends on GPIOLIB || COMPILE_TEST
help
Choose Y here if you have this FM radio chip.
diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h
index 4a337f38cfc9..717a8a3f533f 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -197,6 +197,7 @@ struct fmtx_data {

/* FM driver operation structure */
struct fmdev {
+ struct device *dev;
struct video_device radio_dev; /* V4L2 video device pointer */
struct v4l2_device v4l2_dev; /* V4L2 top level struct */
struct snd_card *card; /* Card which holds FM mixer controls */
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index c20d518af4f3..88a2197c4815 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -172,9 +172,6 @@ static int_handler_prototype int_handler_table[] = {
fm_irq_handle_intmsk_cmd_resp
};

-static long (*g_st_write) (struct sk_buff *skb);
-static struct completion wait_for_fmdrv_reg_comp;
-
static inline void fm_irq_call(struct fmdev *fmdev)
{
fmdev->irq_info.handlers[fmdev->irq_info.stage](fmdev);
@@ -373,7 +370,7 @@ static void send_tasklet(unsigned long arg)

/* Write FM packet to ST driver */
dump_tx_skb_data(skb);
- len = g_st_write(skb);
+ len = hci_ti_fm_send(fmdev->dev->parent, skb);
if (len < 0) {
kfree_skb(skb);
fmdev->resp_comp = NULL;
@@ -1441,42 +1438,13 @@ int fmc_get_mode(struct fmdev *fmdev, u8 *fmmode)
}

/* Called by ST layer when FM packet is available */
-static long fm_st_receive(void *arg, struct sk_buff *skb)
+static void fm_st_receive(void *arg, struct sk_buff *skb)
{
- struct fmdev *fmdev;
-
- fmdev = (struct fmdev *)arg;
-
- if (skb == NULL) {
- fmerr("Invalid SKB received from ST\n");
- return -EFAULT;
- }
-
- if (skb->cb[0] != FM_PKT_LOGICAL_CHAN_NUMBER) {
- fmerr("Received SKB (%p) is not FM Channel 8 pkt\n", skb);
- return -EINVAL;
- }
+ struct fmdev *fmdev = (struct fmdev *) arg;

- memcpy(skb_push(skb, 1), &skb->cb[0], 1);
dump_rx_skb_data(skb);
-
skb_queue_tail(&fmdev->rx_q, skb);
tasklet_schedule(&fmdev->rx_task);
-
- return 0;
-}
-
-/*
- * Called by ST layer to indicate protocol registration completion
- * status.
- */
-static void fm_st_reg_comp_cb(void *arg, int data)
-{
- struct fmdev *fmdev;
-
- fmdev = (struct fmdev *)arg;
- fmdev->streg_cbdata = data;
- complete(&wait_for_fmdrv_reg_comp);
}

/*
@@ -1485,59 +1453,12 @@ static void fm_st_reg_comp_cb(void *arg, int data)
*/
void fmc_prepare(struct fmdev *fmdev)
{
- static struct st_proto_s fm_st_proto;
-
if (test_bit(FM_CORE_READY, &fmdev->flag)) {
fmdbg("FM Core is already up\n");
return;
}

- memset(&fm_st_proto, 0, sizeof(fm_st_proto));
- fm_st_proto.recv = fm_st_receive;
- fm_st_proto.match_packet = NULL;
- fm_st_proto.reg_complete_cb = fm_st_reg_comp_cb;
- fm_st_proto.write = NULL; /* TI ST driver will fill write pointer */
- fm_st_proto.priv_data = fmdev;
- fm_st_proto.chnl_id = 0x08;
- fm_st_proto.max_frame_size = 0xff;
- fm_st_proto.hdr_len = 1;
- fm_st_proto.offset_len_in_hdr = 0;
- fm_st_proto.len_size = 1;
- fm_st_proto.reserve = 1;
-
- ret = st_register(&fm_st_proto);
- if (ret == -EINPROGRESS) {
- init_completion(&wait_for_fmdrv_reg_comp);
- fmdev->streg_cbdata = -EINPROGRESS;
- fmdbg("%s waiting for ST reg completion signal\n", __func__);
-
- if (!wait_for_completion_timeout(&wait_for_fmdrv_reg_comp,
- FM_ST_REG_TIMEOUT)) {
- fmerr("Timeout(%d sec), didn't get reg completion signal from ST\n",
- jiffies_to_msecs(FM_ST_REG_TIMEOUT) / 1000);
- return -ETIMEDOUT;
- }
- if (fmdev->streg_cbdata != 0) {
- fmerr("ST reg comp CB called with error status %d\n",
- fmdev->streg_cbdata);
- return -EAGAIN;
- }
-
- ret = 0;
- } else if (ret == -1) {
- fmerr("st_register failed %d\n", ret);
- return -EAGAIN;
- }
-
- if (fm_st_proto.write != NULL) {
- g_st_write = fm_st_proto.write;
- } else {
- fmerr("Failed to get ST write func pointer\n");
- ret = st_unregister(&fm_st_proto);
- if (ret < 0)
- fmerr("st_unregister failed %d\n", ret);
- return -EAGAIN;
- }
+ hci_ti_set_fm_handler(fmdev->dev->parent, fm_st_receive, fmdev);

spin_lock_init(&fmdev->rds_buff_lock);
spin_lock_init(&fmdev->resp_skb_lock);
@@ -1582,9 +1503,6 @@ void fmc_prepare(struct fmdev *fmdev)
*/
void fmc_release(struct fmdev *fmdev)
{
- static struct st_proto_s fm_st_proto;
- int ret;
-
if (!test_bit(FM_CORE_READY, &fmdev->flag)) {
fmdbg("FM Core is already down\n");
return;
@@ -1601,15 +1519,7 @@ void fmc_release(struct fmdev *fmdev)
fmdev->resp_comp = NULL;
fmdev->rx.freq = 0;

- memset(&fm_st_proto, 0, sizeof(fm_st_proto));
- fm_st_proto.chnl_id = 0x08;
-
- ret = st_unregister(&fm_st_proto);
-
- if (ret < 0)
- fmerr("Failed to de-register FM from ST %d\n", ret);
- else
- fmdbg("Successfully unregistered from ST\n");
+ hci_ti_set_fm_handler(fmdev->dev->parent, NULL, NULL);

clear_bit(FM_CORE_READY, &fmdev->flag);
}
@@ -1624,6 +1534,7 @@ static int wl128x_fm_probe(struct platform_device *pdev)
if (!fmdev)
return -ENOMEM;
platform_set_drvdata(pdev, fmdev);
+ fmdev->dev = &pdev->dev;

fmdev->rx.rds.buf_size = default_rds_buf * FM_RDS_BLK_SIZE;
fmdev->rx.rds.buff = devm_kzalloc(&pdev->dev, fmdev->rx.rds.buf_size, GFP_KERNEL);
diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
index f2293028ab9d..a9de5654b0cd 100644
--- a/include/linux/ti_wilink_st.h
+++ b/include/linux/ti_wilink_st.h
@@ -86,6 +86,8 @@ struct st_proto_s {
extern long st_register(struct st_proto_s *);
extern long st_unregister(struct st_proto_s *);

+void hci_ti_set_fm_handler(struct device *dev, void (*recv_handler) (void *, struct sk_buff *), void *drvdata);
+int hci_ti_fm_send(struct device *dev, struct sk_buff *skb);

/*
* header information used by st_core.c
--
2.19.2


2018-12-21 01:19:27

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 11/14] media: wl128x-radio: fix skb debug printing

From: Sebastian Reichel <[email protected]>

This fixes incorrect code in the TX/RX skb debug print
function and add stubs in receive/transmit packet path.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/media/radio/wl128x/fmdrv_common.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index 473ec5738a11..c20d518af4f3 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -195,7 +195,7 @@ static inline void fm_irq_timeout_stage(struct fmdev *fmdev, u8 stage)

#ifdef FM_DUMP_TXRX_PKT
/* To dump outgoing FM Channel-8 packets */
-inline void dump_tx_skb_data(struct sk_buff *skb)
+static void dump_tx_skb_data(struct sk_buff *skb)
{
int len, len_org;
u8 index;
@@ -220,7 +220,7 @@ inline void dump_tx_skb_data(struct sk_buff *skb)
}

/* To dump incoming FM Channel-8 packets */
-inline void dump_rx_skb_data(struct sk_buff *skb)
+static void dump_rx_skb_data(struct sk_buff *skb)
{
int len, len_org;
u8 index;
@@ -228,7 +228,7 @@ inline void dump_rx_skb_data(struct sk_buff *skb)

evt_hdr = (struct fm_event_msg_hdr *)skb->data;
printk(KERN_INFO ">> hdr:%02x len:%02x sts:%02x numhci:%02x opcode:%02x type:%s dlen:%02x",
- evt_hdr->hdr, evt_hdr->len,
+ evt_hdr->header, evt_hdr->len,
evt_hdr->status, evt_hdr->num_fm_hci_cmds, evt_hdr->op,
(evt_hdr->rd_wr) ? "RD" : "WR", evt_hdr->dlen);

@@ -243,6 +243,9 @@ inline void dump_rx_skb_data(struct sk_buff *skb)
}
printk(KERN_CONT "\n");
}
+#else
+static void dump_tx_skb_data(struct sk_buff *skb) {}
+static void dump_rx_skb_data(struct sk_buff *skb) {}
#endif

void fmc_update_region_info(struct fmdev *fmdev, u8 region_to_set)
@@ -369,6 +372,7 @@ static void send_tasklet(unsigned long arg)
fmdev->resp_comp = fm_cb(skb)->completion;

/* Write FM packet to ST driver */
+ dump_tx_skb_data(skb);
len = g_st_write(skb);
if (len < 0) {
kfree_skb(skb);
@@ -1454,6 +1458,8 @@ static long fm_st_receive(void *arg, struct sk_buff *skb)
}

memcpy(skb_push(skb, 1), &skb->cb[0], 1);
+ dump_rx_skb_data(skb);
+
skb_queue_tail(&fmdev->rx_q, skb);
tasklet_schedule(&fmdev->rx_task);

--
2.19.2


2018-12-21 01:19:30

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 10/14] media: wl128x-radio: simplify fmc_prepare/fmc_release

From: Sebastian Reichel <[email protected]>

Remove unused return code from fmc_prepare() and fmc_release() to
simplify the code a bit.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/media/radio/wl128x/fmdrv_common.c | 26 +++++++++--------------
drivers/media/radio/wl128x/fmdrv_common.h | 4 ++--
drivers/media/radio/wl128x/fmdrv_v4l2.c | 12 ++---------
3 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index d584ca970556..473ec5738a11 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1225,7 +1225,8 @@ static int fm_power_down(struct fmdev *fmdev)
if (ret < 0)
return ret;

- return fmc_release(fmdev);
+ fmc_release(fmdev);
+ return 0;
}

/* Reads init command from FM firmware file and loads to the chip */
@@ -1310,7 +1311,7 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
{
u16 payload;
__be16 asic_id, asic_ver;
- int resp_len, ret;
+ int resp_len, ret = 0;
u8 fw_name[50];

if (mode >= FM_MODE_ENTRY_MAX) {
@@ -1322,11 +1323,7 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
* Initialize FM common module. FM GPIO toggling is
* taken care in Shared Transport driver.
*/
- ret = fmc_prepare(fmdev);
- if (ret < 0) {
- fmerr("Unable to prepare FM Common\n");
- return ret;
- }
+ fmc_prepare(fmdev);

payload = FM_ENABLE;
if (fmc_send_cmd(fmdev, FM_POWER_MODE, REG_WR, &payload,
@@ -1366,7 +1363,8 @@ static int fm_power_up(struct fmdev *fmdev, u8 mode)
} else
return ret;
rel:
- return fmc_release(fmdev);
+ fmc_release(fmdev);
+ return ret;
}

/* Set FM Modes(TX, RX, OFF) */
@@ -1479,14 +1477,13 @@ static void fm_st_reg_comp_cb(void *arg, int data)
* This function will be called from FM V4L2 open function.
* Register with ST driver and initialize driver data.
*/
-int fmc_prepare(struct fmdev *fmdev)
+void fmc_prepare(struct fmdev *fmdev)
{
static struct st_proto_s fm_st_proto;
- int ret;

if (test_bit(FM_CORE_READY, &fmdev->flag)) {
fmdbg("FM Core is already up\n");
- return 0;
+ return;
}

memset(&fm_st_proto, 0, sizeof(fm_st_proto));
@@ -1571,22 +1568,20 @@ int fmc_prepare(struct fmdev *fmdev)

fm_rx_reset_station_info(fmdev);
set_bit(FM_CORE_READY, &fmdev->flag);
-
- return ret;
}

/*
* This function will be called from FM V4L2 release function.
* Unregister from ST driver.
*/
-int fmc_release(struct fmdev *fmdev)
+void fmc_release(struct fmdev *fmdev)
{
static struct st_proto_s fm_st_proto;
int ret;

if (!test_bit(FM_CORE_READY, &fmdev->flag)) {
fmdbg("FM Core is already down\n");
- return 0;
+ return;
}
/* Service pending read */
wake_up_interruptible(&fmdev->rx.rds.read_queue);
@@ -1611,7 +1606,6 @@ int fmc_release(struct fmdev *fmdev)
fmdbg("Successfully unregistered from ST\n");

clear_bit(FM_CORE_READY, &fmdev->flag);
- return ret;
}

static int wl128x_fm_probe(struct platform_device *pdev)
diff --git a/drivers/media/radio/wl128x/fmdrv_common.h b/drivers/media/radio/wl128x/fmdrv_common.h
index 552e22ea6bf3..47a8f0061eb0 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.h
+++ b/drivers/media/radio/wl128x/fmdrv_common.h
@@ -364,8 +364,8 @@ struct fm_event_msg_hdr {
#define FM_TX_ANT_IMP_500 2

/* Functions exported by FM common sub-module */
-int fmc_prepare(struct fmdev *);
-int fmc_release(struct fmdev *);
+void fmc_prepare(struct fmdev *);
+void fmc_release(struct fmdev *);

void fmc_update_region_info(struct fmdev *, u8);
int fmc_send_cmd(struct fmdev *, u8, u16,
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index affa9e199dfb..ab6384e412f9 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -133,11 +133,7 @@ static int fm_v4l2_fops_open(struct file *file)

if (mutex_lock_interruptible(&fmdev->mutex))
return -ERESTARTSYS;
- ret = fmc_prepare(fmdev);
- if (ret < 0) {
- fmerr("Unable to prepare FM CORE\n");
- goto open_unlock;
- }
+ fmc_prepare(fmdev);

fmdbg("Load FM RX firmware..\n");

@@ -171,11 +167,7 @@ static int fm_v4l2_fops_release(struct file *file)
goto release_unlock;
}

- ret = fmc_release(fmdev);
- if (ret < 0) {
- fmerr("FM CORE release failed\n");
- goto release_unlock;
- }
+ fmc_release(fmdev);
fmdev->radio_disconnected = 0;

release_unlock:
--
2.19.2


2018-12-21 01:19:40

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 08/14] media: wl128x-radio: use device managed memory allocation

From: Sebastian Reichel <[email protected]>

This simplifies memory allocation and removes a few useless
errors in case of -ENOMEM errors.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/media/radio/wl128x/fmdrv_common.c | 41 +++++++----------------
1 file changed, 13 insertions(+), 28 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index 9526613adf91..3f189d093eeb 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1614,55 +1614,40 @@ int fmc_release(struct fmdev *fmdev)
return ret;
}

-static int wl128x_fm_probe(struct platform_device *dev)
+static int wl128x_fm_probe(struct platform_device *pdev)
{
- struct fmdev *fmdev = NULL;
- int ret = -ENOMEM;
-
- fmdbg("FM driver\n");
+ struct fmdev *fmdev;
+ int ret;

/* Allocate memory for FM driver context and RX RDS buffer. */
- fmdev = kzalloc(sizeof(struct fmdev), GFP_KERNEL);
- if (NULL == fmdev) {
- fmerr("Can't allocate operation structure memory\n");
- return ret;
- }
+ fmdev = devm_kzalloc(&pdev->dev, sizeof(*fmdev), GFP_KERNEL);
+ if (!fmdev)
+ return -ENOMEM;
+ platform_set_drvdata(pdev, fmdev);
+
fmdev->rx.rds.buf_size = default_rds_buf * FM_RDS_BLK_SIZE;
- fmdev->rx.rds.buff = kzalloc(fmdev->rx.rds.buf_size, GFP_KERNEL);
- if (NULL == fmdev->rx.rds.buff) {
- fmerr("Can't allocate rds ring buffer\n");
- goto rel_dev;
- }
+ fmdev->rx.rds.buff = devm_kzalloc(&pdev->dev, fmdev->rx.rds.buf_size, GFP_KERNEL);
+ if (!fmdev->rx.rds.buff)
+ return -ENOMEM;

/* Ask FM V4L module to register video device. */
ret = fm_v4l2_init_video_device(fmdev, radio_nr);
if (ret < 0)
- goto rel_rdsbuf;
+ return ret;

fmdev->irq_info.handlers = int_handler_table;
fmdev->curr_fmmode = FM_MODE_OFF;
fmdev->tx_data.pwr_lvl = FM_PWR_LVL_DEF;
fmdev->tx_data.preemph = FM_TX_PREEMPH_50US;
return ret;
-
-rel_rdsbuf:
- kfree(fmdev->rx.rds.buff);
-rel_dev:
- kfree(fmdev);
-
- return ret;
}

-static int wl128x_fm_remove(struct platform_device *dev)
+static int wl128x_fm_remove(struct platform_device *pdev)
{
struct fmdev *fmdev = platform_get_drvdata(pdev);

/* Ask FM V4L module to unregister video device */
fm_v4l2_deinit_video_device(fmdev);
- if (fmdev != NULL) {
- kfree(fmdev->rx.rds.buff);
- kfree(fmdev);
- }

return 0;
}
--
2.19.2


2018-12-21 01:19:50

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 07/14] media: wl128x-radio: convert to platform device

From: Sebastian Reichel <[email protected]>

This converts the wl128x FM radio module into a platform device.
It's a preparation for using it from hci_ll Bluetooth driver instead
of TI_ST.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/media/radio/wl128x/fmdrv_common.c | 30 ++++++++++++-----------
1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index f77acec0addf..9526613adf91 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -35,11 +35,10 @@
#include "fmdrv_v4l2.h"
#include "fmdrv_common.h"
#include <linux/ti_wilink_st.h>
+#include <linux/platform_device.h>
#include "fmdrv_rx.h"
#include "fmdrv_tx.h"

-struct fmdev *global_fmdev;
-
/* Region info */
static struct region_info region_configs[] = {
/* Europe/US */
@@ -1615,23 +1614,19 @@ int fmc_release(struct fmdev *fmdev)
return ret;
}

-/*
- * Module init function. Ask FM V4L module to register video device.
- * Allocate memory for FM driver context and RX RDS buffer.
- */
-static int __init fm_drv_init(void)
+static int wl128x_fm_probe(struct platform_device *dev)
{
struct fmdev *fmdev = NULL;
int ret = -ENOMEM;

fmdbg("FM driver\n");

+ /* Allocate memory for FM driver context and RX RDS buffer. */
fmdev = kzalloc(sizeof(struct fmdev), GFP_KERNEL);
if (NULL == fmdev) {
fmerr("Can't allocate operation structure memory\n");
return ret;
}
- global_fmdev = fmdev;
fmdev->rx.rds.buf_size = default_rds_buf * FM_RDS_BLK_SIZE;
fmdev->rx.rds.buff = kzalloc(fmdev->rx.rds.buf_size, GFP_KERNEL);
if (NULL == fmdev->rx.rds.buff) {
@@ -1639,6 +1634,7 @@ static int __init fm_drv_init(void)
goto rel_dev;
}

+ /* Ask FM V4L module to register video device. */
ret = fm_v4l2_init_video_device(fmdev, radio_nr);
if (ret < 0)
goto rel_rdsbuf;
@@ -1657,10 +1653,9 @@ static int __init fm_drv_init(void)
return ret;
}

-/* Module exit function. Ask FM V4L module to unregister video device */
-static void __exit fm_drv_exit(void)
+static int wl128x_fm_remove(struct platform_device *dev)
{
- struct fmdev *fmdev = global_fmdev;
+ struct fmdev *fmdev = platform_get_drvdata(pdev);

/* Ask FM V4L module to unregister video device */
fm_v4l2_deinit_video_device(fmdev);
@@ -1668,12 +1663,19 @@ static void __exit fm_drv_exit(void)
kfree(fmdev->rx.rds.buff);
kfree(fmdev);
}
+
+ return 0;
}

-module_init(fm_drv_init);
-module_exit(fm_drv_exit);
+static struct platform_driver wl128x_fm_drv = {
+ .driver = {
+ .name = "wl128x-fm",
+ },
+ .probe = wl128x_fm_probe,
+ .remove = wl128x_fm_remove,
+};
+module_platform_driver(wl128x_fm_drv);

-/* ------------- Module Info ------------- */
MODULE_AUTHOR("Manjunatha Halli <[email protected]>");
MODULE_DESCRIPTION("FM Driver for TI's Connectivity chip");
MODULE_LICENSE("GPL");
--
2.19.2


2018-12-21 01:19:51

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 06/14] media: wl128x-radio: remove global radio_dev

From: Sebastian Reichel <[email protected]>

Move global radio_dev into device structure to prepare converting
this driver into a normal platform device driver supporting multiple
instances.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/media/radio/wl128x/fmdrv.h | 2 +-
drivers/media/radio/wl128x/fmdrv_common.c | 10 +++++---
drivers/media/radio/wl128x/fmdrv_v4l2.c | 28 +++++++----------------
drivers/media/radio/wl128x/fmdrv_v4l2.h | 2 +-
4 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h
index fa89eef59295..4a337f38cfc9 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -197,7 +197,7 @@ struct fmtx_data {

/* FM driver operation structure */
struct fmdev {
- struct video_device *radio_dev; /* V4L2 video device pointer */
+ struct video_device radio_dev; /* V4L2 video device pointer */
struct v4l2_device v4l2_dev; /* V4L2 top level struct */
struct snd_card *card; /* Card which holds FM mixer controls */
u16 asci_id;
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index 6bbae074f02d..f77acec0addf 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -38,6 +38,8 @@
#include "fmdrv_rx.h"
#include "fmdrv_tx.h"

+struct fmdev *global_fmdev;
+
/* Region info */
static struct region_info region_configs[] = {
/* Europe/US */
@@ -1241,7 +1243,7 @@ static int fm_download_firmware(struct fmdev *fmdev, const u8 *fw_name)
set_bit(FM_FW_DW_INPROGRESS, &fmdev->flag);

ret = request_firmware(&fw_entry, fw_name,
- &fmdev->radio_dev->dev);
+ &fmdev->radio_dev.dev);
if (ret < 0) {
fmerr("Unable to read firmware(%s) content\n", fw_name);
return ret;
@@ -1629,6 +1631,7 @@ static int __init fm_drv_init(void)
fmerr("Can't allocate operation structure memory\n");
return ret;
}
+ global_fmdev = fmdev;
fmdev->rx.rds.buf_size = default_rds_buf * FM_RDS_BLK_SIZE;
fmdev->rx.rds.buff = kzalloc(fmdev->rx.rds.buf_size, GFP_KERNEL);
if (NULL == fmdev->rx.rds.buff) {
@@ -1657,9 +1660,10 @@ static int __init fm_drv_init(void)
/* Module exit function. Ask FM V4L module to unregister video device */
static void __exit fm_drv_exit(void)
{
- struct fmdev *fmdev = NULL;
+ struct fmdev *fmdev = global_fmdev;

- fmdev = fm_v4l2_deinit_video_device();
+ /* Ask FM V4L module to unregister video device */
+ fm_v4l2_deinit_video_device(fmdev);
if (fmdev != NULL) {
kfree(fmdev->rx.rds.buff);
kfree(fmdev);
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index f541b5802844..affa9e199dfb 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -32,8 +32,6 @@
#include "fmdrv_rx.h"
#include "fmdrv_tx.h"

-static struct video_device gradio_dev;
-
/* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */

/* Read RX RDS data */
@@ -540,23 +538,20 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr)
mutex_init(&fmdev->mutex);

/* Setup FM driver's V4L2 properties */
- gradio_dev = fm_viddev_template;
-
- video_set_drvdata(&gradio_dev, fmdev);
+ fmdev->radio_dev = fm_viddev_template;

- gradio_dev.lock = &fmdev->mutex;
- gradio_dev.v4l2_dev = &fmdev->v4l2_dev;
+ video_set_drvdata(&fmdev->radio_dev, fmdev);
+ fmdev->radio_dev.lock = &fmdev->mutex;
+ fmdev->radio_dev.v4l2_dev = &fmdev->v4l2_dev;

/* Register with V4L2 subsystem as RADIO device */
- if (video_register_device(&gradio_dev, VFL_TYPE_RADIO, radio_nr)) {
+ if (video_register_device(&fmdev->radio_dev, VFL_TYPE_RADIO, radio_nr)) {
fmerr("Could not register video device\n");
return -ENOMEM;
}

- fmdev->radio_dev = &gradio_dev;
-
/* Register to v4l2 ctrl handler framework */
- fmdev->radio_dev->ctrl_handler = &fmdev->ctrl_handler;
+ fmdev->radio_dev.ctrl_handler = &fmdev->ctrl_handler;

ret = v4l2_ctrl_handler_init(&fmdev->ctrl_handler, 5);
if (ret < 0) {
@@ -594,20 +589,13 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr)
return 0;
}

-void *fm_v4l2_deinit_video_device(void)
+void fm_v4l2_deinit_video_device(struct fmdev *fmdev)
{
- struct fmdev *fmdev;
-
-
- fmdev = video_get_drvdata(&gradio_dev);
-
/* Unregister to v4l2 ctrl handler framework*/
v4l2_ctrl_handler_free(&fmdev->ctrl_handler);

/* Unregister RADIO device from V4L2 subsystem */
- video_unregister_device(&gradio_dev);
+ video_unregister_device(&fmdev->radio_dev);

v4l2_device_unregister(&fmdev->v4l2_dev);
-
- return fmdev;
}
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.h b/drivers/media/radio/wl128x/fmdrv_v4l2.h
index 9babb4ab2fad..b1a117eb0eb7 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.h
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.h
@@ -24,6 +24,6 @@
#include <media/v4l2-ctrls.h>

int fm_v4l2_init_video_device(struct fmdev *, int);
-void *fm_v4l2_deinit_video_device(void);
+void fm_v4l2_deinit_video_device(struct fmdev *);

#endif
--
2.19.2


2018-12-21 01:19:58

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 04/14] media: wl128x-radio: remove module version

From: Sebastian Reichel <[email protected]>

Drop module version. We already have the kernel's version and
this module is mainline.

Signed-off-by: Sebastian Reichel <[email protected]>
---
drivers/media/radio/wl128x/fmdrv.h | 1 -
drivers/media/radio/wl128x/fmdrv_common.c | 5 ++---
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h
index 1ff2eec4ed52..8ed7c0aeb8b9 100644
--- a/drivers/media/radio/wl128x/fmdrv.h
+++ b/drivers/media/radio/wl128x/fmdrv.h
@@ -29,7 +29,6 @@
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>

-#define FM_DRV_VERSION "0.1.1"
#define FM_DRV_NAME "ti_fmdrv"
#define FM_DRV_CARD_SHORT_NAME "TI FM Radio"
#define FM_DRV_CARD_LONG_NAME "Texas Instruments FM Radio"
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index 800d69c3f80b..6bbae074f02d 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1622,7 +1622,7 @@ static int __init fm_drv_init(void)
struct fmdev *fmdev = NULL;
int ret = -ENOMEM;

- fmdbg("FM driver version %s\n", FM_DRV_VERSION);
+ fmdbg("FM driver\n");

fmdev = kzalloc(sizeof(struct fmdev), GFP_KERNEL);
if (NULL == fmdev) {
@@ -1671,6 +1671,5 @@ module_exit(fm_drv_exit);

/* ------------- Module Info ------------- */
MODULE_AUTHOR("Manjunatha Halli <[email protected]>");
-MODULE_DESCRIPTION("FM Driver for TI's Connectivity chip. " FM_DRV_VERSION);
-MODULE_VERSION(FM_DRV_VERSION);
+MODULE_DESCRIPTION("FM Driver for TI's Connectivity chip");
MODULE_LICENSE("GPL");
--
2.19.2


2018-12-21 01:20:14

by Sebastian Reichel

[permalink] [raw]
Subject: [PATCH 03/14] ARM: OMAP2+: pdata-quirks: drop TI_ST/KIM support

From: Sebastian Reichel <[email protected]>

All TI_ST users have been migrated to the new serdev based HCILL
bluetooth driver. That driver is initialized from DT and does not
need any platform quirks.

Signed-off-by: Sebastian Reichel <[email protected]>
---
arch/arm/mach-omap2/pdata-quirks.c | 52 ------------------------------
1 file changed, 52 deletions(-)

diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index 9fec5f84bf77..2bd83ac74b7a 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -14,7 +14,6 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/of_platform.h>
-#include <linux/ti_wilink_st.h>
#include <linux/wl12xx.h>
#include <linux/mmc/card.h>
#include <linux/mmc/host.h>
@@ -141,53 +140,6 @@ static void __init omap3_sbc_t3530_legacy_init(void)
omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
}

-static struct ti_st_plat_data wilink_pdata = {
- .nshutdown_gpio = 137,
- .dev_name = "/dev/ttyO1",
- .flow_cntrl = 1,
- .baud_rate = 300000,
-};
-
-static struct platform_device wl18xx_device = {
- .name = "kim",
- .id = -1,
- .dev = {
- .platform_data = &wilink_pdata,
- }
-};
-
-static struct ti_st_plat_data wilink7_pdata = {
- .nshutdown_gpio = 162,
- .dev_name = "/dev/ttyO1",
- .flow_cntrl = 1,
- .baud_rate = 3000000,
-};
-
-static struct platform_device wl128x_device = {
- .name = "kim",
- .id = -1,
- .dev = {
- .platform_data = &wilink7_pdata,
- }
-};
-
-static struct platform_device btwilink_device = {
- .name = "btwilink",
- .id = -1,
-};
-
-static void __init omap3_igep0020_rev_f_legacy_init(void)
-{
- platform_device_register(&wl18xx_device);
- platform_device_register(&btwilink_device);
-}
-
-static void __init omap3_igep0030_rev_g_legacy_init(void)
-{
- platform_device_register(&wl18xx_device);
- platform_device_register(&btwilink_device);
-}
-
static void __init omap3_evm_legacy_init(void)
{
hsmmc2_internal_input_clk();
@@ -301,8 +253,6 @@ static void __init omap3_tao3530_legacy_init(void)
static void __init omap3_logicpd_torpedo_init(void)
{
omap3_gpio126_127_129();
- platform_device_register(&wl128x_device);
- platform_device_register(&btwilink_device);
}

/* omap3pandora legacy devices */
@@ -623,8 +573,6 @@ static struct pdata_init pdata_quirks[] __initdata = {
{ "nokia,omap3-n900", nokia_n900_legacy_init, },
{ "nokia,omap3-n9", hsmmc2_internal_input_clk, },
{ "nokia,omap3-n950", hsmmc2_internal_input_clk, },
- { "isee,omap3-igep0020-rev-f", omap3_igep0020_rev_f_legacy_init, },
- { "isee,omap3-igep0030-rev-g", omap3_igep0030_rev_g_legacy_init, },
{ "logicpd,dm3730-torpedo-devkit", omap3_logicpd_torpedo_init, },
{ "ti,omap3-evm-37xx", omap3_evm_legacy_init, },
{ "ti,am3517-evm", am3517_evm_legacy_init, },
--
2.19.2


2018-12-21 18:02:16

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

* Sebastian Reichel <[email protected]> [181221 01:18]:
> The new code has been tested on the Motorola Droid 4. For testing the audio
> should be configured to route Ext to Speaker or Headphone. Then you need to
> plug headphone, since its cable is used as antenna. For testing there is a
> 'radio' utility packages in Debian. When you start the utility you need to
> specify a frequency, since initial get_frequency returns an error:

Nice, good to see that ti-st kim stuff gone :) I gave this a quick
try using fmtools.git and fmscan works just fine. No luck yet with
fm though, it gives VIDIOC_G_CTRL: Not a tty error somehow so
maybe I'm missing some options, patch below for omap2plus_defconfig.

Hmm so looks like nothing to configure for the clocks or
CPCAP_BIT_ST_L_TIMESLOT bits for cap for the EXT? So the
wl12xx audio is wired directly to cpcap EXT then and not a
TDM slot on the mcbsp huh?

> Merry Christmas!

Same to you!

Tony

8< --------------------------------
From tony Mon Sep 17 00:00:00 2001
From: Tony Lindgren <[email protected]>
Date: Fri, 21 Dec 2018 07:57:09 -0800
Subject: [PATCH] ARM: omap2plus_defconfig: Add RADIO_WL128X as a loadable
module

This allows using the FM radio in the wl12xx chips after modprobe
fm_drv using radio from xawt, or fmtools.

Note that the firmware placed into /lib/firmware/ti-connectivity
directory:

fm_rx_ch8_1283.2.bts
fmc_ch8_1283.2.bts

Signed-off-by: Tony Lindgren <[email protected]>
---
arch/arm/configs/omap2plus_defconfig | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -126,6 +126,7 @@ CONFIG_AF_RXRPC=m
CONFIG_RXKAD=y
CONFIG_CFG80211=m
CONFIG_MAC80211=m
+CONFIG_RFKILL=m
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_DMA_CMA=y
@@ -343,12 +344,14 @@ CONFIG_IR_GPIO_TX=m
CONFIG_IR_PWM_TX=m
CONFIG_MEDIA_SUPPORT=m
CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_MEDIA_RADIO_SUPPORT=y
CONFIG_MEDIA_CEC_SUPPORT=y
CONFIG_MEDIA_CONTROLLER=y
CONFIG_VIDEO_V4L2_SUBDEV_API=y
CONFIG_V4L_PLATFORM_DRIVERS=y
CONFIG_VIDEO_OMAP3=m
CONFIG_CEC_PLATFORM_DRIVERS=y
+CONFIG_RADIO_WL128X=m
# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
CONFIG_VIDEO_TVP5150=m
CONFIG_DRM=m
--
2.19.2

2018-12-21 20:06:12

by Adam Ford

[permalink] [raw]
Subject: Re: [PATCH 01/14] ARM: dts: LogicPD Torpedo: Add WiLink UART node

On Thu, Dec 20, 2018 at 7:18 PM Sebastian Reichel <[email protected]> wrote:
>
> From: Sebastian Reichel <[email protected]>
>
> Add a node for the UART part of WiLink chip.
>
> Cc: Adam Ford <[email protected]>
> Signed-off-by: Sebastian Reichel <[email protected]>
> ---
> This is compile tested only!


I have tried this a few times, unfortunately, I cannot get the wl1283
to load the BT Firmware without timing out. The btwilink driver is
the only option that works for me.

[ 22.809600] Bluetooth: hci0: command 0xfd1c tx timeout
[ 31.206390] Bluetooth: hci0: send command failed
[ 31.211334] Bluetooth: hci0: download firmware failed, retrying...
[ 31.367767] Bluetooth: hci0: change remote baud rate command in firmware
[ 38.166351] Bluetooth: hci0: command 0xfd1c tx timeout
[ 46.566375] Bluetooth: hci0: send command failed
[ 46.571289] Bluetooth: hci0: download firmware failed, retrying...
[ 46.738250] Bluetooth: hci0: change remote baud rate command in firmware
[ 53.526336] Bluetooth: hci0: command 0xfd1c tx timeout

It times out, and tries again....and again....

Unless there is a driver fix to the BT UART, I don't think this should
be applied since I don't know what will happen if/when I try to use
the btwilink driver.

Having said that, I have no issues with the wl18xx and a wl127x on
other boards who don't need the btwilink driver. I think it's somehow
related to the wl1283

adam

> ---
> arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
> index 9d5d53fbe9c0..2699da12dc2d 100644
> --- a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
> +++ b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
> @@ -54,6 +54,14 @@
> };
> };
>
> +&uart2 {
> + bluetooth {
> + compatible = "ti,wl1283-st";
> + enable-gpios = <&gpio6 2 GPIO_ACTIVE_HIGH>; /* gpio 162 */
> + max-speed = <3000000>;
> + };
> +};
> +
> &omap3_pmx_core {
> mmc3_pins: pinmux_mm3_pins {
> pinctrl-single,pins = <
> --
> 2.19.2
>

2018-12-21 21:11:16

by Adam Ford

[permalink] [raw]
Subject: Re: [PATCH 14/14] misc: ti-st: Drop superseded driver

On Fri, Dec 21, 2018 at 2:13 AM Sebastian Reichel <[email protected]> wrote:
>
> From: Sebastian Reichel <[email protected]>
>
> This driver has been superseded by the serdev based Bluetooth
> hci_ll driver, which is initialized from DT. All mainline users
> have been converted and this driver can be safely dropped.

There seems to be an issue with my wl1283 because the
logicod-torpedo-37xx-devkit doesn't work with the proposed device tree
changes, but the older shared transport driver still works.
I commented on the patch that modifies the board with details of the
firmware timeout.

Until this is resolved, I'd like to hold off on applying these changes.

Also, there are references to this driver inside pdata-quirks that
need to be removed as well once the loading and timeout issues have
been resolved.

adam
>
> Signed-off-by: Sebastian Reichel <[email protected]>
> ---
> drivers/misc/Kconfig | 1 -
> drivers/misc/Makefile | 1 -
> drivers/misc/ti-st/Kconfig | 18 -
> drivers/misc/ti-st/Makefile | 6 -
> drivers/misc/ti-st/st_core.c | 922 -----------------------------------
> drivers/misc/ti-st/st_kim.c | 868 ---------------------------------
> drivers/misc/ti-st/st_ll.c | 169 -------
> include/linux/ti_wilink_st.h | 335 -------------
> 8 files changed, 2320 deletions(-)
> delete mode 100644 drivers/misc/ti-st/Kconfig
> delete mode 100644 drivers/misc/ti-st/Makefile
> delete mode 100644 drivers/misc/ti-st/st_core.c
> delete mode 100644 drivers/misc/ti-st/st_kim.c
> delete mode 100644 drivers/misc/ti-st/st_ll.c
>
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 3726eacdf65d..a5cc07d33c74 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -516,7 +516,6 @@ config MISC_RTSX
> source "drivers/misc/c2port/Kconfig"
> source "drivers/misc/eeprom/Kconfig"
> source "drivers/misc/cb710/Kconfig"
> -source "drivers/misc/ti-st/Kconfig"
> source "drivers/misc/lis3lv02d/Kconfig"
> source "drivers/misc/altera-stapl/Kconfig"
> source "drivers/misc/mei/Kconfig"
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index af22bbc3d00c..31c1e3eb4952 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -39,7 +39,6 @@ obj-y += cb710/
> obj-$(CONFIG_SPEAR13XX_PCIE_GADGET) += spear13xx_pcie_gadget.o
> obj-$(CONFIG_VMWARE_BALLOON) += vmw_balloon.o
> obj-$(CONFIG_PCH_PHUB) += pch_phub.o
> -obj-y += ti-st/
> obj-y += lis3lv02d/
> obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o
> obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/
> diff --git a/drivers/misc/ti-st/Kconfig b/drivers/misc/ti-st/Kconfig
> deleted file mode 100644
> index 5bb92698bc80..000000000000
> --- a/drivers/misc/ti-st/Kconfig
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -#
> -# TI's shared transport line discipline and the protocol
> -# drivers (BT, FM and GPS)
> -#
> -menu "Texas Instruments shared transport line discipline"
> -config TI_ST
> - tristate "Shared transport core driver"
> - depends on NET && TTY
> - depends on GPIOLIB || COMPILE_TEST
> - select FW_LOADER
> - help
> - This enables the shared transport core driver for TI
> - BT / FM and GPS combo chips. This enables protocol drivers
> - to register themselves with core and send data, the responses
> - are returned to relevant protocol drivers based on their
> - packet types.
> -
> -endmenu
> diff --git a/drivers/misc/ti-st/Makefile b/drivers/misc/ti-st/Makefile
> deleted file mode 100644
> index 78d7ebb14749..000000000000
> --- a/drivers/misc/ti-st/Makefile
> +++ /dev/null
> @@ -1,6 +0,0 @@
> -#
> -# Makefile for TI's shared transport line discipline
> -# and its protocol drivers (BT, FM, GPS)
> -#
> -obj-$(CONFIG_TI_ST) += st_drv.o
> -st_drv-objs := st_core.o st_kim.o st_ll.o
> diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
> deleted file mode 100644
> index eda8d407be28..000000000000
> --- a/drivers/misc/ti-st/st_core.c
> +++ /dev/null
> @@ -1,922 +0,0 @@
> -/*
> - * Shared Transport Line discipline driver Core
> - * This hooks up ST KIM driver and ST LL driver
> - * Copyright (C) 2009-2010 Texas Instruments
> - * Author: Pavan Savoy <[email protected]>
> - *
> - * 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.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> - *
> - */
> -
> -#define pr_fmt(fmt) "(stc): " fmt
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> -#include <linux/tty.h>
> -
> -#include <linux/seq_file.h>
> -#include <linux/skbuff.h>
> -
> -#include <linux/ti_wilink_st.h>
> -
> -extern void st_kim_recv(void *, const unsigned char *, long);
> -void st_int_recv(void *, const unsigned char *, long);
> -/* function pointer pointing to either,
> - * st_kim_recv during registration to receive fw download responses
> - * st_int_recv after registration to receive proto stack responses
> - */
> -static void (*st_recv) (void *, const unsigned char *, long);
> -
> -/********************************************************************/
> -static void add_channel_to_table(struct st_data_s *st_gdata,
> - struct st_proto_s *new_proto)
> -{
> - pr_info("%s: id %d\n", __func__, new_proto->chnl_id);
> - /* list now has the channel id as index itself */
> - st_gdata->list[new_proto->chnl_id] = new_proto;
> - st_gdata->is_registered[new_proto->chnl_id] = true;
> -}
> -
> -static void remove_channel_from_table(struct st_data_s *st_gdata,
> - struct st_proto_s *proto)
> -{
> - pr_info("%s: id %d\n", __func__, proto->chnl_id);
> -/* st_gdata->list[proto->chnl_id] = NULL; */
> - st_gdata->is_registered[proto->chnl_id] = false;
> -}
> -
> -/*
> - * called from KIM during firmware download.
> - *
> - * This is a wrapper function to tty->ops->write_room.
> - * It returns number of free space available in
> - * uart tx buffer.
> - */
> -int st_get_uart_wr_room(struct st_data_s *st_gdata)
> -{
> - struct tty_struct *tty;
> - if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
> - pr_err("tty unavailable to perform write");
> - return -1;
> - }
> - tty = st_gdata->tty;
> - return tty->ops->write_room(tty);
> -}
> -
> -/* can be called in from
> - * -- KIM (during fw download)
> - * -- ST Core (during st_write)
> - *
> - * This is the internal write function - a wrapper
> - * to tty->ops->write
> - */
> -int st_int_write(struct st_data_s *st_gdata,
> - const unsigned char *data, int count)
> -{
> - struct tty_struct *tty;
> - if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) {
> - pr_err("tty unavailable to perform write");
> - return -EINVAL;
> - }
> - tty = st_gdata->tty;
> -#ifdef VERBOSE
> - print_hex_dump(KERN_DEBUG, "<out<", DUMP_PREFIX_NONE,
> - 16, 1, data, count, 0);
> -#endif
> - return tty->ops->write(tty, data, count);
> -
> -}
> -
> -/*
> - * push the skb received to relevant
> - * protocol stacks
> - */
> -static void st_send_frame(unsigned char chnl_id, struct st_data_s *st_gdata)
> -{
> - pr_debug(" %s(prot:%d) ", __func__, chnl_id);
> -
> - if (unlikely
> - (st_gdata == NULL || st_gdata->rx_skb == NULL
> - || st_gdata->is_registered[chnl_id] == false)) {
> - pr_err("chnl_id %d not registered, no data to send?",
> - chnl_id);
> - kfree_skb(st_gdata->rx_skb);
> - return;
> - }
> - /* this cannot fail
> - * this shouldn't take long
> - * - should be just skb_queue_tail for the
> - * protocol stack driver
> - */
> - if (likely(st_gdata->list[chnl_id]->recv != NULL)) {
> - if (unlikely
> - (st_gdata->list[chnl_id]->recv
> - (st_gdata->list[chnl_id]->priv_data, st_gdata->rx_skb)
> - != 0)) {
> - pr_err(" proto stack %d's ->recv failed", chnl_id);
> - kfree_skb(st_gdata->rx_skb);
> - return;
> - }
> - } else {
> - pr_err(" proto stack %d's ->recv null", chnl_id);
> - kfree_skb(st_gdata->rx_skb);
> - }
> - return;
> -}
> -
> -/**
> - * st_reg_complete -
> - * to call registration complete callbacks
> - * of all protocol stack drivers
> - * This function is being called with spin lock held, protocol drivers are
> - * only expected to complete their waits and do nothing more than that.
> - */
> -static void st_reg_complete(struct st_data_s *st_gdata, int err)
> -{
> - unsigned char i = 0;
> - pr_info(" %s ", __func__);
> - for (i = 0; i < ST_MAX_CHANNELS; i++) {
> - if (likely(st_gdata != NULL &&
> - st_gdata->is_registered[i] == true &&
> - st_gdata->list[i]->reg_complete_cb != NULL)) {
> - st_gdata->list[i]->reg_complete_cb
> - (st_gdata->list[i]->priv_data, err);
> - pr_info("protocol %d's cb sent %d\n", i, err);
> - if (err) { /* cleanup registered protocol */
> - st_gdata->is_registered[i] = false;
> - if (st_gdata->protos_registered)
> - st_gdata->protos_registered--;
> - }
> - }
> - }
> -}
> -
> -static inline int st_check_data_len(struct st_data_s *st_gdata,
> - unsigned char chnl_id, int len)
> -{
> - int room = skb_tailroom(st_gdata->rx_skb);
> -
> - pr_debug("len %d room %d", len, room);
> -
> - if (!len) {
> - /* Received packet has only packet header and
> - * has zero length payload. So, ask ST CORE to
> - * forward the packet to protocol driver (BT/FM/GPS)
> - */
> - st_send_frame(chnl_id, st_gdata);
> -
> - } else if (len > room) {
> - /* Received packet's payload length is larger.
> - * We can't accommodate it in created skb.
> - */
> - pr_err("Data length is too large len %d room %d", len,
> - room);
> - kfree_skb(st_gdata->rx_skb);
> - } else {
> - /* Packet header has non-zero payload length and
> - * we have enough space in created skb. Lets read
> - * payload data */
> - st_gdata->rx_state = ST_W4_DATA;
> - st_gdata->rx_count = len;
> - return len;
> - }
> -
> - /* Change ST state to continue to process next
> - * packet */
> - st_gdata->rx_state = ST_W4_PACKET_TYPE;
> - st_gdata->rx_skb = NULL;
> - st_gdata->rx_count = 0;
> - st_gdata->rx_chnl = 0;
> -
> - return 0;
> -}
> -
> -/**
> - * st_wakeup_ack - internal function for action when wake-up ack
> - * received
> - */
> -static inline void st_wakeup_ack(struct st_data_s *st_gdata,
> - unsigned char cmd)
> -{
> - struct sk_buff *waiting_skb;
> - unsigned long flags = 0;
> -
> - spin_lock_irqsave(&st_gdata->lock, flags);
> - /* de-Q from waitQ and Q in txQ now that the
> - * chip is awake
> - */
> - while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq)))
> - skb_queue_tail(&st_gdata->txq, waiting_skb);
> -
> - /* state forwarded to ST LL */
> - st_ll_sleep_state(st_gdata, (unsigned long)cmd);
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> -
> - /* wake up to send the recently copied skbs from waitQ */
> - st_tx_wakeup(st_gdata);
> -}
> -
> -/**
> - * st_int_recv - ST's internal receive function.
> - * Decodes received RAW data and forwards to corresponding
> - * client drivers (Bluetooth,FM,GPS..etc).
> - * This can receive various types of packets,
> - * HCI-Events, ACL, SCO, 4 types of HCI-LL PM packets
> - * CH-8 packets from FM, CH-9 packets from GPS cores.
> - */
> -void st_int_recv(void *disc_data,
> - const unsigned char *data, long count)
> -{
> - char *ptr;
> - struct st_proto_s *proto;
> - unsigned short payload_len = 0;
> - int len = 0;
> - unsigned char type = 0;
> - unsigned char *plen;
> - struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
> - unsigned long flags;
> -
> - ptr = (char *)data;
> - /* tty_receive sent null ? */
> - if (unlikely(ptr == NULL) || (st_gdata == NULL)) {
> - pr_err(" received null from TTY ");
> - return;
> - }
> -
> - pr_debug("count %ld rx_state %ld"
> - "rx_count %ld", count, st_gdata->rx_state,
> - st_gdata->rx_count);
> -
> - spin_lock_irqsave(&st_gdata->lock, flags);
> - /* Decode received bytes here */
> - while (count) {
> - if (st_gdata->rx_count) {
> - len = min_t(unsigned int, st_gdata->rx_count, count);
> - skb_put_data(st_gdata->rx_skb, ptr, len);
> - st_gdata->rx_count -= len;
> - count -= len;
> - ptr += len;
> -
> - if (st_gdata->rx_count)
> - continue;
> -
> - /* Check ST RX state machine , where are we? */
> - switch (st_gdata->rx_state) {
> - /* Waiting for complete packet ? */
> - case ST_W4_DATA:
> - pr_debug("Complete pkt received");
> - /* Ask ST CORE to forward
> - * the packet to protocol driver */
> - st_send_frame(st_gdata->rx_chnl, st_gdata);
> -
> - st_gdata->rx_state = ST_W4_PACKET_TYPE;
> - st_gdata->rx_skb = NULL;
> - continue;
> - /* parse the header to know details */
> - case ST_W4_HEADER:
> - proto = st_gdata->list[st_gdata->rx_chnl];
> - plen =
> - &st_gdata->rx_skb->data
> - [proto->offset_len_in_hdr];
> - pr_debug("plen pointing to %x\n", *plen);
> - if (proto->len_size == 1)/* 1 byte len field */
> - payload_len = *(unsigned char *)plen;
> - else if (proto->len_size == 2)
> - payload_len =
> - __le16_to_cpu(*(unsigned short *)plen);
> - else
> - pr_info("%s: invalid length "
> - "for id %d\n",
> - __func__, proto->chnl_id);
> - st_check_data_len(st_gdata, proto->chnl_id,
> - payload_len);
> - pr_debug("off %d, pay len %d\n",
> - proto->offset_len_in_hdr, payload_len);
> - continue;
> - } /* end of switch rx_state */
> - }
> -
> - /* end of if rx_count */
> - /* Check first byte of packet and identify module
> - * owner (BT/FM/GPS) */
> - switch (*ptr) {
> - case LL_SLEEP_IND:
> - case LL_SLEEP_ACK:
> - case LL_WAKE_UP_IND:
> - pr_debug("PM packet");
> - /* this takes appropriate action based on
> - * sleep state received --
> - */
> - st_ll_sleep_state(st_gdata, *ptr);
> - /* if WAKEUP_IND collides copy from waitq to txq
> - * and assume chip awake
> - */
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - if (st_ll_getstate(st_gdata) == ST_LL_AWAKE)
> - st_wakeup_ack(st_gdata, LL_WAKE_UP_ACK);
> - spin_lock_irqsave(&st_gdata->lock, flags);
> -
> - ptr++;
> - count--;
> - continue;
> - case LL_WAKE_UP_ACK:
> - pr_debug("PM packet");
> -
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - /* wake up ack received */
> - st_wakeup_ack(st_gdata, *ptr);
> - spin_lock_irqsave(&st_gdata->lock, flags);
> -
> - ptr++;
> - count--;
> - continue;
> - /* Unknow packet? */
> - default:
> - type = *ptr;
> -
> - /* Default case means non-HCILL packets,
> - * possibilities are packets for:
> - * (a) valid protocol - Supported Protocols within
> - * the ST_MAX_CHANNELS.
> - * (b) registered protocol - Checked by
> - * "st_gdata->list[type] == NULL)" are supported
> - * protocols only.
> - * Rules out any invalid protocol and
> - * unregistered protocols with channel ID < 16.
> - */
> -
> - if ((type >= ST_MAX_CHANNELS) ||
> - (st_gdata->list[type] == NULL)) {
> - pr_err("chip/interface misbehavior: "
> - "dropping frame starting "
> - "with 0x%02x\n", type);
> - goto done;
> - }
> -
> - st_gdata->rx_skb = alloc_skb(
> - st_gdata->list[type]->max_frame_size,
> - GFP_ATOMIC);
> - if (st_gdata->rx_skb == NULL) {
> - pr_err("out of memory: dropping\n");
> - goto done;
> - }
> -
> - skb_reserve(st_gdata->rx_skb,
> - st_gdata->list[type]->reserve);
> - /* next 2 required for BT only */
> - st_gdata->rx_skb->cb[0] = type; /*pkt_type*/
> - st_gdata->rx_skb->cb[1] = 0; /*incoming*/
> - st_gdata->rx_chnl = *ptr;
> - st_gdata->rx_state = ST_W4_HEADER;
> - st_gdata->rx_count = st_gdata->list[type]->hdr_len;
> - pr_debug("rx_count %ld\n", st_gdata->rx_count);
> - };
> - ptr++;
> - count--;
> - }
> -done:
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - pr_debug("done %s", __func__);
> - return;
> -}
> -
> -/**
> - * st_int_dequeue - internal de-Q function.
> - * If the previous data set was not written
> - * completely, return that skb which has the pending data.
> - * In normal cases, return top of txq.
> - */
> -static struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata)
> -{
> - struct sk_buff *returning_skb;
> -
> - pr_debug("%s", __func__);
> - if (st_gdata->tx_skb != NULL) {
> - returning_skb = st_gdata->tx_skb;
> - st_gdata->tx_skb = NULL;
> - return returning_skb;
> - }
> - return skb_dequeue(&st_gdata->txq);
> -}
> -
> -/**
> - * st_int_enqueue - internal Q-ing function.
> - * Will either Q the skb to txq or the tx_waitq
> - * depending on the ST LL state.
> - * If the chip is asleep, then Q it onto waitq and
> - * wakeup the chip.
> - * txq and waitq needs protection since the other contexts
> - * may be sending data, waking up chip.
> - */
> -static void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb)
> -{
> - unsigned long flags = 0;
> -
> - pr_debug("%s", __func__);
> - spin_lock_irqsave(&st_gdata->lock, flags);
> -
> - switch (st_ll_getstate(st_gdata)) {
> - case ST_LL_AWAKE:
> - pr_debug("ST LL is AWAKE, sending normally");
> - skb_queue_tail(&st_gdata->txq, skb);
> - break;
> - case ST_LL_ASLEEP_TO_AWAKE:
> - skb_queue_tail(&st_gdata->tx_waitq, skb);
> - break;
> - case ST_LL_AWAKE_TO_ASLEEP:
> - pr_err("ST LL is illegal state(%ld),"
> - "purging received skb.", st_ll_getstate(st_gdata));
> - kfree_skb(skb);
> - break;
> - case ST_LL_ASLEEP:
> - skb_queue_tail(&st_gdata->tx_waitq, skb);
> - st_ll_wakeup(st_gdata);
> - break;
> - default:
> - pr_err("ST LL is illegal state(%ld),"
> - "purging received skb.", st_ll_getstate(st_gdata));
> - kfree_skb(skb);
> - break;
> - }
> -
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - pr_debug("done %s", __func__);
> - return;
> -}
> -
> -/*
> - * internal wakeup function
> - * called from either
> - * - TTY layer when write's finished
> - * - st_write (in context of the protocol stack)
> - */
> -static void work_fn_write_wakeup(struct work_struct *work)
> -{
> - struct st_data_s *st_gdata = container_of(work, struct st_data_s,
> - work_write_wakeup);
> -
> - st_tx_wakeup((void *)st_gdata);
> -}
> -void st_tx_wakeup(struct st_data_s *st_data)
> -{
> - struct sk_buff *skb;
> - unsigned long flags; /* for irq save flags */
> - pr_debug("%s", __func__);
> - /* check for sending & set flag sending here */
> - if (test_and_set_bit(ST_TX_SENDING, &st_data->tx_state)) {
> - pr_debug("ST already sending");
> - /* keep sending */
> - set_bit(ST_TX_WAKEUP, &st_data->tx_state);
> - return;
> - /* TX_WAKEUP will be checked in another
> - * context
> - */
> - }
> - do { /* come back if st_tx_wakeup is set */
> - /* woke-up to write */
> - clear_bit(ST_TX_WAKEUP, &st_data->tx_state);
> - while ((skb = st_int_dequeue(st_data))) {
> - int len;
> - spin_lock_irqsave(&st_data->lock, flags);
> - /* enable wake-up from TTY */
> - set_bit(TTY_DO_WRITE_WAKEUP, &st_data->tty->flags);
> - len = st_int_write(st_data, skb->data, skb->len);
> - skb_pull(skb, len);
> - /* if skb->len = len as expected, skb->len=0 */
> - if (skb->len) {
> - /* would be the next skb to be sent */
> - st_data->tx_skb = skb;
> - spin_unlock_irqrestore(&st_data->lock, flags);
> - break;
> - }
> - kfree_skb(skb);
> - spin_unlock_irqrestore(&st_data->lock, flags);
> - }
> - /* if wake-up is set in another context- restart sending */
> - } while (test_bit(ST_TX_WAKEUP, &st_data->tx_state));
> -
> - /* clear flag sending */
> - clear_bit(ST_TX_SENDING, &st_data->tx_state);
> -}
> -
> -/********************************************************************/
> -/* functions called from ST KIM
> -*/
> -void kim_st_list_protocols(struct st_data_s *st_gdata, void *buf)
> -{
> - seq_printf(buf, "[%d]\nBT=%c\nFM=%c\nGPS=%c\n",
> - st_gdata->protos_registered,
> - st_gdata->is_registered[0x04] == true ? 'R' : 'U',
> - st_gdata->is_registered[0x08] == true ? 'R' : 'U',
> - st_gdata->is_registered[0x09] == true ? 'R' : 'U');
> -}
> -
> -/********************************************************************/
> -/*
> - * functions called from protocol stack drivers
> - * to be EXPORT-ed
> - */
> -long st_register(struct st_proto_s *new_proto)
> -{
> - struct st_data_s *st_gdata;
> - long err = 0;
> - unsigned long flags = 0;
> -
> - st_kim_ref(&st_gdata, 0);
> - if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL
> - || new_proto->reg_complete_cb == NULL) {
> - pr_err("gdata/new_proto/recv or reg_complete_cb not ready");
> - return -EINVAL;
> - }
> -
> - if (new_proto->chnl_id >= ST_MAX_CHANNELS) {
> - pr_err("chnl_id %d not supported", new_proto->chnl_id);
> - return -EPROTONOSUPPORT;
> - }
> -
> - if (st_gdata->is_registered[new_proto->chnl_id] == true) {
> - pr_err("chnl_id %d already registered", new_proto->chnl_id);
> - return -EALREADY;
> - }
> -
> - /* can be from process context only */
> - spin_lock_irqsave(&st_gdata->lock, flags);
> -
> - if (test_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state)) {
> - pr_info(" ST_REG_IN_PROGRESS:%d ", new_proto->chnl_id);
> - /* fw download in progress */
> -
> - add_channel_to_table(st_gdata, new_proto);
> - st_gdata->protos_registered++;
> - new_proto->write = st_write;
> -
> - set_bit(ST_REG_PENDING, &st_gdata->st_state);
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - return -EINPROGRESS;
> - } else if (st_gdata->protos_registered == ST_EMPTY) {
> - pr_info(" chnl_id list empty :%d ", new_proto->chnl_id);
> - set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
> - st_recv = st_kim_recv;
> -
> - /* enable the ST LL - to set default chip state */
> - st_ll_enable(st_gdata);
> -
> - /* release lock previously held - re-locked below */
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> -
> - /* this may take a while to complete
> - * since it involves BT fw download
> - */
> - err = st_kim_start(st_gdata->kim_data);
> - if (err != 0) {
> - clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
> - if ((st_gdata->protos_registered != ST_EMPTY) &&
> - (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
> - pr_err(" KIM failure complete callback ");
> - spin_lock_irqsave(&st_gdata->lock, flags);
> - st_reg_complete(st_gdata, err);
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - clear_bit(ST_REG_PENDING, &st_gdata->st_state);
> - }
> - return -EINVAL;
> - }
> -
> - spin_lock_irqsave(&st_gdata->lock, flags);
> -
> - clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state);
> - st_recv = st_int_recv;
> -
> - /* this is where all pending registration
> - * are signalled to be complete by calling callback functions
> - */
> - if ((st_gdata->protos_registered != ST_EMPTY) &&
> - (test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
> - pr_debug(" call reg complete callback ");
> - st_reg_complete(st_gdata, 0);
> - }
> - clear_bit(ST_REG_PENDING, &st_gdata->st_state);
> -
> - /* check for already registered once more,
> - * since the above check is old
> - */
> - if (st_gdata->is_registered[new_proto->chnl_id] == true) {
> - pr_err(" proto %d already registered ",
> - new_proto->chnl_id);
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - return -EALREADY;
> - }
> -
> - add_channel_to_table(st_gdata, new_proto);
> - st_gdata->protos_registered++;
> - new_proto->write = st_write;
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - return err;
> - }
> - /* if fw is already downloaded & new stack registers protocol */
> - else {
> - add_channel_to_table(st_gdata, new_proto);
> - st_gdata->protos_registered++;
> - new_proto->write = st_write;
> -
> - /* lock already held before entering else */
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - return err;
> - }
> -}
> -EXPORT_SYMBOL_GPL(st_register);
> -
> -/* to unregister a protocol -
> - * to be called from protocol stack driver
> - */
> -long st_unregister(struct st_proto_s *proto)
> -{
> - long err = 0;
> - unsigned long flags = 0;
> - struct st_data_s *st_gdata;
> -
> - pr_debug("%s: %d ", __func__, proto->chnl_id);
> -
> - st_kim_ref(&st_gdata, 0);
> - if (!st_gdata || proto->chnl_id >= ST_MAX_CHANNELS) {
> - pr_err(" chnl_id %d not supported", proto->chnl_id);
> - return -EPROTONOSUPPORT;
> - }
> -
> - spin_lock_irqsave(&st_gdata->lock, flags);
> -
> - if (st_gdata->is_registered[proto->chnl_id] == false) {
> - pr_err(" chnl_id %d not registered", proto->chnl_id);
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - return -EPROTONOSUPPORT;
> - }
> -
> - if (st_gdata->protos_registered)
> - st_gdata->protos_registered--;
> -
> - remove_channel_from_table(st_gdata, proto);
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> -
> - if ((st_gdata->protos_registered == ST_EMPTY) &&
> - (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) {
> - pr_info(" all chnl_ids unregistered ");
> -
> - /* stop traffic on tty */
> - if (st_gdata->tty) {
> - tty_ldisc_flush(st_gdata->tty);
> - stop_tty(st_gdata->tty);
> - }
> -
> - /* all chnl_ids now unregistered */
> - st_kim_stop(st_gdata->kim_data);
> - /* disable ST LL */
> - st_ll_disable(st_gdata);
> - }
> - return err;
> -}
> -
> -/*
> - * called in protocol stack drivers
> - * via the write function pointer
> - */
> -long st_write(struct sk_buff *skb)
> -{
> - struct st_data_s *st_gdata;
> - long len;
> -
> - st_kim_ref(&st_gdata, 0);
> - if (unlikely(skb == NULL || st_gdata == NULL
> - || st_gdata->tty == NULL)) {
> - pr_err("data/tty unavailable to perform write");
> - return -EINVAL;
> - }
> -
> - pr_debug("%d to be written", skb->len);
> - len = skb->len;
> -
> - /* st_ll to decide where to enqueue the skb */
> - st_int_enqueue(st_gdata, skb);
> - /* wake up */
> - st_tx_wakeup(st_gdata);
> -
> - /* return number of bytes written */
> - return len;
> -}
> -
> -/* for protocols making use of shared transport */
> -EXPORT_SYMBOL_GPL(st_unregister);
> -
> -/********************************************************************/
> -/*
> - * functions called from TTY layer
> - */
> -static int st_tty_open(struct tty_struct *tty)
> -{
> - int err = 0;
> - struct st_data_s *st_gdata;
> - pr_info("%s ", __func__);
> -
> - st_kim_ref(&st_gdata, 0);
> - st_gdata->tty = tty;
> - tty->disc_data = st_gdata;
> -
> - /* don't do an wakeup for now */
> - clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
> -
> - /* mem already allocated
> - */
> - tty->receive_room = 65536;
> - /* Flush any pending characters in the driver and discipline. */
> - tty_ldisc_flush(tty);
> - tty_driver_flush_buffer(tty);
> - /*
> - * signal to UIM via KIM that -
> - * installation of N_TI_WL ldisc is complete
> - */
> - st_kim_complete(st_gdata->kim_data);
> - pr_debug("done %s", __func__);
> - return err;
> -}
> -
> -static void st_tty_close(struct tty_struct *tty)
> -{
> - unsigned char i = ST_MAX_CHANNELS;
> - unsigned long flags = 0;
> - struct st_data_s *st_gdata = tty->disc_data;
> -
> - pr_info("%s ", __func__);
> -
> - /* TODO:
> - * if a protocol has been registered & line discipline
> - * un-installed for some reason - what should be done ?
> - */
> - spin_lock_irqsave(&st_gdata->lock, flags);
> - for (i = ST_BT; i < ST_MAX_CHANNELS; i++) {
> - if (st_gdata->is_registered[i] == true)
> - pr_err("%d not un-registered", i);
> - st_gdata->list[i] = NULL;
> - st_gdata->is_registered[i] = false;
> - }
> - st_gdata->protos_registered = 0;
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> - /*
> - * signal to UIM via KIM that -
> - * N_TI_WL ldisc is un-installed
> - */
> - st_kim_complete(st_gdata->kim_data);
> - st_gdata->tty = NULL;
> - /* Flush any pending characters in the driver and discipline. */
> - tty_ldisc_flush(tty);
> - tty_driver_flush_buffer(tty);
> -
> - spin_lock_irqsave(&st_gdata->lock, flags);
> - /* empty out txq and tx_waitq */
> - skb_queue_purge(&st_gdata->txq);
> - skb_queue_purge(&st_gdata->tx_waitq);
> - /* reset the TTY Rx states of ST */
> - st_gdata->rx_count = 0;
> - st_gdata->rx_state = ST_W4_PACKET_TYPE;
> - kfree_skb(st_gdata->rx_skb);
> - st_gdata->rx_skb = NULL;
> - spin_unlock_irqrestore(&st_gdata->lock, flags);
> -
> - pr_debug("%s: done ", __func__);
> -}
> -
> -static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
> - char *tty_flags, int count)
> -{
> -#ifdef VERBOSE
> - print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
> - 16, 1, data, count, 0);
> -#endif
> -
> - /*
> - * if fw download is in progress then route incoming data
> - * to KIM for validation
> - */
> - st_recv(tty->disc_data, data, count);
> - pr_debug("done %s", __func__);
> -}
> -
> -/* wake-up function called in from the TTY layer
> - * inside the internal wakeup function will be called
> - */
> -static void st_tty_wakeup(struct tty_struct *tty)
> -{
> - struct st_data_s *st_gdata = tty->disc_data;
> - pr_debug("%s ", __func__);
> - /* don't do an wakeup for now */
> - clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
> -
> - /*
> - * schedule the internal wakeup instead of calling directly to
> - * avoid lockup (port->lock needed in tty->ops->write is
> - * already taken here
> - */
> - schedule_work(&st_gdata->work_write_wakeup);
> -}
> -
> -static void st_tty_flush_buffer(struct tty_struct *tty)
> -{
> - struct st_data_s *st_gdata = tty->disc_data;
> - pr_debug("%s ", __func__);
> -
> - kfree_skb(st_gdata->tx_skb);
> - st_gdata->tx_skb = NULL;
> -
> - tty_driver_flush_buffer(tty);
> - return;
> -}
> -
> -static struct tty_ldisc_ops st_ldisc_ops = {
> - .magic = TTY_LDISC_MAGIC,
> - .name = "n_st",
> - .open = st_tty_open,
> - .close = st_tty_close,
> - .receive_buf = st_tty_receive,
> - .write_wakeup = st_tty_wakeup,
> - .flush_buffer = st_tty_flush_buffer,
> - .owner = THIS_MODULE
> -};
> -
> -/********************************************************************/
> -int st_core_init(struct st_data_s **core_data)
> -{
> - struct st_data_s *st_gdata;
> - long err;
> -
> - err = tty_register_ldisc(N_TI_WL, &st_ldisc_ops);
> - if (err) {
> - pr_err("error registering %d line discipline %ld",
> - N_TI_WL, err);
> - return err;
> - }
> - pr_debug("registered n_shared line discipline");
> -
> - st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL);
> - if (!st_gdata) {
> - pr_err("memory allocation failed");
> - err = tty_unregister_ldisc(N_TI_WL);
> - if (err)
> - pr_err("unable to un-register ldisc %ld", err);
> - err = -ENOMEM;
> - return err;
> - }
> -
> - /* Initialize ST TxQ and Tx waitQ queue head. All BT/FM/GPS module skb's
> - * will be pushed in this queue for actual transmission.
> - */
> - skb_queue_head_init(&st_gdata->txq);
> - skb_queue_head_init(&st_gdata->tx_waitq);
> -
> - /* Locking used in st_int_enqueue() to avoid multiple execution */
> - spin_lock_init(&st_gdata->lock);
> -
> - err = st_ll_init(st_gdata);
> - if (err) {
> - pr_err("error during st_ll initialization(%ld)", err);
> - kfree(st_gdata);
> - err = tty_unregister_ldisc(N_TI_WL);
> - if (err)
> - pr_err("unable to un-register ldisc");
> - return err;
> - }
> -
> - INIT_WORK(&st_gdata->work_write_wakeup, work_fn_write_wakeup);
> -
> - *core_data = st_gdata;
> - return 0;
> -}
> -
> -void st_core_exit(struct st_data_s *st_gdata)
> -{
> - long err;
> - /* internal module cleanup */
> - err = st_ll_deinit(st_gdata);
> - if (err)
> - pr_err("error during deinit of ST LL %ld", err);
> -
> - if (st_gdata != NULL) {
> - /* Free ST Tx Qs and skbs */
> - skb_queue_purge(&st_gdata->txq);
> - skb_queue_purge(&st_gdata->tx_waitq);
> - kfree_skb(st_gdata->rx_skb);
> - kfree_skb(st_gdata->tx_skb);
> - /* TTY ldisc cleanup */
> - err = tty_unregister_ldisc(N_TI_WL);
> - if (err)
> - pr_err("unable to un-register ldisc %ld", err);
> - /* free the global data pointer */
> - kfree(st_gdata);
> - }
> -}
> diff --git a/drivers/misc/ti-st/st_kim.c b/drivers/misc/ti-st/st_kim.c
> deleted file mode 100644
> index 1874ac922166..000000000000
> --- a/drivers/misc/ti-st/st_kim.c
> +++ /dev/null
> @@ -1,868 +0,0 @@
> -/*
> - * Shared Transport Line discipline driver Core
> - * Init Manager module responsible for GPIO control
> - * and firmware download
> - * Copyright (C) 2009-2010 Texas Instruments
> - * Author: Pavan Savoy <[email protected]>
> - *
> - * 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.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> - *
> - */
> -
> -#define pr_fmt(fmt) "(stk) :" fmt
> -#include <linux/platform_device.h>
> -#include <linux/jiffies.h>
> -#include <linux/firmware.h>
> -#include <linux/delay.h>
> -#include <linux/wait.h>
> -#include <linux/gpio.h>
> -#include <linux/debugfs.h>
> -#include <linux/seq_file.h>
> -#include <linux/sched.h>
> -#include <linux/sysfs.h>
> -#include <linux/tty.h>
> -
> -#include <linux/skbuff.h>
> -#include <linux/ti_wilink_st.h>
> -#include <linux/module.h>
> -
> -#define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */
> -static struct platform_device *st_kim_devices[MAX_ST_DEVICES];
> -
> -/**********************************************************************/
> -/* internal functions */
> -
> -/**
> - * st_get_plat_device -
> - * function which returns the reference to the platform device
> - * requested by id. As of now only 1 such device exists (id=0)
> - * the context requesting for reference can get the id to be
> - * requested by a. The protocol driver which is registering or
> - * b. the tty device which is opened.
> - */
> -static struct platform_device *st_get_plat_device(int id)
> -{
> - return st_kim_devices[id];
> -}
> -
> -/**
> - * validate_firmware_response -
> - * function to return whether the firmware response was proper
> - * in case of error don't complete so that waiting for proper
> - * response times out
> - */
> -static void validate_firmware_response(struct kim_data_s *kim_gdata)
> -{
> - struct sk_buff *skb = kim_gdata->rx_skb;
> - if (!skb)
> - return;
> -
> - /* these magic numbers are the position in the response buffer which
> - * allows us to distinguish whether the response is for the read
> - * version info. command
> - */
> - if (skb->data[2] == 0x01 && skb->data[3] == 0x01 &&
> - skb->data[4] == 0x10 && skb->data[5] == 0x00) {
> - /* fw version response */
> - memcpy(kim_gdata->resp_buffer,
> - kim_gdata->rx_skb->data,
> - kim_gdata->rx_skb->len);
> - kim_gdata->rx_state = ST_W4_PACKET_TYPE;
> - kim_gdata->rx_skb = NULL;
> - kim_gdata->rx_count = 0;
> - } else if (unlikely(skb->data[5] != 0)) {
> - pr_err("no proper response during fw download");
> - pr_err("data6 %x", skb->data[5]);
> - kfree_skb(skb);
> - return; /* keep waiting for the proper response */
> - }
> - /* becos of all the script being downloaded */
> - complete_all(&kim_gdata->kim_rcvd);
> - kfree_skb(skb);
> -}
> -
> -/* check for data len received inside kim_int_recv
> - * most often hit the last case to update state to waiting for data
> - */
> -static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len)
> -{
> - register int room = skb_tailroom(kim_gdata->rx_skb);
> -
> - pr_debug("len %d room %d", len, room);
> -
> - if (!len) {
> - validate_firmware_response(kim_gdata);
> - } else if (len > room) {
> - /* Received packet's payload length is larger.
> - * We can't accommodate it in created skb.
> - */
> - pr_err("Data length is too large len %d room %d", len,
> - room);
> - kfree_skb(kim_gdata->rx_skb);
> - } else {
> - /* Packet header has non-zero payload length and
> - * we have enough space in created skb. Lets read
> - * payload data */
> - kim_gdata->rx_state = ST_W4_DATA;
> - kim_gdata->rx_count = len;
> - return len;
> - }
> -
> - /* Change ST LL state to continue to process next
> - * packet */
> - kim_gdata->rx_state = ST_W4_PACKET_TYPE;
> - kim_gdata->rx_skb = NULL;
> - kim_gdata->rx_count = 0;
> -
> - return 0;
> -}
> -
> -/**
> - * kim_int_recv - receive function called during firmware download
> - * firmware download responses on different UART drivers
> - * have been observed to come in bursts of different
> - * tty_receive and hence the logic
> - */
> -static void kim_int_recv(struct kim_data_s *kim_gdata,
> - const unsigned char *data, long count)
> -{
> - const unsigned char *ptr;
> - int len = 0;
> - unsigned char *plen;
> -
> - pr_debug("%s", __func__);
> - /* Decode received bytes here */
> - ptr = data;
> - if (unlikely(ptr == NULL)) {
> - pr_err(" received null from TTY ");
> - return;
> - }
> -
> - while (count) {
> - if (kim_gdata->rx_count) {
> - len = min_t(unsigned int, kim_gdata->rx_count, count);
> - skb_put_data(kim_gdata->rx_skb, ptr, len);
> - kim_gdata->rx_count -= len;
> - count -= len;
> - ptr += len;
> -
> - if (kim_gdata->rx_count)
> - continue;
> -
> - /* Check ST RX state machine , where are we? */
> - switch (kim_gdata->rx_state) {
> - /* Waiting for complete packet ? */
> - case ST_W4_DATA:
> - pr_debug("Complete pkt received");
> - validate_firmware_response(kim_gdata);
> - kim_gdata->rx_state = ST_W4_PACKET_TYPE;
> - kim_gdata->rx_skb = NULL;
> - continue;
> - /* Waiting for Bluetooth event header ? */
> - case ST_W4_HEADER:
> - plen =
> - (unsigned char *)&kim_gdata->rx_skb->data[1];
> - pr_debug("event hdr: plen 0x%02x\n", *plen);
> - kim_check_data_len(kim_gdata, *plen);
> - continue;
> - } /* end of switch */
> - } /* end of if rx_state */
> - switch (*ptr) {
> - /* Bluetooth event packet? */
> - case 0x04:
> - kim_gdata->rx_state = ST_W4_HEADER;
> - kim_gdata->rx_count = 2;
> - break;
> - default:
> - pr_info("unknown packet");
> - ptr++;
> - count--;
> - continue;
> - }
> - ptr++;
> - count--;
> - kim_gdata->rx_skb =
> - alloc_skb(1024+8, GFP_ATOMIC);
> - if (!kim_gdata->rx_skb) {
> - pr_err("can't allocate mem for new packet");
> - kim_gdata->rx_state = ST_W4_PACKET_TYPE;
> - kim_gdata->rx_count = 0;
> - return;
> - }
> - skb_reserve(kim_gdata->rx_skb, 8);
> - kim_gdata->rx_skb->cb[0] = 4;
> - kim_gdata->rx_skb->cb[1] = 0;
> -
> - }
> - return;
> -}
> -
> -static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
> -{
> - unsigned short version = 0, chip = 0, min_ver = 0, maj_ver = 0;
> - const char read_ver_cmd[] = { 0x01, 0x01, 0x10, 0x00 };
> - long timeout;
> -
> - pr_debug("%s", __func__);
> -
> - reinit_completion(&kim_gdata->kim_rcvd);
> - if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) {
> - pr_err("kim: couldn't write 4 bytes");
> - return -EIO;
> - }
> -
> - timeout = wait_for_completion_interruptible_timeout(
> - &kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME));
> - if (timeout <= 0) {
> - pr_err(" waiting for ver info- timed out or received signal");
> - return timeout ? -ERESTARTSYS : -ETIMEDOUT;
> - }
> - reinit_completion(&kim_gdata->kim_rcvd);
> - /* the positions 12 & 13 in the response buffer provide with the
> - * chip, major & minor numbers
> - */
> -
> - version =
> - MAKEWORD(kim_gdata->resp_buffer[12],
> - kim_gdata->resp_buffer[13]);
> - chip = (version & 0x7C00) >> 10;
> - min_ver = (version & 0x007F);
> - maj_ver = (version & 0x0380) >> 7;
> -
> - if (version & 0x8000)
> - maj_ver |= 0x0008;
> -
> - sprintf(bts_scr_name, "ti-connectivity/TIInit_%d.%d.%d.bts",
> - chip, maj_ver, min_ver);
> -
> - /* to be accessed later via sysfs entry */
> - kim_gdata->version.full = version;
> - kim_gdata->version.chip = chip;
> - kim_gdata->version.maj_ver = maj_ver;
> - kim_gdata->version.min_ver = min_ver;
> -
> - pr_info("%s", bts_scr_name);
> - return 0;
> -}
> -
> -static void skip_change_remote_baud(unsigned char **ptr, long *len)
> -{
> - unsigned char *nxt_action, *cur_action;
> - cur_action = *ptr;
> -
> - nxt_action = cur_action + sizeof(struct bts_action) +
> - ((struct bts_action *) cur_action)->size;
> -
> - if (((struct bts_action *) nxt_action)->type != ACTION_WAIT_EVENT) {
> - pr_err("invalid action after change remote baud command");
> - } else {
> - *ptr = *ptr + sizeof(struct bts_action) +
> - ((struct bts_action *)cur_action)->size;
> - *len = *len - (sizeof(struct bts_action) +
> - ((struct bts_action *)cur_action)->size);
> - /* warn user on not commenting these in firmware */
> - pr_warn("skipping the wait event of change remote baud");
> - }
> -}
> -
> -/**
> - * download_firmware -
> - * internal function which parses through the .bts firmware
> - * script file intreprets SEND, DELAY actions only as of now
> - */
> -static long download_firmware(struct kim_data_s *kim_gdata)
> -{
> - long err = 0;
> - long len = 0;
> - unsigned char *ptr = NULL;
> - unsigned char *action_ptr = NULL;
> - unsigned char bts_scr_name[40] = { 0 }; /* 40 char long bts scr name? */
> - int wr_room_space;
> - int cmd_size;
> - unsigned long timeout;
> -
> - err = read_local_version(kim_gdata, bts_scr_name);
> - if (err != 0) {
> - pr_err("kim: failed to read local ver");
> - return err;
> - }
> - err =
> - request_firmware(&kim_gdata->fw_entry, bts_scr_name,
> - &kim_gdata->kim_pdev->dev);
> - if (unlikely((err != 0) || (kim_gdata->fw_entry->data == NULL) ||
> - (kim_gdata->fw_entry->size == 0))) {
> - pr_err(" request_firmware failed(errno %ld) for %s", err,
> - bts_scr_name);
> - return -EINVAL;
> - }
> - ptr = (void *)kim_gdata->fw_entry->data;
> - len = kim_gdata->fw_entry->size;
> - /* bts_header to remove out magic number and
> - * version
> - */
> - ptr += sizeof(struct bts_header);
> - len -= sizeof(struct bts_header);
> -
> - while (len > 0 && ptr) {
> - pr_debug(" action size %d, type %d ",
> - ((struct bts_action *)ptr)->size,
> - ((struct bts_action *)ptr)->type);
> -
> - switch (((struct bts_action *)ptr)->type) {
> - case ACTION_SEND_COMMAND: /* action send */
> - pr_debug("S");
> - action_ptr = &(((struct bts_action *)ptr)->data[0]);
> - if (unlikely
> - (((struct hci_command *)action_ptr)->opcode ==
> - 0xFF36)) {
> - /* ignore remote change
> - * baud rate HCI VS command */
> - pr_warn("change remote baud"
> - " rate command in firmware");
> - skip_change_remote_baud(&ptr, &len);
> - break;
> - }
> - /*
> - * Make sure we have enough free space in uart
> - * tx buffer to write current firmware command
> - */
> - cmd_size = ((struct bts_action *)ptr)->size;
> - timeout = jiffies + msecs_to_jiffies(CMD_WR_TIME);
> - do {
> - wr_room_space =
> - st_get_uart_wr_room(kim_gdata->core_data);
> - if (wr_room_space < 0) {
> - pr_err("Unable to get free "
> - "space info from uart tx buffer");
> - release_firmware(kim_gdata->fw_entry);
> - return wr_room_space;
> - }
> - mdelay(1); /* wait 1ms before checking room */
> - } while ((wr_room_space < cmd_size) &&
> - time_before(jiffies, timeout));
> -
> - /* Timeout happened ? */
> - if (time_after_eq(jiffies, timeout)) {
> - pr_err("Timeout while waiting for free "
> - "free space in uart tx buffer");
> - release_firmware(kim_gdata->fw_entry);
> - return -ETIMEDOUT;
> - }
> - /* reinit completion before sending for the
> - * relevant wait
> - */
> - reinit_completion(&kim_gdata->kim_rcvd);
> -
> - /*
> - * Free space found in uart buffer, call st_int_write
> - * to send current firmware command to the uart tx
> - * buffer.
> - */
> - err = st_int_write(kim_gdata->core_data,
> - ((struct bts_action_send *)action_ptr)->data,
> - ((struct bts_action *)ptr)->size);
> - if (unlikely(err < 0)) {
> - release_firmware(kim_gdata->fw_entry);
> - return err;
> - }
> - /*
> - * Check number of bytes written to the uart tx buffer
> - * and requested command write size
> - */
> - if (err != cmd_size) {
> - pr_err("Number of bytes written to uart "
> - "tx buffer are not matching with "
> - "requested cmd write size");
> - release_firmware(kim_gdata->fw_entry);
> - return -EIO;
> - }
> - break;
> - case ACTION_WAIT_EVENT: /* wait */
> - pr_debug("W");
> - err = wait_for_completion_interruptible_timeout(
> - &kim_gdata->kim_rcvd,
> - msecs_to_jiffies(CMD_RESP_TIME));
> - if (err <= 0) {
> - pr_err("response timeout/signaled during fw download ");
> - /* timed out */
> - release_firmware(kim_gdata->fw_entry);
> - return err ? -ERESTARTSYS : -ETIMEDOUT;
> - }
> - reinit_completion(&kim_gdata->kim_rcvd);
> - break;
> - case ACTION_DELAY: /* sleep */
> - pr_info("sleep command in scr");
> - action_ptr = &(((struct bts_action *)ptr)->data[0]);
> - mdelay(((struct bts_action_delay *)action_ptr)->msec);
> - break;
> - }
> - len =
> - len - (sizeof(struct bts_action) +
> - ((struct bts_action *)ptr)->size);
> - ptr =
> - ptr + sizeof(struct bts_action) +
> - ((struct bts_action *)ptr)->size;
> - }
> - /* fw download complete */
> - release_firmware(kim_gdata->fw_entry);
> - return 0;
> -}
> -
> -/**********************************************************************/
> -/* functions called from ST core */
> -/* called from ST Core, when REG_IN_PROGRESS (registration in progress)
> - * can be because of
> - * 1. response to read local version
> - * 2. during send/recv's of firmware download
> - */
> -void st_kim_recv(void *disc_data, const unsigned char *data, long count)
> -{
> - struct st_data_s *st_gdata = (struct st_data_s *)disc_data;
> - struct kim_data_s *kim_gdata = st_gdata->kim_data;
> -
> - /* proceed to gather all data and distinguish read fw version response
> - * from other fw responses when data gathering is complete
> - */
> - kim_int_recv(kim_gdata, data, count);
> - return;
> -}
> -
> -/* to signal completion of line discipline installation
> - * called from ST Core, upon tty_open
> - */
> -void st_kim_complete(void *kim_data)
> -{
> - struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
> - complete(&kim_gdata->ldisc_installed);
> -}
> -
> -/**
> - * st_kim_start - called from ST Core upon 1st registration
> - * This involves toggling the chip enable gpio, reading
> - * the firmware version from chip, forming the fw file name
> - * based on the chip version, requesting the fw, parsing it
> - * and perform download(send/recv).
> - */
> -long st_kim_start(void *kim_data)
> -{
> - long err = 0;
> - long retry = POR_RETRY_COUNT;
> - struct ti_st_plat_data *pdata;
> - struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
> -
> - pr_info(" %s", __func__);
> - pdata = kim_gdata->kim_pdev->dev.platform_data;
> -
> - do {
> - /* platform specific enabling code here */
> - if (pdata->chip_enable)
> - pdata->chip_enable(kim_gdata);
> -
> - /* Configure BT nShutdown to HIGH state */
> - gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_LOW);
> - mdelay(5); /* FIXME: a proper toggle */
> - gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_HIGH);
> - mdelay(100);
> - /* re-initialize the completion */
> - reinit_completion(&kim_gdata->ldisc_installed);
> - /* send notification to UIM */
> - kim_gdata->ldisc_install = 1;
> - pr_info("ldisc_install = 1");
> - sysfs_notify(&kim_gdata->kim_pdev->dev.kobj,
> - NULL, "install");
> - /* wait for ldisc to be installed */
> - err = wait_for_completion_interruptible_timeout(
> - &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME));
> - if (!err) {
> - /* ldisc installation timeout,
> - * flush uart, power cycle BT_EN */
> - pr_err("ldisc installation timeout");
> - err = st_kim_stop(kim_gdata);
> - continue;
> - } else {
> - /* ldisc installed now */
> - pr_info("line discipline installed");
> - err = download_firmware(kim_gdata);
> - if (err != 0) {
> - /* ldisc installed but fw download failed,
> - * flush uart & power cycle BT_EN */
> - pr_err("download firmware failed");
> - err = st_kim_stop(kim_gdata);
> - continue;
> - } else { /* on success don't retry */
> - break;
> - }
> - }
> - } while (retry--);
> - return err;
> -}
> -
> -/**
> - * st_kim_stop - stop communication with chip.
> - * This can be called from ST Core/KIM, on the-
> - * (a) last un-register when chip need not be powered there-after,
> - * (b) upon failure to either install ldisc or download firmware.
> - * The function is responsible to (a) notify UIM about un-installation,
> - * (b) flush UART if the ldisc was installed.
> - * (c) reset BT_EN - pull down nshutdown at the end.
> - * (d) invoke platform's chip disabling routine.
> - */
> -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 tty_struct *tty = kim_gdata->core_data->tty;
> -
> - reinit_completion(&kim_gdata->ldisc_installed);
> -
> - if (tty) { /* can be called before ldisc is installed */
> - /* Flush any pending characters in the driver and discipline. */
> - tty_ldisc_flush(tty);
> - tty_driver_flush_buffer(tty);
> - }
> -
> - /* send uninstall notification to UIM */
> - pr_info("ldisc_install = 0");
> - kim_gdata->ldisc_install = 0;
> - sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install");
> -
> - /* wait for ldisc to be un-installed */
> - err = wait_for_completion_interruptible_timeout(
> - &kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME));
> - if (!err) { /* timeout */
> - pr_err(" timed out waiting for ldisc to be un-installed");
> - err = -ETIMEDOUT;
> - }
> -
> - /* By default configure BT nShutdown to LOW state */
> - gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_LOW);
> - mdelay(1);
> - gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_HIGH);
> - mdelay(1);
> - gpio_set_value_cansleep(kim_gdata->nshutdown, GPIO_LOW);
> -
> - /* platform specific disable */
> - if (pdata->chip_disable)
> - pdata->chip_disable(kim_gdata);
> - return err;
> -}
> -
> -/**********************************************************************/
> -/* functions called from subsystems */
> -/* called when debugfs entry is read from */
> -
> -static int show_version(struct seq_file *s, void *unused)
> -{
> - struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private;
> - seq_printf(s, "%04X %d.%d.%d\n", kim_gdata->version.full,
> - kim_gdata->version.chip, kim_gdata->version.maj_ver,
> - kim_gdata->version.min_ver);
> - return 0;
> -}
> -
> -static int show_list(struct seq_file *s, void *unused)
> -{
> - struct kim_data_s *kim_gdata = (struct kim_data_s *)s->private;
> - kim_st_list_protocols(kim_gdata->core_data, s);
> - return 0;
> -}
> -
> -static ssize_t show_install(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - struct kim_data_s *kim_data = dev_get_drvdata(dev);
> - return sprintf(buf, "%d\n", kim_data->ldisc_install);
> -}
> -
> -#ifdef DEBUG
> -static ssize_t store_dev_name(struct device *dev,
> - struct device_attribute *attr, const char *buf, size_t count)
> -{
> - struct kim_data_s *kim_data = dev_get_drvdata(dev);
> - pr_debug("storing dev name >%s<", buf);
> - strncpy(kim_data->dev_name, buf, count);
> - pr_debug("stored dev name >%s<", kim_data->dev_name);
> - return count;
> -}
> -
> -static ssize_t store_baud_rate(struct device *dev,
> - struct device_attribute *attr, const char *buf, size_t count)
> -{
> - struct kim_data_s *kim_data = dev_get_drvdata(dev);
> - pr_debug("storing baud rate >%s<", buf);
> - sscanf(buf, "%ld", &kim_data->baud_rate);
> - pr_debug("stored baud rate >%ld<", kim_data->baud_rate);
> - return count;
> -}
> -#endif /* if DEBUG */
> -
> -static ssize_t show_dev_name(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - struct kim_data_s *kim_data = dev_get_drvdata(dev);
> - return sprintf(buf, "%s\n", kim_data->dev_name);
> -}
> -
> -static ssize_t show_baud_rate(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - struct kim_data_s *kim_data = dev_get_drvdata(dev);
> - return sprintf(buf, "%d\n", kim_data->baud_rate);
> -}
> -
> -static ssize_t show_flow_cntrl(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - struct kim_data_s *kim_data = dev_get_drvdata(dev);
> - return sprintf(buf, "%d\n", kim_data->flow_cntrl);
> -}
> -
> -/* structures specific for sysfs entries */
> -static struct kobj_attribute ldisc_install =
> -__ATTR(install, 0444, (void *)show_install, NULL);
> -
> -static struct kobj_attribute uart_dev_name =
> -#ifdef DEBUG /* TODO: move this to debug-fs if possible */
> -__ATTR(dev_name, 0644, (void *)show_dev_name, (void *)store_dev_name);
> -#else
> -__ATTR(dev_name, 0444, (void *)show_dev_name, NULL);
> -#endif
> -
> -static struct kobj_attribute uart_baud_rate =
> -#ifdef DEBUG /* TODO: move to debugfs */
> -__ATTR(baud_rate, 0644, (void *)show_baud_rate, (void *)store_baud_rate);
> -#else
> -__ATTR(baud_rate, 0444, (void *)show_baud_rate, NULL);
> -#endif
> -
> -static struct kobj_attribute uart_flow_cntrl =
> -__ATTR(flow_cntrl, 0444, (void *)show_flow_cntrl, NULL);
> -
> -static struct attribute *uim_attrs[] = {
> - &ldisc_install.attr,
> - &uart_dev_name.attr,
> - &uart_baud_rate.attr,
> - &uart_flow_cntrl.attr,
> - NULL,
> -};
> -
> -static const struct attribute_group uim_attr_grp = {
> - .attrs = uim_attrs,
> -};
> -
> -/**
> - * st_kim_ref - reference the core's data
> - * This references the per-ST platform device in the arch/xx/
> - * board-xx.c file.
> - * This would enable multiple such platform devices to exist
> - * on a given platform
> - */
> -void st_kim_ref(struct st_data_s **core_data, int id)
> -{
> - struct platform_device *pdev;
> - struct kim_data_s *kim_gdata;
> - /* get kim_gdata reference from platform device */
> - pdev = st_get_plat_device(id);
> - if (!pdev)
> - goto err;
> - kim_gdata = platform_get_drvdata(pdev);
> - if (!kim_gdata)
> - goto err;
> -
> - *core_data = kim_gdata->core_data;
> - return;
> -err:
> - *core_data = NULL;
> -}
> -
> -static int kim_version_open(struct inode *i, struct file *f)
> -{
> - return single_open(f, show_version, i->i_private);
> -}
> -
> -static int kim_list_open(struct inode *i, struct file *f)
> -{
> - return single_open(f, show_list, i->i_private);
> -}
> -
> -static const struct file_operations version_debugfs_fops = {
> - /* version info */
> - .open = kim_version_open,
> - .read = seq_read,
> - .llseek = seq_lseek,
> - .release = single_release,
> -};
> -static const struct file_operations list_debugfs_fops = {
> - /* protocols info */
> - .open = kim_list_open,
> - .read = seq_read,
> - .llseek = seq_lseek,
> - .release = single_release,
> -};
> -
> -/**********************************************************************/
> -/* functions called from platform device driver subsystem
> - * need to have a relevant platform device entry in the platform's
> - * board-*.c file
> - */
> -
> -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;
> - int err;
> -
> - if ((pdev->id != -1) && (pdev->id < MAX_ST_DEVICES)) {
> - /* multiple devices could exist */
> - st_kim_devices[pdev->id] = pdev;
> - } else {
> - /* platform's sure about existence of 1 device */
> - st_kim_devices[0] = pdev;
> - }
> -
> - kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_KERNEL);
> - if (!kim_gdata) {
> - pr_err("no mem to allocate");
> - return -ENOMEM;
> - }
> - platform_set_drvdata(pdev, kim_gdata);
> -
> - err = st_core_init(&kim_gdata->core_data);
> - if (err != 0) {
> - pr_err(" ST core init failed");
> - err = -EIO;
> - goto err_core_init;
> - }
> - /* refer to itself */
> - kim_gdata->core_data->kim_data = kim_gdata;
> -
> - /* Claim the chip enable nShutdown gpio from the system */
> - kim_gdata->nshutdown = pdata->nshutdown_gpio;
> - err = gpio_request(kim_gdata->nshutdown, "kim");
> - if (unlikely(err)) {
> - pr_err(" gpio %d request failed ", kim_gdata->nshutdown);
> - goto err_sysfs_group;
> - }
> -
> - /* Configure nShutdown GPIO as output=0 */
> - err = gpio_direction_output(kim_gdata->nshutdown, 0);
> - if (unlikely(err)) {
> - pr_err(" unable to configure gpio %d", kim_gdata->nshutdown);
> - goto err_sysfs_group;
> - }
> - /* get reference of pdev for request_firmware
> - */
> - kim_gdata->kim_pdev = pdev;
> - init_completion(&kim_gdata->kim_rcvd);
> - init_completion(&kim_gdata->ldisc_installed);
> -
> - err = sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp);
> - if (err) {
> - pr_err("failed to create sysfs entries");
> - goto err_sysfs_group;
> - }
> -
> - /* copying platform data */
> - strncpy(kim_gdata->dev_name, pdata->dev_name, UART_DEV_NAME_LEN);
> - kim_gdata->flow_cntrl = pdata->flow_cntrl;
> - kim_gdata->baud_rate = pdata->baud_rate;
> - pr_info("sysfs entries created\n");
> -
> - kim_debugfs_dir = debugfs_create_dir("ti-st", NULL);
> - if (!kim_debugfs_dir) {
> - pr_err(" debugfs entries creation failed ");
> - return 0;
> - }
> -
> - debugfs_create_file("version", S_IRUGO, kim_debugfs_dir,
> - kim_gdata, &version_debugfs_fops);
> - debugfs_create_file("protocols", S_IRUGO, kim_debugfs_dir,
> - kim_gdata, &list_debugfs_fops);
> - return 0;
> -
> -err_sysfs_group:
> - st_core_exit(kim_gdata->core_data);
> -
> -err_core_init:
> - kfree(kim_gdata);
> -
> - return err;
> -}
> -
> -static int kim_remove(struct platform_device *pdev)
> -{
> - /* free the GPIOs requested */
> - struct ti_st_plat_data *pdata = pdev->dev.platform_data;
> - struct kim_data_s *kim_gdata;
> -
> - kim_gdata = platform_get_drvdata(pdev);
> -
> - /* Free the Bluetooth/FM/GPIO
> - * nShutdown gpio from the system
> - */
> - gpio_free(pdata->nshutdown_gpio);
> - pr_info("nshutdown GPIO Freed");
> -
> - debugfs_remove_recursive(kim_debugfs_dir);
> - sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp);
> - pr_info("sysfs entries removed");
> -
> - kim_gdata->kim_pdev = NULL;
> - st_core_exit(kim_gdata->core_data);
> -
> - kfree(kim_gdata);
> - kim_gdata = 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;
> -
> - if (pdata->suspend)
> - return pdata->suspend(pdev, state);
> -
> - return 0;
> -}
> -
> -static int kim_resume(struct platform_device *pdev)
> -{
> - struct ti_st_plat_data *pdata = pdev->dev.platform_data;
> -
> - if (pdata->resume)
> - return pdata->resume(pdev);
> -
> - return 0;
> -}
> -
> -/**********************************************************************/
> -/* entry point for ST KIM module, called in from ST Core */
> -static struct platform_driver kim_platform_driver = {
> - .probe = kim_probe,
> - .remove = kim_remove,
> - .suspend = kim_suspend,
> - .resume = kim_resume,
> - .driver = {
> - .name = "kim",
> - },
> -};
> -
> -module_platform_driver(kim_platform_driver);
> -
> -MODULE_AUTHOR("Pavan Savoy <[email protected]>");
> -MODULE_DESCRIPTION("Shared Transport Driver for TI BT/FM/GPS combo chips ");
> -MODULE_LICENSE("GPL");
> diff --git a/drivers/misc/ti-st/st_ll.c b/drivers/misc/ti-st/st_ll.c
> deleted file mode 100644
> index 93b4d67cc4a3..000000000000
> --- a/drivers/misc/ti-st/st_ll.c
> +++ /dev/null
> @@ -1,169 +0,0 @@
> -/*
> - * Shared Transport driver
> - * HCI-LL module responsible for TI proprietary HCI_LL protocol
> - * Copyright (C) 2009-2010 Texas Instruments
> - * Author: Pavan Savoy <[email protected]>
> - *
> - * 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.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> - *
> - */
> -
> -#define pr_fmt(fmt) "(stll) :" fmt
> -#include <linux/skbuff.h>
> -#include <linux/module.h>
> -#include <linux/platform_device.h>
> -#include <linux/ti_wilink_st.h>
> -
> -/**********************************************************************/
> -/* internal functions */
> -static void send_ll_cmd(struct st_data_s *st_data,
> - unsigned char cmd)
> -{
> -
> - pr_debug("%s: writing %x", __func__, cmd);
> - st_int_write(st_data, &cmd, 1);
> - return;
> -}
> -
> -static void ll_device_want_to_sleep(struct st_data_s *st_data)
> -{
> - struct kim_data_s *kim_data;
> - struct ti_st_plat_data *pdata;
> -
> - pr_debug("%s", __func__);
> - /* sanity check */
> - if (st_data->ll_state != ST_LL_AWAKE)
> - pr_err("ERR hcill: ST_LL_GO_TO_SLEEP_IND"
> - "in state %ld", st_data->ll_state);
> -
> - send_ll_cmd(st_data, LL_SLEEP_ACK);
> - /* update state */
> - st_data->ll_state = ST_LL_ASLEEP;
> -
> - /* communicate to platform about chip asleep */
> - kim_data = st_data->kim_data;
> - pdata = kim_data->kim_pdev->dev.platform_data;
> - if (pdata->chip_asleep)
> - pdata->chip_asleep(NULL);
> -}
> -
> -static void ll_device_want_to_wakeup(struct st_data_s *st_data)
> -{
> - struct kim_data_s *kim_data;
> - struct ti_st_plat_data *pdata;
> -
> - /* diff actions in diff states */
> - switch (st_data->ll_state) {
> - case ST_LL_ASLEEP:
> - send_ll_cmd(st_data, LL_WAKE_UP_ACK); /* send wake_ack */
> - break;
> - case ST_LL_ASLEEP_TO_AWAKE:
> - /* duplicate wake_ind */
> - pr_err("duplicate wake_ind while waiting for Wake ack");
> - break;
> - case ST_LL_AWAKE:
> - /* duplicate wake_ind */
> - pr_err("duplicate wake_ind already AWAKE");
> - break;
> - case ST_LL_AWAKE_TO_ASLEEP:
> - /* duplicate wake_ind */
> - pr_err("duplicate wake_ind");
> - break;
> - }
> - /* update state */
> - st_data->ll_state = ST_LL_AWAKE;
> -
> - /* communicate to platform about chip wakeup */
> - kim_data = st_data->kim_data;
> - pdata = kim_data->kim_pdev->dev.platform_data;
> - if (pdata->chip_awake)
> - pdata->chip_awake(NULL);
> -}
> -
> -/**********************************************************************/
> -/* functions invoked by ST Core */
> -
> -/* called when ST Core wants to
> - * enable ST LL */
> -void st_ll_enable(struct st_data_s *ll)
> -{
> - ll->ll_state = ST_LL_AWAKE;
> -}
> -
> -/* called when ST Core /local module wants to
> - * disable ST LL */
> -void st_ll_disable(struct st_data_s *ll)
> -{
> - ll->ll_state = ST_LL_INVALID;
> -}
> -
> -/* called when ST Core wants to update the state */
> -void st_ll_wakeup(struct st_data_s *ll)
> -{
> - if (likely(ll->ll_state != ST_LL_AWAKE)) {
> - send_ll_cmd(ll, LL_WAKE_UP_IND); /* WAKE_IND */
> - ll->ll_state = ST_LL_ASLEEP_TO_AWAKE;
> - } else {
> - /* don't send the duplicate wake_indication */
> - pr_err(" Chip already AWAKE ");
> - }
> -}
> -
> -/* called when ST Core wants the state */
> -unsigned long st_ll_getstate(struct st_data_s *ll)
> -{
> - pr_debug(" returning state %ld", ll->ll_state);
> - return ll->ll_state;
> -}
> -
> -/* called from ST Core, when a PM related packet arrives */
> -unsigned long st_ll_sleep_state(struct st_data_s *st_data,
> - unsigned char cmd)
> -{
> - switch (cmd) {
> - case LL_SLEEP_IND: /* sleep ind */
> - pr_debug("sleep indication recvd");
> - ll_device_want_to_sleep(st_data);
> - break;
> - case LL_SLEEP_ACK: /* sleep ack */
> - pr_err("sleep ack rcvd: host shouldn't");
> - break;
> - case LL_WAKE_UP_IND: /* wake ind */
> - pr_debug("wake indication recvd");
> - ll_device_want_to_wakeup(st_data);
> - break;
> - case LL_WAKE_UP_ACK: /* wake ack */
> - pr_debug("wake ack rcvd");
> - st_data->ll_state = ST_LL_AWAKE;
> - break;
> - default:
> - pr_err(" unknown input/state ");
> - return -EINVAL;
> - }
> - return 0;
> -}
> -
> -/* Called from ST CORE to initialize ST LL */
> -long st_ll_init(struct st_data_s *ll)
> -{
> - /* set state to invalid */
> - ll->ll_state = ST_LL_INVALID;
> - return 0;
> -}
> -
> -/* Called from ST CORE to de-initialize ST LL */
> -long st_ll_deinit(struct st_data_s *ll)
> -{
> - return 0;
> -}
> diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
> index a9de5654b0cd..76a372bdf540 100644
> --- a/include/linux/ti_wilink_st.h
> +++ b/include/linux/ti_wilink_st.h
> @@ -27,268 +27,9 @@
>
> #include <linux/skbuff.h>
>
> -/**
> - * enum proto-type - The protocol on WiLink chips which share a
> - * common physical interface like UART.
> - */
> -enum proto_type {
> - ST_BT,
> - ST_FM,
> - ST_GPS,
> - ST_MAX_CHANNELS = 16,
> -};
> -
> -/**
> - * struct st_proto_s - Per Protocol structure from BT/FM/GPS to ST
> - * @type: type of the protocol being registered among the
> - * available proto_type(BT, FM, GPS the protocol which share TTY).
> - * @recv: the receiver callback pointing to a function in the
> - * protocol drivers called by the ST driver upon receiving
> - * relevant data.
> - * @match_packet: reserved for future use, to make ST more generic
> - * @reg_complete_cb: callback handler pointing to a function in protocol
> - * handler called by ST when the pending registrations are complete.
> - * The registrations are marked pending, in situations when fw
> - * download is in progress.
> - * @write: pointer to function in ST provided to protocol drivers from ST,
> - * to be made use when protocol drivers have data to send to TTY.
> - * @priv_data: privdate data holder for the protocol drivers, sent
> - * from the protocol drivers during registration, and sent back on
> - * reg_complete_cb and recv.
> - * @chnl_id: channel id the protocol driver is interested in, the channel
> - * id is nothing but the 1st byte of the packet in UART frame.
> - * @max_frame_size: size of the largest frame the protocol can receive.
> - * @hdr_len: length of the header structure of the protocol.
> - * @offset_len_in_hdr: this provides the offset of the length field in the
> - * header structure of the protocol header, to assist ST to know
> - * how much to receive, if the data is split across UART frames.
> - * @len_size: whether the length field inside the header is 2 bytes
> - * or 1 byte.
> - * @reserve: the number of bytes ST needs to reserve in the skb being
> - * prepared for the protocol driver.
> - */
> -struct st_proto_s {
> - enum proto_type type;
> - long (*recv) (void *, struct sk_buff *);
> - unsigned char (*match_packet) (const unsigned char *data);
> - void (*reg_complete_cb) (void *, int data);
> - long (*write) (struct sk_buff *skb);
> - void *priv_data;
> -
> - unsigned char chnl_id;
> - unsigned short max_frame_size;
> - unsigned char hdr_len;
> - unsigned char offset_len_in_hdr;
> - unsigned char len_size;
> - unsigned char reserve;
> -};
> -
> -extern long st_register(struct st_proto_s *);
> -extern long st_unregister(struct st_proto_s *);
> -
> void hci_ti_set_fm_handler(struct device *dev, void (*recv_handler) (void *, struct sk_buff *), void *drvdata);
> int hci_ti_fm_send(struct device *dev, struct sk_buff *skb);
>
> -/*
> - * header information used by st_core.c
> - */
> -
> -/* states of protocol list */
> -#define ST_NOTEMPTY 1
> -#define ST_EMPTY 0
> -
> -/*
> - * possible st_states
> - */
> -#define ST_INITIALIZING 1
> -#define ST_REG_IN_PROGRESS 2
> -#define ST_REG_PENDING 3
> -#define ST_WAITING_FOR_RESP 4
> -
> -/**
> - * struct st_data_s - ST core internal structure
> - * @st_state: different states of ST like initializing, registration
> - * in progress, this is mainly used to return relevant err codes
> - * when protocol drivers are registering. It is also used to track
> - * the recv function, as in during fw download only HCI events
> - * can occur , where as during other times other events CH8, CH9
> - * can occur.
> - * @tty: tty provided by the TTY core for line disciplines.
> - * @tx_skb: If for some reason the tty's write returns lesser bytes written
> - * then to maintain the rest of data to be written on next instance.
> - * This needs to be protected, hence the lock inside wakeup func.
> - * @tx_state: if the data is being written onto the TTY and protocol driver
> - * wants to send more, queue up data and mark that there is
> - * more data to send.
> - * @list: the list of protocols registered, only MAX can exist, one protocol
> - * can register only once.
> - * @rx_state: states to be maintained inside st's tty receive
> - * @rx_count: count to be maintained inside st's tty receieve
> - * @rx_skb: the skb where all data for a protocol gets accumulated,
> - * since tty might not call receive when a complete event packet
> - * is received, the states, count and the skb needs to be maintained.
> - * @rx_chnl: the channel ID for which the data is getting accumalated for.
> - * @txq: the list of skbs which needs to be sent onto the TTY.
> - * @tx_waitq: if the chip is not in AWAKE state, the skbs needs to be queued
> - * up in here, PM(WAKEUP_IND) data needs to be sent and then the skbs
> - * from waitq can be moved onto the txq.
> - * Needs locking too.
> - * @lock: the lock to protect skbs, queues, and ST states.
> - * @protos_registered: count of the protocols registered, also when 0 the
> - * chip enable gpio can be toggled, and when it changes to 1 the fw
> - * needs to be downloaded to initialize chip side ST.
> - * @ll_state: the various PM states the chip can be, the states are notified
> - * to us, when the chip sends relevant PM packets(SLEEP_IND, WAKE_IND).
> - * @kim_data: reference to the parent encapsulating structure.
> - *
> - */
> -struct st_data_s {
> - unsigned long st_state;
> - struct sk_buff *tx_skb;
> -#define ST_TX_SENDING 1
> -#define ST_TX_WAKEUP 2
> - unsigned long tx_state;
> - struct st_proto_s *list[ST_MAX_CHANNELS];
> - bool is_registered[ST_MAX_CHANNELS];
> - unsigned long rx_state;
> - unsigned long rx_count;
> - struct sk_buff *rx_skb;
> - unsigned char rx_chnl;
> - struct sk_buff_head txq, tx_waitq;
> - spinlock_t lock;
> - unsigned char protos_registered;
> - unsigned long ll_state;
> - void *kim_data;
> - struct tty_struct *tty;
> - struct work_struct work_write_wakeup;
> -};
> -
> -/*
> - * wrapper around tty->ops->write_room to check
> - * availability during firmware download
> - */
> -int st_get_uart_wr_room(struct st_data_s *st_gdata);
> -/**
> - * st_int_write -
> - * point this to tty->driver->write or tty->ops->write
> - * depending upon the kernel version
> - */
> -int st_int_write(struct st_data_s*, const unsigned char*, int);
> -
> -/**
> - * st_write -
> - * internal write function, passed onto protocol drivers
> - * via the write function ptr of protocol struct
> - */
> -long st_write(struct sk_buff *);
> -
> -/* function to be called from ST-LL */
> -void st_ll_send_frame(enum proto_type, struct sk_buff *);
> -
> -/* internal wake up function */
> -void st_tx_wakeup(struct st_data_s *st_data);
> -
> -/* init, exit entry funcs called from KIM */
> -int st_core_init(struct st_data_s **);
> -void st_core_exit(struct st_data_s *);
> -
> -/* ask for reference from KIM */
> -void st_kim_ref(struct st_data_s **, int);
> -
> -#define GPS_STUB_TEST
> -#ifdef GPS_STUB_TEST
> -int gps_chrdrv_stub_write(const unsigned char*, int);
> -void gps_chrdrv_stub_init(void);
> -#endif
> -
> -/*
> - * header information used by st_kim.c
> - */
> -
> -/* time in msec to wait for
> - * line discipline to be installed
> - */
> -#define LDISC_TIME 1000
> -#define CMD_RESP_TIME 800
> -#define CMD_WR_TIME 5000
> -#define MAKEWORD(a, b) ((unsigned short)(((unsigned char)(a)) \
> - | ((unsigned short)((unsigned char)(b))) << 8))
> -
> -#define GPIO_HIGH 1
> -#define GPIO_LOW 0
> -
> -/* the Power-On-Reset logic, requires to attempt
> - * to download firmware onto chip more than once
> - * since the self-test for chip takes a while
> - */
> -#define POR_RETRY_COUNT 5
> -
> -/**
> - * struct chip_version - save the chip version
> - */
> -struct chip_version {
> - unsigned short full;
> - unsigned short chip;
> - unsigned short min_ver;
> - unsigned short maj_ver;
> -};
> -
> -#define UART_DEV_NAME_LEN 32
> -/**
> - * struct kim_data_s - the KIM internal data, embedded as the
> - * platform's drv data. One for each ST device in the system.
> - * @uim_pid: KIM needs to communicate with UIM to request to install
> - * the ldisc by opening UART when protocol drivers register.
> - * @kim_pdev: the platform device added in one of the board-XX.c file
> - * in arch/XX/ directory, 1 for each ST device.
> - * @kim_rcvd: completion handler to notify when data was received,
> - * mainly used during fw download, which involves multiple send/wait
> - * for each of the HCI-VS commands.
> - * @ldisc_installed: completion handler to notify that the UIM accepted
> - * the request to install ldisc, notify from tty_open which suggests
> - * the ldisc was properly installed.
> - * @resp_buffer: data buffer for the .bts fw file name.
> - * @fw_entry: firmware class struct to request/release the fw.
> - * @rx_state: the rx state for kim's receive func during fw download.
> - * @rx_count: the rx count for the kim's receive func during fw download.
> - * @rx_skb: all of fw data might not come at once, and hence data storage for
> - * whole of the fw response, only HCI_EVENTs and hence diff from ST's
> - * response.
> - * @core_data: ST core's data, which mainly is the tty's disc_data
> - * @version: chip version available via a sysfs entry.
> - *
> - */
> -struct kim_data_s {
> - long uim_pid;
> - struct platform_device *kim_pdev;
> - struct completion kim_rcvd, ldisc_installed;
> - char resp_buffer[30];
> - const struct firmware *fw_entry;
> - unsigned nshutdown;
> - unsigned long rx_state;
> - unsigned long rx_count;
> - struct sk_buff *rx_skb;
> - struct st_data_s *core_data;
> - struct chip_version version;
> - unsigned char ldisc_install;
> - unsigned char dev_name[UART_DEV_NAME_LEN + 1];
> - unsigned flow_cntrl;
> - unsigned baud_rate;
> -};
> -
> -/**
> - * functions called when 1 of the protocol drivers gets
> - * registered, these need to communicate with UIM to request
> - * ldisc installed, read chip_version, download relevant fw
> - */
> -long st_kim_start(void *);
> -long st_kim_stop(void *);
> -
> -void st_kim_complete(void *);
> -void kim_st_list_protocols(struct st_data_s *, void *);
> -void st_kim_recv(void *, const unsigned char *, long);
> -
> -
> /*
> * BTS headers
> */
> @@ -355,47 +96,6 @@ struct hci_command {
> u32 speed;
> } __attribute__ ((packed));
>
> -/*
> - * header information used by st_ll.c
> - */
> -
> -/* ST LL receiver states */
> -#define ST_W4_PACKET_TYPE 0
> -#define ST_W4_HEADER 1
> -#define ST_W4_DATA 2
> -
> -/* ST LL state machines */
> -#define ST_LL_ASLEEP 0
> -#define ST_LL_ASLEEP_TO_AWAKE 1
> -#define ST_LL_AWAKE 2
> -#define ST_LL_AWAKE_TO_ASLEEP 3
> -#define ST_LL_INVALID 4
> -
> -/* different PM notifications coming from chip */
> -#define LL_SLEEP_IND 0x30
> -#define LL_SLEEP_ACK 0x31
> -#define LL_WAKE_UP_IND 0x32
> -#define LL_WAKE_UP_ACK 0x33
> -
> -/* initialize and de-init ST LL */
> -long st_ll_init(struct st_data_s *);
> -long st_ll_deinit(struct st_data_s *);
> -
> -/**
> - * enable/disable ST LL along with KIM start/stop
> - * called by ST Core
> - */
> -void st_ll_enable(struct st_data_s *);
> -void st_ll_disable(struct st_data_s *);
> -
> -/**
> - * various funcs used by ST core to set/get the various PM states
> - * of the chip.
> - */
> -unsigned long st_ll_getstate(struct st_data_s *);
> -unsigned long st_ll_sleep_state(struct st_data_s *, unsigned char);
> -void st_ll_wakeup(struct st_data_s *);
> -
> /*
> * header information used by st_core.c for FM and GPS
> * packet parsing, the bluetooth headers are already available
> @@ -416,39 +116,4 @@ struct gps_event_hdr {
> u16 plen;
> } __attribute__ ((packed));
>
> -/**
> - * struct ti_st_plat_data - platform data shared between ST driver and
> - * platform specific board file which adds the ST device.
> - * @nshutdown_gpio: Host's GPIO line to which chip's BT_EN is connected.
> - * @dev_name: The UART/TTY name to which chip is interfaced. (eg: /dev/ttyS1)
> - * @flow_cntrl: Should always be 1, since UART's CTS/RTS is used for PM
> - * purposes.
> - * @baud_rate: The baud rate supported by the Host UART controller, this will
> - * be shared across with the chip via a HCI VS command from User-Space Init
> - * Mgr application.
> - * @suspend:
> - * @resume: legacy PM routines hooked to platform specific board file, so as
> - * to take chip-host interface specific action.
> - * @chip_enable:
> - * @chip_disable: Platform/Interface specific mux mode setting, GPIO
> - * configuring, Host side PM disabling etc.. can be done here.
> - * @chip_asleep:
> - * @chip_awake: Chip specific deep sleep states is communicated to Host
> - * specific board-xx.c to take actions such as cut UART clocks when chip
> - * asleep or run host faster when chip awake etc..
> - *
> - */
> -struct ti_st_plat_data {
> - u32 nshutdown_gpio;
> - unsigned char dev_name[UART_DEV_NAME_LEN]; /* uart name */
> - u32 flow_cntrl; /* flow control flag */
> - u32 baud_rate;
> - int (*suspend)(struct platform_device *, pm_message_t);
> - int (*resume)(struct platform_device *);
> - int (*chip_enable) (struct kim_data_s *);
> - int (*chip_disable) (struct kim_data_s *);
> - int (*chip_asleep) (struct kim_data_s *);
> - int (*chip_awake) (struct kim_data_s *);
> -};
> -
> #endif /* TI_WILINK_ST_H */

> --
> 2.19.2
>

2018-12-22 02:48:02

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Hi,

On Fri, Dec 21, 2018 at 10:02:05AM -0800, Tony Lindgren wrote:
> * Sebastian Reichel <[email protected]> [181221 01:18]:
> > The new code has been tested on the Motorola Droid 4. For testing the audio
> > should be configured to route Ext to Speaker or Headphone. Then you need to
> > plug headphone, since its cable is used as antenna. For testing there is a
> > 'radio' utility packages in Debian. When you start the utility you need to
> > specify a frequency, since initial get_frequency returns an error:
>
> Nice, good to see that ti-st kim stuff gone :) I gave this a quick
> try using fmtools.git and fmscan works just fine. No luck yet with
> fm though, it gives VIDIOC_G_CTRL: Not a tty error somehow so
> maybe I'm missing some options, patch below for omap2plus_defconfig.

I only did a few quick tests with 'radio' utility. I could scan
for stations and I could listen to some station. I suppose the
wl128x-radio driver has some buggy code paths, but that are
unrelated to this patchset.

> Hmm so looks like nothing to configure for the clocks or
> CPCAP_BIT_ST_L_TIMESLOT bits for cap for the EXT? So the
> wl12xx audio is wired directly to cpcap EXT then and not a
> TDM slot on the mcbsp huh?

For FM radio it's directly wired to EXT with no DAI being required.
I think that EXT is only used by FM radio and not by bluetooth. BT
seems to use TDM.

> > Merry Christmas!
>
> Same to you!
>
> Tony
>
> 8< --------------------------------
> From tony Mon Sep 17 00:00:00 2001
> From: Tony Lindgren <[email protected]>
> Date: Fri, 21 Dec 2018 07:57:09 -0800
> Subject: [PATCH] ARM: omap2plus_defconfig: Add RADIO_WL128X as a loadable
> module
>
> This allows using the FM radio in the wl12xx chips after modprobe
> fm_drv using radio from xawt, or fmtools.

Mh. I suppose I forgot to add alias to support autoloading the
FM module.

> Note that the firmware placed into /lib/firmware/ti-connectivity
> directory:
>
> fm_rx_ch8_1283.2.bts
> fmc_ch8_1283.2.bts

There is also a TX firmware. The Droid 4's chip should support this,
but I don't know if there is audio routing for this feature.

-- Sebastian

> Signed-off-by: Tony Lindgren <[email protected]>
> ---
> arch/arm/configs/omap2plus_defconfig | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
> --- a/arch/arm/configs/omap2plus_defconfig
> +++ b/arch/arm/configs/omap2plus_defconfig
> @@ -126,6 +126,7 @@ CONFIG_AF_RXRPC=m
> CONFIG_RXKAD=y
> CONFIG_CFG80211=m
> CONFIG_MAC80211=m
> +CONFIG_RFKILL=m
> CONFIG_DEVTMPFS=y
> CONFIG_DEVTMPFS_MOUNT=y
> CONFIG_DMA_CMA=y
> @@ -343,12 +344,14 @@ CONFIG_IR_GPIO_TX=m
> CONFIG_IR_PWM_TX=m
> CONFIG_MEDIA_SUPPORT=m
> CONFIG_MEDIA_CAMERA_SUPPORT=y
> +CONFIG_MEDIA_RADIO_SUPPORT=y
> CONFIG_MEDIA_CEC_SUPPORT=y
> CONFIG_MEDIA_CONTROLLER=y
> CONFIG_VIDEO_V4L2_SUBDEV_API=y
> CONFIG_V4L_PLATFORM_DRIVERS=y
> CONFIG_VIDEO_OMAP3=m
> CONFIG_CEC_PLATFORM_DRIVERS=y
> +CONFIG_RADIO_WL128X=m
> # CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
> CONFIG_VIDEO_TVP5150=m
> CONFIG_DRM=m
> --
> 2.19.2


Attachments:
(No filename) (3.03 kB)
signature.asc (833.00 B)
Download all attachments

2018-12-22 19:10:59

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 05/14] media: wl128x-radio: remove global radio_disconnected

On Fri 2018-12-21 02:17:43, Sebastian Reichel wrote:
> From: Sebastian Reichel <[email protected]>
>
> Move global radio_disconnected into device structure to
> prepare converting this driver into a normal platform
> device driver supporting multiple instances.
>
> Signed-off-by: Sebastian Reichel <[email protected]>

Acked-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (525.00 B)
signature.asc (181.00 B)
Digital signature
Download all attachments

2018-12-22 19:16:46

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 06/14] media: wl128x-radio: remove global radio_dev

On Fri 2018-12-21 02:17:44, Sebastian Reichel wrote:
> From: Sebastian Reichel <[email protected]>
>
> Move global radio_dev into device structure to prepare converting
> this driver into a normal platform device driver supporting multiple
> instances.
>
> Signed-off-by: Sebastian Reichel <[email protected]>

Acked-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (516.00 B)
signature.asc (181.00 B)
Digital signature
Download all attachments

2018-12-22 19:17:56

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 07/14] media: wl128x-radio: convert to platform device

On Fri 2018-12-21 02:17:45, Sebastian Reichel wrote:
> From: Sebastian Reichel <[email protected]>
>
> This converts the wl128x FM radio module into a platform device.
> It's a preparation for using it from hci_ll Bluetooth driver instead
> of TI_ST.
>
> Signed-off-by: Sebastian Reichel <[email protected]>

Acked-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (514.00 B)
signature.asc (181.00 B)
Digital signature
Download all attachments

2018-12-22 19:20:27

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 08/14] media: wl128x-radio: use device managed memory allocation

On Fri 2018-12-21 02:17:46, Sebastian Reichel wrote:
> From: Sebastian Reichel <[email protected]>
>
> This simplifies memory allocation and removes a few useless
> errors in case of -ENOMEM errors.
>
> Signed-off-by: Sebastian Reichel <[email protected]>

Acked-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (462.00 B)
signature.asc (181.00 B)
Digital signature
Download all attachments

2018-12-22 19:29:44

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 10/14] media: wl128x-radio: simplify fmc_prepare/fmc_release

On Fri 2018-12-21 02:17:48, Sebastian Reichel wrote:
> From: Sebastian Reichel <[email protected]>
>
> Remove unused return code from fmc_prepare() and fmc_release() to
> simplify the code a bit.


> /*
> * This function will be called from FM V4L2 release function.
> * Unregister from ST driver.
> */
> -int fmc_release(struct fmdev *fmdev)
> +void fmc_release(struct fmdev *fmdev)
> {
> static struct st_proto_s fm_st_proto;
> int ret;
>
> if (!test_bit(FM_CORE_READY, &fmdev->flag)) {
> fmdbg("FM Core is already down\n");
> - return 0;
> + return;
> }
> /* Service pending read */
> wake_up_interruptible(&fmdev->rx.rds.read_queue);
> @@ -1611,7 +1606,6 @@ int fmc_release(struct fmdev *fmdev)
> fmdbg("Successfully unregistered from ST\n");
>
> clear_bit(FM_CORE_READY, &fmdev->flag);
> - return ret;
> }


You probably leave unused variable (ret) here. I guess that's okay as
you remove it later in the series...?

Also... I'd kind of expect _prepare routine to return int. Even if it
currently does not do anything that could return error, I'd kind of
expect allocations being done there...

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (1.27 kB)
signature.asc (181.00 B)
Digital signature
Download all attachments

2018-12-22 19:30:52

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 11/14] media: wl128x-radio: fix skb debug printing

On Fri 2018-12-21 02:17:49, Sebastian Reichel wrote:
> From: Sebastian Reichel <[email protected]>
>
> This fixes incorrect code in the TX/RX skb debug print
> function and add stubs in receive/transmit packet path.
>
> Signed-off-by: Sebastian Reichel <[email protected]>

Acked-by: Pavel Machek <[email protected]>


> @@ -228,7 +228,7 @@ inline void dump_rx_skb_data(struct sk_buff *skb)
>
> evt_hdr = (struct fm_event_msg_hdr *)skb->data;
> printk(KERN_INFO ">> hdr:%02x len:%02x sts:%02x numhci:%02x opcode:%02x type:%s dlen:%02x",
> - evt_hdr->hdr, evt_hdr->len,
> + evt_hdr->header, evt_hdr->len,
> evt_hdr->status, evt_hdr->num_fm_hci_cmds, evt_hdr->op,
> (evt_hdr->rd_wr) ? "RD" : "WR", evt_hdr->dlen);

Would conversion to dev_info() make sense?

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (956.00 B)
signature.asc (181.00 B)
Digital signature
Download all attachments

2018-12-22 20:08:36

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Merry Christmas!

> This moves all remaining users of the legacy TI_ST driver to hcill (patches
> 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
> device driver with support for multiple instances. Patch 7 will result in
> (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
> some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
> specific parts from wl128x-radio and adds the required infrastructure to use it
> with the serdev hcill driver instead. The remaining patches 13 and 14 remove
> the old TI_ST code.
>
> The new code has been tested on the Motorola Droid 4. For testing the audio
> should be configured to route Ext to Speaker or Headphone. Then you need to
> plug headphone, since its cable is used as antenna. For testing there is a
> 'radio' utility packages in Debian. When you start the utility you need to
> specify a frequency, since initial get_frequency returns an error:
>
> $ radio -f 100.0

Ok, it seems the driver does not work built-in, due to firmware issue:

root@devuan:/home/user# dmesg | grep wl12
[ 1.018951] reg-fixed-voltage regulator-wl12xx: GPIO lookup for
consumer (null)
[ 1.026550] reg-fixed-voltage regulator-wl12xx: using device tree
for GPIO lookup
[ 1.034271] of_get_named_gpiod_flags: can't parse 'gpios' property
of node '/regulator-wl12xx[0]'
[ 1.043487] of_get_named_gpiod_flags: parsed 'gpio' property of
node '/regulator-wl12xx[0]' - status (0)
[ 4.151885] wl12xx_driver wl12xx.1.auto: Direct firmware load for
ti-connectivity/wl128x-nvs.bin failed with error -2
[ 11.368286] vwl1271: disabling
root@devuan:/home/user# find /lib/firmware/ | grep wl128
/lib/firmware/ti-connectivity/wl128x-fw-5-plt.bin
/lib/firmware/ti-connectivity/wl128x-fw-5-mr.bin
/lib/firmware/ti-connectivity/wl128x-fw-5-sr.bin
/lib/firmware/ti-connectivity/wl128x-nvs.bin
root@devuan:/home/user#

Ideas welcome... ... ... am I supposed to compile wl128-nvs.bin into
the kernel using EXTRA_FIRMWARE?

Pavel


> Merry Christmas!
>
> -- Sebastian
>
> Sebastian Reichel (14):
> ARM: dts: LogicPD Torpedo: Add WiLink UART node
> ARM: dts: IGEP: Add WiLink UART node
> ARM: OMAP2+: pdata-quirks: drop TI_ST/KIM support
> media: wl128x-radio: remove module version
> media: wl128x-radio: remove global radio_disconnected
> media: wl128x-radio: remove global radio_dev
> media: wl128x-radio: convert to platform device
> media: wl128x-radio: use device managed memory allocation
> media: wl128x-radio: load firmware from ti-connectivity/
> media: wl128x-radio: simplify fmc_prepare/fmc_release
> media: wl128x-radio: fix skb debug printing
> media: wl128x-radio: move from TI_ST to hci_ll driver
> Bluetooth: btwilink: drop superseded driver
> misc: ti-st: Drop superseded driver
>
> .../boot/dts/logicpd-torpedo-37xx-devkit.dts | 8 +
> arch/arm/boot/dts/omap3-igep0020-rev-f.dts | 8 +
> arch/arm/boot/dts/omap3-igep0030-rev-g.dts | 8 +
> arch/arm/mach-omap2/pdata-quirks.c | 52 -
> drivers/bluetooth/Kconfig | 11 -
> drivers/bluetooth/Makefile | 1 -
> drivers/bluetooth/btwilink.c | 350 -------
> drivers/bluetooth/hci_ll.c | 115 ++-
> drivers/media/radio/wl128x/Kconfig | 2 +-
> drivers/media/radio/wl128x/fmdrv.h | 5 +-
> drivers/media/radio/wl128x/fmdrv_common.c | 211 ++--
> drivers/media/radio/wl128x/fmdrv_common.h | 4 +-
> drivers/media/radio/wl128x/fmdrv_v4l2.c | 55 +-
> drivers/media/radio/wl128x/fmdrv_v4l2.h | 2 +-
> drivers/misc/Kconfig | 1 -
> drivers/misc/Makefile | 1 -
> drivers/misc/ti-st/Kconfig | 18 -
> drivers/misc/ti-st/Makefile | 6 -
> drivers/misc/ti-st/st_core.c | 922 ------------------
> drivers/misc/ti-st/st_kim.c | 868 -----------------
> drivers/misc/ti-st/st_ll.c | 169 ----
> include/linux/ti_wilink_st.h | 337 +------
> 22 files changed, 213 insertions(+), 2941 deletions(-)
> delete mode 100644 drivers/bluetooth/btwilink.c
> delete mode 100644 drivers/misc/ti-st/Kconfig
> delete mode 100644 drivers/misc/ti-st/Makefile
> delete mode 100644 drivers/misc/ti-st/st_core.c
> delete mode 100644 drivers/misc/ti-st/st_kim.c
> delete mode 100644 drivers/misc/ti-st/st_ll.c
>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (4.53 kB)
signature.asc (181.00 B)
Digital signature
Download all attachments

2018-12-22 20:36:51

by Adam Ford

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

On Sat, Dec 22, 2018 at 11:09 AM Tony Lindgren <[email protected]> wrote:
>
> * Sebastian Reichel <[email protected]> [181221 01:18]:
> > The new code has been tested on the Motorola Droid 4. For testing the audio
> > should be configured to route Ext to Speaker or Headphone. Then you need to
> > plug headphone, since its cable is used as antenna. For testing there is a
> > 'radio' utility packages in Debian. When you start the utility you need to
> > specify a frequency, since initial get_frequency returns an error:
>
> Nice, good to see that ti-st kim stuff gone :) I gave this a quick

Tony,

As much as I'd like to see the ti-st kim stuff go, I am not able to
load the Bluetooth on the Torpedo board (wl1283). The hooks on a
different, wl18xx and 127x board work fine. I am not sure if there is
anything different about the wl1283, but I don't have any other boards
other than the Logic PD Torpedo kit. Do you have any wl1283 boards to
test? I'd like to see this BT timeout stuff resolved before we dump
the ti-st kim stuff, otherwise, I'll forever be porting drivers. :-(

adam

> try using fmtools.git and fmscan works just fine. No luck yet with
> fm though, it gives VIDIOC_G_CTRL: Not a tty error somehow so
> maybe I'm missing some options, patch below for omap2plus_defconfig.
>
> Hmm so looks like nothing to configure for the clocks or
> CPCAP_BIT_ST_L_TIMESLOT bits for cap for the EXT? So the
> wl12xx audio is wired directly to cpcap EXT then and not a
> TDM slot on the mcbsp huh?
>
> > Merry Christmas!
>
> Same to you!
>
> Tony
>
> 8< --------------------------------
> From tony Mon Sep 17 00:00:00 2001
> From: Tony Lindgren <[email protected]>
> Date: Fri, 21 Dec 2018 07:57:09 -0800
> Subject: [PATCH] ARM: omap2plus_defconfig: Add RADIO_WL128X as a loadable
> module
>
> This allows using the FM radio in the wl12xx chips after modprobe
> fm_drv using radio from xawt, or fmtools.
>
> Note that the firmware placed into /lib/firmware/ti-connectivity
> directory:
>
> fm_rx_ch8_1283.2.bts
> fmc_ch8_1283.2.bts
>
> Signed-off-by: Tony Lindgren <[email protected]>
> ---
> arch/arm/configs/omap2plus_defconfig | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
> --- a/arch/arm/configs/omap2plus_defconfig
> +++ b/arch/arm/configs/omap2plus_defconfig
> @@ -126,6 +126,7 @@ CONFIG_AF_RXRPC=m
> CONFIG_RXKAD=y
> CONFIG_CFG80211=m
> CONFIG_MAC80211=m
> +CONFIG_RFKILL=m
> CONFIG_DEVTMPFS=y
> CONFIG_DEVTMPFS_MOUNT=y
> CONFIG_DMA_CMA=y
> @@ -343,12 +344,14 @@ CONFIG_IR_GPIO_TX=m
> CONFIG_IR_PWM_TX=m
> CONFIG_MEDIA_SUPPORT=m
> CONFIG_MEDIA_CAMERA_SUPPORT=y
> +CONFIG_MEDIA_RADIO_SUPPORT=y
> CONFIG_MEDIA_CEC_SUPPORT=y
> CONFIG_MEDIA_CONTROLLER=y
> CONFIG_VIDEO_V4L2_SUBDEV_API=y
> CONFIG_V4L_PLATFORM_DRIVERS=y
> CONFIG_VIDEO_OMAP3=m
> CONFIG_CEC_PLATFORM_DRIVERS=y
> +CONFIG_RADIO_WL128X=m
> # CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
> CONFIG_VIDEO_TVP5150=m
> CONFIG_DRM=m
> --
> 2.19.2

2018-12-22 22:40:56

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Hi!

> > This moves all remaining users of the legacy TI_ST driver to hcill (patches
> > 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
> > device driver with support for multiple instances. Patch 7 will result in
> > (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
> > some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
> > specific parts from wl128x-radio and adds the required infrastructure to use it
> > with the serdev hcill driver instead. The remaining patches 13 and 14 remove
> > the old TI_ST code.
> >
> > The new code has been tested on the Motorola Droid 4. For testing the audio
> > should be configured to route Ext to Speaker or Headphone. Then you need to
> > plug headphone, since its cable is used as antenna. For testing there is a
> > 'radio' utility packages in Debian. When you start the utility you need to
> > specify a frequency, since initial get_frequency returns an error:
> >
> > $ radio -f 100.0
>
> Ok, it seems the driver does not work built-in, due to firmware issue:
>
> root@devuan:/home/user# dmesg | grep wl12
> [ 1.018951] reg-fixed-voltage regulator-wl12xx: GPIO lookup for
> consumer (null)
> [ 1.026550] reg-fixed-voltage regulator-wl12xx: using device tree
> for GPIO lookup
> [ 1.034271] of_get_named_gpiod_flags: can't parse 'gpios' property
> of node '/regulator-wl12xx[0]'
> [ 1.043487] of_get_named_gpiod_flags: parsed 'gpio' property of
> node '/regulator-wl12xx[0]' - status (0)
> [ 4.151885] wl12xx_driver wl12xx.1.auto: Direct firmware load for
> ti-connectivity/wl128x-nvs.bin failed with error -2
> [ 11.368286] vwl1271: disabling
> root@devuan:/home/user# find /lib/firmware/ | grep wl128
> /lib/firmware/ti-connectivity/wl128x-fw-5-plt.bin
> /lib/firmware/ti-connectivity/wl128x-fw-5-mr.bin
> /lib/firmware/ti-connectivity/wl128x-fw-5-sr.bin
> /lib/firmware/ti-connectivity/wl128x-nvs.bin
> root@devuan:/home/user#
>
> Ideas welcome... ... ... am I supposed to compile wl128-nvs.bin into
> the kernel using EXTRA_FIRMWARE?

EXTRA_FIRMWARE gets me further... some of it was not in debian.

"Speaker right" needs to be set to "Ext" in alsamixer, and then... it
works! :-)

Quality does not seem to be great, but that may be mixer settings or
something.

Thanks!
Pavel

Tested-by: Pavel Machek <[email protected]>

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (2.45 kB)
signature.asc (181.00 B)
Digital signature
Download all attachments

2018-12-23 15:56:58

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 12/14] media: wl128x-radio: move from TI_ST to hci_ll driver

Hi Sebastian,

> This updates the wl128x-radio driver to be used with hci_ll
> instead of the deprecated TI_ST driver.
>
> Signed-off-by: Sebastian Reichel <[email protected]>
> ---
> drivers/bluetooth/hci_ll.c | 115 ++++++++++++++++++++--
> drivers/media/radio/wl128x/Kconfig | 2 +-
> drivers/media/radio/wl128x/fmdrv.h | 1 +
> drivers/media/radio/wl128x/fmdrv_common.c | 101 ++-----------------
> include/linux/ti_wilink_st.h | 2 +
> 5 files changed, 117 insertions(+), 104 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c
> index 3e767f245ed5..6bcba57e9c9c 100644
> --- a/drivers/bluetooth/hci_ll.c
> +++ b/drivers/bluetooth/hci_ll.c
> @@ -49,6 +49,7 @@
> #include <linux/skbuff.h>
> #include <linux/ti_wilink_st.h>
> #include <linux/clk.h>
> +#include <linux/platform_device.h>
>
> #include <net/bluetooth/bluetooth.h>
> #include <net/bluetooth/hci_core.h>
> @@ -62,6 +63,7 @@
> #define HCI_VS_UPDATE_UART_HCI_BAUDRATE 0xff36
>
> /* HCILL commands */
> +#define HCILL_FM_RADIO 0x08
> #define HCILL_GO_TO_SLEEP_IND 0x30
> #define HCILL_GO_TO_SLEEP_ACK 0x31
> #define HCILL_WAKE_UP_IND 0x32
> @@ -81,6 +83,10 @@ struct ll_device {
> struct gpio_desc *enable_gpio;
> struct clk *ext_clk;
> bdaddr_t bdaddr;
> +
> + struct platform_device *fmdev;
> + void (*fm_handler) (void *, struct sk_buff *);
> + void *fm_drvdata;
> };
>
> struct ll_struct {
> @@ -161,6 +167,35 @@ static int ll_flush(struct hci_uart *hu)
> return 0;
> }
>
> +static int ll_register_fm(struct ll_device *lldev)
> +{
> + struct device *dev = &lldev->serdev->dev;
> + int err;
> +
> + if (!of_device_is_compatible(dev->of_node, "ti,wl1281-st") &&
> + !of_device_is_compatible(dev->of_node, "ti,wl1283-st") &&
> + !of_device_is_compatible(dev->of_node, "ti,wl1285-st"))
> + return -ENODEV;

do we really want to hardcode this here? Isn't there some HCI vendor command or some better DT description that we can use to decide when to register this platform device.

> +
> + lldev->fmdev = platform_device_register_data(dev, "wl128x-fm",
> + PLATFORM_DEVID_AUTO, NULL, 0);

Fix the indentation please to following networking coding style.

> + err = PTR_ERR_OR_ZERO(lldev->fmdev);
> + if (err) {
> + dev_warn(dev, "cannot register FM radio subdevice: %d\n", err);
> + lldev->fmdev = NULL;
> + }
> +
> + return err;
> +}
> +
> +static void ll_unregister_fm(struct ll_device *lldev)
> +{
> + if (!lldev->fmdev)
> + return;
> + platform_device_unregister(lldev->fmdev);
> + lldev->fmdev = NULL;
> +}
> +
> /* Close protocol */
> static int ll_close(struct hci_uart *hu)
> {
> @@ -178,6 +213,8 @@ static int ll_close(struct hci_uart *hu)
> gpiod_set_value_cansleep(lldev->enable_gpio, 0);
>
> clk_disable_unprepare(lldev->ext_clk);
> +
> + ll_unregister_fm(lldev);
> }
>
> hu->priv = NULL;
> @@ -313,18 +350,11 @@ static void ll_device_woke_up(struct hci_uart *hu)
> hci_uart_tx_wakeup(hu);
> }
>
> -/* Enqueue frame for transmittion (padding, crc, etc) */
> -/* may be called from two simultaneous tasklets */
> -static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb)
> +static int ll_enqueue_prefixed(struct hci_uart *hu, struct sk_buff *skb)
> {
> unsigned long flags = 0;
> struct ll_struct *ll = hu->priv;
>
> - BT_DBG("hu %p skb %p", hu, skb);
> -
> - /* Prepend skb with frame type */
> - memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
> -
> /* lock hcill state */
> spin_lock_irqsave(&ll->hcill_lock, flags);
>
> @@ -361,6 +391,18 @@ static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb)
> return 0;
> }
>
> +/* Enqueue frame for transmittion (padding, crc, etc) */
> +/* may be called from two simultaneous tasklets */
> +static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb)
> +{
> + BT_DBG("hu %p skb %p", hu, skb);
> +
> + /* Prepend skb with frame type */
> + memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
> +
> + return ll_enqueue_prefixed(hu, skb);
> +}
> +
> static int ll_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
> {
> struct hci_uart *hu = hci_get_drvdata(hdev);
> @@ -390,6 +432,32 @@ static int ll_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
> return 0;
> }
>
> +static int ll_recv_radio(struct hci_dev *hdev, struct sk_buff *skb)
> +{
> + struct hci_uart *hu = hci_get_drvdata(hdev);
> + struct serdev_device *serdev = hu->serdev;
> + struct ll_device *lldev = serdev_device_get_drvdata(serdev);
> +
> + if (!lldev->fm_handler) {
> + kfree_skb(skb);
> + return -EINVAL;
> + }
> +
> + /* Prepend skb with frame type */
> + memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
> +
> + lldev->fm_handler(lldev->fm_drvdata, skb);

So I have no idea why we bother adding the frame type here. What is the purpose. I think this is useless and we better fix the radio driver if that is what is expected.

> +
> + return 0;
> +}
> +
> +#define LL_RECV_FM_RADIO \
> + .type = HCILL_FM_RADIO, \
> + .hlen = 1, \
> + .loff = 0, \
> + .lsize = 1, \
> + .maxlen = 0xff
> +
> #define LL_RECV_SLEEP_IND \
> .type = HCILL_GO_TO_SLEEP_IND, \
> .hlen = 0, \
> @@ -422,6 +490,7 @@ static const struct h4_recv_pkt ll_recv_pkts[] = {
> { H4_RECV_ACL, .recv = hci_recv_frame },
> { H4_RECV_SCO, .recv = hci_recv_frame },
> { H4_RECV_EVENT, .recv = hci_recv_frame },
> + { LL_RECV_FM_RADIO, .recv = ll_recv_radio },
> { LL_RECV_SLEEP_IND, .recv = ll_recv_frame },
> { LL_RECV_SLEEP_ACK, .recv = ll_recv_frame },
> { LL_RECV_WAKE_IND, .recv = ll_recv_frame },
> @@ -669,11 +738,41 @@ static int ll_setup(struct hci_uart *hu)
> }
> }
>
> + /* We intentionally ignore failures and proceed without FM device */
> + ll_register_fm(lldev);
> +
> return 0;
> }
>
> static const struct hci_uart_proto llp;
>
> +void hci_ti_set_fm_handler(struct device *dev, void (*recv_handler) (void *, struct sk_buff *), void *drvdata)
> +{
> + struct serdev_device *serdev = to_serdev_device(dev);
> + struct ll_device *lldev = serdev_device_get_drvdata(serdev);
> +
> + lldev->fm_drvdata = drvdata;
> + lldev->fm_handler = recv_handler;
> +}
> +EXPORT_SYMBOL_GPL(hci_ti_set_fm_handler);
> +
> +int hci_ti_fm_send(struct device *dev, struct sk_buff *skb)
> +{
> + struct serdev_device *serdev = to_serdev_device(dev);
> + struct ll_device *lldev = serdev_device_get_drvdata(serdev);
> + struct hci_uart *hu = &lldev->hu;
> + int ret;
> +
> + hci_skb_pkt_type(skb) = HCILL_FM_RADIO;
> + ret = ll_enqueue_prefixed(hu, skb);

This is the same as above, lets have the radio driver not add this H:4 protocol type in the first place. It is really pointless that this driver tries to hack around it.

> +
> + if (!ret)
> + hci_uart_tx_wakeup(hu);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(hci_ti_fm_send);
> +
> static int hci_ti_probe(struct serdev_device *serdev)
> {
> struct hci_uart *hu;
> diff --git a/drivers/media/radio/wl128x/Kconfig b/drivers/media/radio/wl128x/Kconfig
> index 64b66bbdae72..847b3ed92639 100644
> --- a/drivers/media/radio/wl128x/Kconfig
> +++ b/drivers/media/radio/wl128x/Kconfig
> @@ -4,7 +4,7 @@
> menu "Texas Instruments WL128x FM driver (ST based)"
> config RADIO_WL128X
> tristate "Texas Instruments WL128x FM Radio"
> - depends on VIDEO_V4L2 && RFKILL && TTY && TI_ST
> + depends on VIDEO_V4L2 && RFKILL && TTY && BT_HCIUART_LL
> depends on GPIOLIB || COMPILE_TEST
> help
> Choose Y here if you have this FM radio chip.
> diff --git a/drivers/media/radio/wl128x/fmdrv.h b/drivers/media/radio/wl128x/fmdrv.h
> index 4a337f38cfc9..717a8a3f533f 100644
> --- a/drivers/media/radio/wl128x/fmdrv.h
> +++ b/drivers/media/radio/wl128x/fmdrv.h
> @@ -197,6 +197,7 @@ struct fmtx_data {
>
> /* FM driver operation structure */
> struct fmdev {
> + struct device *dev;
> struct video_device radio_dev; /* V4L2 video device pointer */
> struct v4l2_device v4l2_dev; /* V4L2 top level struct */
> struct snd_card *card; /* Card which holds FM mixer controls */
> diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
> index c20d518af4f3..88a2197c4815 100644
> --- a/drivers/media/radio/wl128x/fmdrv_common.c
> +++ b/drivers/media/radio/wl128x/fmdrv_common.c
> @@ -172,9 +172,6 @@ static int_handler_prototype int_handler_table[] = {
> fm_irq_handle_intmsk_cmd_resp
> };
>
> -static long (*g_st_write) (struct sk_buff *skb);
> -static struct completion wait_for_fmdrv_reg_comp;
> -
> static inline void fm_irq_call(struct fmdev *fmdev)
> {
> fmdev->irq_info.handlers[fmdev->irq_info.stage](fmdev);
> @@ -373,7 +370,7 @@ static void send_tasklet(unsigned long arg)
>
> /* Write FM packet to ST driver */
> dump_tx_skb_data(skb);
> - len = g_st_write(skb);
> + len = hci_ti_fm_send(fmdev->dev->parent, skb);
> if (len < 0) {
> kfree_skb(skb);
> fmdev->resp_comp = NULL;
> @@ -1441,42 +1438,13 @@ int fmc_get_mode(struct fmdev *fmdev, u8 *fmmode)
> }
>
> /* Called by ST layer when FM packet is available */
> -static long fm_st_receive(void *arg, struct sk_buff *skb)
> +static void fm_st_receive(void *arg, struct sk_buff *skb)
> {
> - struct fmdev *fmdev;
> -
> - fmdev = (struct fmdev *)arg;
> -
> - if (skb == NULL) {
> - fmerr("Invalid SKB received from ST\n");
> - return -EFAULT;
> - }
> -
> - if (skb->cb[0] != FM_PKT_LOGICAL_CHAN_NUMBER) {
> - fmerr("Received SKB (%p) is not FM Channel 8 pkt\n", skb);
> - return -EINVAL;
> - }
> + struct fmdev *fmdev = (struct fmdev *) arg;
>
> - memcpy(skb_push(skb, 1), &skb->cb[0], 1);
> dump_rx_skb_data(skb);
> -
> skb_queue_tail(&fmdev->rx_q, skb);
> tasklet_schedule(&fmdev->rx_task);
> -
> - return 0;
> -}
> -
> -/*
> - * Called by ST layer to indicate protocol registration completion
> - * status.
> - */
> -static void fm_st_reg_comp_cb(void *arg, int data)
> -{
> - struct fmdev *fmdev;
> -
> - fmdev = (struct fmdev *)arg;
> - fmdev->streg_cbdata = data;
> - complete(&wait_for_fmdrv_reg_comp);
> }
>
> /*
> @@ -1485,59 +1453,12 @@ static void fm_st_reg_comp_cb(void *arg, int data)
> */
> void fmc_prepare(struct fmdev *fmdev)
> {
> - static struct st_proto_s fm_st_proto;
> -
> if (test_bit(FM_CORE_READY, &fmdev->flag)) {
> fmdbg("FM Core is already up\n");
> return;
> }
>
> - memset(&fm_st_proto, 0, sizeof(fm_st_proto));
> - fm_st_proto.recv = fm_st_receive;
> - fm_st_proto.match_packet = NULL;
> - fm_st_proto.reg_complete_cb = fm_st_reg_comp_cb;
> - fm_st_proto.write = NULL; /* TI ST driver will fill write pointer */
> - fm_st_proto.priv_data = fmdev;
> - fm_st_proto.chnl_id = 0x08;
> - fm_st_proto.max_frame_size = 0xff;
> - fm_st_proto.hdr_len = 1;
> - fm_st_proto.offset_len_in_hdr = 0;
> - fm_st_proto.len_size = 1;
> - fm_st_proto.reserve = 1;
> -
> - ret = st_register(&fm_st_proto);
> - if (ret == -EINPROGRESS) {
> - init_completion(&wait_for_fmdrv_reg_comp);
> - fmdev->streg_cbdata = -EINPROGRESS;
> - fmdbg("%s waiting for ST reg completion signal\n", __func__);
> -
> - if (!wait_for_completion_timeout(&wait_for_fmdrv_reg_comp,
> - FM_ST_REG_TIMEOUT)) {
> - fmerr("Timeout(%d sec), didn't get reg completion signal from ST\n",
> - jiffies_to_msecs(FM_ST_REG_TIMEOUT) / 1000);
> - return -ETIMEDOUT;
> - }
> - if (fmdev->streg_cbdata != 0) {
> - fmerr("ST reg comp CB called with error status %d\n",
> - fmdev->streg_cbdata);
> - return -EAGAIN;
> - }
> -
> - ret = 0;
> - } else if (ret == -1) {
> - fmerr("st_register failed %d\n", ret);
> - return -EAGAIN;
> - }
> -
> - if (fm_st_proto.write != NULL) {
> - g_st_write = fm_st_proto.write;
> - } else {
> - fmerr("Failed to get ST write func pointer\n");
> - ret = st_unregister(&fm_st_proto);
> - if (ret < 0)
> - fmerr("st_unregister failed %d\n", ret);
> - return -EAGAIN;
> - }
> + hci_ti_set_fm_handler(fmdev->dev->parent, fm_st_receive, fmdev);
>
> spin_lock_init(&fmdev->rds_buff_lock);
> spin_lock_init(&fmdev->resp_skb_lock);
> @@ -1582,9 +1503,6 @@ void fmc_prepare(struct fmdev *fmdev)
> */
> void fmc_release(struct fmdev *fmdev)
> {
> - static struct st_proto_s fm_st_proto;
> - int ret;
> -
> if (!test_bit(FM_CORE_READY, &fmdev->flag)) {
> fmdbg("FM Core is already down\n");
> return;
> @@ -1601,15 +1519,7 @@ void fmc_release(struct fmdev *fmdev)
> fmdev->resp_comp = NULL;
> fmdev->rx.freq = 0;
>
> - memset(&fm_st_proto, 0, sizeof(fm_st_proto));
> - fm_st_proto.chnl_id = 0x08;
> -
> - ret = st_unregister(&fm_st_proto);
> -
> - if (ret < 0)
> - fmerr("Failed to de-register FM from ST %d\n", ret);
> - else
> - fmdbg("Successfully unregistered from ST\n");
> + hci_ti_set_fm_handler(fmdev->dev->parent, NULL, NULL);
>
> clear_bit(FM_CORE_READY, &fmdev->flag);
> }
> @@ -1624,6 +1534,7 @@ static int wl128x_fm_probe(struct platform_device *pdev)
> if (!fmdev)
> return -ENOMEM;
> platform_set_drvdata(pdev, fmdev);
> + fmdev->dev = &pdev->dev;
>
> fmdev->rx.rds.buf_size = default_rds_buf * FM_RDS_BLK_SIZE;
> fmdev->rx.rds.buff = devm_kzalloc(&pdev->dev, fmdev->rx.rds.buf_size, GFP_KERNEL);
> diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
> index f2293028ab9d..a9de5654b0cd 100644
> --- a/include/linux/ti_wilink_st.h
> +++ b/include/linux/ti_wilink_st.h
> @@ -86,6 +86,8 @@ struct st_proto_s {
> extern long st_register(struct st_proto_s *);
> extern long st_unregister(struct st_proto_s *);
>
> +void hci_ti_set_fm_handler(struct device *dev, void (*recv_handler) (void *, struct sk_buff *), void *drvdata);
> +int hci_ti_fm_send(struct device *dev, struct sk_buff *skb);

This really needs to be put somewhere else if we are removing the TI Wilink driver. This header file has to be removed as well.

I wonder really if we are not better having the Bluetooth HCI core provide an abstraction for a vendor channel. So that the HCI packets actually can flow through HCI monitor and be recorded via btmon. This would also mean that the driver could do something like hci_vnd_chan_add() and hci_vnd_chan_del() and use a struct hci_vnd_chan for callback handler hci_vnd_chan_send() functions.

On a side note, what is the protocol the TI FM radio is using anyway? Is that anywhere documented except the driver itself? Are they using HCI commands as well?

Regards

Marcel


2018-12-23 16:15:38

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

* Sebastian Reichel <[email protected]> [181222 02:48]:
> On Fri, Dec 21, 2018 at 10:02:05AM -0800, Tony Lindgren wrote:
> > Hmm so looks like nothing to configure for the clocks or
> > CPCAP_BIT_ST_L_TIMESLOT bits for cap for the EXT? So the
> > wl12xx audio is wired directly to cpcap EXT then and not a
> > TDM slot on the mcbsp huh?
>
> For FM radio it's directly wired to EXT with no DAI being required.
> I think that EXT is only used by FM radio and not by bluetooth. BT
> seems to use TDM.

OK then it sounds like we just need a diff -u of the cpcap regs
from Android with cpcaprw --all before and after using a bluetooth
headset during a voice call to configure it for voice calls for the
TDM. I think snd-soc-motmd just needs the voice output specified
in the mixer in addition to the cpcap configuration.

I don't think have any bluetooth audio gear though, maybe somebody
using a headset can post the diff.

Regards,

Tony

2018-12-23 16:22:39

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

* Adam Ford <[email protected]> [181222 20:36]:
> As much as I'd like to see the ti-st kim stuff go, I am not able to
> load the Bluetooth on the Torpedo board (wl1283). The hooks on a
> different, wl18xx and 127x board work fine. I am not sure if there is
> anything different about the wl1283, but I don't have any other boards
> other than the Logic PD Torpedo kit. Do you have any wl1283 boards to
> test? I'd like to see this BT timeout stuff resolved before we dump
> the ti-st kim stuff, otherwise, I'll forever be porting drivers. :-(

Sebastian and I both tested this with droid 4, which has wl1283. So
it's probably some missing GPIO/regulator/pinconf stuff that the
pdata-quirks.c does for you.

Maybe try adding back also the pdata-quirks.c code and see if that
helps?

Regards,

Tony

2019-01-09 18:12:07

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 12/14] media: wl128x-radio: move from TI_ST to hci_ll driver

Hi Marcel,

First of all thanks for your review.

On Sun, Dec 23, 2018 at 04:56:47PM +0100, Marcel Holtmann wrote:
> Hi Sebastian,

[...]

> > +static int ll_register_fm(struct ll_device *lldev)
> > +{
> > + struct device *dev = &lldev->serdev->dev;
> > + int err;
> > +
> > + if (!of_device_is_compatible(dev->of_node, "ti,wl1281-st") &&
> > + !of_device_is_compatible(dev->of_node, "ti,wl1283-st") &&
> > + !of_device_is_compatible(dev->of_node, "ti,wl1285-st"))
> > + return -ENODEV;
>
> do we really want to hardcode this here? Isn't there some HCI
> vendor command or some better DT description that we can use to
> decide when to register this platform device.

I don't know if there is some way to identify the availability
based on some HCI vendor command. The public documentation from
the WiLink chips is pretty bad.

> > + lldev->fmdev = platform_device_register_data(dev, "wl128x-fm",
> > + PLATFORM_DEVID_AUTO, NULL, 0);
>
> Fix the indentation please to following networking coding style.

Ok.

[...]

> > +static int ll_recv_radio(struct hci_dev *hdev, struct sk_buff *skb)
> > +{
> > + struct hci_uart *hu = hci_get_drvdata(hdev);
> > + struct serdev_device *serdev = hu->serdev;
> > + struct ll_device *lldev = serdev_device_get_drvdata(serdev);
> > +
> > + if (!lldev->fm_handler) {
> > + kfree_skb(skb);
> > + return -EINVAL;
> > + }
> > +
> > + /* Prepend skb with frame type */
> > + memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
> > +
> > + lldev->fm_handler(lldev->fm_drvdata, skb);
>
> So I have no idea why we bother adding the frame type here. What
> is the purpose. I think this is useless and we better fix the
> radio driver if that is what is expected.

That should be possible. I will change this before sending another
revision.

> > + return 0;
> > +}

[...]

> > +int hci_ti_fm_send(struct device *dev, struct sk_buff *skb)
> > +{
> > + struct serdev_device *serdev = to_serdev_device(dev);
> > + struct ll_device *lldev = serdev_device_get_drvdata(serdev);
> > + struct hci_uart *hu = &lldev->hu;
> > + int ret;
> > +
> > + hci_skb_pkt_type(skb) = HCILL_FM_RADIO;
> > + ret = ll_enqueue_prefixed(hu, skb);
>
> This is the same as above, lets have the radio driver not add this
> H:4 protocol type in the first place. It is really pointless that
> this driver tries to hack around it.

Yes, obviously both paths should follow the same logic.

[...]

> > diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
> > index f2293028ab9d..a9de5654b0cd 100644
> > --- a/include/linux/ti_wilink_st.h
> > +++ b/include/linux/ti_wilink_st.h
> > @@ -86,6 +86,8 @@ struct st_proto_s {
> > extern long st_register(struct st_proto_s *);
> > extern long st_unregister(struct st_proto_s *);
> >
> > +void hci_ti_set_fm_handler(struct device *dev, void (*recv_handler) (void *, struct sk_buff *), void *drvdata);
> > +int hci_ti_fm_send(struct device *dev, struct sk_buff *skb);
>
> This really needs to be put somewhere else if we are removing the
> TI Wilink driver. This header file has to be removed as well.

That header is already being used by the hci_ll driver (before this
patch) for some packet structures. I removed all WiLink specific
things in the patch removing the TI WiLink driver and kept it
otherwise.

> I wonder really if we are not better having the Bluetooth HCI core
> provide an abstraction for a vendor channel. So that the HCI
> packets actually can flow through HCI monitor and be recorded via
> btmon. This would also mean that the driver could do something
> like hci_vnd_chan_add() and hci_vnd_chan_del() and use a struct
> hci_vnd_chan for callback handler hci_vnd_chan_send() functions.

Was this question directed to me? I trust your decision how this
should be implemented. I'm missing the big picture from other BT
devices ;)

If I understood you correctly the suggestion is, that the TI BT
driver uses hci_recv_frame() for packet type 0x08 (LL_RECV_FM_RADIO).
Then the FM driver can call hci_vnd_chan_add() in its probe function
and hci_vnd_chan_del() in its remove function to register the receive
hook? Also the dump_tx_skb_data()/dump_rx_skb_data() could be
removed, since btmon can be used to see the packets? Sounds very
nice to me.

> On a side note, what is the protocol the TI FM radio is using
> anyway? Is that anywhere documented except the driver itself? Are
> they using HCI commands as well?

AFAIK there is no public documentation for the TI WiLink chips. At
least my only information source are the existing drivers. The
driver protocol can be seen in drivers/media/radio/wl128x/fmdrv_common.h:

struct fm_cmd_msg_hdr {
__u8 hdr; /* Logical Channel-8 */
__u8 len; /* Number of bytes follows */
__u8 op; /* FM Opcode */
__u8 rd_wr; /* Read/Write command */
__u8 dlen; /* Length of payload */
} __attribute__ ((packed));

struct fm_event_msg_hdr {
__u8 header; /* Logical Channel-8 */
__u8 len; /* Number of bytes follows */
__u8 status; /* Event status */
__u8 num_fm_hci_cmds; /* Number of pkts the host allowed to send */
__u8 op; /* FM Opcode */
__u8 rd_wr; /* Read/Write command */
__u8 dlen; /* Length of payload */
} __attribute__ ((packed));

Apart from the Bluetooth and FM part, the chips also support GPS
(packet type 0x9). The GPS feature is not used on Droid 4 stock
rom and seems to carry some TI specific protocol instead of NMEA.
Here is an old submission for this driver:
http://lkml.iu.edu/hypermail/linux/kernel/1005.0/00918.html

(I don't plan to work on the GPS part, but it provides some more
details about the WiLink chips protocol)

-- Sebastian


Attachments:
(No filename) (5.47 kB)
signature.asc (833.00 B)
Download all attachments

2019-01-09 18:17:56

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 10/14] media: wl128x-radio: simplify fmc_prepare/fmc_release

Hi Pavel,

On Sat, Dec 22, 2018 at 08:29:34PM +0100, Pavel Machek wrote:
> On Fri 2018-12-21 02:17:48, Sebastian Reichel wrote:
> > From: Sebastian Reichel <[email protected]>
> >
> > Remove unused return code from fmc_prepare() and fmc_release() to
> > simplify the code a bit.
>
>
> > /*
> > * This function will be called from FM V4L2 release function.
> > * Unregister from ST driver.
> > */
> > -int fmc_release(struct fmdev *fmdev)
> > +void fmc_release(struct fmdev *fmdev)
> > {
> > static struct st_proto_s fm_st_proto;
> > int ret;
> >
> > if (!test_bit(FM_CORE_READY, &fmdev->flag)) {
> > fmdbg("FM Core is already down\n");
> > - return 0;
> > + return;
> > }
> > /* Service pending read */
> > wake_up_interruptible(&fmdev->rx.rds.read_queue);
> > @@ -1611,7 +1606,6 @@ int fmc_release(struct fmdev *fmdev)
> > fmdbg("Successfully unregistered from ST\n");
> >
> > clear_bit(FM_CORE_READY, &fmdev->flag);
> > - return ret;
> > }
>
>
> You probably leave unused variable (ret) here. I guess that's okay as
> you remove it later in the series...?

It's still being used after this patch (but indeed removed in a
later patch).

> Also... I'd kind of expect _prepare routine to return int. Even if it
> currently does not do anything that could return error, I'd kind of
> expect allocations being done there...

well the driver is basically feature complete and all allocations
happen in probe :)

-- Sebastian


Attachments:
(No filename) (1.44 kB)
signature.asc (833.00 B)
Download all attachments

2019-01-09 19:24:55

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 12/14] media: wl128x-radio: move from TI_ST to hci_ll driver

Hi Sebastian,

>>> +static int ll_register_fm(struct ll_device *lldev)
>>> +{
>>> + struct device *dev = &lldev->serdev->dev;
>>> + int err;
>>> +
>>> + if (!of_device_is_compatible(dev->of_node, "ti,wl1281-st") &&
>>> + !of_device_is_compatible(dev->of_node, "ti,wl1283-st") &&
>>> + !of_device_is_compatible(dev->of_node, "ti,wl1285-st"))
>>> + return -ENODEV;
>>
>> do we really want to hardcode this here? Isn't there some HCI
>> vendor command or some better DT description that we can use to
>> decide when to register this platform device.
>
> I don't know if there is some way to identify the availability
> based on some HCI vendor command. The public documentation from
> the WiLink chips is pretty bad.

can we have some boolean property in the DT file then instead of hardcoding this in the driver.

>
>>> + lldev->fmdev = platform_device_register_data(dev, "wl128x-fm",
>>> + PLATFORM_DEVID_AUTO, NULL, 0);
>>
>> Fix the indentation please to following networking coding style.
>
> Ok.
>
> [...]
>
>>> +static int ll_recv_radio(struct hci_dev *hdev, struct sk_buff *skb)
>>> +{
>>> + struct hci_uart *hu = hci_get_drvdata(hdev);
>>> + struct serdev_device *serdev = hu->serdev;
>>> + struct ll_device *lldev = serdev_device_get_drvdata(serdev);
>>> +
>>> + if (!lldev->fm_handler) {
>>> + kfree_skb(skb);
>>> + return -EINVAL;
>>> + }
>>> +
>>> + /* Prepend skb with frame type */
>>> + memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
>>> +
>>> + lldev->fm_handler(lldev->fm_drvdata, skb);
>>
>> So I have no idea why we bother adding the frame type here. What
>> is the purpose. I think this is useless and we better fix the
>> radio driver if that is what is expected.
>
> That should be possible. I will change this before sending another
> revision.
>
>>> + return 0;
>>> +}
>
> [...]
>
>>> +int hci_ti_fm_send(struct device *dev, struct sk_buff *skb)
>>> +{
>>> + struct serdev_device *serdev = to_serdev_device(dev);
>>> + struct ll_device *lldev = serdev_device_get_drvdata(serdev);
>>> + struct hci_uart *hu = &lldev->hu;
>>> + int ret;
>>> +
>>> + hci_skb_pkt_type(skb) = HCILL_FM_RADIO;
>>> + ret = ll_enqueue_prefixed(hu, skb);
>>
>> This is the same as above, lets have the radio driver not add this
>> H:4 protocol type in the first place. It is really pointless that
>> this driver tries to hack around it.
>
> Yes, obviously both paths should follow the same logic.
>
> [...]
>
>>> diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
>>> index f2293028ab9d..a9de5654b0cd 100644
>>> --- a/include/linux/ti_wilink_st.h
>>> +++ b/include/linux/ti_wilink_st.h
>>> @@ -86,6 +86,8 @@ struct st_proto_s {
>>> extern long st_register(struct st_proto_s *);
>>> extern long st_unregister(struct st_proto_s *);
>>>
>>> +void hci_ti_set_fm_handler(struct device *dev, void (*recv_handler) (void *, struct sk_buff *), void *drvdata);
>>> +int hci_ti_fm_send(struct device *dev, struct sk_buff *skb);
>>
>> This really needs to be put somewhere else if we are removing the
>> TI Wilink driver. This header file has to be removed as well.
>
> That header is already being used by the hci_ll driver (before this
> patch) for some packet structures. I removed all WiLink specific
> things in the patch removing the TI WiLink driver and kept it
> otherwise.

We need to move everything from ti_wilink_st.h that is used in hci_ll.c into that file.

>
>> I wonder really if we are not better having the Bluetooth HCI core
>> provide an abstraction for a vendor channel. So that the HCI
>> packets actually can flow through HCI monitor and be recorded via
>> btmon. This would also mean that the driver could do something
>> like hci_vnd_chan_add() and hci_vnd_chan_del() and use a struct
>> hci_vnd_chan for callback handler hci_vnd_chan_send() functions.
>
> Was this question directed to me? I trust your decision how this
> should be implemented. I'm missing the big picture from other BT
> devices ;)
>
> If I understood you correctly the suggestion is, that the TI BT
> driver uses hci_recv_frame() for packet type 0x08 (LL_RECV_FM_RADIO).
> Then the FM driver can call hci_vnd_chan_add() in its probe function
> and hci_vnd_chan_del() in its remove function to register the receive
> hook? Also the dump_tx_skb_data()/dump_rx_skb_data() could be
> removed, since btmon can be used to see the packets? Sounds very
> nice to me.
>
>> On a side note, what is the protocol the TI FM radio is using
>> anyway? Is that anywhere documented except the driver itself? Are
>> they using HCI commands as well?
>
> AFAIK there is no public documentation for the TI WiLink chips. At
> least my only information source are the existing drivers. The
> driver protocol can be seen in drivers/media/radio/wl128x/fmdrv_common.h:
>
> struct fm_cmd_msg_hdr {
> __u8 hdr; /* Logical Channel-8 */
> __u8 len; /* Number of bytes follows */
> __u8 op; /* FM Opcode */
> __u8 rd_wr; /* Read/Write command */
> __u8 dlen; /* Length of payload */
> } __attribute__ ((packed));
>
> struct fm_event_msg_hdr {
> __u8 header; /* Logical Channel-8 */
> __u8 len; /* Number of bytes follows */
> __u8 status; /* Event status */
> __u8 num_fm_hci_cmds; /* Number of pkts the host allowed to send */
> __u8 op; /* FM Opcode */
> __u8 rd_wr; /* Read/Write command */
> __u8 dlen; /* Length of payload */
> } __attribute__ ((packed));

This is really a custom protocol (even if it kinda modeled after HCI commands/events) and it be really better the core allows to register skb_pkt_type() vendor channels so it just feeds this back into the driver. We need a bit of btmon mapping for this, but that shouldn’t be that hard.

> Apart from the Bluetooth and FM part, the chips also support GPS
> (packet type 0x9). The GPS feature is not used on Droid 4 stock
> rom and seems to carry some TI specific protocol instead of NMEA.
> Here is an old submission for this driver:
> http://lkml.iu.edu/hypermail/linux/kernel/1005.0/00918.html
>
> (I don't plan to work on the GPS part, but it provides some more
> details about the WiLink chips protocol)

We do have a GNSS subsystem now and could just as easily hook this up.

Regards

Marcel


2019-01-10 01:23:20

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 12/14] media: wl128x-radio: move from TI_ST to hci_ll driver

On Wed, Jan 9, 2019 at 1:24 PM Marcel Holtmann <[email protected]> wrote:
>
> Hi Sebastian,
>
> >>> +static int ll_register_fm(struct ll_device *lldev)
> >>> +{
> >>> + struct device *dev = &lldev->serdev->dev;
> >>> + int err;
> >>> +
> >>> + if (!of_device_is_compatible(dev->of_node, "ti,wl1281-st") &&
> >>> + !of_device_is_compatible(dev->of_node, "ti,wl1283-st") &&
> >>> + !of_device_is_compatible(dev->of_node, "ti,wl1285-st"))
> >>> + return -ENODEV;
> >>
> >> do we really want to hardcode this here? Isn't there some HCI
> >> vendor command or some better DT description that we can use to
> >> decide when to register this platform device.
> >
> > I don't know if there is some way to identify the availability
> > based on some HCI vendor command. The public documentation from
> > the WiLink chips is pretty bad.
>
> can we have some boolean property in the DT file then instead of hardcoding this in the driver.

Implying the feature based on the compatible is how this is normally
done for DT. Though typically we'd put the flag in driver match data
rather than code it like this.

However, I'd assume that FM radio depends on an antenna connection (to
the headphone) which a board may or may not have even though the chip
supports it. For that reason, I'm okay with a boolean here.

Rob

2019-01-10 17:43:15

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Hi,

On Sat, Dec 22, 2018 at 09:08:28PM +0100, Pavel Machek wrote:
> Merry Christmas!
>
> > This moves all remaining users of the legacy TI_ST driver to hcill (patches
> > 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
> > device driver with support for multiple instances. Patch 7 will result in
> > (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
> > some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
> > specific parts from wl128x-radio and adds the required infrastructure to use it
> > with the serdev hcill driver instead. The remaining patches 13 and 14 remove
> > the old TI_ST code.
> >
> > The new code has been tested on the Motorola Droid 4. For testing the audio
> > should be configured to route Ext to Speaker or Headphone. Then you need to
> > plug headphone, since its cable is used as antenna. For testing there is a
> > 'radio' utility packages in Debian. When you start the utility you need to
> > specify a frequency, since initial get_frequency returns an error:
> >
> > $ radio -f 100.0
>
> Ok, it seems the driver does not work built-in, due to firmware issue:
>
> root@devuan:/home/user# dmesg | grep wl12
> [ 1.018951] reg-fixed-voltage regulator-wl12xx: GPIO lookup for
> consumer (null)
> [ 1.026550] reg-fixed-voltage regulator-wl12xx: using device tree
> for GPIO lookup
> [ 1.034271] of_get_named_gpiod_flags: can't parse 'gpios' property
> of node '/regulator-wl12xx[0]'
> [ 1.043487] of_get_named_gpiod_flags: parsed 'gpio' property of
> node '/regulator-wl12xx[0]' - status (0)
> [ 4.151885] wl12xx_driver wl12xx.1.auto: Direct firmware load for
> ti-connectivity/wl128x-nvs.bin failed with error -2
> [ 11.368286] vwl1271: disabling
> root@devuan:/home/user# find /lib/firmware/ | grep wl128
> /lib/firmware/ti-connectivity/wl128x-fw-5-plt.bin
> /lib/firmware/ti-connectivity/wl128x-fw-5-mr.bin
> /lib/firmware/ti-connectivity/wl128x-fw-5-sr.bin
> /lib/firmware/ti-connectivity/wl128x-nvs.bin
> root@devuan:/home/user#
>
> Ideas welcome... ... ... am I supposed to compile wl128-nvs.bin into
> the kernel using EXTRA_FIRMWARE?

This is due to the driver loading before the rootfs is available.
You can workaround this without touching your kernel configuration by
rebinding the driver via sysfs: https://lwn.net/Articles/143397/

-- Sebastian


Attachments:
(No filename) (2.33 kB)
signature.asc (833.00 B)
Download all attachments

2019-02-18 22:05:05

by Enric Balletbo Serra

[permalink] [raw]
Subject: Re: [PATCH 02/14] ARM: dts: IGEP: Add WiLink UART node

Hi Sebastian,

Sorry to take so long to reply

Missatge de Sebastian Reichel <[email protected]> del dia dv., 21 de des.
2018 a les 9:05:
>
> From: Sebastian Reichel <[email protected]>
>
> Add a node for the UART part of WiLink chip.
>
> Cc: Enric Balletbo i Serra <[email protected]>
> Signed-off-by: Sebastian Reichel <[email protected]>
> ---
> This is compile tested only!
> ---
> arch/arm/boot/dts/omap3-igep0020-rev-f.dts | 8 ++++++++
> arch/arm/boot/dts/omap3-igep0030-rev-g.dts | 8 ++++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/arch/arm/boot/dts/omap3-igep0020-rev-f.dts b/arch/arm/boot/dts/omap3-igep0020-rev-f.dts
> index 285681d7af49..8bb4298ca05e 100644
> --- a/arch/arm/boot/dts/omap3-igep0020-rev-f.dts
> +++ b/arch/arm/boot/dts/omap3-igep0020-rev-f.dts
> @@ -52,3 +52,11 @@
> interrupts = <17 IRQ_TYPE_EDGE_RISING>; /* gpio 177 */
> };
> };
> +
> +&uart2 {
> + bluetooth {
> + compatible = "ti,wl1835-st";

That should be "ti,wl1831-st"

> + enable-gpios = <&gpio5 9 GPIO_ACTIVE_HIGH>; /* gpio 137 */
> + max-speed = <300000>;
> + };
> +};
> diff --git a/arch/arm/boot/dts/omap3-igep0030-rev-g.dts b/arch/arm/boot/dts/omap3-igep0030-rev-g.dts
> index 1adc73bd2ca0..03be171e9de7 100644
> --- a/arch/arm/boot/dts/omap3-igep0030-rev-g.dts
> +++ b/arch/arm/boot/dts/omap3-igep0030-rev-g.dts
> @@ -74,3 +74,11 @@
> interrupts = <8 IRQ_TYPE_EDGE_RISING>; /* gpio 136 */
> };
> };
> +
> +&uart2 {
> + bluetooth {
> + compatible = "ti,wl1835-st";

That should be "ti,wl1831-st"

> + enable-gpios = <&gpio5 9 GPIO_ACTIVE_HIGH>; /* gpio 137 */
> + max-speed = <300000>;
> + };
> +};
> --
> 2.19.2
>

Apart from that,

Acked-by: Enric Balletbo i Serra <[email protected]>

2019-03-14 08:20:23

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Hi Sebastian,

On 12/21/18 2:17 AM, Sebastian Reichel wrote:
> Hi,
>
> This moves all remaining users of the legacy TI_ST driver to hcill (patches
> 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
> device driver with support for multiple instances. Patch 7 will result in
> (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
> some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
> specific parts from wl128x-radio and adds the required infrastructure to use it
> with the serdev hcill driver instead. The remaining patches 13 and 14 remove
> the old TI_ST code.
>
> The new code has been tested on the Motorola Droid 4. For testing the audio
> should be configured to route Ext to Speaker or Headphone. Then you need to
> plug headphone, since its cable is used as antenna. For testing there is a
> 'radio' utility packages in Debian. When you start the utility you need to
> specify a frequency, since initial get_frequency returns an error:

What is the status of this series?

Based on some of the replies (from Adam Ford in particular) it appears that
this isn't ready to be merged, so is a v2 planned?

Regards,

Hans

>
> $ radio -f 100.0
>
> Merry Christmas!
>
> -- Sebastian
>
> Sebastian Reichel (14):
> ARM: dts: LogicPD Torpedo: Add WiLink UART node
> ARM: dts: IGEP: Add WiLink UART node
> ARM: OMAP2+: pdata-quirks: drop TI_ST/KIM support
> media: wl128x-radio: remove module version
> media: wl128x-radio: remove global radio_disconnected
> media: wl128x-radio: remove global radio_dev
> media: wl128x-radio: convert to platform device
> media: wl128x-radio: use device managed memory allocation
> media: wl128x-radio: load firmware from ti-connectivity/
> media: wl128x-radio: simplify fmc_prepare/fmc_release
> media: wl128x-radio: fix skb debug printing
> media: wl128x-radio: move from TI_ST to hci_ll driver
> Bluetooth: btwilink: drop superseded driver
> misc: ti-st: Drop superseded driver
>
> .../boot/dts/logicpd-torpedo-37xx-devkit.dts | 8 +
> arch/arm/boot/dts/omap3-igep0020-rev-f.dts | 8 +
> arch/arm/boot/dts/omap3-igep0030-rev-g.dts | 8 +
> arch/arm/mach-omap2/pdata-quirks.c | 52 -
> drivers/bluetooth/Kconfig | 11 -
> drivers/bluetooth/Makefile | 1 -
> drivers/bluetooth/btwilink.c | 350 -------
> drivers/bluetooth/hci_ll.c | 115 ++-
> drivers/media/radio/wl128x/Kconfig | 2 +-
> drivers/media/radio/wl128x/fmdrv.h | 5 +-
> drivers/media/radio/wl128x/fmdrv_common.c | 211 ++--
> drivers/media/radio/wl128x/fmdrv_common.h | 4 +-
> drivers/media/radio/wl128x/fmdrv_v4l2.c | 55 +-
> drivers/media/radio/wl128x/fmdrv_v4l2.h | 2 +-
> drivers/misc/Kconfig | 1 -
> drivers/misc/Makefile | 1 -
> drivers/misc/ti-st/Kconfig | 18 -
> drivers/misc/ti-st/Makefile | 6 -
> drivers/misc/ti-st/st_core.c | 922 ------------------
> drivers/misc/ti-st/st_kim.c | 868 -----------------
> drivers/misc/ti-st/st_ll.c | 169 ----
> include/linux/ti_wilink_st.h | 337 +------
> 22 files changed, 213 insertions(+), 2941 deletions(-)
> delete mode 100644 drivers/bluetooth/btwilink.c
> delete mode 100644 drivers/misc/ti-st/Kconfig
> delete mode 100644 drivers/misc/ti-st/Makefile
> delete mode 100644 drivers/misc/ti-st/st_core.c
> delete mode 100644 drivers/misc/ti-st/st_kim.c
> delete mode 100644 drivers/misc/ti-st/st_ll.c
>


2019-03-14 12:19:07

by Adam Ford

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

On Thu, Mar 14, 2019 at 3:21 AM Hans Verkuil <[email protected]> wrote:
>
> Hi Sebastian,
>
> On 12/21/18 2:17 AM, Sebastian Reichel wrote:
> > Hi,
> >
> > This moves all remaining users of the legacy TI_ST driver to hcill (patches
> > 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
> > device driver with support for multiple instances. Patch 7 will result in
> > (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
> > some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
> > specific parts from wl128x-radio and adds the required infrastructure to use it
> > with the serdev hcill driver instead. The remaining patches 13 and 14 remove
> > the old TI_ST code.
> >
> > The new code has been tested on the Motorola Droid 4. For testing the audio
> > should be configured to route Ext to Speaker or Headphone. Then you need to
> > plug headphone, since its cable is used as antenna. For testing there is a
> > 'radio' utility packages in Debian. When you start the utility you need to
> > specify a frequency, since initial get_frequency returns an error:
>
> What is the status of this series?
>
> Based on some of the replies (from Adam Ford in particular) it appears that
> this isn't ready to be merged, so is a v2 planned?

If you can leave the Logic PD Torpedo board alone and don't remove the
legacy st driver for now, go ahead and migrate the others. I know
what you proposed 'should' work on my board, but I don't know why it
doesn't. In fact other boards I maintain use your method, but it just
doesn't work on the Torpedo and I don't know why. (it's not for lack
of trying)

adam
>
> Regards,
>
> Hans
>
> >
> > $ radio -f 100.0
> >
> > Merry Christmas!
> >
> > -- Sebastian
> >
> > Sebastian Reichel (14):
> > ARM: dts: LogicPD Torpedo: Add WiLink UART node
> > ARM: dts: IGEP: Add WiLink UART node
> > ARM: OMAP2+: pdata-quirks: drop TI_ST/KIM support
> > media: wl128x-radio: remove module version
> > media: wl128x-radio: remove global radio_disconnected
> > media: wl128x-radio: remove global radio_dev
> > media: wl128x-radio: convert to platform device
> > media: wl128x-radio: use device managed memory allocation
> > media: wl128x-radio: load firmware from ti-connectivity/
> > media: wl128x-radio: simplify fmc_prepare/fmc_release
> > media: wl128x-radio: fix skb debug printing
> > media: wl128x-radio: move from TI_ST to hci_ll driver
> > Bluetooth: btwilink: drop superseded driver
> > misc: ti-st: Drop superseded driver
> >
> > .../boot/dts/logicpd-torpedo-37xx-devkit.dts | 8 +
> > arch/arm/boot/dts/omap3-igep0020-rev-f.dts | 8 +
> > arch/arm/boot/dts/omap3-igep0030-rev-g.dts | 8 +
> > arch/arm/mach-omap2/pdata-quirks.c | 52 -
> > drivers/bluetooth/Kconfig | 11 -
> > drivers/bluetooth/Makefile | 1 -
> > drivers/bluetooth/btwilink.c | 350 -------
> > drivers/bluetooth/hci_ll.c | 115 ++-
> > drivers/media/radio/wl128x/Kconfig | 2 +-
> > drivers/media/radio/wl128x/fmdrv.h | 5 +-
> > drivers/media/radio/wl128x/fmdrv_common.c | 211 ++--
> > drivers/media/radio/wl128x/fmdrv_common.h | 4 +-
> > drivers/media/radio/wl128x/fmdrv_v4l2.c | 55 +-
> > drivers/media/radio/wl128x/fmdrv_v4l2.h | 2 +-
> > drivers/misc/Kconfig | 1 -
> > drivers/misc/Makefile | 1 -
> > drivers/misc/ti-st/Kconfig | 18 -
> > drivers/misc/ti-st/Makefile | 6 -
> > drivers/misc/ti-st/st_core.c | 922 ------------------
> > drivers/misc/ti-st/st_kim.c | 868 -----------------
> > drivers/misc/ti-st/st_ll.c | 169 ----
> > include/linux/ti_wilink_st.h | 337 +------
> > 22 files changed, 213 insertions(+), 2941 deletions(-)
> > delete mode 100644 drivers/bluetooth/btwilink.c
> > delete mode 100644 drivers/misc/ti-st/Kconfig
> > delete mode 100644 drivers/misc/ti-st/Makefile
> > delete mode 100644 drivers/misc/ti-st/st_core.c
> > delete mode 100644 drivers/misc/ti-st/st_kim.c
> > delete mode 100644 drivers/misc/ti-st/st_ll.c
> >
>

2019-03-19 13:32:05

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Hi Hans,

On Thu, Mar 14, 2019 at 09:20:10AM +0100, Hans Verkuil wrote:
> On 12/21/18 2:17 AM, Sebastian Reichel wrote:
> > This moves all remaining users of the legacy TI_ST driver to hcill (patches
> > 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
> > device driver with support for multiple instances. Patch 7 will result in
> > (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
> > some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
> > specific parts from wl128x-radio and adds the required infrastructure to use it
> > with the serdev hcill driver instead. The remaining patches 13 and 14 remove
> > the old TI_ST code.
> >
> > The new code has been tested on the Motorola Droid 4. For testing the audio
> > should be configured to route Ext to Speaker or Headphone. Then you need to
> > plug headphone, since its cable is used as antenna. For testing there is a
> > 'radio' utility packages in Debian. When you start the utility you need to
> > specify a frequency, since initial get_frequency returns an error:
>
> What is the status of this series?
>
> Based on some of the replies (from Adam Ford in particular) it appears that
> this isn't ready to be merged, so is a v2 planned?

Yes, a v2 is planned, but I'm super busy at the moment. I don't
expect to send something for this merge window. Neither LogicPD
nor IGEP use FM radio, so I can just remove FM support from the
TI_ST framework. Converting those platforms to hci_ll can be done
in a different patchset.

If that was the only issue there would be a v2 already. But Marcel
Holtmann suggested to pass the custom packet data through the BT
subsystem, which is non-trivial (at least for me) :)

-- Sebastian


Attachments:
(No filename) (1.72 kB)
signature.asc (833.00 B)
Download all attachments

2019-05-07 17:27:57

by Adam Ford

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

On Tue, Mar 19, 2019 at 8:33 AM Sebastian Reichel <[email protected]> wrote:
>
> Hi Hans,
>
> On Thu, Mar 14, 2019 at 09:20:10AM +0100, Hans Verkuil wrote:
> > On 12/21/18 2:17 AM, Sebastian Reichel wrote:
> > > This moves all remaining users of the legacy TI_ST driver to hcill (patches
> > > 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
> > > device driver with support for multiple instances. Patch 7 will result in
> > > (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
> > > some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
> > > specific parts from wl128x-radio and adds the required infrastructure to use it
> > > with the serdev hcill driver instead. The remaining patches 13 and 14 remove
> > > the old TI_ST code.
> > >
> > > The new code has been tested on the Motorola Droid 4. For testing the audio
> > > should be configured to route Ext to Speaker or Headphone. Then you need to
> > > plug headphone, since its cable is used as antenna. For testing there is a
> > > 'radio' utility packages in Debian. When you start the utility you need to
> > > specify a frequency, since initial get_frequency returns an error:
> >
> > What is the status of this series?
> >
> > Based on some of the replies (from Adam Ford in particular) it appears that
> > this isn't ready to be merged, so is a v2 planned?
>
> Yes, a v2 is planned, but I'm super busy at the moment. I don't
> expect to send something for this merge window. Neither LogicPD
> nor IGEP use FM radio, so I can just remove FM support from the
> TI_ST framework. Converting those platforms to hci_ll can be done
> in a different patchset.
>
> If that was the only issue there would be a v2 already. But Marcel
> Holtmann suggested to pass the custom packet data through the BT
> subsystem, which is non-trivial (at least for me) :)

I am running some tests today on the wl1283-st on the Logic PD Torpedo
board. Tony had suggested a few options, so I'm going to try those.
Looking at those today. If/when you have a V2, please CC me on it. If
it's been posted, can you send me a link? I would really like to see
the st-kim driver go away so I'd like to resolve the issues with the
torpedo board.

thanks

adam
>
> -- Sebastian

2019-05-08 21:04:28

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Hi Adam,

>>>>> This moves all remaining users of the legacy TI_ST driver to hcill (patches
>>>>> 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
>>>>> device driver with support for multiple instances. Patch 7 will result in
>>>>> (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
>>>>> some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
>>>>> specific parts from wl128x-radio and adds the required infrastructure to use it
>>>>> with the serdev hcill driver instead. The remaining patches 13 and 14 remove
>>>>> the old TI_ST code.
>>>>>
>>>>> The new code has been tested on the Motorola Droid 4. For testing the audio
>>>>> should be configured to route Ext to Speaker or Headphone. Then you need to
>>>>> plug headphone, since its cable is used as antenna. For testing there is a
>>>>> 'radio' utility packages in Debian. When you start the utility you need to
>>>>> specify a frequency, since initial get_frequency returns an error:
>>>>
>>>> What is the status of this series?
>>>>
>>>> Based on some of the replies (from Adam Ford in particular) it appears that
>>>> this isn't ready to be merged, so is a v2 planned?
>>>
>>> Yes, a v2 is planned, but I'm super busy at the moment. I don't
>>> expect to send something for this merge window. Neither LogicPD
>>> nor IGEP use FM radio, so I can just remove FM support from the
>>> TI_ST framework. Converting those platforms to hci_ll can be done
>>> in a different patchset.
>>>
>>> If that was the only issue there would be a v2 already. But Marcel
>>> Holtmann suggested to pass the custom packet data through the BT
>>> subsystem, which is non-trivial (at least for me) :)
>>
>> I am running some tests today on the wl1283-st on the Logic PD Torpedo
>> board. Tony had suggested a few options, so I'm going to try those.
>> Looking at those today. If/when you have a V2, please CC me on it. If
>> it's been posted, can you send me a link? I would really like to see
>> the st-kim driver go away so I'd like to resolve the issues with the
>> torpedo board.
>
> I have run a bunch of tests on the 5.1 kernel. I am able to get the
> firmware to load now and the hci0 goes up. I was able to establish a
> BLE connection to a TI Sensor Tag and read and write data to it with
> good success on the wl1283.
>
> Unfortunately, when I tried to do some more extensive testing over
> classic Bluetooth, I got an error that repeats itself at seemingly
> random intervals:
> Bluetooth: hci0: Frame reassembly failed (-84)
>
> I can still scan and pair, but these Frame reassembly failed errors
> appear to come and go.

there are only 3 places in h4_recv_buf that return EILSEQ. Just add an extra printk to these to figure out which one it is. Maybe it is just extra packet types that we need to handle. If it is not the packet type one, print what packet we have that is causing this.

Regards

Marcel

2019-05-10 13:31:08

by Adam Ford

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

On Wed, May 8, 2019 at 3:58 PM Marcel Holtmann <[email protected]> wrote:
>
> Hi Adam,
>
> >>>>> This moves all remaining users of the legacy TI_ST driver to hcill (patches
> >>>>> 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
> >>>>> device driver with support for multiple instances. Patch 7 will result in
> >>>>> (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
> >>>>> some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
> >>>>> specific parts from wl128x-radio and adds the required infrastructure to use it
> >>>>> with the serdev hcill driver instead. The remaining patches 13 and 14 remove
> >>>>> the old TI_ST code.
> >>>>>
> >>>>> The new code has been tested on the Motorola Droid 4. For testing the audio
> >>>>> should be configured to route Ext to Speaker or Headphone. Then you need to
> >>>>> plug headphone, since its cable is used as antenna. For testing there is a
> >>>>> 'radio' utility packages in Debian. When you start the utility you need to
> >>>>> specify a frequency, since initial get_frequency returns an error:
> >>>>
> >>>> What is the status of this series?
> >>>>
> >>>> Based on some of the replies (from Adam Ford in particular) it appears that
> >>>> this isn't ready to be merged, so is a v2 planned?
> >>>
> >>> Yes, a v2 is planned, but I'm super busy at the moment. I don't
> >>> expect to send something for this merge window. Neither LogicPD
> >>> nor IGEP use FM radio, so I can just remove FM support from the
> >>> TI_ST framework. Converting those platforms to hci_ll can be done
> >>> in a different patchset.
> >>>
> >>> If that was the only issue there would be a v2 already. But Marcel
> >>> Holtmann suggested to pass the custom packet data through the BT
> >>> subsystem, which is non-trivial (at least for me) :)
> >>
> >> I am running some tests today on the wl1283-st on the Logic PD Torpedo
> >> board. Tony had suggested a few options, so I'm going to try those.
> >> Looking at those today. If/when you have a V2, please CC me on it. If
> >> it's been posted, can you send me a link? I would really like to see
> >> the st-kim driver go away so I'd like to resolve the issues with the
> >> torpedo board.
> >
> > I have run a bunch of tests on the 5.1 kernel. I am able to get the
> > firmware to load now and the hci0 goes up. I was able to establish a
> > BLE connection to a TI Sensor Tag and read and write data to it with
> > good success on the wl1283.
> >
> > Unfortunately, when I tried to do some more extensive testing over
> > classic Bluetooth, I got an error that repeats itself at seemingly
> > random intervals:
> > Bluetooth: hci0: Frame reassembly failed (-84)
> >
> > I can still scan and pair, but these Frame reassembly failed errors
> > appear to come and go.
>
> there are only 3 places in h4_recv_buf that return EILSEQ. Just add an extra printk to these to figure out which one it is. Maybe it is just extra packet types that we need to handle. If it is not the packet type one, print what packet we have that is causing this.
>

I added some code around

/* Check for invalid packet type */
if (!skb) {
printk("Check for invalid packet type %x\n", (unsigned int)
(&pkts[i])->type);
return ERR_PTR(-EILSEQ);
}

I don't know if I did it right or I am reading the packet type
correctly, but the frame reassembly errors are being caught here.

[ 408.519165] Check for invalid packet type ff
[ 408.523559] Bluetooth: hci0: Frame reassembly failed (-84)


adam

> Regards
>
> Marcel
>

2019-05-10 15:40:39

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Hi Adam,

>>>>>>> This moves all remaining users of the legacy TI_ST driver to hcill (patches
>>>>>>> 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
>>>>>>> device driver with support for multiple instances. Patch 7 will result in
>>>>>>> (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
>>>>>>> some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
>>>>>>> specific parts from wl128x-radio and adds the required infrastructure to use it
>>>>>>> with the serdev hcill driver instead. The remaining patches 13 and 14 remove
>>>>>>> the old TI_ST code.
>>>>>>>
>>>>>>> The new code has been tested on the Motorola Droid 4. For testing the audio
>>>>>>> should be configured to route Ext to Speaker or Headphone. Then you need to
>>>>>>> plug headphone, since its cable is used as antenna. For testing there is a
>>>>>>> 'radio' utility packages in Debian. When you start the utility you need to
>>>>>>> specify a frequency, since initial get_frequency returns an error:
>>>>>>
>>>>>> What is the status of this series?
>>>>>>
>>>>>> Based on some of the replies (from Adam Ford in particular) it appears that
>>>>>> this isn't ready to be merged, so is a v2 planned?
>>>>>
>>>>> Yes, a v2 is planned, but I'm super busy at the moment. I don't
>>>>> expect to send something for this merge window. Neither LogicPD
>>>>> nor IGEP use FM radio, so I can just remove FM support from the
>>>>> TI_ST framework. Converting those platforms to hci_ll can be done
>>>>> in a different patchset.
>>>>>
>>>>> If that was the only issue there would be a v2 already. But Marcel
>>>>> Holtmann suggested to pass the custom packet data through the BT
>>>>> subsystem, which is non-trivial (at least for me) :)
>>>>
>>>> I am running some tests today on the wl1283-st on the Logic PD Torpedo
>>>> board. Tony had suggested a few options, so I'm going to try those.
>>>> Looking at those today. If/when you have a V2, please CC me on it. If
>>>> it's been posted, can you send me a link? I would really like to see
>>>> the st-kim driver go away so I'd like to resolve the issues with the
>>>> torpedo board.
>>>
>>> I have run a bunch of tests on the 5.1 kernel. I am able to get the
>>> firmware to load now and the hci0 goes up. I was able to establish a
>>> BLE connection to a TI Sensor Tag and read and write data to it with
>>> good success on the wl1283.
>>>
>>> Unfortunately, when I tried to do some more extensive testing over
>>> classic Bluetooth, I got an error that repeats itself at seemingly
>>> random intervals:
>>> Bluetooth: hci0: Frame reassembly failed (-84)
>>>
>>> I can still scan and pair, but these Frame reassembly failed errors
>>> appear to come and go.
>>
>> there are only 3 places in h4_recv_buf that return EILSEQ. Just add an extra printk to these to figure out which one it is. Maybe it is just extra packet types that we need to handle. If it is not the packet type one, print what packet we have that is causing this.
>>
>
> I added some code around
>
> /* Check for invalid packet type */
> if (!skb) {
> printk("Check for invalid packet type %x\n", (unsigned int)
> (&pkts[i])->type);
> return ERR_PTR(-EILSEQ);
> }
>
> I don't know if I did it right or I am reading the packet type
> correctly, but the frame reassembly errors are being caught here.
>
> [ 408.519165] Check for invalid packet type ff
> [ 408.523559] Bluetooth: hci0: Frame reassembly failed (-84)

so now we need to figure our on how to handle HCI_VENDOR_PKT.

#define LL_RECV_VENDOR \
.type = HCI_VENDOR_PKT, \
.hlen = aaa, \
.loff = bbb, \
.lsize = ccc, \
.maxlen = ddd

static const struct h4_recv_pkt ll_recv_pkts[] = {
...
{ LL_RECV_WAKE_ACK, .recv = ll_recv_frame },
{ LL_RECV_VENDOR, .recv = hci_recv_diag },
};

Can you hexdump the data inside the skb and we can figure out what it uses for the header and size.

In hci_bcm.c there are a few examples of fixed size packets and bpa10x.c contains one where it follows an actual header definition. Also hci_nokia.c contains a few for their packets.

Regards

Marcel

2019-10-02 19:04:53

by Adam Ford

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

On Tue, Mar 19, 2019 at 8:33 AM Sebastian Reichel <[email protected]> wrote:
>
> Hi Hans,
>
> On Thu, Mar 14, 2019 at 09:20:10AM +0100, Hans Verkuil wrote:
> > On 12/21/18 2:17 AM, Sebastian Reichel wrote:
> > > This moves all remaining users of the legacy TI_ST driver to hcill (patches
> > > 1-3). Then patches 4-7 convert wl128x-radio driver to a standard platform
> > > device driver with support for multiple instances. Patch 7 will result in
> > > (userless) TI_ST driver no longer supporting radio at runtime. Patch 8-11 do
> > > some cleanups in the wl128x-radio driver. Finally patch 12 removes the TI_ST
> > > specific parts from wl128x-radio and adds the required infrastructure to use it
> > > with the serdev hcill driver instead. The remaining patches 13 and 14 remove
> > > the old TI_ST code.
> > >
> > > The new code has been tested on the Motorola Droid 4. For testing the audio
> > > should be configured to route Ext to Speaker or Headphone. Then you need to
> > > plug headphone, since its cable is used as antenna. For testing there is a
> > > 'radio' utility packages in Debian. When you start the utility you need to
> > > specify a frequency, since initial get_frequency returns an error:
> >
> > What is the status of this series?
> >
> > Based on some of the replies (from Adam Ford in particular) it appears that
> > this isn't ready to be merged, so is a v2 planned?
>
> Yes, a v2 is planned, but I'm super busy at the moment. I don't
> expect to send something for this merge window. Neither LogicPD
> nor IGEP use FM radio, so I can just remove FM support from the
> TI_ST framework. Converting those platforms to hci_ll can be done
> in a different patchset.
>

Sebastian,

After a bunch of testing, I think the issue I was having was the BTS
file being pulled in from linux-firmware. I was able to successfully
load a BTS file that I have from Logic PD with working BLE and BT
working together. I have to run some tests, but if you wouldn't mind
re-basing your code and pushing it again for review, I can most likely
add my 'tested-by'
I am not sure who to discuss my perceived bug in the BTS blob. I have
to go find the old BTS editor and see if I can determine the cause,
but the fact that I can use the BTS file that corresponds to the FCC
certified file that Logic PD used is more important to me than using
the generic BTS file provided by TI, however it would be nice for the
reference BTS file to operate without error.

adam
> If that was the only issue there would be a v2 already. But Marcel
> Holtmann suggested to pass the custom packet data through the BT
> subsystem, which is non-trivial (at least for me) :)
>
> -- Sebastian

2019-10-03 14:43:54

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 00/14] Add support for FM radio in hcill and kill TI_ST

Hi Adam,

On Wed, Oct 02, 2019 at 02:03:52PM -0500, Adam Ford wrote:
> On Tue, Mar 19, 2019 at 8:33 AM Sebastian Reichel <[email protected]> wrote:
> After a bunch of testing, I think the issue I was having was the BTS
> file being pulled in from linux-firmware. I was able to successfully
> load a BTS file that I have from Logic PD with working BLE and BT
> working together. I have to run some tests, but if you wouldn't mind
> re-basing your code and pushing it again for review, I can most likely
> add my 'tested-by'.
>
> I am not sure who to discuss my perceived bug in the BTS blob. I have
> to go find the old BTS editor and see if I can determine the cause,
> but the fact that I can use the BTS file that corresponds to the FCC
> certified file that Logic PD used is more important to me than using
> the generic BTS file provided by TI, however it would be nice for the
> reference BTS file to operate without error.

nice :) I just send a rebased partial series. I need some more time
for the FM radio part (I plan to work on that within the next 3
weeks).

-- Sebastian


Attachments:
(No filename) (1.08 kB)
signature.asc (849.00 B)
Download all attachments