]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm: ssd130x: Always apply segment remap setting
authorChen-Yu Tsai <wens@csie.org>
Tue, 8 Mar 2022 16:07:58 +0000 (00:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:29:53 +0000 (10:29 +0200)
[ Upstream commit a134109c301736ea2ac5054ba3c29c30c87f6ba7 ]

Currently the ssd130x driver only sets the segment remap setting when
the device tree requests it; it however does not clear the setting if
it is not requested. This leads to the setting incorrectly persisting
if the hardware is always on and has no reset GPIO wired. This might
happen when a developer is trying to find the correct settings for an
unknown module, and cause the developer to get confused because the
settings from the device tree are not consistently applied.

Make the driver apply the segment remap setting consistently, setting
the value correctly based on the device tree setting. This also makes
this setting's behavior consistent with the other settings, which are
always applied.

Fixes: a61732e80867 ("drm: Add driver for Solomon SSD130x OLED displays")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220308160758.26060-2-wens@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/solomon/ssd130x.c

index ccd37813558911757a0b54faf57d0addfca84e02..d08d86ef07bcbe7ff39a27f9439043201f344149 100644 (file)
@@ -48,7 +48,7 @@
 #define SSD130X_CONTRAST                       0x81
 #define SSD130X_SET_LOOKUP_TABLE               0x91
 #define SSD130X_CHARGE_PUMP                    0x8d
-#define SSD130X_SEG_REMAP_ON                   0xa1
+#define SSD130X_SET_SEG_REMAP                  0xa0
 #define SSD130X_DISPLAY_OFF                    0xae
 #define SSD130X_SET_MULTIPLEX_RATIO            0xa8
 #define SSD130X_DISPLAY_ON                     0xaf
@@ -61,6 +61,8 @@
 #define SSD130X_SET_COM_PINS_CONFIG            0xda
 #define SSD130X_SET_VCOMH                      0xdb
 
+#define SSD130X_SET_SEG_REMAP_MASK             GENMASK(0, 0)
+#define SSD130X_SET_SEG_REMAP_SET(val)         FIELD_PREP(SSD130X_SET_SEG_REMAP_MASK, (val))
 #define SSD130X_SET_COM_SCAN_DIR_MASK          GENMASK(3, 3)
 #define SSD130X_SET_COM_SCAN_DIR_SET(val)      FIELD_PREP(SSD130X_SET_COM_SCAN_DIR_MASK, (val))
 #define SSD130X_SET_CLOCK_DIV_MASK             GENMASK(3, 0)
@@ -235,7 +237,7 @@ static void ssd130x_power_off(struct ssd130x_device *ssd130x)
 
 static int ssd130x_init(struct ssd130x_device *ssd130x)
 {
-       u32 precharge, dclk, com_invdir, compins, chargepump;
+       u32 precharge, dclk, com_invdir, compins, chargepump, seg_remap;
        int ret;
 
        /* Set initial contrast */
@@ -244,11 +246,11 @@ static int ssd130x_init(struct ssd130x_device *ssd130x)
                return ret;
 
        /* Set segment re-map */
-       if (ssd130x->seg_remap) {
-               ret = ssd130x_write_cmd(ssd130x, 1, SSD130X_SEG_REMAP_ON);
-               if (ret < 0)
-                       return ret;
-       }
+       seg_remap = (SSD130X_SET_SEG_REMAP |
+                    SSD130X_SET_SEG_REMAP_SET(ssd130x->seg_remap));
+       ret = ssd130x_write_cmd(ssd130x, 1, seg_remap);
+       if (ret < 0)
+               return ret;
 
        /* Set COM direction */
        com_invdir = (SSD130X_SET_COM_SCAN_DIR |