From patchwork Tue Dec 12 10:07:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomer Maimon X-Patchwork-Id: 754688 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nuvoton.onmicrosoft.com header.i=@nuvoton.onmicrosoft.com header.b="CBcSRLqJ" Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01rlnn2044.outbound.protection.outlook.com [40.95.54.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2BA8A6; Tue, 12 Dec 2023 02:07:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ciQQQP42QLFHON8zbqiecCmGzCN2qldiDqlmxcbEjWjWsjuOQUdOiHWhk8tVmZvxBvtBLnU7jQFh7n7yqmD4Yq+FjHvmSzCiPx+OnIf4kSZ/5bM1A4yS73S7DL8bIWGyzrPjqy8xDNtJT2q5ejw/801Hv7QMJhr0WKAEDLW7AvzeCIPsPy49lyyz9Fzh6vHiOUBv0jcYKwDEcwgKIBwzf3HW3tD3xolYOO93jHcC3wOgp/whx/urlCvrD2YwiQBcC5G7mGGGgzRbcnosI4eeTS2baGJHig9czayraf+k6kHR6ThyQCVt+gDfjt0qdE7xoVc8iCT5sqtOF2puvNzfjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ALUjWsX9FgdHbt4Zlk1z0xogMsk2bhjqaB1eDM0h8bQ=; b=czQTKuf9BOHZu1MKVW5qFSknRmm9idf6ulcXSizY+q4wrDGmfjtS8dChxgouPXp7cbnkLz4w3bZ1oB99LIY4XX+RAOXBLXaYUvFkmsuWCIlf+wWGHoTtuB9UJDd3D9RzKNEEqFKwUp6Ox6ykt/LJ0uCAHurEqtrq4DwIGS9fVnE19OpRvCL1GI1afC3asLl0RWVTJdfqq2Vri7yT1KcrNYp/QMslgVUEyBjOx6Iht292fi+KsSM2SYygc4w4gAP/VLLAnrwoBikLdysrokp9f+eAEWDGtiJhRO9mykLHsv8icR5jVnCZpJgt3g5vj6Uz7Yj0AjI8PALMtT0wxeviDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 211.75.126.7) smtp.rcpttodomain=arndb.de smtp.mailfrom=gmail.com; dmarc=fail (p=none sp=quarantine pct=100) action=none header.from=gmail.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuvoton.onmicrosoft.com; s=selector2-nuvoton-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ALUjWsX9FgdHbt4Zlk1z0xogMsk2bhjqaB1eDM0h8bQ=; b=CBcSRLqJms6q7qAiaDD10hXGYjE8U4FdI6s7nWY4I22q2xfk03BYeKga8DL7hu6JtU5eqkI7nzOrPsclcaa7N/0C81yla3kVfc1DhDlSfedO242JJZ9jd7isgNkbipRcoK+DyswjSI1FFJdZO1uIstFUOo0LixivhsFKyRfGnJo= Received: from SG2PR04CA0212.apcprd04.prod.outlook.com (2603:1096:4:187::8) by SI2PR03MB5969.apcprd03.prod.outlook.com (2603:1096:4:146::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Tue, 12 Dec 2023 10:07:10 +0000 Received: from SG1PEPF000082E6.apcprd02.prod.outlook.com (2603:1096:4:187:cafe::4f) by SG2PR04CA0212.outlook.office365.com (2603:1096:4:187::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33 via Frontend Transport; Tue, 12 Dec 2023 10:07:10 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 211.75.126.7) smtp.mailfrom=gmail.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=gmail.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 211.75.126.7 as permitted sender) Received: from NTHCCAS01.nuvoton.com (211.75.126.7) by SG1PEPF000082E6.mail.protection.outlook.com (10.167.240.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.18 via Frontend Transport; Tue, 12 Dec 2023 10:07:09 +0000 Received: from NTHCCAS01.nuvoton.com (10.1.8.28) by NTHCCAS01.nuvoton.com (10.1.8.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 12 Dec 2023 18:07:08 +0800 Received: from taln58.nuvoton.co.il (10.191.1.178) by NTHCCAS01.nuvoton.com (10.1.8.28) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 12 Dec 2023 18:07:08 +0800 Received: from taln60.nuvoton.co.il (taln60 [10.191.1.180]) by taln58.nuvoton.co.il (Postfix) with ESMTP id 7E0965F5D9; Tue, 12 Dec 2023 12:07:07 +0200 (IST) From: Tomer Maimon To: , , , , , , , , , , , CC: , , , , Tomer Maimon Subject: [PATCH v2 1/3] dt-bindings: soc: nuvoton: Add NPCM BPC Date: Tue, 12 Dec 2023 12:07:01 +0200 Message-ID: <20231212100703.3374555-2-tmaimon77@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212100703.3374555-1-tmaimon77@gmail.com> References: <20231212100703.3374555-1-tmaimon77@gmail.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NotSetDelaration: True X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[211.75.126.7]; domain=NTHCCAS01.nuvoton.com X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG1PEPF000082E6:EE_|SI2PR03MB5969:EE_ X-MS-Office365-Filtering-Correlation-Id: f2eed293-7fbc-4df2-60d5-08dbfafa1a45 X-MS-Exchange-SenderADCheck: 2 X-MS-Exchange-AntiSpam-Relay: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0vRhsDngQrc75C9mf39qVLQRT1XKC6Erfv0ILSP7oL4/Fbuv592QbIMCOK4G3LOqESb7k2zNRH26cUDTpud6lIIJ+lRSNiGBQlUxajGnTvxT8kmXlL9Mq9QPrqxWIyfOZR5fsHcM6qDr/LPzZLWbNml26QLOT6wRnO1+aTP6pg+PwEzzrj6BKu3ADFuUOtLLzDRFSqRci8BSeqYwkJ4YUxXWLKMEYqHdHNekCY6C91JzDqURfj9VqsvrGCuF1zGC4pJLhH6ObI2aEIoROHM62n3UrNdx0c21WOCtghei2xGSEwqttsG2pmx2b4Z1RvxHRLQlkPtaSHjrmKy6+4gGsit32ksN0RhAG5V/QPx6qcwgggJGNJSevvljTp4+n2ZR56CZx+AZlDAKH+zQYeAexkz86Yh0enyHTHpJAyr8jfjp18gSL+OQIQdsUBHng+idJu2SWMEZqkF1YarANt2v0d72U9j9oHTJGzFBqbvsP0nk2Pef9Vbrj1SS3FFW1sDmE0i6wDH5h2tpPbEDcaK38dkleuro1eymCyczJD7iBaew1staqMhbc+tdb3rGEFhzVPLK4yKdaQF+DMzHWdOOpY5Wv7AJTzTPqq1xwDg6xaXbLvxt4+n7eCSAoixNjguHovJgWiVvGnWj0JTK+/gUC+wd6+uim2aBwGZhZDNFJYnZxeDhjUTLV7snTBjT8l2khG9sQbFCImx5MzB4uVml7CFG/Je4dUF9e8vn6JoelNiSnLF0wtPM7gWOM/WnTJiiQhf1KndoOOnMOmtP2dZ3skh/OhANgG48N62qukG25cTPiKWWwSEQzELKyS6TnZyaQJOE/dGJuc8DuYTIJh3+ew== X-Forefront-Antispam-Report: CIP:211.75.126.7; CTRY:TW; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:NTHCCAS01.nuvoton.com; PTR:211-75-126-7.hinet-ip.hinet.net; CAT:NONE; SFS:(13230031)(4636009)(136003)(396003)(346002)(39860400002)(376002)(230922051799003)(451199024)(82310400011)(64100799003)(48200799006)(61400799012)(46966006)(40470700004)(40460700003)(82202003)(26005)(336012)(6266002)(73392003)(2616005)(1076003)(47076005)(4326008)(8676002)(5660300002)(35950700001)(8936002)(41300700001)(7416002)(498600001)(2906002)(966005)(6666004)(110136005)(316002)(54906003)(70206006)(70586007)(55446002)(86362001)(36756003)(82740400003)(76482006)(356005)(81166007)(921008)(40480700001); DIR:OUT; SFP:1022; X-OriginatorOrg: nuvoton.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2023 10:07:09.1485 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2eed293-7fbc-4df2-60d5-08dbfafa1a45 X-MS-Exchange-CrossTenant-Id: a3f24931-d403-4b4a-94f1-7d83ac638e07 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a3f24931-d403-4b4a-94f1-7d83ac638e07; Ip=[211.75.126.7]; Helo=[NTHCCAS01.nuvoton.com] X-MS-Exchange-CrossTenant-AuthSource: SG1PEPF000082E6.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI2PR03MB5969 X-Spam-Level: ** Added device tree binding documentation for Nuvoton BMC NPCM BIOS Post Code (BPC). The NPCM BPC monitoring two configurable I/O addresses written by the host on the bus. Signed-off-by: Tomer Maimon --- .../soc/nuvoton/nuvoton,npcm-bpc.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml diff --git a/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file mode 100644 index 000000000000..30033cdac8f5 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/nuvoton/nuvoton,npcm-bpc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton BMC NPCM BIOS Post Code (bpc) controller + +maintainers: + - Tomer Maimon + +description: + Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O + addresses written by the host on the bus, the capture data stored in + 128-word FIFO. + + NPCM BPC supports capture double words, when using capture + double word only I/O address 1 is monitored. + +properties: + compatible: + enum: + - nuvoton,npcm750-bpc + - nuvoton,npcm845-bpc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + nuvoton,monitor-ports: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: + Contain monitor I/O addresses on the bus, at least one monitor I/O + address required. + + nuvoton,bpc-en-dwcapture: + description: + If present, Enable FIFO capture of the DWord address according to + one address setting. + type: boolean + +required: + - compatible + - reg + - interrupts + - nuvoton,monitor-ports + +additionalProperties: false + +examples: + - | + #include + #include + + bpc: bpc@f0007040 { + compatible = "nuvoton,npcm750-bpc"; + reg = <0xf0007040 0x20>; + interrupts = ; + nuvoton,monitor-ports = <0x80>; + }; +... From patchwork Tue Dec 12 10:07:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomer Maimon X-Patchwork-Id: 753218 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nuvoton.onmicrosoft.com header.i=@nuvoton.onmicrosoft.com header.b="N/0p4fG1" Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01rlnn2076.outbound.protection.outlook.com [40.95.54.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C338ECF; Tue, 12 Dec 2023 02:07:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IirS6SiPn2cgutrXOlMalC+9PlEnYt22pyDaps1iZke1kNdOUmb2//O5B5mD9s8nxgIbp7O+O/txT6SJf+ywn8qyTsdPNV98sGbw4bY4NYlpMT2kesQlcZpBqqK/H6ik/U+LLlR8D/O9V+8ihhFXc+DwW7dIHFuOw/zwRDDzYrM2hRySbpyW793PpgmeK6qU5M3btMcyQDmYTbrWnDGrd+8owFKcGFVst45RAAmGBToaOjUmKnP3dHPVJSVUcMMyob2FrM2xGyRMY8tWs7HtIQ6PakWdezEkG9oyxM8Cn7hHjYjTfXEjEABCGmUhLQ2id2522u2SHMAoMXHngmYPrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+i9VXHA17foOwtFxfhCvfV4OjRJRyDaaG7Oh+1HoFj4=; b=PjdjdNLcHV2UKjaSspMSjr728fUPKWcfGVBTOyg0vHd3Eh+/8tWXre0tE8gE6yGzAGE2+Fw2F7AfE/6Wan9yl80p5fH8omFUULVTxZSXacoI/fL5SJHUF515kUTbrLd/LnsBWfnV9my5ctqQX9K76YBWIVq6wwjyh1Y6OoP8ee/h094zOVzWZUmkSadgrw7tRiBV9AgruPr++no4D6F41kZUlpI+MpAXnDa3Ptw2VBiRYiDHsU82550V5ABPlmIXauiGA/hOmv/LCtC5H3DfeVzCs8PClHTA2h5YFYQs1RDtV0o5DeMnbZlGJZhNyCEgsOq3HzwArsW7RrNFecgvsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 175.98.123.7) smtp.rcpttodomain=arndb.de smtp.mailfrom=gmail.com; dmarc=fail (p=none sp=quarantine pct=100) action=none header.from=gmail.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuvoton.onmicrosoft.com; s=selector2-nuvoton-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+i9VXHA17foOwtFxfhCvfV4OjRJRyDaaG7Oh+1HoFj4=; b=N/0p4fG1lCLjoU3P/5QHjHCT5nrsMfa+BxGGm2p1gomI/sJ8u0fg9AngtvjO+baFxau8Ih0hgIhsSMjj9W4pULNluua5skAVz9xUNmqhnykygMG/ZnMFCcF9U3rF/wByJRuhGtd6Ikt7Xu98k9ey7788DDO0wXL07Hor/yt/BmA= Received: from KL1P15301CA0057.APCP153.PROD.OUTLOOK.COM (2603:1096:820:3d::19) by TYZPR03MB7637.apcprd03.prod.outlook.com (2603:1096:400:41f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.30; Tue, 12 Dec 2023 10:07:11 +0000 Received: from HK3PEPF0000021B.apcprd03.prod.outlook.com (2603:1096:820:3d:cafe::1d) by KL1P15301CA0057.outlook.office365.com (2603:1096:820:3d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.4 via Frontend Transport; Tue, 12 Dec 2023 10:07:10 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 175.98.123.7) smtp.mailfrom=gmail.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=gmail.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 175.98.123.7 as permitted sender) Received: from NTHCCAS04.nuvoton.com (175.98.123.7) by HK3PEPF0000021B.mail.protection.outlook.com (10.167.8.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.7091.26 via Frontend Transport; Tue, 12 Dec 2023 10:07:10 +0000 Received: from NTHCCAS01.nuvoton.com (10.1.8.28) by NTHCCAS04.nuvoton.com (10.1.8.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Tue, 12 Dec 2023 18:07:08 +0800 Received: from taln58.nuvoton.co.il (10.191.1.178) by NTHCCAS01.nuvoton.com (10.1.8.28) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 12 Dec 2023 18:07:08 +0800 Received: from taln60.nuvoton.co.il (taln60 [10.191.1.180]) by taln58.nuvoton.co.il (Postfix) with ESMTP id 1096D5F5B2; Tue, 12 Dec 2023 12:07:08 +0200 (IST) From: Tomer Maimon To: , , , , , , , , , , , CC: , , , , Tomer Maimon Subject: [PATCH v2 2/3] soc: nuvoton: add configuration menu Date: Tue, 12 Dec 2023 12:07:02 +0200 Message-ID: <20231212100703.3374555-3-tmaimon77@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212100703.3374555-1-tmaimon77@gmail.com> References: <20231212100703.3374555-1-tmaimon77@gmail.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NotSetDelaration: True X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HK3PEPF0000021B:EE_|TYZPR03MB7637:EE_ X-MS-Office365-Filtering-Correlation-Id: 76208ba8-d74d-46e7-c0f3-08dbfafa1b2c X-MS-Exchange-SenderADCheck: 2 X-MS-Exchange-AntiSpam-Relay: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u9g6g4GObf6HEAPTCUZ66Qjyj3IUttb4j+IN8B2p7dpYVS94tzcWiJ0SfJVV6ytgNZOIemuC1yjtcyesbFHOnHGM0x4VhbyuMSQP321BQ5u21rDNSYHdzOC0JugauwV0COKMfN1eGvjtd75Jz2yMWF0dvsk3q7ebDVTavgOB5RoREevyV0AJOloP6momeupkGghtEyIG/MNRqBjUBFhP+TpEl0fqcxUQUNG+Qdj616TbwxkBvR3kimN10ics198uq2ZcFucx3DsJUabEYcYHKv6WYIY0q9AgdNIi43PftosQQwZKNsDaQXEGg8edU4PNwqaE+uqEeahdMvzHojzX8jRDAi+JzegMeeqzLg9YAjLQHjrq6miJ2yfCe71jbpYu7rTKv9n9CWmF6E+uGzDOy27FZ4cNwnnrI8+XhEgx7YhKvHNznrUragxuZNVb5rLx7N9+r6BqjqORvEsR+Qnl2MM1XOAFwH30dKrk8GkTU4GU3RoynK2zDVoDxiyws/D9k9SxhvLkH8IG5y33wmqxqogAZ0spdBOKnug+SNErVJSGKzEPubsBmuU+gKqIoFnSHbQ5FpLAiNfhw82GlaUiH+06Lar8mz63t+wa8X8aiJcCHNxeSzjTKsDaPeNwW7Lg+0Jwej4B7CS8RBEvsRvXS4kxY6gGMxK776gj5sDRmi+ZNgvOuQdgOHznfW3AtFg710FtsxTcErgvIA2zl34UrJD52evOfIDkPtijjlb+omvWJPW+hiNCSLm8TGMlBesGGZv8YEzkVEliobr/tSBXrS8p25K4KjgixdhulIHwKxI9hM5XAkpQgI4WlN8kfXBt X-Forefront-Antispam-Report: CIP:175.98.123.7; CTRY:TW; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:NTHCCAS04.nuvoton.com; PTR:175-98-123-7.static.tfn.net.tw; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(230922051799003)(64100799003)(82310400011)(61400799012)(48200799006)(451199024)(40470700004)(46966006)(40460700003)(73392003)(6266002)(26005)(1076003)(336012)(2616005)(82202003)(6666004)(35950700001)(83380400001)(47076005)(5660300002)(7416002)(4326008)(2906002)(498600001)(76482006)(4744005)(41300700001)(8676002)(8936002)(70206006)(70586007)(316002)(110136005)(54906003)(82740400003)(55446002)(81166007)(36756003)(356005)(86362001)(921008)(40480700001); DIR:OUT; SFP:1022; X-OriginatorOrg: nuvoton.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2023 10:07:10.7273 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76208ba8-d74d-46e7-c0f3-08dbfafa1b2c X-MS-Exchange-CrossTenant-Id: a3f24931-d403-4b4a-94f1-7d83ac638e07 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a3f24931-d403-4b4a-94f1-7d83ac638e07; Ip=[175.98.123.7]; Helo=[NTHCCAS04.nuvoton.com] X-MS-Exchange-CrossTenant-AuthSource: HK3PEPF0000021B.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR03MB7637 X-Spam-Level: ** Add menu configuration to Nuvoton SoC drivers. Signed-off-by: Tomer Maimon --- drivers/soc/nuvoton/Kconfig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig index df46182088ec..d5102f5f0c28 100644 --- a/drivers/soc/nuvoton/Kconfig +++ b/drivers/soc/nuvoton/Kconfig @@ -1,5 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -menuconfig WPCM450_SOC + +menu "NUVOTON SoC drivers" + +config WPCM450_SOC tristate "Nuvoton WPCM450 SoC driver" default y if ARCH_WPCM450 select SOC_BUS @@ -9,3 +12,5 @@ menuconfig WPCM450_SOC This driver provides information such as the SoC model and revision. + +endmenu From patchwork Tue Dec 12 10:07:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomer Maimon X-Patchwork-Id: 754687 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nuvoton.onmicrosoft.com header.i=@nuvoton.onmicrosoft.com header.b="uVZoIwvH" Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01rlnn2045.outbound.protection.outlook.com [40.95.54.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B639418B; Tue, 12 Dec 2023 02:07:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mYAN0XnCtcP4lG+zWRSb65b43Z1diNvMGOoXkLEKvXbJ2HrYnc1fQdnId0nGhg1T2RR34oS8NUGjgfuD/VWYQQfMUM2ScbLovRSmrj7SvdaCVapGSvK1W6zsJGycDNIvt3PckXy0kcOLcaFjV/s4FQqT+S69DHQKF0ekFsj9Kot+QILqGwJuM9xGyFgdgXfQBjuUcsqGr/A3TIWxIirob/gHM38kO18h1iMcTBnV1X66UHa2J+ZO6WMZ8PQ0aOw3x9LrH6Pv8w4Vwtea2X9c7L9+ItMcXCaSC4HPHfEE6NKEk3d3pM3bq96tSkaJJoGe95R72k2uUg4SUjumBjbUTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R4foCvPDNVwDXo0EbsLQRBGehdzooLI7HpoDU0GsiPE=; b=Mm1/jQtcaalqtQDP/j0ZJR+gNo1UsbocbHVLJ2td89MrUJYCq+mRsjv1ISeHo4L+N286n1ehGvF1edy8tlqtTkMjIM1SDwY87FOiciDFQpaHd4JpunynsGjjBcbrzMHyv3sHd1V+SKgr/E3sx1QK/t2Qd29BKkZ1x6drggBEFvaCO+IHNYV/Y1RBHCnMpFnzozi/HnjSmFTJ4OJYWvh7BXOAIaQckTLMFm9qdRpptYHAH0qq6UajOmDCShfIPD/wsIoiS9uii3cHkRJ5LQi8rRhMKNfYj2gLdth3noUrn+W1kCkjt/sjiBTQWxg7sUOiqZZQqFhXEk7eGKdtNyUHwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 211.75.126.7) smtp.rcpttodomain=arndb.de smtp.mailfrom=gmail.com; dmarc=fail (p=none sp=quarantine pct=100) action=none header.from=gmail.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuvoton.onmicrosoft.com; s=selector2-nuvoton-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R4foCvPDNVwDXo0EbsLQRBGehdzooLI7HpoDU0GsiPE=; b=uVZoIwvHgjBe0S4vw0Fow5EftxTXPw5zqKrVr0NuPqY2Ds7sIzsrgUklH+ySMvFN0uW+HRQgnWNYm8wvt8DOzNM6b599J2ZIPWJKZZGL327KgrvHn68dsSQmDZkHzRRHH901KEgiIVTdsW9s87DAowqTl2syGTJUf3yZAvVBpWY= Received: from SG2PR04CA0203.apcprd04.prod.outlook.com (2603:1096:4:187::22) by SEZPR03MB8894.apcprd03.prod.outlook.com (2603:1096:101:252::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Tue, 12 Dec 2023 10:07:12 +0000 Received: from SG1PEPF000082E6.apcprd02.prod.outlook.com (2603:1096:4:187:cafe::c9) by SG2PR04CA0203.outlook.office365.com (2603:1096:4:187::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33 via Frontend Transport; Tue, 12 Dec 2023 10:07:12 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 211.75.126.7) smtp.mailfrom=gmail.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=gmail.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 211.75.126.7 as permitted sender) Received: from NTHCCAS01.nuvoton.com (211.75.126.7) by SG1PEPF000082E6.mail.protection.outlook.com (10.167.240.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.18 via Frontend Transport; Tue, 12 Dec 2023 10:07:11 +0000 Received: from NTHCCAS02.nuvoton.com (10.1.9.121) by NTHCCAS01.nuvoton.com (10.1.8.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 12 Dec 2023 18:07:10 +0800 Received: from NTHCCAS01.nuvoton.com (10.1.8.28) by NTHCCAS02.nuvoton.com (10.1.9.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Tue, 12 Dec 2023 18:07:10 +0800 Received: from taln58.nuvoton.co.il (10.191.1.178) by NTHCCAS01.nuvoton.com (10.1.8.28) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 12 Dec 2023 18:07:09 +0800 Received: from taln60.nuvoton.co.il (taln60 [10.191.1.180]) by taln58.nuvoton.co.il (Postfix) with ESMTP id 307205F5D9; Tue, 12 Dec 2023 12:07:09 +0200 (IST) From: Tomer Maimon To: , , , , , , , , , , , CC: , , , , Tomer Maimon Subject: [PATCH v2 3/3] soc: nuvoton: add NPCM BPC driver Date: Tue, 12 Dec 2023 12:07:03 +0200 Message-ID: <20231212100703.3374555-4-tmaimon77@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231212100703.3374555-1-tmaimon77@gmail.com> References: <20231212100703.3374555-1-tmaimon77@gmail.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NotSetDelaration: True X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[211.75.126.7]; domain=NTHCCAS01.nuvoton.com X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG1PEPF000082E6:EE_|SEZPR03MB8894:EE_ X-MS-Office365-Filtering-Correlation-Id: 65485c7b-91c8-43c1-8da1-08dbfafa1b95 X-MS-Exchange-SenderADCheck: 2 X-MS-Exchange-AntiSpam-Relay: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0HylM7X7cTdPAfkELZ56Lo26Y9+tFzLE7ZEIrGIReB7AAbQESu4M1vq28cgWTiIHVDSMkSVl5iZxgoVq5dxN9jIp3k4yXetz9Xf2Qnm9inIqAhuGKRgF8ZT7hCmb+t/B5xEKgBbvfrm7+LnqXp99lpoNxNxNAzUTA9PnhwyMLKJ35VTYNreVpzPR886wDWuL/2JleVA1V9bZztYT/V438VI1sCUQTChjbL2TEfE3Cl4QHdo8eOzKPpNZvlxlRM0TV86Bi4tHCa/1/+dJ+WGLUuHCZY+IjP4FuKvT72E92L6SBNTdZwTHQjF3UhP2IaWv4UKVOAiXvNq04jsJCM1tNz/hXNaF/RO631zMlm21k2NUEaEblo41FZ0MfX1va4oZaY0bPp0vNjCJOf5dNlLrIKiXl1ShwNq/gfw4fGuUuPOpItcHFzUutPdpxg4BWRFuUjxghPxCU0UkrsgLn6bB6kitegeAroYH6dwwgQExhiHOXww7aYJv243x+QDLTxULVhnB5VPfvCGQCk40tv1uoooQ7KuO3Gf9Yzp2x1cklSkV5vw2xD9He/fM9dtakcNPGBh4sS5ZcdlAXTM+3jK9CQ31LiXUwLsQXXLfz2c8h+chT+EYwYLcDmmLoQ4pHWz7PxMttOwv/FDaw4eCvF+dF/z4ir4ohafnf6JkZmTGpdoECxpfcNNdsr5Y+sJX8fsq4Jb/dYTCU7qSbFpMM9SG4I7lryeGH23P0yikkpoFnAVE++D6c9daQLyFheEr7QV0rQRDUBR5EArgb1X8IqvqnT+9RdMEnLPKzu4Ph2RpkWTW4KlRc8HvGh2ZgTuFl6EM X-Forefront-Antispam-Report: CIP:211.75.126.7; CTRY:TW; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:NTHCCAS01.nuvoton.com; PTR:211-75-126-7.hinet-ip.hinet.net; CAT:NONE; SFS:(13230031)(4636009)(136003)(396003)(346002)(39860400002)(376002)(230922051799003)(82310400011)(451199024)(48200799006)(61400799012)(64100799003)(40470700004)(46966006)(40480700001)(6266002)(73392003)(336012)(26005)(82202003)(1076003)(2616005)(40460700003)(82740400003)(921008)(81166007)(55446002)(86362001)(356005)(36756003)(47076005)(30864003)(5660300002)(83380400001)(7416002)(498600001)(35950700001)(6666004)(70586007)(70206006)(316002)(110136005)(8936002)(8676002)(54906003)(41300700001)(4326008)(2906002)(76482006); DIR:OUT; SFP:1022; X-OriginatorOrg: nuvoton.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2023 10:07:11.3048 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65485c7b-91c8-43c1-8da1-08dbfafa1b95 X-MS-Exchange-CrossTenant-Id: a3f24931-d403-4b4a-94f1-7d83ac638e07 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a3f24931-d403-4b4a-94f1-7d83ac638e07; Ip=[211.75.126.7]; Helo=[NTHCCAS01.nuvoton.com] X-MS-Exchange-CrossTenant-AuthSource: SG1PEPF000082E6.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR03MB8894 X-Spam-Level: ** Add Nuvoton BMC NPCM BIOS post code (BPC) driver. The NPCM BPC monitoring two configurable I/O address written by the host on the bus. Signed-off-by: Tomer Maimon --- drivers/soc/nuvoton/Kconfig | 9 + drivers/soc/nuvoton/Makefile | 1 + drivers/soc/nuvoton/npcm-bpc.c | 388 +++++++++++++++++++++++++++++++++ 3 files changed, 398 insertions(+) create mode 100644 drivers/soc/nuvoton/npcm-bpc.c diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig index d5102f5f0c28..ebd162633942 100644 --- a/drivers/soc/nuvoton/Kconfig +++ b/drivers/soc/nuvoton/Kconfig @@ -2,6 +2,15 @@ menu "NUVOTON SoC drivers" +config NPCM_BPC + tristate "NPCM BIOS Post Code support" + depends on (ARCH_NPCM || COMPILE_TEST) + help + Provides NPCM driver to control the BIOS Post Code + interface which allows the BMC to monitor and save + the data written by the host to an arbitrary I/O port, + the BPC is connected to the host thourgh LPC or eSPI bus. + config WPCM450_SOC tristate "Nuvoton WPCM450 SoC driver" default y if ARCH_WPCM450 diff --git a/drivers/soc/nuvoton/Makefile b/drivers/soc/nuvoton/Makefile index e30317b4e829..c6c96079c6e9 100644 --- a/drivers/soc/nuvoton/Makefile +++ b/drivers/soc/nuvoton/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_NPCM_BPC) += npcm-bpc.o obj-$(CONFIG_WPCM450_SOC) += wpcm450-soc.o diff --git a/drivers/soc/nuvoton/npcm-bpc.c b/drivers/soc/nuvoton/npcm-bpc.c new file mode 100644 index 000000000000..149b05f0ac77 --- /dev/null +++ b/drivers/soc/nuvoton/npcm-bpc.c @@ -0,0 +1,388 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2020 Nuvoton Technology corporation. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEVICE_NAME "npcm-bpc" + +#define NUM_BPC_CHANNELS 2 +#define DW_PAD_SIZE 3 + +/* BIOS POST Code FIFO Registers */ +#define NPCM_BPCFA2L_REG 0x2 //BIOS POST Code FIFO Address 2 LSB +#define NPCM_BPCFA2M_REG 0x4 //BIOS POST Code FIFO Address 2 MSB +#define NPCM_BPCFEN_REG 0x6 //BIOS POST Code FIFO Enable +#define NPCM_BPCFSTAT_REG 0x8 //BIOS POST Code FIFO Status +#define NPCM_BPCFDATA_REG 0xA //BIOS POST Code FIFO Data +#define NPCM_BPCFMSTAT_REG 0xC //BIOS POST Code FIFO Miscellaneous Status +#define NPCM_BPCFA1L_REG 0x10 //BIOS POST Code FIFO Address 1 LSB +#define NPCM_BPCFA1M_REG 0x12 //BIOS POST Code FIFO Address 1 MSB + +/* BIOS register data */ +#define FIFO_IOADDR1_ENABLE 0x80 +#define FIFO_IOADDR2_ENABLE 0x40 + +/* BPC interface package and structure definition */ +#define BPC_KFIFO_SIZE 0x400 + +/* BPC register data */ +#define FIFO_DATA_VALID 0x80 +#define FIFO_OVERFLOW 0x20 +#define FIFO_READY_INT_ENABLE 0x8 +#define FIFO_DWCAPTURE 0x4 +#define FIFO_ADDR_DECODE 0x1 + +/* Host Reset */ +#define HOST_RESET_INT_ENABLE 0x10 +#define HOST_RESET_CHANGED 0x40 + +struct npcm_bpc_channel { + struct npcm_bpc *data; + struct kfifo fifo; + wait_queue_head_t wq; + bool host_reset; + struct miscdevice miscdev; +}; + +struct npcm_bpc { + void __iomem *base; + struct device *dev; + int irq; + bool en_dwcap; + struct npcm_bpc_channel ch[NUM_BPC_CHANNELS]; +}; + +static struct npcm_bpc_channel *npcm_file_to_ch(struct file *file) +{ + return container_of(file->private_data, struct npcm_bpc_channel, + miscdev); +} + +static ssize_t npcm_bpc_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + struct npcm_bpc_channel *chan = npcm_file_to_ch(file); + struct npcm_bpc *bpc = chan->data; + unsigned int copied; + int cond_size = 1; + int ret = 0; + + if (bpc->en_dwcap) + cond_size = 3; + + if (kfifo_len(&chan->fifo) < cond_size) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + + ret = wait_event_interruptible + (chan->wq, kfifo_len(&chan->fifo) > cond_size); + if (ret == -ERESTARTSYS) + return -EINTR; + } + + ret = kfifo_to_user(&chan->fifo, buffer, count, &copied); + + return ret ? ret : copied; +} + +static __poll_t npcm_bpc_poll(struct file *file, struct poll_table_struct *pt) +{ + struct npcm_bpc_channel *chan = npcm_file_to_ch(file); + __poll_t mask = 0; + + poll_wait(file, &chan->wq, pt); + if (!kfifo_is_empty(&chan->fifo)) + mask |= POLLIN; + + if (chan->host_reset) { + mask |= POLLHUP; + chan->host_reset = false; + } + + return mask; +} + +static const struct file_operations npcm_bpc_fops = { + .owner = THIS_MODULE, + .read = npcm_bpc_read, + .poll = npcm_bpc_poll, + .llseek = noop_llseek, +}; + +static irqreturn_t npcm_bpc_irq(int irq, void *arg) +{ + struct npcm_bpc *bpc = arg; + u8 fifo_st, host_st, data; + bool isr_flag = false; + u8 last_addr_bit = 0; + u8 padzero[3] = {0}; + u8 addr_index = 0; + + fifo_st = ioread8(bpc->base + NPCM_BPCFSTAT_REG); + while (FIFO_DATA_VALID & fifo_st) { + /* If dwcapture enabled only channel 0 (FIFO 0) used */ + if (!bpc->en_dwcap) + addr_index = fifo_st & FIFO_ADDR_DECODE; + else + last_addr_bit = fifo_st & FIFO_ADDR_DECODE; + + /* Read data from FIFO to clear interrupt */ + data = ioread8(bpc->base + NPCM_BPCFDATA_REG); + if (kfifo_is_full(&bpc->ch[addr_index].fifo)) + kfifo_skip(&bpc->ch[addr_index].fifo); + kfifo_put(&bpc->ch[addr_index].fifo, data); + if (fifo_st & FIFO_OVERFLOW) + dev_warn(bpc->dev, "BIOS Post Codes FIFO Overflow\n"); + + fifo_st = ioread8(bpc->base + NPCM_BPCFSTAT_REG); + if (bpc->en_dwcap && last_addr_bit) { + if ((fifo_st & FIFO_ADDR_DECODE) || + ((FIFO_DATA_VALID & fifo_st) == 0)) { + while (kfifo_avail(&bpc->ch[addr_index].fifo) < DW_PAD_SIZE) + kfifo_skip(&bpc->ch[addr_index].fifo); + kfifo_in(&bpc->ch[addr_index].fifo, + padzero, DW_PAD_SIZE); + } + } + isr_flag = true; + } + + host_st = ioread8(bpc->base + NPCM_BPCFMSTAT_REG); + if (host_st & HOST_RESET_CHANGED) { + iowrite8(HOST_RESET_CHANGED, + bpc->base + NPCM_BPCFMSTAT_REG); + bpc->ch[addr_index].host_reset = true; + isr_flag = true; + } + + if (isr_flag) { + wake_up_interruptible(&bpc->ch[addr_index].wq); + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +static int npcm_bpc_config_irq(struct npcm_bpc *bpc, + struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + int rc; + + bpc->irq = platform_get_irq(pdev, 0); + if (bpc->irq < 0) { + dev_err(dev, "get IRQ failed\n"); + return bpc->irq; + } + + rc = devm_request_irq(dev, bpc->irq, + npcm_bpc_irq, IRQF_SHARED, + DEVICE_NAME, bpc); + if (rc < 0) { + dev_warn(dev, "Unable to request IRQ %d\n", bpc->irq); + return rc; + } + + return 0; +} + +static int npcm_enable_bpc(struct npcm_bpc *bpc, struct device *dev, + int channel, u16 host_port) +{ + u8 addr_en, reg_en; + int err; + + init_waitqueue_head(&bpc->ch[channel].wq); + + err = kfifo_alloc(&bpc->ch[channel].fifo, BPC_KFIFO_SIZE, + GFP_KERNEL); + if (err) + return err; + + bpc->ch[channel].miscdev.minor = MISC_DYNAMIC_MINOR; + bpc->ch[channel].miscdev.name = + devm_kasprintf(dev, GFP_KERNEL, "%s%d", DEVICE_NAME, channel); + bpc->ch[channel].miscdev.fops = &npcm_bpc_fops; + bpc->ch[channel].miscdev.parent = dev; + err = misc_register(&bpc->ch[channel].miscdev); + if (err) + return err; + + bpc->ch[channel].data = bpc; + bpc->ch[channel].host_reset = false; + + /* Enable host snoop channel at requested port */ + switch (channel) { + case 0: + addr_en = FIFO_IOADDR1_ENABLE; + iowrite8((u8)host_port & 0xFF, + bpc->base + NPCM_BPCFA1L_REG); + iowrite8((u8)(host_port >> 8), + bpc->base + NPCM_BPCFA1M_REG); + break; + case 1: + addr_en = FIFO_IOADDR2_ENABLE; + iowrite8((u8)host_port & 0xFF, + bpc->base + NPCM_BPCFA2L_REG); + iowrite8((u8)(host_port >> 8), + bpc->base + NPCM_BPCFA2M_REG); + break; + default: + return -EINVAL; + } + + if (bpc->en_dwcap) + addr_en = FIFO_DWCAPTURE; + + /* + * Enable FIFO Ready Interrupt, FIFO Capture of I/O addr, + * and Host Reset + */ + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + iowrite8(reg_en | addr_en | FIFO_READY_INT_ENABLE | + HOST_RESET_INT_ENABLE, bpc->base + NPCM_BPCFEN_REG); + + return 0; +} + +static void npcm_disable_bpc(struct npcm_bpc *bpc, int channel) +{ + u8 reg_en; + + switch (channel) { + case 0: + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + if (bpc->en_dwcap) + iowrite8(reg_en & ~FIFO_DWCAPTURE, + bpc->base + NPCM_BPCFEN_REG); + else + iowrite8(reg_en & ~FIFO_IOADDR1_ENABLE, + bpc->base + NPCM_BPCFEN_REG); + break; + case 1: + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + iowrite8(reg_en & ~FIFO_IOADDR2_ENABLE, + bpc->base + NPCM_BPCFEN_REG); + break; + default: + return; + } + + if (!(reg_en & (FIFO_IOADDR1_ENABLE | FIFO_IOADDR2_ENABLE))) + iowrite8(reg_en & + ~(FIFO_READY_INT_ENABLE | HOST_RESET_INT_ENABLE), + bpc->base + NPCM_BPCFEN_REG); + + kfifo_free(&bpc->ch[channel].fifo); + misc_deregister(&bpc->ch[channel].miscdev); +} + +static int npcm_bpc_probe(struct platform_device *pdev) +{ + struct npcm_bpc *bpc; + struct device *dev; + u32 port; + int err; + + dev = &pdev->dev; + + bpc = devm_kzalloc(dev, sizeof(*bpc), GFP_KERNEL); + if (!bpc) + return -ENOMEM; + + bpc->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(bpc->base)) + return PTR_ERR(bpc->base); + + dev_set_drvdata(&pdev->dev, bpc); + + err = of_property_read_u32_index(dev->of_node, "nuvoton,monitor-ports", + 0, &port); + if (err) { + dev_err(dev, "no monitor ports configured\n"); + return -ENODEV; + } + + bpc->en_dwcap = + of_property_read_bool(dev->of_node, "nuvoton,bpc-en-dwcapture"); + + bpc->dev = dev; + + err = npcm_bpc_config_irq(bpc, pdev); + if (err) + return err; + + err = npcm_enable_bpc(bpc, dev, 0, port); + if (err) { + dev_err(dev, "Enable BIOS post code I/O port 0 failed\n"); + return err; + } + + /* + * Configuration of second BPC channel port is optional + * Double-Word Capture ignoring address 2 + */ + if (!bpc->en_dwcap) { + if (of_property_read_u32_index(dev->of_node, + "nuvoton,monitor-ports", 1, + &port) == 0) { + err = npcm_enable_bpc(bpc, dev, 1, port); + if (err) { + dev_err(dev, "Enable BIOS post code I/O port 1 failed, disable I/O port 0\n"); + npcm_disable_bpc(bpc, 0); + return err; + } + } + } + + pr_info("NPCM BIOS Post Code probe\n"); + + return err; +} + +static int npcm_bpc_remove(struct platform_device *pdev) +{ + struct npcm_bpc *bpc = dev_get_drvdata(&pdev->dev); + u8 reg_en; + + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + + if (reg_en & FIFO_IOADDR1_ENABLE) + npcm_disable_bpc(bpc, 0); + if (reg_en & FIFO_IOADDR2_ENABLE) + npcm_disable_bpc(bpc, 1); + + return 0; +} + +static const struct of_device_id npcm_bpc_match[] = { + { .compatible = "nuvoton,npcm750-bpc" }, + { .compatible = "nuvoton,npcm845-bpc" }, + { }, +}; + +static struct platform_driver npcm_bpc_driver = { + .driver = { + .name = DEVICE_NAME, + .of_match_table = npcm_bpc_match, + }, + .probe = npcm_bpc_probe, + .remove = npcm_bpc_remove, +}; + +module_platform_driver(npcm_bpc_driver); + +MODULE_DEVICE_TABLE(of, npcm_bpc_match); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Tomer Maimon "); +MODULE_DESCRIPTION("NPCM BIOS post code monitoring device driver");