Skip to contentSkip to conversation

Support for seven segment display

PATCH Superseded Jaghathiswari Rankappagounder Natarajan 2 participants 5 messages Oct 31, 2016 – Nov 1, 2016

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

The are 3 patches included:

The first patch is a character device driver which implements the user-space API for letting a user write to the display including any conversion methods necessary to map the user input to a 7-segment display.

The second patch is a platform device driver which provides an API for displaying on a 7-segment display, and implements the required bit-banging. The hardware assumed is 74HC164 wired to two 7-segment displays.

The third patch adds clock, data and clear signal lines to control seven segment display on zaius platform

Please provide feedback.

Thanks,
Jagha

#1 lore raw

PATCH v3 1/3 drivers: misc: Character driver for seven segment display

The character device driver implements the user-space API for letting a user write to the display including any conversion methods necessary to map the user input to a 7-segment display.

---
 drivers/misc/Kconfig          |   5 ++
 drivers/misc/Makefile         |   1 +
 drivers/misc/seven_seg_disp.c | 200 ++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/seven_seg_disp.h |  35 ++++++++
 4 files changed, 241 insertions(+)
 create mode 100644 drivers/misc/seven_seg_disp.c
 create mode 100644 drivers/misc/seven_seg_disp.h
drivers/misc/Kconfig +5 -0
index 4617ddc..cf07817 100644
@@ -804,6 +804,11 @@ config PANEL_BOOT_MESSAGE
 	  An empty message will only clear the display at driver init time. Any other
 	  printf()-formatted message is valid with newline and escape codes.
 
+config SEVEN_SEGMENT_DISPLAY
+	tristate "Character driver for seven segment display support"
+	help
+	  Character driver for seven segment display support
+
 config ASPEED_BT_IPMI_HOST
 	tristate "BT IPMI host driver"
 	help
drivers/misc/Makefile +1 -0
index 724861b..f2072b1 100644
@@ -57,4 +57,5 @@ obj-$(CONFIG_ECHO)		+= echo/
 obj-$(CONFIG_VEXPRESS_SYSCFG)	+= vexpress-syscfg.o
 obj-$(CONFIG_CXL_BASE)		+= cxl/
 obj-$(CONFIG_PANEL)             += panel.o
+obj-$(SEVEN_SEGMENT_DISPLAY)	+= seven_seg_disp.o
 obj-$(CONFIG_ASPEED_BT_IPMI_HOST)	+= bt-host.o
drivers/misc/seven_seg_disp.c new file +200 -0

200 lines not on this page · raw message

