GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / ti-st / st_ll.c
blob7a1fb6de830ddeab60dd5379db5684cf5a31a784
1 /*
2 * Shared Transport driver
3 * HCI-LL module responsible for TI proprietary HCI_LL protocol
4 * Copyright (C) 2009 Texas Instruments
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define pr_fmt(fmt) "(stll) :" fmt
22 #include "st_ll.h"
24 /**********************************************************************/
25 /* internal functions */
26 static void send_ll_cmd(struct st_data_s *st_data,
27 unsigned char cmd)
30 pr_info("%s: writing %x", __func__, cmd);
31 st_int_write(st_data, &cmd, 1);
32 return;
35 static void ll_device_want_to_sleep(struct st_data_s *st_data)
37 pr_debug("%s", __func__);
38 /* sanity check */
39 if (st_data->ll_state != ST_LL_AWAKE)
40 pr_err("ERR hcill: ST_LL_GO_TO_SLEEP_IND"
41 "in state %ld", st_data->ll_state);
43 send_ll_cmd(st_data, LL_SLEEP_ACK);
44 /* update state */
45 st_data->ll_state = ST_LL_ASLEEP;
48 static void ll_device_want_to_wakeup(struct st_data_s *st_data)
50 /* diff actions in diff states */
51 switch (st_data->ll_state) {
52 case ST_LL_ASLEEP:
53 send_ll_cmd(st_data, LL_WAKE_UP_ACK); /* send wake_ack */
54 break;
55 case ST_LL_ASLEEP_TO_AWAKE:
56 /* duplicate wake_ind */
57 pr_err("duplicate wake_ind while waiting for Wake ack");
58 break;
59 case ST_LL_AWAKE:
60 /* duplicate wake_ind */
61 pr_err("duplicate wake_ind already AWAKE");
62 break;
63 case ST_LL_AWAKE_TO_ASLEEP:
64 /* duplicate wake_ind */
65 pr_err("duplicate wake_ind");
66 break;
68 /* update state */
69 st_data->ll_state = ST_LL_AWAKE;
72 /**********************************************************************/
73 /* functions invoked by ST Core */
75 /* called when ST Core wants to
76 * enable ST LL */
77 void st_ll_enable(struct st_data_s *ll)
79 ll->ll_state = ST_LL_AWAKE;
82 /* called when ST Core /local module wants to
83 * disable ST LL */
84 void st_ll_disable(struct st_data_s *ll)
86 ll->ll_state = ST_LL_INVALID;
89 /* called when ST Core wants to update the state */
90 void st_ll_wakeup(struct st_data_s *ll)
92 if (likely(ll->ll_state != ST_LL_AWAKE)) {
93 send_ll_cmd(ll, LL_WAKE_UP_IND); /* WAKE_IND */
94 ll->ll_state = ST_LL_ASLEEP_TO_AWAKE;
95 } else {
96 /* don't send the duplicate wake_indication */
97 pr_err(" Chip already AWAKE ");
101 /* called when ST Core wants the state */
102 unsigned long st_ll_getstate(struct st_data_s *ll)
104 pr_debug(" returning state %ld", ll->ll_state);
105 return ll->ll_state;
108 /* called from ST Core, when a PM related packet arrives */
109 unsigned long st_ll_sleep_state(struct st_data_s *st_data,
110 unsigned char cmd)
112 switch (cmd) {
113 case LL_SLEEP_IND: /* sleep ind */
114 pr_info("sleep indication recvd");
115 ll_device_want_to_sleep(st_data);
116 break;
117 case LL_SLEEP_ACK: /* sleep ack */
118 pr_err("sleep ack rcvd: host shouldn't");
119 break;
120 case LL_WAKE_UP_IND: /* wake ind */
121 pr_info("wake indication recvd");
122 ll_device_want_to_wakeup(st_data);
123 break;
124 case LL_WAKE_UP_ACK: /* wake ack */
125 pr_info("wake ack rcvd");
126 st_data->ll_state = ST_LL_AWAKE;
127 break;
128 default:
129 pr_err(" unknown input/state ");
130 return -1;
132 return 0;
135 /* Called from ST CORE to initialize ST LL */
136 long st_ll_init(struct st_data_s *ll)
138 /* set state to invalid */
139 ll->ll_state = ST_LL_INVALID;
140 return 0;
143 /* Called from ST CORE to de-initialize ST LL */
144 long st_ll_deinit(struct st_data_s *ll)
146 return 0;