| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Toggles a GPIO pin to power down a device |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * Andrew Lunn <andrew@lunn.ch> |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * Copyright (C) 2012 Jamie Lentin |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 11 | | - * published by the Free Software Foundation. |
|---|
| 12 | | - * |
|---|
| 13 | 9 | */ |
|---|
| 14 | 10 | #include <linux/kernel.h> |
|---|
| 15 | 11 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 26 | 22 | */ |
|---|
| 27 | 23 | static struct gpio_desc *reset_gpio; |
|---|
| 28 | 24 | static u32 timeout = DEFAULT_TIMEOUT_MS; |
|---|
| 25 | +static u32 active_delay = 100; |
|---|
| 26 | +static u32 inactive_delay = 100; |
|---|
| 29 | 27 | |
|---|
| 30 | 28 | static void gpio_poweroff_do_poweroff(void) |
|---|
| 31 | 29 | { |
|---|
| .. | .. |
|---|
| 33 | 31 | |
|---|
| 34 | 32 | /* drive it active, also inactive->active edge */ |
|---|
| 35 | 33 | gpiod_direction_output(reset_gpio, 1); |
|---|
| 36 | | - mdelay(100); |
|---|
| 34 | + mdelay(active_delay); |
|---|
| 35 | + |
|---|
| 37 | 36 | /* drive inactive, also active->inactive edge */ |
|---|
| 38 | 37 | gpiod_set_value_cansleep(reset_gpio, 0); |
|---|
| 39 | | - mdelay(100); |
|---|
| 38 | + mdelay(inactive_delay); |
|---|
| 40 | 39 | |
|---|
| 41 | 40 | /* drive it active, also inactive->active edge */ |
|---|
| 42 | 41 | gpiod_set_value_cansleep(reset_gpio, 1); |
|---|
| .. | .. |
|---|
| 52 | 51 | bool input = false; |
|---|
| 53 | 52 | enum gpiod_flags flags; |
|---|
| 54 | 53 | |
|---|
| 55 | | -#ifndef CONFIG_ARCH_ROCKCHIP |
|---|
| 56 | 54 | /* If a pm_power_off function has already been added, leave it alone */ |
|---|
| 57 | 55 | if (pm_power_off != NULL) { |
|---|
| 58 | 56 | dev_err(&pdev->dev, |
|---|
| 59 | | - "%s: pm_power_off function already registered", |
|---|
| 57 | + "%s: pm_power_off function already registered\n", |
|---|
| 60 | 58 | __func__); |
|---|
| 61 | 59 | return -EBUSY; |
|---|
| 62 | 60 | } |
|---|
| 63 | | -#endif |
|---|
| 64 | 61 | |
|---|
| 65 | 62 | input = device_property_read_bool(&pdev->dev, "input"); |
|---|
| 66 | 63 | if (input) |
|---|
| .. | .. |
|---|
| 68 | 65 | else |
|---|
| 69 | 66 | flags = GPIOD_OUT_LOW; |
|---|
| 70 | 67 | |
|---|
| 68 | + device_property_read_u32(&pdev->dev, "active-delay-ms", &active_delay); |
|---|
| 69 | + device_property_read_u32(&pdev->dev, "inactive-delay-ms", |
|---|
| 70 | + &inactive_delay); |
|---|
| 71 | 71 | device_property_read_u32(&pdev->dev, "timeout-ms", &timeout); |
|---|
| 72 | 72 | |
|---|
| 73 | 73 | reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags); |
|---|