From patchwork Mon Jan 23 13:46:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 9533383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B99F46020B for ; Mon, 23 Jan 2017 19:19:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AACF327AB2 for ; Mon, 23 Jan 2017 19:19:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E7F627CF9; Mon, 23 Jan 2017 19:19:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 318FD27AB2 for ; Mon, 23 Jan 2017 19:19:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D3AA86E5D6; Mon, 23 Jan 2017 19:19:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 10909 seconds by postgrey-1.35 at gabe; Mon, 23 Jan 2017 19:19:19 UTC Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0060.outbound.protection.outlook.com [104.47.1.60]) by gabe.freedesktop.org (Postfix) with ESMTPS id 58A106E5D6 for ; Mon, 23 Jan 2017 19:19:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=kYb9KLkhtk4ciXALr1TQp0dnS3nOUQNcW7oRfNgQevE=; b=FA4rmWyIJFCulWTr4Ul8WJyFVep2ivIERtFct6bKLkojiPSqraLtmoUGk+CLE+tKAlfUVrkJGO8RMzh3YOo513kgkQjVFwCVm0EE9PDg/Gz76Y0moiMTVjl80m65AJAqs/z5HMNrPfOGa+PTPRjNkbeP2THK/oY48AYzVzKNPd0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Mihail.Atanassov@arm.com; Received: from e110433-lin.cambridge.arm.com (217.140.96.140) by AM4PR08MB0881.eurprd08.prod.outlook.com (10.164.83.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Mon, 23 Jan 2017 13:46:46 +0000 From: Mihail Atanassov To: DRI devel Subject: [PATCH 1/2] drm: mali-dp: Check hw version matches device-tree Date: Mon, 23 Jan 2017 13:46:41 +0000 Message-ID: <1485179202-16118-1-git-send-email-mihail.atanassov@arm.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: HE1PR0701CA0044.eurprd07.prod.outlook.com (10.168.191.12) To AM4PR08MB0881.eurprd08.prod.outlook.com (10.164.83.27) X-MS-Office365-Filtering-Correlation-Id: f2c46620-28a4-474f-b31b-08d443964657 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM4PR08MB0881; X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0881; 3:ZNM1vWxrXZJIhW+rxLjda17nx0wtpfELHCtM9Ui5XTFyEl7iZDwVDpfXb45yzOp/eCA2HYtzxhpSQ8DB2LuIYOMrcedJgFxFzG8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PQffH3oVntKJ7e2OS2guE9OMrL021b98sZnFuaGmTA6QF2HMFeHSXac1WyD3gBMx8Ayhrbtqxrz3rzfmFfvOWT3sgKinkEUl4nwMMJvsZVbJ6QXAFoi4cIJYL3KzlTDbRtiSF3Zt33wjgPpN2LZqHfO0uEbgAMAd1IK9A7NmaJE3rQ/khJpsXdrdtCaWxDH3sdum33WjZS0VrbOYod6JEpfQ==; 20:oad7eubjueAp3agEa/onVGzSDCMnUHy4qpOiUSW/az8ljJH0oB4+GIdvShkgNkdx/14H0NsZFgA4LpCpa9YhzecYSqQwWQJAAIUE6untXTxenhItP6/CVtEUGoZzgdKC97DRYRDmR2POEL7b2nZ7DrWcHTSdJcDYYg01Q3u2izM= NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123558021)(20161123555025)(20161123562025)(20161123564025)(6072148); SRVR:AM4PR08MB0881; BCL:0; PCL:0; RULEID:; SRVR:AM4PR08MB0881; X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0881; 4:P9dknbw538fNLW9g72C8/2p3GE3HCZJK/D9cXhIofVi4wGPnqQ6/VZ4mx8UPoUM8glx5M7ipsF+E5H7qTj00NmF1r37as8uS75/uFkma16UYJisYxvNEWYbGCr7Sb/hVhdDdCAmJuFPZmkI2zbDNYPnM0De/rpeCtjYmE6re5Vu5ggRWyiCqRgaJ9MD1TmuKo8GpumtKfJesuWe/kHD3+SkiSysuYPylguJu2nfyVFr8otcrbHkue0Q1mnQkHde6TLJV+uvdxRMIsK9hgMIXeErQagI2bx6FZOs3CVql9DIRMGrJR7dAG9H9GWtkCsFceCAFgYOjFqXr22HEI61onjdXzehTgbS8b+Y7143rw9ZBxBsT/b9hyHfCzwaVthS4fCeAG78iQTlW0WSaxV/xcurnnl2juLDEfWNtYDT1flbmW4bbtULa54xeGCZF2brzvZk3zlu0B+6flBD+GWG12UlaOesRzKrSilYLk8RFXrQArR7fGWfm2flhxJevWFirGnQgJb/mk0mCnQlzbzLUu4+dHQ7l4yGJQVR+uoFBKDzOm2QV0aVa0HKf1Qad/sfXWHvRL4Vwdd/59rIKZ581QV/TEII1FwXAFt8U0bQ6EOavzOqIK1PoKsJ7ZLcEBoO4wvlvoy8ym3tp39uqrzMIBVtF/bQLJflC8tPkhf/JugY= X-Forefront-PRVS: 0196A226D1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(39410400002)(39850400002)(39860400002)(39840400002)(199003)(189002)(54906002)(92566002)(81156014)(4326007)(50226002)(25786008)(5003940100001)(8676002)(81166006)(33646002)(3846002)(6116002)(106356001)(50466002)(110136003)(305945005)(7736002)(66066001)(189998001)(105586002)(48376002)(42186005)(36756003)(50986999)(68736007)(47776003)(6666003)(101416001)(53936002)(5660300001)(6486002)(6916009)(86362001)(38730400001)(2906002)(97736004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR08MB0881; H:e110433-lin.cambridge.arm.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR08MB0881; 23:uLft8/mURbIQ9BN+krtVU24gH16HXct4N3iL7d+8a?= =?us-ascii?Q?D/DHc3zkwCiisLBO1i9HgN4EDSOy9FLOFTrhTRclc0Wb/TEamWJ/4MGiPP7y?= =?us-ascii?Q?2Q8SGR0kf2WfqWfWKWjhJCJeNkFDdVleMSwINYVU2AdHCZFkU/jRj1hwUxGp?= =?us-ascii?Q?xjoCIrKJz0qkvlXhi6OiQrIvWSA8OC/HAXOAaTc0MMVP8VanWmz2jRll6VUn?= =?us-ascii?Q?INri7aal/cHVmnE3Dm4kyNt7JFfLCJmyVaVV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upP8BWuOJsmtXeMGY+VPmh3E?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0881; 6:W0zOxGVTO40xx/00q3S0jr5k3SOdDyrttR046yIPfoYMc1wuec+rB5qtR15KDrCVlG/VtFQsNIbMwFkih/C95tDCplpjBAFjQ/NNBFV67MLzoX9amboZTsltoKDh46v6zOCg9FaSISacxcorCcpua3xioTWcxQbhPER5MhbpvV3OllMQqKMXzBufF/dPy0QEdBJ8zp+maX1PHjV51xoDceUpvSMuXTGC5RHF4VuYC9EZjbDnosLT6VTuk7PKroSlSemnYxaPJkFVTW4PawG/aO4y+VoYSHbE+qFfo/6Oa6rxn+wxQ8lYMoHEo0elDLnJPmWR50mHfad1IBsmwzZCub8qSWO8Kq17EK6uUw2LJagBXMTc4fk6wN12qmB6OT8lackaFCB3HNLOZfgAV5TkHkCYFDie9S1YADrclr9VMEcldwPtNTMN5WYrcHu8jB2NKPVBF7tfcoh6UbJqDN9qrQ==; 5:EQoRl3UolcUJxeaiwzIgvSCsYdbubtSkIbV3ESDoSXrBqFmEyjYXev7/xl8ynNdB8ixuxx3FX4unVsLgpb913LkrVzmWf5ZrMea1/2E/i+anZwlCPku2HbHY1DiYmqpgqjL2pzR2tiWE1lTpyg9jSGo2cgRosBTM3nklUGxPAQg=; 24:SG24PHSum8FTGopTCUviJo39pubkpPI4G9DOOlTjxEdfCt5rKoXq7czFxdvVKDXaKCQLP8ibaIu7mPqsQBNlZnp2wLWM7q+NpVu7yaCnYZ4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0881; 7:bWEZZtA3/8WDfvlcTwh4vLvfs8rXig3ULf6uBjEryMrJOAB1vOB3oJJBOadIy139XEj24zgKQl9eGAN74sU1Dg8A+kxtrf/uGKgaE4p4oTJnBf5PI13PtugWjPq0/h8N+42qtxblkZWKrI4D1V91BRuNya+ybtKYr0Ayt5+MAE26E6ca6SkKqE4rSOyhfRNs8U1Xn7DgzlTrFkx6/PYOhYcW8IWvZsWdWqRIxLYu4h4KZfAEsvpuyZE8DlsLGPsFo6IaPeBoIW/o5Y85VZWvyEZMKaMFBq7pTNlxOx7UmQ1+FTALUhlW4VtUtrHhd2GGTamKK/2Qlgt+yC1zlFx6VHOA1yZdTM7khDo8NwKglGQkxTExu9D2GZm/PFjmSrrSBgx0DOQf1nwWwx/EdkaqO7Yv1r5OqMxbAa2CHnpi2zEQ1ujFOtRFsIJaR6Yl+sRiu4nLNBhHDfvj1snSJ15kxQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2017 13:46:46.4956 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB0881 Cc: nd@arm.com, Liviu Dudau , LKML X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Refuse to bind if the device-tree compatible string lists a different hardware version. Reviewed-by: Brian Starkey Signed-off-by: Mihail Atanassov --- A couple of small improvements to driver-to-hardware binding. drivers/gpu/drm/arm/malidp_drv.c | 52 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/arm/malidp_regs.h | 2 ++ 2 files changed, 54 insertions(+) diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c index 32f746e..43238f4 100644 --- a/drivers/gpu/drm/arm/malidp_drv.c +++ b/drivers/gpu/drm/arm/malidp_drv.c @@ -256,6 +256,46 @@ static void malidp_lastclose(struct drm_device *drm) }; MODULE_DEVICE_TABLE(of, malidp_drm_of_match); +static bool malidp_is_compatible_hw_id(struct malidp_hw_device *hwdev, + const struct of_device_id *dev_id) +{ + u32 core_id; + const char *compatstr_dp500 = "arm,mali-dp500"; + bool is_dp500; + bool dt_is_dp500; + + /* + * The DP500 CORE_ID register is in a different location, so check it + * first. If the product id field matches, then this is DP500, otherwise + * check the DP550/650 CORE_ID register. + */ + core_id = malidp_hw_read(hwdev, MALIDP500_DC_BASE + MALIDP_DE_CORE_ID); + /* Offset 0x18 will never read 0x500 on products other than DP500. */ + is_dp500 = (MALIDP_PRODUCT_ID(core_id) == 0x500); + dt_is_dp500 = strnstr(dev_id->compatible, compatstr_dp500, + sizeof(dev_id->compatible)) != NULL; + if (is_dp500 != dt_is_dp500) { + DRM_ERROR("Device-tree expects %s, but hardware %s DP500.\n", + dev_id->compatible, is_dp500 ? "is" : "is not"); + return false; + } else if (!dt_is_dp500) { + u16 product_id; + char buf[32]; + + core_id = malidp_hw_read(hwdev, + MALIDP550_DC_BASE + MALIDP_DE_CORE_ID); + product_id = MALIDP_PRODUCT_ID(core_id); + snprintf(buf, sizeof(buf), "arm,mali-dp%X", product_id); + if (!strnstr(dev_id->compatible, buf, + sizeof(dev_id->compatible))) { + DRM_ERROR("Device-tree expects %s, but hardware is DP%03X.\n", + dev_id->compatible, product_id); + return false; + } + } + return true; +} + #define MAX_OUTPUT_CHANNELS 3 static int malidp_bind(struct device *dev) @@ -266,6 +306,7 @@ static int malidp_bind(struct device *dev) struct malidp_drm *malidp; struct malidp_hw_device *hwdev; struct platform_device *pdev = to_platform_device(dev); + struct of_device_id const *dev_id; /* number of lines for the R, G and B output */ u8 output_width[MAX_OUTPUT_CHANNELS]; int ret = 0, i; @@ -329,6 +370,17 @@ static int malidp_bind(struct device *dev) clk_prepare_enable(hwdev->aclk); clk_prepare_enable(hwdev->mclk); + dev_id = of_match_device(malidp_drm_of_match, dev); + if (!dev_id) { + ret = -EINVAL; + goto query_hw_fail; + } + + if (!malidp_is_compatible_hw_id(hwdev, dev_id)) { + ret = -EINVAL; + goto query_hw_fail; + } + ret = hwdev->query_hw(hwdev); if (ret) { DRM_ERROR("Invalid HW configuration\n"); diff --git a/drivers/gpu/drm/arm/malidp_regs.h b/drivers/gpu/drm/arm/malidp_regs.h index 73fecb3..7a89997 100644 --- a/drivers/gpu/drm/arm/malidp_regs.h +++ b/drivers/gpu/drm/arm/malidp_regs.h @@ -92,6 +92,8 @@ #define MALIDP_DE_H_ACTIVE(x) (((x) & 0x1fff) << 0) #define MALIDP_DE_V_ACTIVE(x) (((x) & 0x1fff) << 16) +#define MALIDP_PRODUCT_ID(__core_id) ((u32)(__core_id) >> 16) + /* register offsets and bits specific to DP500 */ #define MALIDP500_DC_BASE 0x00000 #define MALIDP500_DC_CONTROL 0x0000c