aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/platform_data
diff options
context:
space:
mode:
authorNick Crews <ncrews@chromium.org>2019-04-24 12:56:50 -0400
committerEnric Balletbo i Serra <enric.balletbo@collabora.com>2019-05-20 04:18:09 -0400
commit0c0b7ea23aed0b55ef2f9803f13ddaae1943713d (patch)
tree1175fef70919712da89d30c88d92a781cb4c506a /include/linux/platform_data
parenta188339ca5a396acc588e5851ed7e19f66b0ebd9 (diff)
platform/chrome: wilco_ec: Add property helper library
A Property is typically a data item that is stored to NVRAM by the EC. Each of these data items has an index associated with it, known as the Property ID (PID). Properties may have variable lengths, up to a max of WILCO_EC_PROPERTY_MAX_SIZE bytes. Properties can be simple integers, or they may be more complex binary data. This patch adds support for getting and setting properties. This will be useful for setting the charge algorithm and charge schedules, which all use properties. Signed-off-by: Nick Crews <ncrews@chromium.org> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Diffstat (limited to 'include/linux/platform_data')
-rw-r--r--include/linux/platform_data/wilco-ec.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/include/linux/platform_data/wilco-ec.h b/include/linux/platform_data/wilco-ec.h
index 1ff224793c99..50a21bd5fd44 100644
--- a/include/linux/platform_data/wilco-ec.h
+++ b/include/linux/platform_data/wilco-ec.h
@@ -123,4 +123,75 @@ struct wilco_ec_message {
123 */ 123 */
124int wilco_ec_mailbox(struct wilco_ec_device *ec, struct wilco_ec_message *msg); 124int wilco_ec_mailbox(struct wilco_ec_device *ec, struct wilco_ec_message *msg);
125 125
126/*
127 * A Property is typically a data item that is stored to NVRAM
128 * by the EC. Each of these data items has an index associated
129 * with it, known as the Property ID (PID). Properties may have
130 * variable lengths, up to a max of WILCO_EC_PROPERTY_MAX_SIZE
131 * bytes. Properties can be simple integers, or they may be more
132 * complex binary data.
133 */
134
135#define WILCO_EC_PROPERTY_MAX_SIZE 4
136
137/**
138 * struct ec_property_set_msg - Message to get or set a property.
139 * @property_id: Which property to get or set.
140 * @length: Number of bytes of |data| that are used.
141 * @data: Actual property data.
142 */
143struct wilco_ec_property_msg {
144 u32 property_id;
145 int length;
146 u8 data[WILCO_EC_PROPERTY_MAX_SIZE];
147};
148
149/**
150 * wilco_ec_get_property() - Retrieve a property from the EC.
151 * @ec: Embedded Controller device.
152 * @prop_msg: Message for request and response.
153 *
154 * The property_id field of |prop_msg| should be filled before calling this
155 * function. The result will be stored in the data and length fields.
156 *
157 * Return: 0 on success, negative error code on failure.
158 */
159int wilco_ec_get_property(struct wilco_ec_device *ec,
160 struct wilco_ec_property_msg *prop_msg);
161
162/**
163 * wilco_ec_set_property() - Store a property on the EC.
164 * @ec: Embedded Controller device.
165 * @prop_msg: Message for request and response.
166 *
167 * The property_id, length, and data fields of |prop_msg| should be
168 * filled before calling this function.
169 *
170 * Return: 0 on success, negative error code on failure.
171 */
172int wilco_ec_set_property(struct wilco_ec_device *ec,
173 struct wilco_ec_property_msg *prop_msg);
174
175/**
176 * wilco_ec_get_byte_property() - Retrieve a byte-size property from the EC.
177 * @ec: Embedded Controller device.
178 * @property_id: Which property to retrieve.
179 * @val: The result value, will be filled by this function.
180 *
181 * Return: 0 on success, negative error code on failure.
182 */
183int wilco_ec_get_byte_property(struct wilco_ec_device *ec, u32 property_id,
184 u8 *val);
185
186/**
187 * wilco_ec_get_byte_property() - Store a byte-size property on the EC.
188 * @ec: Embedded Controller device.
189 * @property_id: Which property to store.
190 * @val: Value to store.
191 *
192 * Return: 0 on success, negative error code on failure.
193 */
194int wilco_ec_set_byte_property(struct wilco_ec_device *ec, u32 property_id,
195 u8 val);
196
126#endif /* WILCO_EC_H */ 197#endif /* WILCO_EC_H */