diff options
Diffstat (limited to 'drivers/gpio/gpio-rcar.c')
-rw-r--r-- | drivers/gpio/gpio-rcar.c | 65 |
1 files changed, 6 insertions, 59 deletions
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index d9ab0cd1d205..4d9a315cfd43 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c | |||
@@ -196,44 +196,6 @@ static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on) | |||
196 | return 0; | 196 | return 0; |
197 | } | 197 | } |
198 | 198 | ||
199 | static void gpio_rcar_irq_bus_lock(struct irq_data *d) | ||
200 | { | ||
201 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | ||
202 | struct gpio_rcar_priv *p = gpiochip_get_data(gc); | ||
203 | |||
204 | pm_runtime_get_sync(&p->pdev->dev); | ||
205 | } | ||
206 | |||
207 | static void gpio_rcar_irq_bus_sync_unlock(struct irq_data *d) | ||
208 | { | ||
209 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | ||
210 | struct gpio_rcar_priv *p = gpiochip_get_data(gc); | ||
211 | |||
212 | pm_runtime_put(&p->pdev->dev); | ||
213 | } | ||
214 | |||
215 | |||
216 | static int gpio_rcar_irq_request_resources(struct irq_data *d) | ||
217 | { | ||
218 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | ||
219 | struct gpio_rcar_priv *p = gpiochip_get_data(gc); | ||
220 | int error; | ||
221 | |||
222 | error = pm_runtime_get_sync(&p->pdev->dev); | ||
223 | if (error < 0) | ||
224 | return error; | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | |||
229 | static void gpio_rcar_irq_release_resources(struct irq_data *d) | ||
230 | { | ||
231 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | ||
232 | struct gpio_rcar_priv *p = gpiochip_get_data(gc); | ||
233 | |||
234 | pm_runtime_put(&p->pdev->dev); | ||
235 | } | ||
236 | |||
237 | static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) | 199 | static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) |
238 | { | 200 | { |
239 | struct gpio_rcar_priv *p = dev_id; | 201 | struct gpio_rcar_priv *p = dev_id; |
@@ -280,32 +242,18 @@ static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip, | |||
280 | 242 | ||
281 | static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) | 243 | static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset) |
282 | { | 244 | { |
283 | struct gpio_rcar_priv *p = gpiochip_get_data(chip); | 245 | return pinctrl_request_gpio(chip->base + offset); |
284 | int error; | ||
285 | |||
286 | error = pm_runtime_get_sync(&p->pdev->dev); | ||
287 | if (error < 0) | ||
288 | return error; | ||
289 | |||
290 | error = pinctrl_request_gpio(chip->base + offset); | ||
291 | if (error) | ||
292 | pm_runtime_put(&p->pdev->dev); | ||
293 | |||
294 | return error; | ||
295 | } | 246 | } |
296 | 247 | ||
297 | static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset) | 248 | static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset) |
298 | { | 249 | { |
299 | struct gpio_rcar_priv *p = gpiochip_get_data(chip); | ||
300 | |||
301 | pinctrl_free_gpio(chip->base + offset); | 250 | pinctrl_free_gpio(chip->base + offset); |
302 | 251 | ||
303 | /* Set the GPIO as an input to ensure that the next GPIO request won't | 252 | /* |
253 | * Set the GPIO as an input to ensure that the next GPIO request won't | ||
304 | * drive the GPIO pin as an output. | 254 | * drive the GPIO pin as an output. |
305 | */ | 255 | */ |
306 | gpio_rcar_config_general_input_output_mode(chip, offset, false); | 256 | gpio_rcar_config_general_input_output_mode(chip, offset, false); |
307 | |||
308 | pm_runtime_put(&p->pdev->dev); | ||
309 | } | 257 | } |
310 | 258 | ||
311 | static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset) | 259 | static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset) |
@@ -452,6 +400,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) | |||
452 | } | 400 | } |
453 | 401 | ||
454 | pm_runtime_enable(dev); | 402 | pm_runtime_enable(dev); |
403 | pm_runtime_get_sync(dev); | ||
455 | 404 | ||
456 | io = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 405 | io = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
457 | irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 406 | irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
@@ -488,10 +437,6 @@ static int gpio_rcar_probe(struct platform_device *pdev) | |||
488 | irq_chip->irq_unmask = gpio_rcar_irq_enable; | 437 | irq_chip->irq_unmask = gpio_rcar_irq_enable; |
489 | irq_chip->irq_set_type = gpio_rcar_irq_set_type; | 438 | irq_chip->irq_set_type = gpio_rcar_irq_set_type; |
490 | irq_chip->irq_set_wake = gpio_rcar_irq_set_wake; | 439 | irq_chip->irq_set_wake = gpio_rcar_irq_set_wake; |
491 | irq_chip->irq_bus_lock = gpio_rcar_irq_bus_lock; | ||
492 | irq_chip->irq_bus_sync_unlock = gpio_rcar_irq_bus_sync_unlock; | ||
493 | irq_chip->irq_request_resources = gpio_rcar_irq_request_resources; | ||
494 | irq_chip->irq_release_resources = gpio_rcar_irq_release_resources; | ||
495 | irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; | 440 | irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; |
496 | 441 | ||
497 | ret = gpiochip_add_data(gpio_chip, p); | 442 | ret = gpiochip_add_data(gpio_chip, p); |
@@ -522,6 +467,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) | |||
522 | err1: | 467 | err1: |
523 | gpiochip_remove(gpio_chip); | 468 | gpiochip_remove(gpio_chip); |
524 | err0: | 469 | err0: |
470 | pm_runtime_put(dev); | ||
525 | pm_runtime_disable(dev); | 471 | pm_runtime_disable(dev); |
526 | return ret; | 472 | return ret; |
527 | } | 473 | } |
@@ -532,6 +478,7 @@ static int gpio_rcar_remove(struct platform_device *pdev) | |||
532 | 478 | ||
533 | gpiochip_remove(&p->gpio_chip); | 479 | gpiochip_remove(&p->gpio_chip); |
534 | 480 | ||
481 | pm_runtime_put(&pdev->dev); | ||
535 | pm_runtime_disable(&pdev->dev); | 482 | pm_runtime_disable(&pdev->dev); |
536 | return 0; | 483 | return 0; |
537 | } | 484 | } |