Merge "msm: msm_sdcc: Add device tree support for SDCC controllers" into msm-3.0
diff --git a/arch/arm/configs/msm9615_defconfig b/arch/arm/configs/msm9615_defconfig
index 7059684..83efc02 100644
--- a/arch/arm/configs/msm9615_defconfig
+++ b/arch/arm/configs/msm9615_defconfig
@@ -118,6 +118,8 @@
 CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_MSM is not set
 CONFIG_I2C_QUP=y
+CONFIG_MSM_BUS_SCALING=y
+CONFIG_MSM_BUS_RPM_MULTI_TIER_ENABLED=y
 CONFIG_SPI=y
 CONFIG_SPI_QUP=y
 CONFIG_SPI_SPIDEV=m
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index 2d681fa..e5f7449 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -712,9 +712,21 @@
 		bool "6.2.20 + New ADSP"
 endchoice
 
+config MSM_HAS_DEBUG_UART_HS
+	bool
+	help
+	  Say Y here if high speed MSM UART is present.
+
+config MSM_HAS_DEBUG_UART_HS_V14
+	bool
+	select MSM_HAS_DEBUG_UART_HS
+	help
+	  Say Y here if high speed MSM UART v1.4 is present.
+
 config DEBUG_MSM8930_UART
 	bool "Kernel low-level debugging messages via MSM 8930 UART"
 	depends on ARCH_MSM8930 && DEBUG_LL
+	select MSM_HAS_DEBUG_UART_HS
 	help
 	  Say Y here if you want the debug print routines to direct
 	  their output to the serial port on MSM 8930 devices.
@@ -747,6 +759,7 @@
 	config DEBUG_MSM8660_UART
 		bool "Kernel low-level debugging messages via MSM 8660 UART"
 		depends on ARCH_MSM8X60
+		select MSM_HAS_DEBUG_UART_HS
 		help
 		  Say Y here if you want the debug print routines to direct
 		  their output to the serial port on MSM 8660 devices.
@@ -755,9 +768,18 @@
 		bool "Kernel low-level debugging messages via MSM 8960 UART"
 		depends on ARCH_MSM8960
 		select DEBUG_MSM8930_UART
+		select MSM_HAS_DEBUG_UART_HS
 		help
 		  Say Y here if you want the debug print routines to direct
 		  their output to the serial port on MSM 8960 devices.
+
+	config DEBUG_MSMCOPPER_UART
+		bool "Kernel low-level debugging messages via MSM Copper UART"
+		depends on ARCH_MSMCOPPER
+		select MSM_HAS_DEBUG_UART_HS_V14
+		help
+		  Say Y here if you want the debug print routines to direct
+		  their output to the serial port on MSM Copper devices.
 endchoice
 
 choice
diff --git a/arch/arm/mach-msm/acpuclock-9615.c b/arch/arm/mach-msm/acpuclock-9615.c
index ebc7f1b..e6206dd 100644
--- a/arch/arm/mach-msm/acpuclock-9615.c
+++ b/arch/arm/mach-msm/acpuclock-9615.c
@@ -27,6 +27,8 @@
 
 #include <mach/board.h>
 #include <mach/msm_iomap.h>
+#include <mach/msm_bus.h>
+#include <mach/msm_bus_board.h>
 #include <mach/rpm-regulator.h>
 
 #include "acpuclock.h"
@@ -68,6 +70,7 @@
 	unsigned int	src_div;
 	unsigned int	vdd_cpu;
 	unsigned int	vdd_mem;
+	unsigned int	bw_level;
 };
 
 struct acpuclk_state {
@@ -79,12 +82,40 @@
 	.current_speed = &(struct clkctl_acpu_speed){ 0 },
 };
 
+/* Instantaneous bandwidth requests in MB/s. */
+#define BW_MBPS(_bw) \
+	{ \
+		.vectors = &(struct msm_bus_vectors){ \
+			.src = MSM_BUS_MASTER_AMPSS_M0, \
+			.dst = MSM_BUS_SLAVE_EBI_CH0, \
+			.ib = (_bw) * 1000000UL, \
+			.ab = 0, \
+		}, \
+		.num_paths = 1, \
+	}
+static struct msm_bus_paths bw_level_tbl[] = {
+	[0] =  BW_MBPS(152), /* At least  19 MHz on bus. */
+	[1] =  BW_MBPS(368), /* At least  46 MHz on bus. */
+	[2] =  BW_MBPS(552), /* At least  69 MHz on bus. */
+	[3] =  BW_MBPS(736), /* At least  92 MHz on bus. */
+	[4] = BW_MBPS(1064), /* At least 133 MHz on bus. */
+};
+
+static struct msm_bus_scale_pdata bus_client_pdata = {
+	.usecase = bw_level_tbl,
+	.num_usecases = ARRAY_SIZE(bw_level_tbl),
+	.active_only = 1,
+	.name = "acpuclock",
+};
+
+static uint32_t bus_perf_client;
+
 static struct clkctl_acpu_speed acpu_freq_tbl[] = {
-	{ 0,  19200, SRC_CXO,  0, 0,  950000, 1050000 },
-	{ 1, 138000, SRC_PLL0, 6, 1,  950000, 1050000 },
-	{ 1, 276000, SRC_PLL0, 6, 0, 1050000, 1050000 },
-	{ 1, 384000, SRC_PLL8, 3, 0, 1150000, 1150000 },
-	{ 1, 440000, SRC_PLL9, 2, 0, 1150000, 1150000 },
+	{ 0,  19200, SRC_CXO,  0, 0,  950000, 1050000, 0 },
+	{ 1, 138000, SRC_PLL0, 6, 1,  950000, 1050000, 2 },
+	{ 1, 276000, SRC_PLL0, 6, 0, 1050000, 1050000, 2 },
+	{ 1, 384000, SRC_PLL8, 3, 0, 1150000, 1150000, 4 },
+	{ 1, 440000, SRC_PLL9, 2, 0, 1150000, 1150000, 4 },
 	{ 0 }
 };
 
