-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathimanager.h
226 lines (203 loc) · 6.73 KB
/
imanager.h
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/*
* Advantech iManager MFD
*
* Copyright (C) 2016-2017 Advantech Co., Ltd.
* Author: Richard Vidal-Dorsch <richard.dorsch@advantech.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#ifndef _LINUX_MFD_IMANAGER_H_
#define _LINUX_MFD_IMANAGER_H_
#include <linux/mutex.h>
#include "imanager-ec.h"
#define IMANAGER_PCB_NAME_LEN 9
#define IMANAGER_VERSION_LEN 40
/**
* IMANAGER_MSG - macro used to describe iManager message
* @read_len: iManager message read length
* @write_len: iManager message write length
* @parameter: iManager message parameter
* @command: iManager message command type
*
* This macro creates a struct imanager_ec_message which is used for basic EC
* communication
*/
#define IMANAGER_MSG(read_len, write_len, parameter, command) \
.rlen = (read_len), .wlen = (write_len), \
.param = (parameter), .cmd = (command), .data = (NULL)
/**
* struct imanager_ec_message - Describes iManager EC message
* @rlen: iManager message read length
* @wlen: iManager message write length
* @param: iManager message parameter (offset, id, or unit number)
* @cmd: iManager message command type
* @u: union holding struct imanager_ec_smb_message and data field
* @data: pointer to data field
*/
struct imanager_ec_message {
unsigned int rlen;
unsigned int wlen;
unsigned int param;
unsigned int cmd;
union {
struct imanager_ec_smb_message smb;
unsigned char data[EC_MSG_SIZE];
} u;
unsigned char *data;
};
/**
* struct imanager_device_attribute - Describes iManager Device attribute
* @did: iManager Device ID
* @hwp: iManager Hardware Pin number
* @pol: iManager Device Polarity
* @ecdev: pointer to iManager device table entry
*/
struct imanager_device_attribute {
unsigned int did;
unsigned int hwp;
unsigned int pol;
const struct imanager_ec_device *ecdev;
};
/**
* struct imanager_gpio_device - Describes iManager GPIO device
* @num: available GPIO pins
* @attr: pointer to array of iManager GPIO device attribute
*/
struct imanager_gpio_device {
unsigned int num;
struct imanager_device_attribute *attr[EC_MAX_GPIO_NUM];
};
/**
* struct imanager_adc_device - Describes iManager ADC device
* @num: available ADC devices
* @attr: pointer to array of iManager ADC device attribute
* @label pointer to ADC label
*/
struct imanager_adc_device {
unsigned int num;
struct imanager_device_attribute *attr[EC_MAX_ADC_NUM];
const char *label[EC_MAX_ADC_NUM];
};
/**
* struct imanager_fan_device - Describes iManager FAN device
* @num: available FAN devices
* @attr: pointer to array of iManager FAN device attribute
* @label pointer to FAN label
* @temp_label pointer to FAN temperature label
*/
struct imanager_fan_device {
unsigned int num;
struct imanager_device_attribute *attr[EC_MAX_FAN_NUM];
const char *label[EC_MAX_FAN_NUM];
const char *temp_label[EC_MAX_FAN_NUM];
};
/**
* struct imanager_hwmon_device - Describes iManager hwmon device
* @adc: iManager ADC device
* @fan: iManager FAN device
*/
struct imanager_hwmon_device {
struct imanager_adc_device adc;
struct imanager_fan_device fan;
};
/**
* struct imanager_i2c_device - Describes iManager I2C device
* @num: available I2C devices
* @attr: pointer to array of iManager GPIO device attribute
*/
struct imanager_i2c_device {
unsigned int num;
struct imanager_device_attribute *attr[EC_MAX_SMB_NUM];
};
/**
* struct imanager_backlight_device - Describes iManager backlight device
* @num: available backlight devices
* @attr: pointer to array of iManager backlight device attribute
* @brightnes: array of brightness devices
*/
struct imanager_backlight_device {
unsigned int num;
struct imanager_device_attribute *attr[EC_MAX_BLC_NUM];
unsigned char brightness[EC_MAX_BLC_NUM];
};
/**
* struct imanager_watchdog_device - Describes iManager watchdog device
* @num: available WD devices
* @attr: pointer to array of iManager watchdog device attribute
*/
struct imanager_watchdog_device {
unsigned int num;
struct imanager_device_attribute *attr[EC_MAX_BLC_NUM];
};
/**
* struct imanager_info - iManager device information structure
* @kernel_major: iManager EC kernel major revision
* @kernel_minor: iManager EC kernel minor revision
* @firmware_major: iManager EC firmware major revision
* @firmware_minor: iManager EC firmware minor revision
* @type: iManager type - release/debug/custom
* @version: iManager version string
*/
struct imanager_info {
unsigned int kernel_major;
unsigned int kernel_minor;
unsigned int firmware_major;
unsigned int firmware_minor;
const char *type;
char version[IMANAGER_VERSION_LEN];
};
/**
* struct imanager_ec_data - iManager EC data structure
* @features: iManager feature mask
* @chip_name: iManager chip name
* @attr: array of iManager device attribute structure
* @iop: imanager_io_ops structure providing I/O operations
* @gpio: iManager GPIO device structure
* @hwmon: iManager Hardware monitor device structure
* @i2c: iManager I2C/SMBus device structure
* @bl: iManager Backlight/Brightness device structure
* @wdt: iManager Watchdog device structure
* @info: iManager device information
*/
struct imanager_ec_data {
unsigned int features;
const char *chip_name;
struct imanager_device_attribute attr[EC_MAX_DID];
struct imanager_io_ops iop;
struct imanager_gpio_device gpio;
struct imanager_hwmon_device hwmon;
struct imanager_i2c_device i2c;
struct imanager_backlight_device bl;
struct imanager_watchdog_device wdt;
struct imanager_info info;
};
/**
* struct imanager_device_data - Internal representation of the iManager device
* @ec: iManager data structure describing the EC
* @dev: Pointer to kernel device structure
* @lock: iManager mutex
*/
struct imanager_device_data {
struct imanager_ec_data ec;
struct device *dev;
struct mutex lock; /* generic mutex for imanager core */
};
enum ec_mem_type { EC_RAM_ACPI = 1, EC_RAM_HW, EC_RAM_EXT };
int imanager_read(struct imanager_device_data *imgr,
struct imanager_ec_message *msg);
int imanager_write(struct imanager_device_data *imgr,
struct imanager_ec_message *msg);
int imanager_read8(struct imanager_device_data *imgr, u8 cmd, u8 param);
int imanager_write8(struct imanager_device_data *imgr, u8 cmd, u8 param,
u8 byte);
int imanager_read16(struct imanager_device_data *imgr, u8 cmd, u8 param);
int imanager_write16(struct imanager_device_data *imgr, u8 cmd, u8 param,
u16 word);
int imanager_mem_read(struct imanager_device_data *imgr, int mem_type,
int offset, u8 *data, int size);
int imanager_mem_write(struct imanager_device_data *imgr, int mem_type,
int offset, u8 *data, int size);
#endif