GNU Linux-libre 4.9.315-gnu1
[releases.git] / drivers / staging / media / s5p-cec / s5p_cec.h
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/version.h>
26 #include <linux/workqueue.h>
27 #include <media/cec.h>
28
29 #include "exynos_hdmi_cec.h"
30 #include "regs-cec.h"
31 #include "s5p_cec.h"
32
33 #define CEC_NAME        "s5p-cec"
34
35 #define CEC_STATUS_TX_RUNNING           (1 << 0)
36 #define CEC_STATUS_TX_TRANSFERRING      (1 << 1)
37 #define CEC_STATUS_TX_DONE              (1 << 2)
38 #define CEC_STATUS_TX_ERROR             (1 << 3)
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_ERROR
60 };
61
62 struct s5p_cec_dev {
63         struct cec_adapter      *adap;
64         struct clk              *clk;
65         struct device           *dev;
66         struct mutex            lock;
67         struct regmap           *pmu;
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_ */