Merge "msm: CDSP: Enable CDSP loader driver" into msm-4.9
diff --git a/arch/arm64/configs/sdm845-perf_defconfig b/arch/arm64/configs/sdm845-perf_defconfig
index 61bcdd6..e029f82 100644
--- a/arch/arm64/configs/sdm845-perf_defconfig
+++ b/arch/arm64/configs/sdm845-perf_defconfig
@@ -331,6 +331,7 @@
CONFIG_USB_CONFIGFS_F_CDEV=y
CONFIG_USB_CONFIGFS_F_CCID=y
CONFIG_USB_CONFIGFS_F_GSI=y
+CONFIG_USB_CONFIGFS_F_QDSS=y
CONFIG_MMC=y
CONFIG_MMC_BLOCK_MINORS=32
CONFIG_MMC_TEST=y
@@ -347,6 +348,7 @@
CONFIG_ION_MSM=y
CONFIG_SPS=y
CONFIG_SPS_SUPPORT_NDP_BAM=y
+CONFIG_USB_BAM=y
CONFIG_MSM_GCC_SDM845=y
CONFIG_MSM_VIDEOCC_SDM845=y
CONFIG_REMOTE_SPINLOCK_MSM=y
diff --git a/arch/arm64/configs/sdm845_defconfig b/arch/arm64/configs/sdm845_defconfig
index d52229a..6cca05a 100644
--- a/arch/arm64/configs/sdm845_defconfig
+++ b/arch/arm64/configs/sdm845_defconfig
@@ -337,6 +337,7 @@
CONFIG_USB_CONFIGFS_F_CDEV=y
CONFIG_USB_CONFIGFS_F_CCID=y
CONFIG_USB_CONFIGFS_F_GSI=y
+CONFIG_USB_CONFIGFS_F_QDSS=y
CONFIG_MMC=y
CONFIG_MMC_BLOCK_MINORS=32
CONFIG_MMC_TEST=y
@@ -358,6 +359,7 @@
CONFIG_ION_MSM=y
CONFIG_SPS=y
CONFIG_SPS_SUPPORT_NDP_BAM=y
+CONFIG_USB_BAM=y
CONFIG_MSM_GCC_SDM845=y
CONFIG_MSM_VIDEOCC_SDM845=y
CONFIG_REMOTE_SPINLOCK_MSM=y
diff --git a/drivers/cpuidle/lpm-levels.c b/drivers/cpuidle/lpm-levels.c
index cc380a0..8b59bee 100644
--- a/drivers/cpuidle/lpm-levels.c
+++ b/drivers/cpuidle/lpm-levels.c
@@ -381,7 +381,9 @@ static void clusttimer_cancel(void)
struct lpm_cluster *cluster = per_cpu(cpu_cluster, cpu);
hrtimer_try_to_cancel(&cluster->histtimer);
- hrtimer_try_to_cancel(&cluster->parent->histtimer);
+
+ if (cluster->parent)
+ hrtimer_try_to_cancel(&cluster->parent->histtimer);
}
static enum hrtimer_restart clusttimer_fn(struct hrtimer *h)
diff --git a/drivers/gpu/drm/msm/sde/sde_hw_catalog_8996.c b/drivers/gpu/drm/msm/sde/sde_hw_catalog_8996.c
deleted file mode 100644
index 652331f..0000000
--- a/drivers/gpu/drm/msm/sde/sde_hw_catalog_8996.c
+++ /dev/null
@@ -1,671 +0,0 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. 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 and
- * only version 2 as published by the Free Software Foundation.
- *
- * 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.
- */
-
-#include "sde_hw_catalog.h"
-#include "sde_hw_mdss.h"
-#include "sde_hwio.h"
-
-/* VIG layer capability */
-#define VIG_17X_MASK \
- (BIT(SDE_SSPP_SRC) | BIT(SDE_SSPP_SCALER_QSEED2) |\
- BIT(SDE_SSPP_CSC) | BIT(SDE_SSPP_HSIC) |\
- BIT(SDE_SSPP_PCC) | BIT(SDE_SSPP_IGC) |\
- BIT(SDE_SSPP_MEMCOLOR) | BIT(SDE_SSPP_QOS))
-
-/* RGB layer capability */
-#define RGB_17X_MASK \
- (BIT(SDE_SSPP_SRC) | BIT(SDE_SSPP_SCALER_RGB) |\
- BIT(SDE_SSPP_PCC) | BIT(SDE_SSPP_IGC) | BIT(SDE_SSPP_QOS))
-
-/* DMA layer capability */
-#define DMA_17X_MASK \
- (BIT(SDE_SSPP_SRC) | BIT(SDE_SSPP_PCC) | BIT(SDE_SSPP_IGC) |\
- BIT(SDE_SSPP_QOS))
-
-/* Cursor layer capability */
-#define CURSOR_17X_MASK (BIT(SDE_SSPP_SRC) | BIT(SDE_SSPP_CURSOR))
-
-#define MIXER_17X_MASK (BIT(SDE_MIXER_SOURCESPLIT) |\
- BIT(SDE_MIXER_GC))
-
-#define DSPP_17X_MASK \
- (BIT(SDE_DSPP_IGC) | BIT(SDE_DSPP_PCC) |\
- BIT(SDE_DSPP_GC) | BIT(SDE_DSPP_HSIC) | BIT(SDE_DSPP_GAMUT) |\
- BIT(SDE_DSPP_DITHER) | BIT(SDE_DSPP_HIST) | BIT(SDE_DSPP_MEMCOLOR) |\
- BIT(SDE_DSPP_SIXZONE) | BIT(SDE_DSPP_AD) | BIT(SDE_DSPP_VLUT))
-
-#define PINGPONG_17X_MASK \
- (BIT(SDE_PINGPONG_TE) | BIT(SDE_PINGPONG_DSC))
-
-#define PINGPONG_17X_SPLIT_MASK \
- (PINGPONG_17X_MASK | BIT(SDE_PINGPONG_SPLIT) |\
- BIT(SDE_PINGPONG_TE2))
-
-#define WB01_17X_MASK \
- (BIT(SDE_WB_LINE_MODE) | BIT(SDE_WB_BLOCK_MODE) |\
- BIT(SDE_WB_CSC) | BIT(SDE_WB_CHROMA_DOWN) | BIT(SDE_WB_DOWNSCALE) |\
- BIT(SDE_WB_DITHER) | BIT(SDE_WB_TRAFFIC_SHAPER) |\
- BIT(SDE_WB_UBWC_1_0) | BIT(SDE_WB_YUV_CONFIG))
-
-#define WB2_17X_MASK \
- (BIT(SDE_WB_LINE_MODE) | BIT(SDE_WB_TRAFFIC_SHAPER) |\
- BIT(SDE_WB_YUV_CONFIG))
-
-#define DECIMATION_17X_MAX_H 4
-#define DECIMATION_17X_MAX_V 4
-
-#define RES_1080p ((u64)(1088*1920))
-#define RES_UHD ((u64)(3840*2160))
-
-static const struct sde_format_extended plane_formats[] = {
- {DRM_FORMAT_ARGB8888, 0},
- {DRM_FORMAT_ABGR8888, 0},
- {DRM_FORMAT_RGBA8888, 0},
- {DRM_FORMAT_RGBA8888, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_BGRA8888, 0},
- {DRM_FORMAT_XRGB8888, 0},
- {DRM_FORMAT_RGBX8888, 0},
- {DRM_FORMAT_RGBX8888, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_RGB888, 0},
- {DRM_FORMAT_BGR888, 0},
- {DRM_FORMAT_RGB565, 0},
- {DRM_FORMAT_RGB565, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_BGR565, 0},
- {DRM_FORMAT_ARGB1555, 0},
- {DRM_FORMAT_ABGR1555, 0},
- {DRM_FORMAT_RGBA5551, 0},
- {DRM_FORMAT_BGRA5551, 0},
- {DRM_FORMAT_XRGB1555, 0},
- {DRM_FORMAT_XBGR1555, 0},
- {DRM_FORMAT_RGBX5551, 0},
- {DRM_FORMAT_BGRX5551, 0},
- {DRM_FORMAT_ARGB4444, 0},
- {DRM_FORMAT_ABGR4444, 0},
- {DRM_FORMAT_RGBA4444, 0},
- {DRM_FORMAT_BGRA4444, 0},
- {DRM_FORMAT_XRGB4444, 0},
- {DRM_FORMAT_XBGR4444, 0},
- {DRM_FORMAT_RGBX4444, 0},
- {DRM_FORMAT_BGRX4444, 0},
- {0, 0},
-};
-
-static const struct sde_format_extended plane_formats_yuv[] = {
- {DRM_FORMAT_ARGB8888, 0},
- {DRM_FORMAT_ABGR8888, 0},
- {DRM_FORMAT_RGBA8888, 0},
- {DRM_FORMAT_RGBA8888, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_BGRA8888, 0},
- {DRM_FORMAT_XRGB8888, 0},
- {DRM_FORMAT_RGBX8888, 0},
- {DRM_FORMAT_RGBX8888, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_RGB888, 0},
- {DRM_FORMAT_BGR888, 0},
- {DRM_FORMAT_RGB565, 0},
- {DRM_FORMAT_RGB565, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_BGR565, 0},
- {DRM_FORMAT_ARGB1555, 0},
- {DRM_FORMAT_ABGR1555, 0},
- {DRM_FORMAT_RGBA5551, 0},
- {DRM_FORMAT_BGRA5551, 0},
- {DRM_FORMAT_XRGB1555, 0},
- {DRM_FORMAT_XBGR1555, 0},
- {DRM_FORMAT_RGBX5551, 0},
- {DRM_FORMAT_BGRX5551, 0},
- {DRM_FORMAT_ARGB4444, 0},
- {DRM_FORMAT_ABGR4444, 0},
- {DRM_FORMAT_RGBA4444, 0},
- {DRM_FORMAT_BGRA4444, 0},
- {DRM_FORMAT_XRGB4444, 0},
- {DRM_FORMAT_XBGR4444, 0},
- {DRM_FORMAT_RGBX4444, 0},
- {DRM_FORMAT_BGRX4444, 0},
- {DRM_FORMAT_NV12, 0},
- {DRM_FORMAT_NV12, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_NV21, 0},
- {DRM_FORMAT_NV16, 0},
- {DRM_FORMAT_NV61, 0},
- {DRM_FORMAT_VYUY, 0},
- {DRM_FORMAT_UYVY, 0},
- {DRM_FORMAT_YUYV, 0},
- {DRM_FORMAT_YVYU, 0},
- {DRM_FORMAT_YUV420, 0},
- {DRM_FORMAT_YVU420, 0},
- {0, 0},
-};
-
-static const struct sde_format_extended wb0_formats[] = {
- {DRM_FORMAT_RGB565, 0},
- {DRM_FORMAT_RGB888, 0},
- {DRM_FORMAT_ARGB8888, 0},
- {DRM_FORMAT_RGBA8888, 0},
- {DRM_FORMAT_XRGB8888, 0},
- {DRM_FORMAT_RGBX8888, 0},
- {DRM_FORMAT_ARGB1555, 0},
- {DRM_FORMAT_RGBA5551, 0},
- {DRM_FORMAT_XRGB1555, 0},
- {DRM_FORMAT_RGBX5551, 0},
- {DRM_FORMAT_ARGB4444, 0},
- {DRM_FORMAT_RGBA4444, 0},
- {DRM_FORMAT_RGBX4444, 0},
- {DRM_FORMAT_XRGB4444, 0},
-
- {DRM_FORMAT_BGR565, 0},
- {DRM_FORMAT_BGR888, 0},
- {DRM_FORMAT_ABGR8888, 0},
- {DRM_FORMAT_BGRA8888, 0},
- {DRM_FORMAT_BGRX8888, 0},
- {DRM_FORMAT_ABGR1555, 0},
- {DRM_FORMAT_BGRA5551, 0},
- {DRM_FORMAT_XBGR1555, 0},
- {DRM_FORMAT_BGRX5551, 0},
- {DRM_FORMAT_ABGR4444, 0},
- {DRM_FORMAT_BGRA4444, 0},
- {DRM_FORMAT_BGRX4444, 0},
- {DRM_FORMAT_XBGR4444, 0},
-
- {DRM_FORMAT_RGBX8888, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_RGBA8888, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_RGB565, DRM_FORMAT_MOD_QCOM_COMPRESSED},
-
- {DRM_FORMAT_YUV420, 0},
- {DRM_FORMAT_NV12, 0},
- {DRM_FORMAT_NV16, 0},
- {DRM_FORMAT_NV21, 0},
- {DRM_FORMAT_NV61, 0},
- {DRM_FORMAT_UYVY, 0},
- {DRM_FORMAT_YUYV, 0},
-
- {DRM_FORMAT_NV12, DRM_FORMAT_MOD_QCOM_COMPRESSED},
- {DRM_FORMAT_AYUV, DRM_FORMAT_MOD_QCOM_COMPRESSED},
-
- {0, 0},
-};
-
-static const struct sde_format_extended wb2_formats[] = {
- {DRM_FORMAT_RGB565, 0},
- {DRM_FORMAT_RGB888, 0},
- {DRM_FORMAT_ARGB8888, 0},
- {DRM_FORMAT_RGBA8888, 0},
- {DRM_FORMAT_XRGB8888, 0},
- {DRM_FORMAT_RGBX8888, 0},
- {DRM_FORMAT_ARGB1555, 0},
- {DRM_FORMAT_RGBA5551, 0},
- {DRM_FORMAT_XRGB1555, 0},
- {DRM_FORMAT_RGBX5551, 0},
- {DRM_FORMAT_ARGB4444, 0},
- {DRM_FORMAT_RGBA4444, 0},
- {DRM_FORMAT_RGBX4444, 0},
- {DRM_FORMAT_XRGB4444, 0},
-
- {DRM_FORMAT_BGR565, 0},
- {DRM_FORMAT_BGR888, 0},
- {DRM_FORMAT_ABGR8888, 0},
- {DRM_FORMAT_BGRA8888, 0},
- {DRM_FORMAT_BGRX8888, 0},
- {DRM_FORMAT_ABGR1555, 0},
- {DRM_FORMAT_BGRA5551, 0},
- {DRM_FORMAT_XBGR1555, 0},
- {DRM_FORMAT_BGRX5551, 0},
- {DRM_FORMAT_ABGR4444, 0},
- {DRM_FORMAT_BGRA4444, 0},
- {DRM_FORMAT_BGRX4444, 0},
- {DRM_FORMAT_XBGR4444, 0},
-
- {DRM_FORMAT_YUV420, 0},
- {DRM_FORMAT_NV12, 0},
- {DRM_FORMAT_NV16, 0},
- {DRM_FORMAT_YUYV, 0},
-
- {0, 0},
-};
-
-/**
- * set_cfg_1xx_init(): populate sde sub-blocks reg offsets and instance counts
- */
-static inline int set_cfg_1xx_init(struct sde_mdss_cfg *cfg)
-{
-
- /* Layer capability */
- static const struct sde_sspp_sub_blks vig_layer = {
- .maxlinewidth = 2560,
- .danger_lut_linear = 0x000f,
- .safe_lut_linear = 0xfffc,
- .danger_lut_tile = 0xffff,
- .safe_lut_tile = 0xff00,
- .danger_lut_nrt = 0x0,
- .safe_lut_nrt = 0xffff,
- .creq_lut_nrt = 0x0,
- .creq_vblank = 0x2,
- .danger_vblank = 0,
- .pixel_ram_size = 50 * 1024,
- .maxdwnscale = 4, .maxupscale = 20,
- .maxhdeciexp = DECIMATION_17X_MAX_H,
- .maxvdeciexp = DECIMATION_17X_MAX_V,
- .src_blk = {.id = SDE_SSPP_SRC,
- .base = 0x00, .len = 0x150,},
- .scaler_blk = {.id = SDE_SSPP_SCALER_QSEED2,
- .base = 0x200, .len = 0x70,},
- .csc_blk = {.id = SDE_SSPP_CSC,
- .base = 0x320, .len = 0x44,},
- .format_list = plane_formats_yuv,
- .igc_blk = {.id = SDE_SSPP_IGC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .pcc_blk = {.id = SDE_SSPP_PCC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .hsic = {.id = SDE_SSPP_HSIC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .memcolor = {.id = SDE_SSPP_MEMCOLOR, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- };
-
- static const struct sde_sspp_sub_blks layer = {
- .maxlinewidth = 2560,
- .danger_lut_linear = 0x000f,
- .safe_lut_linear = 0xfffc,
- .danger_lut_tile = 0xffff,
- .safe_lut_tile = 0xff00,
- .danger_lut_nrt = 0x0,
- .safe_lut_nrt = 0xffff,
- .creq_lut_nrt = 0x0,
- .creq_vblank = 0x2,
- .danger_vblank = 0,
- .pixel_ram_size = 50 * 1024,
- .maxdwnscale = 4, .maxupscale = 20,
- .maxhdeciexp = DECIMATION_17X_MAX_H,
- .maxvdeciexp = DECIMATION_17X_MAX_V,
- .src_blk = {.id = SDE_SSPP_SRC,
- .base = 0x00, .len = 0x150,},
- .scaler_blk = {.id = SDE_SSPP_SCALER_QSEED2,
- .base = 0x200, .len = 0x70,},
- .csc_blk = {.id = SDE_SSPP_CSC,
- .base = 0x320, .len = 0x44,},
- .format_list = plane_formats,
- .igc_blk = {.id = SDE_SSPP_IGC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .pcc_blk = {.id = SDE_SSPP_PCC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- };
-
- static const struct sde_sspp_sub_blks dma = {
- .maxlinewidth = 2560,
- .danger_lut_linear = 0x000f,
- .safe_lut_linear = 0xfffc,
- .danger_lut_tile = 0xffff,
- .safe_lut_tile = 0xff00,
- .danger_lut_nrt = 0x0,
- .safe_lut_nrt = 0xffff,
- .creq_lut_nrt = 0x0,
- .creq_vblank = 0x2,
- .danger_vblank = 0,
- .pixel_ram_size = 50 * 1024,
- .maxdwnscale = 1, .maxupscale = 1,
- .maxhdeciexp = DECIMATION_17X_MAX_H,
- .maxvdeciexp = DECIMATION_17X_MAX_V,
- .src_blk = {.id = SDE_SSPP_SRC, .base = 0x00, .len = 0x150,},
- .scaler_blk = {.id = 0, .base = 0x00, .len = 0x0,},
- .csc_blk = {.id = 0, .base = 0x00, .len = 0x0,},
- .format_list = plane_formats,
- .igc_blk = {.id = SDE_SSPP_IGC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .pcc_blk = {.id = SDE_SSPP_PCC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- };
-
- static const struct sde_sspp_sub_blks cursor = {
- .maxlinewidth = 128,
- .maxdwnscale = 1, .maxupscale = 1,
- .maxhdeciexp = 0,
- .maxvdeciexp = 0,
- .src_blk = {.id = SDE_SSPP_SRC, .base = 0x00, .len = 0x150,},
- .scaler_blk = {.id = 0, .base = 0x00, .len = 0x0,},
- .csc_blk = {.id = 0, .base = 0x00, .len = 0x0,},
- .format_list = plane_formats,
- };
-
- /* MIXER capability */
- static const struct sde_lm_sub_blks lm = {
- .maxwidth = 2560,
- .maxblendstages = 7, /* excluding base layer */
- .blendstage_base = { /* offsets relative to mixer base */
- 0x20, 0x50, 0x80, 0xB0, 0x230, 0x260, 0x290 },
- .gc = {.id = SDE_DSPP_GC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- };
-
- /* DSPP capability */
- static const struct sde_dspp_sub_blks dspp = {
- .igc = {.id = SDE_DSPP_IGC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .pcc = {.id = SDE_DSPP_PCC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .gamut = {.id = SDE_DSPP_GAMUT, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .dither = {.id = SDE_DSPP_DITHER, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .hsic = {.id = SDE_DSPP_HSIC, .base = 0x00, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .memcolor = {.id = SDE_DSPP_MEMCOLOR, .base = 0x00, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .sixzone = {.id = SDE_DSPP_SIXZONE, .base = 0x00, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .hist = {.id = SDE_DSPP_HIST, .base = 0x00, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .gc = {.id = SDE_DSPP_GC, .base = 0x0, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- .ad = {.id = SDE_DSPP_AD, .base = 0x00, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x3, 0x0)},
- .vlut = {.id = SDE_DSPP_VLUT, .base = 0x1400, .len = 0x0,
- .version = SDE_COLOR_PROCESS_VER(0x1, 0x0)},
- };
-
- /* PINGPONG capability */
- static const struct sde_pingpong_sub_blks pingpong = {
- .te = {.id = SDE_PINGPONG_TE, .base = 0x0000, .len = 0x0,
- .version = 0x1},
- .te2 = {.id = SDE_PINGPONG_TE2, .base = 0x2000, .len = 0x0,
- .version = 0x1},
- .dsc = {.id = SDE_PINGPONG_DSC, .base = 0x10000, .len = 0x0,
- .version = 0x1},
- };
-
- /* Writeback 0/1 capability */
- static const struct sde_wb_sub_blocks wb0 = {
- .maxlinewidth = 2048,
- };
-
- /* Writeback 2 capability */
- static const struct sde_wb_sub_blocks wb2 = {
- .maxlinewidth = 4096,
- };
-
- static const struct sde_vbif_dynamic_ot_cfg dynamic_ot_cfg[] = {
- {RES_1080p * 30, 2},
- {RES_1080p * 60, 4},
- {RES_UHD * 30, 16},
- };
-
- /* Setup Register maps and defaults */
- *cfg = (struct sde_mdss_cfg){
- .mdss_count = 1,
- .mdss = {
- {.id = MDP_TOP, .base = 0x00000000, .features = 0}
- },
- .mdp_count = 1,
- .mdp = {
- {.id = MDP_TOP, .base = 0x00001000, .features = 0,
- .highest_bank_bit = 0x2,
- .clk_ctrls[SDE_CLK_CTRL_VIG0] = {
- .reg_off = 0x2AC, .bit_off = 0},
- .clk_ctrls[SDE_CLK_CTRL_VIG1] = {
- .reg_off = 0x2B4, .bit_off = 0},
- .clk_ctrls[SDE_CLK_CTRL_VIG2] = {
- .reg_off = 0x2BC, .bit_off = 0},
- .clk_ctrls[SDE_CLK_CTRL_VIG3] = {
- .reg_off = 0x2C4, .bit_off = 0},
- .clk_ctrls[SDE_CLK_CTRL_RGB0] = {
- .reg_off = 0x2AC, .bit_off = 4},
- .clk_ctrls[SDE_CLK_CTRL_RGB1] = {
- .reg_off = 0x2B4, .bit_off = 4},
- .clk_ctrls[SDE_CLK_CTRL_RGB2] = {
- .reg_off = 0x2BC, .bit_off = 4},
- .clk_ctrls[SDE_CLK_CTRL_RGB3] = {
- .reg_off = 0x2C4, .bit_off = 4},
- .clk_ctrls[SDE_CLK_CTRL_DMA0] = {
- .reg_off = 0x2AC, .bit_off = 8},
- .clk_ctrls[SDE_CLK_CTRL_DMA1] = {
- .reg_off = 0x2B4, .bit_off = 8},
- .clk_ctrls[SDE_CLK_CTRL_CURSOR0] = {
- .reg_off = 0x3A8, .bit_off = 16},
- .clk_ctrls[SDE_CLK_CTRL_CURSOR1] = {
- .reg_off = 0x3B0, .bit_off = 16},
- .clk_ctrls[SDE_CLK_CTRL_WB0] = {
- .reg_off = 0x2BC, .bit_off = 8},
- .clk_ctrls[SDE_CLK_CTRL_WB1] = {
- .reg_off = 0x2BC, .bit_off = 12},
- .clk_ctrls[SDE_CLK_CTRL_WB2] = {
- .reg_off = 0x2BC, .bit_off = 16},
- },
- },
- .ctl_count = 5,
- .ctl = {
- {.id = CTL_0,
- .base = 0x00002000,
- .features = BIT(SDE_CTL_SPLIT_DISPLAY) |
- BIT(SDE_CTL_PINGPONG_SPLIT) },
- {.id = CTL_1,
- .base = 0x00002200,
- .features = BIT(SDE_CTL_SPLIT_DISPLAY) },
- {.id = CTL_2,
- .base = 0x00002400},
- {.id = CTL_3,
- .base = 0x00002600},
- {.id = CTL_4,
- .base = 0x00002800},
- },
- /* 4 VIG, + 4 RGB + 2 DMA + 2 CURSOR */
- .sspp_count = 12,
- .sspp = {
- {.id = SSPP_VIG0, .base = 0x00005000,
- .features = VIG_17X_MASK, .sblk = &vig_layer,
- .xin_id = 0,
- .clk_ctrl = SDE_CLK_CTRL_VIG0},
- {.id = SSPP_VIG1, .base = 0x00007000,
- .features = VIG_17X_MASK, .sblk = &vig_layer,
- .xin_id = 4,
- .clk_ctrl = SDE_CLK_CTRL_VIG1},
- {.id = SSPP_VIG2, .base = 0x00009000,
- .features = VIG_17X_MASK, .sblk = &vig_layer,
- .xin_id = 8,
- .clk_ctrl = SDE_CLK_CTRL_VIG2},
- {.id = SSPP_VIG3, .base = 0x0000b000,
- .features = VIG_17X_MASK, .sblk = &vig_layer,
- .xin_id = 12,
- .clk_ctrl = SDE_CLK_CTRL_VIG3},
-
- {.id = SSPP_RGB0, .base = 0x00015000,
- .features = RGB_17X_MASK, .sblk = &layer,
- .xin_id = 1,
- .clk_ctrl = SDE_CLK_CTRL_RGB0},
- {.id = SSPP_RGB1, .base = 0x00017000,
- .features = RGB_17X_MASK, .sblk = &layer,
- .xin_id = 5,
- .clk_ctrl = SDE_CLK_CTRL_RGB1},
- {.id = SSPP_RGB2, .base = 0x00019000,
- .features = RGB_17X_MASK, .sblk = &layer,
- .xin_id = 9,
- .clk_ctrl = SDE_CLK_CTRL_RGB2},
- {.id = SSPP_RGB3, .base = 0x0001B000,
- .features = RGB_17X_MASK, .sblk = &layer,
- .xin_id = 13,
- .clk_ctrl = SDE_CLK_CTRL_RGB3},
-
- {.id = SSPP_DMA0, .base = 0x00025000,
- .features = DMA_17X_MASK, .sblk = &dma,
- .xin_id = 2,
- .clk_ctrl = SDE_CLK_CTRL_DMA0},
- {.id = SSPP_DMA1, .base = 0x00027000,
- .features = DMA_17X_MASK, .sblk = &dma,
- .xin_id = 10,
- .clk_ctrl = SDE_CLK_CTRL_DMA1},
-
- {.id = SSPP_CURSOR0, .base = 0x00035000,
- .features = CURSOR_17X_MASK, .sblk = &cursor,
- .xin_id = 7,
- .clk_ctrl = SDE_CLK_CTRL_CURSOR0},
- {.id = SSPP_CURSOR1, .base = 0x00037000,
- .features = CURSOR_17X_MASK, .sblk = &cursor,
- .xin_id = 7,
- .clk_ctrl = SDE_CLK_CTRL_CURSOR1},
- },
- .mixer_count = 6,
- .mixer = {
- {.id = LM_0, .base = 0x00045000,
- .features = MIXER_17X_MASK,
- .sblk = &lm,
- .dspp = DSPP_0,
- .pingpong = PINGPONG_0,
- .lm_pair_mask = (1 << LM_1) },
- {.id = LM_1, .base = 0x00046000,
- .features = MIXER_17X_MASK,
- .sblk = &lm,
- .dspp = DSPP_1,
- .pingpong = PINGPONG_1,
- .lm_pair_mask = (1 << LM_0) },
- {.id = LM_2, .base = 0x00047000,
- .features = MIXER_17X_MASK,
- .sblk = &lm,
- .dspp = DSPP_MAX,
- .pingpong = PINGPONG_2,
- .lm_pair_mask = (1 << LM_5) },
- {.id = LM_3, .base = 0x00048000,
- .features = MIXER_17X_MASK,
- .sblk = &lm,
- .dspp = DSPP_MAX,
- .pingpong = PINGPONG_MAX},
- {.id = LM_4, .base = 0x00049000,
- .features = MIXER_17X_MASK,
- .sblk = &lm,
- .dspp = DSPP_MAX,
- .pingpong = PINGPONG_MAX},
- {.id = LM_5, .base = 0x0004a000,
- .features = MIXER_17X_MASK,
- .sblk = &lm,
- .dspp = DSPP_MAX,
- .pingpong = PINGPONG_3,
- .lm_pair_mask = (1 << LM_2) },
- },
- .dspp_count = 2,
- .dspp = {
- {.id = DSPP_0, .base = 0x00055000,
- .features = DSPP_17X_MASK,
- .sblk = &dspp},
- {.id = DSPP_1, .base = 0x00057000,
- .features = DSPP_17X_MASK,
- .sblk = &dspp},
- },
- .pingpong_count = 4,
- .pingpong = {
- {.id = PINGPONG_0, .base = 0x00071000,
- .features = PINGPONG_17X_SPLIT_MASK,
- .sblk = &pingpong},
- {.id = PINGPONG_1, .base = 0x00071800,
- .features = PINGPONG_17X_SPLIT_MASK,
- .sblk = &pingpong},
- {.id = PINGPONG_2, .base = 0x00072000,
- .features = PINGPONG_17X_MASK,
- .sblk = &pingpong},
- {.id = PINGPONG_3, .base = 0x00072800,
- .features = PINGPONG_17X_MASK,
- .sblk = &pingpong},
- },
- .cdm_count = 1,
- .cdm = {
- {.id = CDM_0, .base = 0x0007A200, .features = 0,
- .intf_connect = BIT(INTF_3),
- .wb_connect = BIT(WB_2),}
- },
- .intf_count = 4,
- .intf = {
- {.id = INTF_0, .base = 0x0006B000,
- .type = INTF_NONE, .controller_id = 0,
- .prog_fetch_lines_worst_case = 21},
- {.id = INTF_1, .base = 0x0006B800,
- .type = INTF_DSI, .controller_id = 0,
- .prog_fetch_lines_worst_case = 21},
- {.id = INTF_2, .base = 0x0006C000,
- .type = INTF_DSI, .controller_id = 1,
- .prog_fetch_lines_worst_case = 21},
- {.id = INTF_3, .base = 0x0006C800,
- .type = INTF_HDMI, .controller_id = 0,
- .prog_fetch_lines_worst_case = 21},
- },
- .wb_count = 3,
- .wb = {
- {.id = WB_0, .base = 0x00065000,
- .features = WB01_17X_MASK,
- .sblk = &wb0,
- .format_list = wb0_formats,
- .vbif_idx = VBIF_NRT,
- .xin_id = 3,
- .clk_ctrl = SDE_CLK_CTRL_WB0},
- {.id = WB_1, .base = 0x00065800,
- .features = WB01_17X_MASK,
- .sblk = &wb0,
- .format_list = wb0_formats,
- .vbif_idx = VBIF_NRT,
- .xin_id = 11,
- .clk_ctrl = SDE_CLK_CTRL_WB1},
- {.id = WB_2, .base = 0x00066000,
- .features = WB2_17X_MASK,
- .sblk = &wb2,
- .format_list = wb2_formats,
- .vbif_idx = VBIF_NRT,
- .xin_id = 6,
- .clk_ctrl = SDE_CLK_CTRL_WB2},
- },
- .vbif_count = 2,
- .vbif = {
- {.id = VBIF_0,
- .base = 0, /* 0x000B0000 */
- .features = BIT(SDE_VBIF_QOS_OTLIM),
- .default_ot_rd_limit = 32,
- .default_ot_wr_limit = 16,
- .xin_halt_timeout = 0x4000,
- .dynamic_ot_rd_tbl = {
- .count = ARRAY_SIZE(dynamic_ot_cfg),
- .cfg = dynamic_ot_cfg},
- .dynamic_ot_wr_tbl = {
- .count = ARRAY_SIZE(dynamic_ot_cfg),
- .cfg = dynamic_ot_cfg},
- },
- {.id = VBIF_1,
- .base = 0, /* 0x000B8000 */
- .features = BIT(SDE_VBIF_QOS_OTLIM),
- .default_ot_rd_limit = 32,
- .default_ot_wr_limit = 16,
- .xin_halt_timeout = 0x4000,
- .dynamic_ot_rd_tbl = {
- .count = ARRAY_SIZE(dynamic_ot_cfg),
- .cfg = dynamic_ot_cfg},
- .dynamic_ot_wr_tbl = {
- .count = ARRAY_SIZE(dynamic_ot_cfg),
- .cfg = dynamic_ot_cfg},
- },
- },
- };
- return 0;
-}
-
-/**
- * sde_mdp_cfg_170_init(): Populate the sde sub-blocks catalog information
- */
-struct sde_mdss_cfg *sde_mdss_cfg_170_init(u32 step)
-{
- struct sde_mdss_cfg *m = NULL;
-
- /*
- * This function, for each sub-block sets,
- * instance count, IO regions,
- * default capabilities and this version capabilities,
- * Additional catalog items
- */
-
- m = kzalloc(sizeof(*m), GFP_KERNEL);
- if (!m)
- return NULL;
-
- set_cfg_1xx_init(m);
- m->hwversion = SDE_HW_VER(1, 7, step);
-
- return m;
-}
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 4d6ee1b..c704c47 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -635,7 +635,7 @@ static int arm_smmu_register_legacy_master(struct device *dev,
__be32 pci_sid;
int err = 0;
- memset(&it, sizeof(it), 0);
+ memset(&it, 0, sizeof(it));
np = dev_get_dev_node(dev);
if (!np || !of_find_property(np, "#stream-id-cells", NULL)) {
of_node_put(np);
diff --git a/drivers/mailbox/qti-tcs.c b/drivers/mailbox/qti-tcs.c
index acf14d8..bcd5fb9 100644
--- a/drivers/mailbox/qti-tcs.c
+++ b/drivers/mailbox/qti-tcs.c
@@ -79,7 +79,6 @@
/* Control/Hidden TCS */
#define TCS_HIDDEN_MAX_SLOTS 3
-#define TCS_HIDDEN_CMD0_DRV_ADDR 0x34
#define TCS_HIDDEN_CMD0_DRV_DATA 0x38
#define TCS_HIDDEN_CMD_SHIFT 0x08
@@ -830,15 +829,12 @@ static int tcs_mbox_invalidate(struct mbox_chan *chan)
static void __tcs_write_hidden(void *base, int d, struct tcs_mbox_msg *msg)
{
int i;
- void __iomem *addr;
- const u32 offset = TCS_HIDDEN_CMD0_DRV_DATA - TCS_HIDDEN_CMD0_DRV_ADDR;
+ void __iomem *addr = base + TCS_HIDDEN_CMD0_DRV_DATA;
- addr = base + TCS_HIDDEN_CMD0_DRV_ADDR;
for (i = 0; i < msg->num_payload; i++) {
/* Only data is write capable */
- writel_relaxed(cpu_to_le32(msg->payload[i].data),
- addr + offset);
- trace_rpmh_control_msg(addr + offset, msg->payload[i].data);
+ writel_relaxed(cpu_to_le32(msg->payload[i].data), addr);
+ trace_rpmh_control_msg(addr, msg->payload[i].data);
addr += TCS_HIDDEN_CMD_SHIFT;
}
}
@@ -899,11 +895,6 @@ static int chan_tcs_ctrl_write(struct mbox_chan *chan, void *data)
goto tx_done;
}
- if (msg->is_complete) {
- dev_err(dev, "Incorrect ctrl request.\n");
- goto tx_done;
- }
-
/* Post the message to the TCS without trigger */
ret = tcs_mbox_write(chan, msg, false);
diff --git a/drivers/media/platform/msm/vidc/msm_vidc.c b/drivers/media/platform/msm/vidc/msm_vidc.c
index 1b93ee9..5d206d3 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc.c
@@ -1041,6 +1041,7 @@ static inline int vb2_bufq_init(struct msm_vidc_inst *inst,
q->mem_ops = &msm_vidc_vb2_mem_ops;
q->drv_priv = inst;
q->allow_zero_bytesused = 1;
+ q->copy_timestamp = 1;
return vb2_queue_init(q);
}
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.c b/drivers/media/platform/msm/vidc/msm_vidc_common.c
index a134364..564ab99 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.c
@@ -2012,7 +2012,7 @@ static void handle_fbd(enum hal_command_response cmd, void *data)
struct vidc_hal_fbd *fill_buf_done;
enum hal_buffer buffer_type;
int extra_idx = 0;
- int64_t time_usec = 0;
+ u64 time_nsec = 0;
struct vb2_v4l2_buffer *vbuf = NULL;
if (!response) {
@@ -2057,11 +2057,11 @@ static void handle_fbd(enum hal_command_response cmd, void *data)
vb->planes[0].length);
if (!(fill_buf_done->flags1 &
HAL_BUFFERFLAG_TIMESTAMPINVALID)) {
- time_usec = fill_buf_done->timestamp_hi;
- time_usec = (time_usec << 32) |
+ time_nsec = fill_buf_done->timestamp_hi;
+ time_nsec = (time_nsec << 32) |
fill_buf_done->timestamp_lo;
} else {
- time_usec = 0;
+ time_nsec = 0;
dprintk(VIDC_DBG,
"Set zero timestamp for buffer %pa, filled: %d, (hi:%u, lo:%u)\n",
&fill_buf_done->packet_buffer1,
@@ -2070,8 +2070,8 @@ static void handle_fbd(enum hal_command_response cmd, void *data)
fill_buf_done->timestamp_lo);
}
vbuf->flags = 0;
-// vb->timestamp = (u64)
-// ns_to_timeval(time_usec * NSEC_PER_USEC);
+ vb->timestamp = time_nsec;
+
extra_idx =
EXTRADATA_IDX(inst->fmts[CAPTURE_PORT].num_planes);
if (extra_idx && extra_idx < VIDEO_MAX_PLANES) {
@@ -2135,7 +2135,7 @@ static void handle_fbd(enum hal_command_response cmd, void *data)
dprintk(VIDC_DBG,
"Got fbd from hal: device_addr: %pa, alloc: %d, filled: %d, offset: %d, ts: %lld, flags: %#x, crop: %d %d %d %d, pic_type: %#x, mark_data: %#x\n",
&fill_buf_done->packet_buffer1, fill_buf_done->alloc_len1,
- fill_buf_done->filled_len1, fill_buf_done->offset1, time_usec,
+ fill_buf_done->filled_len1, fill_buf_done->offset1, time_nsec,
fill_buf_done->flags1, fill_buf_done->start_x_coord,
fill_buf_done->start_y_coord, fill_buf_done->frame_width,
fill_buf_done->frame_height, fill_buf_done->picture_type,
@@ -3583,18 +3583,15 @@ int msm_vidc_comm_cmd(void *instance, union msm_v4l2_cmd *cmd)
static void populate_frame_data(struct vidc_frame_data *data,
const struct vb2_buffer *vb, struct msm_vidc_inst *inst)
{
- int64_t time_usec = 0;
int extra_idx;
enum v4l2_buf_type type = vb->type;
enum vidc_ports port = type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ?
OUTPUT_PORT : CAPTURE_PORT;
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
- do_div(time_usec, NSEC_PER_USEC);
-
data->alloc_len = vb->planes[0].length;
data->device_addr = vb->planes[0].m.userptr;
- data->timestamp = time_usec;
+ data->timestamp = vb->timestamp;
data->flags = 0;
data->clnt_data = data->device_addr;
diff --git a/drivers/platform/msm/gsi/gsi.c b/drivers/platform/msm/gsi/gsi.c
index 188388b..23b0428 100644
--- a/drivers/platform/msm/gsi/gsi.c
+++ b/drivers/platform/msm/gsi/gsi.c
@@ -264,6 +264,11 @@ static void gsi_handle_glob_err(uint32_t err)
}
}
+static void gsi_handle_gp_int1(void)
+{
+ complete(&gsi_ctx->gen_ee_cmd_compl);
+}
+
static void gsi_handle_glob_ee(int ee)
{
uint32_t val;
@@ -288,8 +293,7 @@ static void gsi_handle_glob_ee(int ee)
}
if (val & GSI_EE_n_CNTXT_GLOB_IRQ_EN_GP_INT1_BMSK) {
- notify.evt_id = GSI_PER_EVT_GLOB_GP1;
- gsi_ctx->per.notify_cb(¬ify);
+ gsi_handle_gp_int1();
}
if (val & GSI_EE_n_CNTXT_GLOB_IRQ_EN_GP_INT2_BMSK) {
@@ -2745,6 +2749,67 @@ void gsi_get_inst_ram_offset_and_size(unsigned long *base_offset,
}
EXPORT_SYMBOL(gsi_get_inst_ram_offset_and_size);
+int gsi_halt_channel_ee(unsigned int chan_idx, unsigned int ee, int *code)
+{
+ enum gsi_generic_ee_cmd_opcode op = GSI_GEN_EE_CMD_HALT_CHANNEL;
+ uint32_t val;
+ int res;
+
+ if (!gsi_ctx) {
+ pr_err("%s:%d gsi context not allocated\n", __func__, __LINE__);
+ return -GSI_STATUS_NODEV;
+ }
+
+ if (chan_idx >= gsi_ctx->max_ch || !code) {
+ GSIERR("bad params chan_idx=%d\n", chan_idx);
+ return -GSI_STATUS_INVALID_PARAMS;
+ }
+
+ mutex_lock(&gsi_ctx->mlock);
+ reinit_completion(&gsi_ctx->gen_ee_cmd_compl);
+
+ /* invalidate the response */
+ gsi_ctx->scratch.word0.val = gsi_readl(gsi_ctx->base +
+ GSI_EE_n_CNTXT_SCRATCH_0_OFFS(gsi_ctx->per.ee));
+ gsi_ctx->scratch.word0.s.generic_ee_cmd_return_code = 0;
+ gsi_writel(gsi_ctx->scratch.word0.val, gsi_ctx->base +
+ GSI_EE_n_CNTXT_SCRATCH_0_OFFS(gsi_ctx->per.ee));
+
+ gsi_ctx->gen_ee_cmd_dbg.halt_channel++;
+ val = (((op << GSI_EE_n_GSI_EE_GENERIC_CMD_OPCODE_SHFT) &
+ GSI_EE_n_GSI_EE_GENERIC_CMD_OPCODE_BMSK) |
+ ((chan_idx << GSI_EE_n_GSI_EE_GENERIC_CMD_VIRT_CHAN_IDX_SHFT) &
+ GSI_EE_n_GSI_EE_GENERIC_CMD_VIRT_CHAN_IDX_BMSK) |
+ ((ee << GSI_EE_n_GSI_EE_GENERIC_CMD_EE_SHFT) &
+ GSI_EE_n_GSI_EE_GENERIC_CMD_EE_BMSK));
+ gsi_writel(val, gsi_ctx->base +
+ GSI_EE_n_GSI_EE_GENERIC_CMD_OFFS(gsi_ctx->per.ee));
+
+ res = wait_for_completion_timeout(&gsi_ctx->gen_ee_cmd_compl,
+ msecs_to_jiffies(GSI_CMD_TIMEOUT));
+ if (res == 0) {
+ GSIERR("chan_idx=%u ee=%u timed out\n", chan_idx, ee);
+ res = -GSI_STATUS_TIMED_OUT;
+ goto free_lock;
+ }
+
+ gsi_ctx->scratch.word0.val = gsi_readl(gsi_ctx->base +
+ GSI_EE_n_CNTXT_SCRATCH_0_OFFS(gsi_ctx->per.ee));
+ if (gsi_ctx->scratch.word0.s.generic_ee_cmd_return_code == 0) {
+ GSIERR("No response received\n");
+ res = -GSI_STATUS_ERROR;
+ goto free_lock;
+ }
+
+ res = GSI_STATUS_SUCCESS;
+ *code = gsi_ctx->scratch.word0.s.generic_ee_cmd_return_code;
+free_lock:
+ mutex_unlock(&gsi_ctx->mlock);
+
+ return res;
+}
+EXPORT_SYMBOL(gsi_halt_channel_ee);
+
static int msm_gsi_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -2757,6 +2822,7 @@ static int msm_gsi_probe(struct platform_device *pdev)
}
gsi_ctx->dev = dev;
+ init_completion(&gsi_ctx->gen_ee_cmd_compl);
gsi_debugfs_init();
return 0;
diff --git a/drivers/platform/msm/gsi/gsi.h b/drivers/platform/msm/gsi/gsi.h
index 750ae2b..d0eb162 100644
--- a/drivers/platform/msm/gsi/gsi.h
+++ b/drivers/platform/msm/gsi/gsi.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2017, The Linux Foundation. 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 and
@@ -115,9 +115,12 @@ struct gsi_evt_ctx {
struct gsi_ee_scratch {
union __packed {
struct {
- uint32_t resvd1:15;
+ uint32_t inter_ee_cmd_return_code:3;
+ uint32_t resvd1:2;
+ uint32_t generic_ee_cmd_return_code:3;
+ uint32_t resvd2:7;
uint32_t max_usb_pkt_size:1;
- uint32_t resvd2:8;
+ uint32_t resvd3:8;
uint32_t mhi_base_chan_idx:8;
} s;
uint32_t val;
@@ -135,6 +138,10 @@ struct ch_debug_stats {
unsigned long cmd_completed;
};
+struct gsi_generic_ee_cmd_debug_stats {
+ unsigned long halt_channel;
+};
+
struct gsi_ctx {
void __iomem *base;
struct device *dev;
@@ -143,6 +150,7 @@ struct gsi_ctx {
struct gsi_chan_ctx chan[GSI_CHAN_MAX];
struct ch_debug_stats ch_dbg[GSI_CHAN_MAX];
struct gsi_evt_ctx evtr[GSI_EVT_RING_MAX];
+ struct gsi_generic_ee_cmd_debug_stats gen_ee_cmd_dbg;
struct mutex mlock;
spinlock_t slock;
unsigned long evt_bmap;
@@ -154,6 +162,7 @@ struct gsi_ctx {
struct workqueue_struct *dp_stat_wq;
u32 max_ch;
u32 max_ev;
+ struct completion gen_ee_cmd_compl;
};
enum gsi_re_type {
@@ -227,6 +236,18 @@ enum gsi_evt_ch_cmd_opcode {
GSI_EVT_DE_ALLOC = 0xa,
};
+enum gsi_generic_ee_cmd_opcode {
+ GSI_GEN_EE_CMD_HALT_CHANNEL = 0x1,
+};
+
+enum gsi_generic_ee_cmd_return_code {
+ GSI_GEN_EE_CMD_RETURN_CODE_SUCCESS = 0x1,
+ GSI_GEN_EE_CMD_RETURN_CODE_CHANNEL_NOT_RUNNING = 0x2,
+ GSI_GEN_EE_CMD_RETURN_CODE_INCORRECT_DIRECTION = 0x3,
+ GSI_GEN_EE_CMD_RETURN_CODE_INCORRECT_CHANNEL_TYPE = 0x4,
+ GSI_GEN_EE_CMD_RETURN_CODE_INCORRECT_CHANNEL_INDEX = 0x5,
+};
+
extern struct gsi_ctx *gsi_ctx;
void gsi_debugfs_init(void);
uint16_t gsi_find_idx_from_addr(struct gsi_ring_ctx *ctx, uint64_t addr);
diff --git a/drivers/platform/msm/gsi/gsi_reg.h b/drivers/platform/msm/gsi/gsi_reg.h
index 1acaf74..d0462aa 100644
--- a/drivers/platform/msm/gsi/gsi_reg.h
+++ b/drivers/platform/msm/gsi/gsi_reg.h
@@ -1365,8 +1365,12 @@
(GSI_GSI_REG_BASE_OFFS + 0x0001f018 + 0x4000 * (n))
#define GSI_EE_n_GSI_EE_GENERIC_CMD_RMSK 0xffffffff
#define GSI_EE_n_GSI_EE_GENERIC_CMD_MAXn 3
-#define GSI_EE_n_GSI_EE_GENERIC_CMD_OPCODE_BMSK 0xffffffff
+#define GSI_EE_n_GSI_EE_GENERIC_CMD_OPCODE_BMSK 0x1f
#define GSI_EE_n_GSI_EE_GENERIC_CMD_OPCODE_SHFT 0x0
+#define GSI_EE_n_GSI_EE_GENERIC_CMD_VIRT_CHAN_IDX_BMSK 0x3e0
+#define GSI_EE_n_GSI_EE_GENERIC_CMD_VIRT_CHAN_IDX_SHFT 0x5
+#define GSI_EE_n_GSI_EE_GENERIC_CMD_EE_BMSK 0x3c00
+#define GSI_EE_n_GSI_EE_GENERIC_CMD_EE_SHFT 0xa
/* v1.0 */
#define GSI_V1_0_EE_n_GSI_HW_PARAM_OFFS(n) \
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c
index e9e3c15..e0ae1c6 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c
@@ -1878,6 +1878,45 @@ static void ipa3_q6_avoid_holb(void)
}
}
+static void ipa3_halt_q6_cons_gsi_channels(void)
+{
+ int ep_idx;
+ int client_idx;
+ const struct ipa_gsi_ep_config *gsi_ep_cfg;
+ int ret;
+ int code = 0;
+
+ for (client_idx = 0; client_idx < IPA_CLIENT_MAX; client_idx++) {
+ if (IPA_CLIENT_IS_Q6_CONS(client_idx)) {
+ ep_idx = ipa3_get_ep_mapping(client_idx);
+ if (ep_idx == -1)
+ continue;
+
+ gsi_ep_cfg = ipa3_get_gsi_ep_info(ep_idx);
+ if (!gsi_ep_cfg) {
+ IPAERR("failed to get GSI config\n");
+ ipa_assert();
+ return;
+ }
+
+ ret = gsi_halt_channel_ee(
+ gsi_ep_cfg->ipa_gsi_chan_num, gsi_ep_cfg->ee,
+ &code);
+ if (ret == GSI_STATUS_SUCCESS)
+ IPADBG("halted gsi ch %d ee %d with code %d\n",
+ gsi_ep_cfg->ipa_gsi_chan_num,
+ gsi_ep_cfg->ee,
+ code);
+ else
+ IPAERR("failed to halt ch %d ee %d code %d\n",
+ gsi_ep_cfg->ipa_gsi_chan_num,
+ gsi_ep_cfg->ee,
+ code);
+ }
+ }
+}
+
+
static int ipa3_q6_clean_q6_flt_tbls(enum ipa_ip_type ip,
enum ipa_rule_type rlt)
{
@@ -2302,13 +2341,18 @@ void ipa3_q6_post_shutdown_cleanup(void)
int client_idx;
IPADBG_LOW("ENTER\n");
- IPA_ACTIVE_CLIENTS_INC_SIMPLE();
if (!ipa3_ctx->uc_ctx.uc_loaded) {
IPAERR("uC is not loaded. Skipping\n");
return;
}
+ IPA_ACTIVE_CLIENTS_INC_SIMPLE();
+
+ /* Handle the issue where SUSPEND was removed for some reason */
+ ipa3_q6_avoid_holb();
+ ipa3_halt_q6_cons_gsi_channels();
+
for (client_idx = 0; client_idx < IPA_CLIENT_MAX; client_idx++)
if (IPA_CLIENT_IS_Q6_PROD(client_idx)) {
if (ipa3_uc_is_gsi_channel_empty(client_idx)) {
diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c
index baf3e3f..6d312a0 100644
--- a/drivers/soc/qcom/rpmh.c
+++ b/drivers/soc/qcom/rpmh.c
@@ -245,16 +245,6 @@ int __rpmh_write(struct rpmh_client *rc, enum rpmh_state state,
int ret = 0;
int i;
- /*
- * We cannot wait for completion for a sleep set, its done
- * outside the processor.
- */
- if (rpm_msg->msg.is_complete &&
- (state == RPMH_SLEEP_STATE || state == RPMH_WAKE_ONLY_STATE)) {
- pr_err("Mismatch: sleep/wake set with completion.\n");
- return -EINVAL;
- }
-
/* Cache the request in our store and link the payload */
for (i = 0; i < rpm_msg->msg.num_payload; i++) {
req = cache_rpm_request(rc, state, &rpm_msg->msg.payload[i]);
@@ -638,7 +628,8 @@ int send_single(struct rpmh_client *rc, enum rpmh_state state, u32 addr,
{
DEFINE_RPMH_MSG_ONSTACK(rc, state, NULL, NULL, rpm_msg);
- rpm_msg.msg.is_complete = false;
+ /* Wake sets are always complete and sleep sets are not */
+ rpm_msg.msg.is_complete = (state == RPMH_WAKE_ONLY_STATE);
rpm_msg.cmd.addr = addr;
rpm_msg.cmd.data = data;
@@ -673,7 +664,7 @@ int rpmh_flush(struct rpmh_client *rc)
spin_lock(&rpm->lock);
if (!rpm->dirty) {
- pr_info("Skipping flush, TCS has latest data.\n");
+ pr_debug("Skipping flush, TCS has latest data.\n");
spin_unlock(&rpm->lock);
return 0;
}
diff --git a/drivers/soc/qcom/system_pm.c b/drivers/soc/qcom/system_pm.c
index 78690d9..2855a15 100644
--- a/drivers/soc/qcom/system_pm.c
+++ b/drivers/soc/qcom/system_pm.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2017, The Linux Foundation. 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 and
@@ -16,6 +16,7 @@
#include <soc/qcom/rpmh.h>
+#define ARCH_TIMER_HZ (19200000UL)
#define PDC_TIME_VALID_SHIFT 31
#define PDC_TIME_UPPER_MASK 0xFFFFFF
@@ -25,9 +26,9 @@ static int setup_wakeup(uint64_t sleep_val)
{
struct tcs_cmd cmd[3] = { { 0 } };
- cmd[0].data = sleep_val & 0xFFFFFFFF;
- cmd[1].data = (sleep_val >> 32) & PDC_TIME_UPPER_MASK;
- cmd[1].data |= 1 << PDC_TIME_VALID_SHIFT;
+ cmd[0].data = (sleep_val >> 32) & PDC_TIME_UPPER_MASK;
+ cmd[0].data |= 1 << PDC_TIME_VALID_SHIFT;
+ cmd[1].data = sleep_val & 0xFFFFFFFF;
return rpmh_write_control(rpmh_client, cmd, ARRAY_SIZE(cmd));
}
@@ -35,7 +36,7 @@ static int setup_wakeup(uint64_t sleep_val)
/**
* system_sleep_enter() - Activties done when entering system low power modes
*
- * @sleep_val: The qtimer value for the next wakeup time
+ * @sleep_val: The sleep duration in us.
*
* Returns 0 for success or error values from writing the timer value in the
* hardware block.
@@ -51,6 +52,14 @@ int system_sleep_enter(uint64_t sleep_val)
if (ret)
return ret;
+ /*
+ * Set up the wake up value offset from the current time.
+ * Convert us to ns to allow div by 19.2 Mhz tick timer.
+ */
+ sleep_val *= NSEC_PER_USEC;
+ do_div(sleep_val, NSEC_PER_SEC/ARCH_TIMER_HZ);
+ sleep_val += arch_counter_get_cntvct();
+
return setup_wakeup(sleep_val);
}
EXPORT_SYMBOL(system_sleep_enter);
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a30c8e3..da284fe 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -233,6 +233,9 @@
config USB_F_GSI
tristate
+config USB_F_QDSS
+ tristate
+
# this first set of drivers all depend on bulk-capable hardware.
config USB_CONFIGFS
@@ -549,6 +552,13 @@
help
Generic function driver to support h/w acceleration to IPA over GSI.
+config USB_CONFIGFS_F_QDSS
+ bool "USB QDSS function"
+ select USB_F_QDSS
+ depends on USB_CONFIGFS
+ help
+ USB QDSS function driver to get hwtracing related data over USB.
+
choice
tristate "USB Gadget Drivers"
default USB_ETH
diff --git a/drivers/usb/gadget/function/Makefile b/drivers/usb/gadget/function/Makefile
index e78080c..960c2cc 100644
--- a/drivers/usb/gadget/function/Makefile
+++ b/drivers/usb/gadget/function/Makefile
@@ -62,3 +62,5 @@
obj-$(CONFIG_USB_F_CCID) += usb_f_ccid.o
usb_f_gsi-y := f_gsi.o rndis.o
obj-$(CONFIG_USB_F_GSI) += usb_f_gsi.o
+usb_f_qdss-y := f_qdss.o u_qdss.o
+obj-$(CONFIG_USB_F_QDSS) += usb_f_qdss.o
diff --git a/drivers/usb/gadget/function/f_qdss.c b/drivers/usb/gadget/function/f_qdss.c
new file mode 100644
index 0000000..7114784
--- /dev/null
+++ b/drivers/usb/gadget/function/f_qdss.c
@@ -0,0 +1,1071 @@
+/*
+ * f_qdss.c -- QDSS function Driver
+ *
+ * Copyright (c) 2012-2017, The Linux Foundation. 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 and
+ * only version 2 as published by the Free Software Foundation.
+
+ * 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
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/usb/usb_qdss.h>
+#include <linux/usb/cdc.h>
+
+#include "f_qdss.h"
+
+static DEFINE_SPINLOCK(qdss_lock);
+static LIST_HEAD(usb_qdss_ch_list);
+
+static struct usb_interface_descriptor qdss_data_intf_desc = {
+ .bLength = sizeof(qdss_data_intf_desc),
+ .bDescriptorType = USB_DT_INTERFACE,
+ .bAlternateSetting = 0,
+ .bNumEndpoints = 1,
+ .bInterfaceClass = 0xff,
+ .bInterfaceSubClass = 0xff,
+ .bInterfaceProtocol = 0xff,
+};
+
+static struct usb_endpoint_descriptor qdss_hs_data_desc = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = cpu_to_le16(512),
+};
+
+static struct usb_endpoint_descriptor qdss_ss_data_desc = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = cpu_to_le16(1024),
+};
+
+static struct usb_ss_ep_comp_descriptor qdss_data_ep_comp_desc = {
+ .bLength = sizeof(qdss_data_ep_comp_desc),
+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+ .bMaxBurst = 1,
+ .bmAttributes = 0,
+ .wBytesPerInterval = 0,
+};
+
+static struct usb_interface_descriptor qdss_ctrl_intf_desc = {
+ .bLength = sizeof(qdss_ctrl_intf_desc),
+ .bDescriptorType = USB_DT_INTERFACE,
+ .bAlternateSetting = 0,
+ .bNumEndpoints = 2,
+ .bInterfaceClass = 0xff,
+ .bInterfaceSubClass = 0xff,
+ .bInterfaceProtocol = 0xff,
+};
+
+static struct usb_endpoint_descriptor qdss_hs_ctrl_in_desc = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = cpu_to_le16(512),
+};
+
+static struct usb_endpoint_descriptor qdss_ss_ctrl_in_desc = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = USB_DIR_IN,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = cpu_to_le16(1024),
+};
+
+static struct usb_endpoint_descriptor qdss_hs_ctrl_out_desc = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = USB_DIR_OUT,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = cpu_to_le16(512),
+};
+
+static struct usb_endpoint_descriptor qdss_ss_ctrl_out_desc = {
+ .bLength = USB_DT_ENDPOINT_SIZE,
+ .bDescriptorType = USB_DT_ENDPOINT,
+ .bEndpointAddress = USB_DIR_OUT,
+ .bmAttributes = USB_ENDPOINT_XFER_BULK,
+ .wMaxPacketSize = cpu_to_le16(0x400),
+};
+
+static struct usb_ss_ep_comp_descriptor qdss_ctrl_in_ep_comp_desc = {
+ .bLength = sizeof(qdss_ctrl_in_ep_comp_desc),
+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+ .bMaxBurst = 0,
+ .bmAttributes = 0,
+ .wBytesPerInterval = 0,
+};
+
+static struct usb_ss_ep_comp_descriptor qdss_ctrl_out_ep_comp_desc = {
+ .bLength = sizeof(qdss_ctrl_out_ep_comp_desc),
+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
+ .bMaxBurst = 0,
+ .bmAttributes = 0,
+ .wBytesPerInterval = 0,
+};
+
+static struct usb_descriptor_header *qdss_hs_desc[] = {
+ (struct usb_descriptor_header *) &qdss_data_intf_desc,
+ (struct usb_descriptor_header *) &qdss_hs_data_desc,
+ (struct usb_descriptor_header *) &qdss_ctrl_intf_desc,
+ (struct usb_descriptor_header *) &qdss_hs_ctrl_in_desc,
+ (struct usb_descriptor_header *) &qdss_hs_ctrl_out_desc,
+ NULL,
+};
+
+static struct usb_descriptor_header *qdss_ss_desc[] = {
+ (struct usb_descriptor_header *) &qdss_data_intf_desc,
+ (struct usb_descriptor_header *) &qdss_ss_data_desc,
+ (struct usb_descriptor_header *) &qdss_data_ep_comp_desc,
+ (struct usb_descriptor_header *) &qdss_ctrl_intf_desc,
+ (struct usb_descriptor_header *) &qdss_ss_ctrl_in_desc,
+ (struct usb_descriptor_header *) &qdss_ctrl_in_ep_comp_desc,
+ (struct usb_descriptor_header *) &qdss_ss_ctrl_out_desc,
+ (struct usb_descriptor_header *) &qdss_ctrl_out_ep_comp_desc,
+ NULL,
+};
+
+static struct usb_descriptor_header *qdss_hs_data_only_desc[] = {
+ (struct usb_descriptor_header *) &qdss_data_intf_desc,
+ (struct usb_descriptor_header *) &qdss_hs_data_desc,
+ NULL,
+};
+
+static struct usb_descriptor_header *qdss_ss_data_only_desc[] = {
+ (struct usb_descriptor_header *) &qdss_data_intf_desc,
+ (struct usb_descriptor_header *) &qdss_ss_data_desc,
+ (struct usb_descriptor_header *) &qdss_data_ep_comp_desc,
+ NULL,
+};
+
+/* string descriptors: */
+#define QDSS_DATA_IDX 0
+#define QDSS_CTRL_IDX 1
+
+static struct usb_string qdss_string_defs[] = {
+ [QDSS_DATA_IDX].s = "QDSS DATA",
+ [QDSS_CTRL_IDX].s = "QDSS CTRL",
+ {}, /* end of list */
+};
+
+static struct usb_gadget_strings qdss_string_table = {
+ .language = 0x0409,
+ .strings = qdss_string_defs,
+};
+
+static struct usb_gadget_strings *qdss_strings[] = {
+ &qdss_string_table,
+ NULL,
+};
+
+static inline struct f_qdss *func_to_qdss(struct usb_function *f)
+{
+ return container_of(f, struct f_qdss, port.function);
+}
+
+static
+struct usb_qdss_opts *to_fi_usb_qdss_opts(struct usb_function_instance *fi)
+{
+ return container_of(fi, struct usb_qdss_opts, func_inst);
+}
+/*----------------------------------------------------------------------*/
+
+static void qdss_ctrl_write_complete(struct usb_ep *ep,
+ struct usb_request *req)
+{
+ struct f_qdss *qdss = ep->driver_data;
+ struct qdss_request *d_req = req->context;
+ unsigned long flags;
+
+ pr_debug("qdss_ctrl_write_complete\n");
+
+ if (!req->status) {
+ /* send zlp */
+ if ((req->length >= ep->maxpacket) &&
+ ((req->length % ep->maxpacket) == 0)) {
+ req->length = 0;
+ d_req->actual = req->actual;
+ d_req->status = req->status;
+ if (!usb_ep_queue(qdss->port.ctrl_in, req, GFP_ATOMIC))
+ return;
+ }
+ }
+
+ spin_lock_irqsave(&qdss->lock, flags);
+ list_add_tail(&req->list, &qdss->ctrl_write_pool);
+ if (req->length != 0) {
+ d_req->actual = req->actual;
+ d_req->status = req->status;
+ }
+ spin_unlock_irqrestore(&qdss->lock, flags);
+
+ if (qdss->ch.notify)
+ qdss->ch.notify(qdss->ch.priv, USB_QDSS_CTRL_WRITE_DONE, d_req,
+ NULL);
+}
+
+static void qdss_ctrl_read_complete(struct usb_ep *ep,
+ struct usb_request *req)
+{
+ struct f_qdss *qdss = ep->driver_data;
+ struct qdss_request *d_req = req->context;
+ unsigned long flags;
+
+ pr_debug("qdss_ctrl_read_complete\n");
+
+ d_req->actual = req->actual;
+ d_req->status = req->status;
+
+ spin_lock_irqsave(&qdss->lock, flags);
+ list_add_tail(&req->list, &qdss->ctrl_read_pool);
+ spin_unlock_irqrestore(&qdss->lock, flags);
+
+ if (qdss->ch.notify)
+ qdss->ch.notify(qdss->ch.priv, USB_QDSS_CTRL_READ_DONE, d_req,
+ NULL);
+}
+
+void usb_qdss_free_req(struct usb_qdss_ch *ch)
+{
+ struct f_qdss *qdss;
+ struct usb_request *req;
+ struct list_head *act, *tmp;
+
+ pr_debug("usb_qdss_free_req\n");
+
+ qdss = ch->priv_usb;
+ if (!qdss) {
+ pr_err("usb_qdss_free_req: qdss ctx is NULL\n");
+ return;
+ }
+
+ list_for_each_safe(act, tmp, &qdss->ctrl_write_pool) {
+ req = list_entry(act, struct usb_request, list);
+ list_del(&req->list);
+ usb_ep_free_request(qdss->port.ctrl_in, req);
+ }
+
+ list_for_each_safe(act, tmp, &qdss->ctrl_read_pool) {
+ req = list_entry(act, struct usb_request, list);
+ list_del(&req->list);
+ usb_ep_free_request(qdss->port.ctrl_out, req);
+ }
+}
+EXPORT_SYMBOL(usb_qdss_free_req);
+
+int usb_qdss_alloc_req(struct usb_qdss_ch *ch, int no_write_buf,
+ int no_read_buf)
+{
+ struct f_qdss *qdss = ch->priv_usb;
+ struct usb_request *req;
+ int i;
+
+ pr_debug("usb_qdss_alloc_req\n");
+
+ if (no_write_buf <= 0 || no_read_buf <= 0 || !qdss) {
+ pr_err("usb_qdss_alloc_req: missing params\n");
+ return -ENODEV;
+ }
+
+ for (i = 0; i < no_write_buf; i++) {
+ req = usb_ep_alloc_request(qdss->port.ctrl_in, GFP_ATOMIC);
+ if (!req) {
+ pr_err("usb_qdss_alloc_req: ctrl_in allocation err\n");
+ goto fail;
+ }
+ req->complete = qdss_ctrl_write_complete;
+ list_add_tail(&req->list, &qdss->ctrl_write_pool);
+ }
+
+ for (i = 0; i < no_read_buf; i++) {
+ req = usb_ep_alloc_request(qdss->port.ctrl_out, GFP_ATOMIC);
+ if (!req) {
+ pr_err("usb_qdss_alloc_req:ctrl_out allocation err\n");
+ goto fail;
+ }
+ req->complete = qdss_ctrl_read_complete;
+ list_add_tail(&req->list, &qdss->ctrl_read_pool);
+ }
+
+ return 0;
+
+fail:
+ usb_qdss_free_req(ch);
+ return -ENOMEM;
+}
+EXPORT_SYMBOL(usb_qdss_alloc_req);
+
+static void clear_eps(struct usb_function *f)
+{
+ struct f_qdss *qdss = func_to_qdss(f);
+
+ pr_debug("clear_eps\n");
+
+ if (qdss->port.ctrl_in)
+ qdss->port.ctrl_in->driver_data = NULL;
+ if (qdss->port.ctrl_out)
+ qdss->port.ctrl_out->driver_data = NULL;
+ if (qdss->port.data)
+ qdss->port.data->driver_data = NULL;
+}
+
+static void clear_desc(struct usb_gadget *gadget, struct usb_function *f)
+{
+ pr_debug("clear_desc\n");
+
+ if (gadget_is_superspeed(gadget) && f->ss_descriptors)
+ usb_free_descriptors(f->ss_descriptors);
+
+ if (gadget_is_dualspeed(gadget) && f->hs_descriptors)
+ usb_free_descriptors(f->hs_descriptors);
+}
+
+static int qdss_bind(struct usb_configuration *c, struct usb_function *f)
+{
+ struct usb_gadget *gadget = c->cdev->gadget;
+ struct f_qdss *qdss = func_to_qdss(f);
+ struct usb_ep *ep;
+ int iface;
+
+ pr_debug("qdss_bind\n");
+
+ if (!gadget_is_dualspeed(gadget) && !gadget_is_superspeed(gadget)) {
+ pr_err("qdss_bind: full-speed is not supported\n");
+ return -ENOTSUPP;
+ }
+
+ /* Allocate data I/F */
+ iface = usb_interface_id(c, f);
+ if (iface < 0) {
+ pr_err("interface allocation error\n");
+ return iface;
+ }
+ qdss_data_intf_desc.bInterfaceNumber = iface;
+ qdss->data_iface_id = iface;
+
+ if (qdss->debug_inface_enabled) {
+ /* Allocate ctrl I/F */
+ iface = usb_interface_id(c, f);
+ if (iface < 0) {
+ pr_err("interface allocation error\n");
+ return iface;
+ }
+ qdss_ctrl_intf_desc.bInterfaceNumber = iface;
+ qdss->ctrl_iface_id = iface;
+ }
+
+ ep = usb_ep_autoconfig_ss(gadget, &qdss_ss_data_desc,
+ &qdss_data_ep_comp_desc);
+ if (!ep) {
+ pr_err("ep_autoconfig error\n");
+ goto fail;
+ }
+ qdss->port.data = ep;
+ ep->driver_data = qdss;
+
+ if (qdss->debug_inface_enabled) {
+ ep = usb_ep_autoconfig_ss(gadget, &qdss_ss_ctrl_in_desc,
+ &qdss_ctrl_in_ep_comp_desc);
+ if (!ep) {
+ pr_err("ep_autoconfig error\n");
+ goto fail;
+ }
+ qdss->port.ctrl_in = ep;
+ ep->driver_data = qdss;
+
+ ep = usb_ep_autoconfig_ss(gadget, &qdss_ss_ctrl_out_desc,
+ &qdss_ctrl_out_ep_comp_desc);
+ if (!ep) {
+ pr_err("ep_autoconfig error\n");
+ goto fail;
+ }
+ qdss->port.ctrl_out = ep;
+ ep->driver_data = qdss;
+ }
+
+ /*update descriptors*/
+ qdss_hs_data_desc.bEndpointAddress =
+ qdss_ss_data_desc.bEndpointAddress;
+ if (qdss->debug_inface_enabled) {
+ qdss_hs_ctrl_in_desc.bEndpointAddress =
+ qdss_ss_ctrl_in_desc.bEndpointAddress;
+ qdss_hs_ctrl_out_desc.bEndpointAddress =
+ qdss_ss_ctrl_out_desc.bEndpointAddress;
+ f->hs_descriptors = usb_copy_descriptors(qdss_hs_desc);
+ } else
+ f->hs_descriptors = usb_copy_descriptors(
+ qdss_hs_data_only_desc);
+ if (!f->hs_descriptors) {
+ pr_err("usb_copy_descriptors error\n");
+ goto fail;
+ }
+
+ /* update ss descriptors */
+ if (gadget_is_superspeed(gadget)) {
+ if (qdss->debug_inface_enabled)
+ f->ss_descriptors =
+ usb_copy_descriptors(qdss_ss_desc);
+ else
+ f->ss_descriptors =
+ usb_copy_descriptors(qdss_ss_data_only_desc);
+ if (!f->ss_descriptors) {
+ pr_err("usb_copy_descriptors error\n");
+ goto fail;
+ }
+ }
+
+ return 0;
+fail:
+ clear_eps(f);
+ clear_desc(gadget, f);
+ return -ENOTSUPP;
+}
+
+
+static void qdss_unbind(struct usb_configuration *c, struct usb_function *f)
+{
+ struct f_qdss *qdss = func_to_qdss(f);
+ struct usb_gadget *gadget = c->cdev->gadget;
+
+ pr_debug("qdss_unbind\n");
+
+ flush_workqueue(qdss->wq);
+
+ clear_eps(f);
+ clear_desc(gadget, f);
+}
+
+static void qdss_eps_disable(struct usb_function *f)
+{
+ struct f_qdss *qdss = func_to_qdss(f);
+
+ pr_debug("qdss_eps_disable\n");
+
+ if (qdss->ctrl_in_enabled) {
+ usb_ep_disable(qdss->port.ctrl_in);
+ qdss->ctrl_in_enabled = 0;
+ }
+
+ if (qdss->ctrl_out_enabled) {
+ usb_ep_disable(qdss->port.ctrl_out);
+ qdss->ctrl_out_enabled = 0;
+ }
+
+ if (qdss->data_enabled) {
+ usb_ep_disable(qdss->port.data);
+ qdss->data_enabled = 0;
+ }
+}
+
+static void usb_qdss_disconnect_work(struct work_struct *work)
+{
+ struct f_qdss *qdss;
+ int status;
+
+ qdss = container_of(work, struct f_qdss, disconnect_w);
+ pr_debug("usb_qdss_disconnect_work\n");
+
+ /*
+ * Uninitialized init data i.e. ep specific operation.
+ * Notify qdss to cancel all active transfers.
+ */
+ if (qdss->ch.app_conn) {
+ status = uninit_data(qdss->port.data);
+ if (status)
+ pr_err("%s: uninit_data error\n", __func__);
+
+ if (qdss->ch.notify)
+ qdss->ch.notify(qdss->ch.priv,
+ USB_QDSS_DISCONNECT,
+ NULL,
+ NULL);
+
+ status = set_qdss_data_connection(
+ qdss->gadget,
+ qdss->port.data,
+ qdss->port.data->address,
+ 0);
+ if (status)
+ pr_err("qdss_disconnect error");
+ }
+
+ /*
+ * Decrement usage count which was incremented
+ * before calling connect work
+ */
+ usb_gadget_autopm_put_async(qdss->gadget);
+}
+
+static void qdss_disable(struct usb_function *f)
+{
+ struct f_qdss *qdss = func_to_qdss(f);
+ unsigned long flags;
+
+ pr_debug("qdss_disable\n");
+ spin_lock_irqsave(&qdss->lock, flags);
+ if (!qdss->usb_connected) {
+ spin_unlock_irqrestore(&qdss->lock, flags);
+ return;
+ }
+
+ qdss->usb_connected = 0;
+ spin_unlock_irqrestore(&qdss->lock, flags);
+ /*cancell all active xfers*/
+ qdss_eps_disable(f);
+ queue_work(qdss->wq, &qdss->disconnect_w);
+}
+
+static void usb_qdss_connect_work(struct work_struct *work)
+{
+ struct f_qdss *qdss;
+ int status;
+
+ qdss = container_of(work, struct f_qdss, connect_w);
+
+ /* If cable is already removed, discard connect_work */
+ if (qdss->usb_connected == 0) {
+ pr_debug("%s: discard connect_work\n", __func__);
+ cancel_work_sync(&qdss->disconnect_w);
+ return;
+ }
+
+ pr_debug("usb_qdss_connect_work\n");
+ status = set_qdss_data_connection(
+ qdss->gadget,
+ qdss->port.data,
+ qdss->port.data->address,
+ 1);
+ if (status) {
+ pr_err("set_qdss_data_connection error(%d)", status);
+ return;
+ }
+
+ if (qdss->ch.notify)
+ qdss->ch.notify(qdss->ch.priv, USB_QDSS_CONNECT,
+ NULL, &qdss->ch);
+
+ status = usb_ep_queue(qdss->port.data, qdss->endless_req, GFP_ATOMIC);
+ if (status)
+ pr_err("%s: usb_ep_queue error (%d)\n", __func__, status);
+}
+
+static int qdss_set_alt(struct usb_function *f, unsigned int intf,
+ unsigned int alt)
+{
+ struct f_qdss *qdss = func_to_qdss(f);
+ struct usb_gadget *gadget = f->config->cdev->gadget;
+ struct usb_qdss_ch *ch = &qdss->ch;
+ int ret = 0;
+
+ pr_debug("qdss_set_alt qdss pointer = %pK\n", qdss);
+ qdss->gadget = gadget;
+
+ if (alt != 0)
+ goto fail1;
+
+ if (gadget->speed != USB_SPEED_SUPER &&
+ gadget->speed != USB_SPEED_HIGH) {
+ pr_err("qdss_st_alt: qdss supportes HS or SS only\n");
+ ret = -EINVAL;
+ goto fail1;
+ }
+
+ if (intf == qdss->data_iface_id) {
+ /* Increment usage count on connect */
+ usb_gadget_autopm_get_async(qdss->gadget);
+
+ if (config_ep_by_speed(gadget, f, qdss->port.data)) {
+ ret = -EINVAL;
+ goto fail;
+ }
+
+ ret = usb_ep_enable(qdss->port.data);
+ if (ret)
+ goto fail;
+
+ qdss->port.data->driver_data = qdss;
+ qdss->data_enabled = 1;
+
+
+ } else if ((intf == qdss->ctrl_iface_id) &&
+ (qdss->debug_inface_enabled)) {
+
+ if (config_ep_by_speed(gadget, f, qdss->port.ctrl_in)) {
+ ret = -EINVAL;
+ goto fail1;
+ }
+
+ ret = usb_ep_enable(qdss->port.ctrl_in);
+ if (ret)
+ goto fail1;
+
+ qdss->port.ctrl_in->driver_data = qdss;
+ qdss->ctrl_in_enabled = 1;
+
+ if (config_ep_by_speed(gadget, f, qdss->port.ctrl_out)) {
+ ret = -EINVAL;
+ goto fail1;
+ }
+
+
+ ret = usb_ep_enable(qdss->port.ctrl_out);
+ if (ret)
+ goto fail1;
+
+ qdss->port.ctrl_out->driver_data = qdss;
+ qdss->ctrl_out_enabled = 1;
+ }
+
+ if (qdss->debug_inface_enabled) {
+ if (qdss->ctrl_out_enabled && qdss->ctrl_in_enabled &&
+ qdss->data_enabled) {
+ qdss->usb_connected = 1;
+ pr_debug("qdss_set_alt usb_connected INTF enabled\n");
+ }
+ } else {
+ if (qdss->data_enabled) {
+ qdss->usb_connected = 1;
+ pr_debug("qdss_set_alt usb_connected INTF disabled\n");
+ }
+ }
+
+ if (qdss->usb_connected && ch->app_conn)
+ queue_work(qdss->wq, &qdss->connect_w);
+
+ return 0;
+fail:
+ /* Decrement usage count in case of failure */
+ usb_gadget_autopm_put_async(qdss->gadget);
+fail1:
+ pr_err("qdss_set_alt failed\n");
+ qdss_eps_disable(f);
+ return ret;
+}
+
+static struct f_qdss *alloc_usb_qdss(char *channel_name)
+{
+ struct f_qdss *qdss;
+ int found = 0;
+ struct usb_qdss_ch *ch;
+ unsigned long flags;
+
+ spin_lock_irqsave(&qdss_lock, flags);
+ list_for_each_entry(ch, &usb_qdss_ch_list, list) {
+ if (!strcmp(channel_name, ch->name)) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (found) {
+ spin_unlock_irqrestore(&qdss_lock, flags);
+ pr_err("%s: (%s) is already available.\n",
+ __func__, channel_name);
+ return ERR_PTR(-EEXIST);
+ }
+
+ spin_unlock_irqrestore(&qdss_lock, flags);
+ qdss = kzalloc(sizeof(struct f_qdss), GFP_KERNEL);
+ if (!qdss) {
+ pr_err("%s: Unable to allocate qdss device\n", __func__);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ qdss->wq = create_singlethread_workqueue(channel_name);
+ if (!qdss->wq) {
+ kfree(qdss);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ spin_lock_irqsave(&qdss_lock, flags);
+ ch = &qdss->ch;
+ ch->name = channel_name;
+ list_add_tail(&ch->list, &usb_qdss_ch_list);
+ spin_unlock_irqrestore(&qdss_lock, flags);
+
+ spin_lock_init(&qdss->lock);
+ INIT_LIST_HEAD(&qdss->ctrl_read_pool);
+ INIT_LIST_HEAD(&qdss->ctrl_write_pool);
+ INIT_WORK(&qdss->connect_w, usb_qdss_connect_work);
+ INIT_WORK(&qdss->disconnect_w, usb_qdss_disconnect_work);
+
+ return qdss;
+}
+
+int usb_qdss_ctrl_read(struct usb_qdss_ch *ch, struct qdss_request *d_req)
+{
+ struct f_qdss *qdss = ch->priv_usb;
+ unsigned long flags;
+ struct usb_request *req = NULL;
+
+ pr_debug("usb_qdss_ctrl_read\n");
+
+ if (!qdss)
+ return -ENODEV;
+
+ spin_lock_irqsave(&qdss->lock, flags);
+
+ if (qdss->usb_connected == 0) {
+ spin_unlock_irqrestore(&qdss->lock, flags);
+ return -EIO;
+ }
+
+ if (list_empty(&qdss->ctrl_read_pool)) {
+ spin_unlock_irqrestore(&qdss->lock, flags);
+ pr_err("error: usb_qdss_ctrl_read list is empty\n");
+ return -EAGAIN;
+ }
+
+ req = list_first_entry(&qdss->ctrl_read_pool, struct usb_request, list);
+ list_del(&req->list);
+ spin_unlock_irqrestore(&qdss->lock, flags);
+
+ req->buf = d_req->buf;
+ req->length = d_req->length;
+ req->context = d_req;
+
+ if (usb_ep_queue(qdss->port.ctrl_out, req, GFP_ATOMIC)) {
+ /* If error add the link to linked list again*/
+ spin_lock_irqsave(&qdss->lock, flags);
+ list_add_tail(&req->list, &qdss->ctrl_read_pool);
+ spin_unlock_irqrestore(&qdss->lock, flags);
+ pr_err("qdss usb_ep_queue failed\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(usb_qdss_ctrl_read);
+
+int usb_qdss_ctrl_write(struct usb_qdss_ch *ch, struct qdss_request *d_req)
+{
+ struct f_qdss *qdss = ch->priv_usb;
+ unsigned long flags;
+ struct usb_request *req = NULL;
+
+ pr_debug("usb_qdss_ctrl_write\n");
+
+ if (!qdss)
+ return -ENODEV;
+
+ spin_lock_irqsave(&qdss->lock, flags);
+
+ if (qdss->usb_connected == 0) {
+ spin_unlock_irqrestore(&qdss->lock, flags);
+ return -EIO;
+ }
+
+ if (list_empty(&qdss->ctrl_write_pool)) {
+ pr_err("error: usb_qdss_ctrl_write list is empty\n");
+ spin_unlock_irqrestore(&qdss->lock, flags);
+ return -EAGAIN;
+ }
+
+ req = list_first_entry(&qdss->ctrl_write_pool, struct usb_request,
+ list);
+ list_del(&req->list);
+ spin_unlock_irqrestore(&qdss->lock, flags);
+
+ req->buf = d_req->buf;
+ req->length = d_req->length;
+ req->context = d_req;
+ if (usb_ep_queue(qdss->port.ctrl_in, req, GFP_ATOMIC)) {
+ spin_lock_irqsave(&qdss->lock, flags);
+ list_add_tail(&req->list, &qdss->ctrl_write_pool);
+ spin_unlock_irqrestore(&qdss->lock, flags);
+ pr_err("qdss usb_ep_queue failed\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL(usb_qdss_ctrl_write);
+
+struct usb_qdss_ch *usb_qdss_open(const char *name, void *priv,
+ void (*notify)(void *priv, unsigned int event,
+ struct qdss_request *d_req, struct usb_qdss_ch *))
+{
+ struct usb_qdss_ch *ch;
+ struct f_qdss *qdss;
+ unsigned long flags;
+ int found = 0;
+
+ pr_debug("usb_qdss_open\n");
+
+ if (!notify) {
+ pr_err("usb_qdss_open: notification func is missing\n");
+ return NULL;
+ }
+
+ spin_lock_irqsave(&qdss_lock, flags);
+ /* Check if we already have a channel with this name */
+ list_for_each_entry(ch, &usb_qdss_ch_list, list) {
+ if (!strcmp(name, ch->name)) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) {
+ spin_unlock_irqrestore(&qdss_lock, flags);
+ pr_debug("usb_qdss_open failed as %s not found\n", name);
+ return NULL;
+ }
+
+ pr_debug("usb_qdss_open: qdss ctx found\n");
+ qdss = container_of(ch, struct f_qdss, ch);
+ ch->priv_usb = qdss;
+ ch->priv = priv;
+ ch->notify = notify;
+ ch->app_conn = 1;
+ spin_unlock_irqrestore(&qdss_lock, flags);
+
+ /* the case USB cabel was connected before qdss called qdss_open */
+ if (qdss->usb_connected == 1)
+ queue_work(qdss->wq, &qdss->connect_w);
+
+ return ch;
+}
+EXPORT_SYMBOL(usb_qdss_open);
+
+void usb_qdss_close(struct usb_qdss_ch *ch)
+{
+ struct f_qdss *qdss = ch->priv_usb;
+ struct usb_gadget *gadget;
+ unsigned long flags;
+ int status;
+
+ pr_debug("usb_qdss_close\n");
+
+ spin_lock_irqsave(&qdss_lock, flags);
+ if (!qdss || !qdss->usb_connected) {
+ ch->app_conn = 0;
+ spin_unlock_irqrestore(&qdss_lock, flags);
+ return;
+ }
+
+ usb_ep_dequeue(qdss->port.data, qdss->endless_req);
+ usb_ep_free_request(qdss->port.data, qdss->endless_req);
+ qdss->endless_req = NULL;
+ gadget = qdss->gadget;
+ ch->app_conn = 0;
+ spin_unlock_irqrestore(&qdss_lock, flags);
+
+ status = uninit_data(qdss->port.data);
+ if (status)
+ pr_err("%s: uninit_data error\n", __func__);
+
+ status = set_qdss_data_connection(
+ gadget,
+ qdss->port.data,
+ qdss->port.data->address,
+ 0);
+ if (status)
+ pr_err("%s:qdss_disconnect error\n", __func__);
+ usb_gadget_restart(gadget);
+}
+EXPORT_SYMBOL(usb_qdss_close);
+
+static void qdss_cleanup(void)
+{
+ struct f_qdss *qdss;
+ struct list_head *act, *tmp;
+ struct usb_qdss_ch *_ch;
+ unsigned long flags;
+
+ pr_debug("qdss_cleanup\n");
+
+ list_for_each_safe(act, tmp, &usb_qdss_ch_list) {
+ _ch = list_entry(act, struct usb_qdss_ch, list);
+ qdss = container_of(_ch, struct f_qdss, ch);
+ spin_lock_irqsave(&qdss_lock, flags);
+ destroy_workqueue(qdss->wq);
+ if (!_ch->priv) {
+ list_del(&_ch->list);
+ kfree(qdss);
+ }
+ spin_unlock_irqrestore(&qdss_lock, flags);
+ }
+}
+
+static void qdss_free_func(struct usb_function *f)
+{
+ /* Do nothing as usb_qdss_alloc() doesn't alloc anything. */
+}
+
+static inline struct usb_qdss_opts *to_f_qdss_opts(struct config_item *item)
+{
+ return container_of(to_config_group(item), struct usb_qdss_opts,
+ func_inst.group);
+}
+
+static void qdss_attr_release(struct config_item *item)
+{
+ struct usb_qdss_opts *opts = to_f_qdss_opts(item);
+
+ usb_put_function_instance(&opts->func_inst);
+}
+
+static struct configfs_item_operations qdss_item_ops = {
+ .release = qdss_attr_release,
+};
+
+static ssize_t qdss_enable_debug_inface_show(struct config_item *item,
+ char *page)
+{
+ return snprintf(page, PAGE_SIZE, "%s\n",
+ (to_f_qdss_opts(item)->usb_qdss->debug_inface_enabled == 1) ?
+ "Enabled" : "Disabled");
+}
+
+static ssize_t qdss_enable_debug_inface_store(struct config_item *item,
+ const char *page, size_t len)
+{
+ struct f_qdss *qdss = to_f_qdss_opts(item)->usb_qdss;
+ unsigned long flags;
+ u8 stats;
+
+ if (page == NULL) {
+ pr_err("Invalid buffer");
+ return len;
+ }
+
+ if (kstrtou8(page, 0, &stats) != 0 && (stats != 0 || stats != 1)) {
+ pr_err("(%u)Wrong value. enter 0 to disable or 1 to enable.\n",
+ stats);
+ return len;
+ }
+
+ spin_lock_irqsave(&qdss->lock, flags);
+ qdss->debug_inface_enabled = (stats == 1 ? "true" : "false");
+ spin_unlock_irqrestore(&qdss->lock, flags);
+ return len;
+}
+
+CONFIGFS_ATTR(qdss_, enable_debug_inface);
+static struct configfs_attribute *qdss_attrs[] = {
+ &qdss_attr_enable_debug_inface,
+ NULL,
+};
+
+static struct config_item_type qdss_func_type = {
+ .ct_item_ops = &qdss_item_ops,
+ .ct_attrs = qdss_attrs,
+ .ct_owner = THIS_MODULE,
+};
+
+static void usb_qdss_free_inst(struct usb_function_instance *fi)
+{
+ struct usb_qdss_opts *opts;
+
+ opts = container_of(fi, struct usb_qdss_opts, func_inst);
+ kfree(opts->usb_qdss);
+ kfree(opts);
+}
+
+static int usb_qdss_set_inst_name(struct usb_function_instance *f,
+ const char *name)
+{
+ struct usb_qdss_opts *opts =
+ container_of(f, struct usb_qdss_opts, func_inst);
+ char *ptr;
+ size_t name_len;
+ struct f_qdss *usb_qdss;
+
+ /* get channel_name as expected input qdss.<channel_name> */
+ name_len = strlen(name) + 1;
+ if (name_len > 15)
+ return -ENAMETOOLONG;
+
+ /* get channel name */
+ ptr = kstrndup(name, name_len, GFP_KERNEL);
+ if (!ptr) {
+ pr_err("error:%ld\n", PTR_ERR(ptr));
+ return -ENOMEM;
+ }
+
+ opts->channel_name = ptr;
+ pr_debug("qdss: channel_name:%s\n", opts->channel_name);
+
+ usb_qdss = alloc_usb_qdss(opts->channel_name);
+ if (IS_ERR(usb_qdss)) {
+ pr_err("Failed to create usb_qdss port(%s)\n",
+ opts->channel_name);
+ return -ENOMEM;
+ }
+
+ opts->usb_qdss = usb_qdss;
+ return 0;
+}
+
+static struct usb_function_instance *qdss_alloc_inst(void)
+{
+ struct usb_qdss_opts *opts;
+
+ opts = kzalloc(sizeof(*opts), GFP_KERNEL);
+ if (!opts)
+ return ERR_PTR(-ENOMEM);
+
+ opts->func_inst.free_func_inst = usb_qdss_free_inst;
+ opts->func_inst.set_inst_name = usb_qdss_set_inst_name;
+
+ config_group_init_type_name(&opts->func_inst.group, "",
+ &qdss_func_type);
+ return &opts->func_inst;
+}
+
+static struct usb_function *qdss_alloc(struct usb_function_instance *fi)
+{
+ struct usb_qdss_opts *opts = to_fi_usb_qdss_opts(fi);
+ struct f_qdss *usb_qdss = opts->usb_qdss;
+
+ usb_qdss->port.function.name = "usb_qdss";
+ usb_qdss->port.function.fs_descriptors = qdss_hs_desc;
+ usb_qdss->port.function.hs_descriptors = qdss_hs_desc;
+ usb_qdss->port.function.strings = qdss_strings;
+ usb_qdss->port.function.bind = qdss_bind;
+ usb_qdss->port.function.unbind = qdss_unbind;
+ usb_qdss->port.function.set_alt = qdss_set_alt;
+ usb_qdss->port.function.disable = qdss_disable;
+ usb_qdss->port.function.setup = NULL;
+ usb_qdss->port.function.free_func = qdss_free_func;
+
+ return &usb_qdss->port.function;
+}
+
+DECLARE_USB_FUNCTION_INIT(qdss, qdss_alloc_inst, qdss_alloc);
+static int __init usb_qdss_init(void)
+{
+ int ret;
+
+ INIT_LIST_HEAD(&usb_qdss_ch_list);
+ ret = usb_function_register(&qdssusb_func);
+ if (ret) {
+ pr_err("%s: failed to register diag %d\n", __func__, ret);
+ return ret;
+ }
+ return ret;
+}
+
+static void __exit usb_qdss_exit(void)
+{
+ usb_function_unregister(&qdssusb_func);
+ qdss_cleanup();
+}
+
+module_init(usb_qdss_init);
+module_exit(usb_qdss_exit);
+MODULE_DESCRIPTION("USB QDSS Function Driver");
diff --git a/drivers/usb/gadget/function/f_qdss.h b/drivers/usb/gadget/function/f_qdss.h
new file mode 100644
index 0000000..e673e61
--- /dev/null
+++ b/drivers/usb/gadget/function/f_qdss.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012-2017, The Linux Foundation. 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 and
+ * only version 2 as published by the Free Software Foundation.
+
+ * 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 _F_QDSS_H
+#define _F_QDSS_H
+
+#include <linux/kernel.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include <linux/usb/composite.h>
+#include <linux/usb/usb_qdss.h>
+
+enum qti_port_type {
+ QTI_PORT_RMNET,
+ QTI_PORT_DPL,
+ QTI_NUM_PORTS
+};
+
+struct usb_qdss_bam_connect_info {
+ u32 usb_bam_pipe_idx;
+ u32 peer_pipe_idx;
+ unsigned long usb_bam_handle;
+ struct sps_mem_buffer *data_fifo;
+};
+
+struct gqdss {
+ struct usb_function function;
+ struct usb_ep *ctrl_out;
+ struct usb_ep *ctrl_in;
+ struct usb_ep *data;
+ int (*send_encap_cmd)(enum qti_port_type qport, void *buf, size_t len);
+ void (*notify_modem)(void *g, enum qti_port_type qport, int cbits);
+};
+
+/* struct f_qdss - USB qdss function driver private structure */
+struct f_qdss {
+ struct gqdss port;
+ struct usb_qdss_bam_connect_info bam_info;
+ struct usb_gadget *gadget;
+ short int port_num;
+ u8 ctrl_iface_id;
+ u8 data_iface_id;
+ int usb_connected;
+ bool debug_inface_enabled;
+ struct usb_request *endless_req;
+ struct usb_qdss_ch ch;
+ struct list_head ctrl_read_pool;
+ struct list_head ctrl_write_pool;
+ struct work_struct connect_w;
+ struct work_struct disconnect_w;
+ spinlock_t lock;
+ unsigned int data_enabled:1;
+ unsigned int ctrl_in_enabled:1;
+ unsigned int ctrl_out_enabled:1;
+ struct workqueue_struct *wq;
+};
+
+struct usb_qdss_opts {
+ struct usb_function_instance func_inst;
+ struct f_qdss *usb_qdss;
+ char *channel_name;
+};
+
+int uninit_data(struct usb_ep *ep);
+int set_qdss_data_connection(struct usb_gadget *gadget,
+ struct usb_ep *data_ep, u8 data_addr, int enable);
+#endif
diff --git a/drivers/usb/gadget/function/u_qdss.c b/drivers/usb/gadget/function/u_qdss.c
new file mode 100644
index 0000000..c781d85
--- /dev/null
+++ b/drivers/usb/gadget/function/u_qdss.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2012-2017, The Linux Foundation. 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 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/usb_bam.h>
+
+#include "f_qdss.h"
+static int alloc_sps_req(struct usb_ep *data_ep)
+{
+ struct usb_request *req = NULL;
+ struct f_qdss *qdss = data_ep->driver_data;
+ u32 sps_params = 0;
+
+ pr_debug("send_sps_req\n");
+
+ req = usb_ep_alloc_request(data_ep, GFP_ATOMIC);
+ if (!req) {
+ pr_err("usb_ep_alloc_request failed\n");
+ return -ENOMEM;
+ }
+
+ req->length = 32*1024;
+ sps_params = MSM_SPS_MODE | MSM_DISABLE_WB |
+ qdss->bam_info.usb_bam_pipe_idx;
+ req->udc_priv = sps_params;
+ qdss->endless_req = req;
+
+ return 0;
+}
+
+static int init_data(struct usb_ep *ep);
+int set_qdss_data_connection(struct usb_gadget *gadget,
+ struct usb_ep *data_ep, u8 data_addr, int enable)
+{
+ enum usb_ctrl usb_bam_type;
+ int res = 0;
+ int idx;
+ struct f_qdss *qdss = data_ep->driver_data;
+ struct usb_qdss_bam_connect_info bam_info = qdss->bam_info;
+
+ pr_debug("set_qdss_data_connection\n");
+
+ usb_bam_type = usb_bam_get_bam_type(gadget->name);
+
+ /* There is only one qdss pipe, so the pipe number can be set to 0 */
+ idx = usb_bam_get_connection_idx(usb_bam_type, QDSS_P_BAM,
+ PEER_PERIPHERAL_TO_USB, USB_BAM_DEVICE, 0);
+ if (idx < 0) {
+ pr_err("%s: usb_bam_get_connection_idx failed\n", __func__);
+ return idx;
+ }
+
+ if (enable) {
+ usb_bam_alloc_fifos(usb_bam_type, idx);
+ bam_info.data_fifo =
+ kzalloc(sizeof(struct sps_mem_buffer), GFP_KERNEL);
+ if (!bam_info.data_fifo) {
+ pr_err("qdss_data_connection: memory alloc failed\n");
+ return -ENOMEM;
+ }
+ get_bam2bam_connection_info(usb_bam_type, idx,
+ &bam_info.usb_bam_pipe_idx,
+ NULL, bam_info.data_fifo, NULL);
+
+ alloc_sps_req(data_ep);
+ msm_data_fifo_config(data_ep, bam_info.data_fifo->phys_base,
+ bam_info.data_fifo->size,
+ bam_info.usb_bam_pipe_idx);
+ init_data(qdss->port.data);
+
+ res = usb_bam_connect(usb_bam_type, idx,
+ &(bam_info.usb_bam_pipe_idx));
+ } else {
+ kfree(bam_info.data_fifo);
+ res = usb_bam_disconnect_pipe(usb_bam_type, idx);
+ if (res)
+ pr_err("usb_bam_disconnection error\n");
+ usb_bam_free_fifos(usb_bam_type, idx);
+ }
+
+ return res;
+}
+
+static int init_data(struct usb_ep *ep)
+{
+ int res = 0;
+
+ pr_debug("init_data\n");
+
+ res = msm_ep_config(ep);
+ if (res)
+ pr_err("msm_ep_config failed\n");
+
+ return res;
+}
+
+int uninit_data(struct usb_ep *ep)
+{
+ int res = 0;
+
+ pr_err("uninit_data\n");
+
+ res = msm_ep_unconfig(ep);
+ if (res)
+ pr_err("msm_ep_unconfig failed\n");
+
+ return res;
+}
diff --git a/drivers/video/fbdev/vfb.c b/drivers/video/fbdev/vfb.c
index da653a0..208d8f4 100644
--- a/drivers/video/fbdev/vfb.c
+++ b/drivers/video/fbdev/vfb.c
@@ -36,6 +36,8 @@ static void *videomemory;
static u_long videomemorysize = VIDEOMEMSIZE;
module_param(videomemorysize, ulong, 0);
MODULE_PARM_DESC(videomemorysize, "RAM available to frame buffer (in bytes)");
+static int bpp = 8;
+module_param(bpp, int, 0644);
static char *mode_option = NULL;
module_param(mode_option, charp, 0);
@@ -397,7 +399,13 @@ static int __init vfb_setup(char *options)
/* Test disable for backwards compatibility */
if (!strcmp(this_opt, "disable"))
vfb_enable = 0;
- else
+ else if (!strcmp(this_opt, "bpp=")) {
+ if (kstrtoint(this_opt + 4, 0, &bpp) < 0)
+ bpp = 8;
+ } else if (!strcmp(this_opt, "memsize=")) {
+ if (kstrtoul(this_opt + 8, 0, &videomemorysize) < 0)
+ videomemorysize = VIDEOMEMSIZE;
+ } else
mode_option = this_opt;
}
return 1;
@@ -427,12 +435,8 @@ static int vfb_probe(struct platform_device *dev)
info->screen_base = (char __iomem *)videomemory;
info->fbops = &vfb_ops;
- if (!fb_find_mode(&info->var, info, mode_option,
- NULL, 0, &vfb_default, 8)){
- fb_err(info, "Unable to find usable video mode.\n");
- retval = -EINVAL;
- goto err1;
- }
+ retval = fb_find_mode(&info->var, info, mode_option,
+ NULL, 0, NULL, bpp);
vfb_fix.smem_start = (unsigned long) videomemory;
vfb_fix.smem_len = videomemorysize;
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index da25f07..f7033fa 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -341,7 +341,7 @@ int memblock_is_map_memory(phys_addr_t addr);
int memblock_is_region_memory(phys_addr_t base, phys_addr_t size);
bool memblock_is_reserved(phys_addr_t addr);
bool memblock_is_region_reserved(phys_addr_t base, phys_addr_t size);
-int memblock_overlaps_memory(phys_addr_t base, phys_addr_t size);
+bool memblock_overlaps_memory(phys_addr_t base, phys_addr_t size);
extern void __memblock_dump_all(void);
diff --git a/include/linux/msm_gsi.h b/include/linux/msm_gsi.h
index 6037fbf..d4b4cc7 100644
--- a/include/linux/msm_gsi.h
+++ b/include/linux/msm_gsi.h
@@ -1053,6 +1053,18 @@ int gsi_enable_fw(phys_addr_t gsi_base_addr, u32 gsi_size);
void gsi_get_inst_ram_offset_and_size(unsigned long *base_offset,
unsigned long *size);
+/**
+ * gsi_halt_channel_ee - Peripheral should call this function
+ * to stop other EE's channel. This is usually used in SSR clean
+ *
+ * @chan_idx: Virtual channel index
+ * @ee: EE
+ * @code: [out] response code for operation
+
+ * @Return gsi_status
+ */
+int gsi_halt_channel_ee(unsigned int chan_idx, unsigned int ee, int *code);
+
/*
* Here is a typical sequence of calls
*
@@ -1250,5 +1262,11 @@ static inline void gsi_get_inst_ram_offset_and_size(unsigned long *base_offset,
unsigned long *size)
{
}
+
+static inline int gsi_halt_channel_ee(unsigned int chan_idx, unsigned int ee,
+ int *code)
+{
+ return -GSI_STATUS_UNSUPPORTED_OP;
+}
#endif
#endif
diff --git a/include/linux/usb/usb_qdss.h b/include/linux/usb/usb_qdss.h
new file mode 100644
index 0000000..b58d8ee
--- /dev/null
+++ b/include/linux/usb/usb_qdss.h
@@ -0,0 +1,95 @@
+/* Copyright (c) 2012-2013, 2017 The Linux Foundation. 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 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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 __LINUX_USB_QDSS_H
+#define __LINUX_USB_QDSS_H
+
+#include <linux/kernel.h>
+
+struct qdss_request {
+ char *buf;
+ int length;
+ int actual;
+ int status;
+ void *context;
+};
+
+struct usb_qdss_ch {
+ const char *name;
+ struct list_head list;
+ void (*notify)(void *priv, unsigned int event,
+ struct qdss_request *d_req, struct usb_qdss_ch *ch);
+ void *priv;
+ void *priv_usb;
+ int app_conn;
+};
+
+enum qdss_state {
+ USB_QDSS_CONNECT,
+ USB_QDSS_DISCONNECT,
+ USB_QDSS_CTRL_READ_DONE,
+ USB_QDSS_DATA_WRITE_DONE,
+ USB_QDSS_CTRL_WRITE_DONE,
+};
+
+#if IS_ENABLED(CONFIG_USB_F_QDSS)
+struct usb_qdss_ch *usb_qdss_open(const char *name, void *priv,
+ void (*notify)(void *priv, unsigned int event,
+ struct qdss_request *d_req, struct usb_qdss_ch *ch));
+void usb_qdss_close(struct usb_qdss_ch *ch);
+int usb_qdss_alloc_req(struct usb_qdss_ch *ch, int n_write, int n_read);
+void usb_qdss_free_req(struct usb_qdss_ch *ch);
+int usb_qdss_read(struct usb_qdss_ch *ch, struct qdss_request *d_req);
+int usb_qdss_write(struct usb_qdss_ch *ch, struct qdss_request *d_req);
+int usb_qdss_ctrl_write(struct usb_qdss_ch *ch, struct qdss_request *d_req);
+int usb_qdss_ctrl_read(struct usb_qdss_ch *ch, struct qdss_request *d_req);
+#else
+static inline struct usb_qdss_ch *usb_qdss_open(const char *name, void *priv,
+ void (*n)(void *, unsigned int event,
+ struct qdss_request *d, struct usb_qdss_ch *c))
+{
+ return ERR_PTR(-ENODEV);
+}
+
+static inline int usb_qdss_read(struct usb_qdss_ch *c, struct qdss_request *d)
+{
+ return -ENODEV;
+}
+
+static inline int usb_qdss_write(struct usb_qdss_ch *c, struct qdss_request *d)
+{
+ return -ENODEV;
+}
+
+static inline int usb_qdss_ctrl_write(struct usb_qdss_ch *c,
+ struct qdss_request *d)
+{
+ return -ENODEV;
+}
+
+static inline int usb_qdss_ctrl_read(struct usb_qdss_ch *c,
+ struct qdss_request *d)
+{
+ return -ENODEV;
+}
+static inline int usb_qdss_alloc_req(struct usb_qdss_ch *c, int n_wr, int n_rd)
+{
+ return -ENODEV;
+}
+
+
+static inline void usb_qdss_close(struct usb_qdss_ch *ch) { }
+
+static inline void usb_qdss_free_req(struct usb_qdss_ch *ch) { }
+#endif /* CONFIG_USB_F_QDSS */
+
+#endif
diff --git a/mm/memblock.c b/mm/memblock.c
index 166f17a..49b7c1e 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1641,11 +1641,12 @@ int __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t size
memblock.memory.regions[idx].size) >= end;
}
-int __init_memblock memblock_overlaps_memory(phys_addr_t base, phys_addr_t size)
+bool __init_memblock memblock_overlaps_memory(phys_addr_t base,
+ phys_addr_t size)
{
memblock_cap_size(base, &size);
- return memblock_overlaps_region(&memblock.memory, base, size) >= 0;
+ return memblock_overlaps_region(&memblock.memory, base, size);
}
/**