From patchwork Wed May 11 15:39:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henning Schild X-Patchwork-Id: 571664 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 603F2C43217 for ; Wed, 11 May 2022 15:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343827AbiEKPjX (ORCPT ); Wed, 11 May 2022 11:39:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343818AbiEKPjV (ORCPT ); Wed, 11 May 2022 11:39:21 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2082.outbound.protection.outlook.com [40.107.20.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CA6C95DC4; Wed, 11 May 2022 08:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UNZpduJ76zwVCywRQv5wTuR5wPFZiUl5ysAWwAkvHdJs0wzCNCpn6sbCnmY5ffmA3WwK0AnRnJOE9rtyejvKf5r6qbHMFlDaLFAwTAkil5S6gwn23kBX37m13QH2hejStECm25zOFOOLfQTUk0owsbVFJLZ+45Q+buKLKnM3UAXFsZ3wyv6naDjPbbZ9HbworX0M0WdDPZRIxoGSl1Q8Z23mGX+y2dGCp1s16ZVehlA92LpYq+/Rm5DuA6HM4yoESxIyLnkrSfoTg1lk3VHxZPtdSy0834ZTqO3eJTVbDdFyROhHDmNmEo9aBigPzNi0Pd/GywCVUg+O2A2JnhFqww== 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=NuytOf2M9EtJUoFZOAAwTVMKOQ8vD32V79Bo/CtPEZ0=; b=hwYA6M3MIQ3vv+inPpc0xJWNQiPBom2ZE6Jl9jaBqwF1Kra3DpoGQiXEOV37QoOEejVESbpVQABqxzWrAVdVIHmJKfUFOjNuFxNgCgEN6vH4tTghoPDa+GduERMs5WLARkBOwCuEeeteK1JXSBhlrrs8FYi1ncGJ8BE3Q1x8Dy06EKtmEOCIHjK+qGQ/2oP4AIlhR8FKKmQ0+jWlYHKXyygY2Ep+06L1M1fQlE0CuR6UqSnj+6kLvWQ4HRykuWigs99AlQQyvmw+i3/Pu1b824lTIqfCIyYo03PM/tstFzHB1XwTScB0CVuQs9s8MhBGOrRFHos9k4nIIWZpI25eWQ== 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=NuytOf2M9EtJUoFZOAAwTVMKOQ8vD32V79Bo/CtPEZ0=; b=COhDEnXVBl9Ac1J0V+IcDOkwaDZom1fp/ZlhJPsbtn7Pp2eQMe3tZw28MJB0H5Wsu3+qP1O6OvZq6fR6qKKSvMAh52yCjR5WkXkzcbDAPvYm/+RO54dNN8KZ7xr+cg3BBehsqXXBrrAuKcsmjhQapMd/VeT8CxqlmQoTai1M9OESbKniLr8ze3ev78RAUaZ05dWVpqZ5p02KI6Jv4TuG6IvKgd9YLzB48+BEjCrLsdD545G9ItFVERVph68RK7poEDGlb+KtcrtSp/XYbfGkFP9pnIWh9Ntq1SlqhPyBewJtObSZ6zZVYwaZCZqVaXGdpA4y4Rdb8SOTuJQRe31n9w== Received: from DB8PR03CA0006.eurprd03.prod.outlook.com (2603:10a6:10:be::19) by VI1PR10MB2783.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:eb::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23; Wed, 11 May 2022 15:39:17 +0000 Received: from DB5EUR01FT056.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:be:cafe::3f) by DB8PR03CA0006.outlook.office365.com (2603:10a6:10:be::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 15:39:17 +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 DB5EUR01FT056.mail.protection.outlook.com (10.152.5.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 15:39:16 +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; Wed, 11 May 2022 17:39:16 +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; Wed, 11 May 2022 17:39:16 +0200 From: Henning Schild To: Andy Shevchenko CC: Mark Gross , Wim Van Sebroeck , Guenter Roeck , , , , , Enrico Weigelt , Gerd Haeussler , Henning Schild Subject: [PATCH v2 1/4] leds: simatic-ipc-leds: convert to use P2SB accessor Date: Wed, 11 May 2022 17:39:02 +0200 Message-ID: <20220511153905.13980-2-henning.schild@siemens.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220511153905.13980-1-henning.schild@siemens.com> References: <20220511153905.13980-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: d08ce2d7-fd0e-4e6c-f0c7-08da3364686b X-MS-TrafficTypeDiagnostic: VI1PR10MB2783: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: AeS7qy4Pbw2lxYIhIOgJYU9eAN/KAvTZ8kiKtSzfsXkdc7is4+5QlN2ShSEyPViU1dxciH5ZqilcBI20WWECcDFpZY9U1zlWUf01hOjraHz3Xgj05uI6Qn00mM9OQbGCYyT0wIY5f++BBxORqHtN2xYXpsRpWypTMEXQbhTyVvoBR/XOZUGtOGqrwo0AD7Km8gaPcS7VYcrEyGqiwLrGeonN6v7ejBoidYXyC5i0hH5orJLrhU4R+ZTH0VfJ/uPN+idJAldFqrKirzbDyX5jK263CV/qAdXbdc+AGtWG+rK5DHSYFvpyAahfjWAzsWPp4YUlRJPpyFGWMj6fPOTeUEnFhdWmmX6tkUBuY2QnPBic0l1XWyWKJhe4ks4tdefbYidsqxXnUdEe9d3jri+/yw3zHQJ2RSyx8QpGaaup2/rrhmqAX7TRCJuHyYBUxjs0hrZf3ISxench+U5cTkWD8tvoME1tn81hHcouv7ZVIGlIz+vbuPWe7pN7pXYp9YLDR0yoKj5aWRAL0greerMVPN+2bd0Qorpyg6ZnRgYxh0uiluAX5OuB+jvkADaWlxruLVY5y1+0O64w9G5s71Tx4T6BW8fjLHKYB9Vfr/u98YGM1v0TYbdsgnq75gz/IzSnx6oN8fbTKEPIFiMI7p9ylJqw37tqkbCqPsZ8p0euSvZpj4jMB+E/gbd9iTRvgPfNIih9GxVLG1qxoHYQgYyKFQ== 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)(83380400001)(16526019)(36860700001)(186003)(6666004)(356005)(336012)(956004)(107886003)(2616005)(26005)(1076003)(44832011)(2906002)(36756003)(47076005)(82310400005)(40460700003)(5660300002)(82960400001)(86362001)(8936002)(54906003)(8676002)(70586007)(70206006)(6916009)(4326008)(81166007)(316002)(508600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 15:39:16.7258 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d08ce2d7-fd0e-4e6c-f0c7-08da3364686b 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: DB5EUR01FT056.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2783 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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..9293e6b36c75 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 if X86 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 Wed May 11 15:39:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henning Schild X-Patchwork-Id: 571971 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 A4E08C43219 for ; Wed, 11 May 2022 15:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343837AbiEKPjZ (ORCPT ); Wed, 11 May 2022 11:39:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238411AbiEKPjV (ORCPT ); Wed, 11 May 2022 11:39:21 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2051.outbound.protection.outlook.com [40.107.22.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4770295DFF; Wed, 11 May 2022 08:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V9nJiINBTK4EudjPL0xx4sxfvXj2uZ4TleAZU37IT8cPwdrj7Ktx47rqndMUvQU2ginnf6BPNS7Kt+Qx3AvWFlLhQcpcZkU581WvtjHD8GEzxdRNn2T6rUgmAhhEgwoWpJy5w3xPmx3XqRRdsq9oF2R7zJt1beyL9/LJkmljDLrHaLSS1YT4kARLd6FOOCCtFCSVwRXSaICx0G3mIS+rixT9Z8JjKKH8bj8Jy1lbxQprDOk48vc+w8kGBZdtiZEw/LnqiE8N6DTRjGFNuKAjywQbl8+rcfJo7Tgf/+L13f1/R0eG77EPdTlJ6F0/CIAx6ksrHdzyKc/1lRmMNWkWBA== 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=h3RfU7qtgvXYTPWJ/5Zn3IiuPsAHXx5jxj2HKLH5RhM=; b=EAZ+GFj4SLuLXALJVJRHpxbMYTbD6UBRjaxdbyonrqzlglEPYex5n9tBgOvaJPUVZeBr/9LPZLSwOgt9VW3htp2QR/ve/YTnXSjs9Hn2tX+FZkyE+rrITxYT3JE2LJfHZP7DpUYUBL9812MKMqttQZxZBZAQt1ikre4gwn0Vb7lU/U1avz4Sx4oLOrK90Iltrm+MWqQF41uK3vRLjo++167Fpp8E3v5xUSE20rvXuM+YlAzKngJDPfu8fG7P5mHZloDFYRGL1QnPGgnIZHmn1140FxFr4wzD8JRdYv1PSh4vr7Ow2KubuEJYM1yQ6zui7PBxrXfrezOTDnaf0eh24A== 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=h3RfU7qtgvXYTPWJ/5Zn3IiuPsAHXx5jxj2HKLH5RhM=; b=i1e3mVCxsAkcPkL1Sm6jT4Jk56/R8jRRUmqX1iBMB9y65yyFpKjvTqojAVUHn6quTqxC2EiNmq7sD8aLAzZaJV43vQ715E7p5FMXskuQ4MBaY8oc1WlzMTFvpVtXxrm72ndcBVjtAfJGHBDSyna/hhwI0wR30nCE75JAu3J+GgOf00k8VD/kHg+9EA90aeecQEwFVz+gxJ/QJ6m1wJtKvIad3aCVvJWSFep+jpe0RStGp4BhUPE5kG+cKFfT+HRjcNJi4lAByI4oNgB3jqDUVGHQlSM5wNVzTBANUibLeUjiODmZHMzarRixNRCt2FjC9IevchmRVWYwqE2kB6PV2w== Received: from DB8PR03CA0033.eurprd03.prod.outlook.com (2603:10a6:10:be::46) by VI1PR1001MB1359.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:800:e4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Wed, 11 May 2022 15:39:18 +0000 Received: from DB5EUR01FT056.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:be:cafe::5) by DB8PR03CA0033.outlook.office365.com (2603:10a6:10:be::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 15:39:17 +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 DB5EUR01FT056.mail.protection.outlook.com (10.152.5.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 15:39:17 +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; Wed, 11 May 2022 17:39:16 +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; Wed, 11 May 2022 17:39:16 +0200 From: Henning Schild To: Andy Shevchenko CC: Mark Gross , Wim Van Sebroeck , Guenter Roeck , , , , , Enrico Weigelt , Gerd Haeussler , Henning Schild Subject: [PATCH v2 2/4] watchdog: simatic-ipc-wdt: convert to use P2SB accessor Date: Wed, 11 May 2022 17:39:03 +0200 Message-ID: <20220511153905.13980-3-henning.schild@siemens.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220511153905.13980-1-henning.schild@siemens.com> References: <20220511153905.13980-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: ee13a1a6-52e8-4313-03b4-08da336468fe X-MS-TrafficTypeDiagnostic: VI1PR1001MB1359: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: Ob03LfCVvbI0xqGPB17IpSN3/IhPikOIHwt6J7zAwyM1mzIM/eP2F2L5QnQgntictEY+tgVOi/JpeJuW/h3NOvN/3IVUaqH/pHNQIGh0AM1Oa+4bRR0/f6iukmkIisd+XK2Koas7axReTs9e4+9UP2JTM4hMItyvLsEM+/IwZNb97b4IvL6d/wcnXqaeDxGYKb/h58rW71AGA9J34VxuJRtuI2SE6TGaq2HeiAlNG+1+nqOwFPyv804mGx6gngZsX9SaOBhELtTdRQ8S7MAUvYqZMYLv26qjGp/m+GpiUyB2fC0W0BicNeFPXeM3OG29x7azoLNQzpUY+kbV9Eku+fsaTbzZQ262cR0eIE5/muExHZp2+UqDM0bhqeTZAGPu6NNa/SOVaB2VBkviEkOPOwOG3HoavsV7XvdACpGi6EbORHR8OeT7ezdO9ltMp7MtLWIIZ7feglsmM+2lBIh7iC62k6qP3ROfb0t3RjUQeUMYAkGFlvq5cwcvvBHnBB5Y8qOep9In1uriGjzEZDNq6W7ftMrokYNVWnSxMLNBRK8MjA8v4Yia1sUrc+mWI4hq0e4KQ3trR6kXdRCSROaEkUqEbr0wakKfy1JBMsvKXvqoFIiRy1RX0OxAI9u+5rQnxjSZFO3s/dY8y9D6qK8bQWqjpdNH1/uaLVMXRUyFTWtNj4FRzoMgPdmzEZiV3jA/ZwTIcgFwzVqTMoY87leEOQ== 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)(46966006)(40470700004)(508600001)(36860700001)(8676002)(40460700003)(356005)(81166007)(70206006)(70586007)(86362001)(4326008)(2616005)(316002)(5660300002)(6916009)(26005)(6666004)(54906003)(82960400001)(2906002)(16526019)(107886003)(186003)(47076005)(336012)(44832011)(83380400001)(1076003)(956004)(82310400005)(8936002)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 15:39:17.6831 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee13a1a6-52e8-4313-03b4-08da336468fe 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: DB5EUR01FT056.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR1001MB1359 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 c4e82a8d863f..643a8f5a97b1 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1628,6 +1628,7 @@ config SIEMENS_SIMATIC_IPC_WDT tristate "Siemens Simatic IPC Watchdog" depends on SIEMENS_SIMATIC_IPC select WATCHDOG_CORE + select P2SB if X86 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 Wed May 11 15:39:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henning Schild X-Patchwork-Id: 571970 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 EEEF1C433EF for ; Wed, 11 May 2022 15:39:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343882AbiEKPjj (ORCPT ); Wed, 11 May 2022 11:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343835AbiEKPjc (ORCPT ); Wed, 11 May 2022 11:39:32 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2086.outbound.protection.outlook.com [40.107.22.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5ADE985B1; Wed, 11 May 2022 08:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WKjZQxmJQ91QIE3UrM02HcFXkq+kQefm4LOAWHHP+XEgly7baWqX25fAnHAqWp3eh9fl0ayhFZ/DElbUWRr+3M6mbC9SyuwcWwe9qO0FIEldHFHiPagFL6rv+mZBp6xsWgfLRwe5eYODiq4bQm8LcnYuKmyqyHK7TkDtOxK5hLuizmDAGCaHLVzGI7VH3me1kPbf3oKgSwxHhH8pTEI8bDGagedjDGAA5Ve4E0gBch8TXF0FUIvz9ZjGP5pER0zNq2kDkxCz7g3EUbBToilrZ8McWmyf6ARONxSZEau212IKcVU7EoNy0lzk1lnp81ssWS3PAheR1jrO4or4q4rjYg== 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=goqs5nfPXTf8qmYTd+8/Rla2kcCsSbeJedL60jY2PdLRnWgNSiZ9Zbb3/tnrbqoa0XrCzx5WG0kD36qceaMdAcwVfQqjR33T5QbT7XAM2G+GcG9xuJA+c3d1cG2YdSVH1ATXSEgRvmmdnB6q2QQ64G9ggjQg6ilPdfe2PJF1fEcWlaAzShjgeN6UuoTfs24ai4UD4DqJtdfNLgAgV9ITA9VfHo4vp99hB5pqhMpLq47s5axLKfngKXeud0cDMkQFuSrme4I+zzzX0VoyNhRTve/Pz5BQJdoe2wXYXODdavt/UAxVHWZbZcpmePzNzc/jKfPy8YgO4q8B3y/4F6/byQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.72) 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=OA3PHT7/wTblU7+kyMW8+0kz7lJCq+hmhxGuspN86T80BBCVnuoJNfk24x7Lu9Sfv6ac60IxZQCsUdhN44gInUyCsHe4+THCF/kPpR+qmKStkA7PPg8aP7oCm5K6ywl+sj11U929EPYjdQBs5JkDNiMSyIXIR6GQeKyZt1PA003RWDZfZ/+IAwhV7NLI1kgR4W9nqSg+DOGe3zktIjaHbdQXYyiAQWnYTW0+yQ0FDjiBi3+EWc463cosA2oMJcHfU3nM1tZzrbXzIdwONdQ54mKq92alw3OmwKLxL4o488djsYxLZBqT6Gu5382P8EH5vj8jKjINsPSzOozMDzl2Og== Received: from DB7PR02CA0017.eurprd02.prod.outlook.com (2603:10a6:10:52::30) by AM0PR10MB2321.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:de::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Wed, 11 May 2022 15:39:29 +0000 Received: from DB5EUR01FT096.eop-EUR01.prod.protection.outlook.com (2603:10a6:10:52:cafe::d0) by DB7PR02CA0017.outlook.office365.com (2603:10a6:10:52::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 15:39:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.72) 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.72 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.72; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.72) by DB5EUR01FT096.mail.protection.outlook.com (10.152.5.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 15:39:28 +0000 Received: from DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) by DEMCHDC9SMA.ad011.siemens.net (194.138.21.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 11 May 2022 17:39:27 +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; Wed, 11 May 2022 17:39:27 +0200 From: Henning Schild To: Andy Shevchenko CC: Mark Gross , Wim Van Sebroeck , Guenter Roeck , , , , , Enrico Weigelt , Gerd Haeussler , Henning Schild Subject: [PATCH v2 3/4] platform/x86: simatic-ipc: drop custom P2SB bar code Date: Wed, 11 May 2022 17:39:04 +0200 Message-ID: <20220511153905.13980-4-henning.schild@siemens.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220511153905.13980-1-henning.schild@siemens.com> References: <20220511153905.13980-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: 649e280b-b55a-436c-d183-08da33646f37 X-MS-TrafficTypeDiagnostic: AM0PR10MB2321: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: tKIy7ODJ5OEjyPob3ou8+75W2bgoHi6ETQLuw9txqm+er8pXI4y+6AXqr3X/nPLOq8g+JOnh1epkPXICJmajMoXvu1YqtOt9zGJtNY4PycVPpDMmfr/KARx5Rc7K1BWfITevTSvv3WYNFeotAKKjuIJaHzigUMT7fWsBC1jCUNfq+aMnVU3mRCpYwj32YdhzAB3VfJu01J0G5D5a1r3z+wGghQ0tE1F9OqTY4Wa89xopkYz4klVJxWcO2NGGlwdQWvvZczeWCk0KDaHWDZq9/tY1UOnH0ETLYuQlL15OlmFIo76JB1dWrV3aj7LOhysKR1QO3ug0Y/yc90GpBERcOXGqitJLnNV/L7N/VCAeNB6LgdvgIaaKC7d0MpOs1vGC5jaHzuk6yEs0ieEHqU48kZ+vKFcF57lRooTmlQgL1OyJumSq5hAIP6VkATpVnoCz7Dvuz1HW6DC9XaWut9/WPYW2XWMFRmtPdNNDDoZ1N5HM0nqsCmlA+VjcpjhdwShHJU/yrmTGRDLkgztDa2uxH4SiPzqtKWeL3d3odajDR3fUfd4WdqLJjbcaVGLUTwVEdEC0U+BlhcVzDSsyvv2pblu6zn2F24XgdmmGUBck95ORT+JAKctVdpODrNmCrUmEeqzWgHy23A072CA+sPpJ5NRcgklCLlhHWOji3WC2n2Grf0G7+WaW21W4y1Mr/5X2cNmEULjhK7dXEpXrhgjvIQ== X-Forefront-Antispam-Report: CIP:194.138.21.72; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(2616005)(6666004)(86362001)(82310400005)(356005)(5660300002)(36756003)(83380400001)(956004)(8936002)(107886003)(1076003)(82960400001)(316002)(508600001)(70586007)(47076005)(44832011)(70206006)(4326008)(54906003)(8676002)(336012)(6916009)(2906002)(81166007)(186003)(16526019)(40460700003)(36860700001)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 15:39:28.1317 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 649e280b-b55a-436c-d183-08da33646f37 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.72]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR01FT096.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR10MB2321 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 Wed May 11 15:39:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henning Schild X-Patchwork-Id: 571663 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 EB9A0C433EF for ; Wed, 11 May 2022 15:39:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343879AbiEKPjn (ORCPT ); Wed, 11 May 2022 11:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343867AbiEKPjh (ORCPT ); Wed, 11 May 2022 11:39:37 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150053.outbound.protection.outlook.com [40.107.15.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB5B5986DD; Wed, 11 May 2022 08:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ji9R8mLQ0KTNOJG8SEClA1KtulbHnH6Ip5C8HyQfrQ7aIQjCdSUCrbG1zHE9br5yrD/6ZWbmJOqkfl+rpY7v1shKN2540VmsDt3UYmh1601AjORhfYgfzwrtMFO3U6QUwbsL1L3+ENf1yYzo8V0tRZttv+YX9lr/Vc7rylZkouRxmL5+LtsuOenxvEwZRz9PENHmn/6xgCWbhgB90jxXRSvUPK9fqznSgYKIScDH/YM3leblbkfasFZdKG9I5K0b9vcoXb477kl+4YJ+2YjPaHCx5lXKwKfQ7tpbfCa52cpIx1qdgHR1VBWvJ75etxHLlI620fcX3CiDdOdSpoMQoQ== 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=C67LZWsu1LSLQHL7KU5kb7ZQqW+0E9gYYYhWCoOKS2M=; b=Ob63NGokRz0cSdxPXv3pjxBDxhnJ60bcT1cs3WObt7WZ+/zaASlnYKIO7gWW9D0NkIJQzVYZp9MLStMW01H3CHtUaDffDtxjsyjmL2wS4eMbmCu6XghAP5o41QeezbBJSZaJ8FVhVQIctTvboA8LZ9fa35fti/DVfni8d2yvBD+ZG2Ul7kJYJnuBwYq2UOSMxQ0HCE94eaQjRo1+UdRr1NG/okK6YWN4iqT3s5ipa2Hm/9DiL6IoxZBBK5VAWzvD0l4qC35kUWPtTlNXkgD//hG/2dogrCAeOdYhzuJZ272m/9gWknu6D6Y7Ii39Jaof3KNVCCEZDzhwigObnr1LwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.71) 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=C67LZWsu1LSLQHL7KU5kb7ZQqW+0E9gYYYhWCoOKS2M=; b=fMEYROst85BHAE9J3hsxdmbUhGL0ayCCrqp3Tka5P/p6JkP6umwjZits9W6eQAqDV4vb5bLANnSu3ZEOttdfg+pyBWgk7Hk9zliv6WIWDwaVSgJ3d8U2k3RQKh5GBuTHGnV1LpyD59yJnKx0yYcsIAhqSweBqu5Jm+mmCQ+4kRasFg0Bd1IcvTSQu5+qEyz70xomglEzEa8yDHvBDdEEuTIAwwVDHmIGU75aReWS7zIQYZdVzwzhtKPqFlVLOdbuAPjH4igwAIwMf34Uovp9eg0Vudvta4ooxnNSC5ljoAuiZ0IWelJwXCk4m3Bz5YX9hyvQ63P+FII2E0EgsHK1Ow== Received: from AM6PR04CA0025.eurprd04.prod.outlook.com (2603:10a6:20b:92::38) by AM5PR1001MB0980.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:203:11::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.22; Wed, 11 May 2022 15:39:29 +0000 Received: from VE1EUR01FT017.eop-EUR01.prod.protection.outlook.com (2603:10a6:20b:92::4) by AM6PR04CA0025.outlook.office365.com (2603:10a6:20b:92::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 15:39:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.71) 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.71 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.71; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.71) by VE1EUR01FT017.mail.protection.outlook.com (10.152.2.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5250.13 via Frontend Transport; Wed, 11 May 2022 15:39:28 +0000 Received: from DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) by DEMCHDC9SKA.ad011.siemens.net (194.138.21.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 11 May 2022 17:39:27 +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; Wed, 11 May 2022 17:39:27 +0200 From: Henning Schild To: Andy Shevchenko CC: Mark Gross , Wim Van Sebroeck , Guenter Roeck , , , , , Enrico Weigelt , Gerd Haeussler , Henning Schild Subject: [PATCH v2 4/4] leds: simatic-ipc-leds-gpio: add GPIO version of Siemens driver Date: Wed, 11 May 2022 17:39:05 +0200 Message-ID: <20220511153905.13980-5-henning.schild@siemens.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220511153905.13980-1-henning.schild@siemens.com> References: <20220511153905.13980-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: 3debd758-f6b4-4b65-6b38-08da33646f86 X-MS-TrafficTypeDiagnostic: AM5PR1001MB0980: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: 7CNQwDm40+/VnH0/iN3FZpfF5ATmXjxY4acHAtP0NZoJ+cNEOCia5gQ1GHJHkXhRac1iR0xdZC/igPkNQ67I/nB74Xo8aMyNtihf1uvoyta39GmwcX0YpErtuKHvWaWBlUIqH0XyJPbxuONesN7TwbwZhlipgmUizZL1eqEymdADuYnswBxN5XAHO5V+iJdPfRVWr5quya6xNt/257/6mvE7zOC7DVDYVryfRFvVNypOWEUryazQGpTXhyRQPilgLBIkZD3SoNyj7ljArysEHydM4J6zRVTjunlMVPWVxbh+01Pm0k7Kg5Iu6Vobq9q6kvtL5Pk1p19iXannNgsq390ijuLrBJgO9Z3y9W5lh9g3VUi885j2iOU2eEPQ1Li0DnssdYdFjxMndRClxzOmv+VKlL3u6uWy97vgFqnoCwzXuZxd2QBKVNTYXWfkhZLB58YYMWzgZxRlTexdh0RpdYbB+Q+emhlzDQTwK633Bm3P15zayJqGyBy1bsvbBzqipC39E/THCuBeB0vcBl4bd9yBJbGVRk8xNE/HmdBWzy/1+sif5+n3cXh//vzQU79P5KFEhVQpXBJwwnKv9WlH+Q3HZPnusypsawFhbgRXEOaA6QWmaaTwfgkvrEWCSTbX/F7DAaaxKpOZYNLEwoTuZncFtz7Pz7EXaI9yUT2xdg1+/lfMc7ngwt8PueXPtrYVjwRWvoWNJjIAK23sSLcntw== X-Forefront-Antispam-Report: CIP:194.138.21.71; CTRY:DE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:hybrid.siemens.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(1076003)(54906003)(6916009)(40460700003)(2616005)(956004)(107886003)(186003)(16526019)(86362001)(83380400001)(47076005)(356005)(82960400001)(8936002)(508600001)(336012)(26005)(81166007)(6666004)(316002)(36860700001)(2906002)(82310400005)(36756003)(70206006)(8676002)(70586007)(4326008)(30864003)(5660300002)(44832011)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 15:39:28.6553 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3debd758-f6b4-4b65-6b38-08da33646f86 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.71]; Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR01FT017.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR1001MB0980 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 | 12 ++- drivers/leds/simple/Makefile | 3 +- drivers/leds/simple/simatic-ipc-leds-gpio.c | 108 ++++++++++++++++++++ drivers/leds/simple/simatic-ipc-leds.c | 80 +-------------- drivers/platform/x86/simatic-ipc.c | 5 +- 5 files changed, 129 insertions(+), 79 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 9293e6b36c75..9d2487908743 100644 --- a/drivers/leds/simple/Kconfig +++ b/drivers/leds/simple/Kconfig @@ -3,10 +3,20 @@ config LEDS_SIEMENS_SIMATIC_IPC tristate "LED driver for Siemens Simatic IPCs" depends on LEDS_CLASS depends on SIEMENS_SIMATIC_IPC - select P2SB if X86 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. + +config LEDS_SIEMENS_SIMATIC_IPC_GPIO + tristate "LED driver for Siemens Simatic IPCs, GPIO based" + depends on SIEMENS_SIMATIC_IPC + depends on LEDS_GPIO + 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-gpio. diff --git a/drivers/leds/simple/Makefile b/drivers/leds/simple/Makefile index 8481f1e9e360..e1df74fb5915 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.o +obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC_GPIO) += 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..552b65a72e04 --- /dev/null +++ b/drivers/leds/simple/simatic-ipc-leds-gpio.c @@ -0,0 +1,108 @@ +// 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, 0); + if (IS_ERR(gpiod)) { + err = PTR_ERR(gpiod); + goto out; + } + gpiod_set_value(gpiod, 0); + gpiod_put(gpiod); + + /* PM_WDT_OUT */ + gpiod = gpiod_get_index(&simatic_leds_pdev->dev, NULL, 7, 0); + if (IS_ERR(gpiod)) { + err = PTR_ERR(gpiod); + goto out; + } + gpiod_set_value(gpiod, 0); + 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))