| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | /* SPDX-License-Identifier: GPL-2.0-only */ | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Header file for: | 
					
						
							|  |  |  |  * DRM driver for Solomon SSD130x OLED displays | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright 2022 Red Hat Inc. | 
					
						
							|  |  |  |  * Author: Javier Martinez Canillas <javierm@redhat.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Based on drivers/video/fbdev/ssd1307fb.c | 
					
						
							|  |  |  |  * Copyright 2012 Free Electrons | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-12 14:02:31 +02:00
										 |  |  | #ifndef __SSD130X_H__
 | 
					
						
							|  |  |  | #define __SSD130X_H__
 | 
					
						
							| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-06 00:27:59 +02:00
										 |  |  | #include <drm/drm_connector.h>
 | 
					
						
							|  |  |  | #include <drm/drm_crtc.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | #include <drm/drm_drv.h>
 | 
					
						
							| 
									
										
										
										
											2022-09-06 00:27:59 +02:00
										 |  |  | #include <drm/drm_encoder.h>
 | 
					
						
							|  |  |  | #include <drm/drm_plane_helper.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <linux/regmap.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-14 09:15:05 +02:00
										 |  |  | #define SSD13XX_DATA				0x40
 | 
					
						
							|  |  |  | #define SSD13XX_COMMAND				0x80
 | 
					
						
							| 
									
										
										
										
											2022-04-19 23:48:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-14 09:15:04 +02:00
										 |  |  | enum ssd130x_family_ids { | 
					
						
							| 
									
										
										
										
											2023-10-14 09:15:06 +02:00
										 |  |  | 	SSD130X_FAMILY, | 
					
						
							|  |  |  | 	SSD132X_FAMILY | 
					
						
							| 
									
										
										
										
											2023-10-14 09:15:04 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-19 23:48:22 +02:00
										 |  |  | enum ssd130x_variants { | 
					
						
							| 
									
										
										
										
											2023-10-14 09:15:04 +02:00
										 |  |  | 	/* ssd130x family */ | 
					
						
							| 
									
										
										
										
											2022-04-19 23:48:22 +02:00
										 |  |  | 	SH1106_ID, | 
					
						
							|  |  |  | 	SSD1305_ID, | 
					
						
							|  |  |  | 	SSD1306_ID, | 
					
						
							|  |  |  | 	SSD1307_ID, | 
					
						
							|  |  |  | 	SSD1309_ID, | 
					
						
							| 
									
										
										
										
											2023-10-14 09:15:06 +02:00
										 |  |  | 	/* ssd132x family */ | 
					
						
							|  |  |  | 	SSD1322_ID, | 
					
						
							|  |  |  | 	SSD1325_ID, | 
					
						
							|  |  |  | 	SSD1327_ID, | 
					
						
							| 
									
										
										
										
											2022-04-19 23:48:22 +02:00
										 |  |  | 	NR_SSD130X_VARIANTS | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | struct ssd130x_deviceinfo { | 
					
						
							|  |  |  | 	u32 default_vcomh; | 
					
						
							|  |  |  | 	u32 default_dclk_div; | 
					
						
							|  |  |  | 	u32 default_dclk_frq; | 
					
						
							| 
									
										
										
										
											2023-06-09 19:09:36 +02:00
										 |  |  | 	u32 default_width; | 
					
						
							|  |  |  | 	u32 default_height; | 
					
						
							| 
									
										
										
										
											2023-08-24 17:08:41 +02:00
										 |  |  | 	bool need_pwm; | 
					
						
							|  |  |  | 	bool need_chargepump; | 
					
						
							| 
									
										
										
										
											2022-04-07 01:29:55 +08:00
										 |  |  | 	bool page_mode_only; | 
					
						
							| 
									
										
										
										
											2023-10-14 09:15:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	enum ssd130x_family_ids family_id; | 
					
						
							| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct ssd130x_device { | 
					
						
							|  |  |  | 	struct drm_device drm; | 
					
						
							|  |  |  | 	struct device *dev; | 
					
						
							|  |  |  | 	struct drm_display_mode mode; | 
					
						
							| 
									
										
										
										
											2022-09-06 00:27:59 +02:00
										 |  |  | 	struct drm_plane primary_plane; | 
					
						
							|  |  |  | 	struct drm_crtc crtc; | 
					
						
							|  |  |  | 	struct drm_encoder encoder; | 
					
						
							| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | 	struct drm_connector connector; | 
					
						
							|  |  |  | 	struct i2c_client *client; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct regmap *regmap; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	const struct ssd130x_deviceinfo *device_info; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-07 01:29:55 +08:00
										 |  |  | 	unsigned page_address_mode : 1; | 
					
						
							| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | 	unsigned area_color_enable : 1; | 
					
						
							|  |  |  | 	unsigned com_invdir : 1; | 
					
						
							|  |  |  | 	unsigned com_lrremap : 1; | 
					
						
							|  |  |  | 	unsigned com_seq : 1; | 
					
						
							|  |  |  | 	unsigned lookup_table_set : 1; | 
					
						
							|  |  |  | 	unsigned low_power : 1; | 
					
						
							|  |  |  | 	unsigned seg_remap : 1; | 
					
						
							|  |  |  | 	u32 com_offset; | 
					
						
							|  |  |  | 	u32 contrast; | 
					
						
							|  |  |  | 	u32 dclk_div; | 
					
						
							|  |  |  | 	u32 dclk_frq; | 
					
						
							|  |  |  | 	u32 height; | 
					
						
							|  |  |  | 	u8 lookup_table[4]; | 
					
						
							|  |  |  | 	u32 page_offset; | 
					
						
							|  |  |  | 	u32 col_offset; | 
					
						
							|  |  |  | 	u32 prechargep1; | 
					
						
							|  |  |  | 	u32 prechargep2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct backlight_device *bl_dev; | 
					
						
							|  |  |  | 	struct pwm_device *pwm; | 
					
						
							|  |  |  | 	struct gpio_desc *reset; | 
					
						
							|  |  |  | 	struct regulator *vcc_reg; | 
					
						
							|  |  |  | 	u32 vcomh; | 
					
						
							|  |  |  | 	u32 width; | 
					
						
							|  |  |  | 	/* Cached address ranges */ | 
					
						
							|  |  |  | 	u8 col_start; | 
					
						
							|  |  |  | 	u8 col_end; | 
					
						
							|  |  |  | 	u8 page_start; | 
					
						
							|  |  |  | 	u8 page_end; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-19 23:48:22 +02:00
										 |  |  | extern const struct ssd130x_deviceinfo ssd130x_variants[]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap); | 
					
						
							| 
									
										
										
										
											2022-04-25 21:23:06 +02:00
										 |  |  | void ssd130x_remove(struct ssd130x_device *ssd130x); | 
					
						
							| 
									
										
										
										
											2022-02-14 14:37:07 +01:00
										 |  |  | void ssd130x_shutdown(struct ssd130x_device *ssd130x); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-12 14:02:31 +02:00
										 |  |  | #endif /* __SSD130X_H__ */
 |