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

[TOPIC-GPIO] drivers: ssd16xx: convert to new GPIO API #21686

Merged
merged 1 commit into from
Jan 25, 2020
Merged
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
6 changes: 3 additions & 3 deletions boards/arm/reel_board/reel_board.dts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
height = <120>;
pp-width-bits = <8>;
pp-height-bits = <8>;
reset-gpios = <&gpio0 15 0>;
dc-gpios = <&gpio0 16 0>;
busy-gpios = <&gpio0 14 0>;
reset-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
dc-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
busy-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
gdv = [10 0a];
sdv = [19];
vcom = <0xa8>;
Expand Down
6 changes: 3 additions & 3 deletions boards/arm/reel_board/reel_board_v2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
height = <120>;
pp-width-bits = <8>;
pp-height-bits = <16>;
reset-gpios = <&gpio0 15 0>;
dc-gpios = <&gpio0 16 0>;
busy-gpios = <&gpio0 14 0>;
reset-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
dc-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
busy-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
gdv = [15];
sdv = [41 a8 32];
vcom = <0x26>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
height = <120>;
pp-width-bits = <8>;
pp-height-bits = <8>;
dc-gpios = <&arduino_header 15 0>; /* D9 */
reset-gpios = <&arduino_header 14 0>; /* D8 */
busy-gpios = <&arduino_header 13 0>; /* D7 */
dc-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */
busy-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
gdv = [10 0a];
sdv = [19];
vcom = <0xa8>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
height = <120>;
pp-width-bits = <8>;
pp-height-bits = <16>;
dc-gpios = <&arduino_header 15 0>; /* D9 */
reset-gpios = <&arduino_header 14 0>; /* D8 */
busy-gpios = <&arduino_header 13 0>; /* D7 */
dc-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */
busy-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
gdv = [15];
sdv = [41 a8 32];
vcom = <0x26>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
height = <128>;
pp-width-bits = <16>;
pp-height-bits = <16>;
dc-gpios = <&arduino_header 15 0>; /* D9 */
reset-gpios = <&arduino_header 14 0>; /* D8 */
busy-gpios = <&arduino_header 13 0>; /* D7 */
dc-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */
busy-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
gdv = [16];
sdv = [0a];
vcom = <0xa8>;
Expand Down
29 changes: 16 additions & 13 deletions drivers/display/ssd16xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ LOG_MODULE_REGISTER(ssd16xx);
#define SSD16XX_SPI_FREQ DT_INST_0_SOLOMON_SSD16XXFB_SPI_MAX_FREQUENCY
#define SSD16XX_BUS_NAME DT_INST_0_SOLOMON_SSD16XXFB_BUS_NAME
#define SSD16XX_DC_PIN DT_INST_0_SOLOMON_SSD16XXFB_DC_GPIOS_PIN
#define SSD16XX_DC_FLAGS DT_INST_0_SOLOMON_SSD16XXFB_DC_GPIOS_FLAGS
#define SSD16XX_DC_CNTRL DT_INST_0_SOLOMON_SSD16XXFB_DC_GPIOS_CONTROLLER
#define SSD16XX_CS_PIN DT_INST_0_SOLOMON_SSD16XXFB_CS_GPIOS_PIN
#if defined(DT_INST_0_SOLOMON_SSD16XXFB_CS_GPIOS_CONTROLLER)
#define SSD16XX_CS_CNTRL DT_INST_0_SOLOMON_SSD16XXFB_CS_GPIOS_CONTROLLER
#endif
#define SSD16XX_BUSY_PIN DT_INST_0_SOLOMON_SSD16XXFB_BUSY_GPIOS_PIN
#define SSD16XX_BUSY_CNTRL DT_INST_0_SOLOMON_SSD16XXFB_BUSY_GPIOS_CONTROLLER
#define SSD16XX_BUSY_FLAGS DT_INST_0_SOLOMON_SSD16XXFB_BUSY_GPIOS_FLAGS
#define SSD16XX_RESET_PIN DT_INST_0_SOLOMON_SSD16XXFB_RESET_GPIOS_PIN
#define SSD16XX_RESET_CNTRL DT_INST_0_SOLOMON_SSD16XXFB_RESET_GPIOS_CONTROLLER
#define SSD16XX_RESET_FLAGS DT_INST_0_SOLOMON_SSD16XXFB_RESET_GPIOS_FLAGS

