|
From: Alain P. <apa...@us...> - 2002-05-15 13:29:44
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
hci.c 1.200 1.201=20=20=20=20=20=20=20=20=20=20=20=20=20
hci_vendor.c 1.64 1.65=20=20=20=20=20=20=20=20=20=20=20=20=20=20
unplug_test.c 1.11 1.12=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Implement the deep_sleep mode for Texas Instruments chip.
Allow to go in deep sleep and to exit from deep sleep. For the
moment only from unplug.
The diff of the modified file(s):
--- hci.c 25 Apr 2002 15:08:49 -0000 1.200
+++ hci.c 15 May 2002 13:29:41 -0000 1.201
@@ -364,6 +364,7 @@
u8 *buf; /* Temporary pointer to the incoming data */
u32 tmp_data_len;
=20=20
+=20
PRINTPKT(__FUNCTION__ ": ", data, count);
=20=20=20
tmp_data_len =3D count;
@@ -387,6 +388,16 @@
case ACL_PKT: state =3D WAIT_FOR_ACL_HDR; break;
case SCO_PKT: state =3D WAIT_FOR_SCO_HDR; break;
default:
+=09=09=09=20=20
+ /* Call vendor specific function if needed */
+#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS=09=09=09=20=20
+ if (hci_receive_data_texas_specific(buf, count) =3D=3D 0) {
+ /* Data has been processed by the function. Normaly, it's one byte.=
*/
+ /* What to do if we received more that one byte ? */
+ return;
+ }
+#endif
+=09=09=09
D_ERR(__FUNCTION__ ": discarding %d bytes\n",
count);
/* An unrecognized HCI header type is usually a
--- hci_vendor.c 10 May 2002 12:27:51 -0000 1.64
+++ hci_vendor.c 15 May 2002 13:29:41 -0000 1.65
@@ -89,14 +89,28 @@
#endif
=20
#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS
-/* Texas instrument defines */
-#define TEXAS_SET_SLEEP_MODE 0x0C
+/* Texas instruments defines */
+#define TEXAS_SET_SLEEP_MODE 0x30c
+
+/* Texas instruments specific short UART messages protocol */
+#define TEXAS_MESSAGE_DEEP_SLEEP_REQUEST 0x30
+#define TEXAS_MESSAGE_DEEP_SLEEP_ACKNOWLEDGE 0x31
+#define TEXAS_MESSAGE_WAKE_UP_REQUEST 0x32
+#define TEXAS_MESSAGE_WAKE_UP_ACKNOWLEDGE 0x33
+
+/* Texas machine state */
+enum texas_states { TI_NORMAL_STATE, TI_WAIT_FOR_DEEP_SLEEP, TI_DEEP_SLEEP=
, TI_WAIT_FOR_WAKE_UP};
#endif
=20
#define BT_HW_INFO_MAX 255
=20
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
=20
+#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS
+/* The states for specific TI modes */
+static enum texas_states texas_state =3D TI_NORMAL_STATE;
+#endif
+
/* These are declared in hci.c */
extern cmd_pkt c_pkt;
=20
@@ -1441,7 +1455,7 @@
#elif defined(CONFIG_BLUETOOTH_TEXASINSTRUMENTS)
=20
/*************************************************************************=
****/
-/************** Functions for Texas Instrument Bluetooth chips ***********=
****/
+/************** Functions for Texas Instruments Bluetooth chips **********=
****/
/*************************************************************************=
****/
=20
#define VENDOR " [Texas Instruments]"
@@ -1476,7 +1490,30 @@
void
process_vendor_return_param(u32 ocf, u8* r_val)
{
- D_ERR(__FUNCTION__ VENDOR " Texas specific: Invalid reply (0x%x)\n", ocf);
+ switch (ocf) {
+=09
+ case TEXAS_SET_SLEEP_MODE:
+ if (r_val[0] !=3D 0) {
+ D_ERR(__FUNCTION__ VENDOR ": Set sleep mode failure\n");
+ }
+ else {
+ D_CMD(__FUNCTION__ VENDOR ": Set sleep mode : success\n");
+ }
+ break;
+ case 0x0C:
+ D_ERR(__FUNCTION__ VENDOR ": HCI_ERR_COMMAND_DISALLOWED\n");
+ release_cmd_timer();
+ wake_up_interruptible(&hci_wq);
+ break;
+
+ default:
+ release_cmd_timer();
+ D_ERR(__FUNCTION__ VENDOR " Manufacturer specific: Invalid reply (0x%x)\=
n",
+ ocf);
+ wake_up_interruptible(&hci_wq);
+ break;
+ } /* end of switch */
+
}
=20
char*
@@ -1484,6 +1521,111 @@
{
return "Texas Instruments";
}
+
+s32
+hci_set_sleep_mode(int big_sleep, int deep_sleep)
+{
+ u8 settings[2];
+=20=20
+ D_CMD(__FUNCTION__ VENDOR "\n");
+=09
+ /* Verify that big_sleep and deep_sleep are 1 or 0 */
+ if ((big_sleep > 1) || (big_sleep < 0) || (deep_sleep > 1) || (deep_sleep=
< 0)) {
+ D_ERR(__FUNCTION__ VENDOR ": Deep sleep and/or big sleep out of range\n"=
);
+ return -1;
+ }
+=09=09=09
+ /* Verify that we don't want deep_sleep */
+ if (! deep_sleep) {
+ if ((texas_state =3D=3D TI_WAIT_FOR_DEEP_SLEEP) || (texas_state =3D=3D T=
I_DEEP_SLEEP))
+ {
+ /* We should wake-up */
+ u8 command;
+
+ command =3D TEXAS_MESSAGE_WAKE_UP_REQUEST;
+ texas_state =3D TI_WAIT_FOR_WAKE_UP;
+ return hci_send_raw_data(&command, 1);
+ }
+ }
+=09
+ settings[0] =3D big_sleep;
+ settings[1] =3D deep_sleep;
+=20=20
+ PRINTPKT(__FUNCTION__ VENDOR ":", settings, 2);
+ c_pkt.type =3D CMD_PKT;
+ c_pkt.opcode =3D hci_put_opcode(TEXAS_SET_SLEEP_MODE, MANUFACTURER_SPEC);
+ c_pkt.len =3D 2;
+ memcpy(c_pkt.data, settings, 2);
+=09
+ /* Set texas state machine */
+ if (deep_sleep)
+ texas_state =3D TI_WAIT_FOR_DEEP_SLEEP;
+=09
+ /* TO DO : if we ask for deep sleep when in connection, module is set do =
big sleep. */
+ /* So we shouldn't get into TI_WAIT_FOR_DEEP_SLEEP state */
+=09
+ return send_cmd((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN);
+}
+
+
+/**** hci_receive_data_texas_specific ************************************=
**/
+/* =
*/
+/* this function process the UART short message protocol specific to =
*/
+/* Texas Instruments =
*/
+/* =
*/
+/* Return 0 if data has been correctly interpreted =
*/
+/* Return -1 if not =
*/
+/*************************************************************************=
**/
+
+int
+hci_receive_data_texas_specific(u8* buf, u32 count)
+{
+
+
+/* Just verify that we are waiting for a request */
+ if (texas_state =3D=3D TI_NORMAL_STATE) {
+ return -1; /* We don't wait for anything */
+ }
+
+ switch(*buf) {
+=20=20=20=20
+ case TEXAS_MESSAGE_DEEP_SLEEP_REQUEST: /* Deep sleep request */
+ {
+ u8 acknowledge;
+ D_CMD(__FUNCTION__ ": Deep sleep request\n");
+ if (texas_state !=3D TI_WAIT_FOR_DEEP_SLEEP) {
+ D_ERR(__FUNCTION__ VENDOR ": Receive deep sleep request, but we are no=
t waiting for deep sleep\n");=20
+ return -1;
+ }
+=09=09=09
+ acknowledge =3D TEXAS_MESSAGE_DEEP_SLEEP_ACKNOWLEDGE;
+ hci_send_raw_data(&acknowledge, 1);
+ texas_state =3D TI_DEEP_SLEEP;
+ return 0;
+ }
+ break;
+ case TEXAS_MESSAGE_WAKE_UP_ACKNOWLEDGE: /* Wake-up acnknowledge */
+ {
+=09=09=09
+ if (texas_state !=3D TI_WAIT_FOR_WAKE_UP) {
+ D_ERR(__FUNCTION__ VENDOR ": Receive Wake-up request, but hardware was=
not in deep_sleep\n");=20
+ return -1;
+ }
+ /* Change state before to call hci_set_sleep_mode */
+ texas_state =3D TI_NORMAL_STATE;
+ /* The module is now waked up. Don't allow it to go back to sleep mode =
*/
+ hci_set_sleep_mode(0, 0);
+ return 0;
+ }
+ break;
+ default:
+ /* Another unknown data : let deal the stack with */
+ return -1;
+
+ }
+}
+
+
=20
#else
/*************************************************************************=
****/
--- unplug_test.c 11 Apr 2002 11:53:22 -0000 1.11
+++ unplug_test.c 15 May 2002 13:29:42 -0000 1.12
@@ -2415,6 +2415,24 @@
return rfcomm_send_data(CREATE_RFCOMM_ID(0,2), atd, strlen(atd));
}
=20
+#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS
+
+static s32 test_ti_deep_sleep(void)
+{
+ printk("test_ti_deep_sleep\n");
+ hci_set_sleep_mode(1, 1);
+ return 0;
+}
+
+static s32 test_ti_exit_deep_sleep(void)
+{
+ printk("test_ti_exit_deep_sleep\n");
+ hci_set_sleep_mode(0, 0);
+ return 0;
+}
+
+#endif
+
s32 process_test_cmd(s32 test_case)
{
if (!test_is_initialized) {
@@ -2554,6 +2572,10 @@
case 56: return test_5_6();
case 57: return test_5_7();
case 100: return test_gateway_call();
+#ifdef CONFIG_BLUETOOTH_TEXASINSTRUMENTS
+ case 7000: return test_ti_deep_sleep();
+ case 7001: return test_ti_exit_deep_sleep();
+#endif
case 9001: return sdp_send_data(&sdp_con_list[0], pan_1, pan_1[4] =
+ 5);
case 9002: return sdp_send_data(&sdp_con_list[0], pan_2, pan_2[4] + 5);=
=20=20
=20=20=20=20=20=20=20=20=20
|