summaryrefstree
path: root/kernel/drivers/video/decon_display/decon_display_driver.h
blob: 357193aaa10a19860bd842983bea58a894d3e1f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/* drivers/video/decon_display/decon_display_driver.h
 *
 * Copyright (c) 2011 Samsung Electronics
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#ifndef __DECON_DISPLAY_DRIVER_HEADER__
#define __DECON_DISPLAY_DRIVER_HEADER__

#include <linux/kthread.h>
#include <linux/platform_device.h>

#define VIDEO_MODE      1
#define COMMAND_MODE    0

struct decon_lcd {
	u32	mode;
	u32	vfp;
	u32	vbp;
	u32	hfp;
	u32	hbp;

	u32	vsa;
	u32	hsa;

	u32	xres;
	u32	yres;

	u32	width;
	u32	height;

	u32	hs_clk;
	u32	esc_clk;

	u32	fps;

	u32	mic;
};

enum{
	DISP_STATUS_PM0 = 0,	/* initial status */
	DISP_STATUS_PM1,	/* platform started */
	DISP_STATUS_PM2,	/* platform suspended */
	DISP_STATUS_PM_MAX,
};

extern struct decon_lcd *decon_get_lcd_info(void);

struct display_driver;

#define MAX_GPIO	10

/* display_gpio - GPIOs resource for the display subsystem */
struct display_gpio {
	unsigned id[MAX_GPIO];
};

/* pm_ops - HW IP or DISPLAY Block-specific callbacks */
struct pm_ops {
	void (*clk_on)(struct display_driver *dispdrv);
	void (*clk_off)(struct display_driver *dispdrv);
	int (*pwr_on)(struct display_driver *dispdrv);
	int (*pwr_off)(struct display_driver *dispdrv);
};

/* display_controller_ops - operations for controlling power of
 * dispay controller. */
struct display_controller_ops {
	int (*init_display_decon_clocks)(struct device *dev);
	int (*enable_display_decon_clocks)(struct device *dev);
	int (*disable_display_decon_clocks)(struct device *dev);
	int (*enable_display_decon_runtimepm)(struct device *dev);
	int (*disable_display_decon_runtimepm)(struct device *dev);
	int (*enable_display_dsd_clocks)(struct device *dev);
	int (*disable_display_dsd_clocks)(struct device *dev);
};

/* display_driverr_ops - operations for controlling power of
 * device */
struct display_driver_ops {
	int (*init_display_dsi_clocks)(struct device *dev);
	int (*enable_display_driver_power)(struct device *dev);
	int (*disable_display_driver_power)(struct device *dev);
	int (*reset_display_driver_panel)(struct device *dev);
};

/* display_dt_ops - operations for parsing device tree */
struct display_dt_ops {
	int (*parse_display_driver_dt)(struct platform_device *np,
		struct display_driver *ddp);
	struct s3c_fb_driverdata *(*get_display_drvdata)(void);
	struct s3c_fb_platdata *(*get_display_platdata)(void);
	struct mipi_dsim_config *(*get_display_dsi_drvdata)(void);
	struct mipi_dsim_lcd_config *(*get_display_lcd_drvdata)(void);
	struct display_gpio *(*get_display_dsi_reset_gpio)(void);
#ifdef CONFIG_DECON_MIC
	struct mic_config *(*get_display_mic_config)(void);
#endif
};

/* display_component_decon - This structure is abstraction of the
 * display controller device drvier. */
struct display_component_decon {
	struct resource *regs;
	int irq_no;
	int fifo_irq_no;
	int i80_irq_no;
	struct s3c_fb *sfb;
	struct display_controller_ops decon_ops;
	struct clk *clk;
	struct clk *dsd_clk;
	struct pm_ops *ops;
};

/* display_component_dsi - This structure is abstraction of the
 * MIPI-DSI device drvier. */
struct display_component_dsi {
	struct resource *regs;
	int dsi_irq_no;
	struct display_driver_ops dsi_ops;
	struct mipi_dsim_device *dsim;
	struct clk *clk;
	struct pm_ops *ops;
};

struct display_component_mic {
	struct resource *regs;
	struct decon_mic *mic;
	struct clk *clk;
	struct pm_ops *ops;
};

/* display_pm_status - for representing the status of the display
 * PM component. In normal display, there are three main status.
 * one is the status getting set_win_config,
 * two is the status waiting fence from user,
 * the other is the status wating VSYNC. */
struct display_pm_status {
	spinlock_t slock;
	struct mutex pm_lock;
	struct mutex clk_lock;
	int clock_enabled;
	atomic_t lock_count;
	struct kthread_worker	control_clock_gating;
	struct task_struct	*control_clock_gating_thread;
	struct kthread_work	control_clock_gating_work;
	struct kthread_worker	control_power_gating;
	struct task_struct	*control_power_gating_thread;
	struct kthread_work	control_power_gating_work;
	const struct pm_ops *ops;
	bool clock_gating_on;
	bool power_gating_on;
	bool hotplug_gating_on;
	int clk_idle_count;
	int pwr_idle_count;
	int hotplug_delay_msec;
};

#define MAX_CLK_GATING_COUNT 0
#define MAX_PWR_GATING_COUNT 3
#define MAX_HOTPLUG_DELAY_MSEC 100

/* display_driver - Abstraction for display driver controlling
 * all display system in the system */
struct display_driver {
	/* platform driver for display system */
	struct device *display_driver;
	struct display_component_decon decon_driver;
	struct display_component_dsi dsi_driver;
	struct display_component_mic mic_driver;
	struct display_dt_ops dt_ops;
	unsigned int platform_status;
	struct display_pm_status pm_status;
};

#define GET_DISPDRV_OPS(p) (p)->dsi_driver.dsi_ops
#define GET_DISPCTL_OPS(p) (p)->decon_driver.decon_ops

struct platform_device;

struct display_driver *get_display_driver(void);
int create_decon_display_controller(struct platform_device *pdev);
int create_mipi_dsi_controller(struct platform_device *pdev);
#ifdef CONFIG_DECON_MIC
int create_decon_mic(struct platform_device *pdev);
#endif

#endif