CHROMIUM: mfd: s5m-core: Enable low-jitter via DT.
authorTodd Broch <tbroch@chromium.org>
Wed, 20 Feb 2013 16:34:45 +0000 (08:34 -0800)
committerChromeBot <chrome-bot@google.com>
Wed, 20 Feb 2013 21:36:48 +0000 (13:36 -0800)
Provide facility via device tree to activate the low-jitter
capababilities of the 32Khz clocks (BT, CP, AP).  Note the feature is
enabled for all the clocks or none per the design

Additionally fixed two small nits:
1. added __devinit to declaration of probe function
2. fixed function name of s5m87xx_i2c_parse_dt_pdata for the case when
   CONFIG_OF is undefined

BUG=chrome-os-partner:17833 chrome-os-partner:17858
TEST=manual
1. boot kernel, login as root
2. examine CTRL1 (0xa) register and see Low Jitter_EN bit (<3>) is
enabled for the spring design.
  i2cget -y -f 0 0x66 0xa
  0xf

Signed-off-by: Todd Broch <tbroch@chromium.org>
Change-Id: I80750a3049806692c1c1e214982577f2f39899e1
Reviewed-on: https://gerrit.chromium.org/gerrit/43624
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
drivers/mfd/s5m-core.c
include/linux/mfd/s5m87xx/s5m-core.h

index 601e598..27e219f 100644 (file)
@@ -123,20 +123,38 @@ static struct s5m_platform_data *s5m87xx_i2c_parse_dt_pdata(struct device *dev)
        if (of_property_read_u32(dev->of_node, "s5m-core,device_type",
                                 &pd->device_type)) {
                dev_warn(dev, "no OF device_type property");
-       } else {
-               dev_dbg(dev, "OF device_type property = %u", pd->device_type);
        }
+       dev_dbg(dev, "OF device_type property = %u", pd->device_type);
+
+       if (of_get_property(dev->of_node, "s5m-core,enable-low-jitter", NULL)) {
+               if (!(pd->device_type == S5M8767X))
+                       dev_warn(dev, "no low-jitter for this PMIC type\n");
+               else
+                       pd->low_jitter = true;
+       }
+       dev_dbg(dev, "OF low-jitter property: %u\n", pd->low_jitter);
+
        return pd;
 }
 #else
-static struct s5m_platform_data *s5m8767_i2c_parse_dt_pdata(struct device *dev)
+static struct s5m_platform_data *s5m87xx_i2c_parse_dt_pdata(struct device *dev)
 {
        return 0;
 }
 #endif
 
-static int s5m87xx_i2c_probe(struct i2c_client *i2c,
-                           const struct i2c_device_id *id)
+static int s5m87xx_set_low_jitter(struct s5m87xx_dev *s5m87xx)
+{
+       if (!s5m87xx->pdata->low_jitter)
+               return 0;
+
+       return s5m_reg_update(s5m87xx, S5M8767_REG_CTRL1,
+                             S5M8767_LOW_JITTER_MASK,
+                             S5M8767_LOW_JITTER_MASK);
+}
+
+static int __devinit s5m87xx_i2c_probe(struct i2c_client *i2c,
+                                      const struct i2c_device_id *id)
 {
        struct s5m_platform_data *pdata = i2c->dev.platform_data;
        struct s5m87xx_dev *s5m87xx;
@@ -202,15 +220,15 @@ static int s5m87xx_i2c_probe(struct i2c_client *i2c,
        switch (s5m87xx->device_type) {
        case S5M8751X:
                ret = mfd_add_devices(s5m87xx->dev, -1, s5m8751_devs,
-                                       ARRAY_SIZE(s5m8751_devs), NULL, 0);
+                                     ARRAY_SIZE(s5m8751_devs), NULL, 0);
                break;
        case S5M8763X:
                ret = mfd_add_devices(s5m87xx->dev, -1, s5m8763_devs,
-                                       ARRAY_SIZE(s5m8763_devs), NULL, 0);
+                                     ARRAY_SIZE(s5m8763_devs), NULL, 0);
                break;
        case S5M8767X:
                ret = mfd_add_devices(s5m87xx->dev, -1, s5m8767_devs,
-                                       ARRAY_SIZE(s5m8767_devs), NULL, 0);
+                                     ARRAY_SIZE(s5m8767_devs), NULL, 0);
                break;
        default:
                /* If this happens the probe function is problem */
@@ -220,6 +238,12 @@ static int s5m87xx_i2c_probe(struct i2c_client *i2c,
        if (ret < 0)
                goto err;
 
+       if (s5m87xx_set_low_jitter(s5m87xx) < 0) {
+               dev_err(s5m87xx->dev, "failed to configure low-jitter\n");
+               ret = -EIO;
+               goto err;
+       }
+
        return ret;
 
 err:
index eaf90ed..540adef 100644 (file)
@@ -241,6 +241,8 @@ enum s5m8767_irq {
 #define S5M8767_IRQ_RTC1S_MASK         (1 << 4)
 #define S5M8767_IRQ_WTSR_MASK          (1 << 5)
 
+#define S5M8767_LOW_JITTER_MASK                (1 << 3)
+
 enum s5m8763_irq {
        S5M8763_IRQ_DCINF,
        S5M8763_IRQ_DCINR,
@@ -370,6 +372,8 @@ struct s5m_platform_data {
        bool                            buck2_ramp_enable;
        bool                            buck3_ramp_enable;
        bool                            buck4_ramp_enable;
+
+       bool                            low_jitter;
 };
 
 #endif /*  __LINUX_MFD_S5M_CORE_H */