From patchwork Tue Feb 20 19:21:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jolly Shah X-Patchwork-Id: 10230761 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 8D13E601E7 for ; Tue, 20 Feb 2018 19:22:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BAAC283C5 for ; Tue, 20 Feb 2018 19:22:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FCFF2877C; Tue, 20 Feb 2018 19:22:34 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 801F9283C5 for ; Tue, 20 Feb 2018 19:22:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zY/mfbzCrq+fXt9ATx1BdG3IsC1MCqIGQcd2qbgMBsA=; b=SBMjdi08jKRXjB zVmUW0k16A0WgRwZ622SkGuxQMxcqdhP99LFVuUeb/XudIY8kCN8qB6t6zgB4YS58xtkJr2X+pvum H6XEixhCRynDgeRihUhdHing3sHEk1f6a3IKE8/4hyGTEvRdXefI2AP4nyIkAPh1WfYlIxKfH90Yb a5p+pfaZMlCgSWavokJou4SOjj1S3zRP6AlQkiyu1zt4yty1Ib7hEjk+XVsZbIGkZrGk1hAXFVZRq LD/fNpcdoiE9t4riVHWwMhWnWR0l4j+K7mFtER6O6eRAAduhwxRtDlV08BT2L66xZBFThHEPeMCl3 /0k4dFiPVCR6mXfEEIrA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eoDUY-0006zj-Qz; Tue, 20 Feb 2018 19:22:18 +0000 Received: from mail-by2nam01on0086.outbound.protection.outlook.com ([104.47.34.86] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eoDTr-0006ew-GT for linux-arm-kernel@lists.infradead.org; Tue, 20 Feb 2018 19:21:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=kwqYO7WmqzbLzfeGcsUKTZkFdzPsIMSncVS1RNe0Yg8=; b=3L+AJpHUyZo4Xh1ay4T5xwjtAqBvDBj+JA68FXjU1IQSSVe7/rwDnj8x3sTriwEj3CU2Fwaqf6bE0re5jQQ40UeTfIH0W4GMMk03vzmYHrho558d6jsOZt5OTC2hzBpsJ0+Ww64DMYpc6qNC94sKf7YpPhwRKRCFwOcw0D6oSAA= Received: from BY2PR02CA0101.namprd02.prod.outlook.com (10.163.44.155) by BN6PR02MB3379.namprd02.prod.outlook.com (10.161.153.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.506.18; Tue, 20 Feb 2018 19:21:21 +0000 Received: from SN1NAM02FT064.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::206) by BY2PR02CA0101.outlook.office365.com (2a01:111:e400:5261::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.506.18 via Frontend Transport; Tue, 20 Feb 2018 19:21:20 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by SN1NAM02FT064.mail.protection.outlook.com (10.152.72.143) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.506.19 via Frontend Transport; Tue, 20 Feb 2018 19:21:19 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:45488 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1eoDTb-0003rb-BP; Tue, 20 Feb 2018 11:21:19 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1eoDTb-000269-34; Tue, 20 Feb 2018 11:21:19 -0800 Received: from [172.19.2.91] (helo=xsjjollys50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1eoDTY-000252-I4; Tue, 20 Feb 2018 11:21:16 -0800 From: Jolly Shah To: , , , , , , , , , , Subject: [PATCH v5 3/4] drivers: firmware: xilinx: Add sysfs interface Date: Tue, 20 Feb 2018 11:21:06 -0800 Message-ID: <1519154467-2896-4-git-send-email-jollys@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519154467-2896-1-git-send-email-jollys@xilinx.com> References: <1519154467-2896-1-git-send-email-jollys@xilinx.com> X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(39860400002)(39380400002)(2980300002)(438002)(50944005)(189003)(199004)(5660300001)(106466001)(2906002)(305945005)(7416002)(107886003)(9786002)(36386004)(8676002)(8936002)(81156014)(81166006)(186003)(478600001)(50226002)(63266004)(72206003)(59450400001)(47776003)(77096007)(26005)(336011)(2201001)(48376002)(76176011)(36756003)(50466002)(6666003)(51416003)(4326008)(7696005)(356003)(39060400002)(316002)(54906003)(16586007)(2950100002)(106002)(110136005)(921003)(107986001)(1121003)(5001870100001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR02MB3379; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT064; 1:4Xik4ZSD40dpX3civU5UUtb3C85epWRg8E4q2k5LRkxy1NNF1ZH6a4DTz5NIrOTz5zuK3+GD00OKrX5HGqYPiXrtz5btEiB+JPqXYqPxO81FAnH281b0yvf2NiuY6Vrh MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee54a964-f476-4095-9485-08d578971f61 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:BN6PR02MB3379; X-Microsoft-Exchange-Diagnostics: 1; BN6PR02MB3379; 3:h5+Rq18txh09+zQOe2eKuB5yuMYjXHbZXnE4+H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cKhVmz15HBnekaCDzkhPp5zeCuoz7zxYfjzMO7hi1sbjOGxoZI+uXq4fXyycd9D9pIZ3bNqGmLyzikFM+mj/i7XlovniQSlNLQX5KYuWIiguuYQ4fHUg9Yv21S+qa22HJkPQ5u39KoNO0chFCCmmoWKNqOphwcvmBVKuGWSnJrQwj/ozAm9RPMrQi+OlmoXrEuNvLC33wc21MAL3y2CGsGe1WW4MGZqfuss7O+ydmRHAJxr20Z9GelX1e2rIO6r6x4eJO/gurnQ24Fu/bXJPyHso0nQG9SYYKKOa/P6RGbvR9Orkxmod+xkp1bXQfdKuZ0Q7y+haOzn0AWxyAJg3N2MZlXAgS4bH9A9m4oacwAt0So9Hs5MfXurfuuPSjZiSWd2T0uUFTv1XPoa4WZPqUBsVIR9A5SPcSAq+s X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001058)(6040501)(2401047)(8121501046)(5005006)(3002001)(3231101)(944501161)(10201501046)(93006095)(93004095)(6055026)(6041288)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:BN6PR02MB3379; BCL:0; PCL:0; RULEID:; SRVR:BN6PR02MB3379; X-Microsoft-Exchange-Diagnostics: 1; BN6PR02MB3379; 4:3ym7+yr2ZPKLxVgJ1Z90eAiinEpgmasuQwQrgoS4CeqVumC8bXj41ZZOT7x78J2n1eEFcEp+6jBvWaFDlJhySr8GqkZeHIIhIIlX1aqRHMWZhcl8v3gHHeuhG4Z3dpedfjQWHURyY0bz4i86M205NjiTr7sgPbcgv2/3HnX/i4r48/ARUnSFCLy6WOE3KhUA+3OmxZiQsT0xTznxyuuiFULhagu/mKrFS03pehZGTP9x+QXcYQMEFIdSTMxkovh/A9nFY95GCBs8kh3hziCZzJGGEyUmZGKIJMGSl8CX6hB2g3mq0c5ir4bVUUf8GkuB X-Forefront-PRVS: 05891FB07F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR02MB3379; 23:bCc7jNXb2SCb4ABza23ywgUiZYsLCoIk/xsGrP50T?= =?us-ascii?Q?VccsExDQzo7W7d2NWYTkf6ixUzIAGDO44k0JQbj1nZJv2jjUYjN5emWD9V4K?= =?us-ascii?Q?br4oBjGiM7MFkROgBw4H65EWBZM5jcd+4Nf7RdzdEovwYkOCDVMLvDR6O9jD?= =?us-ascii?Q?o4u4nr5KPw+tGlcUsSBdLxl9BOo2/293utamZoH9yBqUsZsJhWzQ9TVS/m06?= =?us-ascii?Q?/j1MQSZLxQ4hCRGD2q54iF3FxyqCrxu9mKdr9iq2YviQcD8N3tGhj5yjmTQz?= =?us-ascii?Q?3i5is/cTIAHTgEgrr0UPRzNDiNShUiUIAKBtdo7dnF4B5OSQFwwrE9GUXASY?= =?us-ascii?Q?GyJzQm0GXOXDoY5r3It+pfufnC0C8lq2Gg9VxgbAgZ0oAF24AncBkaAMYVuh?= =?us-ascii?Q?B2sQyXZt9Dkel1l465Z55cQt+etqp68NVvjmQUxgWOoH4xMNu87CS1JFlEC/?= =?us-ascii?Q?a/fXNbTANqfdyi5XcjC0DkMfusWfSMXHIP89Gxb2rbM2snVd9+AJhaEqeeHr?= =?us-ascii?Q?EAIs9jo8ZjH+uX8njiy0Lp62CMropMe1NSEotsdqC6i7Df9WI6gekRguCqMS?= =?us-ascii?Q?QsiZhMampep7jP9HfE7DNJ5CMEIqUri6Jb/OefhSYotgePV6mSPEAgENryV5?= =?us-ascii?Q?5YYbOHPug1xt23DjoqxLT/Tz1KbxPNjLPBMb6l9pb4lzSWYe6K+9fqOpbVyj?= =?us-ascii?Q?yaIXPr9pm6eFG5Hkip0JXEJ8FoQU11GdLmj21nkW5P80T6LSHZy/d2RfibmG?= =?us-ascii?Q?zZuMAeaZO2ZXvRnWpns6XSNXsuL30rRPawrEuC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gw6vfReTguLceRZ5CPMUAg8F8fjghyZEWdPj11CWGSvrWcI5wufQX4gxh2VU/Ou8OE=; 24:jESSGOWW7VqR7MlY3gyN1krjXS8GQTilLC/HDgFI6TWDqyOod8Vk03EcrTp8hdV+pQn1en51wDK9DUmZleZL+QBzqagmMVZEvKHI+06awhs=; 7:AOckFFTYqeGMwr8PqX69ztZAPHDt5kgLQ7k/riCnp6VcQWj2XFdf8BaoIGfnextQYIIiQxZUz2Xv2jorSMCXDb7fE4M2eLTP0GRowws7kZaU6DJNWTrWzH183mIQLp4t3YWMB96ZlOZvPaIr3M+IRUkMdYaQ4V2L79O6f9qjTqVG8Nv7hu863AoT/NUNZWODY0LVcjvduKuvaqSYKok0OrsRYt+Xib8x31xr2ezcW4omI6u8BAGCJ5txDur7t6yx SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2018 19:21:19.8739 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee54a964-f476-4095-9485-08d578971f61 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR02MB3379 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180220_112135_570102_073ADC33 X-CRM114-Status: GOOD ( 19.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, rajanv@xilinx.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jolly Shah Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add Firmware-ggs sysfs interface which provides read/write interface to global storage registers. Signed-off-by: Jolly Shah Signed-off-by: Rajan Vaja --- .../ABI/stable/sysfs-driver-zynqmp-firmware | 50 ++++ drivers/firmware/xilinx/zynqmp/Makefile | 2 +- drivers/firmware/xilinx/zynqmp/firmware-ggs.c | 297 +++++++++++++++++++++ drivers/firmware/xilinx/zynqmp/firmware.c | 13 + include/linux/firmware/xilinx/zynqmp/firmware.h | 2 + 5 files changed, 363 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/stable/sysfs-driver-zynqmp-firmware create mode 100644 drivers/firmware/xilinx/zynqmp/firmware-ggs.c diff --git a/Documentation/ABI/stable/sysfs-driver-zynqmp-firmware b/Documentation/ABI/stable/sysfs-driver-zynqmp-firmware new file mode 100644 index 0000000..b04727a --- /dev/null +++ b/Documentation/ABI/stable/sysfs-driver-zynqmp-firmware @@ -0,0 +1,50 @@ +What: /sys/devices/platform/zynqmp-firmware/ggs* +Date: January 2018 +KernelVersion: 4.15.0 +Contact: "Jolly Shah" +Description: + Read/Write PMU global general storage register value, + GLOBAL_GEN_STORAGE{0:3}. + Global general storage register that can be used + by system to pass information between masters. + + The register is reset during system or power-on + resets. Three registers are used by the FSBL and + other Xilinx software products: GLOBAL_GEN_STORAGE{4:6}. + + Usage: + # cat /sys/.../zynqmp-firmware/ggs0 + # echo > /sys/.../zynqmp-firmware/ggs0 + + Example: + # cat /sys/.../zynqmp-firmware/ggs0 + # echo 0xFFFFFFFF 0x1234ABCD > /sys/.../zynqmp-firmware/ggs0 + +Users: Xilinx + +What: /sys/devices/platform/zynqmp-firmware/pggs* +Date: January 2018 +KernelVersion: 4.15.0 +Contact: "Jolly Shah" +Description: + Read/Write PMU persistent global general storage register + value, PERS_GLOB_GEN_STORAGE{0:3}. + Persistent global general storage register that + can be used by system to pass information between + masters. + + This register is only reset by the power-on reset + and maintains its value through a system reset. + Four registers are used by the FSBL and other Xilinx + software products: PERS_GLOB_GEN_STORAGE{4:7}. + Register is reset only by a POR reset. + + Usage: + # cat /sys/.../zynqmp-firmware/pggs0 + # echo > /sys/.../zynqmp-firmware/pggs0 + + Example: + # cat /sys/.../zynqmp-firmware/pggs0 + # echo 0xFFFFFFFF 0x1234ABCD > /sys/.../zynqmp-firmware/pggs0 + +Users: Xilinx diff --git a/drivers/firmware/xilinx/zynqmp/Makefile b/drivers/firmware/xilinx/zynqmp/Makefile index c3ec669..6629781 100644 --- a/drivers/firmware/xilinx/zynqmp/Makefile +++ b/drivers/firmware/xilinx/zynqmp/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ # Makefile for Xilinx firmwares -obj-$(CONFIG_ZYNQMP_FIRMWARE) += firmware.o +obj-$(CONFIG_ZYNQMP_FIRMWARE) += firmware.o firmware-ggs.o diff --git a/drivers/firmware/xilinx/zynqmp/firmware-ggs.c b/drivers/firmware/xilinx/zynqmp/firmware-ggs.c new file mode 100644 index 0000000..e08f6a6 --- /dev/null +++ b/drivers/firmware/xilinx/zynqmp/firmware-ggs.c @@ -0,0 +1,297 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Xilinx Zynq MPSoC Firmware layer + * + * Copyright (C) 2014-2018 Xilinx, Inc. + * + * Jolly Shah + * Rajan Vaja + */ + +#include +#include +#include +#include +#include +#include +#include + +static ssize_t read_register(char *buf, u32 ioctl_id, u32 reg) +{ + int ret; + u32 ret_payload[PAYLOAD_ARG_CNT]; + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); + + if (!eemi_ops || !eemi_ops->ioctl) + return -EFAULT; + + ret = eemi_ops->ioctl(0, ioctl_id, reg, 0, ret_payload); + if (ret) + return ret; + + return sprintf(buf, "0x%x\n", ret_payload[1]); +} + +static ssize_t write_register(const char *buf, size_t count, u32 read_ioctl, + u32 write_ioctl, u32 reg) +{ + char *kern_buff, *inbuf, *tok; + long mask, value; + int ret; + u32 ret_payload[PAYLOAD_ARG_CNT]; + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); + + if (!eemi_ops || !eemi_ops->ioctl) + return -EFAULT; + + kern_buff = kzalloc(count, GFP_KERNEL); + if (!kern_buff) + return -ENOMEM; + + ret = strlcpy(kern_buff, buf, count); + if (ret < 0) { + ret = -EFAULT; + goto err; + } + + inbuf = kern_buff; + + /* Read the write mask */ + tok = strsep(&inbuf, " "); + if (!tok) { + ret = -EFAULT; + goto err; + } + + ret = kstrtol(tok, 16, &mask); + if (ret) { + ret = -EFAULT; + goto err; + } + + /* Read the write value */ + tok = strsep(&inbuf, " "); + if (!tok) { + ret = -EFAULT; + goto err; + } + + ret = kstrtol(tok, 16, &value); + if (ret) { + ret = -EFAULT; + goto err; + } + + ret = eemi_ops->ioctl(0, read_ioctl, reg, 0, ret_payload); + if (ret) { + ret = -EFAULT; + goto err; + } + ret_payload[1] &= ~mask; + value &= mask; + value |= ret_payload[1]; + + ret = eemi_ops->ioctl(0, write_ioctl, reg, value, NULL); + if (ret) + ret = -EFAULT; + +err: + kfree(kern_buff); + if (ret) + return ret; + + return count; +} + +/** + * ggs_show - Show global general storage (ggs) sysfs attribute + * @kobj: Kobject structure + * @attr: Kobject attribute structure + * @buf: Requested available shutdown_scope attributes string + * @reg: Register number + * + * Return:Number of bytes printed into the buffer. + * + * Helper function for viewing a ggs register value. + * + * User-space interface for viewing the content of the ggs0 register. + * cat /sys/firmware/zynqmp/ggs0 + */ +static ssize_t ggs_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf, + u32 reg) +{ + return read_register(buf, IOCTL_READ_GGS, reg); +} + +/** + * ggs_store - Store global general storage (ggs) sysfs attribute + * @kobj: Kobject structure + * @attr: Kobject attribute structure + * @buf: User entered shutdown_scope attribute string + * @count: Size of buf + * @reg: Register number + * + * Return: count argument if request succeeds, the corresponding + * error code otherwise + * + * Helper function for storing a ggs register value. + * + * For example, the user-space interface for storing a value to the + * ggs0 register: + * echo 0xFFFFFFFF 0x1234ABCD > /sys/firmware/zynqmp/ggs0 + */ +static ssize_t ggs_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, + size_t count, + u32 reg) +{ + if (!kobj || !attr || !buf || !count || reg >= GSS_NUM_REGS) + return -EINVAL; + + return write_register(buf, count, IOCTL_READ_GGS, IOCTL_WRITE_GGS, reg); +} + +/* GGS register show functions */ +#define GGS0_SHOW(N) \ + ssize_t ggs##N##_show(struct kobject *kobj, \ + struct kobj_attribute *attr, \ + char *buf) \ + { \ + return ggs_show(kobj, attr, buf, N); \ + } + +static GGS0_SHOW(0); +static GGS0_SHOW(1); +static GGS0_SHOW(2); +static GGS0_SHOW(3); + +/* GGS register store function */ +#define GGS0_STORE(N) \ + ssize_t ggs##N##_store(struct kobject *kobj, \ + struct kobj_attribute *attr, \ + const char *buf, \ + size_t count) \ + { \ + return ggs_store(kobj, attr, buf, count, N); \ + } + +static GGS0_STORE(0); +static GGS0_STORE(1); +static GGS0_STORE(2); +static GGS0_STORE(3); + +/** + * pggs_show - Show persistent global general storage (pggs) sysfs attribute + * @kobj: Kobject structure + * @attr: Kobject attribute structure + * @buf: Requested available shutdown_scope attributes string + * @reg: Register number + * + * Return:Number of bytes printed into the buffer. + * + * Helper function for viewing a pggs register value. + */ +static ssize_t pggs_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf, + u32 reg) +{ + return read_register(buf, IOCTL_READ_PGGS, reg); +} + +/** + * pggs_store - Store persistent global general storage (pggs) sysfs attribute + * @kobj: Kobject structure + * @attr: Kobject attribute structure + * @buf: User entered shutdown_scope attribute string + * @count: Size of buf + * @reg: Register number + * + * Return: count argument if request succeeds, the corresponding + * error code otherwise + * + * Helper function for storing a pggs register value. + */ +static ssize_t pggs_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, + size_t count, + u32 reg) +{ + return write_register(buf, count, IOCTL_READ_PGGS, + IOCTL_WRITE_PGGS, reg); +} + +#define PGGS0_SHOW(N) \ + ssize_t pggs##N##_show(struct kobject *kobj, \ + struct kobj_attribute *attr, \ + char *buf) \ + { \ + return pggs_show(kobj, attr, buf, N); \ + } + +#define PGGS0_STORE(N) \ + ssize_t pggs##N##_store(struct kobject *kobj, \ + struct kobj_attribute *attr, \ + const char *buf, \ + size_t count) \ + { \ + return pggs_store(kobj, attr, buf, count, N); \ + } + +/* PGGS register show functions */ +static PGGS0_SHOW(0); +static PGGS0_SHOW(1); +static PGGS0_SHOW(2); +static PGGS0_SHOW(3); + +/* PGGS register store functions */ +static PGGS0_STORE(0); +static PGGS0_STORE(1); +static PGGS0_STORE(2); +static PGGS0_STORE(3); + +/* GGS register attributes */ +static struct kobj_attribute zynqmp_attr_ggs0 = __ATTR_RW(ggs0); +static struct kobj_attribute zynqmp_attr_ggs1 = __ATTR_RW(ggs1); +static struct kobj_attribute zynqmp_attr_ggs2 = __ATTR_RW(ggs2); +static struct kobj_attribute zynqmp_attr_ggs3 = __ATTR_RW(ggs3); + +/* PGGS register attributes */ +static struct kobj_attribute zynqmp_attr_pggs0 = __ATTR_RW(pggs0); +static struct kobj_attribute zynqmp_attr_pggs1 = __ATTR_RW(pggs1); +static struct kobj_attribute zynqmp_attr_pggs2 = __ATTR_RW(pggs2); +static struct kobj_attribute zynqmp_attr_pggs3 = __ATTR_RW(pggs3); + +static struct attribute *attrs[] = { + &zynqmp_attr_ggs0.attr, + &zynqmp_attr_ggs1.attr, + &zynqmp_attr_ggs2.attr, + &zynqmp_attr_ggs3.attr, + &zynqmp_attr_pggs0.attr, + &zynqmp_attr_pggs1.attr, + &zynqmp_attr_pggs2.attr, + &zynqmp_attr_pggs3.attr, + NULL, +}; + +static const struct attribute_group attr_group = { + .attrs = attrs, + NULL, +}; + +int zynqmp_pm_ggs_init(void) +{ + struct kobject *zynqmp_kobj; + + zynqmp_kobj = kobject_create_and_add("zynqmp", firmware_kobj); + if (!zynqmp_kobj) { + pr_err("zynqmp: Firmware kobj add failed.\n"); + return -ENOMEM; + } + + return sysfs_create_group(zynqmp_kobj, &attr_group); +} diff --git a/drivers/firmware/xilinx/zynqmp/firmware.c b/drivers/firmware/xilinx/zynqmp/firmware.c index 6979f4b..02266d9 100644 --- a/drivers/firmware/xilinx/zynqmp/firmware.c +++ b/drivers/firmware/xilinx/zynqmp/firmware.c @@ -1049,3 +1049,16 @@ static int __init zynqmp_plat_init(void) return ret; } early_initcall(zynqmp_plat_init); + +static int zynqmp_firmware_init(void) +{ + int ret; + + ret = zynqmp_pm_ggs_init(); + if (ret) + pr_err("%s() GGS init fail with error %d\n", + __func__, ret); + + return ret; +} +device_initcall(zynqmp_firmware_init); diff --git a/include/linux/firmware/xilinx/zynqmp/firmware.h b/include/linux/firmware/xilinx/zynqmp/firmware.h index 859d809..94b5a43 100644 --- a/include/linux/firmware/xilinx/zynqmp/firmware.h +++ b/include/linux/firmware/xilinx/zynqmp/firmware.h @@ -578,6 +578,8 @@ struct zynqmp_eemi_ops { int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 *ret_payload); +int zynqmp_pm_ggs_init(void); + #if IS_REACHABLE(CONFIG_ARCH_ZYNQMP) const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void); #else