|
@@ -63,10 +63,27 @@ static struct platform_device *st_get_plat_device(int id)
|
|
|
* in case of error don't complete so that waiting for proper
|
|
|
* response times out
|
|
|
*/
|
|
|
-void validate_firmware_response(struct kim_data_s *kim_gdata)
|
|
|
+static void validate_firmware_response(struct kim_data_s *kim_gdata)
|
|
|
{
|
|
|
struct sk_buff *skb = kim_gdata->rx_skb;
|
|
|
- if (unlikely(skb->data[5] != 0)) {
|
|
|
+ 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);
|
|
|
+ complete_all(&kim_gdata->kim_rcvd);
|
|
|
+ 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);
|
|
@@ -119,7 +136,7 @@ static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len)
|
|
|
* have been observed to come in bursts of different
|
|
|
* tty_receive and hence the logic
|
|
|
*/
|
|
|
-void kim_int_recv(struct kim_data_s *kim_gdata,
|
|
|
+static void kim_int_recv(struct kim_data_s *kim_gdata,
|
|
|
const unsigned char *data, long count)
|
|
|
{
|
|
|
const unsigned char *ptr;
|
|
@@ -207,16 +224,19 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
|
|
|
return -EIO;
|
|
|
}
|
|
|
|
|
|
- if (!wait_for_completion_timeout
|
|
|
- (&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) {
|
|
|
+ if (!wait_for_completion_interruptible_timeout(
|
|
|
+ &kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) {
|
|
|
pr_err(" waiting for ver info- timed out ");
|
|
|
return -ETIMEDOUT;
|
|
|
}
|
|
|
INIT_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[13],
|
|
|
- kim_gdata->resp_buffer[14]);
|
|
|
+ MAKEWORD(kim_gdata->resp_buffer[12],
|
|
|
+ kim_gdata->resp_buffer[13]);
|
|
|
chip = (version & 0x7C00) >> 10;
|
|
|
min_ver = (version & 0x007F);
|
|
|
maj_ver = (version & 0x0380) >> 7;
|
|
@@ -236,7 +256,7 @@ static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-void skip_change_remote_baud(unsigned char **ptr, long *len)
|
|
|
+static void skip_change_remote_baud(unsigned char **ptr, long *len)
|
|
|
{
|
|
|
unsigned char *nxt_action, *cur_action;
|
|
|
cur_action = *ptr;
|
|
@@ -370,9 +390,9 @@ static long download_firmware(struct kim_data_s *kim_gdata)
|
|
|
break;
|
|
|
case ACTION_WAIT_EVENT: /* wait */
|
|
|
pr_debug("W");
|
|
|
- if (!wait_for_completion_timeout
|
|
|
- (&kim_gdata->kim_rcvd,
|
|
|
- msecs_to_jiffies(CMD_RESP_TIME))) {
|
|
|
+ if (!wait_for_completion_interruptible_timeout(
|
|
|
+ &kim_gdata->kim_rcvd,
|
|
|
+ msecs_to_jiffies(CMD_RESP_TIME))) {
|
|
|
pr_err("response timeout during fw download ");
|
|
|
/* timed out */
|
|
|
release_firmware(kim_gdata->fw_entry);
|
|
@@ -410,16 +430,10 @@ 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;
|
|
|
|
|
|
- /* copy to local buffer */
|
|
|
- if (unlikely(data[4] == 0x01 && data[5] == 0x10 && data[0] == 0x04)) {
|
|
|
- /* must be the read_ver_cmd */
|
|
|
- memcpy(kim_gdata->resp_buffer, data, count);
|
|
|
- complete_all(&kim_gdata->kim_rcvd);
|
|
|
- return;
|
|
|
- } else {
|
|
|
- kim_int_recv(kim_gdata, data, count);
|
|
|
- /* either completes or times out */
|
|
|
- }
|
|
|
+ /* 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;
|
|
|
}
|
|
|
|
|
@@ -454,11 +468,6 @@ long st_kim_start(void *kim_data)
|
|
|
if (pdata->chip_enable)
|
|
|
pdata->chip_enable(kim_gdata);
|
|
|
|
|
|
- /* Configure BT nShutdown to HIGH state */
|
|
|
- gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);
|
|
|
- mdelay(5); /* FIXME: a proper toggle */
|
|
|
- gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH);
|
|
|
- mdelay(100);
|
|
|
/* re-initialize the completion */
|
|
|
INIT_COMPLETION(kim_gdata->ldisc_installed);
|
|
|
/* send notification to UIM */
|
|
@@ -467,8 +476,8 @@ long st_kim_start(void *kim_data)
|
|
|
sysfs_notify(&kim_gdata->kim_pdev->dev.kobj,
|
|
|
NULL, "install");
|
|
|
/* wait for ldisc to be installed */
|
|
|
- err = wait_for_completion_timeout(&kim_gdata->ldisc_installed,
|
|
|
- msecs_to_jiffies(LDISC_TIME));
|
|
|
+ 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 */
|
|
@@ -500,8 +509,7 @@ long st_kim_start(void *kim_data)
|
|
|
* (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.
|
|
|
+ * (c) invoke platform's chip disabling routine.
|
|
|
*/
|
|
|
long st_kim_stop(void *kim_data)
|
|
|
{
|
|
@@ -526,20 +534,13 @@ long st_kim_stop(void *kim_data)
|
|
|
sysfs_notify(&kim_gdata->kim_pdev->dev.kobj, NULL, "install");
|
|
|
|
|
|
/* wait for ldisc to be un-installed */
|
|
|
- err = wait_for_completion_timeout(&kim_gdata->ldisc_installed,
|
|
|
- msecs_to_jiffies(LDISC_TIME));
|
|
|
+ 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");
|
|
|
- return -ETIMEDOUT;
|
|
|
+ err = -ETIMEDOUT;
|
|
|
}
|
|
|
|
|
|
- /* By default configure BT nShutdown to LOW state */
|
|
|
- gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);
|
|
|
- mdelay(1);
|
|
|
- gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH);
|
|
|
- mdelay(1);
|
|
|
- gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);
|
|
|
-
|
|
|
/* platform specific disable */
|
|
|
if (pdata->chip_disable)
|
|
|
pdata->chip_disable(kim_gdata);
|
|
@@ -701,7 +702,7 @@ static const struct file_operations list_debugfs_fops = {
|
|
|
* board-*.c file
|
|
|
*/
|
|
|
|
|
|
-struct dentry *kim_debugfs_dir;
|
|
|
+static struct dentry *kim_debugfs_dir;
|
|
|
static int kim_probe(struct platform_device *pdev)
|
|
|
{
|
|
|
long status;
|
|
@@ -731,20 +732,6 @@ static int kim_probe(struct platform_device *pdev)
|
|
|
/* 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;
|
|
|
- status = gpio_request(kim_gdata->nshutdown, "kim");
|
|
|
- if (unlikely(status)) {
|
|
|
- pr_err(" gpio %ld request failed ", kim_gdata->nshutdown);
|
|
|
- return status;
|
|
|
- }
|
|
|
-
|
|
|
- /* Configure nShutdown GPIO as output=0 */
|
|
|
- status = gpio_direction_output(kim_gdata->nshutdown, 0);
|
|
|
- if (unlikely(status)) {
|
|
|
- pr_err(" unable to configure gpio %ld", kim_gdata->nshutdown);
|
|
|
- return status;
|
|
|
- }
|
|
|
/* get reference of pdev for request_firmware
|
|
|
*/
|
|
|
kim_gdata->kim_pdev = pdev;
|
|
@@ -780,18 +767,10 @@ static int kim_probe(struct platform_device *pdev)
|
|
|
|
|
|
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 = dev_get_drvdata(&pdev->dev);
|
|
|
|
|
|
- /* 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");
|
|
@@ -804,7 +783,7 @@ static int kim_remove(struct platform_device *pdev)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-int kim_suspend(struct platform_device *pdev, pm_message_t state)
|
|
|
+static int kim_suspend(struct platform_device *pdev, pm_message_t state)
|
|
|
{
|
|
|
struct ti_st_plat_data *pdata = pdev->dev.platform_data;
|
|
|
|
|
@@ -814,7 +793,7 @@ int kim_suspend(struct platform_device *pdev, pm_message_t state)
|
|
|
return -EOPNOTSUPP;
|
|
|
}
|
|
|
|
|
|
-int kim_resume(struct platform_device *pdev)
|
|
|
+static int kim_resume(struct platform_device *pdev)
|
|
|
{
|
|
|
struct ti_st_plat_data *pdata = pdev->dev.platform_data;
|
|
|
|