You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2018/12/11 11:31:24 UTC

[mynewt-core] 02/04: hw/drivers: Port display driver SSD1673

This is an automated email from the ASF dual-hosted git repository.

naraj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 179f09f4f7bd523b3522789c58c5554c05043aa2
Author: MichaƂ Narajowski <mi...@codecoup.pl>
AuthorDate: Tue Nov 6 13:28:16 2018 +0100

    hw/drivers: Port display driver SSD1673
---
 hw/drivers/display/cfb/include/display/cfb.h |  35 +--
 hw/drivers/display/cfb/pkg.yml               |  29 +++
 hw/drivers/display/cfb/src/cfb.c             | 107 +++++----
 hw/drivers/display/cfb/src/cfb_fonts.c       |  60 ++---
 hw/drivers/display/include/display/display.h | 107 +++++----
 hw/drivers/display/pkg.yml                   |  23 ++
 hw/drivers/display/ssd1673/pkg.yml           |  31 +++
 hw/drivers/display/ssd1673/src/ssd1673.c     | 318 +++++++++++++--------------
 hw/drivers/display/ssd1673/syscfg.yml        |  57 +++++
 9 files changed, 451 insertions(+), 316 deletions(-)

diff --git a/hw/drivers/display/cfb/include/display/cfb.h b/hw/drivers/display/cfb/include/display/cfb.h
index 29e70d8..214adb0 100644
--- a/hw/drivers/display/cfb/include/display/cfb.h
+++ b/hw/drivers/display/cfb/include/display/cfb.h
@@ -12,8 +12,8 @@
 #ifndef __CFB_H__
 #define __CFB_H__
 
-#include <device.h>
-#include <display.h>
+#include "os/mynewt.h"
+#include "display/display.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -42,19 +42,21 @@ enum cfb_display_param {
 };
 
 enum cfb_font_caps {
-	CFB_FONT_MONO_VPACKED		= BIT(0),
-	CFB_FONT_MONO_HPACKED		= BIT(1),
+	CFB_FONT_MONO_VPACKED		= (1UL << 0),
+	CFB_FONT_MONO_HPACKED		= (1UL << 1),
 };
 
 struct cfb_font {
 	const void *data;
-	u8_t width;
-	u8_t height;
+	uint8_t width;
+	uint8_t height;
 	enum cfb_font_caps caps;
-	u8_t first_char;
-	u8_t last_char;
+	uint8_t first_char;
+	uint8_t last_char;
 };
 
+#define CFB_FONTS_COUNT 3
+
 /**
  * @brief Macro for creating a font entry.
  *
@@ -67,8 +69,6 @@ struct cfb_font {
  * @param _lc     Character mapped to last font element.
  */
 #define FONT_ENTRY_DEFINE(_name, _width, _height, _caps, _data, _fc, _lc)      \
