ARM: tegra: Check regulator_enable return values
[linux-3.10.git] / arch / arm / mach-tegra / board-pluto.c
index b85dfec..54ccf4b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-tegra/board-pluto.c
  *
- * Copyright (c) 2012-2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -31,7 +31,6 @@
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/platform_data/tegra_usb.h>
-#include <linux/platform_data/tegra_xusb.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/rm31080a_ts.h>
 #include <linux/tegra_uart.h>
 #include <linux/mfd/max8831.h>
 #include <linux/of_platform.h>
 #include <linux/a2220.h>
-#include <linux/edp.h>
 #include <linux/mfd/tlv320aic3262-registers.h>
 #include <linux/mfd/tlv320aic3xxx-core.h>
 #include <linux/usb/tegra_usb_phy.h>
 
-#include <asm/hardware/gic.h>
-
 #include <mach/clk.h>
 #include <mach/irqs.h>
 #include <mach/pinmux.h>
@@ -72,6 +68,7 @@
 #include <mach/tegra-bb-power.h>
 #include <mach/tegra_wakeup_monitor.h>
 #include <linux/platform_data/tegra_usb_modem_power.h>
+#include <mach/xusb.h>
 
 #include "board.h"
 #include "board-common.h"
@@ -228,6 +225,7 @@ static __initdata struct tegra_clk_init_table pluto_clk_init_table[] = {
        { "sbc5",       "pll_p",        25000000,       false},
        { "sbc6",       "pll_p",        25000000,       false},
        { "extern3",    "clk_m",        12000000,       false},
+       { "dsia",       "pll_d2_out0",  0,              false},
        { NULL,         NULL,           0,              0},
 };
 
@@ -340,7 +338,9 @@ static void pluto_i2c_init(void)
 
        platform_device_register(&tegra11_i2c_device5);
        platform_device_register(&tegra11_i2c_device4);
+#ifndef CONFIG_OF
        platform_device_register(&tegra11_i2c_device3);
+#endif
        platform_device_register(&tegra11_i2c_device2);
        platform_device_register(&tegra11_i2c_device1);
 
