linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roger Shimizu <rogershimizu@gmail.com>
To: Sebastian Reichel <sre@kernel.org>,
	linux-pm@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>
Cc: Roger Shimizu <rogershimizu@gmail.com>,
	Ryan Tandy <ryan@nardis.ca>, Martin Michlmayr <tbm@cyrius.com>,
	Sylver Bruneau <sylver.bruneau@googlemail.com>,
	Herbert Valerio Riedel <hvr@gnu.org>
Subject: [PATCH 2/3] power: reset: make qnap-poweroff flexible on length of power-off command
Date: Mon,  5 Dec 2016 21:45:27 +0900	[thread overview]
Message-ID: <20161205124528.2999-3-rogershimizu@gmail.com> (raw)
In-Reply-To: <20161205124528.2999-1-rogershimizu@gmail.com>

Current power-off command sending to UART1 is fixed to one-byte.
In order to support more devices, it's necessary to make power-off
command as 2-D array argument of device configuration.

By using 2-D array, power-off command may consist a few commands, each
of which may consist a few bytes.

Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
---
 drivers/power/reset/qnap-poweroff.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/power/reset/qnap-poweroff.c b/drivers/power/reset/qnap-poweroff.c
index 47ed120..644478c 100644
--- a/drivers/power/reset/qnap-poweroff.c
+++ b/drivers/power/reset/qnap-poweroff.c
@@ -25,6 +25,7 @@
 #include <linux/clk.h>
 
 #define UART1_REG(x)	(base + ((UART_##x) << 2))
