forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/power/reset/gpio-poweroff.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Toggles a GPIO pin to power down a device
34 *
....@@ -5,11 +6,6 @@
56 * Andrew Lunn <andrew@lunn.ch>
67 *
78 * 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
- *
139 */
1410 #include <linux/kernel.h>
1511 #include <linux/init.h>
....@@ -26,6 +22,8 @@
2622 */
2723 static struct gpio_desc *reset_gpio;
2824 static u32 timeout = DEFAULT_TIMEOUT_MS;
25
+static u32 active_delay = 100;
26
+static u32 inactive_delay = 100;
2927
3028 static void gpio_poweroff_do_poweroff(void)
3129 {
....@@ -33,10 +31,11 @@
3331
3432 /* drive it active, also inactive->active edge */
3533 gpiod_direction_output(reset_gpio, 1);
36
- mdelay(100);
34
+ mdelay(active_delay);
35
+
3736 /* drive inactive, also active->inactive edge */
3837 gpiod_set_value_cansleep(reset_gpio, 0);
39
- mdelay(100);
38
+ mdelay(inactive_delay);
4039
4140 /* drive it active, also inactive->active edge */
4241 gpiod_set_value_cansleep(reset_gpio, 1);
....@@ -52,15 +51,13 @@
5251 bool input = false;
5352 enum gpiod_flags flags;
5453
55
-#ifndef CONFIG_ARCH_ROCKCHIP
5654 /* If a pm_power_off function has already been added, leave it alone */
5755 if (pm_power_off != NULL) {
5856 dev_err(&pdev->dev,
59
- "%s: pm_power_off function already registered",
57
+ "%s: pm_power_off function already registered\n",
6058 __func__);
6159 return -EBUSY;
6260 }
63
-#endif
6461
6562 input = device_property_read_bool(&pdev->dev, "input");
6663 if (input)
....@@ -68,6 +65,9 @@
6865 else
6966 flags = GPIOD_OUT_LOW;
7067
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);
7171 device_property_read_u32(&pdev->dev, "timeout-ms", &timeout);
7272
7373 reset_gpio = devm_gpiod_get(&pdev->dev, NULL, flags);