xref: /openbmc/linux/drivers/gpu/drm/solomon/ssd130x.h (revision 465191d6)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Header file for:
4  * DRM driver for Solomon SSD130x OLED displays
5  *
6  * Copyright 2022 Red Hat Inc.
7  * Author: Javier Martinez Canillas <javierm@redhat.com>
8  *
9  * Based on drivers/video/fbdev/ssd1307fb.c
10  * Copyright 2012 Free Electrons
11  */
12 
13 #ifndef __SSD1307X_H__
14 #define __SSD1307X_H__
15 
16 #include <drm/drm_drv.h>
17 #include <drm/drm_simple_kms_helper.h>
18 
19 #include <linux/regmap.h>
20 
21 #define SSD130X_DATA				0x40
22 #define SSD130X_COMMAND				0x80
23 
24 enum ssd130x_variants {
25 	SH1106_ID,
26 	SSD1305_ID,
27 	SSD1306_ID,
28 	SSD1307_ID,
29 	SSD1309_ID,
30 	NR_SSD130X_VARIANTS
31 };
32 
33 struct ssd130x_deviceinfo {
34 	u32 default_vcomh;
35 	u32 default_dclk_div;
36 	u32 default_dclk_frq;
37 	int need_pwm;
38 	int need_chargepump;
39 	bool page_mode_only;
40 };
41 
42 struct ssd130x_device {
43 	struct drm_device drm;
44 	struct device *dev;
45 	struct drm_simple_display_pipe pipe;
46 	struct drm_display_mode mode;
47 	struct drm_connector connector;
48 	struct i2c_client *client;
49 
50 	struct regmap *regmap;
51 
52 	const struct ssd130x_deviceinfo *device_info;
53 
54 	unsigned page_address_mode : 1;
55 	unsigned area_color_enable : 1;
56 	unsigned com_invdir : 1;
57 	unsigned com_lrremap : 1;
58 	unsigned com_seq : 1;
59 	unsigned lookup_table_set : 1;
60 	unsigned low_power : 1;
61 	unsigned seg_remap : 1;
62 	u32 com_offset;
63 	u32 contrast;
64 	u32 dclk_div;
65 	u32 dclk_frq;
66 	u32 height;
67 	u8 lookup_table[4];
68 	u32 page_offset;
69 	u32 col_offset;
70 	u32 prechargep1;
71 	u32 prechargep2;
72 
73 	struct backlight_device *bl_dev;
74 	struct pwm_device *pwm;
75 	struct gpio_desc *reset;
76 	struct regulator *vcc_reg;
77 	u32 vcomh;
78 	u32 width;
79 	/* Cached address ranges */
80 	u8 col_start;
81 	u8 col_end;
82 	u8 page_start;
83 	u8 page_end;
84 };
85 
86 extern const struct ssd130x_deviceinfo ssd130x_variants[];
87 
88 struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap);
89 void ssd130x_remove(struct ssd130x_device *ssd130x);
90 void ssd130x_shutdown(struct ssd130x_device *ssd130x);
91 
92 #endif /* __SSD1307X_H__ */
93