devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Mark Brown <broonie@kernel.org>
Cc: Kukjin Kim <kgene.kim@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Olof Johansson <olof@lixom.net>, Chris Zhong <zyw@rock-chips.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Abhilash Kesavan <kesavan.abhilash@gmail.com>,
	linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Subject: [PATCH v5 2/5] regulator: Add function to map modes to struct regulator_desc
Date: Fri,  7 Nov 2014 14:00:02 +0100	[thread overview]
Message-ID: <1415365205-27630-3-git-send-email-javier.martinez@collabora.co.uk> (raw)
In-Reply-To: <1415365205-27630-1-git-send-email-javier.martinez@collabora.co.uk>

The "regulator-initial-mode" and "regulator-mode" DT properties allows
to configure the regulator operating modes at startup or when a system
enters into a susend state.

But these properties use as valid values the operating modes supported
by each device while the core deals with the standard operating modes.
So a mapping function is needed to translate from the hardware specific
modes to the standard ones.

This mapping is a non-varying configuration for each regulator, so add
a function pointer to struct regulator_desc that will allow drivers to
define their callback to do the modes translation.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---

Changes in v5:
 - Add a better explanation of what mode is passed as an argument and what
   mode is returned. Suggested by Krzysztof Kozlowski.
 - Explain that this callback is needed to be able to parse the regulator
   initial and suspend state modes. Suggested by Krzysztof Kozlowski.

 include/linux/regulator/driver.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 28da08e..7966650 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -243,6 +243,12 @@ enum regulator_type {
  *
  * @enable_time: Time taken for initial enable of regulator (in uS).
  * @off_on_delay: guard time (in uS), before re-enabling a regulator
+ *
+ * @map_modes: Callback invoked to translate from hardware to standard modes.
+ *             The function returns the standard REGULATOR_MODE that maps to
+ *             the hardware specific mode passed as an argument.
+ *             If the callback is not defined, the "regulator-initial-mode"
+ *             and suspend states "regulator-mode" properties won't be parsed.
  */
 struct regulator_desc {
 	const char *name;
@@ -285,6 +291,8 @@ struct regulator_desc {
 	unsigned int enable_time;
 
 	unsigned int off_on_delay;
+
+	unsigned int (*map_modes)(unsigned int mode);
 };
 
 /**
-- 
2.1.0

  parent reply	other threads:[~2014-11-07 13:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07 13:00 [PATCH v5 0/5] regulator: of: Add initial and suspend modes support Javier Martinez Canillas
2014-11-07 13:00 ` [PATCH v5 1/5] regulator: Document binding for initial and suspend modes Javier Martinez Canillas
     [not found]   ` <1415365205-27630-2-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-11-07 14:58     ` Mark Brown
2014-11-07 15:38       ` Javier Martinez Canillas
     [not found]         ` <545CE75C.8000408-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-11-07 16:10           ` Mark Brown
2014-11-07 16:19             ` Javier Martinez Canillas
2014-11-07 13:00 ` Javier Martinez Canillas [this message]
2014-11-07 15:54   ` [PATCH v5 2/5] regulator: Add function to map modes to struct regulator_desc Mark Brown
2014-11-07 16:17     ` Javier Martinez Canillas
2014-11-07 13:00 ` [PATCH v5 3/5] regulator: of: Add regulator desc param to of_get_regulator_init_data() Javier Martinez Canillas
2014-11-07 15:07   ` Mark Brown
     [not found]     ` <20141107150743.GR8509-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-11-07 15:49       ` Javier Martinez Canillas
2014-11-07 15:23   ` Krzysztof Kozlowski
2014-11-07 16:11     ` Javier Martinez Canillas
2014-11-07 13:00 ` [PATCH v5 4/5] regulator: of: Pass the regulator description in the match table Javier Martinez Canillas
2014-11-07 13:00 ` [PATCH v5 5/5] regulator: of: Add support for parsing initial and suspend modes Javier Martinez Canillas
2014-11-07 15:47   ` Mark Brown
     [not found]     ` <20141107154743.GT8509-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-11-07 16:15       ` Javier Martinez Canillas
     [not found]         ` <545CF02A.9060500-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-11-07 16:21           ` Mark Brown
2014-11-07 15:26 ` [PATCH v5 0/5] regulator: of: Add initial and suspend modes support Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415365205-27630-3-git-send-email-javier.martinez@collabora.co.uk \
    --to=javier.martinez@collabora.co.uk \
    --cc=broonie@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=k.kozlowski@samsung.com \
    --cc=kesavan.abhilash@gmail.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=zyw@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).