From: Lubomir Rintel <lkundrak@v3.sk>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Lubomir Rintel <lkundrak@v3.sk>
Subject: [PATCH v2 6/6] Input: olpc_apsp: enable the SP clock
Date: Mon, 12 Nov 2018 03:30:29 +0100 [thread overview]
Message-ID: <20181112023029.648408-7-lkundrak@v3.sk> (raw)
In-Reply-To: <20181112023029.648408-1-lkundrak@v3.sk>
Without the clock, the keyboard controller won't operate.
Tested on an OLPC XO 1.75.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
Changes since v1:
- Disable the clock in error handling path
drivers/input/serio/olpc_apsp.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/input/serio/olpc_apsp.c b/drivers/input/serio/olpc_apsp.c
index 8b19a47dfa46..91d6fb8d7d8d 100644
--- a/drivers/input/serio/olpc_apsp.c
+++ b/drivers/input/serio/olpc_apsp.c
@@ -23,6 +23,7 @@
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/delay.h>
+#include <linux/clk.h>
/*
* The OLPC XO-1.75 and XO-4 laptops do not have a hardware PS/2 controller.
@@ -74,6 +75,7 @@ struct olpc_apsp {
struct serio *kbio;
struct serio *padio;
void __iomem *base;
+ struct clk *clk;
int open_count;
int irq;
};
@@ -146,11 +148,17 @@ static int olpc_apsp_open(struct serio *port)
struct olpc_apsp *priv = port->port_data;
unsigned int tmp;
unsigned long l;
+ int error;
if (priv->open_count++ == 0) {
+ error = clk_prepare_enable(priv->clk);
+ if (error)
+ return error;
+
l = readl(priv->base + COMMAND_FIFO_STATUS);
if (!(l & CMD_STS_MASK)) {
dev_err(priv->dev, "SP cannot accept commands.\n");
+ clk_disable_unprepare(priv->clk);
return -EIO;
}
@@ -171,6 +179,8 @@ static void olpc_apsp_close(struct serio *port)
/* Disable interrupt 0 */
tmp = readl(priv->base + PJ_INTERRUPT_MASK);
writel(tmp | INT_0, priv->base + PJ_INTERRUPT_MASK);
+
+ clk_disable_unprepare(priv->clk);
}
}
@@ -198,6 +208,10 @@ static int olpc_apsp_probe(struct platform_device *pdev)
if (priv->irq < 0)
return priv->irq;
+ priv->clk = devm_clk_get(&pdev->dev, "sp");
+ if (IS_ERR(priv->clk))
+ return PTR_ERR(priv->clk);
+
/* KEYBOARD */
kb_serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
if (!kb_serio)
--
2.19.1
next prev parent reply other threads:[~2018-11-12 2:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-12 2:30 [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Lubomir Rintel
2018-11-12 2:30 ` [PATCH v2 1/6] dt-bindings: olpc,ap-sp: add clock Lubomir Rintel
2018-11-12 2:30 ` [PATCH v2 2/6] dt-bindings: marvell,mmp2: Add clock id for the SP clock Lubomir Rintel
2018-11-12 2:30 ` [PATCH v2 3/6] clk: mmp2: add " Lubomir Rintel
2018-11-12 2:30 ` [PATCH v2 4/6] Input: olpc_apsp: drop CONFIG_OLPC dependency Lubomir Rintel
2018-11-12 2:30 ` [PATCH v2 5/6] Input: olpc_apsp: check FIFO status on open(), not probe() Lubomir Rintel
2018-11-12 2:30 ` Lubomir Rintel [this message]
2018-11-15 19:15 ` [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Dmitry Torokhov
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=20181112023029.648408-7-lkundrak@v3.sk \
--to=lkundrak@v3.sk \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mturquette@baylibre.com \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
/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