xref: /openbmc/linux/drivers/gpu/drm/solomon/ssd130x.h (revision 08b7cf13)
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 struct ssd130x_deviceinfo {
22 	u32 default_vcomh;
23 	u32 default_dclk_div;
24 	u32 default_dclk_frq;
25 	int need_pwm;
26 	int need_chargepump;
27 };
28 
29 struct ssd130x_device {
30 	struct drm_device drm;
31 	struct device *dev;
32 	struct drm_simple_display_pipe pipe;
33 	struct drm_display_mode mode;
34 	struct drm_connector connector;
35 	struct i2c_client *client;
36 
37 	struct regmap *regmap;
38 
39 	const struct ssd130x_deviceinfo *device_info;
40 
41 	unsigned area_color_enable : 1;
42 	unsigned com_invdir : 1;
43 	unsigned com_lrremap : 1;
44 	unsigned com_seq : 1;
45 	unsigned lookup_table_set : 1;
46 	unsigned low_power : 1;
47 	unsigned seg_remap : 1;
48 	u32 com_offset;
49 	u32 contrast;
50 	u32 dclk_div;
51 	u32 dclk_frq;
52 	u32 height;
53 	u8 lookup_table[4];
54 	u32 page_offset;
55 	u32 col_offset;
56 	u32 prechargep1;
57 	u32 prechargep2;
58 
59 	struct backlight_device *bl_dev;
60 	struct pwm_device *pwm;
61 	struct gpio_desc *reset;
62 	struct regulator *vcc_reg;
63 	u32 vcomh;
64 	u32 width;
65 	/* Cached address ranges */
66 	u8 col_start;
67 	u8 col_end;
68 	u8 page_start;
69 	u8 page_end;
70 };
71 
72 struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap);
73 int ssd130x_remove(struct ssd130x_device *ssd130x);
74 void ssd130x_shutdown(struct ssd130x_device *ssd130x);
75 
76 #endif /* __SSD1307X_H__ */
77