#define EPD_PANEL_WIDTH DT_INST_0_SOLOMON_SSD16XXFB_WIDTH
#define EPD_PANEL_HEIGHT DT_INST_0_SOLOMON_SSD16XXFB_HEIGHT
Expand Down Expand Up @@ -85,7 +88,7 @@ static inline int ssd16xx_write_cmd(struct ssd16xx_data *driver,
struct spi_buf buf = {.buf = &cmd, .len = sizeof(cmd)};
struct spi_buf_set buf_set = {.buffers = &buf, .count = 1};

gpio_pin_write(driver->dc, SSD16XX_DC_PIN, 0);
gpio_pin_set(driver->dc, SSD16XX_DC_PIN, 1);
err = spi_write(driver->spi_dev, &driver->spi_config, &buf_set);
if (err < 0) {
return err;
Expand All @@ -94,7 +97,7 @@ static inline int ssd16xx_write_cmd(struct ssd16xx_data *driver,
if (data != NULL) {
buf.buf = data;
buf.len = len;
gpio_pin_write(driver->dc, SSD16XX_DC_PIN, 1);
gpio_pin_set(driver->dc, SSD16XX_DC_PIN, 0);
err = spi_write(driver->spi_dev, &driver->spi_config, &buf_set);
if (err < 0) {
return err;
Expand All @@ -106,12 +109,12 @@ static inline int ssd16xx_write_cmd(struct ssd16xx_data *driver,

static inline void ssd16xx_busy_wait(struct ssd16xx_data *driver)
{
u32_t val = 0U;
int pin = gpio_pin_get(driver->busy, SSD16XX_BUSY_PIN);

gpio_pin_read(driver->busy, SSD16XX_BUSY_PIN, &val);
while (val) {
while (pin > 0) {
__ASSERT(pin >= 0, "Failed to get pin level");
k_sleep(SSD16XX_BUSY_DELAY);
gpio_pin_read(driver->busy, SSD16XX_BUSY_PIN, &val);
pin = gpio_pin_get(driver->busy, SSD16XX_BUSY_PIN);
}
}

Expand Down Expand Up @@ -413,7 +416,7 @@ static int ssd16xx_clear_and_write_buffer(struct device *dev, u8_t ram_cmd,
return err;
}

gpio_pin_write(driver->dc, SSD16XX_DC_PIN, 0);
gpio_pin_set(driver->dc, SSD16XX_DC_PIN, 1);

sbuf.buf = &ram_cmd;
sbuf.len = 1;
Expand All @@ -422,7 +425,7 @@ static int ssd16xx_clear_and_write_buffer(struct device *dev, u8_t ram_cmd,
return err;
}

gpio_pin_write(driver->dc, SSD16XX_DC_PIN, 1);
gpio_pin_set(driver->dc, SSD16XX_DC_PIN, 0);

memset(clear_page, 0xff, sizeof(clear_page));
sbuf.buf = clear_page;
Expand Down Expand Up @@ -450,9 +453,9 @@ static int ssd16xx_controller_init(struct device *dev)

LOG_DBG("");

gpio_pin_write(driver->reset, SSD16XX_RESET_PIN, 0);
gpio_pin_set(driver->reset, SSD16XX_RESET_PIN, 1);
k_sleep(SSD16XX_RESET_DELAY);
gpio_pin_write(driver->reset, SSD16XX_RESET_PIN, 1);
gpio_pin_set(driver->reset, SSD16XX_RESET_PIN, 0);
k_sleep(SSD16XX_RESET_DELAY);
ssd16xx_busy_wait(driver);

Expand Down Expand Up @@ -571,7 +574,7 @@ static int ssd16xx_init(struct device *dev)
}

gpio_pin_configure(driver->reset, SSD16XX_RESET_PIN,
GPIO_DIR_OUT);
GPIO_OUTPUT_INACTIVE | SSD16XX_RESET_FLAGS);

driver->dc = device_get_binding(SSD16XX_DC_CNTRL);
if (driver->dc == NULL) {
Expand All @@ -580,7 +583,7 @@ static int ssd16xx_init(struct device *dev)
}

gpio_pin_configure(driver->dc, SSD16XX_DC_PIN,
GPIO_DIR_OUT);
GPIO_OUTPUT_INACTIVE | SSD16XX_DC_FLAGS);

driver->busy = device_get_binding(SSD16XX_BUSY_CNTRL);
if (driver->busy == NULL) {
Expand All @@ -589,7 +592,7 @@ static int ssd16xx_init(struct device *dev)
}

gpio_pin_configure(driver->busy, SSD16XX_BUSY_PIN,
GPIO_DIR_IN);
GPIO_INPUT | SSD16XX_BUSY_FLAGS);

#if defined(SSD16XX_CS_CNTRL)
driver->cs_ctrl.gpio_dev = device_get_binding(SSD16XX_CS_CNTRL);
Expand Down
15 changes: 15 additions & 0 deletions dts/bindings/display/solomon,ssd1673fb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,29 @@ properties:
reset-gpios:
type: phandle-array
required: true
description: RESET pin.

The RESET pin of SSD16XX is active low.
If connected directly the MCU pin should be configured
as active low.

dc-gpios:
type: phandle-array
required: true
description: DC pin.

The DC pin of SSD16XX is active low (transmission command byte).
If connected directly the MCU pin should be configured
as active low.

busy-gpios:
type: phandle-array
required: true
description: BUSY pin.

The BUSY pin of SSD16XX is active high.
If connected directly the MCU pin should be configured
as active high.

lut-initial:
type: uint8-array
Expand Down