- 根目录:
- drivers
- misc
- ti-st
- st_ll.c
#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>
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__);
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);
st_data->ll_state = ST_LL_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;
switch (st_data->ll_state) {
case ST_LL_ASLEEP:
send_ll_cmd(st_data, LL_WAKE_UP_ACK);
break;
case ST_LL_ASLEEP_TO_AWAKE:
pr_err("duplicate wake_ind while waiting for Wake ack");
break;
case ST_LL_AWAKE:
pr_err("duplicate wake_ind already AWAKE");
break;
case ST_LL_AWAKE_TO_ASLEEP:
pr_err("duplicate wake_ind");
break;
}
st_data->ll_state = ST_LL_AWAKE;
kim_data = st_data->kim_data;
pdata = kim_data->kim_pdev->dev.platform_data;
if (pdata->chip_asleep)
pdata->chip_awake(NULL);
}
void st_ll_enable(struct st_data_s *ll)
{
ll->ll_state = ST_LL_AWAKE;
}
void st_ll_disable(struct st_data_s *ll)
{
ll->ll_state = ST_LL_INVALID;
}
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);
ll->ll_state = ST_LL_ASLEEP_TO_AWAKE;
} else {
pr_err(" Chip already AWAKE ");
}
}
unsigned long st_ll_getstate(struct st_data_s *ll)
{
pr_debug(" returning state %ld", ll->ll_state);
return ll->ll_state;
}
unsigned long st_ll_sleep_state(struct st_data_s *st_data,
unsigned char cmd)
{
switch (cmd) {
case LL_SLEEP_IND:
pr_debug("sleep indication recvd");
ll_device_want_to_sleep(st_data);
break;
case LL_SLEEP_ACK:
pr_err("sleep ack rcvd: host shouldn't");
break;
case LL_WAKE_UP_IND:
pr_debug("wake indication recvd");
ll_device_want_to_wakeup(st_data);
break;
case LL_WAKE_UP_ACK:
pr_debug("wake ack rcvd");
st_data->ll_state = ST_LL_AWAKE;
break;
default:
pr_err(" unknown input/state ");
return -EINVAL;
}
return 0;
}
long st_ll_init(struct st_data_s *ll)
{
ll->ll_state = ST_LL_INVALID;
return 0;
}
long st_ll_deinit(struct st_data_s *ll)
{
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169