Re: [PATCH v7 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Friday 20 December 2013 11:45 PM, Michael Trimarchi wrote:
Hi

On Fri, Dec 20, 2013 at 6:35 PM, Balaji T K <balajitk@xxxxxx> wrote:
In DT case, PBAIS registers are programmed via regulator,
use regulator APIs to control PBIAS.

Signed-off-by: Balaji T K <balajitk@xxxxxx>
---
  drivers/mmc/host/omap_hsmmc.c |   39 +++++++++++++++++++++++++++++++++++++++
  1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 342be25..0a390f8 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -126,6 +126,10 @@
  #define OMAP_MMC_MAX_CLOCK     52000000
  #define DRIVER_NAME            "omap_hsmmc"

+#define VDD_1V8                        1800000         /* 180000 uV */
+#define VDD_3V0                        3000000         /* 300000 uV */
+#define VDD_165_195            (ffs(MMC_VDD_165_195) - 1)
+
  /*
   * One controller can have multiple slots, like on some omap boards using
   * omap.c controller driver. Luckily this is not currently done on any known
@@ -164,6 +168,8 @@ struct omap_hsmmc_host {
          */
         struct  regulator       *vcc;
         struct  regulator       *vcc_aux;
+       struct  regulator       *pbias;
+       bool                    pbias_enabled;
         int                     pbias_disable;
         void    __iomem         *base;
         resource_size_t         mapbase;
@@ -272,6 +278,15 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
         if (mmc_slot(host).before_set_reg)
                 mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);

+       if (host->pbias) {
+               if (host->pbias_enabled == 1) {
+                       ret = regulator_disable(host->pbias);
+                       if (!ret)
+                               host->pbias_enabled = 0;

you should return error?

+               }
+               regulator_set_voltage(host->pbias, VDD_3V0, VDD_3V0);
+       }
+
         /*
          * Assume Vcc regulator is used only to power the card ... OMAP
          * VDDS is used to power the pins, optionally with a transceiver to
@@ -306,9 +321,29 @@ static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on,
                 }
         }

+       if (host->pbias) {
+               if (vdd <= VDD_165_195)
+                       ret = regulator_set_voltage(host->pbias, VDD_1V8,
+                                                               VDD_1V8);
+               else
+                       ret = regulator_set_voltage(host->pbias, VDD_3V0,
+                                                               VDD_3V0);
+               if (ret < 0)
+                       goto error_set_power;
+
+               if (host->pbias_enabled == 0) {
+                       ret = regulator_enable(host->pbias);
+                       if (!ret) {
+                               host->pbias_enabled = 1;
+                               goto error_set_power;

Is this an error condition? Do you need this flag?

Hi,

pbias_enabled flag is used to balance regulator_enable/regulator_disable, otherwise
regulator might be kept enabled base on to use count.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux