.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * OLPC serio driver for multiplexed input from Marvell MMP security processor |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2011-2013 One Laptop Per Child |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #include <linux/module.h> |
---|
.. | .. |
---|
145 | 136 | { |
---|
146 | 137 | struct olpc_apsp *priv = port->port_data; |
---|
147 | 138 | unsigned int tmp; |
---|
| 139 | + unsigned long l; |
---|
148 | 140 | |
---|
149 | 141 | if (priv->open_count++ == 0) { |
---|
| 142 | + l = readl(priv->base + COMMAND_FIFO_STATUS); |
---|
| 143 | + if (!(l & CMD_STS_MASK)) { |
---|
| 144 | + dev_err(priv->dev, "SP cannot accept commands.\n"); |
---|
| 145 | + return -EIO; |
---|
| 146 | + } |
---|
| 147 | + |
---|
150 | 148 | /* Enable interrupt 0 by clearing its bit */ |
---|
151 | 149 | tmp = readl(priv->base + PJ_INTERRUPT_MASK); |
---|
152 | 150 | writel(tmp & ~INT_0, priv->base + PJ_INTERRUPT_MASK); |
---|
.. | .. |
---|
172 | 170 | struct serio *kb_serio, *pad_serio; |
---|
173 | 171 | struct olpc_apsp *priv; |
---|
174 | 172 | struct resource *res; |
---|
175 | | - struct device_node *np; |
---|
176 | | - unsigned long l; |
---|
177 | 173 | int error; |
---|
178 | 174 | |
---|
179 | 175 | priv = devm_kzalloc(&pdev->dev, sizeof(struct olpc_apsp), GFP_KERNEL); |
---|
180 | 176 | if (!priv) |
---|
181 | 177 | return -ENOMEM; |
---|
182 | 178 | |
---|
183 | | - np = pdev->dev.of_node; |
---|
| 179 | + priv->dev = &pdev->dev; |
---|
| 180 | + |
---|
184 | 181 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
185 | 182 | priv->base = devm_ioremap_resource(&pdev->dev, res); |
---|
186 | 183 | if (IS_ERR(priv->base)) { |
---|
.. | .. |
---|
191 | 188 | priv->irq = platform_get_irq(pdev, 0); |
---|
192 | 189 | if (priv->irq < 0) |
---|
193 | 190 | return priv->irq; |
---|
194 | | - |
---|
195 | | - l = readl(priv->base + COMMAND_FIFO_STATUS); |
---|
196 | | - if (!(l & CMD_STS_MASK)) { |
---|
197 | | - dev_err(&pdev->dev, "SP cannot accept commands.\n"); |
---|
198 | | - return -EIO; |
---|
199 | | - } |
---|
200 | 191 | |
---|
201 | 192 | /* KEYBOARD */ |
---|
202 | 193 | kb_serio = kzalloc(sizeof(struct serio), GFP_KERNEL); |
---|
.. | .. |
---|
236 | 227 | goto err_irq; |
---|
237 | 228 | } |
---|
238 | 229 | |
---|
239 | | - priv->dev = &pdev->dev; |
---|
240 | 230 | device_init_wakeup(priv->dev, 1); |
---|
241 | 231 | platform_set_drvdata(pdev, priv); |
---|
242 | 232 | |
---|