1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* drivers/media/platform/s5p-cec/s5p_cec.h
3  *
4  * Samsung S5P HDMI CEC driver
5  *
6  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7  */
8 
9 #ifndef _S5P_CEC_H_
10 #define _S5P_CEC_H_ __FILE__
11 
12 #include <linux/clk.h>
13 #include <linux/interrupt.h>
14 #include <linux/kernel.h>
15 #include <linux/mfd/syscon.h>
16 #include <linux/module.h>
17 #include <linux/of.h>
18 #include <linux/platform_device.h>
19 #include <linux/pm_runtime.h>
20 #include <linux/timer.h>
21 #include <linux/workqueue.h>
22 #include <media/cec.h>
23 
24 #include "exynos_hdmi_cec.h"
25 #include "regs-cec.h"
26 #include "s5p_cec.h"
27 
28 #define CEC_NAME	"s5p-cec"
29 
30 #define CEC_STATUS_TX_RUNNING		(1 << 0)
31 #define CEC_STATUS_TX_TRANSFERRING	(1 << 1)
32 #define CEC_STATUS_TX_DONE		(1 << 2)
33 #define CEC_STATUS_TX_ERROR		(1 << 3)
34 #define CEC_STATUS_TX_NACK		(1 << 4)
35 #define CEC_STATUS_TX_BYTES		(0xFF << 8)
36 #define CEC_STATUS_RX_RUNNING		(1 << 16)
37 #define CEC_STATUS_RX_RECEIVING		(1 << 17)
38 #define CEC_STATUS_RX_DONE		(1 << 18)
39 #define CEC_STATUS_RX_ERROR		(1 << 19)
40 #define CEC_STATUS_RX_BCAST		(1 << 20)
41 #define CEC_STATUS_RX_BYTES		(0xFF << 24)
42 
43 #define CEC_WORKER_TX_DONE		(1 << 0)
44 #define CEC_WORKER_RX_MSG		(1 << 1)
45 
46 /* CEC Rx buffer size */
47 #define CEC_RX_BUFF_SIZE		16
48 /* CEC Tx buffer size */
49 #define CEC_TX_BUFF_SIZE		16
50 
51 enum cec_state {
52 	STATE_IDLE,
53 	STATE_BUSY,
54 	STATE_DONE,
55 	STATE_NACK,
56 	STATE_ERROR
57 };
58 
59 struct cec_notifier;
60 
61 struct s5p_cec_dev {
62 	struct cec_adapter	*adap;
63 	struct clk		*clk;
64 	struct device		*dev;
65 	struct mutex		lock;
66 	struct regmap           *pmu;
67 	struct cec_notifier	*notifier;
68 	int			irq;
69 	void __iomem		*reg;
70 
71 	enum cec_state		rx;
72 	enum cec_state		tx;
73 	struct cec_msg		msg;
74 };
75 
76 #endif /* _S5P_CEC_H_ */
77