ARM: tegra12: set CPU rate to 2.2GHz for sku 0x87
[linux-3.10.git] / arch / arm / mach-tegra / tegra11_clocks.c
index b3c8df5..01746af 100644 (file)
 #include <linux/syscore_ops.h>
 #include <linux/platform_device.h>
 #include <linux/clk/tegra.h>
+#include <linux/tegra-soc.h>
+#include <linux/tegra-powergate.h>
 
 #include <asm/clkdev.h>
 
 #include <mach/edp.h>
-#include <mach/hardware.h>
 #include <mach/mc.h>
-#include <mach/powergate.h>
 
 #include "clock.h"
-#include "fuse.h"
 #include "iomap.h"
 #include "dvfs.h"
 #include "pm.h"
@@ -568,7 +567,6 @@ static void __iomem *reg_pmc_base = IO_ADDRESS(TEGRA_PMC_BASE);
 static void __iomem *misc_gp_base = IO_ADDRESS(TEGRA_APB_MISC_BASE);
 static void __iomem *reg_xusb_padctl_base = IO_ADDRESS(TEGRA_XUSB_PADCTL_BASE);
 
-#define MISC_GP_HIDREV                         0x804
 #define MISC_GP_TRANSACTOR_SCRATCH_0           0x864
 #define MISC_GP_TRANSACTOR_SCRATCH_LA_ENABLE   (0x1 << 1)
 #define MISC_GP_TRANSACTOR_SCRATCH_DDS_ENABLE  (0x1 << 2)
@@ -590,8 +588,6 @@ static int tegra_periph_clk_enable_refcount[CLK_OUT_ENB_NUM * 32];
        __raw_writel(value, reg_pmc_base + (reg))
 #define pmc_readl(reg) \
        __raw_readl(reg_pmc_base + (reg))
-#define chipid_readl() \
-       __raw_readl(misc_gp_base + MISC_GP_HIDREV)
 #define xusb_padctl_writel(value, reg) \
        __raw_writel(value, reg_xusb_padctl_base + (reg))
 #define xusb_padctl_readl(reg) \
@@ -599,13 +595,15 @@ static int tegra_periph_clk_enable_refcount[CLK_OUT_ENB_NUM * 32];
 
 #define clk_writel_delay(value, reg)                                   \
        do {                                                            \
-               __raw_writel((value), reg_clk_base + (reg));    \
+               __raw_writel((value), reg_clk_base + (reg));            \
+               __raw_readl(reg_clk_base + (reg));                      \
                udelay(2);                                              \
        } while (0)
 
 #define pll_writel_delay(value, reg)                                   \
        do {                                                            \
-               __raw_writel((value), reg_clk_base + (reg));    \
+               __raw_writel((value), reg_clk_base + (reg));            \
+               __raw_readl(reg_clk_base + (reg));                      \
                udelay(1);                                              \
        } while (0)
 
