blob: 215e7ec4dea237b3c6452efe2f3b957fb99507ab [file] [log] [blame]
Andres Salomoneecb3e42010-09-24 19:13:42 -07001#ifndef OLPC_DCON_H_
2#define OLPC_DCON_H_
3
Andres Salomonbbe963f2011-02-10 17:54:24 -08004#include <linux/notifier.h>
5#include <linux/workqueue.h>
6
Andres Salomoneecb3e42010-09-24 19:13:42 -07007/* DCON registers */
8
9#define DCON_REG_ID 0
10#define DCON_REG_MODE 1
11
12#define MODE_PASSTHRU (1<<0)
13#define MODE_SLEEP (1<<1)
14#define MODE_SLEEP_AUTO (1<<2)
15#define MODE_BL_ENABLE (1<<3)
16#define MODE_BLANK (1<<4)
17#define MODE_CSWIZZLE (1<<5)
18#define MODE_COL_AA (1<<6)
19#define MODE_MONO_LUMA (1<<7)
20#define MODE_SCAN_INT (1<<8)
21#define MODE_CLOCKDIV (1<<9)
22#define MODE_DEBUG (1<<14)
23#define MODE_SELFTEST (1<<15)
24
Jens Frederich98d4f932013-08-15 21:34:55 +020025#define DCON_REG_HRES 0x2
26#define DCON_REG_HTOTAL 0x3
27#define DCON_REG_HSYNC_WIDTH 0x4
28#define DCON_REG_VRES 0x5
29#define DCON_REG_VTOTAL 0x6
30#define DCON_REG_VSYNC_WIDTH 0x7
31#define DCON_REG_TIMEOUT 0x8
32#define DCON_REG_SCAN_INT 0x9
Jens Frederich9467d112013-08-17 16:20:54 +020033#define DCON_REG_BRIGHT 0xa
Jens Frederich98d4f932013-08-15 21:34:55 +020034#define DCON_REG_MEM_OPT_A 0x41
35#define DCON_REG_MEM_OPT_B 0x42
36
37/* Load Delay Locked Loop (DLL) settings for clock delay */
38#define MEM_DLL_CLOCK_DELAY (1<<0)
39/* Memory controller power down function */
Gary Servin55567342014-01-26 13:00:18 -030040#define MEM_POWER_DOWN (1<<8)
Jens Frederich98d4f932013-08-15 21:34:55 +020041/* Memory controller software reset */
42#define MEM_SOFT_RESET (1<<0)
Andres Salomoneecb3e42010-09-24 19:13:42 -070043
Andres Salomoneecb3e42010-09-24 19:13:42 -070044/* Status values */
45
46#define DCONSTAT_SCANINT 0
47#define DCONSTAT_SCANINT_DCON 1
48#define DCONSTAT_DISPLAYLOAD 2
49#define DCONSTAT_MISSED 3
50
51/* Source values */
52
53#define DCON_SOURCE_DCON 0
54#define DCON_SOURCE_CPU 1
55
Andres Salomoneecb3e42010-09-24 19:13:42 -070056/* Interrupt */
57#define DCON_IRQ 6
58
Andres Salomonbbe963f2011-02-10 17:54:24 -080059struct dcon_priv {
60 struct i2c_client *client;
61 struct fb_info *fbinfo;
Andres Salomonc59eef12011-02-10 17:56:27 -080062 struct backlight_device *bl_dev;
Andres Salomonbbe963f2011-02-10 17:54:24 -080063
Andres Salomonc40f20d2012-10-01 14:45:50 -070064 wait_queue_head_t waitq;
Andres Salomonbbe963f2011-02-10 17:54:24 -080065 struct work_struct switch_source;
66 struct notifier_block reboot_nb;
Andres Salomonbbe963f2011-02-10 17:54:24 -080067
68 /* Shadow register for the DCON_REG_MODE register */
69 u8 disp_mode;
70
Andres Salomonc59eef12011-02-10 17:56:27 -080071 /* The current backlight value - this saves us some smbus traffic */
72 u8 bl_val;
73
Andres Salomonbbe963f2011-02-10 17:54:24 -080074 /* Current source, initialized at probe time */
75 int curr_src;
76
77 /* Desired source */
78 int pending_src;
79
Andres Salomon309ef2a22011-02-10 17:54:58 -080080 /* Variables used during switches */
81 bool switched;
Ksenija Stanojevic851f7c02015-10-02 19:24:05 +020082 ktime_t irq_time;
83 ktime_t load_time;
Andres Salomon309ef2a22011-02-10 17:54:58 -080084
Andres Salomonbbe963f2011-02-10 17:54:24 -080085 /* Current output type; true == mono, false == color */
86 bool mono;
87 bool asleep;
88 /* This get set while controlling fb blank state from the driver */
89 bool ignore_fb_events;
90};
91
Andres Salomon097cd832011-02-10 17:53:24 -080092struct dcon_platform_data {
Andres Salomonbbe963f2011-02-10 17:54:24 -080093 int (*init)(struct dcon_priv *);
Andres Salomon097cd832011-02-10 17:53:24 -080094 void (*bus_stabilize_wiggle)(void);
95 void (*set_dconload)(int);
Xi Wang91762052011-12-02 16:28:43 -050096 int (*read_status)(u8 *);
Andres Salomon097cd832011-02-10 17:53:24 -080097};
98
99#include <linux/interrupt.h>
100
Joe Perchese4fde762015-08-10 14:51:27 -0700101irqreturn_t dcon_interrupt(int irq, void *id);
Andres Salomon097cd832011-02-10 17:53:24 -0800102
103#ifdef CONFIG_FB_OLPC_DCON_1
104extern struct dcon_platform_data dcon_pdata_xo_1;
105#endif
106
107#ifdef CONFIG_FB_OLPC_DCON_1_5
108extern struct dcon_platform_data dcon_pdata_xo_1_5;
109#endif
110
Andres Salomoneecb3e42010-09-24 19:13:42 -0700111#endif