From patchwork Fri May 13 08:36:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henning Schild X-Patchwork-Id: 573659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A10F6C4321E for ; Fri, 13 May 2022 08:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378387AbiEMIhJ (ORCPT ); Fri, 13 May 2022 04:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378297AbiEMIhH (ORCPT ); Fri, 13 May 2022 04:37:07 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70040.outbound.protection.outlook.com [40.107.7.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F02812631DA; Fri, 13 May 2022 01:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RgeQ+4usPyCCRKXEGpmCIFxsIbauNQ+9/ssP1hUAeycHNawpUuRP/gOI3eybOCaC0fVqR7mpFaXdzoZfol2Eyr6P5OZ/VmhckWcarUfHJwUZFok6ynvnrn0V/plvoU067+ATfQolxVqac1s3HRjuHJL2jLQIwm3ybkV0JosivdNGyeAKljIj7XNoHZ5L+fkCSWwZJu6qIGVjRZjCRiXYyYLdHVvd5bnyx4kCbijUmvJJAz0FD/d+fDT/ZZfU62qf8jxwHZOx1GKAwx4FYugKsL5NElITgqfmKQaYRTY/NbIe4NQPRlJi1/INapE/kLHDPEbby8WD3hDE5F7ZINsBaQ== 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=i7j44S2xYRBxXRq+XJyqczwUz0cTeeyfC4foTiE0zbE=; b=nKXRy26dwywogRgxh7BAdl+l+egXf2f2BarujZppspe1ws07oxV5dyg9TMYz15dOZvtmjpptbb+lzU4zfYiXCACcEkx2jOmMpU6fZ4Tqyx7w5MKsx7gldvCNJDXsJoEhY6xKlE79WeXzoWJo5EY1IAR6OW/4o1pOyDIVOFFRKETpcVcvIwS0+H009a+jpC89srrSwJ2REA4EVPe6gHpZdcfUISWPMK9/vPuljpDNlgLl6FGLEYPZVHwolfgwm2mQhMJ36yFIIkb/JUDnntfo3q1YKrBpPmHPK6HTp3KgKbihMnlwO+v3w05JE4fsOh/8DD8CHH/4YTeYa+Ux5g/lGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.70) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i7j44S2xYRBxXRq+XJyqczwUz0cTeeyfC4foTiE0zbE=; b=QUXZcxpoFptuZq3sqFW0KeWor87BREPcV4Av+LvKro91D0BqRzr1CXojW1GxbHtGTaLx1zuKNCgdzdvT/cWTNhY4F/OS8Air04GzCLhq5lHeFtW0atdLSv8PwSqdDDcrPZbP/Whh/f+V8G2tPcgzC6JSMNIYy8IqebGcchSOtYGiDwSvXRtZpQzP12NOK6VnXvYco/8QB3Y2nXN/m9+yIgYMKnf/IZvvJLzT3FeQAYBj+MuMycxbrJBjsLZIm0AkvIyWpmW7yWfl3EZTvMPX/taAqC4RrwF9gjaXLMwWArDHk8/J1AHrbDX+q/IIg0gZPo1bqK0edrL8opTlbotNPQ== Received: from AS9PR06CA0756.eurprd06.prod.outlook.com (2603:10a6:20b:484::12) by VI1PR10MB3662.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:800:13e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13; Fri, 13 May 2022 08:37:04 +0000 Received: from VE1EUR01FT055.eop-EUR01.prod.protection.outlook.com (2603:10a6:20b:484:cafe::e6) by AS9PR06CA0756.outlook.office365.com (2603:10a6:20b:484::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.14 via Frontend Transport; Fri, 13 May 2022 08:37:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.70) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.70 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.70; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.70) by VE1EUR01FT055.mail.protection.outlook.com (10.152.3.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Fri, 13 May 2022 08:37:03 +0000 Received: from DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) by DEMCHDC9SJA.ad011.siemens.net (194.138.21.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:37:02 +0200 Received: from md1za8fc.ad001.siemens.net (139.25.69.210) by DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:37:02 +0200 From: Henning Schild To: Andy Shevchenko CC: Mark Gross , Wim Van Sebroeck , Guenter Roeck , , , , , Enrico Weigelt , Gerd Haeussler , Henning Schild Subject: [PATCH v3 1/4] leds: simatic-ipc-leds: convert to use P2SB accessor Date: Fri, 13 May 2022 10:36:49 +0200 Message-ID: <20220513083652.974-2-henning.schild@siemens.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220513083652.974-1-henning.schild@siemens.com> References: <20220513083652.974-1-henning.schild@siemens.com> MIME-Version: 1.0 X-Originating-IP: [139.25.69.210] X-ClientProxiedBy: DEMCHDC89XA.ad011.siemens.net (139.25.226.103) To DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d871267d-68f4-427d-268e-08da34bbc1c2 X-MS-TrafficTypeDiagnostic: VI1PR10MB3662:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TJgQvJ8XGVMWLquLhEiC8WC35nhd4GiZ3Uzgxf2p/VNHsN8q0wI5Xw/wO+xNhQUGqFWKYa2JBJnNpKU85gyv9aQSLTUsZFE2R6hxa6S40o5g44ou47h3Qz3/pkuF54cOouNT3nXFhbsjAB8uRpfNBR7mZ5gTC4f4gujQOTFGBkDoMCE512MwD5EeOfa4wy/JcamgcaIpq2IQ6SXhjuuZxFHzmp4Y3oYoK0k8eZhCJRzXCqLVw9z+ASWjiZplZwPIzP9h2diHkUP/+2vG+DndMe1ge+wlalsebElqWQCjOSlwFrkNbJEKBPcnaj7O9AMtY1p6o5uif6nadHW2rwHuwC/NHb3mLTz+hJD1lZ+5qVfaVO3UzH8OLo+LfvILREuljWFgG9lKhMxDnylZ205JF2Kz0znnQDEKCqvyK1xABuwQfHjqlsIXmU0s0c+gQ7b5UqLBiefcQitgmHoPGkm4bZXeZ8Y/nH7NM9ropIAYfN7gUIB7wm7w1br8xEU8s/XO4DmqVEcf+42BEqjlDuP2rViJHbM1DCU6L2BY+VAEM6SWmpVMh4WxdoRfwS30Q0bNJXqIgAmYcqltL4lyXbYCLEbm7zHNwZvngkL9yu4ru6bm2OwfqXTUVeHmZaORNicql21tM5+OhXN/eqv5HJygnGOJPER0qB62iBPevxYoPRo+3RMX8Pz2UmDj1qtlom0i X-Forefront-Antispam-Report: CIP:194.138.21.70; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:hybrid.siemens.com; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(8936002)(6916009)(82310400005)(83380400001)(26005)(1076003)(336012)(5660300002)(40460700003)(47076005)(316002)(86362001)(36860700001)(186003)(36756003)(16526019)(508600001)(2616005)(44832011)(70206006)(356005)(54906003)(7596003)(7636003)(70586007)(6666004)(82960400001)(8676002)(107886003)(956004)(2906002)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2022 08:37:03.9976 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d871267d-68f4-427d-268e-08da34bbc1c2 X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a; Ip=[194.138.21.70]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR01FT055.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB3662 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Since we have a common P2SB accessor in tree we may use it instead of open coded variants. Replace custom code by p2sb_bar() call. Signed-off-by: Henning Schild --- drivers/leds/simple/Kconfig | 1 + drivers/leds/simple/simatic-ipc-leds.c | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/leds/simple/Kconfig b/drivers/leds/simple/Kconfig index 9f6a68336659..bbf8cff3c3f6 100644 --- a/drivers/leds/simple/Kconfig +++ b/drivers/leds/simple/Kconfig @@ -3,6 +3,7 @@ config LEDS_SIEMENS_SIMATIC_IPC tristate "LED driver for Siemens Simatic IPCs" depends on LEDS_CLASS depends on SIEMENS_SIMATIC_IPC + select P2SB help This option enables support for the LEDs of several Industrial PCs from Siemens. diff --git a/drivers/leds/simple/simatic-ipc-leds.c b/drivers/leds/simple/simatic-ipc-leds.c index 078d43f5ba38..2e7597c143d8 100644 --- a/drivers/leds/simple/simatic-ipc-leds.c +++ b/drivers/leds/simple/simatic-ipc-leds.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -38,8 +39,8 @@ static struct simatic_ipc_led simatic_ipc_leds_io[] = { { } }; -/* the actual start will be discovered with PCI, 0 is a placeholder */ -static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME); +/* the actual start will be discovered with p2sb, 0 is a placeholder */ +static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, 0, KBUILD_MODNAME); static void __iomem *simatic_ipc_led_memory; @@ -145,14 +146,13 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev) ipcled = simatic_ipc_leds_mem; type = IORESOURCE_MEM; - /* get GPIO base from PCI */ - res->start = simatic_ipc_get_membase0(PCI_DEVFN(13, 0)); - if (res->start == 0) - return -ENODEV; + err = p2sb_bar(NULL, 0, res); + if (err) + return err; /* do the final address calculation */ res->start = res->start + (0xC5 << 16); - res->end += res->start; + res->end = res->start + SZ_4K - 1; simatic_ipc_led_memory = devm_ioremap_resource(dev, res); if (IS_ERR(simatic_ipc_led_memory)) From patchwork Fri May 13 08:36:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henning Schild X-Patchwork-Id: 572485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAA5BC43217 for ; Fri, 13 May 2022 08:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378391AbiEMIhI (ORCPT ); Fri, 13 May 2022 04:37:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378276AbiEMIhH (ORCPT ); Fri, 13 May 2022 04:37:07 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70052.outbound.protection.outlook.com [40.107.7.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 495E426273E; Fri, 13 May 2022 01:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EA5e4SKJxkEgam/g/N7xtfQUZuiWPlLQOwO1SEIBMml8hrWXlqcQxNsW+jQNEGtBwuCTL88cFwgnr1Wy/rTASwbOnT8ZYD0Z8Um4IOcs5NwVlEV56w4PcY8He32PPaCSYAH2WzGPrRuoySVmc0aE2e8RgFSlVMQkAOsEh8P+gcgG+fOP07SbowmD5mVdAQPhwckfgLdHakf12+zbPZ5/Jhf55+bn9f0mR8Y46qcGUgl9Kf/UTDP9Gqkm7qNIlPjwm6SlctL7WvWKXNJ1N7dEnk0q8dVH9HhqZu/nXeT2sHV7rR2XK2kHijpDG/bGafa38IyyT6Kl76vYEJ8Eqbsv+g== 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=g/bvzut7vDPs6Qu42tMSsNBM1KLXMXM7ArXnJxh9Qi4=; b=Jl5VFKN6j5JnGzVypZQ5mXs/CtgQl4ofFdRy7va+iWhHDY9isv1u89OQNrWiAhLtavQwcA8xwfHsPQqNr7iS3J/jQO95BYM6uK3Sku7GI4jLvOmFlZWQYCuMRiaarbiUXrobgg3PkvsU4kdThRTbWhwfDecfZPRV48/ih5ZhPNl57ptERSJXW2X767TvgWTeeKNqtyL6kP6uedLdox+6BfFpJDEKVQMskMMCP00qgpIRUKcTkoAef3NOaFr4izbPFmYToY/s03JYbilo2eZ+DMmmZsuPsD3452OcI8sRNJbr02QNitDKkZ2KU5TtO/dyozYZpYgHH7Cm/lWjfi8O5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.73) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g/bvzut7vDPs6Qu42tMSsNBM1KLXMXM7ArXnJxh9Qi4=; b=z/t8LAziRB251j2aq8EtSohVI4kdC2RKaNo0j6uIDZbki26HikS0kQIlp7LyGHkBEaVtVGqU3kt80DQzL0me3daVpWXQ+9PNNaoqODTIho6X5eFSkhW3IJ+2nzjeqpf4a1E3lJjS15jGXk8vHY/JUP7ssbm08EEl5lerCvC9MtHXx/6FfDwLMv7cmnIroY5ebaXNAlJejA7CADdEXdHsgu4BNi1DwifybiG28NfZh7v0iXSTx5TypAVaHqVr024X+RDlYbqFTg/pLNqJGjvZOoKAG7zh6xOx3dkdlktBGf/NnCLsHqp0WfgOu8c/u0sU2+S8Xxw8Pak63qubE1NHtg== Received: from DBBPR09CA0004.eurprd09.prod.outlook.com (2603:10a6:10:c0::16) by GVXPR10MB5792.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:6e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Fri, 13 May 2022 08:37:03 +0000 Received: from DB5EUR01FT039.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:c0:cafe::6a) by DBBPR09CA0004.outlook.office365.com (2603:10a6:10:c0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Fri, 13 May 2022 08:37:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.73) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.73 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.73; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.73) by DB5EUR01FT039.mail.protection.outlook.com (10.152.5.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Fri, 13 May 2022 08:37:03 +0000 Received: from DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) by DEMCHDC9SNA.ad011.siemens.net (194.138.21.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:37:02 +0200 Received: from md1za8fc.ad001.siemens.net (139.25.69.210) by DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:37:02 +0200 From: Henning Schild To: Andy Shevchenko CC: Mark Gross , Wim Van Sebroeck , Guenter Roeck , , , , , Enrico Weigelt , Gerd Haeussler , Henning Schild Subject: [PATCH v3 2/4] watchdog: simatic-ipc-wdt: convert to use P2SB accessor Date: Fri, 13 May 2022 10:36:50 +0200 Message-ID: <20220513083652.974-3-henning.schild@siemens.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220513083652.974-1-henning.schild@siemens.com> References: <20220513083652.974-1-henning.schild@siemens.com> MIME-Version: 1.0 X-Originating-IP: [139.25.69.210] X-ClientProxiedBy: DEMCHDC89XA.ad011.siemens.net (139.25.226.103) To DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a434ec37-4ade-4c53-c2aa-08da34bbc167 X-MS-TrafficTypeDiagnostic: GVXPR10MB5792:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HM8HVcro9pWg/W8xmDX1W9SAUYVfOQmgZ8QtpR1UEkZZx6pgXRL13x6SUV0Y9sheFy8jr0WKtzUPXJpxOePx03GxFbWCLhGmwluYGEfNojlARpYNFBPd4ggB+sEAqjzMcpZRw1wzhE512fxOjfaPnfuJVhH+9/xA5Y3QL0zgd/G4XYMVMI6iKbfsOipIELeTOXWoDa/3l57r2Zmv1Yals5UAi18gAOKfVm5/w5GNhB7QNPmaSu2p4E5FmJRpNV2HW37uip8HxG+qSH4hTNMPSZ0mP/3aFrdZvQHMMSXkuoV4cHYtpTsUXPLlvv7Gy4+N95IxgJ7z0uh/e/bO3ZYRwd69UazUAPU5AfjCJOKQp5KMn0w8+Wvr3RQl27kHFf8kOvyBylQ+jvCzAx+eB3zCY5bwFpZF2NDtsY8X2WG/XIstVm1oY7GA3xMz11mj+t5ttPI/8bn4jmUxtMyF+qIuYd/zxUVEFPDjXDulwZuc3/N6uv1nE6jb8XxRf2mVmr6YnTeWdYj3XEZHBK+pc6FRJcEEngbIr5cqeTtmcywCN81FGOmnev53AmB94yeBBFqFMAd3p2+Pw9eDEyaW64yQVtR2ha1tEmZq4q9k8FY/4P4WpbciGKeaM8Q59qBcduIcgMVLh1gQLDxkpojTMt5UikBu4zFZDQVyeoBMUPsZh7b+6ZCFBQJ3/9AMS2F5GpcCwBHJGpvJTXdMHzPCIPd2UQ== X-Forefront-Antispam-Report: CIP:194.138.21.73; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(2906002)(70586007)(54906003)(4326008)(70206006)(81166007)(107886003)(6916009)(8676002)(336012)(47076005)(2616005)(82310400005)(16526019)(186003)(36860700001)(956004)(356005)(82960400001)(40460700003)(36756003)(83380400001)(6666004)(8936002)(1076003)(508600001)(316002)(5660300002)(26005)(86362001)(44832011)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2022 08:37:03.4052 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a434ec37-4ade-4c53-c2aa-08da34bbc167 X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a; Ip=[194.138.21.73]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT039.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR10MB5792 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Since we have a common P2SB accessor in tree we may use it instead of open coded variants. Replace custom code by p2sb_bar() call. Signed-off-by: Henning Schild --- drivers/watchdog/Kconfig | 1 + drivers/watchdog/simatic-ipc-wdt.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index a7cd3ef5b3d8..0097fbb455ab 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1639,6 +1639,7 @@ config SIEMENS_SIMATIC_IPC_WDT tristate "Siemens Simatic IPC Watchdog" depends on SIEMENS_SIMATIC_IPC select WATCHDOG_CORE + select P2SB help This driver adds support for several watchdogs found in Industrial PCs from Siemens. diff --git a/drivers/watchdog/simatic-ipc-wdt.c b/drivers/watchdog/simatic-ipc-wdt.c index 8bac793c63fb..6599695dc672 100644 --- a/drivers/watchdog/simatic-ipc-wdt.c +++ b/drivers/watchdog/simatic-ipc-wdt.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -54,9 +55,9 @@ static struct resource io_resource_trigger = DEFINE_RES_IO_NAMED(WD_TRIGGER_IOADR, SZ_1, KBUILD_MODNAME " WD_TRIGGER_IOADR"); -/* the actual start will be discovered with pci, 0 is a placeholder */ +/* the actual start will be discovered with p2sb, 0 is a placeholder */ static struct resource mem_resource = - DEFINE_RES_MEM_NAMED(0, SZ_4, "WD_RESET_BASE_ADR"); + DEFINE_RES_MEM_NAMED(0, 0, "WD_RESET_BASE_ADR"); static u32 wd_timeout_table[] = {2, 4, 6, 8, 16, 32, 48, 64 }; static void __iomem *wd_reset_base_addr; @@ -150,6 +151,7 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev) struct simatic_ipc_platform *plat = pdev->dev.platform_data; struct device *dev = &pdev->dev; struct resource *res; + int ret; switch (plat->devmode) { case SIMATIC_IPC_DEVICE_227E: @@ -190,15 +192,14 @@ static int simatic_ipc_wdt_probe(struct platform_device *pdev) if (plat->devmode == SIMATIC_IPC_DEVICE_427E) { res = &mem_resource; - /* get GPIO base from PCI */ - res->start = simatic_ipc_get_membase0(PCI_DEVFN(0x1f, 1)); - if (res->start == 0) - return -ENODEV; + ret = p2sb_bar(NULL, 0, res); + if (ret) + return ret; /* do the final address calculation */ res->start = res->start + (GPIO_COMMUNITY0_PORT_ID << 16) + PAD_CFG_DW0_GPP_A_23; - res->end += res->start; + res->end = res->start + SZ_4 - 1; wd_reset_base_addr = devm_ioremap_resource(dev, res); if (IS_ERR(wd_reset_base_addr)) From patchwork Fri May 13 08:36:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henning Schild X-Patchwork-Id: 572484 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E0D8C433F5 for ; Fri, 13 May 2022 08:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378412AbiEMIhV (ORCPT ); Fri, 13 May 2022 04:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378407AbiEMIhT (ORCPT ); Fri, 13 May 2022 04:37:19 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150055.outbound.protection.outlook.com [40.107.15.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3075D2631FC; Fri, 13 May 2022 01:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N4aUSk4F1q8EFaLNZW8Fc4ckbLY2U40Pr2WlBscAEVTqcTOcVcWs4qGKyK3eYfBQ8yUSNlWMxaREuit4kjveGJJ8fhiAODciNWSejeHxKdQ5HwnPSx4Cetf1ty5WRSWODTXca+NRKBUgIbuAdUGA2CGb881KXg2zGHqOCb/yALzQA8Cz/GkIXyId2mFUb/lEK+lYBRvk+1ItZEO7qrvkjmhDXVdIYLVKyGE9+k4giBDI/ZGknwzHB2GHiPFB1mMTaKs8OwrQUtCe+BArJ4OMk9eFXvFynLwrH6szGIaFUELLq5HxOT55ROqNdYG5q5NZb9iJ26raVjQe2oTDO78RaQ== 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=mXb1Ul8YIVAW0UgrIv39CjhPnheGZruVTP2NTPcNEXo=; b=LcCoEf/WQgFzk2gYGWJjvkr9+6zU0ECya2DNt18R1YMBoZ4I2KNbenQcAGr/bX1kxt7rU7Pb/mbEDmaLOFWbbXaw+XY1lFpRH91mmglQz+dgvHYghuZKYFSatTyvBQArigyGbez/pOXOVQHl+0rRoCGkjx2EK2mvnmItikR7hRazlFa6T21/I0f87aG+4Fi2ad/hgeRhZExlmyJt3NxlhxUXNxkBPExKu6bIvfuWfGnXTSDFiaCx+pd47LLBtzJKPFfFB/+MBSaslc7VBfBWtGeEdzWblUhP8vYJzFpLTP9Whbg/y5P7q91FOuDP6mCJ/LM1c/eMvM8tjpeWTzsuiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.70) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mXb1Ul8YIVAW0UgrIv39CjhPnheGZruVTP2NTPcNEXo=; b=BA5WwtYQ84hHyCNHqgXjPAkExDytU3rQaixv+wGQpFZQpoc2e+0M6sVbdurzG/lPYec64oJ7i262j8rzxcMy5yh/7NNex41U+pzaLVgcg5SxiVzMTZFhb1UJ7HTTDaHThM1QYA+6W1pTidVutJAHV4RbEhkrhQkEt55woOwWWuBucI/D6dfhOGiQIY8uBpiYqSzbl/c1vkQhxpFAiwiN3oARNjRmLC4C81c8W9hVmIhpGxzGKiYP//yOIvjcr9/PE8GfeokPotqvNEcQC8kSyL4XFx3OE4yvPo3SVlgXnphN2D8ExUxWitAHYhWjOlWrqbDIu3yz2tn8WpVpiM22VQ== Received: from AM6PR04CA0014.eurprd04.prod.outlook.com (2603:10a6:20b:92::27) by AM7PR10MB3923.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:172::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13; Fri, 13 May 2022 08:37:16 +0000 Received: from VE1EUR01FT044.eop-EUR01.prod.protection.outlook.com (2603:10a6:20b:92:cafe::bd) by AM6PR04CA0014.outlook.office365.com (2603:10a6:20b:92::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.15 via Frontend Transport; Fri, 13 May 2022 08:37:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.70) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.70 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.70; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.70) by VE1EUR01FT044.mail.protection.outlook.com (10.152.3.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Fri, 13 May 2022 08:37:14 +0000 Received: from DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) by DEMCHDC9SJA.ad011.siemens.net (194.138.21.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:37:14 +0200 Received: from md1za8fc.ad001.siemens.net (139.25.69.210) by DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:37:13 +0200 From: Henning Schild To: Andy Shevchenko CC: Mark Gross , Wim Van Sebroeck , Guenter Roeck , , , , , Enrico Weigelt , Gerd Haeussler , Henning Schild Subject: [PATCH v3 3/4] platform/x86: simatic-ipc: drop custom P2SB bar code Date: Fri, 13 May 2022 10:36:51 +0200 Message-ID: <20220513083652.974-4-henning.schild@siemens.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220513083652.974-1-henning.schild@siemens.com> References: <20220513083652.974-1-henning.schild@siemens.com> MIME-Version: 1.0 X-Originating-IP: [139.25.69.210] X-ClientProxiedBy: DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) To DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e97dee0-8c15-419b-9707-08da34bbc847 X-MS-TrafficTypeDiagnostic: AM7PR10MB3923:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2P1eKoN7W+0vvNBD4uMb24W5l/eApqUNf6JmFUuwTOMOflxM2tFi3xtexlhfKTDFnOedzaMOZYgvF4cwENc3E5SDoijoOtED8vSJn5uL4MQhgvb+JtWlnLc7ULFR0NDgAoSgDd6tcX5pDVxzRQP+yvHd6v1Z4m0lPWlUA5+jmkwKygFRF05d/qrYCKUOM0+7mj6Vio4Zofk7r8Lf+/a/yJetfP5fmcfDA2TRTivtvfZpL3+b5mUyyMaHiWM03J6TRhasXKtB2bXkyQggczA+XBSvLuZmPPBd5/PGzAjktfzhgxYYj8OEtQmOySL4mXI8wWh8LOW2G/zkmzIKW7+giKTV4yquBSa4fFebi5CqFYJILDkc9m5DNoLz4BVWlBYhNOmC98GeTdeCs//Z/N0Iw1Af/elaH6Kg8I/yhW7mZPKsaqeq3vExG5TAWNMhuuUYpfLRJhBev8lZI+lAyTgdkj/hLIjbAmH/noR4lUvQgZ8nWaB/Y7liFCa9AHpB7Qm5eAxDxE6VZmMPHMsf0pEpp7qUAmhkHD0ISkPNoy6ns7m8YMaT3pTgUrDWBJeA5vrqWDL6CPLfNbJKvRB1y24jIK1g9BburbanGML2kiwxvSP+/FO1xG+y3stt3HEFf/wdrEWrawnsAgPRmc8ACi5LkG2Wg7nEb5jbo5m1jdAnNLl6JKWBgfZSQ9ULlA7vsCs+ X-Forefront-Antispam-Report: CIP:194.138.21.70; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:hybrid.siemens.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(4326008)(82960400001)(316002)(336012)(70586007)(36756003)(6916009)(356005)(2906002)(6666004)(47076005)(83380400001)(36860700001)(82310400005)(8676002)(70206006)(54906003)(5660300002)(186003)(16526019)(7596003)(26005)(7636003)(508600001)(8936002)(40460700003)(86362001)(44832011)(2616005)(956004)(107886003)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2022 08:37:14.9385 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e97dee0-8c15-419b-9707-08da34bbc847 X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a; Ip=[194.138.21.70]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR01FT044.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR10MB3923 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The two drivers that used to use this have been switched over to the common P2SB accessor, so this code is not needed any longer. Signed-off-by: Henning Schild --- drivers/platform/x86/simatic-ipc.c | 38 ------------------- .../platform_data/x86/simatic-ipc-base.h | 2 - 2 files changed, 40 deletions(-) diff --git a/drivers/platform/x86/simatic-ipc.c b/drivers/platform/x86/simatic-ipc.c index b599cda5ba3c..26c35e1660cb 100644 --- a/drivers/platform/x86/simatic-ipc.c +++ b/drivers/platform/x86/simatic-ipc.c @@ -101,44 +101,6 @@ static int register_platform_devices(u32 station_id) return 0; } -/* FIXME: this should eventually be done with generic P2SB discovery code - * the individual drivers for watchdogs and LEDs access memory that implements - * GPIO, but pinctrl will not come up because of missing ACPI entries - * - * While there is no conflict a cleaner solution would be to somehow bring up - * pinctrl even with these ACPI entries missing, and base the drivers on pinctrl. - * After which the following function could be dropped, together with the code - * poking the memory. - */ -/* - * Get membase address from PCI, used in leds and wdt module. Here we read - * the bar0. The final address calculation is done in the appropriate modules - */ -u32 simatic_ipc_get_membase0(unsigned int p2sb) -{ - struct pci_bus *bus; - u32 bar0 = 0; - /* - * The GPIO memory is in bar0 of the hidden P2SB device. - * Unhide the device to have a quick look at it, before we hide it - * again. - * Also grab the pci rescan lock so that device does not get discovered - * and remapped while it is visible. - * This code is inspired by drivers/mfd/lpc_ich.c - */ - bus = pci_find_bus(0, 0); - pci_lock_rescan_remove(); - pci_bus_write_config_byte(bus, p2sb, 0xE1, 0x0); - pci_bus_read_config_dword(bus, p2sb, PCI_BASE_ADDRESS_0, &bar0); - - bar0 &= ~0xf; - pci_bus_write_config_byte(bus, p2sb, 0xE1, 0x1); - pci_unlock_rescan_remove(); - - return bar0; -} -EXPORT_SYMBOL(simatic_ipc_get_membase0); - static int __init simatic_ipc_init_module(void) { const struct dmi_system_id *match; diff --git a/include/linux/platform_data/x86/simatic-ipc-base.h b/include/linux/platform_data/x86/simatic-ipc-base.h index 62d2bc774067..39fefd48cf4d 100644 --- a/include/linux/platform_data/x86/simatic-ipc-base.h +++ b/include/linux/platform_data/x86/simatic-ipc-base.h @@ -24,6 +24,4 @@ struct simatic_ipc_platform { u8 devmode; }; -u32 simatic_ipc_get_membase0(unsigned int p2sb); - #endif /* __PLATFORM_DATA_X86_SIMATIC_IPC_BASE_H */ From patchwork Fri May 13 08:36:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henning Schild X-Patchwork-Id: 573658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6CD2C433F5 for ; Fri, 13 May 2022 08:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378425AbiEMIh1 (ORCPT ); Fri, 13 May 2022 04:37:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378416AbiEMIhV (ORCPT ); Fri, 13 May 2022 04:37:21 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2056.outbound.protection.outlook.com [40.107.20.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D80BD2655CE; Fri, 13 May 2022 01:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D3mXIG3Lo+JnKrLOd+JtxlIuLJmg5l8XEDVM9OxiRrfuSa0krV5rJHhTauZld+BvI+VZd5o1AIjVdqkP9+EDdeH9a0GRb93jdFmB536M9JxJCLhq0/KZI5wWb9KEeCRQCMbhWzDl6jXyn7UhOFygFwZ31DeB+O135Fg93HoW+9abu6jaAVzpPtr/pCUGqW1+9aOpA+udo7A6Z1KKQ88DPucz/nXCpn53LjgI6oimHddOnXI7Zv4mvHE9aJ3aigWpYCeaF7DC7rnN3hSIjvfw9KdjuRbZyUKpDrtNOG6JGJFeZ4x+ZUlEaBjuhwHvYQcHQ1sOvR6/UIcfWnnnpGPqaw== 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=P+IwfmZOu53L0UY/fvak0+V27Hs7B6p71/Zsq4rxx/0=; b=hH9MYOdsqUjOcbjMmY4Ev7EenfbhupcJRG5oBPp6TEZzwklpqfLZ/vsi6+9ULe68i1ZeFYJYYDS0SE4pR338/YljLyu9HwcyMXh1Hs3XFs+CZZ783X73ldWZsMPQOzHQg6AvPDjiK9tni/ZP7R1Njl/nR/jiKUvUDIcRhoJvKc2ZT1KMK6GzlaS5NTfORfGXJhEp5X8N80xRADR8FcrvBBEknGAN4h8LKJR4JRfQTYA1CCrjPwVV0+NTWogol9IXfWkGntoSppD0qQH9kCkgyYZbVxEyBxli5NNpJv7Ea8Nk63tyyjIZYK1IM7ma6vqNqTUprPHOZz/ts9Wkvm90fw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.73) smtp.rcpttodomain=linux.intel.com smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P+IwfmZOu53L0UY/fvak0+V27Hs7B6p71/Zsq4rxx/0=; b=CFKvgU7KdDgiODF2Uqx9Vz3U+XuPjDPesH1P6a5DMXlchWD+n7PX+mAJHpsKZEiVhp47BmhsaUi224B++RFBuHffy9ZOMkRZbmeFqQeJQK2GecR5Kep2lG4ESgfbPPYH1GnTzekTfGo/nZ9f2SAXc+rxPoB+9fw9tFgS/8AtrmRrGzY66m9RlZPsLYGbGmrUjZL2tG1hTkIANyam+0towsgiTE28NetaZdSQYTtjCktX+O1vOQOd3T1G7fAU3QIEYc2gyMMNzycplZANCP4l/fXlExUtSg0VZJWL5Zk2Ya39A8cEpSwbsz2FgT0YyAt62hm6h2LTDRh9PFVK3HFmQQ== Received: from DB7PR03CA0105.eurprd03.prod.outlook.com (2603:10a6:10:72::46) by DB9PR10MB5642.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:30d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13; Fri, 13 May 2022 08:37:16 +0000 Received: from DB5EUR01FT081.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:72:cafe::7f) by DB7PR03CA0105.outlook.office365.com (2603:10a6:10:72::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.15 via Frontend Transport; Fri, 13 May 2022 08:37:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.73) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.73 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.73; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.73) by DB5EUR01FT081.mail.protection.outlook.com (10.152.5.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Fri, 13 May 2022 08:37:14 +0000 Received: from DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) by DEMCHDC9SNA.ad011.siemens.net (194.138.21.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:37:14 +0200 Received: from md1za8fc.ad001.siemens.net (139.25.69.210) by DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:37:14 +0200 From: Henning Schild To: Andy Shevchenko CC: Mark Gross , Wim Van Sebroeck , Guenter Roeck , , , , , Enrico Weigelt , Gerd Haeussler , Henning Schild Subject: [PATCH v3 4/4] leds: simatic-ipc-leds-gpio: add GPIO version of Siemens driver Date: Fri, 13 May 2022 10:36:52 +0200 Message-ID: <20220513083652.974-5-henning.schild@siemens.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220513083652.974-1-henning.schild@siemens.com> References: <20220513083652.974-1-henning.schild@siemens.com> MIME-Version: 1.0 X-Originating-IP: [139.25.69.210] X-ClientProxiedBy: DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) To DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 096e781e-372d-4433-48aa-08da34bbc840 X-MS-TrafficTypeDiagnostic: DB9PR10MB5642:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZoIPqiFPTa9qWJee548pQft9du1A2I3XV2bf489oxj4I47cTafnRn2irMJPxxPKzL5J1Ma6u/AG/lwQ23ymIgu9HXibTQaObOfSmT8W/Qj0kAo/xZn5u10k2RFqlNOdM8LIfx+51C70F8WufP05+xCCzvT773tNqhAZfzlnWkn7rFZ9USc4CxiNCMWzS20twQw883LNUN1AjGKIMbB/wL8PLW2mpw3U8tRqB8Ge9B9ZbAywImzCLUqIf5YFxjxcNVP/BsEFIWOxvhAFBwaKckm6069bJ9GW5XheR630cncdUedRbIozJzuoj1RK2vnSxtxZ/eMCgWnilTgRXNopYYmQcdo6QltDYPcihhE3m4jITfeHmjHHBxrU3NO2i9tT0EVtzIvrye1APcAUmAQd4CAWzY8Hs3c7AvMjRPHsPdGlWqENMZELwRH0Sul9wXmnQiJRKoCqBV9hP/rRo6Wa63ktJM9RCeAEg1VAI8ehOXvcj0T9NFjjn3Jh0nLqAepHeAd0wagcEvIS9u9hMp8sjHjlWMvAKNzAzaTHnFORHzS5kyRzbf+gOJ1A8DA1sGWBy1YTrGZMxDkkk/OwFlWn8Dpmm+HGZOOSWQ1YSnuVM/FXAxYSxt9UC8A5Gu9RPdUdIO4SV2dXbtDG0PKvrXhQRHXkc44sBvpyc729m8FWebD8YLlHTa+DOE0J/RMHhuIhdp2esNygtJjJMCWzXN58W/Q== X-Forefront-Antispam-Report: CIP:194.138.21.73; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(2906002)(186003)(26005)(83380400001)(107886003)(54906003)(44832011)(1076003)(82310400005)(316002)(6916009)(47076005)(30864003)(36756003)(16526019)(6666004)(5660300002)(956004)(2616005)(36860700001)(82960400001)(336012)(508600001)(4326008)(8676002)(70206006)(86362001)(70586007)(356005)(81166007)(40460700003)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 May 2022 08:37:14.8750 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 096e781e-372d-4433-48aa-08da34bbc840 X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a; Ip=[194.138.21.73]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT081.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR10MB5642 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org On Apollo Lake the pinctrl drivers will now come up without ACPI. Use that instead of open coding it. Create a new driver for that which can later be filled with more GPIO based models, and which has different dependencies. Signed-off-by: Henning Schild --- drivers/leds/simple/Kconfig | 7 +- drivers/leds/simple/Makefile | 1 + drivers/leds/simple/simatic-ipc-leds-gpio.c | 105 ++++++++++++++++++++ drivers/leds/simple/simatic-ipc-leds.c | 80 +-------------- drivers/platform/x86/simatic-ipc.c | 5 +- 5 files changed, 117 insertions(+), 81 deletions(-) create mode 100644 drivers/leds/simple/simatic-ipc-leds-gpio.c diff --git a/drivers/leds/simple/Kconfig b/drivers/leds/simple/Kconfig index bbf8cff3c3f6..fd2b8225d926 100644 --- a/drivers/leds/simple/Kconfig +++ b/drivers/leds/simple/Kconfig @@ -1,12 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only config LEDS_SIEMENS_SIMATIC_IPC tristate "LED driver for Siemens Simatic IPCs" - depends on LEDS_CLASS + depends on LEDS_GPIO depends on SIEMENS_SIMATIC_IPC - select P2SB help This option enables support for the LEDs of several Industrial PCs from Siemens. - To compile this driver as a module, choose M here: the module - will be called simatic-ipc-leds. + To compile this driver as a module, choose M here: the modules + will be called simatic-ipc-leds and simatic-ipc-leds-gpio. diff --git a/drivers/leds/simple/Makefile b/drivers/leds/simple/Makefile index 8481f1e9e360..1c7ef5e1324b 100644 --- a/drivers/leds/simple/Makefile +++ b/drivers/leds/simple/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds.o +obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds-gpio.o diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio.c b/drivers/leds/simple/simatic-ipc-leds-gpio.c new file mode 100644 index 000000000000..4c9e663a90ba --- /dev/null +++ b/drivers/leds/simple/simatic-ipc-leds-gpio.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Siemens SIMATIC IPC driver for GPIO based LEDs + * + * Copyright (c) Siemens AG, 2022 + * + * Authors: + * Henning Schild + */ + +#include +#include +#include +#include +#include + +static struct gpiod_lookup_table simatic_ipc_led_gpio_table = { + .dev_id = "leds-gpio", + .table = { + GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 51, NULL, 0, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 52, NULL, 1, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 53, NULL, 2, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 57, NULL, 3, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 58, NULL, 4, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 60, NULL, 5, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 56, NULL, 6, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 59, NULL, 7, GPIO_ACTIVE_HIGH), + }, +}; + +static const struct gpio_led simatic_ipc_gpio_leds[] = { + { .name = "green:" LED_FUNCTION_STATUS "-3" }, + { .name = "red:" LED_FUNCTION_STATUS "-1" }, + { .name = "green:" LED_FUNCTION_STATUS "-1" }, + { .name = "red:" LED_FUNCTION_STATUS "-2" }, + { .name = "green:" LED_FUNCTION_STATUS "-2" }, + { .name = "red:" LED_FUNCTION_STATUS "-3" }, +}; + +static const struct gpio_led_platform_data simatic_ipc_gpio_leds_pdata = { + .num_leds = ARRAY_SIZE(simatic_ipc_gpio_leds), + .leds = simatic_ipc_gpio_leds, +}; + +static struct platform_device *simatic_leds_pdev; + +static int simatic_ipc_leds_gpio_remove(struct platform_device *pdev) +{ + gpiod_remove_lookup_table(&simatic_ipc_led_gpio_table); + platform_device_unregister(simatic_leds_pdev); + + return 0; +} + +static int simatic_ipc_leds_gpio_probe(struct platform_device *pdev) +{ + struct gpio_desc *gpiod; + int err; + + gpiod_add_lookup_table(&simatic_ipc_led_gpio_table); + simatic_leds_pdev = platform_device_register_resndata(NULL, + "leds-gpio", PLATFORM_DEVID_NONE, NULL, 0, + &simatic_ipc_gpio_leds_pdata, + sizeof(simatic_ipc_gpio_leds_pdata)); + if (IS_ERR(simatic_leds_pdev)) { + err = PTR_ERR(simatic_leds_pdev); + goto out; + } + + /* PM_BIOS_BOOT_N */ + gpiod = gpiod_get_index(&simatic_leds_pdev->dev, NULL, 6, GPIOD_OUT_LOW); + if (IS_ERR(gpiod)) { + err = PTR_ERR(gpiod); + goto out; + } + gpiod_put(gpiod); + + /* PM_WDT_OUT */ + gpiod = gpiod_get_index(&simatic_leds_pdev->dev, NULL, 7, GPIOD_OUT_LOW); + if (IS_ERR(gpiod)) { + err = PTR_ERR(gpiod); + goto out; + } + gpiod_put(gpiod); + + return 0; +out: + simatic_ipc_leds_gpio_remove(pdev); + + return err; +} + +static struct platform_driver simatic_ipc_led_gpio_driver = { + .probe = simatic_ipc_leds_gpio_probe, + .remove = simatic_ipc_leds_gpio_remove, + .driver = { + .name = KBUILD_MODNAME, + } +}; +module_platform_driver(simatic_ipc_led_gpio_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:" KBUILD_MODNAME); +MODULE_SOFTDEP("pre: platform:leds-gpio"); +MODULE_AUTHOR("Henning Schild "); diff --git a/drivers/leds/simple/simatic-ipc-leds.c b/drivers/leds/simple/simatic-ipc-leds.c index 2e7597c143d8..4894c228c165 100644 --- a/drivers/leds/simple/simatic-ipc-leds.c +++ b/drivers/leds/simple/simatic-ipc-leds.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -24,7 +23,7 @@ #define SIMATIC_IPC_LED_PORT_BASE 0x404E struct simatic_ipc_led { - unsigned int value; /* mask for io and offset for mem */ + unsigned int value; /* mask for io */ char *name; struct led_classdev cdev; }; @@ -39,21 +38,6 @@ static struct simatic_ipc_led simatic_ipc_leds_io[] = { { } }; -/* the actual start will be discovered with p2sb, 0 is a placeholder */ -static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, 0, KBUILD_MODNAME); - -static void __iomem *simatic_ipc_led_memory; - -static struct simatic_ipc_led simatic_ipc_leds_mem[] = { - {0x500 + 0x1A0, "red:" LED_FUNCTION_STATUS "-1"}, - {0x500 + 0x1A8, "green:" LED_FUNCTION_STATUS "-1"}, - {0x500 + 0x1C8, "red:" LED_FUNCTION_STATUS "-2"}, - {0x500 + 0x1D0, "green:" LED_FUNCTION_STATUS "-2"}, - {0x500 + 0x1E0, "red:" LED_FUNCTION_STATUS "-3"}, - {0x500 + 0x198, "green:" LED_FUNCTION_STATUS "-3"}, - { } -}; - static struct resource simatic_ipc_led_io_res = DEFINE_RES_IO_NAMED(SIMATIC_IPC_LED_PORT_BASE, SZ_2, KBUILD_MODNAME); @@ -89,28 +73,6 @@ static enum led_brightness simatic_ipc_led_get_io(struct led_classdev *led_cd) return inw(SIMATIC_IPC_LED_PORT_BASE) & led->value ? LED_OFF : led_cd->max_brightness; } -static void simatic_ipc_led_set_mem(struct led_classdev *led_cd, - enum led_brightness brightness) -{ - struct simatic_ipc_led *led = cdev_to_led(led_cd); - void __iomem *reg = simatic_ipc_led_memory + led->value; - u32 val; - - val = readl(reg); - val = (val & ~1) | (brightness == LED_OFF); - writel(val, reg); -} - -static enum led_brightness simatic_ipc_led_get_mem(struct led_classdev *led_cd) -{ - struct simatic_ipc_led *led = cdev_to_led(led_cd); - void __iomem *reg = simatic_ipc_led_memory + led->value; - u32 val; - - val = readl(reg); - return (val & 1) ? LED_OFF : led_cd->max_brightness; -} - static int simatic_ipc_leds_probe(struct platform_device *pdev) { const struct simatic_ipc_platform *plat = pdev->dev.platform_data; @@ -118,9 +80,7 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev) struct simatic_ipc_led *ipcled; struct led_classdev *cdev; struct resource *res; - void __iomem *reg; - int err, type; - u32 val; + int err; switch (plat->devmode) { case SIMATIC_IPC_DEVICE_227D: @@ -135,51 +95,19 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev) } ipcled = simatic_ipc_leds_io; } - type = IORESOURCE_IO; if (!devm_request_region(dev, res->start, resource_size(res), KBUILD_MODNAME)) { dev_err(dev, "Unable to register IO resource at %pR\n", res); return -EBUSY; } break; - case SIMATIC_IPC_DEVICE_127E: - res = &simatic_ipc_led_mem_res; - ipcled = simatic_ipc_leds_mem; - type = IORESOURCE_MEM; - - err = p2sb_bar(NULL, 0, res); - if (err) - return err; - - /* do the final address calculation */ - res->start = res->start + (0xC5 << 16); - res->end = res->start + SZ_4K - 1; - - simatic_ipc_led_memory = devm_ioremap_resource(dev, res); - if (IS_ERR(simatic_ipc_led_memory)) - return PTR_ERR(simatic_ipc_led_memory); - - /* initialize power/watchdog LED */ - reg = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */ - val = readl(reg); - writel(val & ~1, reg); - - reg = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */ - val = readl(reg); - writel(val | 1, reg); - break; default: return -ENODEV; } while (ipcled->value) { cdev = &ipcled->cdev; - if (type == IORESOURCE_MEM) { - cdev->brightness_set = simatic_ipc_led_set_mem; - cdev->brightness_get = simatic_ipc_led_get_mem; - } else { - cdev->brightness_set = simatic_ipc_led_set_io; - cdev->brightness_get = simatic_ipc_led_get_io; - } + cdev->brightness_set = simatic_ipc_led_set_io; + cdev->brightness_get = simatic_ipc_led_get_io; cdev->max_brightness = LED_ON; cdev->name = ipcled->name; diff --git a/drivers/platform/x86/simatic-ipc.c b/drivers/platform/x86/simatic-ipc.c index 26c35e1660cb..ca3647b751d5 100644 --- a/drivers/platform/x86/simatic-ipc.c +++ b/drivers/platform/x86/simatic-ipc.c @@ -51,6 +51,7 @@ static int register_platform_devices(u32 station_id) { u8 ledmode = SIMATIC_IPC_DEVICE_NONE; u8 wdtmode = SIMATIC_IPC_DEVICE_NONE; + char *pdevname = KBUILD_MODNAME "_leds"; int i; platform_data.devmode = SIMATIC_IPC_DEVICE_NONE; @@ -64,10 +65,12 @@ static int register_platform_devices(u32 station_id) } if (ledmode != SIMATIC_IPC_DEVICE_NONE) { + if (ledmode == SIMATIC_IPC_DEVICE_127E) + pdevname = KBUILD_MODNAME "_leds_gpio"; platform_data.devmode = ledmode; ipc_led_platform_device = platform_device_register_data(NULL, - KBUILD_MODNAME "_leds", PLATFORM_DEVID_NONE, + pdevname, PLATFORM_DEVID_NONE, &platform_data, sizeof(struct simatic_ipc_platform)); if (IS_ERR(ipc_led_platform_device))