Commit 90b593ce authored by Rob Clark's avatar Rob Clark

drm/msm/adreno: Switch to chip-id for identifying GPU

Since the revision becomes an opaque identifier with future GPUs, move
away from treating different ranges of bits as having a given meaning.
This means that we need to explicitly list different patch revisions in
the device table.
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/549782/
parent b42ab854
...@@ -145,7 +145,7 @@ static void a4xx_enable_hwcg(struct msm_gpu *gpu) ...@@ -145,7 +145,7 @@ static void a4xx_enable_hwcg(struct msm_gpu *gpu)
gpu_write(gpu, REG_A4XX_RBBM_CLOCK_DELAY_HLSQ, 0x00220000); gpu_write(gpu, REG_A4XX_RBBM_CLOCK_DELAY_HLSQ, 0x00220000);
/* Early A430's have a timing issue with SP/TP power collapse; /* Early A430's have a timing issue with SP/TP power collapse;
disabling HW clock gating prevents it. */ disabling HW clock gating prevents it. */
if (adreno_is_a430(adreno_gpu) && adreno_gpu->rev.patchid < 2) if (adreno_is_a430(adreno_gpu) && adreno_patchid(adreno_gpu) < 2)
gpu_write(gpu, REG_A4XX_RBBM_CLOCK_CTL, 0); gpu_write(gpu, REG_A4XX_RBBM_CLOCK_CTL, 0);
else else
gpu_write(gpu, REG_A4XX_RBBM_CLOCK_CTL, 0xAAAAAAAA); gpu_write(gpu, REG_A4XX_RBBM_CLOCK_CTL, 0xAAAAAAAA);
......
...@@ -1770,7 +1770,7 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev) ...@@ -1770,7 +1770,7 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
nr_rings = 4; nr_rings = 4;
if (adreno_cmp_rev(ADRENO_REV(5, 1, 0, ANY_ID), config->rev)) if (config->info->revn == 510)
nr_rings = 1; nr_rings = 1;
ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, nr_rings); ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, nr_rings);
......
...@@ -179,7 +179,7 @@ static void a540_lm_setup(struct msm_gpu *gpu) ...@@ -179,7 +179,7 @@ static void a540_lm_setup(struct msm_gpu *gpu)
/* The battery current limiter isn't enabled for A540 */ /* The battery current limiter isn't enabled for A540 */
config = AGC_LM_CONFIG_BCL_DISABLED; config = AGC_LM_CONFIG_BCL_DISABLED;
config |= adreno_gpu->rev.patchid << AGC_LM_CONFIG_GPU_VERSION_SHIFT; config |= adreno_patchid(adreno_gpu) << AGC_LM_CONFIG_GPU_VERSION_SHIFT;
/* For now disable GPMU side throttling */ /* For now disable GPMU side throttling */
config |= AGC_LM_CONFIG_THROTTLE_DISABLE; config |= AGC_LM_CONFIG_THROTTLE_DISABLE;
......
...@@ -790,10 +790,16 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state) ...@@ -790,10 +790,16 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)
gmu_write(gmu, REG_A6XX_GMU_AHB_FENCE_RANGE_0, gmu_write(gmu, REG_A6XX_GMU_AHB_FENCE_RANGE_0,
(1 << 31) | (0xa << 18) | (0xa0)); (1 << 31) | (0xa << 18) | (0xa0));
chipid = adreno_gpu->rev.core << 24; /*
chipid |= adreno_gpu->rev.major << 16; * Note that the GMU has a slightly different layout for
chipid |= adreno_gpu->rev.minor << 12; * chip_id, for whatever reason, so a bit of massaging
chipid |= adreno_gpu->rev.patchid << 8; * is needed. The upper 16b are the same, but minor and
* patchid are packed in four bits each with the lower
* 8b unused:
*/
chipid = adreno_gpu->chip_id & 0xffff0000;
chipid |= (adreno_gpu->chip_id << 4) & 0xf000; /* minor */
chipid |= (adreno_gpu->chip_id << 8) & 0x0f00; /* patchid */
gmu_write(gmu, REG_A6XX_GMU_HFI_SFR_ADDR, chipid); gmu_write(gmu, REG_A6XX_GMU_HFI_SFR_ADDR, chipid);
......
...@@ -22,7 +22,7 @@ module_param_named(allow_vram_carveout, allow_vram_carveout, bool, 0600); ...@@ -22,7 +22,7 @@ module_param_named(allow_vram_carveout, allow_vram_carveout, bool, 0600);
static const struct adreno_info gpulist[] = { static const struct adreno_info gpulist[] = {
{ {
.rev = ADRENO_REV(2, 0, 0, 0), .chip_ids = ADRENO_CHIP_IDS(0x02000000),
.family = ADRENO_2XX_GEN1, .family = ADRENO_2XX_GEN1,
.revn = 200, .revn = 200,
.fw = { .fw = {
...@@ -33,7 +33,7 @@ static const struct adreno_info gpulist[] = { ...@@ -33,7 +33,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a2xx_gpu_init, .init = a2xx_gpu_init,
}, { /* a200 on i.mx51 has only 128kib gmem */ }, { /* a200 on i.mx51 has only 128kib gmem */
.rev = ADRENO_REV(2, 0, 0, 1), .chip_ids = ADRENO_CHIP_IDS(0x02000001),
.family = ADRENO_2XX_GEN1, .family = ADRENO_2XX_GEN1,
.revn = 201, .revn = 201,
.fw = { .fw = {
...@@ -44,7 +44,7 @@ static const struct adreno_info gpulist[] = { ...@@ -44,7 +44,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a2xx_gpu_init, .init = a2xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(2, 2, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x02020000),
.family = ADRENO_2XX_GEN2, .family = ADRENO_2XX_GEN2,
.revn = 220, .revn = 220,
.fw = { .fw = {
...@@ -55,7 +55,10 @@ static const struct adreno_info gpulist[] = { ...@@ -55,7 +55,10 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a2xx_gpu_init, .init = a2xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(3, 0, 5, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(
0x03000512,
0x03000520
),
.family = ADRENO_3XX, .family = ADRENO_3XX,
.revn = 305, .revn = 305,
.fw = { .fw = {
...@@ -66,7 +69,7 @@ static const struct adreno_info gpulist[] = { ...@@ -66,7 +69,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a3xx_gpu_init, .init = a3xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(3, 0, 6, 0), .chip_ids = ADRENO_CHIP_IDS(0x03000600),
.family = ADRENO_3XX, .family = ADRENO_3XX,
.revn = 307, /* because a305c is revn==306 */ .revn = 307, /* because a305c is revn==306 */
.fw = { .fw = {
...@@ -77,7 +80,11 @@ static const struct adreno_info gpulist[] = { ...@@ -77,7 +80,11 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a3xx_gpu_init, .init = a3xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(3, 2, ANY_ID, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(
0x03020000,
0x03020001,
0x03020002
),
.family = ADRENO_3XX, .family = ADRENO_3XX,
.revn = 320, .revn = 320,
.fw = { .fw = {
...@@ -88,7 +95,11 @@ static const struct adreno_info gpulist[] = { ...@@ -88,7 +95,11 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a3xx_gpu_init, .init = a3xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(3, 3, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(
0x03030000,
0x03030001,
0x03030002
),
.family = ADRENO_3XX, .family = ADRENO_3XX,
.revn = 330, .revn = 330,
.fw = { .fw = {
...@@ -99,7 +110,7 @@ static const struct adreno_info gpulist[] = { ...@@ -99,7 +110,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a3xx_gpu_init, .init = a3xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(4, 0, 5, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x04000500),
.family = ADRENO_4XX, .family = ADRENO_4XX,
.revn = 405, .revn = 405,
.fw = { .fw = {
...@@ -110,7 +121,7 @@ static const struct adreno_info gpulist[] = { ...@@ -110,7 +121,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a4xx_gpu_init, .init = a4xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(4, 2, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x04020000),
.family = ADRENO_4XX, .family = ADRENO_4XX,
.revn = 420, .revn = 420,
.fw = { .fw = {
...@@ -121,7 +132,7 @@ static const struct adreno_info gpulist[] = { ...@@ -121,7 +132,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a4xx_gpu_init, .init = a4xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(4, 3, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x04030002),
.family = ADRENO_4XX, .family = ADRENO_4XX,
.revn = 430, .revn = 430,
.fw = { .fw = {
...@@ -132,7 +143,7 @@ static const struct adreno_info gpulist[] = { ...@@ -132,7 +143,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD, .inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a4xx_gpu_init, .init = a4xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(5, 0, 6, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x05000600),
.family = ADRENO_5XX, .family = ADRENO_5XX,
.revn = 506, .revn = 506,
.fw = { .fw = {
...@@ -150,7 +161,7 @@ static const struct adreno_info gpulist[] = { ...@@ -150,7 +161,7 @@ static const struct adreno_info gpulist[] = {
.init = a5xx_gpu_init, .init = a5xx_gpu_init,
.zapfw = "a506_zap.mdt", .zapfw = "a506_zap.mdt",
}, { }, {
.rev = ADRENO_REV(5, 0, 8, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x05000800),
.family = ADRENO_5XX, .family = ADRENO_5XX,
.revn = 508, .revn = 508,
.fw = { .fw = {
...@@ -167,7 +178,7 @@ static const struct adreno_info gpulist[] = { ...@@ -167,7 +178,7 @@ static const struct adreno_info gpulist[] = {
.init = a5xx_gpu_init, .init = a5xx_gpu_init,
.zapfw = "a508_zap.mdt", .zapfw = "a508_zap.mdt",
}, { }, {
.rev = ADRENO_REV(5, 0, 9, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x05000900),
.family = ADRENO_5XX, .family = ADRENO_5XX,
.revn = 509, .revn = 509,
.fw = { .fw = {
...@@ -185,7 +196,7 @@ static const struct adreno_info gpulist[] = { ...@@ -185,7 +196,7 @@ static const struct adreno_info gpulist[] = {
/* Adreno 509 uses the same ZAP as 512 */ /* Adreno 509 uses the same ZAP as 512 */
.zapfw = "a512_zap.mdt", .zapfw = "a512_zap.mdt",
}, { }, {
.rev = ADRENO_REV(5, 1, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x05010000),
.family = ADRENO_5XX, .family = ADRENO_5XX,
.revn = 510, .revn = 510,
.fw = { .fw = {
...@@ -200,7 +211,7 @@ static const struct adreno_info gpulist[] = { ...@@ -200,7 +211,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = 250, .inactive_period = 250,
.init = a5xx_gpu_init, .init = a5xx_gpu_init,
}, { }, {
.rev = ADRENO_REV(5, 1, 2, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x05010200),
.family = ADRENO_5XX, .family = ADRENO_5XX,
.revn = 512, .revn = 512,
.fw = { .fw = {
...@@ -217,7 +228,10 @@ static const struct adreno_info gpulist[] = { ...@@ -217,7 +228,10 @@ static const struct adreno_info gpulist[] = {
.init = a5xx_gpu_init, .init = a5xx_gpu_init,
.zapfw = "a512_zap.mdt", .zapfw = "a512_zap.mdt",
}, { }, {
.rev = ADRENO_REV(5, 3, 0, 2), .chip_ids = ADRENO_CHIP_IDS(
0x05030002,
0x05030004
),
.family = ADRENO_5XX, .family = ADRENO_5XX,
.revn = 530, .revn = 530,
.fw = { .fw = {
...@@ -236,7 +250,7 @@ static const struct adreno_info gpulist[] = { ...@@ -236,7 +250,7 @@ static const struct adreno_info gpulist[] = {
.init = a5xx_gpu_init, .init = a5xx_gpu_init,
.zapfw = "a530_zap.mdt", .zapfw = "a530_zap.mdt",
}, { }, {
.rev = ADRENO_REV(5, 4, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x05040001),
.family = ADRENO_5XX, .family = ADRENO_5XX,
.revn = 540, .revn = 540,
.fw = { .fw = {
...@@ -254,7 +268,7 @@ static const struct adreno_info gpulist[] = { ...@@ -254,7 +268,7 @@ static const struct adreno_info gpulist[] = {
.init = a5xx_gpu_init, .init = a5xx_gpu_init,
.zapfw = "a540_zap.mdt", .zapfw = "a540_zap.mdt",
}, { }, {
.rev = ADRENO_REV(6, 1, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06010000),
.family = ADRENO_6XX_GEN1, .family = ADRENO_6XX_GEN1,
.revn = 610, .revn = 610,
.fw = { .fw = {
...@@ -280,7 +294,7 @@ static const struct adreno_info gpulist[] = { ...@@ -280,7 +294,7 @@ static const struct adreno_info gpulist[] = {
{ 127, 4 }, { 127, 4 },
), ),
}, { }, {
.rev = ADRENO_REV(6, 1, 8, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06010800),
.family = ADRENO_6XX_GEN1, .family = ADRENO_6XX_GEN1,
.revn = 618, .revn = 618,
.fw = { .fw = {
...@@ -298,7 +312,7 @@ static const struct adreno_info gpulist[] = { ...@@ -298,7 +312,7 @@ static const struct adreno_info gpulist[] = {
), ),
}, { }, {
.machine = "qcom,sm4350", .machine = "qcom,sm4350",
.rev = ADRENO_REV(6, 1, 9, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06010900),
.family = ADRENO_6XX_GEN1, .family = ADRENO_6XX_GEN1,
.revn = 619, .revn = 619,
.fw = { .fw = {
...@@ -317,7 +331,7 @@ static const struct adreno_info gpulist[] = { ...@@ -317,7 +331,7 @@ static const struct adreno_info gpulist[] = {
), ),
}, { }, {
.machine = "qcom,sm6375", .machine = "qcom,sm6375",
.rev = ADRENO_REV(6, 1, 9, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06010900),
.family = ADRENO_6XX_GEN1, .family = ADRENO_6XX_GEN1,
.revn = 619, .revn = 619,
.fw = { .fw = {
...@@ -335,7 +349,7 @@ static const struct adreno_info gpulist[] = { ...@@ -335,7 +349,7 @@ static const struct adreno_info gpulist[] = {
{ 177, 2 }, { 177, 2 },
), ),
}, { }, {
.rev = ADRENO_REV(6, 1, 9, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06010900),
.family = ADRENO_6XX_GEN1, .family = ADRENO_6XX_GEN1,
.revn = 619, .revn = 619,
.fw = { .fw = {
...@@ -356,7 +370,10 @@ static const struct adreno_info gpulist[] = { ...@@ -356,7 +370,10 @@ static const struct adreno_info gpulist[] = {
{ 180, 1 }, { 180, 1 },
), ),
}, { }, {
.rev = ADRENO_REV(6, 3, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(
0x06030001,
0x06030002
),
.family = ADRENO_6XX_GEN1, .family = ADRENO_6XX_GEN1,
.revn = 630, .revn = 630,
.fw = { .fw = {
...@@ -370,7 +387,7 @@ static const struct adreno_info gpulist[] = { ...@@ -370,7 +387,7 @@ static const struct adreno_info gpulist[] = {
.zapfw = "a630_zap.mdt", .zapfw = "a630_zap.mdt",
.hwcg = a630_hwcg, .hwcg = a630_hwcg,
}, { }, {
.rev = ADRENO_REV(6, 4, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06040001),
.family = ADRENO_6XX_GEN2, .family = ADRENO_6XX_GEN2,
.revn = 640, .revn = 640,
.fw = { .fw = {
...@@ -388,7 +405,7 @@ static const struct adreno_info gpulist[] = { ...@@ -388,7 +405,7 @@ static const struct adreno_info gpulist[] = {
{ 1, 1 }, { 1, 1 },
), ),
}, { }, {
.rev = ADRENO_REV(6, 5, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06050002),
.family = ADRENO_6XX_GEN3, .family = ADRENO_6XX_GEN3,
.revn = 650, .revn = 650,
.fw = { .fw = {
...@@ -410,7 +427,7 @@ static const struct adreno_info gpulist[] = { ...@@ -410,7 +427,7 @@ static const struct adreno_info gpulist[] = {
{ 3, 2 }, { 3, 2 },
), ),
}, { }, {
.rev = ADRENO_REV(6, 6, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06060001),
.family = ADRENO_6XX_GEN4, .family = ADRENO_6XX_GEN4,
.revn = 660, .revn = 660,
.fw = { .fw = {
...@@ -426,7 +443,7 @@ static const struct adreno_info gpulist[] = { ...@@ -426,7 +443,7 @@ static const struct adreno_info gpulist[] = {
.hwcg = a660_hwcg, .hwcg = a660_hwcg,
.address_space_size = SZ_16G, .address_space_size = SZ_16G,
}, { }, {
.rev = ADRENO_REV(6, 3, 5, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06030500),
.family = ADRENO_6XX_GEN4, .family = ADRENO_6XX_GEN4,
.fw = { .fw = {
[ADRENO_FW_SQE] = "a660_sqe.fw", [ADRENO_FW_SQE] = "a660_sqe.fw",
...@@ -445,7 +462,7 @@ static const struct adreno_info gpulist[] = { ...@@ -445,7 +462,7 @@ static const struct adreno_info gpulist[] = {
{ 190, 1 }, { 190, 1 },
), ),
}, { }, {
.rev = ADRENO_REV(6, 8, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06080000),
.family = ADRENO_6XX_GEN2, .family = ADRENO_6XX_GEN2,
.revn = 680, .revn = 680,
.fw = { .fw = {
...@@ -459,7 +476,7 @@ static const struct adreno_info gpulist[] = { ...@@ -459,7 +476,7 @@ static const struct adreno_info gpulist[] = {
.zapfw = "a640_zap.mdt", .zapfw = "a640_zap.mdt",
.hwcg = a640_hwcg, .hwcg = a640_hwcg,
}, { }, {
.rev = ADRENO_REV(6, 9, 0, ANY_ID), .chip_ids = ADRENO_CHIP_IDS(0x06090000),
.family = ADRENO_6XX_GEN4, .family = ADRENO_6XX_GEN4,
.fw = { .fw = {
[ADRENO_FW_SQE] = "a660_sqe.fw", [ADRENO_FW_SQE] = "a660_sqe.fw",
...@@ -494,30 +511,15 @@ MODULE_FIRMWARE("qcom/a630_sqe.fw"); ...@@ -494,30 +511,15 @@ MODULE_FIRMWARE("qcom/a630_sqe.fw");
MODULE_FIRMWARE("qcom/a630_gmu.bin"); MODULE_FIRMWARE("qcom/a630_gmu.bin");
MODULE_FIRMWARE("qcom/a630_zap.mbn"); MODULE_FIRMWARE("qcom/a630_zap.mbn");
static inline bool _rev_match(uint8_t entry, uint8_t id) static const struct adreno_info *adreno_info(uint32_t chip_id)
{ {
return (entry == ANY_ID) || (entry == id);
}
bool adreno_cmp_rev(struct adreno_rev rev1, struct adreno_rev rev2)
{
return _rev_match(rev1.core, rev2.core) &&
_rev_match(rev1.major, rev2.major) &&
_rev_match(rev1.minor, rev2.minor) &&
_rev_match(rev1.patchid, rev2.patchid);
}
static const struct adreno_info *adreno_info(struct adreno_rev rev)
{
int i;
/* identify gpu: */ /* identify gpu: */
for (i = 0; i < ARRAY_SIZE(gpulist); i++) { for (int i = 0; i < ARRAY_SIZE(gpulist); i++) {
const struct adreno_info *info = &gpulist[i]; const struct adreno_info *info = &gpulist[i];
if (info->machine && !of_machine_is_compatible(info->machine)) if (info->machine && !of_machine_is_compatible(info->machine))
continue; continue;
if (adreno_cmp_rev(info->rev, rev)) for (int j = 0; info->chip_ids[j]; j++)
if (info->chip_ids[j] == chip_id)
return info; return info;
} }
...@@ -598,12 +600,11 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev) ...@@ -598,12 +600,11 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
return NULL; return NULL;
} }
static int find_chipid(struct device *dev, struct adreno_rev *rev) static int find_chipid(struct device *dev, uint32_t *chipid)
{ {
struct device_node *node = dev->of_node; struct device_node *node = dev->of_node;
const char *compat; const char *compat;
int ret; int ret;
u32 chipid;
/* first search the compat strings for qcom,adreno-XYZ.W: */ /* first search the compat strings for qcom,adreno-XYZ.W: */
ret = of_property_read_string_index(node, "compatible", 0, &compat); ret = of_property_read_string_index(node, "compatible", 0, &compat);
...@@ -612,32 +613,34 @@ static int find_chipid(struct device *dev, struct adreno_rev *rev) ...@@ -612,32 +613,34 @@ static int find_chipid(struct device *dev, struct adreno_rev *rev)
if (sscanf(compat, "qcom,adreno-%u.%u", &r, &patch) == 2 || if (sscanf(compat, "qcom,adreno-%u.%u", &r, &patch) == 2 ||
sscanf(compat, "amd,imageon-%u.%u", &r, &patch) == 2) { sscanf(compat, "amd,imageon-%u.%u", &r, &patch) == 2) {
rev->core = r / 100; uint32_t core, major, minor;
core = r / 100;
r %= 100; r %= 100;
rev->major = r / 10; major = r / 10;
r %= 10; r %= 10;
rev->minor = r; minor = r;
rev->patchid = patch;
*chipid = (core << 24) |
(major << 16) |
(minor << 8) |
patch;
return 0; return 0;
} }
if (sscanf(compat, "qcom,adreno-%08x", chipid) == 1)
return 0;
} }
/* and if that fails, fall back to legacy "qcom,chipid" property: */ /* and if that fails, fall back to legacy "qcom,chipid" property: */
ret = of_property_read_u32(node, "qcom,chipid", &chipid); ret = of_property_read_u32(node, "qcom,chipid", chipid);
if (ret) { if (ret) {
DRM_DEV_ERROR(dev, "could not parse qcom,chipid: %d\n", ret); DRM_DEV_ERROR(dev, "could not parse qcom,chipid: %d\n", ret);
return ret; return ret;
} }
rev->core = (chipid >> 24) & 0xff;
rev->major = (chipid >> 16) & 0xff;
rev->minor = (chipid >> 8) & 0xff;
rev->patchid = (chipid & 0xff);
dev_warn(dev, "Using legacy qcom,chipid binding!\n"); dev_warn(dev, "Using legacy qcom,chipid binding!\n");
dev_warn(dev, "Use compatible qcom,adreno-%u%u%u.%u instead.\n",
rev->core, rev->major, rev->minor, rev->patchid);
return 0; return 0;
} }
...@@ -651,23 +654,23 @@ static int adreno_bind(struct device *dev, struct device *master, void *data) ...@@ -651,23 +654,23 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)
struct msm_gpu *gpu; struct msm_gpu *gpu;
int ret; int ret;
ret = find_chipid(dev, &config.rev); ret = find_chipid(dev, &config.chip_id);
if (ret) if (ret)
return ret; return ret;
dev->platform_data = &config; dev->platform_data = &config;
priv->gpu_pdev = to_platform_device(dev); priv->gpu_pdev = to_platform_device(dev);
info = adreno_info(config.rev); info = adreno_info(config.chip_id);
if (!info) { if (!info) {
dev_warn(drm->dev, "Unknown GPU revision: %"ADRENO_CHIPID_FMT"\n", dev_warn(drm->dev, "Unknown GPU revision: %"ADRENO_CHIPID_FMT"\n",
ADRENO_CHIPID_ARGS(config.rev)); ADRENO_CHIPID_ARGS(config.chip_id));
return -ENXIO; return -ENXIO;
} }
config.info = info; config.info = info;
DBG("Found GPU: %"ADRENO_CHIPID_FMT, ADRENO_CHIPID_ARGS(config.rev)); DBG("Found GPU: %"ADRENO_CHIPID_FMT, ADRENO_CHIPID_ARGS(config.chip_id));
priv->is_a2xx = info->family < ADRENO_3XX; priv->is_a2xx = info->family < ADRENO_3XX;
priv->has_cached_coherent = priv->has_cached_coherent =
......
...@@ -326,10 +326,7 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx, ...@@ -326,10 +326,7 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx,
*value = !adreno_is_a650_family(adreno_gpu) ? 0x100000 : 0; *value = !adreno_is_a650_family(adreno_gpu) ? 0x100000 : 0;
return 0; return 0;
case MSM_PARAM_CHIP_ID: case MSM_PARAM_CHIP_ID:
*value = (uint64_t)adreno_gpu->rev.patchid | *value = adreno_gpu->chip_id;
((uint64_t)adreno_gpu->rev.minor << 8) |
((uint64_t)adreno_gpu->rev.major << 16) |
((uint64_t)adreno_gpu->rev.core << 24);
if (!adreno_gpu->info->revn) if (!adreno_gpu->info->revn)
*value |= ((uint64_t) adreno_gpu->speedbin) << 32; *value |= ((uint64_t) adreno_gpu->speedbin) << 32;
return 0; return 0;
...@@ -849,7 +846,7 @@ void adreno_show(struct msm_gpu *gpu, struct msm_gpu_state *state, ...@@ -849,7 +846,7 @@ void adreno_show(struct msm_gpu *gpu, struct msm_gpu_state *state,
drm_printf(p, "revision: %u (%"ADRENO_CHIPID_FMT")\n", drm_printf(p, "revision: %u (%"ADRENO_CHIPID_FMT")\n",
adreno_gpu->info->revn, adreno_gpu->info->revn,
ADRENO_CHIPID_ARGS(adreno_gpu->rev)); ADRENO_CHIPID_ARGS(adreno_gpu->chip_id));
/* /*
* If this is state collected due to iova fault, so fault related info * If this is state collected due to iova fault, so fault related info
* *
...@@ -922,7 +919,7 @@ void adreno_dump_info(struct msm_gpu *gpu) ...@@ -922,7 +919,7 @@ void adreno_dump_info(struct msm_gpu *gpu)
printk("revision: %u (%"ADRENO_CHIPID_FMT")\n", printk("revision: %u (%"ADRENO_CHIPID_FMT")\n",
adreno_gpu->info->revn, adreno_gpu->info->revn,
ADRENO_CHIPID_ARGS(adreno_gpu->rev)); ADRENO_CHIPID_ARGS(adreno_gpu->chip_id));
for (i = 0; i < gpu->nr_rings; i++) { for (i = 0; i < gpu->nr_rings; i++) {
struct msm_ringbuffer *ring = gpu->rb[i]; struct msm_ringbuffer *ring = gpu->rb[i];
...@@ -1073,14 +1070,13 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, ...@@ -1073,14 +1070,13 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
struct adreno_platform_config *config = dev->platform_data; struct adreno_platform_config *config = dev->platform_data;
struct msm_gpu_config adreno_gpu_config = { 0 }; struct msm_gpu_config adreno_gpu_config = { 0 };
struct msm_gpu *gpu = &adreno_gpu->base; struct msm_gpu *gpu = &adreno_gpu->base;
struct adreno_rev *rev = &config->rev;
const char *gpu_name; const char *gpu_name;
u32 speedbin; u32 speedbin;
int ret; int ret;
adreno_gpu->funcs = funcs; adreno_gpu->funcs = funcs;
adreno_gpu->info = config->info; adreno_gpu->info = config->info;
adreno_gpu->rev = *rev; adreno_gpu->chip_id = config->chip_id;
/* Only handle the core clock when GMU is not in use (or is absent). */ /* Only handle the core clock when GMU is not in use (or is absent). */
if (adreno_has_gmu_wrapper(adreno_gpu) || if (adreno_has_gmu_wrapper(adreno_gpu) ||
...@@ -1105,7 +1101,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, ...@@ -1105,7 +1101,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
adreno_gpu->speedbin = (uint16_t) (0xffff & speedbin); adreno_gpu->speedbin = (uint16_t) (0xffff & speedbin);
gpu_name = devm_kasprintf(dev, GFP_KERNEL, "%"ADRENO_CHIPID_FMT, gpu_name = devm_kasprintf(dev, GFP_KERNEL, "%"ADRENO_CHIPID_FMT,
ADRENO_CHIPID_ARGS(config->rev)); ADRENO_CHIPID_ARGS(config->chip_id));
if (!gpu_name) if (!gpu_name)
return -ENOMEM; return -ENOMEM;
......
...@@ -54,23 +54,15 @@ enum adreno_family { ...@@ -54,23 +54,15 @@ enum adreno_family {
#define ADRENO_QUIRK_HAS_HW_APRIV BIT(3) #define ADRENO_QUIRK_HAS_HW_APRIV BIT(3)
#define ADRENO_QUIRK_HAS_CACHED_COHERENT BIT(4) #define ADRENO_QUIRK_HAS_CACHED_COHERENT BIT(4)
struct adreno_rev {
uint8_t core;
uint8_t major;
uint8_t minor;
uint8_t patchid;
};
#define ANY_ID 0xff
#define ADRENO_REV(core, major, minor, patchid) \
((struct adreno_rev){ core, major, minor, patchid })
/* Helper for formating the chip_id in the way that userspace tools like /* Helper for formating the chip_id in the way that userspace tools like
* crashdec expect. * crashdec expect.
*/ */
#define ADRENO_CHIPID_FMT "u.%u.%u.%u" #define ADRENO_CHIPID_FMT "u.%u.%u.%u"
#define ADRENO_CHIPID_ARGS(_r) (_r).core, (_r).major, (_r).minor, (_r).patchid #define ADRENO_CHIPID_ARGS(_c) \
(((_c) >> 24) & 0xff), \
(((_c) >> 16) & 0xff), \
(((_c) >> 8) & 0xff), \
((_c) & 0xff)
struct adreno_gpu_funcs { struct adreno_gpu_funcs {
struct msm_gpu_funcs base; struct msm_gpu_funcs base;
...@@ -92,7 +84,12 @@ struct adreno_speedbin { ...@@ -92,7 +84,12 @@ struct adreno_speedbin {
struct adreno_info { struct adreno_info {
const char *machine; const char *machine;
struct adreno_rev rev; /**
* @chipids: Table of matching chip-ids
*
* Terminated with 0 sentinal
*/
uint32_t *chip_ids;
enum adreno_family family; enum adreno_family family;
uint32_t revn; uint32_t revn;
const char *fw[ADRENO_FW_MAX]; const char *fw[ADRENO_FW_MAX];
...@@ -112,6 +109,8 @@ struct adreno_info { ...@@ -112,6 +109,8 @@ struct adreno_info {
struct adreno_speedbin *speedbins; struct adreno_speedbin *speedbins;
}; };
#define ADRENO_CHIP_IDS(tbl...) (uint32_t[]) { tbl, 0 }
/* /*
* Helper to build a speedbin table, ie. the table: * Helper to build a speedbin table, ie. the table:
* fuse | speedbin * fuse | speedbin
...@@ -132,8 +131,8 @@ struct adreno_info { ...@@ -132,8 +131,8 @@ struct adreno_info {
struct adreno_gpu { struct adreno_gpu {
struct msm_gpu base; struct msm_gpu base;
struct adreno_rev rev;
const struct adreno_info *info; const struct adreno_info *info;
uint32_t chip_id;
uint16_t speedbin; uint16_t speedbin;
const struct adreno_gpu_funcs *funcs; const struct adreno_gpu_funcs *funcs;
...@@ -182,7 +181,7 @@ struct adreno_ocmem { ...@@ -182,7 +181,7 @@ struct adreno_ocmem {
/* platform config data (ie. from DT, or pdata) */ /* platform config data (ie. from DT, or pdata) */
struct adreno_platform_config { struct adreno_platform_config {
struct adreno_rev rev; uint32_t chip_id;
const struct adreno_info *info; const struct adreno_info *info;
}; };
...@@ -200,7 +199,15 @@ struct adreno_platform_config { ...@@ -200,7 +199,15 @@ struct adreno_platform_config {
__ret; \ __ret; \
}) })
bool adreno_cmp_rev(struct adreno_rev rev1, struct adreno_rev rev2); static inline uint8_t adreno_patchid(const struct adreno_gpu *gpu)
{
/* It is probably ok to assume legacy "adreno_rev" format
* for all a6xx devices, but probably best to limit this
* to older things.
*/
WARN_ON_ONCE(gpu->info->family >= ADRENO_6XX_GEN1);
return gpu->chip_id & 0xff;
}
static inline bool adreno_is_revn(const struct adreno_gpu *gpu, uint32_t revn) static inline bool adreno_is_revn(const struct adreno_gpu *gpu, uint32_t revn)
{ {
...@@ -256,7 +263,7 @@ static inline bool adreno_is_a330(const struct adreno_gpu *gpu) ...@@ -256,7 +263,7 @@ static inline bool adreno_is_a330(const struct adreno_gpu *gpu)
static inline bool adreno_is_a330v2(const struct adreno_gpu *gpu) static inline bool adreno_is_a330v2(const struct adreno_gpu *gpu)
{ {
return adreno_is_a330(gpu) && (gpu->rev.patchid > 0); return adreno_is_a330(gpu) && (adreno_patchid(gpu) > 0);
} }
static inline int adreno_is_a405(const struct adreno_gpu *gpu) static inline int adreno_is_a405(const struct adreno_gpu *gpu)
...@@ -346,8 +353,7 @@ static inline int adreno_is_a650(const struct adreno_gpu *gpu) ...@@ -346,8 +353,7 @@ static inline int adreno_is_a650(const struct adreno_gpu *gpu)
static inline int adreno_is_7c3(const struct adreno_gpu *gpu) static inline int adreno_is_7c3(const struct adreno_gpu *gpu)
{ {
/* The order of args is important here to handle ANY_ID correctly */ return gpu->info->chip_ids[0] == 0x06030500;
return adreno_cmp_rev(ADRENO_REV(6, 3, 5, ANY_ID), gpu->rev);
} }
static inline int adreno_is_a660(const struct adreno_gpu *gpu) static inline int adreno_is_a660(const struct adreno_gpu *gpu)
...@@ -362,8 +368,7 @@ static inline int adreno_is_a680(const struct adreno_gpu *gpu) ...@@ -362,8 +368,7 @@ static inline int adreno_is_a680(const struct adreno_gpu *gpu)
static inline int adreno_is_a690(const struct adreno_gpu *gpu) static inline int adreno_is_a690(const struct adreno_gpu *gpu)
{ {
/* The order of args is important here to handle ANY_ID correctly */ return gpu->info->chip_ids[0] == 0x06090000;
return adreno_cmp_rev(ADRENO_REV(6, 9, 0, ANY_ID), gpu->rev);
} }
/* check for a615, a616, a618, a619 or any a630 derivatives */ /* check for a615, a616, a618, a619 or any a630 derivatives */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment