linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes
@ 2018-11-12  2:30 Lubomir Rintel
  2018-11-12  2:30 ` [PATCH v2 1/6] dt-bindings: olpc,ap-sp: add clock Lubomir Rintel
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Lubomir Rintel @ 2018-11-12  2:30 UTC (permalink / raw)
  To: Dmitry Torokhov, Michael Turquette, Stephen Boyd, linux-input
  Cc: linux-kernel, linux-clk, devicetree, Rob Herring, Mark Rutland,
	Lubomir Rintel

This makes keyboard/touchpad work on a DT MMP2 platform.

Changes since v1:
- Collected Acks
- Replaced "Input: olpc_apsp: depend on CONFIG_OF" patch with "Input:
  olpc_apsp: drop CONFIG_OLPC dependency", since it was correctly
  pointed out that the driver doesn't actually depend on OF.
- Dropped "Input: olpc_apsp: allocate the GPIOs used" and "dt-bindings:
  olpc,ap-sp: add GPIO lines" since at the moment they are not useful
  for much more than documenting the lines the SP uses and actually
  claiming them was deemed not to be a good idea.
- Fixed error handling in the "enable the SP clock" patch.

Cheers
Lubo



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/6] dt-bindings: olpc,ap-sp: add clock
  2018-11-12  2:30 [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Lubomir Rintel
@ 2018-11-12  2:30 ` Lubomir Rintel
  2018-11-12  2:30 ` [PATCH v2 2/6] dt-bindings: marvell,mmp2: Add clock id for the SP clock Lubomir Rintel
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Lubomir Rintel @ 2018-11-12  2:30 UTC (permalink / raw)
  To: Dmitry Torokhov, Michael Turquette, Stephen Boyd, linux-input
  Cc: linux-kernel, linux-clk, devicetree, Rob Herring, Mark Rutland,
	Lubomir Rintel

The clock is necessary for the device operation, hence it's required.
Its name, "sp", stands for "Security Processor". It is one of several
names that are used for the processor that serves as the keyboard
controller on an OLPC and is consistent with the node name.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
 Documentation/devicetree/bindings/serio/olpc,ap-sp.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/serio/olpc,ap-sp.txt b/Documentation/devicetree/bindings/serio/olpc,ap-sp.txt
index 0e72183f52bc..36603419d6f8 100644
--- a/Documentation/devicetree/bindings/serio/olpc,ap-sp.txt
+++ b/Documentation/devicetree/bindings/serio/olpc,ap-sp.txt
@@ -4,10 +4,14 @@ Required properties:
 - compatible : "olpc,ap-sp"
 - reg : base address and length of SoC's WTM registers
 - interrupts : SP-AP interrupt
+- clocks : phandle + clock-specifier for the clock that drives the WTM
+- clock-names:  should be "sp"
 
 Example:
 	ap-sp@d4290000 {
 		compatible = "olpc,ap-sp";
 		reg = <0xd4290000 0x1000>;
 		interrupts = <40>;
+		clocks = <&soc_clocks MMP2_CLK_SP>;
+		clock-names = "sp";
 	}
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/6] dt-bindings: marvell,mmp2: Add clock id for the SP clock
  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 ` Lubomir Rintel
  2018-11-12  2:30 ` [PATCH v2 3/6] clk: mmp2: add " Lubomir Rintel
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Lubomir Rintel @ 2018-11-12  2:30 UTC (permalink / raw)
  To: Dmitry Torokhov, Michael Turquette, Stephen Boyd, linux-input
  Cc: linux-kernel, linux-clk, devicetree, Rob Herring, Mark Rutland,
	Lubomir Rintel

This is the clock for the "security processor" core.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
 include/dt-bindings/clock/marvell,mmp2.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/dt-bindings/clock/marvell,mmp2.h b/include/dt-bindings/clock/marvell,mmp2.h
index 228a5e234af0..7b24fc791146 100644
--- a/include/dt-bindings/clock/marvell,mmp2.h
+++ b/include/dt-bindings/clock/marvell,mmp2.h
@@ -71,6 +71,7 @@
 #define MMP2_CLK_CCIC1_MIX		117
 #define MMP2_CLK_CCIC1_PHY		118
 #define MMP2_CLK_CCIC1_SPHY		119
+#define MMP2_CLK_SP			120
 
 #define MMP2_NR_CLKS			200
 #endif
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/6] clk: mmp2: add SP clock
  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 ` Lubomir Rintel
  2018-11-12  2:30 ` [PATCH v2 4/6] Input: olpc_apsp: drop CONFIG_OLPC dependency Lubomir Rintel
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Lubomir Rintel @ 2018-11-12  2:30 UTC (permalink / raw)
  To: Dmitry Torokhov, Michael Turquette, Stephen Boyd, linux-input
  Cc: linux-kernel, linux-clk, devicetree, Rob Herring, Mark Rutland,
	Lubomir Rintel

The "security processor", sometimes referred to as "wireless trusted
module" or "generic encrypt unit" is a low-power core present on MMP2,
that has nothing to do with security, wireless, trust or encryption.

On an OLPC machine it runs CForth and serves as a keyboard controller:
http://dev.laptop.org/git/users/wmb/cforth/tree/src/app/arm-xo-1.75/ps2.fth

The register address was obtained from the OLPC kernel, since the
datasheet seems to be the Marvell's most important business secret.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
 drivers/clk/mmp/clk-of-mmp2.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/clk/mmp/clk-of-mmp2.c b/drivers/clk/mmp/clk-of-mmp2.c
index d083b860f083..61fefc046ec5 100644
--- a/drivers/clk/mmp/clk-of-mmp2.c
+++ b/drivers/clk/mmp/clk-of-mmp2.c
@@ -53,6 +53,7 @@
 #define APMU_DISP1	0x110
 #define APMU_CCIC0	0x50
 #define APMU_CCIC1	0xf4
+#define APMU_SP		0x68
 #define MPMU_UART_PLL	0x14
 
 struct mmp2_clk_unit {
@@ -209,6 +210,8 @@ static struct mmp_clk_mix_config ccic1_mix_config = {
 	.reg_info = DEFINE_MIX_REG_INFO(4, 16, 2, 6, 32),
 };
 
+static DEFINE_SPINLOCK(sp_lock);
+
 static struct mmp_param_mux_clk apmu_mux_clks[] = {
 	{MMP2_CLK_DISP0_MUX, "disp0_mux", disp_parent_names, ARRAY_SIZE(disp_parent_names), CLK_SET_RATE_PARENT, APMU_DISP0, 6, 2, 0, &disp0_lock},
 	{MMP2_CLK_DISP1_MUX, "disp1_mux", disp_parent_names, ARRAY_SIZE(disp_parent_names), CLK_SET_RATE_PARENT, APMU_DISP1, 6, 2, 0, &disp1_lock},
@@ -239,6 +242,7 @@ static struct mmp_param_gate_clk apmu_gate_clks[] = {
 	{MMP2_CLK_CCIC1, "ccic1_clk", "ccic1_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC1, 0x1b, 0x1b, 0x0, 0, &ccic1_lock},
 	{MMP2_CLK_CCIC1_PHY, "ccic1_phy_clk", "ccic1_mix_clk", CLK_SET_RATE_PARENT, APMU_CCIC1, 0x24, 0x24, 0x0, 0, &ccic1_lock},
 	{MMP2_CLK_CCIC1_SPHY, "ccic1_sphy_clk", "ccic1_sphy_div", CLK_SET_RATE_PARENT, APMU_CCIC1, 0x300, 0x300, 0x0, 0, &ccic1_lock},
+	{MMP2_CLK_SP, "sp_clk", NULL, CLK_SET_RATE_PARENT, APMU_SP, 0x1b, 0x1b, 0x0, 0, &sp_lock},
 };
 
 static void mmp2_axi_periph_clk_init(struct mmp2_clk_unit *pxa_unit)
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 4/6] Input: olpc_apsp: drop CONFIG_OLPC dependency
  2018-11-12  2:30 [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Lubomir Rintel
                   ` (2 preceding siblings ...)
  2018-11-12  2:30 ` [PATCH v2 3/6] clk: mmp2: add " Lubomir Rintel
@ 2018-11-12  2:30 ` Lubomir Rintel
  2018-11-12  2:30 ` [PATCH v2 5/6] Input: olpc_apsp: check FIFO status on open(), not probe() Lubomir Rintel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Lubomir Rintel @ 2018-11-12  2:30 UTC (permalink / raw)
  To: Dmitry Torokhov, Michael Turquette, Stephen Boyd, linux-input
  Cc: linux-kernel, linux-clk, devicetree, Rob Herring, Mark Rutland,
	Lubomir Rintel

CONFIG_OLPC is specific to the x86 platform code, while the driver is for
an ARM-based laptop.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Pavel Machek <pavel@ucw.cz>
---
 drivers/input/serio/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index d90d9f1098ff..c9c7224d5ae0 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -254,7 +254,6 @@ config SERIO_APBPS2
 
 config SERIO_OLPC_APSP
 	tristate "OLPC AP-SP input support"
-	depends on OLPC || COMPILE_TEST
 	help
 	  Say Y here if you want support for the keyboard and touchpad included
 	  in the OLPC XO-1.75 and XO-4 laptops.
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 5/6] Input: olpc_apsp: check FIFO status on open(), not probe()
  2018-11-12  2:30 [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Lubomir Rintel
                   ` (3 preceding siblings ...)
  2018-11-12  2:30 ` [PATCH v2 4/6] Input: olpc_apsp: drop CONFIG_OLPC dependency Lubomir Rintel
@ 2018-11-12  2:30 ` Lubomir Rintel
  2018-11-12  2:30 ` [PATCH v2 6/6] Input: olpc_apsp: enable the SP clock Lubomir Rintel
  2018-11-15 19:15 ` [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Dmitry Torokhov
  6 siblings, 0 replies; 8+ messages in thread
From: Lubomir Rintel @ 2018-11-12  2:30 UTC (permalink / raw)
  To: Dmitry Torokhov, Michael Turquette, Stephen Boyd, linux-input
  Cc: linux-kernel, linux-clk, devicetree, Rob Herring, Mark Rutland,
	Lubomir Rintel

Let's defer the FIFO status checking until open().

When we'll get a clk handle, this will allow us to defer clock enablement
until the device is actually used.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 drivers/input/serio/olpc_apsp.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/input/serio/olpc_apsp.c b/drivers/input/serio/olpc_apsp.c
index 8e9a4209fcad..8b19a47dfa46 100644
--- a/drivers/input/serio/olpc_apsp.c
+++ b/drivers/input/serio/olpc_apsp.c
@@ -145,8 +145,15 @@ static int olpc_apsp_open(struct serio *port)
 {
 	struct olpc_apsp *priv = port->port_data;
 	unsigned int tmp;
+	unsigned long l;
 
 	if (priv->open_count++ == 0) {
+		l = readl(priv->base + COMMAND_FIFO_STATUS);
+		if (!(l & CMD_STS_MASK)) {
+			dev_err(priv->dev, "SP cannot accept commands.\n");
+			return -EIO;
+		}
+
 		/* Enable interrupt 0 by clearing its bit */
 		tmp = readl(priv->base + PJ_INTERRUPT_MASK);
 		writel(tmp & ~INT_0, priv->base + PJ_INTERRUPT_MASK);
@@ -173,7 +180,6 @@ static int olpc_apsp_probe(struct platform_device *pdev)
 	struct olpc_apsp *priv;
 	struct resource *res;
 	struct device_node *np;
-	unsigned long l;
 	int error;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(struct olpc_apsp), GFP_KERNEL);
@@ -192,12 +198,6 @@ static int olpc_apsp_probe(struct platform_device *pdev)
 	if (priv->irq < 0)
 		return priv->irq;
 
-	l = readl(priv->base + COMMAND_FIFO_STATUS);
-	if (!(l & CMD_STS_MASK)) {
-		dev_err(&pdev->dev, "SP cannot accept commands.\n");
-		return -EIO;
-	}
-
 	/* KEYBOARD */
 	kb_serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
 	if (!kb_serio)
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 6/6] Input: olpc_apsp: enable the SP clock
  2018-11-12  2:30 [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Lubomir Rintel
                   ` (4 preceding siblings ...)
  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
  2018-11-15 19:15 ` [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Dmitry Torokhov
  6 siblings, 0 replies; 8+ messages in thread
From: Lubomir Rintel @ 2018-11-12  2:30 UTC (permalink / raw)
  To: Dmitry Torokhov, Michael Turquette, Stephen Boyd, linux-input
  Cc: linux-kernel, linux-clk, devicetree, Rob Herring, Mark Rutland,
	Lubomir Rintel

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes
  2018-11-12  2:30 [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Lubomir Rintel
                   ` (5 preceding siblings ...)
  2018-11-12  2:30 ` [PATCH v2 6/6] Input: olpc_apsp: enable the SP clock Lubomir Rintel
@ 2018-11-15 19:15 ` Dmitry Torokhov
  6 siblings, 0 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2018-11-15 19:15 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: Michael Turquette, Stephen Boyd, linux-input, linux-kernel,
	linux-clk, devicetree, Rob Herring, Mark Rutland

On Mon, Nov 12, 2018 at 03:30:23AM +0100, Lubomir Rintel wrote:
> This makes keyboard/touchpad work on a DT MMP2 platform.
> 
> Changes since v1:
> - Collected Acks
> - Replaced "Input: olpc_apsp: depend on CONFIG_OF" patch with "Input:
>   olpc_apsp: drop CONFIG_OLPC dependency", since it was correctly
>   pointed out that the driver doesn't actually depend on OF.
> - Dropped "Input: olpc_apsp: allocate the GPIOs used" and "dt-bindings:
>   olpc,ap-sp: add GPIO lines" since at the moment they are not useful
>   for much more than documenting the lines the SP uses and actually
>   claiming them was deemed not to be a good idea.
> - Fixed error handling in the "enable the SP clock" patch.

Applied the series, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-11-15 19:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 6/6] Input: olpc_apsp: enable the SP clock Lubomir Rintel
2018-11-15 19:15 ` [PATCH v2 0/6] OLPC 1.75 Keyboard/Touchpad fixes Dmitry Torokhov

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).