@@ -104,6 +135,25 @@
 	udelay(1);
 }
 
+/* Update the bus bandwidth request. */
+static void set_bus_bw(unsigned int bw)
+{
+	int ret;
+
+	/* Bounds check. */
+	if (bw >= ARRAY_SIZE(bw_level_tbl)) {
+		pr_err("invalid bandwidth request (%d)\n", bw);
+		return;
+	}
+
+	/* Update bandwidth if request has changed. This may sleep. */
+	ret = msm_bus_scale_client_update_request(bus_perf_client, bw);
+	if (ret)
+		pr_err("bandwidth request failed (%d)\n", ret);
+
+	return;
+}
+
 /* Apply any per-cpu voltage increases. */
 static int increase_vdd(unsigned int vdd_cpu, unsigned int vdd_mem)
 {
@@ -198,6 +248,9 @@
 	if (reason == SETRATE_SWFI || reason == SETRATE_PC)
 		goto out;
 
+	/* Update bus bandwith request. */
+	set_bus_bw(tgt_s->bw_level);
+
 	/* Drop VDD levels if we can. */
 	if (tgt_s->khz < strt_s->khz)
 		decrease_vdd(tgt_s->vdd_cpu, tgt_s->vdd_mem);
@@ -258,6 +311,13 @@
 	int i;
 
 	mutex_init(&drv_state.lock);
+
+	bus_perf_client = msm_bus_scale_register_client(&bus_client_pdata);
+	if (!bus_perf_client) {
+		pr_err("Unable to register bus client\n");
+		BUG();
+	}
+
 	for (i = 0; i < NUM_SRC; i++) {
 		if (clocks[i].name) {
 			clocks[i].clk = clk_get_sys(NULL, clocks[i].name);
diff --git a/arch/arm/mach-msm/board-9615.c b/arch/arm/mach-msm/board-9615.c
index d863b5d..eddd4ed 100644
--- a/arch/arm/mach-msm/board-9615.c
+++ b/arch/arm/mach-msm/board-9615.c
@@ -27,6 +27,7 @@
 #include <linux/mfd/pm8xxx/pm8xxx-adc.h>
 #include <linux/leds.h>
 #include <linux/leds-pm8xxx.h>
+#include <mach/msm_bus_board.h>
 #include "timer.h"
 #include "devices.h"
 #include "board-9615.h"
@@ -602,6 +603,17 @@
 	return 0;
 }
 
+static void __init msm9615_init_buses(void)
+{
+#ifdef CONFIG_MSM_BUS_SCALING
+	msm_bus_rpm_set_mt_mask();
+	msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
+	msm_bus_9615_sys_fabric.dev.platform_data =
+		&msm_bus_9615_sys_fabric_pdata;
+	msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
+#endif
+}
+
 static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
 	.max_clock_speed = 24000000,
 };
@@ -675,6 +687,8 @@
 	&msm9615_qcedev_device,
 #endif
 	&msm9615_device_watchdog,
+	&msm_bus_9615_sys_fabric,
+	&msm_bus_def_fab,
 };
 
 static void __init msm9615_i2c_init(void)
@@ -690,6 +704,8 @@
 	msm9615_i2c_init();
 	regulator_suppress_info_printing();
 	platform_device_register(&msm9615_device_rpm_regulator);
+	msm_clock_init(&msm9615_clock_init_data);
+	msm9615_init_buses();
 	msm9615_device_qup_spi_gsbi3.dev.platform_data =
 				&msm9615_qup_spi_gsbi3_pdata;
 	msm9615_device_ssbi_pmic1.dev.platform_data =
@@ -699,7 +715,6 @@
 	msm_device_otg.dev.platform_data = &msm_otg_pdata;
 	platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
 
-	msm_clock_init(&msm9615_clock_init_data);
 	acpuclk_init(&acpuclk_9615_soc_data);
 
 	/* Ensure ar6000pm device is registered before MMC/SDC */
