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