drm/ssd130x: Add support for SINO WEALTH SH1106
Subsystems (4)
v2 cover drm/ssd130x: Add support for SINO WEALTH SH1106
From: Chen-Yu Tsai <[email protected]>
Hi everyone,
This series adds support for SH1106 to the ssd130x OLED display driver.
Changes since v1:
- Fixed ordering of SINO WEALTH in vendor prefix list
- Updated allOf:if: blocks in DT binding, i.e. added default values for solomon,dclk-{div,frq}
- Added SSD130X_PAGE_COL_START_{HIGH,LOW}_SET and used that to set the bitfields for the two commands.
I didn't feel SSD130X_PAGE_COL_START_{HIGH,LOW}_MASK was needed, as it was the same between both commands.
- Added SH110x to the SSD130X Kconfig help texts
There are SH110[789] as well, but they don't seem to be easy to find.
The SINO WEALTH SH1106 is an OLED display driver that is somewhat compatible with the SSD1306. It supports a slightly wider display, at 132 instead of 128 pixels. The basic commands are the same, but the SH1106 doesn't support the horizontal or vertical address modes.
This driver chip is found in some cheap 1.3" OLED panel modules. It acts as a substitute for the SSD1306.
Patch 1 adds an entry to the vendor prefixes for SINO WEALTH Eletronics Ltd.
Patch 2 adds an entry for SH1106 to the ssd1307fb binding.
Patch 3 adds support for the base "page addressing mode" to the ssd130x driver.
Patch 4 adds support for the SH1106 to the ssd130x driver.
Please have a look.
Thanks
ChenYu
Chen-Yu Tsai (4):
dt-bindings: vendor-prefixes: Add prefix for SINO WEALTH Eletronics
Ltd.
dt-bindings: display: ssd1307fb: Add entry for SINO WEALTH SH1106 drm/ssd130x: Support page addressing mode
drm/ssd130x: Add support for SINO WEALTH SH1106
.../bindings/display/solomon,ssd1307fb.yaml | 13 ++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + drivers/gpu/drm/solomon/Kconfig | 9 ++- drivers/gpu/drm/solomon/ssd130x-i2c.c | 11 +++ drivers/gpu/drm/solomon/ssd130x.c | 73 +++++++++++++++++-- drivers/gpu/drm/solomon/ssd130x.h | 2 + 6 files changed, 99 insertions(+), 11 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/4 dt-bindings: vendor-prefixes: Add prefix for SINO WEALTH Eletronics Ltd.
From: Chen-Yu Tsai <[email protected]>
Add a vendor prefix entry for SINO WEALTH Eletronics Ltd.
(http://www.sinowealth.com).
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -1130,6 +1130,8 @@ patternProperties: description: Sinlinx Electronics Technology Co., LTD "^sinovoip,.*": description: SinoVoip Co., Ltd + "^sinowealth,.*": + description: SINO WEALTH Electronic Ltd. "^sipeed,.*": description: Shenzhen Sipeed Technology Co., Ltd. "^sirf,.*":
Signature · 1 line
2.34.1
PATCH v2 2/4 dt-bindings: display: ssd1307fb: Add entry for SINO WEALTH SH1106
In reply to Chen-Yu TsaiFrom: Chen-Yu Tsai <[email protected]>
The SINO WEALTH SH1106 is an OLED display driver that is somewhat compatible with the SSD1306. It supports a slightly wider display, at 132 instead of 128 pixels. The basic commands are the same, but the SH1106 doesn't support the horizontal or vertical address modes.
Add a compatible string for it.
--- .../bindings/display/solomon,ssd1307fb.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml +13 -0
@@ -13,6 +13,7 @@ maintainers: properties: compatible: enum: + - sinowealth,sh1106-i2c - solomon,ssd1305fb-i2c - solomon,ssd1306fb-i2c - solomon,ssd1307fb-i2c
@@ -131,6 +132,18 @@ required: - reg allOf: + - if: + properties: + compatible: + contains: + const: sinowealth,sh1106-i2c + then: + properties: + solomon,dclk-div: + default: 1 + solomon,dclk-frq: + default: 5 + - if: properties: compatible:
Signature · 1 line
2.34.1
Re: [PATCH v2 2/4] dt-bindings: display: ssd1307fb: Add entry for SINO WEALTH SH1106
Hi Chen-Yu,
Quoted 10 lines · Chen-Yu Tsai
From: Chen-Yu Tsai <[email protected]>
The SINO WEALTH SH1106 is an OLED display driver that is somewhat compatible with the SSD1306. It supports a slightly wider display, at 132 instead of 128 pixels. The basic commands are the same, but the SH1106 doesn't support the horizontal or vertical address modes.
Add a compatible string for it.
Signed-off-by Chen-Yu Tsai <[email protected]>
Thanks for your patch!
Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml maintainers: · line 16
Quoted 7 lines
Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml +1
-0@@ -13,6 +13,7 @@ maintainers: properties: compatible: enum: + - sinowealth,sh1106-i2c
Please don't introduce new compatible values including the bus type. There is no need for that, and this will only lead to more deprecated compatible values soon...
Oops, this is already commit 97a40c23cda5d64a ("dt-bindings:
display: ssd1307fb: Add entry for SINO WEALTH SH1106") in drm-misc/for-linux-next...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Javier Martinez Canillas
maintainerRe: [PATCH v2 2/4] dt-bindings: display: ssd1307fb: Add entry for SINO WEALTH SH1106
Hello Geert,
Quoted 1 line · Geert Uytterhoeven
Hi Chen-Yu,
[snip]
Quoted 12 lines
Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml maintainers: · line 16
Quoted 7 lines
Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml +1
-0@@ -13,6 +13,7 @@ maintainers: properties: compatible: enum: + - sinowealth,sh1106-i2cPlease don't introduce new compatible values including the bus type. There is no need for that, and this will only lead to more deprecated compatible values soon...
Quoted 4 lines
Oops, this is already commit
97a40c23cda5d64a("dt-bindings:
display: ssd1307fb: Add entry for SINO WEALTH SH1106") in drm-misc/for-linux-next...
Yeah, too late :/ I didn't think it would be controversial at the time.
Signature · 5 lines
Best regards, Javier Martinez Canillas Linux Engineering Red Hat
PATCH v2 3/4 drm/ssd130x: Support page addressing mode
In reply to Chen-Yu TsaiFrom: Chen-Yu Tsai <[email protected]>
On the SINO WEALTH SH1106, which is mostly compatible with the SSD1306, only the basic page addressing mode is supported. This addressing mode is not as easy to use compared to the currently supported horizontal addressing mode, as the page address has to be set prior to writing out each page, and each page must be written out separately as a result. Also, there is no way to force the column address to wrap around early, thus the column address must also be reset for each page to be accurate.
Add support for this addressing mode, with a flag to choose it. This flag is designed to be set from the device info data structure, but can be extended to be explicitly forced on through a device tree property if such a need arises.
--- drivers/gpu/drm/solomon/ssd130x.c | 73 ++++++++++++++++++++++++++++--- drivers/gpu/drm/solomon/ssd130x.h | 2 + 2 files changed, 68 insertions(+), 7 deletions(-)
drivers/gpu/drm/solomon/ssd130x.c +66 -7
@@ -42,6 +42,8 @@#define SSD130X_DATA 0x40#define SSD130X_COMMAND 0x80 +#define SSD130X_PAGE_COL_START_LOW 0x00 +#define SSD130X_PAGE_COL_START_HIGH 0x10#define SSD130X_SET_ADDRESS_MODE 0x20#define SSD130X_SET_COL_RANGE 0x21#define SSD130X_SET_PAGE_RANGE 0x22
@@ -61,6 +63,11 @@#define SSD130X_SET_COM_PINS_CONFIG 0xda#define SSD130X_SET_VCOMH 0xdb +#define SSD130X_PAGE_COL_START_MASK GENMASK(3, 0) +#define SSD130X_PAGE_COL_START_HIGH_SET (val) FIELD_PREP(SSD130X_PAGE_COL_START_MASK, (val) >> 4) +#define SSD130X_PAGE_COL_START_LOW_SET (val) FIELD_PREP(SSD130X_PAGE_COL_START_MASK, (val)) +#define SSD130X_START_PAGE_ADDRESS_MASK GENMASK(2, 0) +#define SSD130X_START_PAGE_ADDRESS_SET (val) FIELD_PREP(SSD130X_START_PAGE_ADDRESS_MASK, (val))#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)
@@ -130,6 +137,7 @@ static int ssd130x_write_cmd(struct ssd130x_device *ssd130x, int count,return ret; } +/* Set address range for horizontal/vertical addressing modes */ static int ssd130x_set_col_range (struct ssd130x_device *ssd130x,u8 col_start,u8 cols) {
@@ -166,6 +174,26 @@ static int ssd130x_set_page_range(struct ssd130x_device *ssd130x,return 0 ; } +/* Set page and column start address for page addressing mode */ +static int ssd130x_set_page_pos (struct ssd130x_device *ssd130x, +u8 page_start,u8 col_start) +{ +int ret; +u32 page, col_low, col_high; + + page =SSD130X_START_PAGE_ADDRESS | +SSD130X_START_PAGE_ADDRESS_SET (page_start); + col_low =SSD130X_PAGE_COL_START_LOW | +SSD130X_PAGE_COL_START_LOW_SET (col_start); + col_high =SSD130X_PAGE_COL_START_HIGH | +SSD130X_PAGE_COL_START_HIGH_SET (col_start); + ret =ssd130x_write_cmd (ssd130x,3 , page, col_low, col_high); +if (ret <0 ) +return ret; + +return 0 ; +} +static int ssd130x_pwm_enable (struct ssd130x_device *ssd130x) {struct device *dev = ssd130x->dev;
@@ -342,6 +370,11 @@ static int ssd130x_init(struct ssd130x_device *ssd130x) } } +/* Switch to page addressing mode */ +if (ssd130x->page_address_mode) +return ssd130x_write_cmd (ssd130x,2 ,SSD130X_SET_ADDRESS_MODE , +SSD130X_SET_ADDRESS_MODE_PAGE ); +/* Switch to horizontal addressing mode */ return ssd130x_write_cmd (ssd130x,2 ,SSD130X_SET_ADDRESS_MODE ,SSD130X_SET_ADDRESS_MODE_HORIZONTAL );
@@ -396,13 +429,16 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf,* (5) A4 B4 C4 D4 E4 F4 G4 H4 */ - ret =ssd130x_set_col_range (ssd130x, ssd130x->col_offset + x, width); -if (ret <0 ) - goto out_free; +if (!ssd130x->page_address_mode) { +/* Set address range for horizontal addressing mode */ + ret =ssd130x_set_col_range (ssd130x, ssd130x->col_offset + x, width); +if (ret <0 ) + goto out_free; - ret =ssd130x_set_page_range (ssd130x, ssd130x->page_offset + y /8 , pages); -if (ret <0 ) - goto out_free; + ret =ssd130x_set_page_range (ssd130x, ssd130x->page_offset + y /8 , pages); +if (ret <0 ) + goto out_free; + }for (i =0 ; i < pages; i++) {int m =8 ;
@@ -421,9 +457,29 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf, } data_array[array_idx++] = data; } + +/* +* In page addressing mode, the start address needs to be reset, +* and each page then needs to be written out separately. +*/ +if (ssd130x->page_address_mode) { + ret =ssd130x_set_page_pos (ssd130x, + ssd130x->page_offset + i, + ssd130x->col_offset + x); +if (ret <0 ) + goto out_free; + + ret =ssd130x_write_data (ssd130x, data_array, width); +if (ret <0 ) + goto out_free; + + array_idx =0 ; + } } - ret =ssd130x_write_data (ssd130x, data_array, width * pages); +/* Write out update in one go if we aren't using page addressing mode */ +if (!ssd130x->page_address_mode) + ret =ssd130x_write_data (ssd130x, data_array, width * pages); out_free:kfree (data_array);
@@ -806,6 +862,9 @@ struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap) ssd130x->regmap = regmap; ssd130x->device_info =device_get_match_data (dev); +if (ssd130x->device_info->page_mode_only) + ssd130x->page_address_mode =1 ; +ssd130x_parse_properties (ssd130x); ret =ssd130x_get_resources (ssd130x);
drivers/gpu/drm/solomon/ssd130x.h +2 -0
@@ -24,6 +24,7 @@ struct ssd130x_deviceinfo {u32 default_dclk_frq;int need_pwm;int need_chargepump; +bool page_mode_only; };struct ssd130x_device {
@@ -38,6 +39,7 @@ struct ssd130x_device {const struct ssd130x_deviceinfo *device_info; + unsigned page_address_mode : 1; unsigned area_color_enable : 1; unsigned com_invdir : 1; unsigned com_lrremap : 1;
Signature · 1 line
2.34.1
PATCH v2 4/4 drm/ssd130x: Add support for SINO WEALTH SH1106
In reply to Chen-Yu TsaiFrom: Chen-Yu Tsai <[email protected]>
The SINO WEALTH SH1106 is an OLED display driver that is somewhat compatible with the SSD1306. It supports a slightly wider display, at 132 instead of 128 pixels. The basic commands are the same, but the SH1106 doesn't support the horizontal or vertical address modes.
Add support for this display driver. The default values for some of the hardware settings are taken from the datasheet.
--- drivers/gpu/drm/solomon/Kconfig | 9 +++++---- drivers/gpu/drm/solomon/ssd130x-i2c.c | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/solomon/Kconfig +5 -4
@@ -5,9 +5,9 @@ config DRM_SSD130X select DRM_GEM_SHMEM_HELPER select DRM_KMS_HELPER help - DRM driver for the SSD1305, SSD1306, SSD1307 and SSD1309 Solomon - OLED controllers. This is only for the core driver, a driver for - the appropriate bus transport in your chip also must be selected. + DRM driver for the SSD130x Solomon and SINO WEALTH SH110x OLED + controllers. This is only for the core driver, a driver for the + appropriate bus transport in your chip also must be selected. If M is selected the module will be called ssd130x.
@@ -16,6 +16,7 @@ config DRM_SSD130X_I2C depends on DRM_SSD130X && I2C select REGMAP_I2C help - Say Y here if the SSD130x OLED display is connected via I2C bus. + Say Y here if the SSD130x or SH110x OLED display is connected via + I2C bus. If M is selected the module will be called ssd130x-i2c.
drivers/gpu/drm/solomon/ssd130x-i2c.c +11 -0
@@ -53,6 +53,13 @@ static void ssd130x_i2c_shutdown(struct i2c_client *client)ssd130x_shutdown (ssd130x); } +static struct ssd130x_deviceinfo ssd130x_sh1106_deviceinfo = { + .default_vcomh =0x40 , + .default_dclk_div =1 , + .default_dclk_frq =5 , + .page_mode_only =1 , +}; +static struct ssd130x_deviceinfo ssd130x_ssd1305_deviceinfo = { .default_vcomh =0x34 , .default_dclk_div =1 ,
@@ -80,6 +87,10 @@ static struct ssd130x_deviceinfo ssd130x_ssd1309_deviceinfo = { };static const struct of_device_id ssd130x_of_match[] = { + { + .compatible ="sinowealth,sh1106-i2c" , + .data = &ssd130x_sh1106_deviceinfo, + }, { .compatible ="solomon,ssd1305fb-i2c" , .data = &ssd130x_ssd1305_deviceinfo,
Signature · 1 line
2.34.1
Hello Chen-Yu,
Quoted 8 lines · Chen-Yu Tsai
From: Chen-Yu Tsai <[email protected]>
Hi everyone,
This series adds support for SH1106 to the ssd130x OLED display driver.
Thanks for re-spinning your series. I believe that gave you my Acked-by for most of the patches in v1 already? But it seems you didn't pick them up.
You addressed the comments I had in v1 so those stand, for all patches:
Best regards,
Javier
Javier Martinez Canillas
maintainerOn 4/6/22 19:29, Chen-Yu Tsai wrote:
Pushed this series to drm-misc (drm-misc-next), thanks again for your patches!
Signature · 5 lines
Best regards, Javier Martinez Canillas Linux Engineering Red Hat