diff --git a/arch/arm/mach-msm/devices-8960.c b/arch/arm/mach-msm/devices-8960.c
index b4db3d6..af48067 100644
--- a/arch/arm/mach-msm/devices-8960.c
+++ b/arch/arm/mach-msm/devices-8960.c
@@ -415,13 +415,13 @@
 		.src = MSM_BUS_MASTER_HD_CODEC_PORT0,
 		.dst = MSM_BUS_SLAVE_EBI_CH0,
 		.ab  = 372244480,
-		.ib  = 1861222400,
+		.ib  = 2560000000U,
 	},
 	{
 		.src = MSM_BUS_MASTER_HD_CODEC_PORT1,
 		.dst = MSM_BUS_SLAVE_EBI_CH0,
 		.ab  = 501219328,
-		.ib  = 2004877312,
+		.ib  = 2560000000U,
 	},
 	{
 		.src = MSM_BUS_MASTER_AMPSS_M0,
@@ -441,13 +441,13 @@
 		.src = MSM_BUS_MASTER_HD_CODEC_PORT0,
 		.dst = MSM_BUS_SLAVE_EBI_CH0,
 		.ab  = 222298112,
-		.ib  = 1778384896,
+		.ib  = 2560000000U,
 	},
 	{
 		.src = MSM_BUS_MASTER_HD_CODEC_PORT1,
 		.dst = MSM_BUS_SLAVE_EBI_CH0,
 		.ab  = 330301440,
-		.ib  = 1321205760,
+		.ib  = 2560000000U,
 	},
 	{
 		.src = MSM_BUS_MASTER_AMPSS_M0,
diff --git a/arch/arm/mach-msm/devices-9615.c b/arch/arm/mach-msm/devices-9615.c
index e5a3f20..47e33d0 100644
--- a/arch/arm/mach-msm/devices-9615.c
+++ b/arch/arm/mach-msm/devices-9615.c
@@ -26,6 +26,7 @@
 #include <mach/irqs.h>
 #include <mach/socinfo.h>
 #include <mach/rpm.h>
+#include <mach/msm_bus_board.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <mach/msm_sps.h>
 #include <mach/dma.h>
@@ -860,3 +861,13 @@
 			irq_set_handler(i, handle_percpu_irq);
 	}
 }
+
+struct platform_device msm_bus_9615_sys_fabric = {
+	.name  = "msm_bus_fabric",
+	.id    =  MSM_BUS_FAB_SYSTEM,
+};
+
+struct platform_device msm_bus_def_fab = {
+	.name  = "msm_bus_fabric",
+	.id    =  MSM_BUS_FAB_DEFAULT,
+};
diff --git a/arch/arm/mach-msm/devices.h b/arch/arm/mach-msm/devices.h
index b5cadd3..48686f0 100644
--- a/arch/arm/mach-msm/devices.h
+++ b/arch/arm/mach-msm/devices.h
@@ -79,6 +79,8 @@
 extern struct platform_device msm9615_device_qup_spi_gsbi3;
 extern struct platform_device msm9615_device_ssbi_pmic1;
 extern struct platform_device msm9615_device_tsens;
+extern struct platform_device msm_bus_9615_sys_fabric;
+extern struct platform_device msm_bus_def_fab;
 
 extern struct platform_device msm_device_sdc1;
 extern struct platform_device msm_device_sdc2;
diff --git a/arch/arm/mach-msm/include/mach/debug-macro.S b/arch/arm/mach-msm/include/mach/debug-macro.S
index 5112888..deeb883 100644
--- a/arch/arm/mach-msm/include/mach/debug-macro.S
+++ b/arch/arm/mach-msm/include/mach/debug-macro.S
@@ -18,6 +18,7 @@
 
 #include <mach/hardware.h>
 #include <mach/msm_iomap.h>
+#include <mach/msm_serial_hsl_regs.h>
 
 #ifdef MSM_DEBUG_UART_PHYS
        .macro  addruart, rp, rv
@@ -26,17 +27,17 @@
 	.endm
 
 	.macro	senduart,rd,rx
-#ifdef CONFIG_SERIAL_MSM_HSL
+#ifdef CONFIG_MSM_HAS_DEBUG_UART_HS
 	@ Clear TX_READY by writing to the UARTDM_CR register
 	mov	r12, #0x300