@@ -1255,7 +1253,7 @@ static int tegra11_cpu_clk_set_rate(struct clk *c, unsigned long rate)
        bool is_dfll = c->parent->parent == c->u.cpu.dynamic;
 
        /* On SILICON allow CPU rate change only if cpu regulator is connected.
-          Ignore regulator connection on FPGA and SIMULATION platforms. */
+          Ignore regulator connection on FPGA platforms. */
 #ifdef CONFIG_TEGRA_SILICON_PLATFORM
        if (c->dvfs) {
                if (!c->dvfs->dvfs_rail)
@@ -1438,8 +1436,8 @@ static int tegra11_cpu_cmplx_clk_set_parent(struct clk *c, struct clk *p)
                ret = clk_set_rate(p_source, rate);
                if (ret)
                        goto abort;
-       } else if ((p->parent->parent == dfll) || ((p->u.cpu.dynamic == dfll) &&
-                       (dfll->state != UNINITIALIZED) && use_dfll)) {
+       } else if ((p->parent->parent == dfll) ||
+                  (p->dvfs && tegra_dvfs_is_dfll_range(p->dvfs, rate))) {
                /* LP => G (DFLL selected as clock source) switch:
                 * set DFLL rate ready (DFLL is still disabled)
                 * (set target p_source as dfll, G source is already selected)
@@ -1489,23 +1487,11 @@ static int tegra11_cpu_cmplx_clk_set_parent(struct clk *c, struct clk *p)
                goto abort;
        }
 
-       /* Disabling old parent scales old mode voltage rail */
-       if (c->refcnt)
-               clk_disable(c->parent);
-       if (p_source_old) {
-               clk_disable(p->parent);
-               clk_disable(p_source_old);
-       }
-
-       clk_reparent(c, p);
-
        /*
         * Lock DFLL now (resume closed loop VDD_CPU control).
-        * G CPU operations are always resumed on DFLL if it can be used, even
-        * when autoswitch between PLL and DFLL is allowed, and resume rate is
-        * low enough to run on PLL. This makes CPU clock source ready for
-        * speedy ramp with cl_dvfs controlling volatge (and that ramp is the
-        * most likely reason for going to G CPU in the 1st place)
+        * G CPU operations are resumed on DFLL if it was the last G CPU
+        * clock source, or if resume rate is in DFLL usage range in case
+        * when auto-switch between PLL and DFLL is enabled.
         */
        if (p_source == dfll) {
                if (tegra_dvfs_rail_is_dfll_mode(tegra_cpu_rail)) {
@@ -1517,6 +1503,16 @@ static int tegra11_cpu_cmplx_clk_set_parent(struct clk *c, struct clk *p)
                }
        }
 
+       /* Disabling old parent scales old mode voltage rail */
+       if (c->refcnt)
+               clk_disable(c->parent);
+       if (p_source_old) {
+               clk_disable(p->parent);
+               clk_disable(p_source_old);
+       }
+
+       clk_reparent(c, p);
+
        tegra_dvfs_rail_mode_updating(tegra_cpu_rail, false);
        return 0;
 
@@ -1850,7 +1846,6 @@ static struct clk_ops tegra_blink_clk_ops = {
 static int tegra11_pll_clk_wait_for_lock(
        struct clk *c, u32 lock_reg, u32 lock_bits)
 {
-#ifndef CONFIG_TEGRA_SIMULATION_PLATFORM
 #if USE_PLL_LOCK_BITS
        int i;
        u32 val = 0;
@@ -1880,7 +1875,6 @@ static int tegra11_pll_clk_wait_for_lock(
        }
 #endif
        udelay(c->u.pll.lock_delay);
-#endif
        return 0;
 }
 
@@ -2506,9 +2500,7 @@ static void tegra11_pllcx_clk_init(struct clk *c)
         * and no enabled module clocks should use it as a source during clock
         * init.
         */
-#ifndef CONFIG_TEGRA_SIMULATION_PLATFORM
        BUG_ON(c->state == ON);
-#endif
        /*
         * Most of PLLCX register fields are shadowed, and can not be read
         * directly from PLL h/w. Hence, actual PLLCX boot state is unknown.
@@ -2725,9 +2717,7 @@ static void pllx_set_defaults(struct clk *c, unsigned long input_rate)
 
        /* Only s/w dyn ramp control is supported */
        val = clk_readl(PLLX_HW_CTRL_CFG);
-#ifndef CONFIG_TEGRA_SIMULATION_PLATFORM
        BUG_ON(!(val & PLLX_HW_CTRL_CFG_SWCTRL));
-#endif
 
        pllxc_get_dyn_steps(c, input_rate, &step_a, &step_b);
        val = step_a << PLLX_MISC2_DYNRAMP_STEPA_SHIFT;
@@ -2745,11 +2735,9 @@ static void pllx_set_defaults(struct clk *c, unsigned long input_rate)
 
        /* Check/set IDDQ */
        val = clk_readl(c->reg + PLL_MISCN(c, 3));
-       if (c->state == ON) {
-#ifndef CONFIG_TEGRA_SIMULATION_PLATFORM
+       if (c->state == ON)
                BUG_ON(val & PLLX_MISC3_IDDQ);
-#endif
-       } else {
+       else {
                val |= PLLX_MISC3_IDDQ;
                clk_writel(val, c->reg + PLL_MISCN(c, 3));
        }
@@ -2780,9 +2768,7 @@ static void pllc_set_defaults(struct clk *c, unsigned long input_rate)
        clk_writel(val, c->reg + PLL_MISC(c));
 
        if (c->state == ON) {
-#ifndef CONFIG_TEGRA_SIMULATION_PLATFORM
                BUG_ON(val & PLLC_MISC_IDDQ);
-#endif
        } else {
                val |= PLLC_MISC_IDDQ;
                clk_writel(val, c->reg + PLL_MISC(c));
@@ -2996,10 +2982,8 @@ static void pllm_set_defaults(struct clk *c, unsigned long input_rate)
 
        if (c->state != ON)
                val |= PLLM_MISC_IDDQ;
-#ifndef CONFIG_TEGRA_SIMULATION_PLATFORM
        else
                BUG_ON(val & PLLM_MISC_IDDQ);
-#endif
 
        clk_writel(val, c->reg + PLL_MISC(c));
 }
@@ -3163,10 +3147,8 @@ static void pllre_set_defaults(struct clk *c, unsigned long input_rate)
 
        if (c->state != ON)
                val |= PLLRE_MISC_IDDQ;
-#ifndef CONFIG_TEGRA_SIMULATION_PLATFORM
        else
                BUG_ON(val & PLLRE_MISC_IDDQ);
-#endif
 
        clk_writel(val, c->reg + PLL_MISC(c));
 }
@@ -3685,11 +3667,17 @@ static int tegra11_use_dfll_cb(const char *arg, const struct kernel_param *kp)
        unsigned long c_flags, p_flags;
        unsigned int old_use_dfll;
        struct clk *c = tegra_get_clock_by_name("cpu");
+       struct clk *dfll = tegra_get_clock_by_name("dfll_cpu");
 
-       if (!c->parent || !c->parent->dvfs)
+       if (!c->parent || !c->parent->dvfs || !dfll)
                return -ENOSYS;
 
        clk_lock_save(c, &c_flags);
+       if (dfll->state == UNINITIALIZED) {
+               pr_err("%s: DFLL is not initialized\n", __func__);
+               clk_unlock_restore(c, &c_flags);
+               return -ENOSYS;
+       }
        if (c->parent->u.cpu.mode == MODE_LP) {
                pr_err("%s: DFLL is not used on LP CPU\n", __func__);
                clk_unlock_restore(c, &c_flags);
@@ -3949,6 +3937,13 @@ static void tegra11_periph_clk_init(struct clk *c)
                c->parent = c->inputs[0].input;
        }
 
+       /* if peripheral is left under reset - enforce safe rate */
+       if (!(c->flags & PERIPH_NO_RESET) &&
+           (clk_readl(PERIPH_CLK_TO_RST_REG(c)) & PERIPH_CLK_TO_BIT(c))) {
+               tegra_periph_clk_safe_rate_init(c);
+                val = clk_readl(c->reg);
+       }
+
        if (c->flags & DIV_U71) {
                u32 divu71 = val & PERIPH_CLK_SOURCE_DIVU71_MASK;
                if (c->flags & DIV_U71_IDLE) {
@@ -4036,7 +4031,7 @@ static void tegra11_periph_clk_disable(struct clk *c)
                 * flush the write operation in apb bus. This will avoid the
                 * peripheral access after disabling clock*/
                if (c->flags & PERIPH_ON_APB)
-                       val = chipid_readl();
+                       val = tegra_read_chipid();
 
                clk_writel_delay(
                        PERIPH_CLK_TO_BIT(c), PERIPH_CLK_TO_ENB_CLR_REG(c));
@@ -4060,7 +4055,7 @@ static void tegra11_periph_clk_reset(struct clk *c, bool assert)
                         * will avoid the peripheral access after disabling
                         * clock */
                        if (c->flags & PERIPH_ON_APB)
-                               val = chipid_readl();
+                               val = tegra_read_chipid();
 
                        clk_writel(PERIPH_CLK_TO_BIT(c),
                                   PERIPH_CLK_TO_RST_SET_REG(c));
@@ -4344,7 +4339,6 @@ static struct clk_ops tegra_1xbus_clk_ops = {
        .shared_bus_update      = &tegra11_clk_1xbus_update,
 };
 
-#if !defined(CONFIG_TEGRA_SIMULATION_PLATFORM)
 /* msenc clock propagation WAR for bug 1005168 */
 static int tegra11_msenc_clk_enable(struct clk *c)
 {
@@ -4368,7 +4362,6 @@ static struct clk_ops tegra_msenc_clk_ops = {
        .round_rate             = &tegra11_periph_clk_round_rate,
        .reset                  = &tegra11_periph_clk_reset,
 };
-#endif
 /* Periph extended clock configuration ops */
 static int
 tegra11_vi_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting)
@@ -4867,10 +4860,14 @@ static int tegra11_clk_cbus_enable(struct clk *c)
        return 0;
 }
 
+/* select 5 steps below top rate as fine granularity region */
+#define CBUS_FINE_GRANULARITY          12000000        /* 12 MHz */
+#define CBUS_FINE_GRANULARITY_RANGE    (5 * CBUS_FINE_GRANULARITY)
+
 static long tegra11_clk_cbus_round_updown(struct clk *c, unsigned long rate,
                                          bool up)
 {
-       int i;
+       int i, n;
 
        if (!c->dvfs) {
                if (!c->min_rate)
@@ -4892,6 +4889,27 @@ static long tegra11_clk_cbus_round_updown(struct clk *c, unsigned long rate,
        }
        rate = max(rate, c->min_rate);
 
+       /* for top rates in fine granularity region don't clip to dvfs table */
+       n = c->dvfs->num_freqs;
+       if ((n >= 2) && (c->dvfs->millivolts[n-1] <= c->dvfs->max_millivolts) &&
+           (rate > c->dvfs->freqs[n-2])) {
+               unsigned long threshold = max(c->dvfs->freqs[n-1],
+                       c->dvfs->freqs[n-2] + CBUS_FINE_GRANULARITY_RANGE);
+               threshold -= CBUS_FINE_GRANULARITY_RANGE;
+
+               if (rate == threshold)
+                       return threshold;
+
+               if (rate < threshold)
+                       return up ? threshold : c->dvfs->freqs[n-2];
+
+               rate = (up ? DIV_ROUND_UP(rate, CBUS_FINE_GRANULARITY) :
+                       rate / CBUS_FINE_GRANULARITY) * CBUS_FINE_GRANULARITY;
+               rate = clamp(rate, threshold, c->dvfs->freqs[n-1]);
+               return rate;
+       }
+
+       /* clip rate to dvfs table steps */
        for (i = 0; ; i++) {
                unsigned long f = c->dvfs->freqs[i];
                int mv = c->dvfs->millivolts[i];
@@ -6630,6 +6648,9 @@ static struct raw_notifier_head host1x_rate_change_nh;
 
 static struct clk tegra_clk_host1x = {
        .name      = "host1x",
+       .lookup    = {
+               .dev_id = "host1x",
+       },
        .ops       = &tegra_1xbus_clk_ops,
        .reg       = 0x180,
        .inputs    = mux_pllm_pllc_pllp_plla,
@@ -6657,7 +6678,7 @@ static struct clk tegra_clk_c2bus = {
        .name      = "c2bus",
        .parent    = &tegra_pll_c2,
        .ops       = &tegra_clk_cbus_ops,
-       .max_rate  = 700000000,
+       .max_rate  = 864000000,
        .mul       = 1,
        .div       = 1,
        .flags     = PERIPH_ON_CBUS,
@@ -6732,6 +6753,35 @@ static struct clk tegra_clk_cbus = {
 };
 #endif
 
+static void tegra11_camera_mclk_init(struct clk *c)
+{
+       c->state = OFF;
+       c->set = true;
+       c->parent = tegra_get_clock_by_name("vi_sensor");
+       c->max_rate = c->parent->max_rate;
+}
+
+static int tegra11_camera_mclk_set_rate(struct clk *c, unsigned long rate)
+{
+       return clk_set_rate(c->parent, rate);
+}
+
+static struct clk_ops tegra_camera_mclk_ops = {
+       .init     = tegra11_camera_mclk_init,
+       .enable   = tegra11_periph_clk_enable,
+       .disable  = tegra11_periph_clk_disable,
+       .set_rate = tegra11_camera_mclk_set_rate,
+};
+
+static struct clk tegra_camera_mclk = {
+       .name = "mclk",
+       .ops = &tegra_camera_mclk_ops,
+       .u.periph = {
+               .clk_num = 92, /* csus */
+       },
+       .flags = PERIPH_NO_RESET,
+};
+
 #define PERIPH_CLK(_name, _dev, _con, _clk_num, _reg, _max, _inputs, _flags) \
        {                                               \
                .name      = _name,                     \
@@ -6839,8 +6889,8 @@ struct clk tegra_list_clks[] = {
        D_AUDIO_CLK("dam0",     "tegra30-dam.0",        NULL,   108,    0x3d8,  19910000,  mux_d_audio_clk,     MUX | DIV_U71 | PERIPH_ON_APB),
        D_AUDIO_CLK("dam1",     "tegra30-dam.1",        NULL,   109,    0x3dc,  19910000,  mux_d_audio_clk,     MUX | DIV_U71 | PERIPH_ON_APB),
        D_AUDIO_CLK("dam2",     "tegra30-dam.2",        NULL,   110,    0x3e0,  19910000,  mux_d_audio_clk,     MUX | DIV_U71 | PERIPH_ON_APB),
-       PERIPH_CLK("adx",       "adx",                  NULL,   154,    0x638,  19910000,  mux_plla_pllc_pllp_clkm,     MUX | DIV_U71 | PERIPH_ON_APB),
-       PERIPH_CLK("amx",       "amx",                  NULL,   153,    0x63c,  19910000,  mux_plla_pllc_pllp_clkm,     MUX | DIV_U71 | PERIPH_ON_APB),
+       PERIPH_CLK("adx",       "adx",                  NULL,   154,    0x638,  24730000,  mux_plla_pllc_pllp_clkm,     MUX | DIV_U71 | PERIPH_ON_APB),
+       PERIPH_CLK("amx",       "amx",                  NULL,   153,    0x63c,  24730000,  mux_plla_pllc_pllp_clkm,     MUX | DIV_U71 | PERIPH_ON_APB),
        PERIPH_CLK("hda",       "tegra30-hda",          "hda",          125,    0x428,  48000000,  mux_pllp_pllc_pllm_clkm,     MUX | DIV_U71 | PERIPH_ON_APB),
        PERIPH_CLK("hda2codec_2x",      "tegra30-hda",  "hda2codec",    111,    0x3e4,  48000000,  mux_pllp_pllc_pllm_clkm,     MUX | DIV_U71 | PERIPH_ON_APB),
        PERIPH_CLK("hda2hdmi",  "tegra30-hda",          "hda2hdmi",     128,    0,      48000000,  mux_clk_m,                   PERIPH_ON_APB),
@@ -6873,23 +6923,19 @@ struct clk tegra_list_clks[] = {
        PERIPH_CLK("i2c3",      "tegra11-i2c.2",        "div-clk",      67,     0x1b8,  136000000, mux_pllp_clkm,       MUX | DIV_U16 | PERIPH_ON_APB),
        PERIPH_CLK("i2c4",      "tegra11-i2c.3",        "div-clk",      103,    0x3c4,  136000000, mux_pllp_clkm,       MUX | DIV_U16 | PERIPH_ON_APB),
        PERIPH_CLK("i2c5",      "tegra11-i2c.4",        "div-clk",      47,     0x128,  64000000,  mux_pllp_clkm,       MUX | DIV_U16 | PERIPH_ON_APB),
-       PERIPH_CLK("mipi-cal",  "mipi-cal",             NULL,   56,     0,      60000000,  mux_clk_m,   0),
+       PERIPH_CLK("mipi-cal",  "mipi-cal",             NULL,   56,     0,      60000000,  mux_clk_m,                   PERIPH_ON_APB),
        PERIPH_CLK("mipi-cal-fixed", "mipi-cal-fixed",  NULL,   0,      0,      108000000, mux_pllp_out3,       PERIPH_NO_ENB),
-       PERIPH_CLK("uarta",     "tegra_uart.0",         NULL,   6,      0x178,  800000000, mux_pllp_pllc_pllm_clkm,     MUX | DIV_U151 | DIV_U151_UART | PERIPH_ON_APB),
-       PERIPH_CLK("uartb",     "tegra_uart.1",         NULL,   7,      0x17c,  800000000, mux_pllp_pllc_pllm_clkm,     MUX | DIV_U151 | DIV_U151_UART | PERIPH_ON_APB),
-       PERIPH_CLK("uartc",     "tegra_uart.2",         NULL,   55,     0x1a0,  800000000, mux_pllp_pllc_pllm_clkm,     MUX | DIV_U151 | DIV_U151_UART | PERIPH_ON_APB),
-       PERIPH_CLK("uartd",     "tegra_uart.3",         NULL,   65,     0x1c0,  800000000, mux_pllp_pllc_pllm_clkm,     MUX | DIV_U151 | DIV_U151_UART | PERIPH_ON_APB),
+       PERIPH_CLK("uarta",     "serial-tegra.0",       NULL,   6,      0x178,  800000000, mux_pllp_pllc_pllm_clkm,     MUX | DIV_U151 | DIV_U151_UART | PERIPH_ON_APB),
+       PERIPH_CLK("uartb",     "serial-tegra.1",       NULL,   7,      0x17c,  800000000, mux_pllp_pllc_pllm_clkm,     MUX | DIV_U151 | DIV_U151_UART | PERIPH_ON_APB),
+       PERIPH_CLK("uartc",     "serial-tegra.2",       NULL,   55,     0x1a0,  800000000, mux_pllp_pllc_pllm_clkm,     MUX | DIV_U151 | DIV_U151_UART | PERIPH_ON_APB),
+       PERIPH_CLK("uartd",     "serial-tegra.3",       NULL,   65,     0x1c0,  800000000, mux_pllp_pllc_pllm_clkm,     MUX | DIV_U151 | DIV_U151_UART | PERIPH_ON_APB),
        PERIPH_CLK("uarte",     "tegra_uart.4",         NULL,   66,     0x1c4,  800000000, mux_pllp_pllc_pllm_clkm,     MUX | DIV_U151 | DIV_U151_UART | PERIPH_ON_APB),
-       PERIPH_CLK("3d",        "3d",                   NULL,   24,     0x158,  700000000, mux_pllm_pllc2_c_c3_pllp_plla,       MUX | MUX8 | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE | PERIPH_MANUAL_RESET),
-       PERIPH_CLK("2d",        "2d",                   NULL,   21,     0x15c,  700000000, mux_pllm_pllc2_c_c3_pllp_plla,       MUX | MUX8 | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE),
+       PERIPH_CLK("3d",        "3d",                   NULL,   24,     0x158,  864000000, mux_pllm_pllc2_c_c3_pllp_plla,       MUX | MUX8 | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE | PERIPH_MANUAL_RESET),
+       PERIPH_CLK("2d",        "2d",                   NULL,   21,     0x15c,  864000000, mux_pllm_pllc2_c_c3_pllp_plla,       MUX | MUX8 | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE),
        PERIPH_CLK_EX("vi",     "vi",                   "vi",   20,     0x148,  425000000, mux_pllm_pllc_pllp_plla,     MUX | DIV_U71 | DIV_U71_INT, &tegra_vi_clk_ops),
        PERIPH_CLK("vi_sensor", NULL,                   "vi_sensor",    20,     0x1a8,  150000000, mux_pllm_pllc_pllp_plla,     MUX | DIV_U71 | PERIPH_NO_RESET),
-       PERIPH_CLK("epp",       "epp",                  NULL,   19,     0x16c,  700000000, mux_pllm_pllc2_c_c3_pllp_plla,       MUX | MUX8 | DIV_U71 | DIV_U71_INT),
-#ifdef CONFIG_TEGRA_SIMULATION_PLATFORM
-       PERIPH_CLK("msenc",     "msenc",                NULL,   60,     0x170,  600000000, mux_pllm_pllc_pllp_plla,     MUX | DIV_U71 | DIV_U71_INT),
-#else
+       PERIPH_CLK("epp",       "epp",                  NULL,   19,     0x16c,  864000000, mux_pllm_pllc2_c_c3_pllp_plla,       MUX | MUX8 | DIV_U71 | DIV_U71_INT),
        PERIPH_CLK_EX("msenc",  "msenc",                NULL,   91,     0x1f0,  600000000, mux_pllm_pllc2_c_c3_pllp_plla,       MUX | MUX8 | DIV_U71 | DIV_U71_INT, &tegra_msenc_clk_ops),
-#endif
        PERIPH_CLK("tsec",      "tsec",                 NULL,   83,     0x1f4,  600000000, mux_pllp_pllc2_c_c3_pllm_clkm,       MUX | MUX8 | DIV_U71 | DIV_U71_INT),
        PERIPH_CLK_EX("dtv",    "dtv",                  NULL,   79,     0x1dc,  250000000, mux_clk_m,                   PERIPH_ON_APB,  &tegra_dtv_clk_ops),
        PERIPH_CLK("hdmi",      "hdmi",                 NULL,   51,     0x18c,  297000000, mux_pllp_pllm_plld_plla_pllc_plld2_clkm,     MUX | MUX8 | DIV_U71),
@@ -6943,17 +6989,14 @@ struct clk tegra_list_clks[] = {
        SHARED_CLK("cap.throttle.sclk", "cap_throttle", NULL,   &tegra_clk_sbus_cmplx, NULL, 0, SHARED_CEILING),
        SHARED_CLK("floor.sclk", "floor_sclk",          NULL,   &tegra_clk_sbus_cmplx, NULL, 0, 0),
        SHARED_CLK("override.sclk", "override_sclk",    NULL,   &tegra_clk_sbus_cmplx, NULL, 0, SHARED_OVERRIDE),
-       SHARED_CLK("sbc1.sclk", "tegra11-spi.0",        "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
-       SHARED_CLK("sbc2.sclk", "tegra11-spi.1",        "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
-       SHARED_CLK("sbc3.sclk", "tegra11-spi.2",        "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
-       SHARED_CLK("sbc4.sclk", "tegra11-spi.3",        "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
-       SHARED_CLK("sbc5.sclk", "tegra11-spi.4",        "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
-       SHARED_CLK("sbc6.sclk", "tegra11-spi.5",        "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
 
        SHARED_EMC_CLK("avp.emc",       "tegra-avp",    "emc",  &tegra_clk_emc, NULL, 0, 0, 0),
-       SHARED_EMC_CLK("cpu.emc",       "cpu",          "emc",  &tegra_clk_emc, NULL, 0, 0, 0),
-       SHARED_EMC_CLK("disp1.emc",     "tegradc.0",    "emc",  &tegra_clk_emc, NULL, 0, SHARED_ISO_BW, BIT(EMC_USER_DC)),
-       SHARED_EMC_CLK("disp2.emc",     "tegradc.1",    "emc",  &tegra_clk_emc, NULL, 0, SHARED_ISO_BW, BIT(EMC_USER_DC)),
+       SHARED_EMC_CLK("disp1.emc", "tegradc.0",        "emc",  &tegra_clk_emc,
+                               NULL, 0, SHARED_ISO_BW, BIT(EMC_USER_DC1)),
+       SHARED_EMC_CLK("disp2.emc", "tegradc.1",        "emc",  &tegra_clk_emc,
+                               NULL, 0, SHARED_ISO_BW, BIT(EMC_USER_DC2)),
+       SHARED_EMC_CLK("mon_cpu.emc",   "tegra_mon",            "cpu_emc",
+                                               &tegra_clk_emc, NULL, 0, 0, 0),
        SHARED_EMC_CLK("hdmi.emc",      "hdmi",         "emc",  &tegra_clk_emc, NULL, 0, 0, 0),
        SHARED_EMC_CLK("usbd.emc",      "tegra-udc.0",  "emc",  &tegra_clk_emc, NULL, 0, 0, 0),
        SHARED_EMC_CLK("usb1.emc",      "tegra-ehci.0", "emc",  &tegra_clk_emc, NULL, 0, 0, 0),
@@ -6974,6 +7017,7 @@ struct clk tegra_list_clks[] = {
        SHARED_EMC_CLK("override.emc", "override.emc",  NULL,   &tegra_clk_emc, NULL, 0, SHARED_OVERRIDE, 0),
        SHARED_EMC_CLK("edp.emc",       "edp.emc",      NULL,   &tegra_clk_emc, NULL, 0, SHARED_CEILING, 0),
        SHARED_EMC_CLK("battery.emc", "battery_edp",    "emc",  &tegra_clk_emc, NULL, 0, SHARED_CEILING, 0),
+       SHARED_EMC_CLK("floor.profile.emc", "profile.emc", NULL, &tegra_clk_emc, NULL,  0, 0, 0),
 
 #ifdef CONFIG_TEGRA_DUAL_CBUS
        DUAL_CBUS_CLK("3d.cbus",        "tegra_gr3d",           "gr3d", &tegra_clk_c2bus, "3d",  0, 0),
@@ -6986,6 +7030,7 @@ struct clk tegra_list_clks[] = {
        SHARED_CLK("edp.c2bus",         "edp.c2bus",            NULL,   &tegra_clk_c2bus, NULL,  0, SHARED_CEILING),
        SHARED_CLK("battery.c2bus",     "battery_edp",          "gpu",  &tegra_clk_c2bus, NULL,  0, SHARED_CEILING),
        SHARED_CLK("cap.profile.c2bus", "profile.c2bus",        NULL,   &tegra_clk_c2bus, NULL,  0, SHARED_CEILING),
+       SHARED_CLK("floor.profile.c2bus", "profile.c2bus",      NULL,   &tegra_clk_c2bus, NULL,  0, 0),
 
        DUAL_CBUS_CLK("msenc.cbus",     "tegra_msenc",          "msenc",  &tegra_clk_c3bus, "msenc", 0, 0),
        DUAL_CBUS_CLK("tsec.cbus",      "tegra_tsec",           "tsec",   &tegra_clk_c3bus, "tsec", 0, 0),
@@ -7010,10 +7055,21 @@ struct clk tegra_list_clks[] = {
        SHARED_CLK("edp.cbus",  "edp.cbus",             NULL,   &tegra_clk_cbus, NULL,  0, SHARED_CEILING),
        SHARED_CLK("battery.cbus", "battery_edp",       "gpu",  &tegra_clk_cbus, NULL,  0, SHARED_CEILING),
        SHARED_CLK("cap.profile.cbus", "profile.cbus",  NULL,   &tegra_clk_cbus, NULL,  0, SHARED_CEILING),
+       SHARED_CLK("floor.profile.cbus", "profile.cbus", NULL,  &tegra_clk_cbus, NULL,  0, 0),
 #endif
        SHARED_CLK("nv.host1x", "tegra_host1x",         "host1x", &tegra_clk_host1x, NULL,  0, 0),
        SHARED_CLK("vi.host1x", "tegra_vi",             "host1x", &tegra_clk_host1x, NULL,  0, 0),
+       SHARED_CLK("cap.host1x", "cap.host1x",          NULL,     &tegra_clk_host1x, NULL,  0, SHARED_CEILING),
+       SHARED_CLK("floor.host1x", "floor.host1x",      NULL,     &tegra_clk_host1x, NULL,  0, 0),
        SHARED_CLK("override.host1x", "override.host1x", NULL,    &tegra_clk_host1x, NULL,  0, SHARED_OVERRIDE),
+       SHARED_CLK("floor.profile.host1x", "profile.host1x", NULL, &tegra_clk_host1x, NULL,  0, 0),
+
+       SHARED_CLK("sbc1.sclk", "spi_tegra.0", "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
+       SHARED_CLK("sbc2.sclk", "spi_tegra.1", "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
+       SHARED_CLK("sbc3.sclk", "spi_tegra.2", "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
+       SHARED_CLK("sbc4.sclk", "spi_tegra.3", "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
+       SHARED_CLK("sbc5.sclk", "spi_tegra.4", "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
+       SHARED_CLK("sbc6.sclk", "spi_tegra.5", "sclk", &tegra_clk_sbus_cmplx, NULL, 0, 0),
 };
 
 
@@ -7169,7 +7225,16 @@ struct clk_duplicate tegra_clk_duplicates[] = {
        CLK_DUPLICATE("i2c5", "tegra_cl_dvfs", "i2c"),
        CLK_DUPLICATE("cpu_g", "tegra_cl_dvfs", "safe_dvfs"),
        CLK_DUPLICATE("epp.cbus", "tegra_isp", "epp"),
-       CLK_DUPLICATE("vi_sensor", NULL, "default_mclk"),
+       CLK_DUPLICATE("i2s0", NULL, "i2s0"),
+       CLK_DUPLICATE("i2s1", NULL, "i2s1"),
+       CLK_DUPLICATE("i2s2", NULL, "i2s2"),
+       CLK_DUPLICATE("i2s3", NULL, "i2s3"),
+       CLK_DUPLICATE("i2s4", NULL, "i2s4"),
+       CLK_DUPLICATE("dam0", NULL, "dam0"),
+       CLK_DUPLICATE("dam1", NULL, "dam1"),
+       CLK_DUPLICATE("dam2", NULL, "dam2"),
+       CLK_DUPLICATE("spdif_in", NULL, "spdif_in"),
+       CLK_DUPLICATE("mclk", NULL, "default_mclk"),
 };
 
 struct clk *tegra_ptr_clks[] = {
@@ -7877,21 +7942,24 @@ static void tegra11_clk_resume(void)
        p = tegra_clk_emc.parent;
        tegra11_periph_clk_init(&tegra_clk_emc);
 
+       /* Turn Off pll_m if it was OFF before suspend, and emc was not switched
+          to pll_m across suspend; re-init pll_m to sync s/w and h/w states */
+       if ((tegra_pll_m.state == OFF) &&
+           (&tegra_pll_m != tegra_clk_emc.parent))
+               tegra11_pllm_clk_disable(&tegra_pll_m);
+       tegra11_pllm_clk_init(&tegra_pll_m);
+
        if (p != tegra_clk_emc.parent) {
-               /* FIXME: old parent is left enabled here even if EMC was its
-                  only child before suspend (may happen on Tegra11 !!) */
                pr_debug("EMC parent(refcount) across suspend: %s(%d) : %s(%d)",
                        p->name, p->refcnt, tegra_clk_emc.parent->name,
                        tegra_clk_emc.parent->refcnt);
 
-               BUG_ON(!p->refcnt);
-               p->refcnt--;
-
-               /* the new parent is enabled by low level code, but ref count
-                  need to be updated up to the root */
-               p = tegra_clk_emc.parent;
-               while (p && ((p->refcnt++) == 0))
-                       p = p->parent;
+               /* emc switched to the new parent by low level code, but ref
+                  count and s/w state need to be updated */
+               clk_disable(p);
+               clk_enable(tegra_clk_emc.parent);
+               tegra_dvfs_set_rate(&tegra_clk_emc,
+                                   clk_get_rate_all_locked(&tegra_clk_emc));
        }
        tegra_emc_timing_invalidate();
 
@@ -7903,6 +7971,8 @@ static void tegra11_clk_resume(void)
 static struct syscore_ops tegra_clk_syscore_ops = {
        .suspend = tegra11_clk_suspend,
        .resume = tegra11_clk_resume,
+       .save = tegra11_clk_suspend,
+       .restore = tegra11_clk_resume,
 };
 #endif
 
@@ -7985,6 +8055,8 @@ void __init tegra11x_init_clocks(void)
        for (i = 0; i < ARRAY_SIZE(tegra_list_clks); i++)
                tegra11_init_one_clock(&tegra_list_clks[i]);
 
+       tegra11_init_one_clock(&tegra_camera_mclk);
+
        for (i = 0; i < ARRAY_SIZE(tegra_sync_source_list); i++)
                tegra11_init_one_clock(&tegra_sync_source_list[i]);
        for (i = 0; i < ARRAY_SIZE(tegra_clk_audio_list); i++)