<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Zephyr power management issues</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79303/zephyr-power-management-issues</link><description>Dear Nordic, 
 As per power management, could you please suggest any thoughts for following: 
 We have two ICs on the board connected to nRF52840: 6-DOF sensor (over SPI) and flash mem (over QSPI). Both of them are powered from one external LDO regulator</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Sep 2021 13:35:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79303/zephyr-power-management-issues" /><item><title>RE: Zephyr power management issues</title><link>https://devzone.nordicsemi.com/thread/329866?ContentTypeID=1</link><pubDate>Thu, 16 Sep 2021 13:35:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35bfc65b-fabc-4b52-9e0d-925d107d4479</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;2. I got a clarification from one of our developers on this: PM_DEVICE enables device power management from a system perspective. So for example when the system is suspsended, so will the devices be. PM_DEVICE_RUNTIME enables a separate API that drivers can use to implement runtime power management independent of the system state.&lt;/p&gt;
&lt;p&gt;He&amp;#39;d also like to add a word of caution, as PM_DEVICE_RUNTIME is missing some features as of yet like dependency management.&lt;/p&gt;
&lt;p&gt;3. Thank you for your suggestions. I will indeed forward this to the development team and we&amp;#39;ll evaluate it internally.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr power management issues</title><link>https://devzone.nordicsemi.com/thread/329571?ContentTypeID=1</link><pubDate>Wed, 15 Sep 2021 10:15:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37db6dd5-7b90-4a47-b4c5-8ef16e8a08ce</guid><dc:creator>Dmitry Kr</dc:creator><description>&lt;p&gt;Hi Simonr,&lt;/p&gt;
&lt;p&gt;1. OK.&lt;/p&gt;
&lt;p&gt;2. Yes, we&amp;#39;ve implemented. For clarity, could you please suggest:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;a) when PM_DEVICE_RUNTIME is &lt;span style="text-decoration:underline;"&gt;enabled&lt;/span&gt;, should we turn-off device power on init or turn-on by default? Different device drivers have different implementations, and example (dummy_driver) is disabled (turned off) by default. What&amp;#39;s the common approach?&lt;/p&gt;
&lt;p&gt;b) when&amp;nbsp;&lt;span&gt;PM_DEVICE_RUNTIME is &lt;em&gt;&lt;span style="text-decoration:underline;"&gt;disabled&lt;/span&gt;&lt;/em&gt;&amp;nbsp;(and PM_DEVICE) still enabled, should we enable device power by default?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;c) at which usecases we should use PM_DEVICE without PM_DEVICE_RUNTIME?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3. Yes, but it isn&amp;#39;t turned off when SPI driver goes to suspended state, and this pin provides parasitic power for the sensor, leads to 14 uA consumption in addition. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For the SPI driver, could you please consider the following suggestions to the driver&amp;#39;s source?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For spi_context.h:&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;// @ctmlab added -&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;static inline void spi_context_cs_deconfigure(struct spi_context *ctx)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;{&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;if (ctx-&amp;gt;config-&amp;gt;cs &amp;amp;&amp;amp; ctx-&amp;gt;config-&amp;gt;cs-&amp;gt;gpio_dev) {&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;gpio_pin_configure(ctx-&amp;gt;config-&amp;gt;cs-&amp;gt;gpio_dev,&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;ctx-&amp;gt;config-&amp;gt;cs-&amp;gt;gpio_pin,&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;GPIO_DISCONNECTED);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;} else {&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;LOG_INF(&amp;quot;CS control inhibited (no GPIO device)&amp;quot;);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;// &amp;lt;-&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For spi_nrfx_spim / spim_nrfx_pm_control():&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;case PM_DEVICE_STATE_LOW_POWER:&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;case PM_DEVICE_STATE_SUSPEND:&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;case PM_DEVICE_STATE_OFF:&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;if (data-&amp;gt;pm_state == PM_DEVICE_STATE_ACTIVE) {&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;nrfx_spim_uninit(&amp;amp;config-&amp;gt;spim);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;// @ctmlab 2021-09-10 added -&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;struct spi_context *ctx = &amp;amp;get_dev_data(dev)-&amp;gt;ctx;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;spi_context_cs_deconfigure(ctx);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;// &amp;lt;-&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;break;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;For spi_nrfx_spim / spim_nrfx_pm_control():&lt;/p&gt;
&lt;p&gt;&lt;code class="inline-code"&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr power management issues</title><link>https://devzone.nordicsemi.com/thread/329155?ContentTypeID=1</link><pubDate>Mon, 13 Sep 2021 08:22:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43444e9a-1372-4039-9e3f-69912b48993b</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;1. Yes, in order to add a &amp;#39;vin-supply&amp;#39; field I&amp;#39;d recommend&amp;nbsp;making&amp;nbsp;a custom implementation of the QSPI driver with this field.&lt;/p&gt;
&lt;p&gt;2. That sounds like a good idea if you need to manage the power usage of multiple external devices, as PM_DEVICE_RUNTIME lets devices be suspended/resumed based on device usage.&lt;/p&gt;
&lt;p&gt;3.&amp;nbsp;The SPI documentation specifies that a GPIO node is supposed to be used when instantiating a SPI_CS_CONTROL structure.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for notifying us of the missing bracket. I&amp;#39;ve reported it internally.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr power management issues</title><link>https://devzone.nordicsemi.com/thread/328985?ContentTypeID=1</link><pubDate>Fri, 10 Sep 2021 10:17:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60953876-428b-4a24-a9ca-a22de62b4762</guid><dc:creator>Dmitry Kr</dc:creator><description>&lt;p&gt;Hi Simonr,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We&amp;nbsp;applied the regulator susbystem as well by your recommendation (at another ticket).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The question is not about the regulator module itself (it works fine enough for the moment) still about the proper approach to implement that in the application.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/subsys/pm/device_pm/src/main.c"&gt;dummy_driver&lt;/a&gt; application shows relatively clear approach about regulator PM chain management (parent - child suspending), and we&amp;#39;re going to implement someting like that.&lt;/p&gt;
&lt;p&gt;The still active questions are:&lt;/p&gt;
&lt;p&gt;1. Basic &amp;#39;nordic,qspi-nor&amp;#39; driver doesn&amp;#39;t have &amp;#39;vin-supply&amp;#39; field, should we implement our custom driver for NOR flash based on this driver? Or should we manually turn on-off the regulator for flash? &lt;em&gt;Please note there will be logging and perhaps bootloader modules in chain with QSPI driver.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;2. Should we consider using PM_DEVICE_RUNTIME functionality and related functions for PM management of external ICs?&lt;/p&gt;
&lt;p&gt;3. As of SPI driver, there is an issue with PM function: although it has de-initialization for SCK/MOSI/MISO pins, the CS pin still remains active and&amp;nbsp;leads parasitic supply of external ICs (spi_context_cs_configure() - the only function for CS pin configuration from spi_context.h). How we should deal that?&lt;/p&gt;
&lt;p&gt;PS. pls note the pm/device_runtime.h header has no closing &amp;#39;}&amp;#39; bracket for &amp;#39;external &amp;quot;C&amp;quot; {&amp;#39; definition. It leads to error on using the module with C++ sources.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr power management issues</title><link>https://devzone.nordicsemi.com/thread/328556?ContentTypeID=1</link><pubDate>Wed, 08 Sep 2021 10:53:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84b151b0-9f6e-4ed8-a8c1-d3acfcf6f765</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Thank you for the update.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. The &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.6.99-ncs1-rc1/doc/reference/peripherals/regulators.rst"&gt;regulator subsystem&lt;/a&gt; here describes how you can add a regulator to any kind of external device (like sensors or external flash drives). It should be possible to implement something like this for both the QSPI flash and sensor you&amp;#39;re using.&lt;/p&gt;
&lt;p&gt;2. Check out the subsystem linked to above as well as the regulator.h file in&amp;nbsp;&lt;strong&gt;\NCS_VERSION\zephyr\include\drivers\&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr power management issues</title><link>https://devzone.nordicsemi.com/thread/328343?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2021 10:01:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98f9c5e1-3e5a-4945-ab5a-83b6429e95e0</guid><dc:creator>Dmitry Kr</dc:creator><description>&lt;p&gt;Hi Simonr,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. Of course it has power :) We have &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/78340/gpio-port-definition-in-devicetree"&gt;GPIO-controlled&lt;/a&gt; LDO 3.6-&amp;gt;1.8V on the board and both QSPI flash and 6-DOF sensor are powered from this LDO. For good battery life it&amp;#39;s necessary to turn off LDO when devices are not in use (when disconnected from Bluetooth central). So, for example, &amp;#39;jedec,spi-nor&amp;#39; device has &amp;#39;vin-supply&amp;#39; property, why don&amp;#39;t the &amp;#39;nordic,qspi-nor&amp;#39; have? How it can be controlled?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. Could you please suggest proper example / description we shoud consider to control powering of the sensor?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr power management issues</title><link>https://devzone.nordicsemi.com/thread/328219?ContentTypeID=1</link><pubDate>Mon, 06 Sep 2021 13:29:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:251bf482-093d-40a1-a9ae-525a34f177b2</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Dmitry&lt;/p&gt;
&lt;p&gt;1. I&amp;#39;m not sure I understand the question. It sounds like you don&amp;#39;t have a Vin on the QSPI device you&amp;#39;re using, but I find that hard to believe. How do you power the QSPI device?&lt;/p&gt;
&lt;p&gt;2. Yes, I think the power managemer in the nRFConnect SDK should be able to handle power management on the chip. You could alternatively set these SPI lines low so they don&amp;#39;t draw any current at all during this time.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>