-	str	r12, [\rx, #0x10]
+	str	r12, [\rx, #UARTDM_CR_OFFSET]
 	@ Write 0x1 to NCF register
 	mov 	r12, #0x1
-	str	r12, [\rx, #0x40]
+	str	r12, [\rx, #UARTDM_NCF_TX_OFFSET]
 	@ UARTDM reg. Read to induce delay
-	ldr	r12, [\rx, #0x08]
+	ldr	r12, [\rx, #UARTDM_SR_OFFSET]
 	@ Write the 1 character to UARTDM_TF
-	str	\rd, [\rx, #0x70]
+	str	\rd, [\rx, #UARTDM_TF_OFFSET]
 #else
 	teq     \rx, #0
 	strne   \rd, [\rx, #0x0C]
@@ -44,13 +45,13 @@
 	.endm
 
 	.macro	waituart,rd,rx
-#ifdef CONFIG_SERIAL_MSM_HSL
+#ifdef CONFIG_MSM_HAS_DEBUG_UART_HS
 	@ check for TX_EMT in UARTDM_SR
-	ldr	\rd, [\rx, #0x08]
+	ldr	\rd, [\rx, #UARTDM_SR_OFFSET]
 	tst	\rd, #0x08
 	bne	1002f
 	@ wait for TXREADY in UARTDM_ISR
-1001:	ldreq	\rd, [\rx, #0x14]
+1001:	ldreq	\rd, [\rx, #UARTDM_ISR_OFFSET]
 	tst	\rd, #0x80
 	dsb
 	beq 	1001b
diff --git a/arch/arm/mach-msm/include/mach/msm_iomap-copper.h b/arch/arm/mach-msm/include/mach/msm_iomap-copper.h
index 3999982..57758c3 100644
--- a/arch/arm/mach-msm/include/mach/msm_iomap-copper.h
+++ b/arch/arm/mach-msm/include/mach/msm_iomap-copper.h
@@ -38,4 +38,9 @@
 #define COPPER_TMR0_PHYS	0xF908A000
 #define COPPER_TMR0_SIZE	SZ_4K
 
+#ifdef CONFIG_DEBUG_MSMCOPPER_UART
+#define MSM_DEBUG_UART_BASE	IOMEM(0xFA782000)
+#define MSM_DEBUG_UART_PHYS	0xF9682000
+#endif
+
 #endif
diff --git a/arch/arm/mach-msm/include/mach/msm_serial_hsl_regs.h b/arch/arm/mach-msm/include/mach/msm_serial_hsl_regs.h
new file mode 100644
index 0000000..b465b56
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/msm_serial_hsl_regs.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ASM_ARCH_MSM_SERIAL_HSL_REGS_H
+#define __ASM_ARCH_MSM_SERIAL_HSL_REGS_H
+
+#ifdef CONFIG_MSM_HAS_DEBUG_UART_HS_V14
+#define UARTDM_MR2_OFFSET	0x4
+#define UARTDM_CSR_OFFSET	0xa0
+#define UARTDM_SR_OFFSET	0xa4
+#define UARTDM_CR_OFFSET	0xa8
+#define UARTDM_ISR_OFFSET	0xb4
+#define UARTDM_NCF_TX_OFFSET	0x40
+#define UARTDM_TF_OFFSET	0x100
+#else
+#define UARTDM_MR2_OFFSET	0x4
+#define UARTDM_CSR_OFFSET	0x8
+#define UARTDM_SR_OFFSET	0x8
+#define UARTDM_CR_OFFSET	0x10
+#define UARTDM_ISR_OFFSET	0x14
+#define UARTDM_NCF_TX_OFFSET	0x40
+#define UARTDM_TF_OFFSET	0x70
+#endif
+
+#endif
diff --git a/arch/arm/mach-msm/include/mach/uncompress.h b/arch/arm/mach-msm/include/mach/uncompress.h
index 74cbda1..7560dc2 100644
--- a/arch/arm/mach-msm/include/mach/uncompress.h
+++ b/arch/arm/mach-msm/include/mach/uncompress.h
@@ -21,6 +21,7 @@
 #include <asm/processor.h>
 
 #include <mach/msm_iomap.h>
+#include <mach/msm_serial_hsl_regs.h>
 
 #ifndef CONFIG_DEBUG_ICEDCC
 static void putc(int c)
@@ -28,18 +29,18 @@
 #if defined(MSM_DEBUG_UART_PHYS)
 	unsigned long base = MSM_DEBUG_UART_PHYS;
 
-#ifdef CONFIG_SERIAL_MSM_HSL
+#ifdef CONFIG_MSM_HAS_DEBUG_UART_HS
 	/*
 	 * Wait for TX_READY to be set; but skip it if we have a
 	 * TX underrun.
 	 */
-	if (__raw_readl(base + 0x08) & 0x08)
-		while (!(__raw_readl(base + 0x14) & 0x80))
+	if (!(__raw_readl(base + UARTDM_SR_OFFSET) & 0x08))
+		while (!(__raw_readl(base + UARTDM_ISR_OFFSET) & 0x80))
 			cpu_relax();
 
-	__raw_writel(0x300, base + 0x10);
-	__raw_writel(0x1, base + 0x40);
-	__raw_writel(c, base + 0x70);
+	__raw_writel(0x300, base + UARTDM_CR_OFFSET);
+	__raw_writel(0x1, base + UARTDM_NCF_TX_OFFSET);
+	__raw_writel(c, base + UARTDM_TF_OFFSET);
 #else
 	/* Wait for TX_READY to be set */
 	while (!(__raw_readl(base + 0x08) & 0x04))
diff --git a/arch/arm/mach-msm/io.c b/arch/arm/mach-msm/io.c
index 8a79af7..f09c6d9 100644
--- a/arch/arm/mach-msm/io.c
+++ b/arch/arm/mach-msm/io.c
@@ -286,6 +286,9 @@
 	MSM_CHIP_DEVICE(TLMM, COPPER),
 	MSM_CHIP_DEVICE(TMR, COPPER),
 	MSM_CHIP_DEVICE(TMR0, COPPER),
+#ifdef CONFIG_DEBUG_MSMCOPPER_UART
+	MSM_DEVICE(DEBUG_UART),
+#endif
 };
 
 void __init msm_map_copper_io(void)
diff --git a/drivers/input/touchscreen/cyttsp-i2c.c b/drivers/input/touchscreen/cyttsp-i2c.c
index 4aa4796..9df1189 100644
--- a/drivers/input/touchscreen/cyttsp-i2c.c
+++ b/drivers/input/touchscreen/cyttsp-i2c.c
@@ -935,6 +935,7 @@
 	u16 st_x2, st_y2;
 	u8 st_z2;
 	s32 retval;
+	int val;
 
 	cyttsp_xdebug("TTSP handler start 1:\n");
 
@@ -1239,16 +1240,20 @@
 			FLIP_XY(g_xy_data.x4, g_xy_data.y4);
 
 		if (rev_x) {
-			g_xy_data.x4 = INVERT_X(g_xy_data.x4,
-						ts->platform_data->panel_maxx);
-			if (g_xy_data.x4 < 0)
+			val = INVERT_X(g_xy_data.x4,
+					ts->platform_data->panel_maxx);
+			if (val >= 0)
+				g_xy_data.x4 = val;
+			else
 				pr_debug("X value is negative. Please configure"
 					" maxx in platform data structure\n");
 		}
 		if (rev_y) {
-			g_xy_data.y4 = INVERT_X(g_xy_data.y4,
-						ts->platform_data->panel_maxy);
-			if (g_xy_data.y4 < 0)
+			val = INVERT_X(g_xy_data.y4,
+					ts->platform_data->panel_maxy);
+			if (val >= 0)
+				g_xy_data.y4 = val;
+			else
 				pr_debug("Y value is negative. Please configure"
 					" maxy in platform data structure\n");
 
@@ -1293,17 +1298,21 @@
 			FLIP_XY(g_xy_data.x3, g_xy_data.y3);
 
 		if (rev_x) {
-			g_xy_data.x3 = INVERT_X(g_xy_data.x3,
-						ts->platform_data->panel_maxx);
-			if (g_xy_data.x3 < 0)
+			val = INVERT_X(g_xy_data.x3,
+					ts->platform_data->panel_maxx);
+			if (val >= 0)
+				g_xy_data.x3 = val;
+			else
 				pr_debug("X value is negative. Please configure"
 					" maxx in platform data structure\n");
 
 		}
 		if (rev_y) {
-			g_xy_data.y3 = INVERT_X(g_xy_data.y3,
-						ts->platform_data->panel_maxy);
-			if (g_xy_data.y3 < 0)
+			val = INVERT_X(g_xy_data.y3,
+					ts->platform_data->panel_maxy);
+			if (val >= 0)
+				g_xy_data.y3 = val;
+			else
 				pr_debug("Y value is negative. Please configure"
 					" maxy in platform data structure\n");
 
@@ -1348,16 +1357,20 @@
 			FLIP_XY(g_xy_data.x2, g_xy_data.y2);
 
 		if (rev_x) {
-			g_xy_data.x2 = INVERT_X(g_xy_data.x2,
-						ts->platform_data->panel_maxx);
-			if (g_xy_data.x2 < 0)
+			val = INVERT_X(g_xy_data.x2,
+					ts->platform_data->panel_maxx);
+			if (val >= 0)
+				g_xy_data.x2 = val;
+			else
 				pr_debug("X value is negative. Please configure"
 					" maxx in platform data structure\n");
 		}
 		if (rev_y) {
-			g_xy_data.y2 = INVERT_X(g_xy_data.y2,
-						ts->platform_data->panel_maxy);
-			if (g_xy_data.y2 < 0)
+			val = INVERT_X(g_xy_data.y2,
+					ts->platform_data->panel_maxy);
+			if (val >= 0)
+				g_xy_data.y2 = val;
+			else
 				pr_debug("Y value is negative. Please configure"
 					" maxy in platform data structure\n");
 		}
@@ -1401,16 +1414,20 @@
 			FLIP_XY(g_xy_data.x1, g_xy_data.y1);
 
 		if (rev_x) {
-			g_xy_data.x1 = INVERT_X(g_xy_data.x1,
-						ts->platform_data->panel_maxx);
-			if (g_xy_data.x1 < 0)
+			val = INVERT_X(g_xy_data.x1,
+					ts->platform_data->panel_maxx);
+			if (val >= 0)
+				g_xy_data.x1 = val;
+			else
 				pr_debug("X value is negative. Please configure"
 					" maxx in platform data structure\n");
 		}
 		if (rev_y) {
-			g_xy_data.y1 = INVERT_X(g_xy_data.y1,
-						ts->platform_data->panel_maxy);
-			if (g_xy_data.y1 < 0)
+			val = INVERT_X(g_xy_data.y1,
+					ts->platform_data->panel_maxy);
+			if (val >= 0)
+				g_xy_data.y1 = val;
+			else
 				pr_debug("Y value is negative. Please configure"
 					" maxy in platform data structure");
 		}
@@ -2744,7 +2761,7 @@
 	ts = kzalloc(sizeof(struct cyttsp), GFP_KERNEL);
 	if (ts == NULL) {
 		cyttsp_xdebug1("err kzalloc for cyttsp\n");
-		retval = -ENOMEM;
+		return -ENOMEM;
 	}
 
 	/* Enable runtime PM ops, start in ACTIVE mode */
@@ -2779,10 +2796,8 @@
 		error = cyttsp_initialize(client, ts);
 		if (error) {
 			cyttsp_xdebug1("err cyttsp_initialize\n");
-			if (ts != NULL) {
-				/* deallocate memory */
-				kfree(ts);
-			}
+			/* deallocate memory */
+			kfree(ts);
 /*
 			i2c_del_driver(&cyttsp_driver);
 */
@@ -3054,8 +3069,7 @@
 		gpio_free(ts->platform_data->irq_gpio);
 
 	/* housekeeping */
-	if (ts != NULL)
-		kfree(ts);
+	kfree(ts);
 
 	cyttsp_alert("Leaving\n");
 
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index d9411ed..a4edb24 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -49,6 +49,8 @@
 	if (ms < 1000 / HZ) {
 		cond_resched();
 		mdelay(ms);
+	} else if (ms < jiffies_to_msecs(2)) {
+		usleep_range(ms * 1000, (ms + 1) * 1000);
 	} else {
 		msleep(ms);
 	}
diff --git a/drivers/video/msm/hdmi_msm.c b/drivers/video/msm/hdmi_msm.c
index 78447f9..4ef0da6 100644
--- a/drivers/video/msm/hdmi_msm.c
+++ b/drivers/video/msm/hdmi_msm.c
@@ -3347,8 +3347,6 @@
 		MSM_HDMI_SAMPLE_RATE_48KHZ, channels);
 	hdmi_msm_audio_info_setup(TRUE, channels, 0, FALSE);
 
-	hdmi_msm_audio_ctrl_setup(FALSE, 1);
-
 	/* Turn on Audio FIFO and SAM DROP ISR */
 	HDMI_OUTP(0x02CC, HDMI_INP(0x02CC) | BIT(1) | BIT(3));
 	DEV_INFO("HDMI Audio: Enabled\n");
diff --git a/drivers/video/msm/lcdc.c b/drivers/video/msm/lcdc.c
index cf8a5ff..135bf68 100644
--- a/drivers/video/msm/lcdc.c
+++ b/drivers/video/msm/lcdc.c
@@ -29,7 +29,6 @@
 #include <linux/clk.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
-#include <mach/clk.h>
 
 #include "msm_fb.h"
 
@@ -78,7 +77,7 @@
 #ifndef CONFIG_MSM_BUS_SCALING
 	if (mfd->ebi1_clk) {
 		if (mdp_rev == MDP_REV_303) {
-			if (clk_set_min_rate(mfd->ebi1_clk, 0))
+			if (clk_set_rate(mfd->ebi1_clk, 0))
 				pr_err("%s: ebi1_lcdc_clk set rate failed\n",
 					__func__);
 		}
@@ -117,7 +116,7 @@
 
 	if (mfd->ebi1_clk) {
 		if (mdp_rev == MDP_REV_303) {
-			if (clk_set_min_rate(mfd->ebi1_clk, 65000000))
+			if (clk_set_rate(mfd->ebi1_clk, 65000000))
 				pr_err("%s: ebi1_lcdc_clk set rate failed\n",
 					__func__);
 		} else {
diff --git a/drivers/video/msm/msm_dss_io_7x27a.c b/drivers/video/msm/msm_dss_io_7x27a.c
index 5f1abd4..032c9cd 100644
--- a/drivers/video/msm/msm_dss_io_7x27a.c
+++ b/drivers/video/msm/msm_dss_io_7x27a.c
@@ -13,7 +13,6 @@
 #include <linux/clk.h>
 #include "msm_fb.h"
 #include "mipi_dsi.h"
-#include <mach/clk.h>
 
 /* multimedia sub system sfpb */
 char *mmss_sfpb_base;
@@ -313,7 +312,7 @@
 	unsigned data = 0;
 	uint32 pll_ctrl;
 
-	if (clk_set_min_rate(ebi1_dsi_clk, 65000000)) /* 65 MHz */
+	if (clk_set_rate(ebi1_dsi_clk, 65000000)) /* 65 MHz */
 		pr_err("%s: ebi1_dsi_clk set rate failed\n", __func__);
 	clk_enable(ebi1_dsi_clk);
 
@@ -339,7 +338,7 @@
 	clk_disable(mdp_dsi_pclk);
 	/* DSIPHY_PLL_CTRL_0, disable dsi pll */
 	MIPI_OUTP(MIPI_DSI_BASE + 0x0200, 0x40);
-	if (clk_set_min_rate(ebi1_dsi_clk, 0))
+	if (clk_set_rate(ebi1_dsi_clk, 0))
 		pr_err("%s: ebi1_dsi_clk set rate failed\n", __func__);
 	clk_disable(ebi1_dsi_clk);
 }
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index cb43a9c..af8ee26 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -51,20 +51,20 @@
 {
 	BT_DBG("mgr %p", mgr);
 
-	write_lock_bh(&amp_mgr_list_lock);
+	write_lock(&amp_mgr_list_lock);
 	list_del(&mgr->list);
-	write_unlock_bh(&amp_mgr_list_lock);
+	write_unlock(&amp_mgr_list_lock);
 
-	read_lock_bh(&mgr->ctx_list_lock);
+	read_lock(&mgr->ctx_list_lock);
 	while (!list_empty(&mgr->ctx_list)) {
 		struct amp_ctx *ctx;
 		ctx = list_first_entry(&mgr->ctx_list, struct amp_ctx, list);
-		read_unlock_bh(&mgr->ctx_list_lock);
+		read_unlock(&mgr->ctx_list_lock);
 		BT_DBG("kill ctx %p", ctx);
 		kill_ctx(ctx);
-		read_lock_bh(&mgr->ctx_list_lock);
+		read_lock(&mgr->ctx_list_lock);
 	}
-	read_unlock_bh(&mgr->ctx_list_lock);
+	read_unlock(&mgr->ctx_list_lock);
 
 	kfree(mgr->ctrls);
 
@@ -76,14 +76,14 @@
 	struct amp_mgr *mgr;
 	struct amp_mgr *found = NULL;
 
-	read_lock_bh(&amp_mgr_list_lock);
+	read_lock(&amp_mgr_list_lock);
 	list_for_each_entry(mgr, &amp_mgr_list, list) {
 		if ((mgr->a2mp_sock) && (mgr->a2mp_sock->sk == sk)) {
 			found = mgr;
 			break;
 		}
 	}
-	read_unlock_bh(&amp_mgr_list_lock);
+	read_unlock(&amp_mgr_list_lock);
 	return found;
 }
 
@@ -92,17 +92,19 @@
 {
 	struct amp_mgr *mgr;
 
-	write_lock_bh(&amp_mgr_list_lock);
+	write_lock(&amp_mgr_list_lock);
 	list_for_each_entry(mgr, &amp_mgr_list, list) {
 		if (mgr->l2cap_conn == conn) {
 			BT_DBG("conn %p found %p", conn, mgr);
+			write_unlock(&amp_mgr_list_lock);
 			goto gc_finished;
 		}
 	}
+	write_unlock(&amp_mgr_list_lock);
 
 	mgr = kzalloc(sizeof(*mgr), GFP_ATOMIC);
 	if (!mgr)
-		goto gc_finished;
+		return NULL;
 
 	mgr->l2cap_conn = conn;
 	mgr->next_ident = 1;
@@ -113,12 +115,13 @@
 	mgr->a2mp_sock = open_fixed_channel(conn->src, conn->dst);
 	if (!mgr->a2mp_sock) {
 		kfree(mgr);
-		goto gc_finished;
+		return NULL;
 	}
+	write_lock(&amp_mgr_list_lock);
 	list_add(&(mgr->list), &amp_mgr_list);
+	write_unlock(&amp_mgr_list_lock);
 
 gc_finished:
-	write_unlock_bh(&amp_mgr_list_lock);
 	return mgr;
 }
 
@@ -169,9 +172,9 @@
 static inline void start_ctx(struct amp_mgr *mgr, struct amp_ctx *ctx)
 {
 	BT_DBG("ctx %p", ctx);
-	write_lock_bh(&mgr->ctx_list_lock);
+	write_lock(&mgr->ctx_list_lock);
 	list_add(&ctx->list, &mgr->ctx_list);
-	write_unlock_bh(&mgr->ctx_list_lock);
+	write_unlock(&mgr->ctx_list_lock);
 	ctx->mgr = mgr;
 	execute_ctx(ctx, AMP_INIT, 0);
 }
@@ -182,9 +185,9 @@
 
 	BT_DBG("ctx %p deferred %p", ctx, ctx->deferred);
 	del_timer(&ctx->timer);
-	write_lock_bh(&mgr->ctx_list_lock);
+	write_lock(&mgr->ctx_list_lock);
 	list_del(&ctx->list);
-	write_unlock_bh(&mgr->ctx_list_lock);
+	write_unlock(&mgr->ctx_list_lock);
 	if (ctx->deferred)
 		execute_ctx(ctx->deferred, AMP_INIT, 0);
 	kfree(ctx);
@@ -195,14 +198,14 @@
 	struct amp_ctx *fnd = NULL;
 	struct amp_ctx *ctx;
 
-	read_lock_bh(&mgr->ctx_list_lock);
+	read_lock(&mgr->ctx_list_lock);
 	list_for_each_entry(ctx, &mgr->ctx_list, list) {
 		if (ctx->type == type) {
 			fnd = ctx;
 			break;
 		}
 	}
-	read_unlock_bh(&mgr->ctx_list_lock);
+	read_unlock(&mgr->ctx_list_lock);
 	return fnd;
 }
 
@@ -212,14 +215,14 @@
 	struct amp_ctx *fnd = NULL;
 	struct amp_ctx *ctx;
 
-	read_lock_bh(&mgr->ctx_list_lock);
+	read_lock(&mgr->ctx_list_lock);
 	list_for_each_entry(ctx, &mgr->ctx_list, list) {
 		if ((ctx->type == type) && (ctx != cur)) {
 			fnd = ctx;
 			break;
 		}
 	}
-	read_unlock_bh(&mgr->ctx_list_lock);
+	read_unlock(&mgr->ctx_list_lock);
 	return fnd;
 }
 
@@ -228,7 +231,7 @@
 	struct amp_ctx *fnd = NULL;
 	struct amp_ctx *ctx;
 
-	read_lock_bh(&mgr->ctx_list_lock);
+	read_lock(&mgr->ctx_list_lock);
 	list_for_each_entry(ctx, &mgr->ctx_list, list) {
 		if ((ctx->evt_type & AMP_A2MP_RSP) &&
 				(ctx->rsp_ident == ident)) {
@@ -236,7 +239,7 @@
 			break;
 		}
 	}
-	read_unlock_bh(&mgr->ctx_list_lock);
+	read_unlock(&mgr->ctx_list_lock);
 	return fnd;
 }
 
@@ -246,10 +249,10 @@
 	struct amp_mgr *mgr;
 	struct amp_ctx *fnd = NULL;
 
-	read_lock_bh(&amp_mgr_list_lock);
+	read_lock(&amp_mgr_list_lock);
 	list_for_each_entry(mgr, &amp_mgr_list, list) {
 		struct amp_ctx *ctx;
-		read_lock_bh(&mgr->ctx_list_lock);
+		read_lock(&mgr->ctx_list_lock);
 		list_for_each_entry(ctx, &mgr->ctx_list, list) {
 			struct hci_dev *ctx_hdev;
 			ctx_hdev = hci_dev_get(A2MP_HCI_ID(ctx->id));
@@ -272,9 +275,9 @@
 			if (fnd)
 				break;
 		}
-		read_unlock_bh(&mgr->ctx_list_lock);
+		read_unlock(&mgr->ctx_list_lock);
 	}
-	read_unlock_bh(&amp_mgr_list_lock);
+	read_unlock(&amp_mgr_list_lock);
 	return fnd;
 }
 
@@ -371,13 +374,13 @@
 {
 	struct amp_mgr *mgr;
 
-	read_lock_bh(&amp_mgr_list_lock);
+	read_lock(&amp_mgr_list_lock);
 	list_for_each_entry(mgr, &amp_mgr_list, list) {
 		if (mgr->discovered)
 			send_a2mp_cl(mgr, next_ident(mgr),
 					A2MP_CHANGE_NOTIFY, 0, NULL);
 	}
-	read_unlock_bh(&amp_mgr_list_lock);
+	read_unlock(&amp_mgr_list_lock);
 }
 
 static inline int discover_req(struct amp_mgr *mgr, struct sk_buff *skb)
@@ -1517,10 +1520,10 @@
 	struct amp_ctx *ctx = NULL;
 
 	BT_DBG("mgr %p", mgr);
-	read_lock_bh(&mgr->ctx_list_lock);
+	read_lock(&mgr->ctx_list_lock);
 	if (!list_empty(&mgr->ctx_list))
 		ctx = list_first_entry(&mgr->ctx_list, struct amp_ctx, list);
-	read_unlock_bh(&mgr->ctx_list_lock);
+	read_unlock(&mgr->ctx_list_lock);
 	BT_DBG("ctx %p", ctx);
 	if (ctx)
 		execute_ctx(ctx, AMP_INIT, NULL);
@@ -1549,7 +1552,7 @@
 
 /* L2CAP-A2MP interface */
 
-void a2mp_receive(struct sock *sk, struct sk_buff *skb)
+static void a2mp_receive(struct sock *sk, struct sk_buff *skb)
 {
 	struct a2mp_cmd_hdr *hdr = (struct a2mp_cmd_hdr *) skb->data;
 	int len;