@@ -682,7 +682,8 @@ static struct tegra_usb_platform_data tegra_ehci3_hsic_smsc_hub_pdata = {
 static struct tegra_usb_platform_data tegra_udc_pdata = {
        .port_otg = true,
        .has_hostpc = true,
-       .id_det_type = TEGRA_USB_VIRTUAL_ID,
+       .id_det_type = TEGRA_USB_PMU_ID,
+       .unaligned_dma_buf_supported = false,
        .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
        .op_mode = TEGRA_USB_OPMODE_DEVICE,
        .u_data.dev = {
@@ -697,8 +698,8 @@ static struct tegra_usb_platform_data tegra_udc_pdata = {
                .idle_wait_delay = 17,
                .term_range_adj = 6,
                .xcvr_setup = 8,
-               .xcvr_lsfslew = 2,
-               .xcvr_lsrslew = 2,
+               .xcvr_lsfslew = 0,
+               .xcvr_lsrslew = 3,
                .xcvr_setup_offset = 0,
                .xcvr_use_fuses = 1,
        },
@@ -707,7 +708,7 @@ static struct tegra_usb_platform_data tegra_udc_pdata = {
 static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
        .port_otg = true,
        .has_hostpc = true,
-       .id_det_type = TEGRA_USB_VIRTUAL_ID,
+       .id_det_type = TEGRA_USB_PMU_ID,
        .unaligned_dma_buf_supported = false,
        .phy_intf = TEGRA_USB_PHY_INTF_UTMI,
        .op_mode = TEGRA_USB_OPMODE_HOST,
@@ -723,8 +724,8 @@ static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
                .idle_wait_delay = 17,
                .term_range_adj = 6,
                .xcvr_setup = 15,
-               .xcvr_lsfslew = 2,
-               .xcvr_lsrslew = 2,
+               .xcvr_lsfslew = 0,
+               .xcvr_lsrslew = 3,
                .xcvr_setup_offset = 0,
                .xcvr_use_fuses = 1,
                .vbus_oc_map = 0x7,
@@ -734,6 +735,7 @@ static struct tegra_usb_platform_data tegra_ehci1_utmi_pdata = {
 static struct tegra_usb_otg_data tegra_otg_pdata = {
        .ehci_device = &tegra_ehci1_device,
        .ehci_pdata = &tegra_ehci1_utmi_pdata,
+       .id_extcon_dev_name = "MAX77665_MUIC_ID",
 };
 
 static struct regulator *baseband_reg;
@@ -874,10 +876,12 @@ static int baseband_init(void)
        }
 
        baseband_reg = regulator_get(NULL, "vdd_core_bb");
-       if (IS_ERR_OR_NULL(baseband_reg))
+       if (IS_ERR(baseband_reg))
                pr_warn("%s: baseband regulator get failed\n", __func__);
-       else
-               regulator_enable(baseband_reg);
+       else {
+               if (regulator_enable(baseband_reg) != 0)
+                       pr_warn("baseband regulator enable failed\n");
+       }
 
        /* enable pull-up for MDM1 UART RX */
        tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_GPIO_PU1,
@@ -1130,54 +1134,18 @@ static void pluto_modem_init(void)
        }
 }
 
-static struct tegra_xusb_pad_data xusb_padctl_data = {
-       .pad_mux = (0x1 << 0),
-       .port_cap = (0x1 << 0),
-       .snps_oc_map = (0x1ff << 0),
-       .usb2_oc_map = (0x3c << 0),
-       .ss_port_map = (0x1 << 0),
-       .oc_det = (0x3f << 10),
-       .rx_wander = (0xf << 4),
-       .rx_eq = (0x3070 << 8),
-       .cdr_cntl = (0x26 << 24),
-       .dfe_cntl = 0x002008EE,
-       .hs_slew = (0xE << 6),
-       .ls_rslew = (0x3 << 14),
-       .otg_pad0_ctl0 = (0x0 << 19),
-       .otg_pad1_ctl0 = (0x7 << 19),
-       .otg_pad0_ctl1 = (0x3 << 0),
-       .otg_pad1_ctl1 = (0x4 << 0),
-       .hs_disc_lvl = (0x5 << 2),
-       .hsic_pad0_ctl0 = (0x00 << 8),
-       .hsic_pad0_ctl1 = (0x00 << 8),
+static struct tegra_xusb_board_data xusb_bdata = {
+       .portmap = TEGRA_XUSB_SS_P0 | TEGRA_XUSB_USB2_P0,
+       /* ss_portmap[0:3] = SS0 map, ss_portmap[4:7] = SS1 map */
+       .ss_portmap = (TEGRA_XUSB_SS_PORT_MAP_USB2_P0 << 0),
 };
 
 static void pluto_xusb_init(void)
 {
        int usb_port_owner_info = tegra_get_usb_port_owner_info();
 
-       if (usb_port_owner_info & UTMI1_PORT_OWNER_XUSB) {
-               u32 usb_calib0 = tegra_fuse_readl(FUSE_SKU_USB_CALIB_0);
-
-               pr_info("dalmore_xusb_init: usb_calib0 = 0x%08x\n", usb_calib0);
-               /*
-                * read from usb_calib0 and pass to driver
-                * set HS_CURR_LEVEL (PAD0)     = usb_calib0[5:0]
-                * set TERM_RANGE_ADJ           = usb_calib0[10:7]
-                * set HS_SQUELCH_LEVEL         = usb_calib0[12:11]
-                * set HS_IREF_CAP              = usb_calib0[14:13]
-                * set HS_CURR_LEVEL (PAD1)     = usb_calib0[20:15]
-                */
-
-               xusb_padctl_data.hs_curr_level_pad0 = (usb_calib0 >> 0) & 0x3f;
-               xusb_padctl_data.hs_term_range_adj = (usb_calib0 >> 7) & 0xf;
-               xusb_padctl_data.hs_squelch_level = (usb_calib0 >> 11) & 0x3;
-               xusb_padctl_data.hs_iref_cap = (usb_calib0 >> 13) & 0x3;
-               xusb_padctl_data.hs_curr_level_pad1 = (usb_calib0 >> 15) & 0x3f;
-
-               tegra_xhci_device.dev.platform_data = &xusb_padctl_data;
-               platform_device_register(&tegra_xhci_device);
-       }
+       if (usb_port_owner_info & UTMI1_PORT_OWNER_XUSB)
+               tegra_xusb_init(&xusb_bdata);
 }
 #else
 static void pluto_usb_init(void) { }
@@ -1293,7 +1261,7 @@ static struct spi_board_info synaptics_9999_spi_board_pluto[] = {
 static int __init pluto_touch_init(void)
 {
        tegra_clk_init_from_table(touch_clk_init_table);
-       if (tegra_get_touch_id() == RAYDIUM_TOUCH) {
+       if (tegra_get_touch_vendor_id() == RAYDIUM_TOUCH) {
                pr_info("%s: initializing raydium\n", __func__);
                rm31080a_pluto_spi_board[0].irq =
                        gpio_to_irq(TOUCH_GPIO_IRQ_RAYDIUM_SPI);
@@ -1310,42 +1278,6 @@ static int __init pluto_touch_init(void)
        return 0;
 }
 
-#ifdef CONFIG_EDP_FRAMEWORK
-static struct edp_manager battery_edp_manager = {
-       .name = "battery",
-       .max = 20000
-};
-
-static void __init pluto_battery_edp_init(void)
-{
-       struct edp_governor *g;
-       int r;
-
-       r = edp_register_manager(&battery_edp_manager);
-       if (r)
-               goto err_ret;
-
-       /* start with priority governor */
-       g = edp_get_governor("priority");
-       if (!g) {
-               r = -EFAULT;
-               goto err_ret;
-       }
-
-       r = edp_set_governor(&battery_edp_manager, g);
-       if (r)
-               goto err_ret;
-
-       return;
-
-err_ret:
-       pr_err("Battery EDP init failed with error %d\n", r);
-       WARN_ON(1);
-}
-#else
-static inline void pluto_battery_edp_init(void) {}
-#endif
-
 #ifdef CONFIG_USE_OF
 struct of_dev_auxdata pluto_auxdata_lookup[] __initdata = {
        OF_DEV_AUXDATA("nvidia,tegra114-apbdma", 0x6000a000, "tegra-dma", NULL),
@@ -1389,9 +1321,14 @@ struct of_dev_auxdata pluto_auxdata_lookup[] __initdata = {
 };
 #endif
 
+static void __init pluto_dtv_init(void)
+{
+       platform_device_register(&tegra_dtv_device);
+}
+
 static void __init tegra_pluto_early_init(void)
 {
-       pluto_battery_edp_init();
+       pluto_sysedp_init();
        tegra_clk_init_from_table(pluto_clk_init_table);
        tegra_clk_verify_parents();
        tegra_soc_device_init("tegra_pluto");
@@ -1412,6 +1349,7 @@ static void __init tegra_pluto_late_init(void)
        tegra_io_dpd_init();
        pluto_sdhci_init();
        pluto_regulator_init();
+       pluto_dtv_init();
        pluto_suspend_init();
        pluto_touch_init();
        pluto_emc_init();
@@ -1435,6 +1373,8 @@ static void __init tegra_pluto_late_init(void)
        tegra_serial_debug_init(TEGRA_UARTD_BASE, INT_WDT_CPU, NULL, -1, -1);
        pluto_soctherm_init();
        tegra_register_fuse();
+       pluto_sysedp_core_init();
+       pluto_sysedp_psydepl_init();
 }
 
 static void __init pluto_ramconsole_reserve(unsigned long size)
@@ -1476,8 +1416,7 @@ MACHINE_START(TEGRA_PLUTO, "tegra_pluto")
        .reserve        = tegra_pluto_reserve,
        .init_early     = tegra11x_init_early,
        .init_irq       = tegra_dt_init_irq,
-       .handle_irq     = gic_handle_irq,
-       .timer          = &tegra_sys_timer,
+       .init_time      = tegra_init_timer,
        .init_machine   = tegra_pluto_dt_init,
        .restart        = tegra_assert_system_reset,
        .dt_compat      = pluto_dt_board_compat,