+#define MICON_CMD_SIZE	4
 
 /* 4-byte magic hello command to UART1-attached microcontroller */
 static const unsigned char qnap_micon_magic[] = {
@@ -34,22 +35,33 @@ static const unsigned char qnap_micon_magic[] = {
 	0x00
 };
 
+// for each row, first byte is the size of command
+static const unsigned char qnap_power_off_cmd[][MICON_CMD_SIZE] = {
+	{ 1, 'A'},
+	{}
+};
+
+static const unsigned char synology_power_off_cmd[][MICON_CMD_SIZE] = {
+	{ 1, '1'},
+	{}
+};
+
 struct power_off_cfg {
 	u32 baud;
 	const unsigned char *magic;
-	char cmd;
+	const unsigned char (*cmd)[MICON_CMD_SIZE];
 };
 
 static const struct power_off_cfg qnap_power_off_cfg = {
 	.baud = 19200,
 	.magic = qnap_micon_magic,
-	.cmd = 'A',
+	.cmd = qnap_power_off_cmd,
 };
 
 static const struct power_off_cfg synology_power_off_cfg = {
 	.baud = 9600,
 	.magic = qnap_micon_magic,
-	.cmd = '1',
+	.cmd = synology_power_off_cmd,
 };
 
 static const struct of_device_id qnap_power_off_of_match_table[] = {
@@ -83,7 +95,10 @@ static void qnap_power_off(void)
 	writel(cfg->magic[3], UART1_REG(MCR));
 
 	/* send the power-off command to PIC */
-	writel(cfg->cmd, UART1_REG(TX));
+	if(cfg->cmd[0][0] == 1 && cfg->cmd[1][0] == 0) {
+		/* for qnap and synology, it's simply one-byte command */
+		writel(cfg->cmd[0][1], UART1_REG(TX));
+	}
 }
 
 static int qnap_power_off_probe(struct platform_device *pdev)
-- 
2.10.2


  parent reply	other threads:[~2016-12-05 12:45 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-05 12:45 [PATCH 0/3] make kurobox-pro be able to shutdown after device-tree migration Roger Shimizu
2016-12-05 12:45 ` [PATCH 1/3] power: reset: make qnap-poweroff flexible on hello magic command to uart1 Roger Shimizu
2016-12-05 12:45 ` Roger Shimizu [this message]
2016-12-05 12:45 ` [PATCH 3/3] power: reset: make qnap-poweroff support kurobox-pro Roger Shimizu
2016-12-06 17:34 ` [PATCH 0/3] make kurobox-pro be able to shutdown after device-tree migration Andrew Lunn
2016-12-07 17:24   ` [PATCH v1 " Roger Shimizu
2016-12-07 17:24     ` [PATCH v1 1/3] power: reset: make qnap-poweroff flexible on hello magic command to uart1 Roger Shimizu
2016-12-07 17:24     ` [PATCH v1 2/3] power: reset: make qnap-poweroff flexible on length of power-off command Roger Shimizu
2016-12-07 17:24     ` [PATCH v1 3/3] power: reset: make qnap-poweroff support kurobox-pro Roger Shimizu
2016-12-07 18:04     ` [PATCH v1 0/3] make kurobox-pro be able to shutdown after device-tree migration Andrew Lunn
2016-12-16 10:05     ` [PATCH v2] power: reset: add linkstation-reset driver Roger Shimizu
2016-12-19  0:34       ` Roger Shimizu
2016-12-19 15:38       ` Sebastian Reichel
2016-12-19 16:03         ` Andrew Lunn
2016-12-19 16:12           ` Roger Shimizu
2016-12-19 17:37         ` Roger Shimizu
     [not found]           ` <CAEQ9gEnQEHdcA4ox3teOXKcrdf2AAqUMp=A6W6c7nXhk4VrKiw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-21 15:59             ` Sebastian Reichel
2016-12-21 16:41               ` Andrew Lunn
     [not found]                 ` <20161221164136.GM30952-g2DYL2Zd6BY@public.gmane.org>
2016-12-22 14:49                   ` Sebastian Reichel
2016-12-26 16:13                     ` Roger Shimizu
2016-12-27  7:06       ` [PATCH v3 0/3] make kurobox-pro be able to shutdown after device-tree migration Roger Shimizu
2016-12-27  7:06         ` [PATCH v3 1/3] power: reset: add linkstation-reset driver Roger Shimizu
     [not found]           ` <20161227070611.14852-2-rogershimizu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-03  5:19             ` Florian Fainelli
2017-01-03 13:09               ` Andrew Lunn
2017-01-03 14:08                 ` Roger Shimizu
     [not found]                   ` <CAEQ9gE=MoQcr3eX0DAxZtvx0FW9pzgkUGjdxKHcsKwH7_+UsUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-03 18:39                     ` Florian Fainelli
2016-12-27  7:06         ` [PATCH v3 2/3] DT: bingdings: power: reset: add linkstation-reset doc Roger Shimizu
2017-01-03  5:21           ` Florian Fainelli
2017-01-03 13:12             ` Andrew Lunn
2017-01-03 14:11               ` Roger Shimizu
2017-01-03 17:09           ` Rob Herring
2017-01-06 12:18             ` Roger Shimizu
2016-12-27  7:06         ` [PATCH v3 3/3] ARM: DT: add power-off support to linkstation lsgl and kuroboxpro Roger Shimizu
2017-01-07 15:04         ` [PATCH v4 0/2] make kurobox-pro be able to shutdown after device-tree migration Roger Shimizu
     [not found]           ` <20170107150451.17912-1-rogershimizu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-01-07 15:04             ` [PATCH v4 1/2] power: reset: add linkstation-reset driver Roger Shimizu
2017-01-08 17:02               ` Ryan Tandy
2017-01-09  3:31                 ` Roger Shimizu
2017-01-09  5:43                   ` Ryan Tandy
2017-01-18 12:08               ` Roger Shimizu
2017-01-19  4:43                 ` Sebastian Reichel
2017-01-26 15:28                   ` Gregory CLEMENT
2017-01-26 15:33                     ` Roger Shimizu
2017-01-27  9:15                       ` Gregory CLEMENT
2017-01-07 15:04             ` [PATCH v4 2/2] ARM: DT: add power-off support to linkstation lsgl and kuroboxpro Roger Shimizu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161205124528.2999-3-rogershimizu@gmail.com \
    --to=rogershimizu@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=hvr@gnu.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=ryan@nardis.ca \
    --cc=sre@kernel.org \
    --cc=sylver.bruneau@googlemail.com \
    --cc=tbm@cyrius.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).