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