From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=203.18.50.4; helo=nat-hk.nvidia.com; envelope-from=jbrasen@nvidia.com; receiver=edk2-devel@lists.01.org Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 87B5921A07A82 for ; Wed, 5 Dec 2018 16:37:23 -0800 (PST) Received: from hkpgpgate101.nvidia.com (Not Verified[10.18.92.77]) by nat-hk.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 06 Dec 2018 08:37:22 +0800 Received: from HKMAIL104.nvidia.com ([10.18.16.13]) by hkpgpgate101.nvidia.com (PGP Universal service); Wed, 05 Dec 2018 16:37:21 -0800 X-PGP-Universal: processed; by hkpgpgate101.nvidia.com on Wed, 05 Dec 2018 16:37:21 -0800 Received: from DRBGMAIL101.nvidia.com (10.18.16.20) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 6 Dec 2018 00:37:19 +0000 Received: from HKMAIL102.nvidia.com (10.18.16.11) by DRBGMAIL101.nvidia.com (10.18.16.20) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 6 Dec 2018 00:37:18 +0000 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (104.47.32.58) by HKMAIL102.nvidia.com (10.18.16.11) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 6 Dec 2018 00:37:18 +0000 Received: from DM5PR12MB2439.namprd12.prod.outlook.com (52.132.141.32) by DM5PR12MB1324.namprd12.prod.outlook.com (10.168.238.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.17; Thu, 6 Dec 2018 00:37:15 +0000 Received: from DM5PR12MB2439.namprd12.prod.outlook.com ([fe80::b466:38b9:472b:54d8]) by DM5PR12MB2439.namprd12.prod.outlook.com ([fe80::b466:38b9:472b:54d8%6]) with mapi id 15.20.1382.023; Thu, 6 Dec 2018 00:37:15 +0000 From: Jeff Brasen To: "edk2-devel@lists.01.org" Thread-Topic: [PATCH v2] ArmPkg/ArmScmiDxe: Add clock enable function Thread-Index: AQHUh1oZxy8arM6ru0amFYDIUKOd+6Vw6Nq8 Date: Thu, 6 Dec 2018 00:37:15 +0000 Message-ID: References: <51b70aa08f34e31ac4e19bebdc96d5298691e9ba.1543437347.git.jbrasen@nvidia.com> In-Reply-To: <51b70aa08f34e31ac4e19bebdc96d5298691e9ba.1543437347.git.jbrasen@nvidia.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=jbrasen@nvidia.com; x-originating-ip: [216.228.112.22] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR12MB1324; 6:DGxIKfiKcFtvRjiKM/V3AW21AZ6Nw19x61aI4tRtaw6W4XX/i6TKKMFqOYwNGyRZ2A+4WxYC47XTWkXq5+/Vg3b+W94PGTsLvlSe6mRFpysv1uOUkorbIdnnMrsUpNv6d82uty+Q0kyOdpH4WDyE7zHnA5kp4AqH8opoAslMK/iMIurs5g09tmE6bc0uC/erAR5j9LstOxEjvm4+sjr7xAPpdZcIjQOcib3h3hLYndnVCvw+qPJRxi5Zw7ig5s8RMqAW8INEuIFrAvbSRr7xVNzdbOiE4MGuhQiKbNBkGfinUB8jll4GpIKUIH05TZXmeq1Svrd4FCy0XzNqBkD+WT8AZ7IpiIfRM5WGAIFdkIrzVDrr+98gO93yhICqvyZYqaXahepLPzXm2/pSWxpxCYtp+2SdzvpjJxKyDVb+Pzj8krA8AdT1L3Y9AR58R5PbmIe2xK+16hd94Mh5vGApag==; 5:EJFRXuxuwEOBsJoutV7JruhRX1fexqKgj9iQEh0QkWDIrjF9IeX7SzDzJX0rKTjEREf7O48buRhCKVSDcSF+GNOYDCuQJMF4Tkj0GLc2J4wZLYXKB1oXZu6sUApjgp8xPeVAlGllD8T6YATFLT2+Un4zAy0H+3lTigeVEqiPpW8=; 7:x/qC0zdF5CyVtL05jVUOOCghLJWnGib+jjIChmhpPe5gJ2dgmy+uqrzdSN6P+uvFiV1+l6OWr4o6q0DTuBIQaqVvD18k/SIX5msvTt+XZT2IC+mxuFHQ5fHdSbhXUGgTTBI1xqcYt+kc6KIrsVyRmw== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: e1f86846-c503-4d85-4e06-08d65b12f8a5 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DM5PR12MB1324; x-ms-traffictypediagnostic: DM5PR12MB1324: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231455)(999002)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DM5PR12MB1324; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1324; x-forefront-prvs: 087894CD3C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(346002)(376002)(39860400002)(366004)(396003)(199004)(189003)(6916009)(229853002)(6606003)(14454004)(6436002)(478600001)(11346002)(476003)(54906003)(316002)(4326008)(6246003)(26005)(14444005)(5640700003)(19627405001)(19627235002)(186003)(2501003)(55016002)(256004)(33656002)(54896002)(9686003)(53936002)(81166006)(2351001)(102836004)(8936002)(105586002)(81156014)(8676002)(5660300001)(106356001)(6506007)(97736004)(53546011)(74316002)(7736002)(446003)(66066001)(25786009)(2906002)(6116002)(3846002)(68736007)(7696005)(71200400001)(71190400001)(99286004)(575784001)(76176011)(486006)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1324; H:DM5PR12MB2439.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: GMSLbpRm/n1KcsWFwdNp1nAM0tZvSV/REJL7M9W1HNW9R2cnrfU56oB9OwMVnVPi/ZHlPc7JD4tIbHrJakbf+pJ5gh++TaPio9uYqTWhfRVIeRwq6Zd41PWvqCJxMbdw+Tlebe5WUdCNtcjSRcyfKumXLOaPi9GsqooPE9crG/3iEllLmiIC8Xx8IzZ6dZxDuyLAv/LBCr0C07uMJk+fSCiwxuYsxUwWmGAEtKxC14xbEmoaoy3KB2oSvgH5D5qwkqS5Uws9o/ub4uwTpRAn78HJBtk1/HvZXfa+X/csLDKJsuMwzlXQ7lAwBY88sKe97QPXkT1bn/1KGkAbGOfHdmTxUXvcy0wRrh0AiMZeN4k= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e1f86846-c503-4d85-4e06-08d65b12f8a5 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Dec 2018 00:37:15.7525 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1324 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1544056643; bh=BZM5NvE01K1+yq5FIbRuCN0VXsUY/CEyToC4QhnvxmU=; h=X-PGP-Universal:From:To:CC:Subject:Thread-Topic:Thread-Index:Date: Message-ID:References:In-Reply-To:Accept-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:authentication-results:x-originating-ip: x-ms-publictraffictype:x-microsoft-exchange-diagnostics: x-ms-exchange-antispam-srfa-diagnostics: x-ms-office365-filtering-correlation-id:x-microsoft-antispam: x-ms-traffictypediagnostic:x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck:x-exchange-antispam-report-cfa-test: x-forefront-prvs:x-forefront-antispam-report:received-spf: x-microsoft-antispam-message-info:spamdiagnosticoutput: spamdiagnosticmetadata:MIME-Version: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg: Content-Language:Content-Type; b=THHtSLTryPzxJtnW1yjGLjn7xLJbNq8M8XcZuw/8/k92q3mq1MCryusA2PkULODz1 VS6SoYx7/bC2i0+mzWRIE0TbXypcvHMdXMoXus/pbsEAl+ouJU8GToRAkI39k8Ysu8 /WeEVseI70odtNqVuOsrjwo7+mcj+jWEcIjTfft13jqqeGgwEG474YJ+MLfn3rBcvm pzZtENNATHuwCm+2yVNqoLVujnv/5DHyI2Blbde/81FYfuB3zFxEQrlTF7RI8Febe3 2Oms8OCNeZYqePS3l/O40KyfQnpYs5anAiMBFBwDV4zF0G0p/22Iyup0yGgjqqQoUx oCxMrNqBp0Izw== X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [PATCH v2] ArmPkg/ArmScmiDxe: Add clock enable function X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2018 00:37:24 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Leif/Ard, =20 Any comments on this v2 patch for this? Thanks, Jeff ________________________________ From: Jeff Brasen Sent: Wednesday, November 28, 2018 1:36:16 PM To: edk2-devel@lists.01.org Cc: Jeff Brasen; Ard Biesheuvel; Leif Lindholm; Grish Pathak Subject: [PATCH v2] ArmPkg/ArmScmiDxe: Add clock enable function Add function to allow enabling and disabling of the clock using the SCMI interface. Add gArmScmiClock2ProtocolGuid to distinguish platforms that support new API from those that just have the older protocol. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jeff Brasen Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Grish Pathak --- =20ArmPkg/ArmPkg.dec | 1 + =20.../ArmScmiDxe/ArmScmiClockProtocolPrivate.h | 7 +++ =20ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf | 1 + =20ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 52 ++++++++++++++= +++++++- =20ArmPkg/Include/Protocol/ArmScmiClockProtocol.h | 27 +++++++++++ =205 files changed, 87 insertions(+), 1 deletion(-) diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index d99eb67..2f5e5b3 100644 --- a/ArmPkg/ArmPkg.dec +++ b/ArmPkg/ArmPkg.dec @@ -59,6 +59,7 @@ =20 ## Arm System Control and Management Interface(SCMI) Clock managemen= t protocol =20 ## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h =20 gArmScmiClockProtocolGuid =3D { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9, = 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } } + gArmScmiClock2ProtocolGuid =3D { 0xb8d8caf2, 0x9e94, 0x462c, { 0xa8, 0= x34, 0x6c, 0x99, 0xfc, 0x05, 0xef, 0xcf } } =20 ## Arm System Control and Management Interface(SCMI) Clock managemen= t protocol =20 ## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h b/Ar= mPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h index 0d1ec6f..c135bac 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h @@ -59,6 +59,13 @@ typedef struct { =20 CLOCK_RATE_DWORD Rate; =20} CLOCK_RATE_SET_ATTRIBUTES; + +// Message parameters for CLOCK_CONFIG_SET command. +typedef struct { + UINT32 ClockId; + UINT32 Attributes; +} CLOCK_CONFIG_SET_ATTRIBUTES; + =20// if ClockAttr Bit[0] is set then clock device is enabled. =20#define CLOCK_ENABLE_MASK 0x1 =20#define CLOCK_ENABLED(ClockAttr) ((ClockAttr & CLOCK_ENABLE_MASK) =3D= =3D 1) diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf b/ArmPkg/Drivers/Ar= mScmiDxe/ArmScmiDxe.inf index 05ce9c0..9b29b9f 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf @@ -46,6 +46,7 @@ =20[Protocols] =20 gArmScmiBaseProtocolGuid =20 gArmScmiClockProtocolGuid + gArmScmiClock2ProtocolGuid =20 gArmScmiPerformanceProtocolGuid =20[Depex] diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c b/ArmPkg/Drive= rs/ArmScmiDxe/ScmiClockProtocol.c index 64d2afa..27b53d3 100644 --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c @@ -388,6 +388,53 @@ ClockRateSet ( =20 return Status; =20} +/** Enable/Disable specified clock. + + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + @param[in] Enable TRUE to enable, FALSE to disable. + + @retval EFI_SUCCESS Clock enable/disable successful. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +STATIC +EFI_STATUS +ClockEnable ( + IN SCMI_CLOCK2_PROTOCOL *This, + IN UINT32 ClockId, + IN BOOLEAN Enable + ) +{ + EFI_STATUS Status; + CLOCK_CONFIG_SET_ATTRIBUTES *ClockConfigSetAttributes; + SCMI_COMMAND Cmd; + UINT32 PayloadLength; + + Status =3D ScmiCommandGetPayload ((UINT32**)&ClockConfigSetAttributes)= ; + if (EFI_ERROR (Status)) { + return Status; + } + + // Fill arguments for clock protocol command. + ClockConfigSetAttributes->ClockId =3D ClockId; + ClockConfigSetAttributes->Attributes =3D Enable ? BIT0 : 0; + + Cmd.ProtocolId =3D SCMI_PROTOCOL_ID_CLOCK; + Cmd.MessageId =3D SCMI_MESSAGE_ID_CLOCK_CONFIG_SET; + + PayloadLength =3D sizeof (CLOCK_CONFIG_SET_ATTRIBUTES); + + // Execute and wait for response on a SCMI channel. + Status =3D ScmiCommandExecute ( + &Cmd, + &PayloadLength, + NULL + ); + + return Status; +} + =20// Instance of the SCMI clock management protocol. =20STATIC CONST SCMI_CLOCK_PROTOCOL ScmiClockProtocol =3D { =20 ClockGetVersion, @@ -395,7 +442,8 @@ STATIC CONST SCMI_CLOCK_PROTOCOL ScmiClockProtocol =3D= =20{ =20 ClockGetClockAttributes, =20 ClockDescribeRates, =20 ClockRateGet, - ClockRateSet + ClockRateSet, + ClockEnable =20 }; =20/** Initialize clock management protocol and install protocol on a giv= en handle. @@ -413,6 +461,8 @@ ScmiClockProtocolInit ( =20 Handle, =20 &gArmScmiClockProtocolGuid, =20 &ScmiClockProtocol, + &gArmScmiClock2ProtocolGuid, + &ScmiClockProtocol, =20 NULL =20 ); =20} diff --git a/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h b/ArmPkg/Incl= ude/Protocol/ArmScmiClockProtocol.h index 3db26cb..28d3d59 100644 --- a/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h +++ b/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h @@ -24,7 +24,12 @@ =20 0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e= , 0xaa} \ =20 } +#define ARM_SCMI_CLOCK2_PROTOCOL_GUID { \ + 0xb8d8caf2, 0x9e94, 0x462c, { 0xa8, 0x34, 0x6c, 0x99, 0xfc, 0x05, 0xef= , 0xcf } \ + } + =20extern EFI_GUID gArmScmiClockProtocolGuid; +extern EFI_GUID gArmScmiClock2ProtocolGuid; =20// Message Type for clock management protocol. =20typedef enum { @@ -74,6 +79,7 @@ typedef struct { =20#pragma pack() =20typedef struct _SCMI_CLOCK_PROTOCOL SCMI_CLOCK_PROTOCOL; +typedef SCMI_CLOCK_PROTOCOL SCMI_CLOCK2_PROTOCOL; =20// Protocol Interface functions. @@ -205,6 +211,25 @@ EFI_STATUS =20 IN UINT64 Rate =20 ); +/** Enable/Disable specified clock. + Function is only available under gArmScmiClock2ProtocolGuid + + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + @param[in] Enable TRUE to enable, FALSE to disable. + + @retval EFI_SUCCESS Clock enable/disable successful. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK_ENABLE) ( + IN SCMI_CLOCK2_PROTOCOL *This, + IN UINT32 ClockId, + IN BOOLEAN Enable + ); + =20typedef struct _SCMI_CLOCK_PROTOCOL { =20 SCMI_CLOCK_GET_VERSION GetVersion; =20 SCMI_CLOCK_GET_TOTAL_CLOCKS GetTotalClocks; @@ -212,6 +237,8 @@ typedef struct _SCMI_CLOCK_PROTOCOL { =20 SCMI_CLOCK_DESCRIBE_RATES DescribeRates; =20 SCMI_CLOCK_RATE_GET RateGet; =20 SCMI_CLOCK_RATE_SET RateSet; + //Only available under gArmScmiClock2ProtocolGuid + SCMI_CLOCK_ENABLE Enable; =20} SCMI_CLOCK_PROTOCOL; =20#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */ -- 2.7.4 -------------------------------------------------------------------------= ---------- This email message is for the sole use of the intended recipient(s) and m= ay contain confidential information. Any unauthorized review, use, disclosure or di= stribution is prohibited. If you are not the intended recipient, please contact the= =20sender by reply email and destroy all copies of the original message. -------------------------------------------------------------------------= ----------