All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] quectel: Possibility to switch power by gpio level
@ 2020-10-02 12:49 poeschel
  2020-10-02 14:52 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: poeschel @ 2020-10-02 12:49 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2287 bytes --]

From: Lars Poeschel <poeschel@lemonage.de>

This does apply on top of my previous patch:
[PATCH v2] quectel: Power on/off with a gpio pulse

-- >8 --
Subject: [PATCH] quectel: Possibility to switch power by gpio level

Normally quectel modems are powered on or off by a gpio pulse on their
PWR_KEY pin.
If you have some special circuitry that powers your modem by gpio level
then this here is for you. You can switch to level behaviour by setting
environment variable OFONO_QUECTEL_GPIO_LEVEL. The gpio goes to high
level for the modem to power on and to low level if it should power off.
---
 plugins/quectel.c | 17 ++++++++++++-----
 plugins/udevng.c  |  5 +++++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/plugins/quectel.c b/plugins/quectel.c
index 6ab1d6fd..d4a49555 100644
--- a/plugins/quectel.c
+++ b/plugins/quectel.c
@@ -271,10 +271,17 @@ static void close_serial(struct ofono_modem *modem)
 		close_ngsm(modem);
 
 	if (data->gpio) {
-		l_gpio_writer_set(data->gpio, 1, &gpio_value);
-		g_timeout_add(750, gpio_power_off_cb, modem);
-	} else
-		ofono_modem_set_powered(modem, FALSE);
+		if (ofono_modem_get_boolean(modem, "GpioLevel")) {
+			gpio_value = 0;
+			l_gpio_writer_set(data->gpio, 1, &gpio_value);
+		} else {
+			l_gpio_writer_set(data->gpio, 1, &gpio_value);
+			g_timeout_add(750, gpio_power_off_cb, modem);
+			return;
+		}
+	}
+
+	ofono_modem_set_powered(modem, FALSE);
 
 }
 
@@ -1164,7 +1171,7 @@ static int open_serial(struct ofono_modem *modem)
 		return -EIO;
 	}
 
-	if (data->gpio)
+	if (data->gpio && !ofono_modem_get_boolean(modem, "GpioLevel"))
 		g_timeout_add(2100, gpio_power_on_cb, data);
 
 	/*
diff --git a/plugins/udevng.c b/plugins/udevng.c
index db13073e..8b1943aa 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -921,6 +921,11 @@ static gboolean setup_quectel_serial(struct modem_info *modem)
 	if (value)
 		ofono_modem_set_string(modem->modem, "GpioOffset", value);
 
+	value = udev_device_get_property_value(info->dev,
+						"OFONO_QUECTEL_GPIO_LEVEL");
+	if (value)
+		ofono_modem_set_boolean(modem->modem, "GpioLevel", TRUE);
+
 	value = udev_device_get_property_value(info->dev,
 						"OFONO_QUECTEL_MUX");
 	if (value)
-- 
2.28.0

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

* Re: [PATCH] quectel: Possibility to switch power by gpio level
  2020-10-02 12:49 [PATCH] quectel: Possibility to switch power by gpio level poeschel
@ 2020-10-02 14:52 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2020-10-02 14:52 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 288 bytes --]

Hi Lars,

On 10/2/20 7:49 AM, poeschel(a)lemonage.de wrote:
> From: Lars Poeschel <poeschel@lemonage.de>
> 
> This does apply on top of my previous patch:
> [PATCH v2] quectel: Power on/off with a gpio pulse

I think you might as well just combine the two...

Regards,
-Denis

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

end of thread, other threads:[~2020-10-02 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02 12:49 [PATCH] quectel: Possibility to switch power by gpio level poeschel
2020-10-02 14:52 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.