xref: /linux/include/linux/platform_data/lenovo-yoga-c630.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) 2022-2024, Linaro Ltd
4  * Authors:
5  *    Bjorn Andersson
6  *    Dmitry Baryshkov
7  */
8 
9 #ifndef _LENOVO_YOGA_C630_DATA_H
10 #define _LENOVO_YOGA_C630_DATA_H
11 
12 struct yoga_c630_ec;
13 struct notifier_block;
14 
15 #define YOGA_C630_MOD_NAME	"lenovo_yoga_c630"
16 
17 #define YOGA_C630_DEV_UCSI	"ucsi"
18 #define YOGA_C630_DEV_PSY	"psy"
19 
20 int yoga_c630_ec_read8(struct yoga_c630_ec *ec, u8 addr);
21 int yoga_c630_ec_read16(struct yoga_c630_ec *ec, u8 addr);
22 
23 int yoga_c630_ec_register_notify(struct yoga_c630_ec *ec, struct notifier_block *nb);
24 void yoga_c630_ec_unregister_notify(struct yoga_c630_ec *ec, struct notifier_block *nb);
25 
26 #define YOGA_C630_UCSI_WRITE_SIZE	8
27 #define YOGA_C630_UCSI_CCI_SIZE		4
28 #define YOGA_C630_UCSI_DATA_SIZE	16
29 #define YOGA_C630_UCSI_READ_SIZE	(YOGA_C630_UCSI_CCI_SIZE + YOGA_C630_UCSI_DATA_SIZE)
30 
31 u16 yoga_c630_ec_ucsi_get_version(struct yoga_c630_ec *ec);
32 int yoga_c630_ec_ucsi_write(struct yoga_c630_ec *ec,
33 			    const u8 req[YOGA_C630_UCSI_WRITE_SIZE]);
34 int yoga_c630_ec_ucsi_read(struct yoga_c630_ec *ec,
35 			   u8 resp[YOGA_C630_UCSI_READ_SIZE]);
36 
37 #define LENOVO_EC_EVENT_USB		0x20
38 #define LENOVO_EC_EVENT_UCSI		0x21
39 #define LENOVO_EC_EVENT_HPD		0x22
40 #define LENOVO_EC_EVENT_BAT_STATUS	0x24
41 #define LENOVO_EC_EVENT_BAT_INFO	0x25
42 #define LENOVO_EC_EVENT_BAT_ADPT_STATUS	0x37
43 
44 #endif
45