Merge "platform: msm8996: Add support for BLSP2" into lk.lnx.1.0-dev.1.0
diff --git a/platform/msm8996/acpuclock.c b/platform/msm8996/acpuclock.c
index ffceba4..7ed7ff6 100644
--- a/platform/msm8996/acpuclock.c
+++ b/platform/msm8996/acpuclock.c
@@ -37,6 +37,8 @@
#include <pm8x41.h>
#include <rpm-smd.h>
#include <regulator.h>
+#include <blsp_qup.h>
+#include <err.h>
#define RPM_CE_CLK_TYPE 0x6563
#define CE1_CLK_ID 0x0
@@ -604,3 +606,51 @@
writel(0x0, DSI_PIXEL1_CBCR);
}
}
+
+
+void clock_config_blsp_i2c(uint8_t blsp_id, uint8_t qup_id)
+{
+ uint8_t ret = 0;
+ char clk_name[64];
+
+ struct clk *qup_clk;
+
+ if((blsp_id != BLSP_ID_2) || ((qup_id != QUP_ID_1) &&
+ (qup_id != QUP_ID_3))) {
+ dprintf(CRITICAL, "Incorrect BLSP-%d or QUP-%d configuration\n",
+ blsp_id, qup_id);
+ ASSERT(0);
+ }
+
+ if (qup_id == QUP_ID_1) {
+ snprintf(clk_name, sizeof(clk_name), "blsp2_qup2_ahb_iface_clk");
+ }
+ else if (qup_id == QUP_ID_3) {
+ snprintf(clk_name, sizeof(clk_name), "blsp1_qup4_ahb_iface_clk");
+ }
+
+ ret = clk_get_set_enable(clk_name, 0 , 1);
+ if (ret) {
+ dprintf(CRITICAL, "Failed to enable %s clock\n", clk_name);
+ return;
+ }
+
+ if (qup_id == QUP_ID_1) {
+ snprintf(clk_name, sizeof(clk_name), "gcc_blsp2_qup2_i2c_apps_clk");
+ }
+ else if (qup_id == QUP_ID_3) {
+ snprintf(clk_name, sizeof(clk_name), "gcc_blsp1_qup4_i2c_apps_clk");
+ }
+
+ qup_clk = clk_get(clk_name);
+ if (!qup_clk) {
+ dprintf(CRITICAL, "Failed to get %s\n", clk_name);
+ return;
+ }
+
+ ret = clk_enable(qup_clk);
+ if (ret) {
+ dprintf(CRITICAL, "Failed to enable %s\n", clk_name);
+ return;
+ }
+}
\ No newline at end of file
diff --git a/platform/msm8996/gpio.c b/platform/msm8996/gpio.c
index 281584f..ba369e4 100644
--- a/platform/msm8996/gpio.c
+++ b/platform/msm8996/gpio.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -30,6 +30,7 @@
#include <reg.h>
#include <platform/iomap.h>
#include <platform/gpio.h>
+#include <blsp_qup.h>
/* Remove the file after the gpio patch to move this to msm_shared gets merged. */
void gpio_tlmm_config(uint32_t gpio, uint8_t func,
@@ -62,3 +63,28 @@
gpio_tlmm_config(4, 2, GPIO_OUTPUT, GPIO_NO_PULL,
GPIO_8MA, GPIO_DISABLE);
}
+
+
+/* Configure gpios for blsp */
+void gpio_config_blsp_i2c(uint8_t blsp_id, uint8_t qup_id)
+{
+ if(blsp_id == BLSP_ID_2) {
+ switch (qup_id) {
+ case QUP_ID_1:
+ /* configure I2C SDA gpio */
+ gpio_tlmm_config(GPIO_BLSP2_ACTIVE_1, 3, GPIO_OUTPUT,
+ GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE);
+
+ /* configure I2C SCL gpio */
+ gpio_tlmm_config(GPIO_BLSP2_ACTIVE_2, 3, GPIO_OUTPUT,
+ GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE);
+ break;
+ default:
+ dprintf(CRITICAL, "Incorrect QUP id %d\n", qup_id);
+ ASSERT(0);
+ };
+ } else {
+ dprintf(CRITICAL, "Incorrect BLSP id %d\n",blsp_id);
+ ASSERT(0);
+ }
+}
diff --git a/platform/msm8996/include/platform/clock.h b/platform/msm8996/include/platform/clock.h
index 4ad790f..01a551e 100644
--- a/platform/msm8996/include/platform/clock.h
+++ b/platform/msm8996/include/platform/clock.h
@@ -123,5 +123,6 @@
void mmss_gdsc_disable();
void video_gdsc_enable();
void video_gdsc_disable();
+void clock_config_blsp_i2c(uint8_t blsp_id, uint8_t qup_id);
#endif
diff --git a/platform/msm8996/include/platform/gpio.h b/platform/msm8996/include/platform/gpio.h
index 4d9c650..9cf42f1 100644
--- a/platform/msm8996/include/platform/gpio.h
+++ b/platform/msm8996/include/platform/gpio.h
@@ -55,6 +55,9 @@
#define GPIO_ENABLE 0
#define GPIO_DISABLE 1
+#define GPIO_BLSP2_ACTIVE_1 6
+#define GPIO_BLSP2_ACTIVE_2 7
+
void gpio_config_uart_dm(uint8_t id);
void gpio_config_blsp_i2c(uint8_t, uint8_t);
void gpio_set(uint32_t gpio, uint32_t dir);
diff --git a/platform/msm8996/include/platform/iomap.h b/platform/msm8996/include/platform/iomap.h
index 50d2542..2fb9c8a 100644
--- a/platform/msm8996/include/platform/iomap.h
+++ b/platform/msm8996/include/platform/iomap.h
@@ -68,6 +68,13 @@
#define BLSP2_UART1_BASE (PERIPH_SS_BASE + 0x001B0000)
+/* I2C */
+#define BLSP_QUP_BASE(blsp_id, qup_id) (PERIPH_SS_BASE + ((blsp_id) - 1) * 0x100000 \
+ + 0xB5000 + 0x1000 * (qup_id))
+#define GCC_BLSP2_QUP2_APPS_CBCR (CLK_CTL_BASE + 0x28008)
+#define GCC_BLSP2_QUP2_CFG_RCGR (CLK_CTL_BASE + 0x28010)
+#define GCC_BLSP2_QUP2_CMD_RCGR (CLK_CTL_BASE + 0x2800C)
+
/* USB3.0 */
#define MSM_USB30_BASE 0x6A00000
#define MSM_USB30_QSCRATCH_BASE 0x6AF8800
diff --git a/platform/msm8996/include/platform/irqs.h b/platform/msm8996/include/platform/irqs.h
index ab5e2ff..61d267b 100644
--- a/platform/msm8996/include/platform/irqs.h
+++ b/platform/msm8996/include/platform/irqs.h
@@ -67,4 +67,6 @@
#define NR_IRQS (NR_MSM_IRQS + NR_GPIO_IRQS + \
NR_BOARD_IRQS)
+#define BLSP_QUP_IRQ(blsp_id, qup_id) (GIC_SPI_START + 95 + blsp_id * \
+ 6 + qup_id)
#endif /* __IRQS_THULIUM_H */
diff --git a/platform/msm8996/msm8996-clock.c b/platform/msm8996/msm8996-clock.c
index 1d07cea..782a624 100644
--- a/platform/msm8996/msm8996-clock.c
+++ b/platform/msm8996/msm8996-clock.c
@@ -237,6 +237,40 @@
},
};
+static struct clk_freq_tbl ftbl_gcc_blsp1_qup2_i2c_apps_clk_src[] = {
+ F( 96000, cxo, 10, 1, 2),
+ F( 4800000, cxo, 4, 0, 0),
+ F( 9600000, cxo, 2, 0, 0),
+ F( 16000000, gpll0, 10, 1, 5),
+ F( 19200000, gpll0, 1, 0, 0),
+ F( 25000000, gpll0, 16, 1, 2),
+ F( 50000000, gpll0, 16, 0, 0),
+ F_END
+};
+
+static struct rcg_clk gcc_blsp2_qup2_i2c_apps_clk_src = {
+ .cmd_reg = (uint32_t *) GCC_BLSP2_QUP2_CMD_RCGR,
+ .cfg_reg = (uint32_t *) GCC_BLSP2_QUP2_CFG_RCGR,
+ .set_rate = clock_lib2_rcg_set_rate_hid,
+ .freq_tbl = ftbl_gcc_blsp1_qup2_i2c_apps_clk_src,
+ .current_freq = &rcg_dummy_freq,
+
+ .c = {
+ .dbg_name = "gcc_blsp2_qup2_i2c_apps_clk_src",
+ .ops = &clk_ops_rcg,
+ },
+};
+
+static struct branch_clk gcc_blsp2_qup2_i2c_apps_clk = {
+ .cbcr_reg = (uint32_t *) GCC_BLSP2_QUP2_APPS_CBCR,
+ .parent = &gcc_blsp2_qup2_i2c_apps_clk_src.c,
+
+ .c = {
+ .dbg_name = "gcc_blsp2_qup2_i2c_apps_clk",
+ .ops = &clk_ops_branch,
+ },
+};
+
/* SDCC Clocks */
static struct clk_freq_tbl ftbl_gcc_sdcc1_4_apps_clk[] =
{
@@ -731,6 +765,13 @@
CLK_LOOKUP("mmss_mmagic_ahb_clk", mmss_mmagic_ahb_clk.c),
CLK_LOOKUP("smmu_mdp_ahb_clk", smmu_mdp_ahb_clk.c),
CLK_LOOKUP("mdp_ahb_clk", mdp_ahb_clk.c),
+
+ /* BLSP CLOCKS */
+ CLK_LOOKUP("blsp2_qup2_ahb_iface_clk", gcc_blsp2_ahb_clk.c),
+ CLK_LOOKUP("gcc_blsp2_qup2_i2c_apps_clk_src",
+ gcc_blsp2_qup2_i2c_apps_clk_src.c),
+ CLK_LOOKUP("gcc_blsp2_qup2_i2c_apps_clk",
+ gcc_blsp2_qup2_i2c_apps_clk.c),
};
void platform_clock_init(void)
diff --git a/platform/msm_shared/include/blsp_qup.h b/platform/msm_shared/include/blsp_qup.h
index 4fc891c..41b7ab5 100644
--- a/platform/msm_shared/include/blsp_qup.h
+++ b/platform/msm_shared/include/blsp_qup.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013,2015, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
diff --git a/platform/msm_shared/include/i2c_qup.h b/platform/msm_shared/include/i2c_qup.h
index b5fd2bd..4105880 100644
--- a/platform/msm_shared/include/i2c_qup.h
+++ b/platform/msm_shared/include/i2c_qup.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2010-2013,2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -192,9 +192,6 @@
#define EPROTONOSUPPORT 93
#define ETIMEDOUT 110
-#define FALSE 0
-#define TRUE 1
-
#define USEC_PER_SEC 1000000L
#define IRQF_TRIGGER_NONE 0x00000000