-	static const struct cfb_font _name				       \
-	__attribute__ ((section(".font_entry."))) __attribute__((used)) =      \
 	{								       \
 		.width = _width,					       \
 		.height = _height,					       \
@@ -88,7 +88,7 @@ struct cfb_font {
  *
  * @return 0 on success, negative value otherwise
  */
-int cfb_print(struct device *dev, char *str, u16_t x, u16_t y);
+int cfb_print(struct os_dev *dev, char *str, uint16_t x, uint16_t y);
 
 /**
  * @brief Clear framebuffer.
@@ -98,7 +98,7 @@ int cfb_print(struct device *dev, char *str, u16_t x, u16_t y);
  *
  * @return 0 on success, negative value otherwise
  */
-int cfb_framebuffer_clear(struct device *dev, bool clear_display);
+int cfb_framebuffer_clear(struct os_dev *dev, bool clear_display);
 
 /**
  * @brief Finalize framebuffer and write it to display RAM,
@@ -108,7 +108,7 @@ int cfb_framebuffer_clear(struct device *dev, bool clear_display);
  *
  * @return 0 on success, negative value otherwise
  */
-int cfb_framebuffer_finalize(struct device *dev);
+int cfb_framebuffer_finalize(struct os_dev *dev);
 
 /**
  * @brief Get display parameter.
@@ -118,7 +118,7 @@ int cfb_framebuffer_finalize(struct device *dev);
  *
  * @return Display parameter value
  */
-int cfb_get_display_parameter(struct device *dev, enum cfb_display_param);
+int cfb_get_display_parameter(struct os_dev *dev, enum cfb_display_param);
 
 /**
  * @brief Set font.
@@ -128,7 +128,7 @@ int cfb_get_display_parameter(struct device *dev, enum cfb_display_param);
  *
  * @return 0 on success, negative value otherwise
  */
-int cfb_framebuffer_set_font(struct device *dev, u8_t idx);
+int cfb_framebuffer_set_font(struct os_dev *dev, uint8_t idx);
 
 /**
  * @brief Get font size.
@@ -140,7 +140,8 @@ int cfb_framebuffer_set_font(struct device *dev, u8_t idx);
  *
  * @return 0 on success, negative value otherwise
  */
-int cfb_get_font_size(struct device *dev, u8_t idx, u8_t *width, u8_t *height);
+int cfb_get_font_size(struct os_dev *dev, uint8_t idx,
+		      uint8_t *width, uint8_t *height);
 
 /**
  * @brief Initialize Character Framebuffer.
@@ -149,7 +150,7 @@ int cfb_get_font_size(struct device *dev, u8_t idx, u8_t *width, u8_t *height);
  *
  * @return 0 on success, negative value otherwise
  */
-int cfb_framebuffer_init(struct device *dev);
+int cfb_framebuffer_init(struct os_dev *dev);
 
 #ifdef __cplusplus
 }
diff --git a/hw/drivers/display/cfb/pkg.yml b/hw/drivers/display/cfb/pkg.yml
new file mode 100644
index 0000000..843cc42
--- /dev/null
+++ b/hw/drivers/display/cfb/pkg.yml
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: hw/drivers/display/cfb
+pkg.description: Driver for the character frame buffer
+pkg.author: "Apache Mynewt dev@mynewt.apache.org"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+    - display
+    - cfb
+
+pkg.deps:
+    - "@apache-mynewt-core/hw/drivers/display"
+    - "@apache-mynewt-core/sys/log/modlog"
diff --git a/hw/drivers/display/cfb/src/cfb.c b/hw/drivers/display/cfb/src/cfb.c
index dc2bc14..e9a3c63 100644
--- a/hw/drivers/display/cfb/src/cfb.c
+++ b/hw/drivers/display/cfb/src/cfb.c
@@ -4,23 +4,18 @@
  * SPDX-License-Identifier: Apache-2.0
  */
 
-#include <zephyr.h>
-#include <string.h>
-#include <display/cfb.h>
+#include "os/mynewt.h"
+#include "modlog/modlog.h"
+#include "display/cfb.h"
 
-#define LOG_LEVEL CONFIG_CFB_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(cfb);
-
-extern const struct cfb_font __font_entry_start[0];
-extern const struct cfb_font __font_entry_end[0];
+extern const struct cfb_font font_array[CFB_FONTS_COUNT];
 
 struct char_framebuffer {
 	/** Pointer to a buffer in RAM */
-	u8_t *buf;
+	uint8_t *buf;
 
 	/** Size of the framebuffer */
-	u32_t size;
+	uint32_t size;
 
 	/** Pointer to the font entry array */
 	const struct cfb_font *fonts;
@@ -32,33 +27,33 @@ struct char_framebuffer {
 	enum display_screen_info screen_info;
 
 	/** Resolution of a framebuffer in pixels in X direction */
-	u8_t x_res;
+	uint8_t x_res;
 
 	/** Resolution of a framebuffer in pixels in Y direction */
-	u8_t y_res;
+	uint8_t y_res;
 
 	/** Number of pixels per tile, typically 8 */
-	u8_t ppt;
+	uint8_t ppt;
 
 	/** Number of available fonts */
-	u8_t numof_fonts;
+	uint8_t numof_fonts;
 
 	/** Current font index */
-	u8_t font_idx;
+	uint8_t font_idx;
 
 	/** Font kerning */
-	s8_t kerning;
+	int8_t kerning;
 
-	/** Invertedj*/
+	/** Inverted */
 	bool inverted;
 };
 
 static struct char_framebuffer char_fb;
 
-static inline u8_t *get_glyph_ptr(const struct cfb_font *fptr, char c)
+static inline uint8_t *get_glyph_ptr(const struct cfb_font *fptr, char c)
 {
 	if (fptr->caps & CFB_FONT_MONO_VPACKED) {
-		return (u8_t *)fptr->data +
+		return (uint8_t *)fptr->data +
 		       (c - fptr->first_char) *
 		       (fptr->width * fptr->height / 8);
 	}
@@ -70,11 +65,11 @@ static inline u8_t *get_glyph_ptr(const struct cfb_font *fptr, char c)
  * Draw the monochrome character in the monochrome tiled framebuffer,
  * a byte is interpreted as 8 pixels ordered vertically among each other.
  */
-static u8_t draw_char_vtmono(const struct char_framebuffer *fb,
-			     char c, u16_t x, u16_t y)
+static uint8_t draw_char_vtmono(const struct char_framebuffer *fb,
+			     char c, uint16_t x, uint16_t y)
 {
 	const struct cfb_font *fptr = &(fb->fonts[fb->font_idx]);
-	u8_t *glyph_ptr;
+	uint8_t *glyph_ptr;
 
 	if (c < fptr->first_char || c > fptr->last_char) {
 		c = ' ';
@@ -86,10 +81,10 @@ static u8_t draw_char_vtmono(const struct char_framebuffer *fb,
 	}
 
 	for (size_t g_x = 0; g_x < fptr->width; g_x++) {
-		u32_t y_segment = y / 8;
+		uint32_t y_segment = y / 8;
 
 		for (size_t g_y = 0; g_y < fptr->height / 8; g_y++) {
-			u32_t fb_y = (y_segment + g_y) * fb->x_res;
+			uint32_t fb_y = (y_segment + g_y) * fb->x_res;
 
 			if ((fb_y + x + g_x) >= fb->size) {
 				return 0;
@@ -103,7 +98,7 @@ static u8_t draw_char_vtmono(const struct char_framebuffer *fb,
 	return fptr->width;
 }
 
-int cfb_print(struct device *dev, char *str, u16_t x, u16_t y)
+int cfb_print(struct os_dev *dev, char *str, uint16_t x, uint16_t y)
 {
 	const struct char_framebuffer *fb = &char_fb;
 	const struct cfb_font *fptr = &(fb->fonts[fb->font_idx]);
@@ -113,7 +108,7 @@ int cfb_print(struct device *dev, char *str, u16_t x, u16_t y)
 	}
 
 	if (fptr->height % 8) {
-		LOG_ERR("Wrong font size");
+		MODLOG_DFLT(ERROR, "Wrong font size");
 		return -1;
 	}
 
@@ -128,14 +123,14 @@ int cfb_print(struct device *dev, char *str, u16_t x, u16_t y)
 		return 0;
 	}
 
-	LOG_ERR("Unsupported framebuffer configuration");
+	MODLOG_DFLT(ERROR, "Unsupported framebuffer configuration");
 	return -1;
 }
 
 static int cfb_reverse_bytes(const struct char_framebuffer *fb)
 {
 	if (!(fb->screen_info & SCREEN_INFO_MONO_VTILED)) {
-		LOG_ERR("Unsupported framebuffer configuration");
+		MODLOG_DFLT(ERROR, "Unsupported framebuffer configuration");
 		return -1;
 	}
 
@@ -160,11 +155,12 @@ static int cfb_invert(const struct char_framebuffer *fb)
 	return 0;
 }
 
-int cfb_framebuffer_clear(struct device *dev, bool clear_display)
+int cfb_framebuffer_clear(struct os_dev *dev, bool clear_display)
 {
-	const struct display_driver_api *api = dev->driver_api;
+	const struct display_driver_api *api = dev->od_init_arg;
 	const struct char_framebuffer *fb = &char_fb;
 	struct display_buffer_descriptor desc;
+	int rc;
 
 	if (!fb || !fb->buf) {
 		return -1;
@@ -177,19 +173,31 @@ int cfb_framebuffer_clear(struct device *dev, bool clear_display)
 	memset(fb->buf, 0, fb->size);
 
 	if (clear_display && (fb->screen_info & SCREEN_INFO_EPD)) {
-		api->set_contrast(dev, 1);
-		api->write(dev, 0, 0, &desc, fb->buf);
-		api->set_contrast(dev, 0);
+		rc = api->set_contrast(dev, 1);
+		if (rc) {
+			return rc;
+		}
+
+		rc = api->write(dev, 0, 0, &desc, fb->buf);
+		if (rc) {
+			return rc;
+		}
+
+		rc = api->set_contrast(dev, 0);
+		if (rc) {
+			return rc;
+		}
 	}
 
 	return 0;
 }
 
-int cfb_framebuffer_finalize(struct device *dev)
+int cfb_framebuffer_finalize(struct os_dev *dev)
 {
-	const struct display_driver_api *api = dev->driver_api;
+	const struct display_driver_api *api = dev->od_init_arg;
 	const struct char_framebuffer *fb = &char_fb;
 	struct display_buffer_descriptor desc;
+	int rc;
 
 	if (!fb || !fb->buf) {
 		return -1;
@@ -208,10 +216,11 @@ int cfb_framebuffer_finalize(struct device *dev)
 		cfb_reverse_bytes(fb);
 	}
 
-	return api->write(dev, 0, 0, &desc, fb->buf);
+	rc = api->write(dev, 0, 0, &desc, fb->buf);
+	return rc;
 }
 
-int cfb_get_display_parameter(struct device *dev,
+int cfb_get_display_parameter(struct os_dev *dev,
 			       enum cfb_display_param param)
 {
 	const struct char_framebuffer *fb = &char_fb;
@@ -237,7 +246,7 @@ int cfb_get_display_parameter(struct device *dev,
 	return 0;
 }
 
-int cfb_framebuffer_set_font(struct device *dev, u8_t idx)
+int cfb_framebuffer_set_font(struct os_dev *dev, uint8_t idx)
 {
 	struct char_framebuffer *fb = &char_fb;
 
@@ -250,7 +259,8 @@ int cfb_framebuffer_set_font(struct device *dev, u8_t idx)
 	return 0;
 }
 
-int cfb_get_font_size(struct device *dev, u8_t idx, u8_t *width, u8_t *height)
+int cfb_get_font_size(struct os_dev *dev, uint8_t idx,
+		      uint8_t *width, uint8_t *height)
 {
 	const struct char_framebuffer *fb = &char_fb;
 
@@ -259,26 +269,27 @@ int cfb_get_font_size(struct device *dev, u8_t idx, u8_t *width, u8_t *height)
 	}
 
 	if (width) {
-		*width = __font_entry_start[idx].width;
+		*width = font_array[idx].width;
 	}
 
 	if (height) {
-		*height = __font_entry_start[idx].height;
+		*height = font_array[idx].height;
 	}
 
 	return 0;
 }
 
-int cfb_framebuffer_init(struct device *dev)
+int cfb_framebuffer_init(struct os_dev *dev)
 {
-	const struct display_driver_api *api = dev->driver_api;
+	const struct display_driver_api *api = dev->od_init_arg;
 	struct char_framebuffer *fb = &char_fb;
 	struct display_capabilities cfg;
 
 	api->get_capabilities(dev, &cfg);
 
-	fb->numof_fonts = __font_entry_end - __font_entry_start;
-	LOG_DBG("number of fonts %d", fb->numof_fonts);
+
+	fb->numof_fonts = (sizeof(font_array) / sizeof((font_array)[0]));
+	MODLOG_DFLT(DEBUG, "number of fonts %d", fb->numof_fonts);
 	if (!fb->numof_fonts) {
 		return -1;
 	}
@@ -293,11 +304,11 @@ int cfb_framebuffer_init(struct device *dev)
 	fb->kerning = 0;
 	fb->inverted = false;
 
-	fb->fonts = __font_entry_start;
+	fb->fonts = font_array;
 	fb->font_idx = 0;
 
 	fb->size = fb->x_res * fb->y_res / fb->ppt;
-	fb->buf = k_malloc(fb->size);
+	fb->buf = malloc(fb->size);
 	if (!fb->buf) {
 		return -1;
 	}
diff --git a/hw/drivers/display/cfb/src/cfb_fonts.c b/hw/drivers/display/cfb/src/cfb_fonts.c
index 47e0942..8138b80 100644
--- a/hw/drivers/display/cfb/src/cfb_fonts.c
+++ b/hw/drivers/display/cfb/src/cfb_fonts.c
@@ -8,13 +8,12 @@
  * Licensed under the Apache License, Version 2.0
  */
 
-#include <zephyr.h>
-#include <display/cfb.h>
+#include "display/cfb.h"
 
 #define CFB_FONTS_FIRST_CHAR	32
 #define CFB_FONTS_LAST_CHAR	127
 
-const u8_t cfb_font_1016[95][20] = {
+const uint8_t cfb_font_1016[95][20] = {
 	/*   */
 	{
 		0x00, 0x00,
@@ -1252,7 +1251,7 @@ const u8_t cfb_font_1016[95][20] = {
 	},
 };
 
-const u8_t cfb_font_1524[95][45] = {
+const uint8_t cfb_font_1524[95][45] = {
 	/*   */
 	{
 		0x00, 0x00, 0x00,
@@ -2965,7 +2964,7 @@ const u8_t cfb_font_1524[95][45] = {
 	},
 };
 
-const u8_t cfb_font_2032[95][80] = {
+const uint8_t cfb_font_2032[95][80] = {
 	/*   */
 	{
 		0x00, 0x00, 0x00, 0x00,
@@ -5153,27 +5152,30 @@ const u8_t cfb_font_2032[95][80] = {
 	},
 };
 
-FONT_ENTRY_DEFINE(font1016,
-		  10,
-		  16,
-		  CFB_FONT_MONO_VPACKED,
-		  cfb_font_1016,
-		  CFB_FONTS_FIRST_CHAR,
-		  CFB_FONTS_LAST_CHAR
-);
-FONT_ENTRY_DEFINE(font1524,
-		  15,
-		  24,
-		  CFB_FONT_MONO_VPACKED,
-		  cfb_font_1524,
-		  CFB_FONTS_FIRST_CHAR,
-		  CFB_FONTS_LAST_CHAR
-);
-FONT_ENTRY_DEFINE(font2032,
-		  20,
-		  32,
-		  CFB_FONT_MONO_VPACKED,
-		  cfb_font_2032,
-		  CFB_FONTS_FIRST_CHAR,
-		  CFB_FONTS_LAST_CHAR
-);
+const struct cfb_font font_array[CFB_FONTS_COUNT] = {
+	FONT_ENTRY_DEFINE(font2032,
+			  20,
+			  32,
+			  CFB_FONT_MONO_VPACKED,
+			  cfb_font_2032,
+			  CFB_FONTS_FIRST_CHAR,
+			  CFB_FONTS_LAST_CHAR
+	),
+	FONT_ENTRY_DEFINE(font1524,
+			  15,
+			  24,
+			  CFB_FONT_MONO_VPACKED,
+			  cfb_font_1524,
+			  CFB_FONTS_FIRST_CHAR,
+			  CFB_FONTS_LAST_CHAR
+	),
+	FONT_ENTRY_DEFINE(font1016,
+			  10,
+			  16,
+			  CFB_FONT_MONO_VPACKED,
+			  cfb_font_1016,
+			  CFB_FONTS_FIRST_CHAR,
+			  CFB_FONTS_LAST_CHAR
+	),
+};
+
diff --git a/hw/drivers/display/include/display/display.h b/hw/drivers/display/include/display/display.h
index 82dc695..435b7e1 100644
--- a/hw/drivers/display/include/display/display.h
+++ b/hw/drivers/display/include/display/display.h
@@ -19,18 +19,16 @@
  * @{
  */
 
-#include <device.h>
-#include <stddef.h>
-#include <zephyr/types.h>
+#include "os/mynewt.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 enum display_pixel_format {
-	PIXEL_FORMAT_RGB_888		= BIT(0),
-	PIXEL_FORMAT_MONO01		= BIT(1), /* 0=Black 1=White */
-	PIXEL_FORMAT_MONO10		= BIT(2), /* 1=Black 0=White */
+	PIXEL_FORMAT_RGB_888		= (1UL << 0),
+	PIXEL_FORMAT_MONO01		= (1UL << 1), /* 0=Black 1=White */
+	PIXEL_FORMAT_MONO10		= (1UL << 2), /* 1=Black 0=White */
 };
 
 enum display_screen_info {
@@ -38,16 +36,16 @@ enum display_screen_info {
 	 * If selected, one octet represents 8 pixels ordered vertically,
 	 * otherwise ordered horizontally.
 	 */
-	SCREEN_INFO_MONO_VTILED		= BIT(0),
+	SCREEN_INFO_MONO_VTILED		= (1UL << 0),
 	/**
 	 * If selected, the MSB represents the first pixel,
 	 * otherwise MSB represents the last pixel.
 	 */
-	SCREEN_INFO_MONO_MSB_FIRST	= BIT(1),
+	SCREEN_INFO_MONO_MSB_FIRST	= (1UL << 1),
 	/**
 	 * Electrophoretic Display.
 	 */
-	SCREEN_INFO_EPD			= BIT(2),
+	SCREEN_INFO_EPD			= (1UL << 2),
 };
 
 /**
@@ -86,10 +84,10 @@ enum display_orientation {
  *
  */
 struct display_capabilities {
-	u16_t x_resolution;
-	u16_t y_resolution;
-	u32_t supported_pixel_formats;
-	u32_t screen_info;
+	uint16_t x_resolution;
+	uint16_t y_resolution;
+	uint32_t supported_pixel_formats;
+	uint32_t screen_info;
 	enum display_pixel_format current_pixel_format;
 	enum display_orientation current_orientation;
 };
@@ -112,10 +110,10 @@ struct display_capabilities {
  *
  */
 struct display_buffer_descriptor {
-	u32_t buf_size;
-	u16_t width;
-	u16_t height;
-	u16_t pitch;
+	uint32_t buf_size;
+	uint16_t width;
+	uint16_t height;
+	uint16_t pitch;
 };
 
 /**
@@ -123,22 +121,22 @@ struct display_buffer_descriptor {
  * @brief Callback API to turn on display blanking
  * See display_blanking_on() for argument description
  */
-typedef int (*display_blanking_on_api)(const struct device *dev);
+typedef int (*display_blanking_on_api)(const struct os_dev *dev);
 
 /**
  * @typedef display_blanking_off_api
  * @brief Callback API to turn off display blanking
  * See display_blanking_off() for argument description
  */
-typedef int (*display_blanking_off_api)(const struct device *dev);
+typedef int (*display_blanking_off_api)(const struct os_dev *dev);
 
 /**
  * @typedef display_write_api
  * @brief Callback API for writing data to the display
  * See display_write() for argument description
  */
-typedef int (*display_write_api)(const struct device *dev, const u16_t x,
-				 const u16_t y,
+typedef int (*display_write_api)(const struct os_dev *dev, const uint16_t x,
+				 const uint16_t y,
 				 const struct display_buffer_descriptor *desc,
 				 const void *buf);
 
@@ -147,8 +145,8 @@ typedef int (*display_write_api)(const struct device *dev, const u16_t x,
  * @brief Callback API for reading data from the display
  * See display_read() for argument description
  */
-typedef int (*display_read_api)(const struct device *dev, const u16_t x,
-				const u16_t y,
+typedef int (*display_read_api)(const struct os_dev *dev, const uint16_t x,
+				const uint16_t y,
 				const struct display_buffer_descriptor *desc,
 				void *buf);
 
@@ -157,30 +155,30 @@ typedef int (*display_read_api)(const struct device *dev, const u16_t x,
  * @brief Callback API to get framebuffer pointer
  * See display_get_framebuffer() for argument description
  */
-typedef void *(*display_get_framebuffer_api)(const struct device *dev);
+typedef void *(*display_get_framebuffer_api)(const struct os_dev *dev);
 
 /**
  * @typedef display_set_brightness_api
  * @brief Callback API to set display brightness
  * See display_set_brightness() for argument description
  */
-typedef int (*display_set_brightness_api)(const struct device *dev,
-					  const u8_t brightness);
+typedef int (*display_set_brightness_api)(const struct os_dev *dev,
+					  const uint8_t brightness);
 
 /**
  * @typedef display_set_contrast_api
  * @brief Callback API to set display contrast
  * See display_set_contrast() for argument description
  */
-typedef int (*display_set_contrast_api)(const struct device *dev,
-					const u8_t contrast);
+typedef int (*display_set_contrast_api)(const struct os_dev *dev,
+					const uint8_t contrast);
 
 /**
  * @typedef display_get_capabilities_api
  * @brief Callback API to get display capabilities
  * See display_get_capabilities() for argument description
  */
-typedef void (*display_get_capabilities_api)(const struct device *dev,
+typedef void (*display_get_capabilities_api)(const struct os_dev *dev,
 					     struct display_capabilities *
 					     capabilities);
 
@@ -189,7 +187,7 @@ typedef void (*display_get_capabilities_api)(const struct device *dev,
  * @brief Callback API to set pixel format used by the display
  * See display_set_pixel_format() for argument description
  */
-typedef int (*display_set_pixel_format_api)(const struct device *dev,
+typedef int (*display_set_pixel_format_api)(const struct os_dev *dev,
 					    const enum display_pixel_format
 					    pixel_format);
 
@@ -198,7 +196,7 @@ typedef int (*display_set_pixel_format_api)(const struct device *dev,
  * @brief Callback API to set orientation used by the display
  * See display_set_orientation() for argument description
  */
-typedef int (*display_set_orientation_api)(const struct device *dev,
+typedef int (*display_set_orientation_api)(const struct os_dev *dev,
 					   const enum display_orientation
 					   orientation);
 
@@ -230,13 +228,13 @@ struct display_driver_api {
  *
  * @retval 0 on success else negative errno code.
  */
-static inline int display_write(const struct device *dev, const u16_t x,
-				const u16_t y,
+static inline int display_write(const struct os_dev *dev, const uint16_t x,
+				const uint16_t y,
 				const struct display_buffer_descriptor *desc,
 				const void *buf)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	return api->write(dev, x, y, desc, buf);
 }
@@ -252,13 +250,13 @@ static inline int display_write(const struct device *dev, const u16_t x,
  *
  * @retval 0 on success else negative errno code.
  */
-static inline int display_read(const struct device *dev, const u16_t x,
-			       const u16_t y,
+static inline int display_read(const struct os_dev *dev, const uint16_t x,
+			       const uint16_t y,
 			       const struct display_buffer_descriptor *desc,
 			       void *buf)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	return api->read(dev, x, y, desc, buf);
 }
@@ -272,10 +270,10 @@ static inline int display_read(const struct device *dev, const u16_t x,
  * is not supported
  *
  */
-static inline void *display_get_framebuffer(const struct device *dev)
+static inline void *display_get_framebuffer(const struct os_dev *dev)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	return api->get_framebuffer(dev);
 }
@@ -287,10 +285,10 @@ static inline void *display_get_framebuffer(const struct device *dev)
  *
  * @retval 0 on success else negative errno code.
  */
-static inline int display_blanking_on(const struct device *dev)
+static inline int display_blanking_on(const struct os_dev *dev)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	return api->blanking_on(dev);
 }
@@ -302,10 +300,10 @@ static inline int display_blanking_on(const struct device *dev)
  *
  * @retval 0 on success else negative errno code.
  */
-static inline int display_blanking_off(const struct device *dev)
+static inline int display_blanking_off(const struct os_dev *dev)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	return api->blanking_off(dev);
 }
@@ -321,11 +319,11 @@ static inline int display_blanking_off(const struct device *dev)
  *
  * @retval 0 on success else negative errno code.
  */
-static inline int display_set_brightness(const struct device *dev,
-					 u8_t brightness)
+static inline int display_set_brightness(const struct os_dev *dev,
+					 uint8_t brightness)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	return api->set_brightness(dev, brightness);
 }
@@ -341,10 +339,11 @@ static inline int display_set_brightness(const struct device *dev,
  *
  * @retval 0 on success else negative errno code.
  */
-static inline int display_set_contrast(const struct device *dev, u8_t contrast)
+static inline int display_set_contrast(const struct os_dev *dev,
+				       uint8_t contrast)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	return api->set_contrast(dev, contrast);
 }
@@ -355,12 +354,12 @@ static inline int display_set_contrast(const struct device *dev, u8_t contrast)
  * @param dev Pointer to device structure
  * @param capabilities Pointer to capabilities structure to populate
  */
-static inline void display_get_capabilities(const struct device *dev,
+static inline void display_get_capabilities(const struct os_dev *dev,
 					    struct display_capabilities *
 					    capabilities)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	api->get_capabilities(dev, capabilities);
 }
@@ -374,11 +373,11 @@ static inline void display_get_capabilities(const struct device *dev,
  * @retval 0 on success else negative errno code.
  */
 static inline int
-display_set_pixel_format(const struct device *dev,
+display_set_pixel_format(const struct os_dev *dev,
 			 const enum display_pixel_format pixel_format)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	return api->set_pixel_format(dev, pixel_format);
 }
@@ -391,12 +390,12 @@ display_set_pixel_format(const struct device *dev,
  *
  * @retval 0 on success else negative errno code.
  */
-static inline int display_set_orientation(const struct device *dev,
+static inline int display_set_orientation(const struct os_dev *dev,
 					  const enum display_orientation
 					  orientation)
 {
 	struct display_driver_api *api =
-		(struct display_driver_api *)dev->driver_api;
+		(struct display_driver_api *)dev->od_init_arg;
 
 	return api->set_orientation(dev, orientation);
 }
diff --git a/hw/drivers/display/pkg.yml b/hw/drivers/display/pkg.yml
new file mode 100644
index 0000000..7524fd1
--- /dev/null
+++ b/hw/drivers/display/pkg.yml
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: hw/drivers/display
+pkg.description: Display Drivers
+pkg.author: "Apache Mynewt <de...@mynewt.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
diff --git a/hw/drivers/display/ssd1673/pkg.yml b/hw/drivers/display/ssd1673/pkg.yml
new file mode 100644
index 0000000..3d20952
--- /dev/null
+++ b/hw/drivers/display/ssd1673/pkg.yml
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: hw/drivers/display/ssd1673
+pkg.description: SSD1673 Display Drivers
+pkg.author: "Apache Mynewt <de...@mynewt.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.deps:
+    - "@apache-mynewt-core/kernel/os"
+    - "@apache-mynewt-core/hw/hal"
+    - "@apache-mynewt-core/sys/log/modlog"
+
+pkg.init:
+    ssd1673_pkg_init: 601
diff --git a/hw/drivers/display/ssd1673/src/ssd1673.c b/hw/drivers/display/ssd1673/src/ssd1673.c
index 3d4b290..710174b 100644
--- a/hw/drivers/display/ssd1673/src/ssd1673.c
+++ b/hw/drivers/display/ssd1673/src/ssd1673.c
@@ -4,19 +4,17 @@
  * SPDX-License-Identifier: Apache-2.0
  */
 
-#define LOG_LEVEL CONFIG_DISPLAY_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(ssd1673);
+#include <stdint.h>
 
-#include <string.h>
-#include <device.h>
-#include <display.h>
-#include <init.h>
-#include <gpio.h>
-#include <spi.h>
+#include "os/mynewt.h"
+#include "hal/hal_gpio.h"
+#include "hal/hal_spi.h"
+#include "modlog/modlog.h"
+
+#include "display/display.h"
+#include "display/cfb.h"
 
 #include "ssd1673_regs.h"
-#include <display/cfb.h>
 
 #define EPD_PANEL_WIDTH			250
 #define EPD_PANEL_HEIGHT		120
@@ -31,76 +29,87 @@ LOG_MODULE_REGISTER(ssd1673);
 #define SSD1673_PANEL_LAST_GATE		249
 
 struct ssd1673_data {
-	struct device *reset;
-	struct device *dc;
-	struct device *busy;
-	struct device *spi_dev;
-	struct spi_config spi_config;
-#if defined(CONFIG_SSD1673_SPI_GPIO_CS)
-	struct spi_cs_control cs_ctrl;
-#endif
-	u8_t contrast;
-	u8_t scan_mode;
-	u8_t last_lut;
-	u8_t numof_part_cycles;
+	struct display_driver_api driver_api;
+	struct hal_spi_settings spi_config;
+	uint8_t contrast;
+	uint8_t scan_mode;
+	uint8_t last_lut;
+	uint8_t numof_part_cycles;
 };
 
+static struct ssd1673_data ssd1673_driver;
+static struct os_dev ssd1673;
+
 #define SSD1673_LAST_LUT_INITIAL		0
 #define SSD1673_LAST_LUT_DEFAULT		255
 #define SSD1673_LUT_SIZE			29
 
-static u8_t ssd1673_lut_initial[SSD1673_LUT_SIZE] = {
+static uint8_t ssd1673_lut_initial[SSD1673_LUT_SIZE] = {
 	0x22, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x11,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
 	0x01, 0x00, 0x00, 0x00, 0x00
 };
 
-static u8_t ssd1673_lut_default[SSD1673_LUT_SIZE] = {
+static uint8_t ssd1673_lut_default[SSD1673_LUT_SIZE] = {
 	0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00, 0x00
 };
 
+#define SSD1673_BUSY_DELAY_TICKS os_time_ms_to_ticks32(SSD1673_BUSY_DELAY)
+#define SSD1673_RESET_DELAY_TICKS os_time_ms_to_ticks32(SSD1673_RESET_DELAY)
+
+#define CONFIG_SSD1673_OS_DEV_NAME	MYNEWT_VAL(SSD1673_OS_DEV_NAME)
+#define CONFIG_SSD1673_BUSY_PIN		MYNEWT_VAL(SSD1673_BUSY_PIN)
+#define CONFIG_SSD1673_RESET_PIN	MYNEWT_VAL(SSD1673_RESET_PIN)
+#define CONFIG_SSD1673_DC_PIN		MYNEWT_VAL(SSD1673_DC_PIN)
+#define CONFIG_SSD1673_CS_PIN		MYNEWT_VAL(SSD1673_CS_PIN)
+#define CONFIG_SSD1673_SPI_FREQ		MYNEWT_VAL(SSD1673_SPI_FREQ)
+#define CONFIG_SSD1673_SPI_DEV		MYNEWT_VAL(SSD1673_SPI_DEV)
+
 static inline int ssd1673_write_cmd(struct ssd1673_data *driver,
-				    u8_t cmd, u8_t *data, size_t len)
+				    uint8_t cmd, uint8_t *data, size_t len)
 {
-	struct spi_buf buf = {.buf = &cmd, .len = sizeof(cmd)};
-	struct spi_buf_set buf_set = {.buffers = &buf, .count = 1};
+	hal_gpio_write(CONFIG_SSD1673_DC_PIN, 0);
+	hal_gpio_write(CONFIG_SSD1673_CS_PIN, 0);
 
-	gpio_pin_write(driver->dc, CONFIG_SSD1673_DC_PIN, 0);
-	if (spi_write(driver->spi_dev, &driver->spi_config, &buf_set)) {
+	if (hal_spi_txrx(CONFIG_SSD1673_SPI_DEV,
+			 &cmd, NULL, sizeof(cmd))) {
+		hal_gpio_write(CONFIG_SSD1673_CS_PIN, 1);
 		return -1;
 	}
 
 	if (data != NULL) {
-		buf.buf = data;
-		buf.len = len;
-		gpio_pin_write(driver->dc, CONFIG_SSD1673_DC_PIN, 1);
-		if (spi_write(driver->spi_dev, &driver->spi_config, &buf_set)) {
+		hal_gpio_write(CONFIG_SSD1673_DC_PIN, 1);
+		if (hal_spi_txrx(CONFIG_SSD1673_SPI_DEV,
+				 data, NULL, len)) {
+			hal_gpio_write(CONFIG_SSD1673_CS_PIN, 1);
 			return -1;
 		}
 	}
 
+	hal_gpio_write(CONFIG_SSD1673_CS_PIN, 1);
 	return 0;
 }
 
 static inline void ssd1673_busy_wait(struct ssd1673_data *driver)
 {
-	u32_t val = 0;
+	int val = 0;
 
-	gpio_pin_read(driver->busy, CONFIG_SSD1673_BUSY_PIN, &val);
+	val = hal_gpio_read(CONFIG_SSD1673_BUSY_PIN);
 	while (val) {
-		k_busy_wait(SSD1673_BUSY_DELAY);
-		gpio_pin_read(driver->busy, CONFIG_SSD1673_BUSY_PIN, &val);
+		os_cputime_delay_ticks(SSD1673_BUSY_DELAY_TICKS);
+		val = hal_gpio_read(CONFIG_SSD1673_BUSY_PIN);
 	};
 }
 
 static inline int ssd1673_set_ram_param(struct ssd1673_data *driver,
-					u8_t sx, u8_t ex, u8_t sy, u8_t ey)
+					uint8_t sx, uint8_t ex,
+					uint8_t sy, uint8_t ey)
 {
-	u8_t tmp[2];
+	uint8_t tmp[2];
 
 	tmp[0] = sx; tmp[1] = ex;
 	if (ssd1673_write_cmd(driver, SSD1673_CMD_RAM_XPOS_CTRL,
@@ -118,7 +127,7 @@ static inline int ssd1673_set_ram_param(struct ssd1673_data *driver,
 }
 
 static inline int ssd1673_set_ram_ptr(struct ssd1673_data *driver,
-				       u8_t x, u8_t y)
+				       uint8_t x, uint8_t y)
 {
 	if (ssd1673_write_cmd(driver, SSD1673_CMD_RAM_XPOS_CNTR,
 			      &x, sizeof(x))) {
@@ -143,10 +152,10 @@ static inline void ssd1673_set_orientation(struct ssd1673_data *driver)
 #endif
 }
 
-int ssd1673_resume(const struct device *dev)
+int ssd1673_resume(const struct os_dev *dev)
 {
-	struct ssd1673_data *driver = dev->driver_data;
-	u8_t tmp;
+	struct ssd1673_data *driver = dev->od_init_arg;
+	uint8_t tmp;
 
 	/*
 	 * Uncomment for voltage measurement
@@ -160,19 +169,19 @@ int ssd1673_resume(const struct device *dev)
 				 &tmp, sizeof(tmp));
 }
 
-static int ssd1673_suspend(const struct device *dev)
+static int ssd1673_suspend(const struct os_dev *dev)
 {
-	struct ssd1673_data *driver = dev->driver_data;
-	u8_t tmp = SSD1673_SLEEP_MODE_DSM;
+	struct ssd1673_data *driver = dev->od_init_arg;
+	uint8_t tmp = SSD1673_SLEEP_MODE_DSM;
 
 	return ssd1673_write_cmd(driver, SSD1673_CMD_SLEEP_MODE,
 				 &tmp, sizeof(tmp));
 }
 
-static int ssd1673_update_display(const struct device *dev, bool initial)
+static int ssd1673_update_display(const struct os_dev *dev, bool initial)
 {
-	struct ssd1673_data *driver = dev->driver_data;
-	u8_t tmp;
+	struct ssd1673_data *driver = dev->od_init_arg;
+	uint8_t tmp;
 
 	tmp = SSD1673_CTRL1_INITIAL_UPDATE_LH;
 	if (ssd1673_write_cmd(driver, SSD1673_CMD_UPDATE_CTRL1,
@@ -219,35 +228,33 @@ static int ssd1673_update_display(const struct device *dev, bool initial)
 	return 0;
 }
 
-static int ssd1673_write(const struct device *dev, const u16_t x,
-			 const u16_t y,
+static int ssd1673_write(const struct os_dev *dev, const uint16_t x,
+			 const uint16_t y,
 			 const struct display_buffer_descriptor *desc,
 			 const void *buf)
 {
-	struct ssd1673_data *driver = dev->driver_data;
-	u8_t cmd = SSD1673_CMD_WRITE_RAM;
-	u8_t dummy_page[SSD1673_RAM_YRES];
-	struct spi_buf sbuf = {.buf = &cmd, .len = 1};
-	struct spi_buf_set buf_set = {.buffers = &sbuf, .count = 1};
+	struct ssd1673_data *driver = dev->od_init_arg;
+	uint8_t cmd = SSD1673_CMD_WRITE_RAM;
+	uint8_t dummy_page[SSD1673_RAM_YRES];
 	bool update = true;
 
 	if (desc->pitch < desc->width) {
-		LOG_ERR("Pitch is smaller then width");
+		MODLOG_DFLT(ERROR, "Pitch is smaller then width");
 		return -1;
 	}
 
 	if (buf == NULL || desc->buf_size == 0) {
-		LOG_ERR("Display buffer is not available");
+		MODLOG_DFLT(ERROR, "Display buffer is not available");
 		return -1;
 	}
 
 	if (desc->pitch > desc->width) {
-		LOG_ERR("Unsupported mode");
+		MODLOG_DFLT(ERROR, "Unsupported mode");
 		return -1;
 	}
 
 	if (x != 0 && y != 0) {
-		LOG_ERR("Unsupported origin");
+		MODLOG_DFLT(ERROR, "Unsupported origin");
 		return -1;
 	}
 
@@ -298,36 +305,40 @@ static int ssd1673_write(const struct device *dev, const u16_t x,
 		return -1;
 	}
 
-	gpio_pin_write(driver->dc, CONFIG_SSD1673_DC_PIN, 0);
-	if (spi_write(driver->spi_dev, &driver->spi_config, &buf_set)) {
+	hal_gpio_write(CONFIG_SSD1673_DC_PIN, 0);
+	hal_gpio_write(CONFIG_SSD1673_CS_PIN, 0);
+
+	if (hal_spi_txrx(CONFIG_SSD1673_SPI_DEV, &cmd, NULL, sizeof(cmd))) {
+		hal_gpio_write(CONFIG_SSD1673_CS_PIN, 1);
 		return -1;
 	}
 
-	gpio_pin_write(driver->dc, CONFIG_SSD1673_DC_PIN, 1);
+	hal_gpio_write(CONFIG_SSD1673_DC_PIN, 1);
 	/* clear unusable page */
 	if (driver->scan_mode == SSD1673_DATA_ENTRY_XDYIY) {
-		sbuf.buf = dummy_page;
-		sbuf.len = sizeof(dummy_page);
-		if (spi_write(driver->spi_dev, &driver->spi_config, &buf_set)) {
+		if (hal_spi_txrx(CONFIG_SSD1673_SPI_DEV, dummy_page,
+				 NULL, sizeof(dummy_page))) {
+			hal_gpio_write(CONFIG_SSD1673_CS_PIN, 1);
 			return -1;
 		}
 	}
 
-	sbuf.buf = (u8_t *)buf;
-	sbuf.len = desc->buf_size;
-	if (spi_write(driver->spi_dev, &driver->spi_config, &buf_set)) {
+	if (hal_spi_txrx(CONFIG_SSD1673_SPI_DEV, (uint8_t *)buf,
+			 NULL, desc->buf_size)) {
+		hal_gpio_write(CONFIG_SSD1673_CS_PIN, 1);
 		return -1;
 	}
 
 	/* clear unusable page */
 	if (driver->scan_mode == SSD1673_DATA_ENTRY_XIYDY) {
-		sbuf.buf = dummy_page;
-		sbuf.len = sizeof(dummy_page);
-		if (spi_write(driver->spi_dev, &driver->spi_config, &buf_set)) {
+		if (hal_spi_txrx(CONFIG_SSD1673_SPI_DEV, dummy_page,
+				 NULL, sizeof(dummy_page))) {
+			hal_gpio_write(CONFIG_SSD1673_CS_PIN, 1);
 			return -1;
 		}
 	}
 
+	hal_gpio_write(CONFIG_SSD1673_CS_PIN, 1);
 
 	if (update) {
 		if (driver->contrast) {
@@ -339,38 +350,38 @@ static int ssd1673_write(const struct device *dev, const u16_t x,
 	return 0;
 }
 
-static int ssd1673_read(const struct device *dev, const u16_t x,
-			const u16_t y,
+static int ssd1673_read(const struct os_dev *dev, const uint16_t x,
+			const uint16_t y,
 			const struct display_buffer_descriptor *desc,
 			void *buf)
 {
-	LOG_ERR("not supported");
-	return -ENOTSUP;
+	MODLOG_DFLT(ERROR, "not supported");
+	return -1;
 }
 
-static void *ssd1673_get_framebuffer(const struct device *dev)
+static void *ssd1673_get_framebuffer(const struct os_dev *dev)
 {
-	LOG_ERR("not supported");
+	MODLOG_DFLT(ERROR, "not supported");
 	return NULL;
 }
 
-static int ssd1673_set_brightness(const struct device *dev,
-				  const u8_t brightness)
+static int ssd1673_set_brightness(const struct os_dev *dev,
+				  const uint8_t brightness)
 {
-	LOG_WRN("not supported");
-	return -ENOTSUP;
+	MODLOG_DFLT(WARN, "not supported");
+	return -1;
 }
 
-static int ssd1673_set_contrast(const struct device *dev, u8_t contrast)
+static int ssd1673_set_contrast(const struct os_dev *dev, uint8_t contrast)
 {
-	struct ssd1673_data *driver = dev->driver_data;
+	struct ssd1673_data *driver = dev->od_init_arg;
 
 	driver->contrast = contrast;
 
 	return 0;
 }
 
-static void ssd1673_get_capabilities(const struct device *dev,
+static void ssd1673_get_capabilities(const struct os_dev *dev,
 				     struct display_capabilities *caps)
 {
 	memset(caps, 0, sizeof(struct display_capabilities));
@@ -383,24 +394,24 @@ static void ssd1673_get_capabilities(const struct device *dev,
 			    SCREEN_INFO_EPD;
 }
 
-static int ssd1673_set_pixel_format(const struct device *dev,
+static int ssd1673_set_pixel_format(const struct os_dev *dev,
 				    const enum display_pixel_format pf)
 {
-	LOG_ERR("not supported");
-	return -ENOTSUP;
+	MODLOG_DFLT(ERROR, "not supported");
+	return -1;
 }
 
-static int ssd1673_controller_init(struct device *dev)
+static int ssd1673_controller_init(struct os_dev *dev)
 {
-	struct ssd1673_data *driver = dev->driver_data;
-	u8_t tmp[3];
+	struct ssd1673_data *driver = dev->od_init_arg;
+	uint8_t tmp[3];
 
-	LOG_DBG("");
+	MODLOG_DFLT(DEBUG, "");
 
-	gpio_pin_write(driver->reset, CONFIG_SSD1673_RESET_PIN, 0);
-	k_sleep(SSD1673_RESET_DELAY);
-	gpio_pin_write(driver->reset, CONFIG_SSD1673_RESET_PIN, 1);
-	k_sleep(SSD1673_RESET_DELAY);
+	hal_gpio_write(CONFIG_SSD1673_RESET_PIN, 0);
+	os_time_delay(SSD1673_RESET_DELAY_TICKS);
+	hal_gpio_write(CONFIG_SSD1673_RESET_PIN, 1);
+	os_time_delay(SSD1673_RESET_DELAY_TICKS);
 	ssd1673_busy_wait(driver);
 
 	if (ssd1673_write_cmd(driver, SSD1673_CMD_SW_RESET, NULL, 0)) {
@@ -448,85 +459,56 @@ static int ssd1673_controller_init(struct device *dev)
 	return 0;
 }
 
-static int ssd1673_init(struct device *dev)
+static int ssd1673_init(struct os_dev *dev, void *arg)
 {
-	struct ssd1673_data *driver = dev->driver_data;
-
-	LOG_DBG("");
-
-	driver->spi_dev = device_get_binding(CONFIG_SSD1673_SPI_DEV_NAME);
-	if (driver->spi_dev == NULL) {
-		LOG_ERR("Could not get SPI device for SSD1673");
-		return -EIO;
-	}
-
-	driver->spi_config.frequency = CONFIG_SSD1673_SPI_FREQ;
-	driver->spi_config.operation = SPI_OP_MODE_MASTER | SPI_WORD_SET(8);
-	driver->spi_config.slave = CONFIG_SSD1673_SPI_SLAVE_NUMBER;
-	driver->spi_config.cs = NULL;
-
-	driver->reset = device_get_binding(CONFIG_SSD1673_RESET_GPIO_PORT_NAME);
-	if (driver->reset == NULL) {
-		LOG_ERR("Could not get GPIO port for SSD1673 reset");
-		return -EIO;
-	}
-
-	gpio_pin_configure(driver->reset, CONFIG_SSD1673_RESET_PIN,
-			   GPIO_DIR_OUT);
-
-	driver->dc = device_get_binding(CONFIG_SSD1673_DC_GPIO_PORT_NAME);
-	if (driver->dc == NULL) {
-		LOG_ERR("Could not get GPIO port for SSD1673 DC signal");
-		return -EIO;
-	}
-
-	gpio_pin_configure(driver->dc, CONFIG_SSD1673_DC_PIN,
-			   GPIO_DIR_OUT);
-
-	driver->busy = device_get_binding(CONFIG_SSD1673_BUSY_GPIO_PORT_NAME);
-	if (driver->busy == NULL) {
-		LOG_ERR("Could not get GPIO port for SSD1673 busy signal");
-		return -EIO;
-	}
-
-	gpio_pin_configure(driver->busy, CONFIG_SSD1673_BUSY_PIN,
-			   GPIO_DIR_IN);
-
-#if defined(CONFIG_SSD1673_SPI_GPIO_CS)
-	driver->cs_ctrl.gpio_dev = device_get_binding(
-		CONFIG_SSD1673_SPI_GPIO_CS_DRV_NAME);
-	if (!driver->cs_ctrl.gpio_dev) {
-		LOG_ERR("Unable to get SPI GPIO CS device");
-		return -EIO;
-	}
-
-	driver->cs_ctrl.gpio_pin = CONFIG_SSD1673_SPI_GPIO_CS_PIN;
-	driver->cs_ctrl.delay = 0;
-	driver->spi_config.cs = &driver->cs_ctrl;
-#endif
+	struct ssd1673_data *driver = dev->od_init_arg;
+	int rc;
+
+	MODLOG_DFLT(DEBUG, "");
+
+	driver->spi_config.baudrate = CONFIG_SSD1673_SPI_FREQ;
+	driver->spi_config.data_mode = HAL_SPI_MODE0;
+	driver->spi_config.data_order = HAL_SPI_MSB_FIRST;
+	driver->spi_config.word_size = HAL_SPI_WORD_SIZE_8BIT;
+	rc = hal_spi_config(0, &driver->spi_config);
+	assert(rc == 0);
+
+	driver->driver_api.blanking_on = ssd1673_resume,
+	driver->driver_api.blanking_off = ssd1673_suspend,
+	driver->driver_api.write = ssd1673_write,
+	driver->driver_api.read = ssd1673_read,
+	driver->driver_api.get_framebuffer = ssd1673_get_framebuffer,
+	driver->driver_api.set_brightness = ssd1673_set_brightness,
+	driver->driver_api.set_contrast = ssd1673_set_contrast,
+	driver->driver_api.get_capabilities = ssd1673_get_capabilities,
+	driver->driver_api.set_pixel_format = ssd1673_set_pixel_format,
+	driver->driver_api.set_orientation = NULL,
+
+	rc = hal_gpio_init_out(CONFIG_SSD1673_RESET_PIN, 1);
+	assert(rc == 0);
+	rc = hal_gpio_init_out(CONFIG_SSD1673_DC_PIN, 1);
+	assert(rc == 0);
+	rc = hal_gpio_init_out(CONFIG_SSD1673_CS_PIN, 1);
+	assert(rc == 0);
+	rc = hal_gpio_init_in(CONFIG_SSD1673_BUSY_PIN, HAL_GPIO_PULL_NONE);
+	assert(rc == 0);
 
 	ssd1673_controller_init(dev);
 
 	return 0;
 }
 
-static struct ssd1673_data ssd1673_driver;
+int ssd1673_pkg_init(void)
+{
+	int rc;
 
-static struct display_driver_api ssd1673_driver_api = {
-	.blanking_on = ssd1673_resume,
-	.blanking_off = ssd1673_suspend,
-	.write = ssd1673_write,
-	.read = ssd1673_read,
-	.get_framebuffer = ssd1673_get_framebuffer,
-	.set_brightness = ssd1673_set_brightness,
-	.set_contrast = ssd1673_set_contrast,
-	.get_capabilities = ssd1673_get_capabilities,
-	.set_pixel_format = ssd1673_set_pixel_format,
-	.set_orientation = NULL,
-};
+	/* Ensure this function only gets called by sysinit. */
+	SYSINIT_ASSERT_ACTIVE();
 
+	rc = os_dev_create(&ssd1673, CONFIG_SSD1673_OS_DEV_NAME,
+			   OS_DEV_INIT_SECONDARY, OS_DEV_INIT_PRIO_DEFAULT,
+			   ssd1673_init, &ssd1673_driver);
+	SYSINIT_PANIC_ASSERT(rc == 0);
 
-DEVICE_AND_API_INIT(ssd1673, CONFIG_SSD1673_DEV_NAME, ssd1673_init,
-		    &ssd1673_driver, NULL,
-		    POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY,
-		    &ssd1673_driver_api);
+	return 0;
+}
diff --git a/hw/drivers/display/ssd1673/syscfg.yml b/hw/drivers/display/ssd1673/syscfg.yml
new file mode 100644
index 0000000..0649f69
--- /dev/null
+++ b/hw/drivers/display/ssd1673/syscfg.yml
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+syscfg.defs:
+    SSD1673_OS_DEV_NAME:
+        description: 'os_dev device name for SSD1673'
+        value: '"ssd1673"'
+
+    SSD1673_BUSY_PIN:
+        description: 'BUSY pin for SSD1673'
+        value:
+        restrictions:
+        - $notnull
+
+    SSD1673_RESET_PIN:
+        description: 'RESET pin for SSD1673'
+        value:
+        restrictions:
+        - $notnull
+
+    SSD1673_DC_PIN:
+        description: 'DC pin for SSD1673'
+        value:
+        restrictions:
+        - $notnull
+
+    SSD1673_CS_PIN:
+        description: 'CS pin for SSD1673'
+        value:
+        restrictions:
+        - $notnull
+
+    SSD1673_SPI_DEV:
+        description: 'SPI device for SSD1673'
+        value:
+        restrictions:
+        - $notnull
+
+    SSD1673_SPI_FREQ:
+        description: 'SPI frequency for SSD1673 in kHz; Max frequency is 5MHz'
+        value: 4000
+