From patchwork Tue Jan 23 05:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 190715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp138080dyi; Mon, 22 Jan 2024 21:47:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtuPiNTvYnJ7bKY7+5fr5NR47AKZ7xIyaWQPIghCuMpR2p4XTCZglN9nW26IMymJMNBZo9 X-Received: by 2002:a50:d7d7:0:b0:55c:661b:7fd3 with SMTP id m23-20020a50d7d7000000b0055c661b7fd3mr570644edj.70.1705988875938; Mon, 22 Jan 2024 21:47:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705988875; cv=pass; d=google.com; s=arc-20160816; b=ijHKJBwcrTSbDh5ZWncceX0xgF+0DdHuykI58M460EL7DqCt+cL9NBOyYjnJHzys2r YPgePiE+es2w8cGS4aTPttuoiZyM3H6wNgcNiYXiZYjdyacLbPDDB1f4DY67sC/RQfI/ vlrq/yvPWT7k4xeOoyxFXr7Px66WBeFHj4dEXAjmEWTqHMWMbk/sigELXm4njP+ptDtg 29q5DN7MG5eJPEYquiQnoHt3lRJehqlMqtVzxP05h3qywTjdlCTUntZfjkJ1aK8KNxp3 iGbYWqhbzyctGmsz42dq+HDyMujq1ngMVAgLpmPWHg3ou/BHdVYh0rkal7rBB2AJpaBg eT0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=NlX2IhxC7IG7fdNkMTjgsYy+j07HegipBBnoIZyhKXU=; fh=z4RmidW4C/H6Wukz35Ay3Y7gZc5eNYlbqbLWbc/zZ2Y=; b=i3b165ZwhGPTwN4SABicHtc5LcoJCD3OW08syWo78RRMResEf8ZBYby5NjjDFwhpdt B0VfDt97f6XEgDBKHxUO913lWUzxcRyDMj5Ez/07Rvtakkvq/Z62WhFR/lkMzR9Vv90Y U2ZuPV6iBlbDBAUj4z/ShMjXUMoC0xYB2wCqH5J5uuKUgC3mLb5TquT3A+NQcAjLZ0WK iMXtVNLyExZoNb0xWrt8cBoIAbRRsnVbf7pGRID5DY6SMbcKTcKkAHrEEOXo6Nc0bSc4 +M+YTZLew+HChnLHigmPlvpN2PfjJ6Pc8S1tkkuRWlamKGwP3XlkCZfFXgvTLX4k2D5N n/cw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-34736-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34736-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id er20-20020a056402449400b0055c8ec36e22si24038edb.677.2024.01.22.21.47.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 21:47:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34736-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-34736-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34736-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8EA7A1F2390B for ; Tue, 23 Jan 2024 05:47:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF2D812E67; Tue, 23 Jan 2024 05:46:52 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C787107B6; Tue, 23 Jan 2024 05:46:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705988811; cv=none; b=oPQDOVWeTR2YJhoxnP7bMKUmMddInWDhnQf2dt8o5RJEorfzvsSg+1cwKFvIHDnM6pIGA4jD8tZ7x0/hW01TYAcUzcSo1h9d9f2Hgcn+lEOitNlBwQSHELufJ6uqPrJM6fTYROUqRWybBartZOSg/P9piZiqVUL61XGgQAOy2A8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705988811; c=relaxed/simple; bh=qupRBqwpHsyoUgPYtpJJmnv5z1ZGXy9lZftnWpjUnAY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qn8M3JsPTs1sN/+MR+/aoY/xhnb+pLW5ZRWs9JRpZuJxEM8TTWgIZJ2riZtyQNgpYl65+EjNNTlwA6AK7oLVcJ1WrKRTVE2ErApaVoF2lDDQQy288MEhjhwehfnH2qjHxFfPSkuKo8GPFkCj7qxac12AAuYQ64hpdNNloFntYMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 572691FB; Mon, 22 Jan 2024 21:47:34 -0800 (PST) Received: from a077893.arm.com (unknown [10.163.40.228]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2D3203F762; Mon, 22 Jan 2024 21:46:43 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com Cc: Anshuman Khandual , Lorenzo Pieralisi , Sudeep Holla , Mike Leach , James Clark , Maxime Coquelin , Alexandre Torgue , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-stm32@st-md-mailman.stormreply.com, Leo Yan , Alexander Shishkin Subject: [PATCH V4 04/11] coresight: Add helpers registering/removing both AMBA and platform drivers Date: Tue, 23 Jan 2024 11:16:01 +0530 Message-Id: <20240123054608.1790189-5-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240123054608.1790189-1-anshuman.khandual@arm.com> References: <20240123054608.1790189-1-anshuman.khandual@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788858991697654015 X-GMAIL-MSGID: 1788858991697654015 This adds two different helpers i.e coresight_init_driver()/remove_driver() enabling coresight devices to register or remove AMBA and platform drivers. Cc: Suzuki K Poulose Cc: Mike Leach Cc: James Clark Cc: Leo Yan Cc: Alexander Shishkin Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: coresight@lists.linaro.org Signed-off-by: Anshuman Khandual --- drivers/hwtracing/coresight/coresight-core.c | 29 ++++++++++++++++++++ include/linux/coresight.h | 7 +++++ 2 files changed, 36 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index d7f0e231feb9..4e897cc5da81 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1836,6 +1836,35 @@ static void __exit coresight_exit(void) module_init(coresight_init); module_exit(coresight_exit); +int coresight_init_driver(const char *drv, struct amba_driver *amba_drv, + struct platform_driver *pdev_drv) +{ + int ret; + + ret = amba_driver_register(amba_drv); + if (ret) { + pr_err("%s: error registering AMBA driver\n", drv); + return ret; + } + + ret = platform_driver_register(pdev_drv); + if (!ret) + return 0; + + pr_err("%s: error registering platform driver\n", drv); + amba_driver_unregister(amba_drv); + return ret; +} +EXPORT_SYMBOL_GPL(coresight_init_driver); + +void coresight_remove_driver(struct amba_driver *amba_drv, + struct platform_driver *pdev_drv) +{ + amba_driver_unregister(amba_drv); + platform_driver_unregister(pdev_drv); +} +EXPORT_SYMBOL_GPL(coresight_remove_driver); + MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Pratik Patel "); MODULE_AUTHOR("Mathieu Poirier "); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index a4cb7dd6ca23..7e1646d4863c 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -12,6 +12,8 @@ #include #include #include +#include +#include /* Peripheral id registers (0xFD0-0xFEC) */ #define CORESIGHT_PERIPHIDR4 0xfd0 @@ -598,6 +600,11 @@ void coresight_relaxed_write64(struct coresight_device *csdev, u64 val, u32 offset); void coresight_write64(struct coresight_device *csdev, u64 val, u32 offset); +int coresight_init_driver(const char *drv, struct amba_driver *amba_drv, + struct platform_driver *pdev_drv); + +void coresight_remove_driver(struct amba_driver *amba_drv, + struct platform_driver *pdev_drv); #else static inline struct coresight_device * coresight_register(struct coresight_desc *desc) { return NULL; }