]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - arch/arm/mach-tegra/board-macallan-power.c
ARM: tegra12: set CPU rate to 2.2GHz for sku 0x87
[linux-3.10.git] / arch / arm / mach-tegra / board-macallan-power.c
index 9ebbf3ab25823c4bac024a0f1cae5c31bff248bd..2ccaa03fc6c93bb0a33a563f5531c38c24a323ee 100644 (file)
 #include <linux/mfd/palmas.h>
 #include <linux/power/bq2419x-charger.h>
 #include <linux/max17048_battery.h>
+#include <linux/power/power_supply_extcon.h>
 #include <linux/gpio.h>
 #include <linux/interrupt.h>
 #include <linux/regulator/userspace-consumer.h>
-#include <linux/edp.h>
-#include <linux/edpdev.h>
-#include <linux/platform_data/tegra_edp.h>
 #include <linux/pid_thermal_gov.h>
+#include <linux/tegra-soc.h>
 
 #include <asm/mach-types.h>
 #include <linux/power/sbs-battery.h>
 
 #include <mach/irqs.h>
-#include <mach/hardware.h>
 #include <mach/edp.h>
 #include <mach/gpio-tegra.h>
 
@@ -65,6 +63,7 @@
 /* BQ2419X VBUS regulator */
 static struct regulator_consumer_supply bq2419x_vbus_supply[] = {
        REGULATOR_SUPPLY("usb_vbus", "tegra-ehci.0"),
+       REGULATOR_SUPPLY("usb_vbus", "tegra-otg"),
 };
 
 static struct regulator_consumer_supply bq2419x_batt_supply[] = {
@@ -109,6 +108,17 @@ static struct i2c_board_info __initdata bq2419x_boardinfo[] = {
        },
 };
 
