Skip to content

Commit ed22cee

Browse files
lkundrakdtor
authored andcommitted
Input: olpc_apsp - enable the SP clock
Without the clock, the keyboard controller won't operate. Tested on an OLPC XO 1.75. Signed-off-by: Lubomir Rintel <[email protected]> Acked-by: Pavel Machek <[email protected]> Reviewed-by: Rob Herring <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent af51834 commit ed22cee

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Documentation/devicetree/bindings/serio/olpc,ap-sp.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ Required properties:
44
- compatible : "olpc,ap-sp"
55
- reg : base address and length of SoC's WTM registers
66
- interrupts : SP-AP interrupt
7+
- clocks : phandle + clock-specifier for the clock that drives the WTM
8+
- clock-names: should be "sp"
79

810
Example:
911
ap-sp@d4290000 {
1012
compatible = "olpc,ap-sp";
1113
reg = <0xd4290000 0x1000>;
1214
interrupts = <40>;
15+
clocks = <&soc_clocks MMP2_CLK_SP>;
16+
clock-names = "sp";
1317
}

drivers/input/serio/olpc_apsp.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/of.h>
2424
#include <linux/slab.h>
2525
#include <linux/delay.h>
26+
#include <linux/clk.h>
2627

2728
/*
2829
* The OLPC XO-1.75 and XO-4 laptops do not have a hardware PS/2 controller.
@@ -74,6 +75,7 @@ struct olpc_apsp {
7475
struct serio *kbio;
7576
struct serio *padio;
7677
void __iomem *base;
78+
struct clk *clk;
7779
int open_count;
7880
int irq;
7981
};
@@ -146,11 +148,17 @@ static int olpc_apsp_open(struct serio *port)
146148
struct olpc_apsp *priv = port->port_data;
147149
unsigned int tmp;
148150
unsigned long l;
151+
int error;
149152

150153
if (priv->open_count++ == 0) {
154+
error = clk_prepare_enable(priv->clk);
155+
if (error)
156+
return error;
157+
151158
l = readl(priv->base + COMMAND_FIFO_STATUS);
152159
if (!(l & CMD_STS_MASK)) {
153160
dev_err(priv->dev, "SP cannot accept commands.\n");
161+
clk_disable_unprepare(priv->clk);
154162
return -EIO;
155163
}
156164

@@ -171,6 +179,8 @@ static void olpc_apsp_close(struct serio *port)
171179
/* Disable interrupt 0 */
172180
tmp = readl(priv->base + PJ_INTERRUPT_MASK);
173181
writel(tmp | INT_0, priv->base + PJ_INTERRUPT_MASK);
182+
183+
clk_disable_unprepare(priv->clk);
174184
}
175185
}
176186

@@ -198,6 +208,10 @@ static int olpc_apsp_probe(struct platform_device *pdev)
198208
if (priv->irq < 0)
199209
return priv->irq;
200210

211+
priv->clk = devm_clk_get(&pdev->dev, "sp");
212+
if (IS_ERR(priv->clk))
213+
return PTR_ERR(priv->clk);
214+
201215
/* KEYBOARD */
202216
kb_serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
203217
if (!kb_serio)

0 commit comments

Comments
 (0)