Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSD1309 display support #83436

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion drivers/display/Kconfig.ssd1306
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
menuconfig SSD1306
bool "SSD1306 display driver"
default y
depends on DT_HAS_SOLOMON_SSD1306FB_ENABLED || DT_HAS_SINOWEALTH_SH1106_ENABLED
depends on DT_HAS_SOLOMON_SSD1306FB_ENABLED || DT_HAS_SOLOMON_SSD1309FB_ENABLED || DT_HAS_SINOWEALTH_SH1106_ENABLED
select I2C if $(dt_compat_on_bus,$(DT_COMPAT_SOLOMON_SSD1306FB),i2c)
select SPI if $(dt_compat_on_bus,$(DT_COMPAT_SOLOMON_SSD1306FB),spi)
select I2C if $(dt_compat_on_bus,$(DT_COMPAT_SOLOMON_SSD1309FB),i2c)
select SPI if $(dt_compat_on_bus,$(DT_COMPAT_SOLOMON_SSD1309FB),spi)
select I2C if $(dt_compat_on_bus,$(DT_COMPAT_SINOWEALTH_SH1106),i2c)
select SPI if $(dt_compat_on_bus,$(DT_COMPAT_SINOWEALTH_SH1106),spi)
help
Expand Down
22 changes: 16 additions & 6 deletions drivers/display/ssd1306.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ LOG_MODULE_REGISTER(ssd1306, CONFIG_DISPLAY_LOG_LEVEL);
#define SSD1306_PANEL_VCOM_DESEL_LEVEL 0x20
#define SSD1306_PANEL_PUMP_VOLTAGE SSD1306_SET_PUMP_VOLTAGE_90

#define SSD1306_PANEL_VCOM_DESEL_LEVEL_SSD1309 0x34

#ifndef SSD1306_ADDRESSING_MODE
#define SSD1306_ADDRESSING_MODE (SSD1306_SET_MEM_ADDRESSING_HORIZONTAL)
#endif
Expand Down Expand Up @@ -55,6 +57,7 @@ struct ssd1306_config {
bool com_invdir;
bool com_sequential;
bool color_inversion;
bool ssd1309_compatible;
bool sh1106_compatible;
int ready_time_ms;
bool use_internal_iref;
Expand All @@ -65,6 +68,7 @@ struct ssd1306_data {
};

#if (DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(solomon_ssd1306fb, i2c) || \
DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(solomon_ssd1309fb, i2c) || \
DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(sinowealth_sh1106, i2c))
static bool ssd1306_bus_ready_i2c(const struct device *dev)
{
Expand Down Expand Up @@ -92,6 +96,7 @@ static const char *ssd1306_bus_name_i2c(const struct device *dev)
#endif

#if (DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(solomon_ssd1306fb, spi) || \
DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(solomon_ssd1309fb, spi) || \
DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(sinowealth_sh1106, spi))
static bool ssd1306_bus_ready_spi(const struct device *dev)
{
Expand Down Expand Up @@ -167,7 +172,8 @@ static inline int ssd1306_set_timing_setting(const struct device *dev)
SSD1306_SET_CHARGE_PERIOD,
config->prechargep,
SSD1306_SET_VCOM_DESELECT_LEVEL,
SSD1306_PANEL_VCOM_DESEL_LEVEL};
config->ssd1309_compatible ? SSD1306_PANEL_VCOM_DESEL_LEVEL_SSD1309 :
SSD1306_PANEL_VCOM_DESEL_LEVEL};

return ssd1306_write_bus(dev, cmd_buf, sizeof(cmd_buf), true);
}
Expand Down Expand Up @@ -428,12 +434,14 @@ static int ssd1306_init_device(const struct device *dev)
return -EIO;
}

if (ssd1306_set_charge_pump(dev)) {
return -EIO;
}
if (!config->ssd1309_compatible) {
if (ssd1306_set_charge_pump(dev)) {
return -EIO;
}

if (ssd1306_set_iref_mode(dev)) {
return -EIO;
if (ssd1306_set_iref_mode(dev)) {
return -EIO;
}
}

if (ssd1306_write_bus(dev, cmd_buf, sizeof(cmd_buf), true)) {
Expand Down Expand Up @@ -517,6 +525,7 @@ static DEVICE_API(display, ssd1306_driver_api) = {
.com_sequential = DT_PROP(node_id, com_sequential), \
.prechargep = DT_PROP(node_id, prechargep), \
.color_inversion = DT_PROP(node_id, inversion_on), \
.ssd1309_compatible = DT_NODE_HAS_COMPAT(node_id, solomon_ssd1309fb), \
.sh1106_compatible = DT_NODE_HAS_COMPAT(node_id, sinowealth_sh1106), \
.ready_time_ms = DT_PROP(node_id, ready_time_ms), \
.use_internal_iref = DT_PROP(node_id, use_internal_iref), \
Expand All @@ -528,4 +537,5 @@ static DEVICE_API(display, ssd1306_driver_api) = {
POST_KERNEL, CONFIG_DISPLAY_INIT_PRIORITY, &ssd1306_driver_api);

DT_FOREACH_STATUS_OKAY(solomon_ssd1306fb, SSD1306_DEFINE)
DT_FOREACH_STATUS_OKAY(solomon_ssd1309fb, SSD1306_DEFINE)
DT_FOREACH_STATUS_OKAY(sinowealth_sh1106, SSD1306_DEFINE)
8 changes: 8 additions & 0 deletions dts/bindings/display/solomon,ssd1309fb-i2c.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2025, Marcio Ribeiro
# SPDX-License-Identifier: Apache-2.0

description: SSD1309 128x64 dot-matrix display controller on I2C bus

compatible: "solomon,ssd1309fb"

include: ["solomon,ssd1306fb-common.yaml", "i2c-device.yaml"]
14 changes: 14 additions & 0 deletions dts/bindings/display/solomon,ssd1309fb-spi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2025, Marcio Ribeiro
# SPDX-License-Identifier: Apache-2.0

description: SSD1309 128x64 dot-matrix display controller on SPI bus

compatible: "solomon,ssd1309fb"

include: ["solomon,ssd1306fb-common.yaml", "spi-device.yaml"]

properties:
data_cmd-gpios:
type: phandle-array
required: true
description: D/C# pin.
Loading