drivers/misc/seven_seg_disp.h new file +35 -0
new file mode 100644
index 0000000..13ac780
@@ -0,0 +1,35 @@
+/*
+ * Seven segment display support
+ * * Copyright (c) 2016 Google, Inc
+ *
+ * * This program is free software; you can redistribute it and/or modify
+ * * it under the terms of the GNU General Public License version 2 as
+ * * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef SEVEN_SEG_DISP_H
+#define SEVEN_SEG_DISP_H
+
+#include <linux/device.h>
+#include <linux/cdev.h>
+
+#define MAX_DISP_CHAR_SIZE 3
+
+#define DEFAULT_REFRESH_INTERVAL 1000
+
+struct seven_seg_disp_dev {
+	u16 current_seven_seg_disp_data;
+	char seven_seg_disp_data_array[MAX_DISP_CHAR_SIZE];
+	struct device parent;
+	struct device *dev;
+	struct cdev cdev;
+	void (*update_seven_seg_data)(struct device *, u16 data);
+};
+
+int seven_seg_setup_cdev(struct seven_seg_disp_dev *disp_dev,
+	void (*update_disp_data)(struct device *, u16 data));
+
+void seven_seg_rem_cdev(struct seven_seg_disp_dev *disp_dev);
+
+#endif

--
2.8.0.rc3.226.g39d4020

#2 lore raw

PATCH v3 2/3 drivers: misc: Platform driver for seven segment display

In reply to Jaghathiswari Rankappagounder Natarajan

Platform driver provides an API for displaying on a 7-segment display, and implements the required bit-banging.

---
 .../bindings/misc/seven_segment_disp.txt           |  23 +++
 drivers/misc/Kconfig                               |   7 +
 drivers/misc/Makefile                              |   2 +
 drivers/misc/seven_seg_gpio.c                      | 225 +++++++++++++++++++++
 4 files changed, 257 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/seven_segment_disp.txt
 create mode 100644 drivers/misc/seven_seg_gpio.c
Documentation/devicetree/bindings/misc/seven_segment_disp.txt new file +23 -0
new file mode 100644
index 0000000..9c01b97
@@ -0,0 +1,23 @@
+Seven segment display support connected to GPIO lines
+
+Required properties:
+- compatible : should be "seven-seg-gpio-dev".
+- clock-gpios :  Should specify the GPIO pin connected to the Clock line on the hardware.
+- data-gpios : Should specify the GPIO pin connected to Data line on the hardware.
+- clear-gpios : Should specify the GPIO pin connected to Clear line on the hardware.
+
+Optional properties:
+- refresh-interval-ms : The interval at which to refresh the display.
+  If this property is not present, the default value is 1000.
+
+Examples:
+
+#include <dt-bindings/gpio/gpio.h>
+
+seven-seg-disp {
+	compatible = "seven-seg-gpio-dev";
+	refresh-interval-ms = "1000";
+	clock-gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
+	data-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>;
+	clear-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
+};
drivers/misc/Kconfig +7 -0
index cf07817..7adb9e3 100644
@@ -814,6 +814,13 @@ config ASPEED_BT_IPMI_HOST
 	help
 	  Support for the Aspeed BT ipmi host.
 
+config SEVEN_SEGMENT_GPIO
+	tristate "Platform driver to update seven segment display"
+	depends on SEVEN_SEGMENT_DISPLAY
+	help
+	  Support to periodically update display on two seven segment displays.
+	  The hardware assumed is 74HC164 wired to two seven segment displays.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +2 -0
index f2072b1..dddde19 100644
@@ -59,3 +59,5 @@ obj-$(CONFIG_CXL_BASE)		+= cxl/
 obj-$(CONFIG_PANEL)             += panel.o
 obj-$(SEVEN_SEGMENT_DISPLAY)	+= seven_seg_disp.o
 obj-$(CONFIG_ASPEED_BT_IPMI_HOST)	+= bt-host.o
+obj-$(SEVEN_SEGMENT_GPIO)	+= seven_seg_gpio.o
+
drivers/misc/seven_seg_gpio.c new file +225 -0

225 lines not on this page · raw message

--
2.8.0.rc3.226.g39d4020

#3 lore raw

PATCH v3 3/3 devicetree: Add devicetree changes to support seven segment display on zaius

In reply to Jaghathiswari Rankappagounder Natarajan

Add clock, data and clear signal lines to control seven segment display on zaius platform

---
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts +9 -1
index 4c4754b..cdead36 100644
@@ -1,7 +1,7 @@
 /dts-v1/;
 
 #include "aspeed-g5.dtsi"
-
+#include <dt-bindings/gpio/aspeed-gpio.h>
 / {
 	model = "Zaius BMC";
 	compatible = "ingrasys,zaius-bmc", "aspeed,ast2500";
@@ -58,6 +58,14 @@
 			};
 		};
 	};
+
+	seven-seg-disp {
+		compatible = "seven-seg-gpio-dev";
+		refresh-interval-ms = "1000";
+		clock-gpios = <&gpio ASPEED_GPIO(J, 0) GPIO_ACTIVE_HIGH>;
+		data-gpios = <&gpio ASPEED_GPIO(J, 2) GPIO_ACTIVE_HIGH>;
+		clear-gpios = <&gpio ASPEED_GPIO(J, 1) GPIO_ACTIVE_HIGH>;
+	};
 };
 
 &uart5 {

--
2.8.0.rc3.226.g39d4020

maintainer
#4 lore raw
In reply to Jaghathiswari Rankappagounder Natarajan

Hey Jagha,

Quoted 1 line · Jaghathiswari Rankappagounder Natarajan

The are 3 patches included:

Git provides some nice features when you generate your patches to send. One of them is --cover-letter, which generates a template for this first email you're sending.

git format-patch [email protected] [email protected] -v 3 --cover-letter -o mypatch-v3 origin/master

This will create patches for all the commits between HEAD and origin/master, with a cover letter, and place them in a directory called mypatch-v3. The cover letter is just a template; you can fill out the subject line and the contents.

You can then use git send-email to send them:

git send-email mypatch-v3/*.patch

Quoted 3 lines

The first patch is a character device driver which implements the user-space API for letting a user write to the display including any conversion methods necessary to map the user input to a 7-segment display.

I haven't had a chance to take a close look at your patches. Are you sure you've addressed all of the review from Rick? I can spot a few things that have not changed that he pointed out.

When reviewing via email, you can chose to reply to all of the points that your reivewier has made. This is a great idea when starting a new project as it forces you to think about each comment.

You should certainly include a changelog between versions. In individual patches you can place some text below the cut line (the -- marker), like this:

v1:
- Fixed checkpatch errors
- Reworked init fuction as suggested by Larry

v2:
- Changed camel case to kernel style

You can use a similar format in the cover letter to describe changes that affect the entire series, or higher level things.

I suggest having a read of this:

https://www.kernel.org/doc/Documentation/SubmittingPatches

I also suggest finding other people in your office who have worked on the upstream kernel for advice.

Cheers,

Joel

Quoted 12 lines

The second patch is a platform device driver which provides an API for displaying on a 7-segment display, and implements the required bit-banging. The hardware assumed is 74HC164 wired to two 7-segment displays.

The third patch adds clock, data and clear signal lines to control seven segment display on zaius platform

Please provide feedback.

Thanks,
Jagha