+static struct power_supply_extcon_plat_data psy_extcon_pdata = {
+       .extcon_name = "tegra-udc",
+};
+
+static struct platform_device psy_extcon_device = {
+       .name = "power-supply-extcon",
+       .id = -1,
+       .dev = {
+               .platform_data = &psy_extcon_pdata,
+       },
+};
 
 /************************ Macallan based regulator ****************/
 static struct regulator_consumer_supply palmas_smps123_supply[] = {
@@ -153,6 +163,7 @@ static struct regulator_consumer_supply palmas_smps8_supply[] = {
        REGULATOR_SUPPLY("vlogic", "0-0069"),
        REGULATOR_SUPPLY("vid", "0-000d"),
        REGULATOR_SUPPLY("vddio", "0-0078"),
+       REGULATOR_SUPPLY("vdd", "0-004c"),
 };
 
 static struct regulator_consumer_supply palmas_smps9_supply[] = {
@@ -161,7 +172,7 @@ static struct regulator_consumer_supply palmas_smps9_supply[] = {
        REGULATOR_SUPPLY("pwrdet_hv", NULL),
 };
 
-static struct regulator_consumer_supply palmas_smps10_supply[] = {
+static struct regulator_consumer_supply palmas_smps10_out1_supply[] = {
 };
 
 static struct regulator_consumer_supply palmas_ldo1_supply[] = {
@@ -254,7 +265,7 @@ static struct regulator_consumer_supply palmas_regen1_supply[] = {
 static struct regulator_consumer_supply palmas_regen2_supply[] = {
 };
 
-PALMAS_REGS_PDATA(smps123, 900,  1300, NULL, 0, 0, 0, 0,
+PALMAS_REGS_PDATA(smps123, 900,  1350, NULL, 0, 0, 0, 0,
        0, PALMAS_EXT_CONTROL_ENABLE1, 0, 0, 0);
 PALMAS_REGS_PDATA(smps45, 900,  1400, NULL, 0, 0, 0, 0,
        0, PALMAS_EXT_CONTROL_NSLEEP, 0, 0, 0);
@@ -266,7 +277,7 @@ PALMAS_REGS_PDATA(smps8, 1800,  1800, NULL, 1, 1, 1, NORMAL,
        0, 0, 0, 0, 0);
 PALMAS_REGS_PDATA(smps9, 2900,  2900, NULL, 1, 0, 1, NORMAL,
        0, 0, 0, 0, 0);
-PALMAS_REGS_PDATA(smps10, 5000,  5000, NULL, 0, 0, 0, 0,
+PALMAS_REGS_PDATA(smps10_out1, 5000,  5000, NULL, 0, 0, 0, 0,
        0, 0, 0, 0, 0);
 PALMAS_REGS_PDATA(ldo1, 1050,  1050, palmas_rails(smps7), 1, 0, 1, 0,
        0, PALMAS_EXT_CONTROL_NSLEEP, 0, 0, 0);
@@ -306,7 +317,8 @@ static struct regulator_init_data *macallan_reg_data[PALMAS_NUM_REGS] = {
        PALMAS_REG_PDATA(smps7),
        PALMAS_REG_PDATA(smps8),
        PALMAS_REG_PDATA(smps9),
-       PALMAS_REG_PDATA(smps10),
+       NULL,
+       PALMAS_REG_PDATA(smps10_out1),
        PALMAS_REG_PDATA(ldo1),
        PALMAS_REG_PDATA(ldo2),
        PALMAS_REG_PDATA(ldo3),
@@ -336,7 +348,8 @@ static struct palmas_reg_init *macallan_reg_init[PALMAS_NUM_REGS] = {
        PALMAS_REG_INIT_DATA(smps7),
        PALMAS_REG_INIT_DATA(smps8),
        PALMAS_REG_INIT_DATA(smps9),
-       PALMAS_REG_INIT_DATA(smps10),
+       NULL,
+       PALMAS_REG_INIT_DATA(smps10_out1),
        PALMAS_REG_INIT_DATA(ldo1),
        PALMAS_REG_INIT_DATA(ldo2),
        PALMAS_REG_INIT_DATA(ldo3),
@@ -360,16 +373,16 @@ static struct palmas_pmic_platform_data pmic_platform = {
 };
 
 static struct palmas_pinctrl_config palmas_pincfg[] = {
-       PALMAS_PINMUX(POWERGOOD, POWERGOOD, DEFAULT, DEFAULT),
-       PALMAS_PINMUX(VAC, VAC, DEFAULT, DEFAULT),
-       PALMAS_PINMUX(GPIO0, GPIO, DEFAULT, DEFAULT),
-       PALMAS_PINMUX(GPIO1, GPIO, DEFAULT, DEFAULT),
-       PALMAS_PINMUX(GPIO2, GPIO, DEFAULT, DEFAULT),
-       PALMAS_PINMUX(GPIO3, GPIO, DEFAULT, DEFAULT),
-       PALMAS_PINMUX(GPIO4, GPIO, DEFAULT, DEFAULT),
-       PALMAS_PINMUX(GPIO5, GPIO, DEFAULT, DEFAULT),
-       PALMAS_PINMUX(GPIO6, GPIO, DEFAULT, DEFAULT),
-       PALMAS_PINMUX(GPIO7, GPIO, DEFAULT, DEFAULT),
+       PALMAS_PINMUX("powergood", "powergood", NULL, NULL),
+       PALMAS_PINMUX("vac", "vac", NULL, NULL),
+       PALMAS_PINMUX("gpio0", "id", "pull-up", NULL),
+       PALMAS_PINMUX("gpio1", "vbus_det", NULL, NULL),
+       PALMAS_PINMUX("gpio2", "gpio", NULL, NULL),
+       PALMAS_PINMUX("gpio3", "gpio", NULL, NULL),
+       PALMAS_PINMUX("gpio4", "gpio", NULL, NULL),
+       PALMAS_PINMUX("gpio5", "gpio", NULL, NULL),
+       PALMAS_PINMUX("gpio6", "gpio", NULL, NULL),
+       PALMAS_PINMUX("gpio7", "gpio", NULL, NULL),
 };
 
 static struct palmas_pinctrl_platform_data palmas_pinctrl_pdata = {
@@ -379,7 +392,7 @@ static struct palmas_pinctrl_platform_data palmas_pinctrl_pdata = {
        .dvfs2_enable = false,
 };
 
-struct palmas_extcon_platform_data palmas_extcon_pdata = {
+static struct palmas_extcon_platform_data palmas_extcon_pdata = {
        .connection_name = "palmas-extcon",
        .enable_vbus_detection = true,
        .enable_id_pin_detection = true,
@@ -389,7 +402,6 @@ static struct palmas_platform_data palmas_pdata = {
        .gpio_base = PALMAS_TEGRA_GPIO_BASE,
        .irq_base = PALMAS_TEGRA_IRQ_BASE,
        .pmic_pdata = &pmic_platform,
-       .use_power_off = true,
        .pinctrl_pdata = &palmas_pinctrl_pdata,
        .extcon_pdata = &palmas_extcon_pdata,
 };
@@ -489,7 +501,7 @@ FIXED_REG(3,        dvdd_ts,        dvdd_ts,
        TEGRA_GPIO_PH4, false,  false,  1,      1800);
 
 FIXED_REG(4,   vdd_hdmi_5v0,   vdd_hdmi_5v0,
-       palmas_rails(smps10),   0,      0,
+       palmas_rails(smps10_out1),      0,      0,
        TEGRA_GPIO_PK6, true,   true,   0,      5000);
 
 FIXED_REG(5,   vddio_sd_slot,  vddio_sd_slot,
@@ -578,6 +590,10 @@ static struct platform_device macallan_pda_power_device = {
        },
 };
 
+static void macallan_board_suspend(int state, enum suspend_stage stage)
+{
+}
+
 static struct tegra_suspend_platform_data macallan_suspend_data = {
        .cpu_timer      = 300,
        .cpu_off_timer  = 300,
@@ -597,6 +613,7 @@ static struct tegra_suspend_platform_data macallan_suspend_data = {
        .lp1_core_volt_low = 0,
        .lp1_core_volt_high = 0,
 #endif
+       .board_suspend = macallan_board_suspend,
 };
 #ifdef CONFIG_ARCH_TEGRA_HAS_CL_DVFS
 /* board parameters for cpu dfll */
@@ -637,6 +654,7 @@ static struct tegra_cl_dvfs_platform_data macallan_cl_dvfs_data = {
        },
        .vdd_map = pmu_cpu_vdd_map,
        .vdd_map_size = PMU_CPU_VDD_MAP_SIZE,
+       .pmu_undershoot_gb = 100,
 
        .cfg_param = &macallan_cl_dvfs_param,
 };
@@ -656,7 +674,7 @@ static int __init macallan_cl_dvfs_init(void)
 
 static int __init macallan_fixed_regulator_init(void)
 {
-       if (!machine_is_macallan())
+       if (!of_machine_is_compatible("nvidia,macallan"))
                return 0;
 
        return platform_add_devices(fixed_reg_devs,
@@ -692,6 +710,7 @@ int __init macallan_regulator_init(void)
        i2c_register_board_info(0, bq2419x_boardinfo,
                        ARRAY_SIZE(bq2419x_boardinfo));
 
+       platform_device_register(&psy_extcon_device);
        platform_device_register(&macallan_pda_power_device);
 
        return 0;
@@ -820,9 +839,15 @@ static struct soctherm_platform_data macallan_soctherm_data = {
        },
        .throttle = {
                [THROTTLE_HEAVY] = {
+                       .priority = 100,
                        .devs = {
                                [THROTTLE_DEV_CPU] = {
-                                       .enable = 1,
+                                       .enable = true,
+                                       .depth = 80,
+                               },
+                               [THROTTLE_DEV_GPU] = {
+                                       .enable = true,
+                                       .depth = 80,
                                },
                        },
                },
@@ -850,148 +875,16 @@ int __init macallan_soctherm_init(void)
        struct board_info board_info;
        tegra_get_board_info(&board_info);
        if (board_info.board_id == BOARD_E1545)
-               tegra_add_cdev_trips(
+               tegra_add_all_vmin_trips(
                        macallan_soctherm_data.therm[THERM_CPU].trips,
                        &macallan_soctherm_data.therm[THERM_CPU].num_trips);
        tegra_platform_edp_init(macallan_soctherm_data.therm[THERM_CPU].trips,
                        &macallan_soctherm_data.therm[THERM_CPU].num_trips,
                        6000); /* edp temperature margin */
-       tegra_add_tj_trips(macallan_soctherm_data.therm[THERM_CPU].trips,
+       tegra_add_cpu_vmax_trips(macallan_soctherm_data.therm[THERM_CPU].trips,
                        &macallan_soctherm_data.therm[THERM_CPU].num_trips);
-       tegra_add_vc_trips(macallan_soctherm_data.therm[THERM_CPU].trips,
+       tegra_add_core_edp_trips(macallan_soctherm_data.therm[THERM_CPU].trips,
                        &macallan_soctherm_data.therm[THERM_CPU].num_trips);
 
-
        return tegra11_soctherm_init(&macallan_soctherm_data);
 }
-
-static struct edp_manager macallan_sysedp_manager = {
-       .name = "battery",
-       .max = 27300
-};
-
-void __init macallan_sysedp_init(void)
-{
-       struct edp_governor *g;
-       int r;
-
-       if (!IS_ENABLED(CONFIG_EDP_FRAMEWORK))
-               return;
-
-       if (get_power_supply_type() != POWER_SUPPLY_TYPE_BATTERY)
-               macallan_sysedp_manager.max = INT_MAX;
-
-       r = edp_register_manager(&macallan_sysedp_manager);
-       WARN_ON(r);
-       if (r)
-               return;
-
-       /* start with priority governor */
-       g = edp_get_governor("priority");
-       WARN_ON(!g);
-       if (!g)
-               return;
-
-       r = edp_set_governor(&macallan_sysedp_manager, g);
-       WARN_ON(r);
-}
-
-static unsigned int macallan_psydepl_states[] = {
-       9900, 9600, 9300, 9000, 8700, 8400, 8100, 7800,
-       7500, 7200, 6900, 6600, 6300, 6000, 5800, 5600,
-       5400, 5200, 5000, 4800, 4600, 4400, 4200, 4000,
-       3800, 3600, 3400, 3200, 3000, 2800, 2600, 2400,
-       2200, 2000, 1900, 1800, 1700, 1600, 1500, 1400,
-       1300, 1200, 1100, 1000,  900,  800,  700,  600,
-        500,  400,  300,  200,  100,    0
-};
-
-static struct psy_depletion_ibat_lut macallan_ibat_lut[] = {
-       {  60,  500 },
-       {  40, 3900 },
-       {   0, 3900 },
-       { -30,    0 }
-};
-
-static struct psy_depletion_rbat_lut macallan_rbat_lut[] = {
-       { 0, 95000 }
-};
-
-static struct psy_depletion_platform_data macallan_psydepl_pdata = {
-       .power_supply = "battery",
-       .states = macallan_psydepl_states,
-       .num_states = ARRAY_SIZE(macallan_psydepl_states),
-       .e0_index = 16,
-       .r_const = 55000,
-       .vsys_min = 3250000,
-       .vcharge = 4200000,
-       .ibat_nom = 3900,
-       .ibat_lut = macallan_ibat_lut,
-       .rbat_lut = macallan_rbat_lut
-};
-
-static struct platform_device macallan_psydepl_device = {
-       .name = "psy_depletion",
-       .id = -1,
-       .dev = { .platform_data = &macallan_psydepl_pdata }
-};
-
-void __init macallan_sysedp_psydepl_init(void)
-{
-       int r;
-
-       r = platform_device_register(&macallan_psydepl_device);
-       WARN_ON(r);
-}
-
-static struct tegra_sysedp_corecap macallan_sysedp_corecap[] = {
-       {  1000, {  1000, 240000, 204000}, {  1000, 240000, 204000 } },
-       {  2000, {  1000, 240000, 204000}, {  1000, 240000, 204000 } },
-       {  3000, {  1000, 240000, 204000}, {  1000, 240000, 204000 } },
-       {  4000, {  1000, 240000, 204000}, {  1000, 240000, 204000 } },
-       {  5000, {  1000, 240000, 204000}, {  1000, 240000, 312000 } },
-       {  6000, {  1679, 240000, 312000}, {  1679, 240000, 312000 } },
-       {  7000, {  1843, 240000, 624000}, {  1975, 324000, 408000 } },
-       {  8000, {  2843, 240000, 624000}, {  2306, 420000, 624000 } },
-       {  9000, {  3843, 240000, 624000}, {  2606, 420000, 792000 } },
-       { 10000, {  4565, 240000, 792000}, {  3398, 528000, 792000 } },
-       { 11000, {  5565, 240000, 792000}, {  4398, 528000, 792000 } },
-       { 12000, {  6565, 240000, 792000}, {  4277, 600000, 792000 } },
-       { 13000, {  7565, 240000, 792000}, {  5277, 600000, 792000 } },
-       { 14000, {  8565, 240000, 792000}, {  6277, 600000, 792000 } },
-       { 15000, {  9565, 240000, 792000}, {  7277, 600000, 792000 } },
-       { 16000, { 10565, 240000, 792000}, {  8277, 600000, 792000 } },
-       { 17000, { 11565, 240000, 792000}, {  9277, 600000, 792000 } },
-       { 18000, { 12565, 240000, 792000}, { 10277, 600000, 792000 } },
-       { 19000, { 13565, 240000, 792000}, { 11277, 600000, 792000 } },
-       { 20000, { 14565, 240000, 792000}, { 12277, 600000, 792000 } },
-       { 23000, { 14565, 600000, 792000}, { 14565, 600000, 792000 } }
-};
-
-static struct tegra_sysedp_platform_data macallan_sysedp_platdata = {
-       .corecap = macallan_sysedp_corecap,
-       .corecap_size = ARRAY_SIZE(macallan_sysedp_corecap),
-       .core_gain = 130,
-       .init_req_watts = 20000
-};
-
-static struct platform_device macallan_sysedp_device = {
-       .name = "tegra_sysedp",
-       .id = -1,
-       .dev = { .platform_data = &macallan_sysedp_platdata }
-};
-
-void __init macallan_sysedp_core_init(void)
-{
-       int r;
-
-       macallan_sysedp_platdata.cpufreq_lim = tegra_get_system_edp_entries(
-                       &macallan_sysedp_platdata.cpufreq_lim_size);
-       if (!macallan_sysedp_platdata.cpufreq_lim) {
-               WARN_ON(1);
-               return;
-       }
-
-       r = platform_device_register(&macallan_sysedp_device);
-       WARN_ON(r);
-}