From patchwork Fri Jun 10 20:23:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12878087 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BDBFCCA47B for ; Fri, 10 Jun 2022 20:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Hopn6ltKTFYcW8ybij6diJdFQ9rFL65Jw28El8tUECk=; b=Jki0XuqDMYh9NH +O6JvLbPqgjCXYWNLVMllNo/hu9PguBKJlopiuh7zbyzwTBAFF4u7U2Zb4pyC4kxJVcB6zOZoLqGO ctBlIr7iOaOjqdE6+CzwxbqC99oXzR+XfM6ijcF7CFVF4lc7GSmnqQzBl7OBSPII2HQ+rSPSKYLmS MeGg7gOmo4BEDhQLcnfH5MBarjJHA09gZ5RYQQRtZEBi08SB50476aQKUpAW9IwFzzJ0BY3XHQNuq nKkAUPLFrAHq1F7gqO/59kpMOQibEu1hMAis+R+huy7U4N8iiQmm8+KKCrte5K45ns6/JPiNEloLq eAXNphG9XE31OD8G2bxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlAj-009iEX-PC; Fri, 10 Jun 2022 20:23:58 +0000 Received: from mail-mw2nam10on20707.outbound.protection.outlook.com ([2a01:111:f400:7e89::707] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlAf-009i9I-Jf for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 20:23:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EXqD7K0IzzA+WAEqYXfkS0xR/JMH35igw9YfhdpwHtC/ThehsTglq4DVpZlszL7fPbVAHdziBmE+RVcdO1u/6e+xekp4VZsRZydoEXludVgCCILYRF4TjmgjwT+Bpr1Esh9CxIGj3Ni5ofdhgxXnUCu1iVRNIXcRrc20Cr2oEPKMREQhVJO26QAHV1M6cPvv2ENswhvCPTDwpmvvrX2PxcIxM46Tpjtf4c/NqkRWktPv5wOysbIZvLceve04ug4GfRMUSygi5dvpf3iI+R4IdFSfrhzJjlDwhXXmGpQ9tEnygjVvcM9c30xPw7Wv4vwPVmlobbON78IbrMYe7w1BpA== 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=9x7kWRSNpD+mSE0GFZSzfzBcOugNaKgLSOz2TG7srtE=; b=Z0KTs0m4JrPM3f/HSJjVaRbl7WkdcwLOEOR3nXTyJrTivwQ+JQgMlEcMgMEvm9vV5WmMQyWeyiwn8E6eBURP678vkd8g0q7zkH/mTHoipFFc2vdBaCR6ohAYU6mQ/ptVhTzRZx/cAYMp0SMzlMA7/GGEJztP2g8YTy97YfJ1gYOJqCexwNpB2W9T8+PF0yzmRrCTcUpMR2PJJD/RTfZTuJ+6Y3pI+2xKKB89z6V4JSwi1fZiNgeW38/ahqXuo75s49iCnq6Rojn8CckpGTtexP8xpNp34+J1dqGnhpUe2N1c/fTlOAPsijs/GojNFaYo7+byr9iXfex9zeLCMSrGhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9x7kWRSNpD+mSE0GFZSzfzBcOugNaKgLSOz2TG7srtE=; b=EHRqFLdpUFRwT4INPqsryuIk5pE418HYV70RivHfz4/2BjImrq9jcrGhMyCAkxbs5PiBqW91U+0TXR0LDAyibc3CX4UaPKHBWeGoSavs0/M9JxJbDZfB16pWOx78C6eAoV4RMNwVz0IO2Tx670tWmoBSmfsMb73JvYcpX/3uPq4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1629.namprd10.prod.outlook.com (2603:10b6:301:9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Fri, 10 Jun 2022 20:23:46 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f%7]) with mapi id 15.20.5332.014; Fri, 10 Jun 2022 20:23:46 +0000 From: Colin Foster To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Linus Walleij , Wolfram Sang , Terry Bowman , Andy Shevchenko Subject: [PATCH v10 net-next 1/7] mfd: ocelot: add helper to get regmap from a resource Date: Fri, 10 Jun 2022 13:23:24 -0700 Message-Id: <20220610202330.799510-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610202330.799510-1-colin.foster@in-advantage.com> References: <20220610202330.799510-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0246.namprd04.prod.outlook.com (2603:10b6:303:88::11) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 409485c7-5b1b-40f5-d8c0-08da4b1f1e91 X-MS-TrafficTypeDiagnostic: MWHPR10MB1629: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: j5JVdAmMpAvQbvyCu6E/GEYkIVWwmYpn5W5ni/RJDOx3gEfgrmhN1shBk++4sbSWUmuSQ0sijqtkPYneZTFA+w/FqhLgZsa7mCr1UPe5CoRhPaW5z1sRYS6nYpGihq+Mi8mp9fn3CZJ/yGO6rMB7UpbXgeEfY9bh0HTH70mW63btWb/ZfoZeRrn2gKorjPHV7xh1dPdLLQbJnCJCPVVt4ye7PMuGoUD9cTiguJ0gA9Zfr63oZT9aozxMy3XMXgiyB2Qq1ytgSF14tN+LpAx8f8joQkGWNxbhDzwFjDud0Ww+QQLc1Mq+xu0f26R5g1hOpmop09KbDzg3V0k8oMbBVcfX3jducVTokm4PNnCm+5P5aYnyj6kLLINVH9ZXflmjhRj8WbXqxC9RKmUrSIhMMXFks5ijGbRKu1LI4RLmXmkFclQeO/H5DB3IWCrhJ3y/bG8v2VaTfL95dekPakxB68EO+00tH29aPfIwq+Clgwt76h2xQmiTJN11NoG4D9EInWQ5nMgoz8AYnf16Q978aGwf41hsjehoZv5y6EYfHo6Zm0ryC+K2oENy8CI2pTTN7FwFzl8wXmWANeZS8K3ILF0ARlIi5HMx++Pkr2AfMgxG1/FbJin0hSnSEkIWICsr+OBnirTkjbOQGDlf5Jc90x5BSOEsn8S7tYs5hXC/8eFixeaf5hdqawqUVm+YXsxfzOXf2VJg2wHEUs3iCxu49w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(39830400003)(396003)(366004)(346002)(316002)(83380400001)(2616005)(2906002)(1076003)(6486002)(54906003)(8936002)(36756003)(6666004)(52116002)(6512007)(6506007)(26005)(186003)(41300700001)(86362001)(44832011)(66556008)(66476007)(38100700002)(38350700002)(5660300002)(4326008)(7416002)(8676002)(508600001)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XzekJcFAMJdjonIO5mbRqOTFxvCoEh1uA0AUy7GDIVzNIpCIBXjzejjl28k4PjDUZHJpipaPffGQlP3OsNzl0G5wPBP4+V581YcgmYroJN2myl2Z9rgqw4EYRUuS02iwXFajxyNtPYlBowq0S9+eTRrkLjNtDsoFsYXABiQ114RAhv1BIMrl15uhkkJS37EDVtXZ9u2QQtM/joW4Wcdd+hqWFhcVcugpa9k37525TphmsvJBS0L4rH+hP5nKl0euBlGRBM9JJOQRfn17WhNFz9zYFDR5HZuUCoAA7eRTHj295PyP9D2a7fr6MiQucOvPyTVWZ0DP6/Qs6Lp7qLVntPQpqBff1Dm9W2mVK2cDpygJ4/+dBb77In68pUWfEoLhAem79wt1OPS9dUe/Dm49WPzTfUZOhWXpAWwB8fa0nGZXB3KZnJ6kuOdoaPHHmuyySN6OhBheFGNdobostaStW0JxyVcQcoMrnmpCurGmbtu56Gm1WTegodB7SEIVXp9rOBIDu6UBtIhLy58FGxNnci8nK0zSpXaGb9zcESb4tWQIL/BGy+AzTZIgXF3TYaSf/z/4Oli3vt6hvdow+Spiiz5Pelhu1OqM7wyc4QRTy+6OKh4IXvm5CIJO5euJlDcAaoCUHB+TgzSUNCQmexYEmSIbK+Uj4/N695zgVOOXpUSmoycFsfEkPHcHVywwit1nc5dThXpMyW7T0chTGUlP5cchdXk2vSO3mu3YbUbDIyit0+yRruCZfGWcOBcL4ZtzPt/G/J8bsRF1flSdnKWIjhswYM3qr+6v/kVzMAOKV3afQ5uo0oVMIUynzTWWtUArjB1Oba9naf2l8apODzX1VHyjvrZIi5G7kyvjsRwdqiZp7knORU3hITA6Fxijekt9a54G0cTlmuZ/JTWC/09fWgoYmj12o9l4/bf3qDabc72Y49NdG5YdVcc/S39AEbPbQnMeTJSicDfocEcyvtB0t0f5a30fiK79MnqnUysvufL4RH7uFv9nQ6iKcZHO2v7zkFt87a5xzPsx/Pm0Fpnag0kw14jlTyz+Uh/2IWXEJ5bwYQFA7b8nmUTh+n6RIawa+6t2LPifhZ0g2+BF7pIVqojBOUiEm2Bm97F7AfcAcFtpgigioQGocw0Thn2zPyS1R4j3/mBfjOwp8w0IWHI1vgJ9eCFg6/rnzQToWhfU6zMO2PpDygnxweg7UrhcHbwKHMaKxtK8RjtPQ8X5IDbog67xwJ2Fax3HLbR/LC4JnUlhmMWSYPIKxIECaC2O03VqwMe/ampj7Nnvgo9li3INXTKKSDOlxcLCX3/Bu20elt3xLUppessszYImK7jmiXb3FXH28uOtEXgjJKVfuyOrKeNwVnrPtLIV8+FbZ49to5P1ZcDPfm5Rz+j6EMQhDCRueog3d7TgxAXqM9/4oCug5NUqjxwNMxD9zmjvxuWz/us2qVuaDUGynVaddyKeCKi8DCbIYbUkkW/Uj2jlWx0zlt7Re9PDflz+AFj8bxLwH3ox1zu41Hm16TAX6lep02JS7CP+3ncUAD/ubE0sETm3BAarypImmY1HfNVj/jX8wyx801RxebtlMBHPV9i2xOBNC3Q/fE/YF8UCB6wPl/UGIARl9D8F+1TUacBlgGhIsb9+vQS8Rg6fwDvRFZPz6Vsd/AHVcgthNXITkNNl0snzWc8jBtGjNwRcveSYuN3RtX0B5BuY8oWzAaRpWApi1myFmAsgzA//v54fBVZ6/7+avsfxv3jnITlCqSkCwR3iTs2tcwUwZYo6bcGguXnBYf/Q X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 409485c7-5b1b-40f5-d8c0-08da4b1f1e91 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 20:23:45.8259 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JZAfrfHAfR9freUzlaa651DctPLaYAOlFb/Bo8Vh1v2h5xs7V22eKJfLWrGns2r4hthJQFOrAomqKDtNJN2peLJkKq1i3YXqAd6oFt/3cjk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1629 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_132353_818207_3C402849 X-CRM114-Status: GOOD ( 18.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Several ocelot-related modules are designed for MMIO / regmaps. As such, they often use a combination of devm_platform_get_and_ioremap_resource and devm_regmap_init_mmio. Operating in an MFD might be different, in that it could be memory mapped, or it could be SPI, I2C... In these cases a fallback to use IORESOURCE_REG instead of IORESOURCE_MEM becomes necessary. When this happens, there's redundant logic that needs to be implemented in every driver. In order to avoid this redundancy, utilize a single function that, if the MFD scenario is enabled, will perform this fallback logic. Signed-off-by: Colin Foster --- MAINTAINERS | 5 +++++ include/linux/mfd/ocelot.h | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 include/linux/mfd/ocelot.h diff --git a/MAINTAINERS b/MAINTAINERS index 033a01b07f8f..91b4151c5ad1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14352,6 +14352,11 @@ F: net/dsa/tag_ocelot.c F: net/dsa/tag_ocelot_8021q.c F: tools/testing/selftests/drivers/net/ocelot/* +OCELOT EXTERNAL SWITCH CONTROL +M: Colin Foster +S: Supported +F: include/linux/mfd/ocelot.h + OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER M: Frederic Barrat M: Andrew Donnellan diff --git a/include/linux/mfd/ocelot.h b/include/linux/mfd/ocelot.h new file mode 100644 index 000000000000..40e775f1143f --- /dev/null +++ b/include/linux/mfd/ocelot.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* Copyright 2022 Innovative Advantage Inc. */ + +#include +#include +#include + +static inline void +ocelot_platform_init_regmap_from_resource(struct platform_device *pdev, + unsigned int index, + struct regmap **map, + struct resource **res, + const struct regmap_config *config); +{ + u32 __iomem *regs = + devm_platform_get_and_ioremap_resource(pdev, index, res); + + if (!IS_ERR(regs)) + *map = devm_regmap_init_mmio(&pdev->dev, regs, config); + else + *map = ERR_PTR(ENODEV); +} From patchwork Fri Jun 10 20:23:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12878089 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3B57C43334 for ; Fri, 10 Jun 2022 20:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yYeYGqNLEUOXDRse0Td4CNxMQYVFvlu7rihSywj0mL0=; b=S3bcyY5h2U7FIC vCOotlGIGFrF0zkkNXMWLOKq2B2TbPJYtbchdgLmLjHi7JDePns+873IRq/X3xOEMSRiJdOACl7bA 54QeMm8OIX1HpMRKLKfeidL0L4y9KJsXGKPQlHkzYCkyJX+d4bvz6NdaRgovLy6BMmaoakAUIpFqk sRZoFBXmmu7r2imM2WSmOskuvmVi+om2ZtIGd/vj47t6cuCGc2WXvFuc5WKlExgtxmFIwFBNTqkws VHDWcSbx+RhW6PGy9oKoLUimi+JJh8Ofyhwjlo5cDYlvhZBj5aYx4n0U8TsdCwtePwqJIB4KcPL6j Hb6pe3V2wlTrB2g1V07Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlBC-009iSC-7F; Fri, 10 Jun 2022 20:24:26 +0000 Received: from mail-mw2nam10on20707.outbound.protection.outlook.com ([2a01:111:f400:7e89::707] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlAh-009i9I-D7 for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 20:23:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hoYFdk/O9ccSoTWM3FxoxS6xji+zXKF+F4GJzEc+FaXXeAf+ZdL2TNAdUO554QPXOKU8rL1Bhc3R8Hk20y6+GCLpL/O08s0JNRraF+fYoDK0sXEQhkuOBMAx6hUR4ZlAtpSIz/ZLSb1a8GZwnFC2x1PsQ7y70mHD8RTltgZ4XhJspusYUKjl1Rw0g8U7mvxNL5Bl2Zzm4/T739TU2dfi6hqK7fYhIF+KuxmWic1RRunhRe2QPItlP6lUMZ1nMcaq5v24cC/Lv0Qc1/G2mZmDKo3k59+d3uIOZw8ZwMELFs+FRQopZvz/aQQBVjLktZ00s77MjOLmG57nmIGFXQTVXA== 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=b1S5ylTNgu22/DjmUQDnVJgFf9sfgio6PxASxNsJ2J0=; b=hy/FxnalC8W6RhJ8gwhmBORDX0/Gc5JewGWUhyzbqB7B+rVjqiw/tyfL9xkUN9tgq/p/VhYSrvEJAJ/ampkXk8GQatHRfRQXhSDyVyIofYpS8ceM51/qF32EO6GdnZFY6SudNx1tlyI6x/TGiKxYby787dSLYQ6TNkax0bQ4jQ0tPl+PYFwsB/0esVyCy1qZor2uplQgvPmmq7sJF8i0Gx7IqZaRrFSFUkjQXaZX5fALKfwTVol3TWNa7g3wB/5oq5/tXjSEa9NlY0r9Yvv+jMJJwR1q+dUJs3RyZnE0vWTb+nRHQeyR8gPZnERt/kBvlqCwyrrEcMZWhL1p/ITXUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b1S5ylTNgu22/DjmUQDnVJgFf9sfgio6PxASxNsJ2J0=; b=jiqmnOtn1ImxosllMdIg5f3wb7h151xOYUG9K6JFfmJObBAmzYKP9NYJ1sYucWcq/11OcZY8kenUYGljP5jmovFOzjBW/g5nCSFXqCFGYZ1Ffv8FkQSeWA3Pjj5jD0L8Fb+XsEa+vbfjlN1tyXpAYy5NW+PM1TcFVCYWX5NTIls= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1629.namprd10.prod.outlook.com (2603:10b6:301:9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Fri, 10 Jun 2022 20:23:46 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f%7]) with mapi id 15.20.5332.014; Fri, 10 Jun 2022 20:23:46 +0000 From: Colin Foster To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Linus Walleij , Wolfram Sang , Terry Bowman , Andy Shevchenko Subject: [PATCH v10 net-next 2/7] net: mdio: mscc-miim: add ability to be used in a non-mmio configuration Date: Fri, 10 Jun 2022 13:23:25 -0700 Message-Id: <20220610202330.799510-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610202330.799510-1-colin.foster@in-advantage.com> References: <20220610202330.799510-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0246.namprd04.prod.outlook.com (2603:10b6:303:88::11) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89e10663-40fa-4d98-80fa-08da4b1f1f1e X-MS-TrafficTypeDiagnostic: MWHPR10MB1629: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: YhGCsM40uNuRfDJiOLdyHKzgOSNaiV2ImclJTblFEcIIS5HWiWVO7Z1w4+FnA+QfY+av6CF4yTywOZI188QzZHznaLEimK0mqokmDFC3zuOb/Tme7hz9DJSoQdvH3kaL8oMZeBw+z+8hwy1xwcGVS0dlEYt2O0tBdwNzp+TPRgbioSl3kn9rbbjq8zGosCK206pq+5pcj51h2hVVa7Kr8DyB8SIgP7mh63PLuGGsjcubQQO+gbVjC981UkYWukErgoYxiDAocgrGk9NjfgyVZt2xGreSRiAe1DuYhG2zGir6kECCQXZ2NVzTphVvZhMw+i2fHqVH1p81Ij0CDudjZWYdPEIGOtFKgs8VlKcEuxEc6C2D+HIfTod+7dHRh0xCiRqzPaB5yBfuuZucALchx+iwPAB4i9VIOP1R8KGKLze/eRtOJ5vqwxjMSHSwSeFCgoDGN0iqaYFznFl8gEe+FMZYFffl05yJ2Ru5UKOMp2Hzvwug+kjM1odZZ6Yo0R+4djhh28Y55xswZiQfJpAg3Tahv++0zqDiBpS3cwT0rVByPKqE1u8W1exK9i2G51or4vt4W9zsAnMQwJLV5LP394dt/xoG3jH9BUHEd6KRahm0lQm9cX45Di9rTxd2PXOq5pxb9D5N3PxG4dzrlWbQYlndo6MK0ldc3djMb3BD3rnxLV1l2xarFNcb5Em1mvMoZCysgXoHRyT+Bj8a1nBP/A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(39830400003)(396003)(366004)(346002)(316002)(83380400001)(2616005)(2906002)(1076003)(6486002)(54906003)(8936002)(36756003)(6666004)(52116002)(6512007)(6506007)(26005)(186003)(41300700001)(86362001)(44832011)(66556008)(66476007)(38100700002)(38350700002)(5660300002)(4326008)(7416002)(8676002)(508600001)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZQ4x9L0yROMU0cC0yGq0dE4gHB0UNMLAWjD4tUIr3nXULlXJdyqGtRrzSqP25wJN8PspVupsaEvTAydxuYXUhFqCWskvqfnqAuMP9rZoJplqeCJygIkscxIAUrWk08u9T9cw+jDg7wGS1IaMReAIS3UpGZRBgybP1OwoCxCQSlLKsXEI+XKDo1tHKeCJ/+2lWgVDxjcLXDOM7XfAvB9ZqsRJHXtiAuT0oUdFy7nNjzPqhz419TSquxbjsBrGotW2G7gyiQ0LBOavSjY2eykjZ7TUvNptUoZZkBjtLwgxZ+Rg8xAvesz3HrhHD1LBd6WE7crxQODTOVBZDBbq7jCUUxY+7/yXmuYwFaQU9TwJkSo/tsUC4i/a6HnXdrqWJ/Xjk54GUaoJvHvmJul1RbDW38TB2RqzvKRck+PIjnJBrrWe7/bcbGWS2bCRWOYuFHM9fBBwEAtTM6piKJeeJ3gCPfrGNNIdaPkUPv9bQXjS30jfYkait7f2jHOAEkVFDSOFM8ZnQEaxq661ni/ZVI3bsg5HHO/uvoYSgg0h9FE9EXP+mVRpm5wXPywyjFXRSuXBIn84jWkPpNmE2u+cDyxReQRJSJiC3J1o3cIrz3o90rVh3ciC9gR9SdIxWoTFaqxlY7AmNrckeHlrtnon4INeytRQ1vTAEM9A4jYkz1L1RqaKe28CystmwAmTbc+H8x8inrPteBfjt/IWNuA3cgfnWldsI7x0mG79szGAP1DTleNjVGhWTFEiTpKY6NA+fxI8xmBSum2iHHLCne1pStjrbpWfI2CAH1e3I/UG3zyVibWnLxQSoVoLYHWa+vbE6f+G6GW5zTZnlijqhHVMWsjdRBgiwxcX0f85aeY8vq657HkUWRSdbA+/E4TbC/eN4qftOYAWKAdNM73yKLz/l48ikWjuAbmwuHbnXzS9kJRwlnXvmtavHRiXk5/yXlCpHaYP19Drr+jSP10Ep/Ttfy1+atWDoqM0K1mSFPrh3VR9O4K/Q18DN4UlO+/+fLkgDi8MpotIo/kOUKr20uv0TyG23OwwcESm224O/n/rYyKSQzg4n9WopDtP6P2wxIBGicJqJnS4BHwLTK5a49kknVqddJWqnVW23eZ47Ne/JksOpmk5JjM6/1jtaDGCT0zs3e4tq4e3naUXSDvkeli+u4VxAwg91bdc1nmDQIB4fV8Vaie1b0sOFqDwjCpYuSt7mQzQll1VF354wD1FK4h2GQtDatkCqlujek0UiFsGB4+oh+6p+Ogvr4lJ6HtrBPh2IRCBiwx0OLbJVby1fgZH4NCpKKLsP4SVwd2R1yhOvryO5kq3HY+X3NA8i+TYfKmos9FgIeBsJ24koz7JUcp1onc6FHD/+3tEho6tezdZmdwyNR6Gj6GtTThoQwtr4z+EXe2CqMp27zwLNnZnRmW3xla3J0SFpYFu5gkUGMtaypfhu5bE102Yfhy5dXyhc3V0kzvK7CyjhjuzyRpALOwIBMOxAtLXs/FItEvaNh4g0i/BZaLq7Sj/ZvjFADf/NuxRPBHVIZW+TwguhZ4Osnrlv7gnTPx5UpNI2xq8/zC16h4xdcP1FUEjF24HjMVOZTwpNCkXtbzrwoAYKNaxYypkFG1TEBWqWghqCKh5Jq5faGyMe51XRoe048LDmqMhbctv4VXr/gNyqSxpUCGYWyjbpKEdcPp3HCWjOAwePBD+wtllZBJDbGqllcHK54obOD5WSz4rHQ8tJp9hGczK9y+SiDb0PxCaL9ohoycq+VgvG6uhoJTUBT836hhfYS/ii6CzBjLG X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89e10663-40fa-4d98-80fa-08da4b1f1f1e X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 20:23:46.6383 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4TgNi6axHUkrTbxqr1TPBgFfPePk4RbE3tV4+Ymv213kNavdHpIrbf3DmmTrJ1NK4MgQPdDV29LBvlvlC0YVLF2dKIz2AYV5z4/101IeWv4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1629 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_132355_473643_38990769 X-CRM114-Status: GOOD ( 18.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are a few Ocelot chips that contain the logic for this bus, but are controlled externally. Specifically the VSC7511, 7512, 7513, and 7514. In the externally controlled configurations these registers are not memory-mapped. Add support for these non-memory-mapped configurations. Signed-off-by: Colin Foster --- drivers/net/mdio/mdio-mscc-miim.c | 27 ++++++++------------------- include/linux/mfd/ocelot.h | 2 +- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc-miim.c index 08541007b18a..cd89a313cf82 100644 --- a/drivers/net/mdio/mdio-mscc-miim.c +++ b/drivers/net/mdio/mdio-mscc-miim.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -270,43 +271,31 @@ static int mscc_miim_clk_set(struct mii_bus *bus) static int mscc_miim_probe(struct platform_device *pdev) { - struct regmap *mii_regmap, *phy_regmap = NULL; struct device_node *np = pdev->dev.of_node; + struct regmap *mii_regmap, *phy_regmap; struct device *dev = &pdev->dev; - void __iomem *regs, *phy_regs; struct mscc_miim_dev *miim; struct resource *res; struct mii_bus *bus; int ret; - regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); - if (IS_ERR(regs)) { - dev_err(dev, "Unable to map MIIM registers\n"); - return PTR_ERR(regs); - } - - mii_regmap = devm_regmap_init_mmio(dev, regs, &mscc_miim_regmap_config); - + ocelot_platform_init_regmap_from_resource(pdev, 0, &mii_regmap, NULL, + &mscc_miim_regmap_config); if (IS_ERR(mii_regmap)) { dev_err(dev, "Unable to create MIIM regmap\n"); return PTR_ERR(mii_regmap); } /* This resource is optional */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + ocelot_platform_init_regmap_from_resource(pdev, 1, &phy_regmap, &res, + &mscc_miim_phy_regmap_config); if (res) { - phy_regs = devm_ioremap_resource(dev, res); - if (IS_ERR(phy_regs)) { - dev_err(dev, "Unable to map internal phy registers\n"); - return PTR_ERR(phy_regs); - } - - phy_regmap = devm_regmap_init_mmio(dev, phy_regs, - &mscc_miim_phy_regmap_config); if (IS_ERR(phy_regmap)) { dev_err(dev, "Unable to create phy register regmap\n"); return PTR_ERR(phy_regmap); } + } else { + phy_regmap = NULL; } ret = mscc_miim_setup(dev, &bus, "mscc_miim", mii_regmap, 0); diff --git a/include/linux/mfd/ocelot.h b/include/linux/mfd/ocelot.h index 40e775f1143f..effa4cc0fc43 100644 --- a/include/linux/mfd/ocelot.h +++ b/include/linux/mfd/ocelot.h @@ -10,7 +10,7 @@ ocelot_platform_init_regmap_from_resource(struct platform_device *pdev, unsigned int index, struct regmap **map, struct resource **res, - const struct regmap_config *config); + const struct regmap_config *config) { u32 __iomem *regs = devm_platform_get_and_ioremap_resource(pdev, index, res); From patchwork Fri Jun 10 20:23:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12878090 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACB26C43334 for ; Fri, 10 Jun 2022 20:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6rtq5y2J0Xg9h+f6VOJuUWZ6n8WagFUn9LgxQvXjjic=; b=p2Y8g0Oc/W9foZ mfV16j5YFVjhe3ghZnkmXMYBULLS642mDs4DGBqAgDXd0kfC0Tekj5b1zpl85ZDTcMIh9Ex92Gxmp 2anjpJacfImeuG3Ltazl42/AV54eBWQ4SS3BzNiaxPCjuCJeXyNFknzjjODY+nDSZKSZXXwWVyF9j mITyr1dd6eRTeAO9tPOQhR6IXwS9R8YyhADie8LALRTMAt5KJMwGMo/yN7cG/a/a7V3x5GgKFoehL CX+79IVjzgeuNz8BTf6WLr9fBfbqRp4Cv/IbpvzSXIq6c9K+ghfAiv56CJkIJU+Y/khtWAcBAX4uc eZsBT3nGAD62ca7XPgYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlBQ-009iY1-ES; Fri, 10 Jun 2022 20:24:40 +0000 Received: from mail-mw2nam10on2072f.outbound.protection.outlook.com ([2a01:111:f400:7e89::72f] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlAi-009iBJ-Jw for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 20:23:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cb05GgOWAEk9aYvEXqtzYoBM+8Pgt8SlNF0JatVG/XPW2PBVroy6TMz4FyrvxTd8ZonxJquM/e/11QqPbuV4z5jcpNJgBDkRdXuB/PHwStCxVamYfLtTmpb2Y8s9AsxxOzDqLjnsSDIiY/hNXuG1LH6xtq7bGHz/2gKhasJtMMBNvVHChLgpVJpjrqsqp8grkxFA8yeB/37LRDYLiFs4Ri8ele1vdLLYmA/nWK3s+Nu/dmZIU+jz7LeeYOUMXXoquwAq5jNhEocB5MZXZLZmOy1y/OXmy/Xa4FLGmzIHcyzKmtx3KSFPAMqmZ8zQmxURR+MeU282Di3N+RrNUpEklg== 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=iAdLj5PQta2TPxzuQkdcF5w3vYdR8cuUjFKNyQFjmPE=; b=LCxKkfJQt/eYWGW/JnhJxMWtC1lN4rPCam5xYo6U2SMpFSR+b7ptdd5FLDnSrIxAF9nySU31fySVUSuJqZCGGF3U3ZPE+8kL85CZblWocpZnOac9IJ3kZRogZciCemdq2jobWpg0uJ9X/QsevRfHp777o9Hzb+7xj31G3tP3n4eZaqQNOIdaLroprFwwGW1t0+GHfABQBjyrJoxKWeqpNAXv8x0G9CYETjsD/v94hrh+//hBxpITHICEFzzKwbZePQNt1XbF2+vOkA0wZbHkRnDg6j9ALpY4cMhKozq/WO/Bti9gZaVGzbpIBfs4aVrFK51QzIAgduhqO4sHhZq70g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iAdLj5PQta2TPxzuQkdcF5w3vYdR8cuUjFKNyQFjmPE=; b=MT80FS7hTF5V27D67KfSSctTzJYupbHb8O5QLPJXOeNpF8LzBY9R9m2Wxqr/8DQ8qbqRGhQaD3e6z2uVbGW6HrhRdG1J/T6NPfzTr0F4VlwCND9ZOrtKwArEJbg7aWi8k14qLbAFoUJm5BoaT3Rg5voy/OEMRf9OAw8u12kBxFQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1629.namprd10.prod.outlook.com (2603:10b6:301:9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Fri, 10 Jun 2022 20:23:48 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f%7]) with mapi id 15.20.5332.014; Fri, 10 Jun 2022 20:23:48 +0000 From: Colin Foster To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Linus Walleij , Wolfram Sang , Terry Bowman , Andy Shevchenko Subject: [PATCH v10 net-next 3/7] pinctrl: ocelot: add ability to be used in a non-mmio configuration Date: Fri, 10 Jun 2022 13:23:26 -0700 Message-Id: <20220610202330.799510-4-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610202330.799510-1-colin.foster@in-advantage.com> References: <20220610202330.799510-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0246.namprd04.prod.outlook.com (2603:10b6:303:88::11) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 32082673-f455-42c0-9c0e-08da4b1f1fdf X-MS-TrafficTypeDiagnostic: MWHPR10MB1629: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: avW/4DYqJrIZ6mgMBnxfPwo4qywPoWvkEo6maYYJyeiIWF3XQ7Bfwdg8FtM/zYeDDvQhb4ganjnOUB1EuN9e+Ju2ftob7/6KyJlq6NpMGbvDnMJtX7waLrL4AuCKXBQvkz9iKv9JI4vYw+80ddD8mycc4VihyyXRlx5iYy6PFl5ajoDJwMPy6AtP9uIQ56EhU/M1PuOtoIqvBYDCSs5T947b/q61R9pdBaWm8B+K4NSF72CUDRTXnAPGjHnnlQ+WAoqc4dULcWTI+CgSfjCzdBOtto2oBeCBV9sP3whIK2BExlwJdwqrEabP3WpmD9Q8N8ylyETvlKCJfweGaCpSCez5BshjKUTBdegic4b7QZOkQ+w5z3aYVGZpAPBHHp1KSyzYzhf4NC7LRPwpVdb/AT4vxg9pG1c40Wp7gZr6dNZb7sx858dYNMV9KzduCIWXLPVSiqlRo8vcxtvEhWrR5frg2OcOBhnagbhxm21WLU4/gLns8Ktfo3I4n40CaTRv4ky8A0aCGxpZ9XIT1zwrFN0/dZ+YJC8kfbuC1Eb/oyRgIYOoxzmX1q0da2sHpu2P4fwSn41Ou1OAUVb0RdVSe7xOly3fgOSK/VIj+OfUiZO1TauukDo/i3uyVbZloSTZqzI94guvp8Oj57Oj/XjrZJE58O59FFgFsmj9YagGcakoRFCI8Js62lbWVPqR+UkDFa9L1VMVGC7pk8FR9JXKzQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(39830400003)(396003)(366004)(346002)(316002)(83380400001)(2616005)(2906002)(1076003)(6486002)(54906003)(8936002)(36756003)(6666004)(52116002)(6512007)(6506007)(26005)(186003)(41300700001)(86362001)(44832011)(66556008)(66476007)(38100700002)(38350700002)(5660300002)(4326008)(7416002)(8676002)(508600001)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xe+czl5JeI7HaHTBkxKh0Wnab8ojXrHGiqAwEIAjkXfG/QrMfc5/tM7Bbnih5k4WYk1H70/C+w/ZQafdgEOS8JaTpVBA3E98KRJxGl4nkm6OnPMXXolmQHTv4gQilY7H1h5qNUx3E806PcVUoOJZs7Hwiz+dMpl0u11d6r9H8QYpQ8oaZHQg1YjUhIrfLWA4jav5YSZn1AgrXN3ic/kAHf1/nN2qH4CeH7siN6ce/plvn/V8rD3k5FcrRZ/zVSONTzrb7rLkJMKzLeoUQOZnhW4ABDzLhgq+nvUPNCAwwV7h1tE8qsdhgW0Z3R6TeaSm9Ky0htOH3uwwW2goBNOLxvCF8AClChj+akuNJu9kYtd3uaytAotOUty112CHrrntqGgjefRZ2PUBuVDKcw9WVO7oJ1wkDOlurppU4g3CTX2CmieFdXLSWJ3TWPfHDypiRqFQsnhFHGQeppcfAVS9V0h4jXft63bnFQ+X9/feMAdQ/Jl+8F2eGSimmNsSrbb99NXGChrjN08XlZJ3mGkurZNmOqf0xwQsGM+VgxQ+EdBEdPkVU9695ieLj8S2VwKmLjZKiBxkvNkao0xZTdzTdoODlCFGw6LSpVjb1tLRpR2Wi9oh5QFlnf6gf2sD43dT/lZnkKfsKmbADHEqE//1dNCCDQKwTCHU+D5d6ITeTxRp/PLvVDm1NHeQ7+LsY7GtR0WorfLo5xCW9LsDiEu/PY1nqt8cpidV44Q8ZM+tzBL2jwMbanDyfVgypbAJPo3wn+WXej+qa3wSYhqfi7mX6LK5c8i/LwOQ4DNkstSnuhvNxQodUC08xEk8fVKrLO/3CCaQySuSk48dKAb9YLAxUS6jSKWLyNDZBcClhLhECN/px6Ek0qwQ9SwDopXZObjJkzIXMy0sV+ofj6yAeSUYKeaWfgycwm1WkxEY1bOuCkf+uH6jguDMNSqxQk3HA8upVyKYLcfycZgPhaC6gFoZwtaxfy/7MgyHILKcWNWdal2ipyY0shEDFLesRDtmaEWv9fRBGm5lc3MLJpydIGqYAmWegOR4nS25Jm4t+NdC12CuSMvFfRpRnmzEUR5f5LIoQ+424zKn83HBUkmFhB2KwduceVDDDyTsPLiVXQXyd8dnZV66/ovntO21lfsaA+SLNrzHmU77YOO4bPjdOMzggs54R6QPpe4LrjMITaoFwkFGWcpPWfDUj2XbgMiwqpTM9KEgPofgbKr9BKszMlGDBYOx6im6ZdXO3n0UgpSrkIZROroQhKudpDrEPevwr/pH8od7E0N4GkEgBtcXfPlW5yeeY47MNcZqpuHfTx3uMMJKfOrfyYOQmDz52W5Kn7/aMmaxdq5Mc/DWE9Z0/Uo57ObwmgmRGLBcvF20SjauA6ilkNfSgivPG5AfVeh8FoLB4D5brY8u9OzXPiSbd4U/222s3yGCu2bPehwKRcCakWMHj45iiuiLK8rbx8Pk7+NNNwIc/cZ0B0wgxTHEQiRKnbU4SWY+l8PiLK1RRJgwobMeOOGvYA2MZWBryc+SGgmlPeOKDcNSY95HQpO79vSWUP5kON/gJtBvxntKELQv3e6sJuciXKaWYJDv3tVrgocEIJVaQ7UBRUYUJAuDttWlHScWXqDl2Z0U9wfzJP8JXuQYayfUVMwNaYimm9XULH8kpURv9GLQnqiX9nmk9ROL5z3wUwacoRXuokLbTC0nf4aECBXFtG46h4argFzLGOqhnxC59dbVwhZj1q3M3Af+Qhe0u96B2c2sJb/oHTVQbclhwIeYEu5cjJnO0u8c5VMq X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32082673-f455-42c0-9c0e-08da4b1f1fdf X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 20:23:47.9351 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ESkJWWZK4S1/lkg8HZAzlzc0/Z575XBNz61K0ezuqqqqomdRzFSjARQ4JqzIXxmA9B2ESr0nQNlreU1JEQWeaJRzBVokTFX71HhZZ83u7LM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1629 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_132356_668429_22860BCC X-CRM114-Status: GOOD ( 14.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are a few Ocelot chips that contain pinctrl logic, but can be controlled externally. Specifically the VSC7511, 7512, 7513 and 7514. In the externally controlled configurations these registers are not memory-mapped. Add support for these non-memory-mapped configurations. Signed-off-by: Colin Foster --- drivers/pinctrl/pinctrl-ocelot.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index 5f4a8c5c6650..7ac12102120f 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1917,7 +1918,6 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) struct ocelot_pinctrl *info; struct reset_control *reset; struct regmap *pincfg; - void __iomem *base; int ret; struct regmap_config regmap_config = { .reg_bits = 32, @@ -1937,16 +1937,12 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) "Failed to get reset\n"); reset_control_reset(reset); - base = devm_ioremap_resource(dev, - platform_get_resource(pdev, IORESOURCE_MEM, 0)); - if (IS_ERR(base)) - return PTR_ERR(base); - info->stride = 1 + (info->desc->npins - 1) / 32; regmap_config.max_register = OCELOT_GPIO_SD_MAP * info->stride + 15 * 4; - info->map = devm_regmap_init_mmio(dev, base, ®map_config); + ocelot_platform_init_regmap_from_resource(pdev, 0, &info->map, NULL, + ®map_config); if (IS_ERR(info->map)) { dev_err(dev, "Failed to create regmap\n"); return PTR_ERR(info->map); From patchwork Fri Jun 10 20:23:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12878091 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A36F9C43334 for ; Fri, 10 Jun 2022 20:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lFgJFZmVdFPc8OyD5TKIbxhObZTvODES55bkmgG7EYc=; b=x5ruyvGbXdvg6Z zJt6J+w9N/NZ0HIxRMdH1Y71+wgB3ifr4w93d32fjB0r6LigQCOKas+c9azFyqxeh2ErmSYI4/G3o mpm3XP0p9dN21+7JSfzHcQ1XKeKY/IK3BmflPM9RhTDwYi8YmZbTasETgWVGiDHWS/1+crvggIB8b fdhxaQigWDB4/JlzX6Rl7pu7OrhBhK+L/k42Ir/5UB+Hu0KzzJDFbXW8aY84LB6DRS9e4vhSq3H85 zpcHPkkiJWN7NyJ+3+nZ8nesNJXcoYSN3rZbRzIN/mvqPgIWSrYtUu9dmPC55bsQAnmBofzPmJpZr R+e9GTd47jfCkPJanrFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlBn-009ijG-MS; Fri, 10 Jun 2022 20:25:04 +0000 Received: from mail-mw2nam10on20707.outbound.protection.outlook.com ([2a01:111:f400:7e89::707] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlAi-009i9I-Ua for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 20:23:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SZuRTmkiy5I6VsByaeu0ZKBFD0v+KnvrMPO4aRspKiGf17aaepxKdapV+GemsriCDU0mzyexfqdFwJTCXGnfxNTD1HbLbZYt2HQhDw2zJij/K92zy5ejS9ltNk8nwsUDN5pbvW2QNZwKo55hSOojlebIfNV1ThYkziBt+eFhXGq3/qfdkHpsht5mvMSwAlq4Gj7PDaaiJX835oTuL8fwrkUo8AUJ2hU8dW5ETSxUjAvv1KwGxXP73+kMeGKtm1C5lVQluX15PApxrAhx3KIXscFj6uzuHlLkR9MksrgvYAGiPC198/o0SMIcx/N/J5OAZNISltxVR9ypoBQTJLNdvQ== 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=p6B4X2S6ByfrNayHTGMhOyw2kSy23jsOuPxVkk6Em5g=; b=jANdFjGSPfFXgVFgC9AA6S1Ao6TmhTWaUq+UwFR8CbxR2VFu6IPLCUzoD0IusQ8m3io6Bm+zaUByYDolsd97xCGxBdvbrR9HNl/1ewuRMaYGSIl2PIMj9PtnwFmMpSXeiScUO/e43vyrbBfMl0y/le8ZSgPhVniCeQA3nQ36+i3KJ2A7GwlpzSrZvRrwr9C3O+PrJ3rVijbgShqF6Vc8G9MyR2udpjoURbNXsGHE0A5N4WbV9CVWX4uzDN4P4rv4nD1R2sP0DYda4gDLZZwUDNRbhhXJ0mDCsRT6ylzicJl2FyQEGR2Q8cukh632yDY7Q4KV0/vGWWGPTU01r46cyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p6B4X2S6ByfrNayHTGMhOyw2kSy23jsOuPxVkk6Em5g=; b=sU5eDW69yUZpmroQOr0KCVD+4cD1oSQkPXDaAn4jr2LOSDgSQkB861MSvb60kpugpFbmk2RVUnUk6xnuxYDT1V1PwzRaIh1kRQPsJvuLnyCqwVycppu0JfKdi7K4tFqQFVbDB/eWQFi6vjZiBhXSVmbQSCwpp1CFXtLUIUy88FU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1629.namprd10.prod.outlook.com (2603:10b6:301:9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Fri, 10 Jun 2022 20:23:48 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f%7]) with mapi id 15.20.5332.014; Fri, 10 Jun 2022 20:23:48 +0000 From: Colin Foster To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Linus Walleij , Wolfram Sang , Terry Bowman , Andy Shevchenko Subject: [PATCH v10 net-next 4/7] pinctrl: microchip-sgpio: add ability to be used in a non-mmio configuration Date: Fri, 10 Jun 2022 13:23:27 -0700 Message-Id: <20220610202330.799510-5-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610202330.799510-1-colin.foster@in-advantage.com> References: <20220610202330.799510-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0246.namprd04.prod.outlook.com (2603:10b6:303:88::11) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86cc6a30-447d-42b1-f675-08da4b1f205d X-MS-TrafficTypeDiagnostic: MWHPR10MB1629: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: aCf8yudlVX5wrzJhaKPX/IJJDn23OAU0a7+hsHK0PiVl9Kt05ZI6bXAEHzCIlndqHtrrPYmVKaxTNZG5NbhEkD21G7R1O++dRbAuraLYAuSKmBWPzu1e5/XICbDMIcrKfbdYtGk/pSNlg6YXZwOFsJtIXlsFL2kDq5EsMkXa/AgE6+oh9wzaMmMyEXnMkzBMYBjY5lsUdVkbJmyccXoKMFF9TvBC/m+GitlCTC+lhOizayB43hq+NHsVQ6Xx7PrTwx29gCxac+9Io8YSySUslglWVdYQSZvHdqyBkPzDHB9QkmxdYTZMgQWHNQncsaSITKapuYTpq2q+sTkqMWN+dcD0LQt5DMQKslb7yzZOp2HILStmOf/jmrpjD6R+aU7lKBWerdzC7iIHyCFE6xAN2nzG8c0i5conu5pRh7Dylc/w6M+D1rj2VtwWCNSMLCm05uw6eATGcdCkZZUkhlfHz/ckYBPWm9/0B2uCTYLc76e1dp8L6fv+aitSMSqKO/+LLYuUWHJXwvnSjGDaKVIW01VuTee3bXJVk99bPQF5QyRy+R7ovlnS8T1YO73/gJ46xb1pbo1zbGOgQWxhmQgtIy1/ug+10pPZcprVOtGqEZ5t1zlGEIYXdAtUMyQUxT8aC069Da8dfpLuzw8G/ozfUp95uMHI8DJmPWpyH0Zky9BCeRdHygtBC62gqO07XNy3Zyor1sF82mujUZ5b/pWLqA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(39830400003)(396003)(366004)(346002)(316002)(83380400001)(2616005)(2906002)(1076003)(6486002)(54906003)(8936002)(36756003)(6666004)(52116002)(6512007)(6506007)(26005)(186003)(41300700001)(86362001)(44832011)(66556008)(66476007)(38100700002)(38350700002)(5660300002)(4326008)(7416002)(8676002)(508600001)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5FKofilow+BUxlGaq/p+vuh3MasfmAMEClKF3ZgwDPdxbZQEcWEK/X+sS/0nt5Pal+BZfVt2QH3cjrF/2ExR13TR7eeRn0MCEHyo/eAcCAAXgPqGPJ91hlBmpR5pvgEjlv7qGwSmxCeHelhvJ+uAXVBB7+GreFfCviViabrehjdFCcQc1T23nHaDmdVm1wJ2wzi2tjsJ1oWHqaEkJbGUbXKRpraMmdMPbSShOirEq4LjBT2ygrywntFDXFB/4QDiaqQJk6nT7wfwT4MtxwXSvODSo665YW9Brj7UmskjSQQtUL1dFQyu+SkSxgO9I9hWVwh738doNcDn4OMAqWCDGR1UP13prDLwynOxeCDF4LpuTR1e8zVrc+MMXoVz17dYBYTAD7iYfyf2df94J3lxb4B40aOlchk+wf/TDK+biNe8Pvd41I83Ux1PVa1c9Rj5Dcomq/GA01QKXVEhnxNVNbhSN3/ef9TdCRrg/taHuaRkCgT8T/BZg447iffveIUpjZelnVMIpZN+67LcWE02DL8y3E9m/34FJsdSFsGJFtL0LHApQybbeKRfr5HYFny4P4IAFa1yNij/lmc4Vac1DcL1VCps0ZURVZCuyHZkZ7A7cYhS9wKUBs1UBcVXn3Qtv+A6CR0CS2cCWtVVsmQPi1nKHRd9BWI+lI1ujwCKzv65nzI5IwOGLtKFBDA6bA/a+HwGk8Rgvo96XBAiyF/YL1mC4pzHve6Lpm5NO+1+8Cf3QXfqUpatAmbhagUuRzrFVXSEWH68sog0hXItGSM8ysmvL2tJwbugBCcbLj6tuNKn9MXme5whzOUZ2DsWF6ZkoFVXlzPqUPuBZwLfE55TkCOMaPR65gwHWTbNTtVh4X5akeEgztAlmUym1SiqV6JZ9/NY8cQQ6ijDplORqmC1dVG37bQ5Hr4IgGHMZxAAsozoK8+Zmyxr8q7EpdeZ4hkxJne9s7iajx02oKyVgk9Ifan1XdTvcex66VKF0lzKjLbcHzBR+ajOQoAuYD8BUpdKpRSaBim/EO6jwatA7Yr/6ZhrrvyEQSOFfJ5co1Rcp+fGn55+c7KwrbBXwrVrVBl2K6Wse49ar/hD23HmtrIFvEADu+TMy0lpmdWVz73g04h9Pu6mE7I2eSdTVD7Qg2VoMOQhw2KLFrqkDUXSDdgdfwN/BU59gwXd5vUt9z+zM/3eb6pmf8jnZ6MCN79heKqriz/oQhswOmkDFQy3BXEKvFOtaPcTz9plYnyZd9c2epzpB4DZqHAMmRJHOecS5t96m9W4Y4pHTfpTuOeQhiUG0t2AF2MxHzW1cuuEFx6cGCH8GUFOQA0A2pz3q2AdAArrEmqINFQkH5Cp3k0z04oHq89pd2Fd7L+w34/QiIQzF+S0l6gzYcpzutEWJmBYSWGqHLx1OxORmDAN1pkpcyuBgdwt+zjH70lVAs+C+Z1aUVsN4yu8XbcTZizF+QH+uicLpI+0dNHhJ/TBd00Lo8omuIKv2YngBjJ0D79EuhWRXfnPpaTPqIyW/XJ9qCyPW8UfGXyxgBgL36uTPFZc1sn0EXYJu/nBuo05p+yKvseV9MLM5eGK2ofu5n1DqvDXK2jvSSxPBuKKh5leiOnrNE2toiHui3l84vSfbX/wT8qGNl/J6uNxm0NuBjeVAMCRJqR+4eK39ORfVyN+17nipJdgpaNJHWVbIGn4BSuYmLeOSvtpkYif591OShthVlYsT0sHiniHL3FVmcMw1CBMD40ZSAD/wD+YEKG9ET3F703RFwDpyAs0pyT7Tm5hGCowqMTT X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86cc6a30-447d-42b1-f675-08da4b1f205d X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 20:23:48.7788 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8aDeXPntdFJRRrRX+SJ+yMUENjVQqyxSrZOrOgzzcrmDSd2d5feab1qHnujORMzowRQ24ZBeP2roYWfNTw/4lfNaV+mvrnkS8BbibeFsVa0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1629 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_132357_013284_BC4ACA97 X-CRM114-Status: GOOD ( 14.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are a few Ocelot chips that can contain SGPIO logic, but can be controlled externally. Specifically the VSC7511, 7512, 7513, and 7514. In the externally controlled configurations these registers are not memory-mapped. Add support for these non-memory-mapped configurations. Signed-off-by: Colin Foster --- drivers/pinctrl/pinctrl-microchip-sgpio.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c index 6f55bf7d5e05..25fe57a0c26e 100644 --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -904,7 +905,6 @@ static int microchip_sgpio_probe(struct platform_device *pdev) struct reset_control *reset; struct sgpio_priv *priv; struct clk *clk; - u32 __iomem *regs; u32 val; struct regmap_config regmap_config = { .reg_bits = 32, @@ -937,11 +937,8 @@ static int microchip_sgpio_probe(struct platform_device *pdev) return -EINVAL; } - regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(regs)) - return PTR_ERR(regs); - - priv->regs = devm_regmap_init_mmio(dev, regs, ®map_config); + ocelot_platform_init_regmap_from_resource(pdev, 0, &priv->regs, NULL, + ®map_config); if (IS_ERR(priv->regs)) return PTR_ERR(priv->regs); From patchwork Fri Jun 10 20:23:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12878092 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7031AC433EF for ; Fri, 10 Jun 2022 20:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=E8iDNtm4+VrzR4vRx/1IjANi/n0y7G8H2Lr6aZTpedg=; b=jNyL7YixUTqk+X ZF/RnsAufXPCj0n8AmWAvC7tqOXp9DQ8Fk3ASp3uurhfhwJoB0nsf9yhOJ2/kXksR2IubtbZy5UPD nrv5I73jmDRTpearA5Z7KAgyOgeU6Z2xSZglcXWha0m717H3gGym+TRHl2Fl83bUekAvYVjW6ElJt 2QM2gNhnoFxkhdH6mQ3U1NCrBgwqQn2Egl4EM57J8xjZ1euSVVfVZ6I5fs6xjLVNcIzffqP1ZeDra yPmBtvpW1KwJqP8eRIkKQHXhSm8CkP5zR3ql4BwYj7qG56GYrMQpWRR01RMABIcC5/AY9+/HKB6eX pf0ml9K/8/ruJcYZD8kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlCE-009izC-Vy; Fri, 10 Jun 2022 20:25:33 +0000 Received: from mail-mw2nam10on2072f.outbound.protection.outlook.com ([2a01:111:f400:7e89::72f] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlAk-009iBJ-2j for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 20:23:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BZl6U9b2Z3L3dmk6FMGy7Pji082gkjP6+EyKcVnU18k2t3CeJ76vpKM1fHKNaaKZzbQDZwg4U1gM/wEXBJgucf8UD3gAN2oeQ74Ek1vO7g+eD1mbOyL+Yoi5BMOY0Wwb1x0uOynZke18YzbieCzkBCoUa8dmuo2tPRPJd/6eshte5R/TgLUUTfn6M02AKsfmo+xWOZh9de4IZi6Hrwd27oiLEoctJ8D6wfeFf8l0pGtJH54dBBdIK+sPs82OOTtGbPWKdPFB+acp/hulpr3hUUYOOAGKqfg3gS/1m4pEU61pVd1syZf37OgcbWJLNXsYnr3R9LUXCMuVyPlbcA+Rag== 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=dpcqD3YrPb8E3bZrxcGsy544jFxVoAUX4RKcmXtCjec=; b=dGAdqiNrX6EjF8N0D+8mLhRafFsHQHHKHL/NslxTjE53UxW1pLiXlnDalum5aO7GQ1mdFaNlAITb7qAn8tkskMPk42FbfJtAxX0pK1oYxVbuEaKJS3cWdbAuYeEGspaIIUSAIH7KVLa65YV/rhuWGSNB5S1N2dr7F0E9nDEc0zflfiZ+mEsEX/sywNBuckZG4K19S6IrDQE/ZR/9j5z0neE9nBqufWFYwx9A7d2v8+Gcmn1OqZAZZzlwRf13t4IIrG6b3tG3dzlDOrHe3EULBwIh8ke9SctlfZlJYiOYr4Pr5pIg07WoA8sOp9HepKT8MkFXsTvWuAoi95GDV6F+cQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dpcqD3YrPb8E3bZrxcGsy544jFxVoAUX4RKcmXtCjec=; b=uWl71PZrTVisDSme6crGXmesilEKvsg8cB2xislVa2hZSq3ojnOcXslveJShBALdZU9Dv2v5BE6/fz0CmGJ6zCj5rifnRARmTCR/H3p2ohDR2fiJXrpWBdb33CBwJ1PACsph83caoHTwZoZvKfeynFQAndnAB/TT4FYID41uI1A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1629.namprd10.prod.outlook.com (2603:10b6:301:9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Fri, 10 Jun 2022 20:23:49 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f%7]) with mapi id 15.20.5332.014; Fri, 10 Jun 2022 20:23:49 +0000 From: Colin Foster To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Linus Walleij , Wolfram Sang , Terry Bowman , Andy Shevchenko Subject: [PATCH v10 net-next 5/7] resource: add define macro for register address resources Date: Fri, 10 Jun 2022 13:23:28 -0700 Message-Id: <20220610202330.799510-6-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610202330.799510-1-colin.foster@in-advantage.com> References: <20220610202330.799510-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0246.namprd04.prod.outlook.com (2603:10b6:303:88::11) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ee623b9-7860-45ca-1579-08da4b1f20e1 X-MS-TrafficTypeDiagnostic: MWHPR10MB1629: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: i9NnR7ttXicfJIl7dPgdTgdQwxn9nLXjbAcM9NtFzLAbvCJSDAFWGTg04h1xhuvVidjf1cUYwGktQEoPBvl9ZG+hf6nA9HiDiA7OScOplWDgCKZlaKvBm4uo7LlIvTwe2MloCdZTmWhIMsPWbOvsrh6fhJuGOaOHYVG4Zv0G79x7ut4O4QTAujYhJEl0+x5uf+VNRmFJairfQIzJcjtYHt5iK0fhOtd4G86H2iyOHZ4yAjH+apzy1fA6L6AUTViiGScjOjbmzxHowBRADjNpARVkdKPpYR83cO7Nxg5ALPjp/PjrieuZOwCpOL0ETjMpt68DjyY/NCUrAuyl2M+cBtJnc31D6rI+2jQqHYK6bfACBiFkynbQmSa6VLCfWiDJ7u3emtZet08UNluEBrVzBfElk5xOb2h0p+jJr9+sewdTleKmIdblyL66/kzoD6x/0WfHMTb3AR2P+1tWuJGYY/FkKf63RmDmOfjv5dt60560Ob4SVwxA/kYjQ1PSHLGfj15jDfxlhMnyfM7FaxywUbunZ+1niIo/8UF4593NiDvSsyzj2mjROqVIVUILs8rhwn4yB8NaHlesGxA9ZjEclrl6pkYvBh2Ya3RM8msuw+EnYDsejKnJopfccnfNmtSn0jcfFyBm/cT6hJnVD+oLjVG8JGo+97M5QPgynB8aHhBQcFM8B40DsO2WPbRYppYlC+N47SISXwEsVyMnwog18g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(39830400003)(396003)(366004)(346002)(316002)(2616005)(2906002)(1076003)(6486002)(54906003)(8936002)(36756003)(6666004)(52116002)(6512007)(6506007)(26005)(186003)(41300700001)(86362001)(4744005)(44832011)(66556008)(66476007)(38100700002)(38350700002)(5660300002)(4326008)(7416002)(8676002)(508600001)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tY04v83dEnsA9d2GaMoQz46JNgH7c4dbmwWpB0oR6qdwBCCCdpLGOXviKIlAjHHpAQei+TkmGheML+ZMFAWYA24/iBN0PtKPJOKC1CaE30cnQ+YbTCw2rWZqTJWXYRvKDx1S4c80p3a82gaGwjc1NzvB2o+z50NWooUM53dBskpqxewYp1YosH6KxiLs+ibTQVlmnrcf90hforWk1HwlY3hJB6QMoe0FKR1ijJ/gkHoPfR5NApN4FuxLJLmTbAJfCTRODZ32ocTS9jpVzwb9Rrw5vaEH0P/l4vIzNiqK24yuEQuNclAz6FlzU/jw/y29+xoZDiauOA0w/MSWbGlOVY7wTxdr+8rihfG/r1EFJOrn/rZTW55j1gwsqKr16Q2JOws+m2gHWyHOKnpk9u98JEf+ly5OhnlzazK4Cn00EUnO1/hJ3SPZ91z1ybKs8VMw/sei9yLcXhHfsi6U/e1a72JsBWGtFTcz27EvvJZTh0T7Ed7xud5RbKAlcr6c1+l3MjvvFF3j2HddNED+2cQlq4RU4qoW/JeljySn49ZRVZdeJxq804RY4JsmcPsxywDIfU6xa97ZsPp/H41KQtvY3Lj9pt8Y/ucq8SrrcJDQmHOARuNmelJgLz9z7XUGU7+bLWZWPaoPOZtbWXULIXKK7QO8hiR9uyZOx69nHBR3M6MQ6ZgKUWEJQlBfHvU1VkIkoHlPE4JsnLOMCJmMmY+ZlPpSvGmXR0JPTNDbMk+QzheC4aEKyedp6CqnOElhgJw44z9SJgNwXSSv58ADcVoKjNPpLeRINyeRiFIl6iSwjmh/A9sHXj116rVV2jLQjhHq8q/LpQIejZ7olnZJbh/gblP8CtOc1zdVXgy2dXgnrmn5F/J04LyfncwjqbobRbgb1z/HzmNZgJ00f43z+s6jk7cU1pYF8UQyStVblHNNtu0WrGUN6C1cexxt8tsGyQIf0kbHwiGSBAX3A4bSgSLnJoHE7mMeFQn+jIRSrBlatr+Qz71LPaUa23199lt9r1oa8gQveNphpAkxG4uee4KjFslljLdt78f0AqFxoJErea3NaS1NQ6lcaRySII7doz2NgZBFm7CMZVw5fePUqrtkEFgyQGpDC2Wn4zWV9AMdc9g0nZHJdISkzpFdW60OqobwXSdx+ykxORJ4DEaW+mKdhn15NnUvrXudKf10qLhH98zDhevrHgleYuKAPBCTCH7pbjJg5fi5sUUZnGAZZLjxndYhJ9Q/wRFOkNLjdLJ5nIBGWyBLkUj53H0vLxPy9rUAnLSpoSoJvEiqeVib+akjsKV4bAkh0XyD5xqmAj8qME0juFFWvulVGyNPLo+55Wm/QwdInXnV3JwzLRgMIe34zCH9OS3jWLc4yKeQCosbVG6rIfkyQNTmBQFgh7ciyXW3Bdx1vediWdQRxqzARV05P1vBLpwJFUpzhyXagKof0h8TyH/9iAkPEm18YQPOxyxDdfe+5AhFeFEQklznWN5RlFu/Hy98KS5yKT3vz9On1TGHWa3Pj81lPiVlwT9kNs6hJ8VUbgGaywOMswEZt6V2Cz8FYd7Cls0ASV//jO/YzuMcUPW6///4dkO3qJUcrrO9+gf5aFZ6oha6LfLjg7bkoW8tdKDzWOsCKEexM5yT6Iu39B7Akzb7h9BV1y4EjDBgdAL/btHZSpruGP+uSz/fiQjFo0hjA0w9/7MsPX38N6ncR4i0hMFKOEJAAnI2m5GUSbV1G/zieOcZ0UbZjIdxXyt/PRzcdCjQTgH5bsxwWujUd511+rNFTVW2p6BMrTGX X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ee623b9-7860-45ca-1579-08da4b1f20e1 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 20:23:49.5756 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WsqIFD7w9OpeDrlRH5Cp+YKPxdbq0X2tMaK/91skCTLOjr3Wz2wxgyNukRv+yJIDImycAfeZ9pAjpzEIF+5pDKFVhnHtRO9SHBZELUUJdRQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1629 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_132358_153685_2D91E94F X-CRM114-Status: GOOD ( 10.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DEFINE_RES_ macros have been created for the commonly used resource types, but not IORESOURCE_REG. Add the macro so it can be used in a similar manner to all other resource types. Signed-off-by: Colin Foster --- include/linux/ioport.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index ec5f71f7135b..f3b0e238c020 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -171,6 +171,11 @@ enum { #define DEFINE_RES_MEM(_start, _size) \ DEFINE_RES_MEM_NAMED((_start), (_size), NULL) +#define DEFINE_RES_REG_NAMED(_start, _size, _name) \ + DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_REG) +#define DEFINE_RES_REG(_start, _size) \ + DEFINE_RES_MEM_NAMED((_start), (_size), NULL) + #define DEFINE_RES_IRQ_NAMED(_irq, _name) \ DEFINE_RES_NAMED((_irq), 1, (_name), IORESOURCE_IRQ) #define DEFINE_RES_IRQ(_irq) \ From patchwork Fri Jun 10 20:23:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12878093 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A588C433EF for ; Fri, 10 Jun 2022 20:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=te+6MpBBdZs4lgcR9/BxM4LdG+ZepnEL5uV1M+HFKrA=; b=bSjGWfX+Gaw5sa Jm8qZnlmR4PRS67+DPJk1M2F7mj7hozqdEXiorv6Uke11Pp3yW0YbCL8TmPyHPsztiE76Wy78oFtf 8fEDsPZ9h2hCdx7+RASaKks/yge1zX1yy2ifSYYY7PGGvgwNF1AKkwhIRRDDct3sWiEp9MOBvM5HD L7cC/VVjFdnt2/Vi2PNpt1gpva0zOhSJI0IecHZ8N3LUqdWmwT8wZnnpvcVfsYcSoKrnB86D4V/6i +c6IUrmKKNr5HRpIXf/aBSIoVynpCKPQ4l4wPOaepyi8wcIEFkoI8fZj8ap0xjFAX4QXnYW1hX1xf brA6E/hsmtl1XyWWfSDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlCn-009jG6-JG; Fri, 10 Jun 2022 20:26:05 +0000 Received: from mail-mw2nam10on20707.outbound.protection.outlook.com ([2a01:111:f400:7e89::707] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlAk-009i9I-Ee for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 20:24:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bw7JccKv1Y9s4LZkKj2FoDYbbC98P0E6B9W1IONkluiO66m8Ad4sdRcBNjySjngrEPjjAmYIWY9Dg4TnlTmTes+FSbkxzR/OXGFethDVA1PC4dqcjL+X3Od7gH104czd3vYNwj3DRoJlhS18SIy4ETSvDt4J3Ao+ddbciQDfHXgXYOdUkzxnwpGfauIO0ceTDrHZfurYXoCKX2OuUfAZ+Lvjw5rcGloM+qLEg9zDdC4pmlLk3Se5avwGxZf/6J7blxVU8g/0yMWlsY3/6jWIH9+BAdMXsiKvVpyICJjowNw/UdAUkfdSNCo1fKvuMXqqOhTNQ5v6vZtaNufrjyVkAQ== 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=0TxUElxae3D5rFWa+9Bc7GEjNNlZ/Nwh0pZeDVBhKjA=; b=kABDT7bGkr2CyOWi651fYvI1qOz+/HPVA9kGFeGyDfDc4ic7hyv5qxGm85UglI2J4xpcTNMg0P5XZ6jrseNIk/JcmIW9S9E9Dc9cDH8o1Vk+ZELSAxI2oK2YOaQFcijj6l1jyzu0n4QXV0mYCIZKc42wiIIhUpel350+ygd2WO17IgbOWNpXo1eoRvLMAvzYCYAGa8WicCvB1Xl/hggy7M5wbG79Hb1iURPn5RD0voYNVmFgJ1wpmIM3b2vbKT8uwu71Eoey4v73mYCz4AAg/Qf2nDNbgPbbqxZ+iDtzcPh2c0P2m3NQJb5n7KwHJ9oITXdwHbwdIXZ+3XQQGum9xg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0TxUElxae3D5rFWa+9Bc7GEjNNlZ/Nwh0pZeDVBhKjA=; b=tglPBofd5dUpMoTlcUz4vYVKJjLoGTj6lRpHbj7LCAADO+nuhKQbz1OOL2Pl8F1LOpW616eGRf5+MZsm12i1crVtCqgxa0+FU7wGFRKgl4eEKHCuS4Hzqbrt+4iGAaliLHAfwLrVBUfcEN3xIDGfulxo3ajoU3lNGJRBzbpK0PU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1629.namprd10.prod.outlook.com (2603:10b6:301:9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Fri, 10 Jun 2022 20:23:50 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f%7]) with mapi id 15.20.5332.014; Fri, 10 Jun 2022 20:23:50 +0000 From: Colin Foster To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Linus Walleij , Wolfram Sang , Terry Bowman , Andy Shevchenko Subject: [PATCH v10 net-next 6/7] dt-bindings: mfd: ocelot: add bindings for VSC7512 Date: Fri, 10 Jun 2022 13:23:29 -0700 Message-Id: <20220610202330.799510-7-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610202330.799510-1-colin.foster@in-advantage.com> References: <20220610202330.799510-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0246.namprd04.prod.outlook.com (2603:10b6:303:88::11) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ca206aa0-55ea-4158-98d1-08da4b1f2147 X-MS-TrafficTypeDiagnostic: MWHPR10MB1629: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: LWBK7S4JiNp9SDV7qHpncagKk3c69gH36QLUKlXuXQM8PCKGXfU64JNz2uwg5hx/HwzIFzk7Ve6D0+m6KOgWsZdFcVd8tToWaR2mA83Y1fuWkwWk7gE+MThCSyLIpoT99DXMv7jILQhIEUqkAODdw/lDjullQFF6k5a7Nea2qqznjpBnv/YA2M1c0ABFky5phjpv+EmrYXd1TgGzDv43PFVQ2GzB3AIW2n89+36WH9h4SuHfEoIR3B6++dWsFJx+Xk4iJLUIsdFActsrbZo1W/zdwwnCxg8SKmy+cb9TjbOeEx7tl37GCtrL6M0nTI8/ChzqGsQL4DniHt34R/R4g6vDJnHruhOeJAnfNWnCIUofz2PELL3b+makBDOrqi6wnZ7ZVG8/DfVU2jVMBCptQUvlJQBsFr9pmjtilE+uLHa2nOZycDBe7uix+dkcQcbbyG6L+vMX6yCNS6l5OwKgaVSwe8Sgsa59mihYGjCyBv9AUGrUoVfciI+Oo9xwFts4wDmMGYjKYvGAAn9buEAmiW5OG8XmDFj6VbfjDb4N/icCpiHW68B+2nWRLSxpFQ40VJXjivO0RPSbUSGiMGcYbyB3Et/fg6IpzhNq3v2FFXqp6HS/EvnCARHalokxJr0OzXuBL89EqtJDhbu68119iK6iV0K8meolbP/vy0ACMjZ1X/uacPtSap8Lzm0bVHZzv9YAmPwvV3ecu2PL3OYc7gYbUpAihKMIJhmM7T5lL4EmDjWxFZIpUTkyxT35OrRO9y1SMv1XUyEsVFuKNUJ/Qyzixn+LBEcCleT1pndC9ug= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(39830400003)(396003)(366004)(346002)(316002)(83380400001)(2616005)(2906002)(1076003)(6486002)(54906003)(8936002)(36756003)(6666004)(52116002)(6512007)(6506007)(26005)(186003)(41300700001)(86362001)(44832011)(66556008)(66476007)(966005)(38100700002)(38350700002)(5660300002)(4326008)(7416002)(8676002)(508600001)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LQPm//7OrYwJbRBuKftmHa3SWhBZCmXbfTcWNqT07OsaS2E8rKLqUFDNHBIcj92JArCyEjElfrQ26suSXDLudjcRfunL4rf28DtyphuwIMEBBsGt8tAtpPk5dszGgDnN+AQv5nHOFbBwhHOQ8u4wibIuEsMrg8Tq/qQr+5c0hvo66LLj7nkVPJ05nRhyTgNeAYYem4TEQPNLB4EfM0msXQY4LfJZodZKlwNj16npyJR4HrMgVxKe4y6z3z/jR2nYEnfmkpjz7l1nedguTQ8HznZAfbI02SMbU608rmVVoHD8VZQ4SYhHwM3aEc9oHjTvECq/K1kWSpgGoTdK2dZV9kZWvQjZHWjyHf77cCBTyz6O/CjiUNQCd0QTygUGXwOx7UeRrfpJjh+MWyt6w8lR+7p/IPf0pDLKAYn0mOWGUVSj0F/QCQTvYZTWTWCRrfVn/1eGCLotX4Ju2vXWfVtbWIeyYQD7z1P7S5lTIgw5+rPjDYXm46JA/wFrgZXoIICUtFv/OSM4ROOEJmfE89OJonpkc022NedZmXCT9pBpt4xmGqE8/h/8eIEpX4G1a0rcUD4An0oxhaP0SZumrjYrYS4axMlbWeq9buTB0KljwfRDApL1G2s2Md9fZOFNTX3mnoiSVKpt4DVQYNBFFuZVUjdAoIblh+2YukK9pLtDUV+Nj/plV1+ih3X9pIZt31IKd4dV0JHeVdy01Q74DA0XyUxXG02Hz7WyoOqWS2WeeBT9VFecCBKSt4vihLr4GDxkkpuzRzJigamVjjQjZJPcN6+HqdiBaZVIqKG+D2PUbgRLiB2lskGmJsUPTuA0/6mP4Ab7gUG/ptaZ0Q+L1XkHAiNNYyyYxx2OHYL4xZEXJWBkNWydH/fjVKuCoJhbqbHUd2cvCwGrF8kje2YBdRjsU9mruST1weZyQvLNPJWaxgvOjAwx2WQRRfIAxZ4Fcokf6GNmO+tlh/fjBqrOj9WjK9Kc7oCKNYgnUjMqOFVbDdCxnm9Ji1Ga7Uxe0GJeVRALD2blaVOgola7JOiNCBm09TEadX1xOoocqPgzqfL1q7et/16nJDHGpzu6TEuOr631Juhb3+4dUKXorMPTAk+y9iBIxjmuf8/JChqnjOtRZrpchVw3txca/iZKp9BPaxd28ZtyEcC9k17EP46uSeUxxXADpN1j1yTl4Ho7fAF6MAorRt8ih3S+mWeItAEoaFNfgyBUwByohmBkJK/z2fm+SBaYy2bzeE53HHiYavB5fmfqtxU4s2PJTUQKlfmOMtC1VOeQ9DaQDlEQv8aaxzCUvjRcjeuMO6/S0tGNFBmZG+oVu7UEA+JRn3MFMFQM6wsoiAm3fYFW9qrpeppqouZmb6+PBowHotZ69fsprbIHDfeDzD3dxw3Q70dvlZwgOODCHEgCYs9j0QnWMFZqB79EIzLkTzNhMlXvyxrk/e1eIEkhuWxEuYD0OFJIXKVcJaCoX5Zq8SO0gPuEZr0cgMoIAl+hmCI5HHLB7+JWABQaBoDJHJFIsFAlrOPw7LkpDhukprgQRRERn8YjI+E+rjpKtd8418IAMjgk03Z0iM2m2s8/i1oJ4U05QNkelAnuvvQ/EVwO+i0AFw+n0VuRTsjePqptE0eX5BzJeyfksAfiU3824Pcb1SJP7pX2Mg3l2NBXaEwJ7h/ZyMcMrUVEPFsgY1maynCbMr2uVfEvoYT7AyAYVIZbMoYt0XRxTbJIdUtxQ8OvA+63psre9AfkB81mAnmQbBP0YNXBbJ9QwCCOICl9gWcPLJLXggH7fu5o51Dr X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca206aa0-55ea-4158-98d1-08da4b1f2147 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 20:23:50.2474 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gZjg6I/hS0P3izRNzoBVxg7ALScMvKXZUtqwefLcA5OAwugaDQ5WWKfKXq14Q+O4XFJvBkXQo3Vn6YlsDp7hgtun948bC0SLC0Hh1x9RWmk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1629 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_132358_571319_3EF61DAB X-CRM114-Status: GOOD ( 16.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add devicetree bindings for SPI-controlled Ocelot chips, specifically the VSC7512. Signed-off-by: Colin Foster --- .../devicetree/bindings/mfd/mscc,ocelot.yaml | 160 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 161 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml diff --git a/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml new file mode 100644 index 000000000000..e298ca8d616d --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml @@ -0,0 +1,160 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */ +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/mscc,ocelot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ocelot Externally-Controlled Ethernet Switch + +maintainers: + - Colin Foster + +description: | + The Ocelot ethernet switch family contains chips that have an internal CPU + (VSC7513, VSC7514) and chips that don't (VSC7511, VSC7512). All switches have + the option to be controlled externally, which is the purpose of this driver. + + The switch family is a multi-port networking switch that supports many + interfaces. Additionally, the device can perform pin control, MDIO buses, and + external GPIO expanders. + +properties: + compatible: + enum: + - mscc,vsc7512-spi + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + spi-max-frequency: + maxItems: 1 + +patternProperties: + "^pinctrl@[0-9a-f]+$": + type: object + $ref: /schemas/pinctrl/mscc,ocelot-pinctrl.yaml + + "^gpio@[0-9a-f]+$": + type: object + $ref: /schemas/pinctrl/microchip,sparx5-sgpio.yaml + properties: + compatible: + enum: + - mscc,ocelot-sgpio + + "^mdio@[0-9a-f]+$": + type: object + $ref: /schemas/net/mscc,miim.yaml + properties: + compatible: + enum: + - mscc,ocelot-miim + +required: + - compatible + - reg + - '#address-cells' + - '#size-cells' + - spi-max-frequency + +additionalProperties: false + +examples: + - | + ocelot_clock: ocelot-clock { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <125000000>; + }; + + spi0 { + #address-cells = <1>; + #size-cells = <0>; + + ocelot-chip@0 { + compatible = "mscc,vsc7512-spi"; + spi-max-frequency = <2500000>; + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + mdio0: mdio@7107009c { + compatible = "mscc,ocelot-miim"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x7107009c>; + + sw_phy0: ethernet-phy@0 { + reg = <0x0>; + }; + }; + + mdio1: mdio@710700c0 { + compatible = "mscc,ocelot-miim"; + pinctrl-names = "default"; + pinctrl-0 = <&miim1_pins>; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x710700c0>; + + sw_phy4: ethernet-phy@4 { + reg = <0x4>; + }; + }; + + gpio: pinctrl@71070034 { + compatible = "mscc,ocelot-pinctrl"; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&gpio 0 0 22>; + reg = <0x71070034>; + + sgpio_pins: sgpio-pins { + pins = "GPIO_0", "GPIO_1", "GPIO_2", "GPIO_3"; + function = "sg0"; + }; + + miim1_pins: miim1-pins { + pins = "GPIO_14", "GPIO_15"; + function = "miim"; + }; + }; + + sgpio: gpio@710700f8 { + compatible = "mscc,ocelot-sgpio"; + #address-cells = <1>; + #size-cells = <0>; + bus-frequency = <12500000>; + clocks = <&ocelot_clock>; + microchip,sgpio-port-ranges = <0 15>; + pinctrl-names = "default"; + pinctrl-0 = <&sgpio_pins>; + reg = <0x710700f8>; + + sgpio_in0: gpio@0 { + compatible = "microchip,sparx5-sgpio-bank"; + reg = <0>; + gpio-controller; + #gpio-cells = <3>; + ngpios = <64>; + }; + + sgpio_out1: gpio@1 { + compatible = "microchip,sparx5-sgpio-bank"; + reg = <1>; + gpio-controller; + #gpio-cells = <3>; + ngpios = <64>; + }; + }; + }; + }; + +... + diff --git a/MAINTAINERS b/MAINTAINERS index 91b4151c5ad1..119fb4207ba3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14355,6 +14355,7 @@ F: tools/testing/selftests/drivers/net/ocelot/* OCELOT EXTERNAL SWITCH CONTROL M: Colin Foster S: Supported +F: Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml F: include/linux/mfd/ocelot.h OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER From patchwork Fri Jun 10 20:23:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12878094 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A046C433EF for ; Fri, 10 Jun 2022 20:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0YLUfXlKQzw2S8tXfFDxh1yEljUeBmulhTFYpn0YcZ8=; b=b12zmaapiAamQZ a0Jn14sPIwYyZFTGyxeLezO1aSCxDMuSKzW754jWxBySpZx9KuF2MN7iILz+0B9CHZaJIQgkTp8A/ xiJGokMdU4JLtev0/qpvsEIFl1SZKLjywVD2KOcJe3v7J89jtyRBTtY58o0fg4wzlj4u/AvSasxUL JswYVc9isYCHTMZTGZ57ri1nfneEXP5zCkbuF+1a/pVrNTsylLu9GcgUasDxTJOBrSWiHgBZKP8nu T6LnUutoytlmPUEn+HBO3mGTYw33sh8g6VtBHgsvf0UhHzfM6FyeYYd4iVc5WoC/95IaZsYZhIOvO 3yM1W1/P/Mmi3vgydp8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlDJ-009jXi-O2; Fri, 10 Jun 2022 20:26:38 +0000 Received: from mail-mw2nam10on2072f.outbound.protection.outlook.com ([2a01:111:f400:7e89::72f] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzlAl-009iBJ-GV for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 20:24:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RUFLFQIcgEs5fAwcOLIPHyUDw96buS3NQWoVZL6jv9MEcub28hRK/pJkZejMpjXjMGOri/EhNCSRg9Gn/mja0Wd5zJtY/vfh0VQ+6T3ssIFA7K0YjJYX04VLg2xMxdpiACK5O5BN/5yciKs1pbLXgN532TsljfVHR4d4Qe/vSFyze8/MZ+eVaCBZPoDIEPMd+33Xey68el/creaePgUVUtFtJ/jMYJYt69JZeoyBQqGEh786i/22dxV+WkK+PSRa/u1uHxxSefmbGApoAkiQb7dDw2esa/clnO/xqiv2aq1FfiKCwBkM0hny/SssZpB1+qh2v0/1EKR+DJecowU3Dg== 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=cwnsPo0wRnz1YiT6eiolrvkTeqX/VXDDVkcIOExa3iQ=; b=Mb7+WynaqAkxkKzkQ+9i9Vuit0uw8Mx/6PNKQeA7N2DAwCPb1vRsnwphkcZogmdWOdr7InI35YEq+cWChdQ7921ihXW1AGPVojf4mrK9COtH8Tj6+AD/6Z2yp36s2VeBwcwbCzIg9oeHmkvJsk+J8Ha3YHbhJpZHl3i1B1o5xUI7d/tnh5/B1e0+/BoXNQUybBXlBSEpJMZ3ypJ751ueyEa9fOXu2n7XcjWmtUnjSsAeqP73vutQmCeHZzq4ie1QJJHM1g1Bj+rL5GPMBz1dQWeXlP7Z5Is0YvsiDk+SJ3hrrtxyUv78U9nq/83dHUEF3wmnrjc0YJjvDgyKXvnRLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cwnsPo0wRnz1YiT6eiolrvkTeqX/VXDDVkcIOExa3iQ=; b=fe4GhD+b6COvM8nlJ751H1uouCuLQ2ptlmrogETUx62yvtQN5jYv4CAMCMIS4Dna5ZK64zpnHaFoOLPCc1a+uR/XgdlfQJp+07ntGpSSnQoz82pNSPrMQXV7KosS9CF7D2fwKNkGuJ2775N/bx/+/beepbzbLZq654eo9rN+LPU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1629.namprd10.prod.outlook.com (2603:10b6:301:9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Fri, 10 Jun 2022 20:23:51 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f%7]) with mapi id 15.20.5332.014; Fri, 10 Jun 2022 20:23:51 +0000 From: Colin Foster To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Linus Walleij , Wolfram Sang , Terry Bowman , Andy Shevchenko Subject: [PATCH v10 net-next 7/7] mfd: ocelot: add support for the vsc7512 chip via spi Date: Fri, 10 Jun 2022 13:23:30 -0700 Message-Id: <20220610202330.799510-8-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610202330.799510-1-colin.foster@in-advantage.com> References: <20220610202330.799510-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0246.namprd04.prod.outlook.com (2603:10b6:303:88::11) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a3b1176-5521-4240-69fb-08da4b1f21bc X-MS-TrafficTypeDiagnostic: MWHPR10MB1629: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: LHwwh+AuVYdaPiOENwicfJJ2CNU0llGofqp4dbq5w71+kHvAp17Q2KoWw1EYH4JgXuMokvsriu5YniRtPjNvXTSPBpmmtSsPYEGgWgP5VX5N0CdRlrufm/sDw6EJqv985tyWeV4rKEiBrBTAPBhezrI7EVFsthqhNdMPoWVljwkS3YqMfFNnveF1KJTQdXNAZsWGH7IU60Q4r8PfY9Vh6aZ3SEMv8lG9oLap2DpY32SnWCH8XcSSVciivjFWvSxo+TMzZZR3X0OF5ckN6wI68Vu5OqqHWYYiLMhVQORS81jNUewwN1iN6kkM70RtMgat3qE+NPDQji0WboZmmvjZUc9grNzioTBT3TFeO5i4wGxv1M5BysoFWy3v7Nfao4+I0cjTMB1T0S65NdTASaLQJnEPA7kzt0UvbOy7gIgvWpJ4Y0fr3zXbJQB2Ni3q7hTxpcflJSvEnihBjkPtuJwjZex3CRXssWvxtq3LArIV+Rf0QBAHMLbCVHHdyiyF3WMpqBgEv1yfdQEdqHQyXREbc7NW5+hLv389WTRqsRpj8QLmBAl0pCqua0pw9EaLRYB3J7tCrbGl7dGURwCFcDTAX3Vdk5sXGl8FW1wLpiBQes9niMOAMT5LAVsZOgxS9QD4QrcRrwfuAPQjulARuEoWM3W5nNQzUYr//ysR4PFkbesAUuQJ6myB928Z+9uMInhDc2C3/cvcbUcR+LdmW4nyDg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2351.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(39830400003)(396003)(366004)(346002)(316002)(83380400001)(2616005)(2906002)(1076003)(6486002)(54906003)(8936002)(36756003)(6666004)(52116002)(6512007)(6506007)(26005)(186003)(41300700001)(86362001)(44832011)(66556008)(66476007)(38100700002)(38350700002)(5660300002)(4326008)(7416002)(8676002)(30864003)(508600001)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QLQFLCET69UgnADzwKfmm6MP2aOMBwo5jkIUEJhl1jaOuzoiviSlujm05uKdlAa0O1tymMNyUZd7q8Uc7tT1u8Ds/huBz5wg4BWugDM3fD3gSs+8CSsnmJQhH2ExtqJ5mYQvnR+ulHtOHIvD2MjhwwI6zwOIEVAJsDu/aIGLWT55gT3puXr8Im56M9eprDEBN3i/e72T/hOu0e8NhBdEsR8b1YvMn0ONbdOs7XS1R9MJOnVxYBn4gX+6YjJYtodJ28hvz+oitA8knYxqFWu90CPoCpf+IhmrBh1LLFPFgYR8vJH9BeGkZc7bWf+jkENPXFh2Sg0mJv2R8ve1FPBD2UNcrqooil8p+G5jULfGhK0R1FE5ITVUAX+2lhlf/nVW93inhpOkK+ksVKrBZWT9Pn+my6xFvhFKuvN7a6JaoYX/nrPiu6uqbkHcQDeDso4O3VyR+t82M87+dCt8j951OsHqA/KaU10KGJSSuVZxmwdixQZjhxv8Lm0gzgKoFXyY8Kns6mB4+O5fenf8E2Be2U2pEIWsztgTQrm6Fqfyi5Rr3neDIl/CRi2Y/K0f+ut1LeOm3WO4HONh1BkYHBHEtYXZoOYNBWZy26LpoVRBK4rdyUA0dAN0LbIwXqP+tnutcFmpzmsaxAebyXm/pZnZa1tDotde7San7nf8ErbN7MbkiVXZsVRCNr+y83t8VYunIaQ/codmgs8C+iaWyRb7OLSsYcl/u94tTGTJpHNejQBy0kxf7ei4Vleh+AlcAopTQfEEsTSy8tE0MIkPyFcTW3ONuwFiTjkgE7v9hfkCCkTLWs1ROB3dHhwwlwL9TAJxqYSwnCB4VeB/WnMZ1hKnpJm2j13LyTDSjvmQU3QboCqw7m4Ju871tHL0ub+I/djdWaylZfs7anR6TvCJmGsKza8+8kRP+Zztxic533XgqPT9I/S7tuSIEDAG3kgHue0P/57DVkTC8TVHsx2d6fP/GGxrbZtwDtqCc78NfE5Byb1T3aFgf49ORk5ZJP1slI1uzRIj59aL0uHbGMH03xz+gZXEgh9huqiyh0vEaayzj7itRKooq5gPObaMvgoCAzIKK8LZWBicA7WBbTCTF5XVUSdPJI2DcDuB/6umAAi7ICLsuZjE5ufbivnUcH6qf6SDHz49hJLZ09/BkBwySWQ42Z12UTZ7b2hCF/f5Ja+gZNSAuglU6behZ5g4+gvLJHZiqDR/lxKrSPZw5Eh4+4AbpdqkWx5O4olLXaYTl84fAjAcpjxJ/5B1o0YjVkbTx9aSXgvGzYxTYNlNb3obd05XAoQe3HBEDFhZ2SEXdiajPRzQZBkzcSMWoxvsB/kjgqAOBrn0TxP4tyqfG7yT1PwbpLFz+o3GcJMlhkX4SZReFYd+OrbYgPMh8F64RFqHqdHSuVvPi3711Ei1n13iVJK1uIVnn9QbjGEiUGc8SYIHgYIv88/QDGfrgm2f7WDh7v2Y66ZQn1vErmyivfjiksCMQdTXkgOfGjSQSlLLLmCu/8wXrrR2op6yRMiLr58BHWNitgHXawG2etDgW2rL8bgQIpZFLAn6ZfWB0y6Bqhgt735goLxdlMaY7xAn+4RIQRnF26ErbFY5IR6XU6XTtWKSKZIdWwYiBLYu99Llb2phJ0vIl8uO62AM/XiGMVgG9LW+YClM2aIOnnFe0nyMRqOQyMVyJuCx0y5TbraaBV6oOK9E0JwELx0HMIRhECR7XOWiptxeUGtmLLI40WxpDAAUjsbFxuFC6AuCySwg//yOWqcbOaRUTyqvMHeiKgAwhk0v X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a3b1176-5521-4240-69fb-08da4b1f21bc X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 20:23:51.0911 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gUjVWKDa4Bg5TBwRcvKP88AZ2d2BXZs62OyUg8hyz/ddZ3ak6c5rWkHN1FOIo2F1I5I7d4XnGMxiMzVtlh2zDphC2rjSy/h4P+NTRl+LI98= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1629 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_132359_653172_5372A73B X-CRM114-Status: GOOD ( 24.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The VSC7512 is a networking chip that contains several peripherals. Many of these peripherals are currently supported by the VSC7513 and VSC7514 chips, but those run on an internal CPU. The VSC7512 lacks this CPU, and must be controlled externally. Utilize the existing drivers by referencing the chip as an MFD. Add support for the two MDIO buses, the internal phys, pinctrl, and serial GPIO. Signed-off-by: Colin Foster Reported-by: kernel test robot Reported-by: kernel test robot --- MAINTAINERS | 1 + drivers/mfd/Kconfig | 18 +++ drivers/mfd/Makefile | 2 + drivers/mfd/ocelot-core.c | 175 +++++++++++++++++++++ drivers/mfd/ocelot-spi.c | 313 +++++++++++++++++++++++++++++++++++++ drivers/mfd/ocelot.h | 28 ++++ include/linux/mfd/ocelot.h | 10 ++ 7 files changed, 547 insertions(+) create mode 100644 drivers/mfd/ocelot-core.c create mode 100644 drivers/mfd/ocelot-spi.c create mode 100644 drivers/mfd/ocelot.h diff --git a/MAINTAINERS b/MAINTAINERS index 119fb4207ba3..d24ec7c591a6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14356,6 +14356,7 @@ OCELOT EXTERNAL SWITCH CONTROL M: Colin Foster S: Supported F: Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml +F: drivers/mfd/ocelot* F: include/linux/mfd/ocelot.h OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 3b59456f5545..6887b513b3fb 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -962,6 +962,24 @@ config MFD_MENF21BMC This driver can also be built as a module. If so the module will be called menf21bmc. +config MFD_OCELOT + bool "Microsemi Ocelot External Control Support" + depends on SPI_MASTER + select MFD_CORE + select REGMAP_SPI + help + Ocelot is a family of networking chips that support multiple ethernet + and fibre interfaces. In addition to networking, they contain several + other functions, including pictrl, MDIO, and communication with + external chips. While some chips have an internal processor capable of + running an OS, others don't. All chips can be controlled externally + through different interfaces, including SPI, I2C, and PCIe. + + Say yes here to add support for Ocelot chips (VSC7511, VSC7512, + VSC7513, VSC7514) controlled externally. + + If unsure, say N. + config EZX_PCAP bool "Motorola EZXPCAP Support" depends on SPI_MASTER diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 858cacf659d6..bc517632ba5f 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -120,6 +120,8 @@ obj-$(CONFIG_MFD_MC13XXX_I2C) += mc13xxx-i2c.o obj-$(CONFIG_MFD_CORE) += mfd-core.o +obj-$(CONFIG_MFD_OCELOT) += ocelot-core.o ocelot-spi.o + obj-$(CONFIG_EZX_PCAP) += ezx-pcap.o obj-$(CONFIG_MFD_CPCAP) += motorola-cpcap.o diff --git a/drivers/mfd/ocelot-core.c b/drivers/mfd/ocelot-core.c new file mode 100644 index 000000000000..7ec5245f24c6 --- /dev/null +++ b/drivers/mfd/ocelot-core.c @@ -0,0 +1,175 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Core driver for the Ocelot chip family. + * + * The VSC7511, 7512, 7513, and 7514 can be controlled internally via an + * on-chip MIPS processor, or externally via SPI, I2C, PCIe. This core driver is + * intended to be the bus-agnostic glue between, for example, the SPI bus and + * the child devices. + * + * Copyright 2021, 2022 Innovative Advantage Inc. + * + * Author: Colin Foster + */ + +#include +#include +#include +#include +#include + +#include "ocelot.h" + +#define GCB_SOFT_RST 0x0008 + +#define SOFT_CHIP_RST 0x1 + +#define VSC7512_MIIM0_RES_START 0x7107009c +#define VSC7512_MIIM0_RES_SIZE 0x24 + +#define VSC7512_MIIM1_RES_START 0x710700c0 +#define VSC7512_MIIM1_RES_SIZE 0x24 + +#define VSC7512_PHY_RES_START 0x710700f0 +#define VSC7512_PHY_RES_SIZE 0x4 + +#define VSC7512_GPIO_RES_START 0x71070034 +#define VSC7512_GPIO_RES_SIZE 0x6c + +#define VSC7512_SIO_CTRL_RES_START 0x710700f8 +#define VSC7512_SIO_CTRL_RES_SIZE 0x100 + +#define VSC7512_GCB_RST_SLEEP 100 +#define VSC7512_GCB_RST_TIMEOUT 100000 + +static int ocelot_gcb_chip_rst_status(struct ocelot_ddata *ddata) +{ + int val, err; + + err = regmap_read(ddata->gcb_regmap, GCB_SOFT_RST, &val); + if (err) + val = -1; + + return val; +} + +int ocelot_chip_reset(struct device *dev) +{ + struct ocelot_ddata *ddata = dev_get_drvdata(dev); + int ret, val; + + /* + * Reset the entire chip here to put it into a completely known state. + * Other drivers may want to reset their own subsystems. The register + * self-clears, so one write is all that is needed and wait for it to + * clear. + */ + ret = regmap_write(ddata->gcb_regmap, GCB_SOFT_RST, SOFT_CHIP_RST); + if (ret) + return ret; + + ret = readx_poll_timeout(ocelot_gcb_chip_rst_status, ddata, val, !val, + VSC7512_GCB_RST_SLEEP, + VSC7512_GCB_RST_TIMEOUT); + if (ret) + return dev_err_probe(ddata->dev, ret, "timeout: chip reset\n"); + + return 0; +} +EXPORT_SYMBOL_NS(ocelot_chip_reset, MFD_OCELOT); + +static const struct resource vsc7512_miim0_resources[] = { + DEFINE_RES_REG_NAMED(VSC7512_MIIM0_RES_START, VSC7512_MIIM0_RES_SIZE, + "gcb_miim0"), + DEFINE_RES_REG_NAMED(VSC7512_PHY_RES_START, VSC7512_PHY_RES_SIZE, + "gcb_phy"), +}; + +static const struct resource vsc7512_miim1_resources[] = { + DEFINE_RES_REG_NAMED(VSC7512_MIIM1_RES_START, VSC7512_MIIM1_RES_SIZE, + "gcb_miim1"), +}; + +static const struct resource vsc7512_pinctrl_resources[] = { + DEFINE_RES_REG_NAMED(VSC7512_GPIO_RES_START, VSC7512_GPIO_RES_SIZE, + "gcb_gpio"), +}; + +static const struct resource vsc7512_sgpio_resources[] = { + DEFINE_RES_REG_NAMED(VSC7512_SIO_CTRL_RES_START, + VSC7512_SIO_CTRL_RES_SIZE, + "gcb_sio"), +}; + +static const struct mfd_cell vsc7512_devs[] = { + { + .name = "ocelot-pinctrl", + .of_compatible = "mscc,ocelot-pinctrl", + .num_resources = ARRAY_SIZE(vsc7512_pinctrl_resources), + .resources = vsc7512_pinctrl_resources, + }, { + .name = "ocelot-sgpio", + .of_compatible = "mscc,ocelot-sgpio", + .num_resources = ARRAY_SIZE(vsc7512_sgpio_resources), + .resources = vsc7512_sgpio_resources, + }, { + .name = "ocelot-miim0", + .of_compatible = "mscc,ocelot-miim", + .of_reg = vsc7512_miim0_resources[0].start, + .use_of_reg = true, + .num_resources = ARRAY_SIZE(vsc7512_miim0_resources), + .resources = vsc7512_miim0_resources, + }, { + .name = "ocelot-miim1", + .of_compatible = "mscc,ocelot-miim", + .num_resources = ARRAY_SIZE(vsc7512_miim1_resources), + .of_reg = vsc7512_miim1_resources[0].start, + .use_of_reg = true, + .resources = vsc7512_miim1_resources, + }, +}; + +void +ocelot_platform_init_regmap_from_resource(struct platform_device *pdev, + unsigned int index, + struct regmap **map, + struct resource **res, + const struct regmap_config *config) +{ + struct device *dev = &pdev->dev; + struct resource *resource; + struct resource **pres; + u32 __iomem *regs; + + *map = ERR_PTR(ENODEV); + pres = res ? res : &resource; + + regs = devm_platform_get_and_ioremap_resource(pdev, index, res); + if (IS_ERR(regs)) { + /* + * Fall back to using IORESOURCE_REG, which is possible in an + * MFD configuration + */ + *pres = platform_get_resource(pdev, IORESOURCE_REG, index); + if (!*pres) { + dev_err_probe(dev, PTR_ERR(*pres), + "Failed to get resource\n"); + return; + } + + *map = ocelot_spi_init_regmap(dev->parent, dev, *pres); + } else { + *map = devm_regmap_init_mmio(dev, regs, config); + } +} + +int ocelot_core_init(struct device *dev) +{ + return devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, vsc7512_devs, + ARRAY_SIZE(vsc7512_devs), NULL, 0, NULL); +} +EXPORT_SYMBOL_NS(ocelot_core_init, MFD_OCELOT); + +MODULE_DESCRIPTION("Externally Controlled Ocelot Chip Driver"); +MODULE_AUTHOR("Colin Foster "); +MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/ocelot-spi.c b/drivers/mfd/ocelot-spi.c new file mode 100644 index 000000000000..e07dc1d040a8 --- /dev/null +++ b/drivers/mfd/ocelot-spi.c @@ -0,0 +1,313 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * SPI core driver for the Ocelot chip family. + * + * This driver will handle everything necessary to allow for communication over + * SPI to the VSC7511, VSC7512, VSC7513 and VSC7514 chips. The main functions + * are to prepare the chip's SPI interface for a specific bus speed, and a host + * processor's endianness. This will create and distribute regmaps for any + * children. + * + * Copyright 2021, 2022 Innovative Advantage Inc. + * + * Author: Colin Foster + */ + +#include +#include +#include +#include +#include + +#include + +#include "ocelot.h" + +#define DEV_CPUORG_IF_CTRL 0x0000 +#define DEV_CPUORG_IF_CFGSTAT 0x0004 + +#define CFGSTAT_IF_NUM_VCORE (0 << 24) +#define CFGSTAT_IF_NUM_VRAP (1 << 24) +#define CFGSTAT_IF_NUM_SI (2 << 24) +#define CFGSTAT_IF_NUM_MIIM (3 << 24) + +#define VSC7512_DEVCPU_ORG_RES_START 0x71000000 +#define VSC7512_DEVCPU_ORG_RES_SIZE 0x38 + +#define VSC7512_CHIP_REGS_RES_START 0x71070000 +#define VSC7512_CHIP_REGS_RES_SIZE 0x14 + +static const struct resource vsc7512_dev_cpuorg_resource = + DEFINE_RES_REG_NAMED(VSC7512_DEVCPU_ORG_RES_START, + VSC7512_DEVCPU_ORG_RES_SIZE, + "devcpu_org"); + +static const struct resource vsc7512_gcb_resource = + DEFINE_RES_REG_NAMED(VSC7512_CHIP_REGS_RES_START, + VSC7512_CHIP_REGS_RES_SIZE, + "devcpu_gcb_chip_regs"); + +static int ocelot_spi_initialize(struct device *dev) +{ + struct ocelot_ddata *ddata = dev_get_drvdata(dev); + u32 val, check; + int err; + + val = OCELOT_SPI_BYTE_ORDER; + + /* + * The SPI address must be big-endian, but we want the payload to match + * our CPU. These are two bits (0 and 1) but they're repeated such that + * the write from any configuration will be valid. The four + * configurations are: + * + * 0b00: little-endian, MSB first + * | 111111 | 22221111 | 33222222 | + * | 76543210 | 54321098 | 32109876 | 10987654 | + * + * 0b01: big-endian, MSB first + * | 33222222 | 22221111 | 111111 | | + * | 10987654 | 32109876 | 54321098 | 76543210 | + * + * 0b10: little-endian, LSB first + * | 111111 | 11112222 | 22222233 | + * | 01234567 | 89012345 | 67890123 | 45678901 | + * + * 0b11: big-endian, LSB first + * | 22222233 | 11112222 | 111111 | | + * | 45678901 | 67890123 | 89012345 | 01234567 | + */ + err = regmap_write(ddata->cpuorg_regmap, DEV_CPUORG_IF_CTRL, val); + if (err) + return err; + + /* + * Apply the number of padding bytes between a read request and the data + * payload. Some registers have access times of up to 1us, so if the + * first payload bit is shifted out too quickly, the read will fail. + */ + val = ddata->spi_padding_bytes; + err = regmap_write(ddata->cpuorg_regmap, DEV_CPUORG_IF_CFGSTAT, val); + if (err) + return err; + + /* + * After we write the interface configuration, read it back here. This + * will verify several different things. The first is that the number of + * padding bytes actually got written correctly. These are found in bits + * 0:3. + * + * The second is that bit 16 is cleared. Bit 16 is IF_CFGSTAT:IF_STAT, + * and will be set if the register access is too fast. This would be in + * the condition that the number of padding bytes is insufficient for + * the SPI bus frequency. + * + * The last check is for bits 31:24, which define the interface by which + * the registers are being accessed. Since we're accessing them via the + * serial interface, it must return IF_NUM_SI. + */ + check = val | CFGSTAT_IF_NUM_SI; + + err = regmap_read(ddata->cpuorg_regmap, DEV_CPUORG_IF_CFGSTAT, &val); + if (err) + return err; + + if (check != val) + return -ENODEV; + + return 0; +} + +static const struct regmap_config ocelot_spi_regmap_config = { + .reg_bits = 24, + .reg_stride = 4, + .reg_downshift = 2, + .val_bits = 32, + + .write_flag_mask = 0x80, + + .use_single_write = true, + .can_multi_write = false, + + .reg_format_endian = REGMAP_ENDIAN_BIG, + .val_format_endian = REGMAP_ENDIAN_NATIVE, +}; + +static int ocelot_spi_regmap_bus_read(void *context, + const void *reg, size_t reg_size, + void *val, size_t val_size) +{ + struct ocelot_ddata *ddata = context; + static const u8 dummy_buf[16] = {0}; + struct spi_transfer tx, padding, rx; + struct spi_device *spi = ddata->spi; + struct spi_message msg; + + spi = ddata->spi; + + spi_message_init(&msg); + + memset(&tx, 0, sizeof(tx)); + + tx.tx_buf = reg; + tx.len = reg_size; + + spi_message_add_tail(&tx, &msg); + + if (ddata->spi_padding_bytes) { + memset(&padding, 0, sizeof(padding)); + + padding.len = ddata->spi_padding_bytes; + padding.tx_buf = dummy_buf; + padding.dummy_data = 1; + + spi_message_add_tail(&padding, &msg); + } + + memset(&rx, 0, sizeof(rx)); + rx.rx_buf = val; + rx.len = val_size; + + spi_message_add_tail(&rx, &msg); + + return spi_sync(spi, &msg); +} + +static int ocelot_spi_regmap_bus_write(void *context, const void *data, + size_t count) +{ + struct ocelot_ddata *ddata = context; + struct spi_device *spi = ddata->spi; + + return spi_write(spi, data, count); +} + +static const struct regmap_bus ocelot_spi_regmap_bus = { + .write = ocelot_spi_regmap_bus_write, + .read = ocelot_spi_regmap_bus_read, +}; + +struct regmap * +ocelot_spi_init_regmap(struct device *dev, struct device *child, + const struct resource *res) +{ + struct ocelot_ddata *ddata = dev_get_drvdata(dev); + struct regmap_config regmap_config; + + memcpy(®map_config, &ocelot_spi_regmap_config, + sizeof(regmap_config)); + + regmap_config.name = res->name; + regmap_config.max_register = res->end - res->start; + regmap_config.reg_base = res->start; + + return devm_regmap_init(child, &ocelot_spi_regmap_bus, ddata, + ®map_config); +} + +static int ocelot_spi_probe(struct spi_device *spi) +{ + struct device *dev = &spi->dev; + struct ocelot_ddata *ddata; + struct regmap *r; + int err; + + ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); + if (!ddata) + return -ENOMEM; + + ddata->dev = dev; + dev_set_drvdata(dev, ddata); + + if (spi->max_speed_hz <= 500000) { + ddata->spi_padding_bytes = 0; + } else { + /* + * Calculation taken from the manual for IF_CFGSTAT:IF_CFG. + * Register access time is 1us, so we need to configure and send + * out enough padding bytes between the read request and data + * transmission that lasts at least 1 microsecond. + */ + ddata->spi_padding_bytes = 1 + + (spi->max_speed_hz / 1000000 + 2) / 8; + } + + ddata->spi = spi; + + spi->bits_per_word = 8; + + err = spi_setup(spi); + if (err < 0) { + return dev_err_probe(&spi->dev, err, + "Error performing SPI setup\n"); + } + + r = ocelot_spi_init_regmap(dev, dev, &vsc7512_dev_cpuorg_resource); + if (IS_ERR(r)) + return PTR_ERR(r); + + ddata->cpuorg_regmap = r; + + r = ocelot_spi_init_regmap(dev, dev, &vsc7512_gcb_resource); + if (IS_ERR(r)) + return PTR_ERR(r); + + ddata->gcb_regmap = r; + + /* + * The chip must be set up for SPI before it gets initialized and reset. + * This must be done before calling init, and after a chip reset is + * performed. + */ + err = ocelot_spi_initialize(dev); + if (err) + return dev_err_probe(dev, err, "Error initializing SPI bus\n"); + + err = ocelot_chip_reset(dev); + if (err) + return dev_err_probe(dev, err, "Error resetting device\n"); + + /* + * A chip reset will clear the SPI configuration, so it needs to be done + * again before we can access any registers + */ + err = ocelot_spi_initialize(dev); + if (err) { + return dev_err_probe(dev, err, + "Error initializing SPI bus after reset\n"); + } + + err = ocelot_core_init(dev); + if (err < 0) { + return dev_err_probe(dev, err, + "Error initializing Ocelot core\n"); + return err; + } + + return 0; +} + +static const struct spi_device_id ocelot_spi_ids[] = { + { "vsc7512", 0 }, + { } +}; + +static const struct of_device_id ocelot_spi_of_match[] = { + { .compatible = "mscc,vsc7512-spi" }, + { } +}; +MODULE_DEVICE_TABLE(of, ocelot_spi_of_match); + +static struct spi_driver ocelot_spi_driver = { + .driver = { + .name = "ocelot_spi", + .of_match_table = ocelot_spi_of_match, + }, + .id_table = ocelot_spi_ids, + .probe = ocelot_spi_probe, +}; +module_spi_driver(ocelot_spi_driver); + +MODULE_DESCRIPTION("SPI Controlled Ocelot Chip Driver"); +MODULE_AUTHOR("Colin Foster "); +MODULE_LICENSE("Dual MIT/GPL"); diff --git a/drivers/mfd/ocelot.h b/drivers/mfd/ocelot.h new file mode 100644 index 000000000000..cf33c3ab89c2 --- /dev/null +++ b/drivers/mfd/ocelot.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* Copyright 2021, 2022 Innovative Advantage Inc. */ + +#include + +struct ocelot_ddata { + struct device *dev; + struct regmap *gcb_regmap; + struct regmap *cpuorg_regmap; + int spi_padding_bytes; + struct spi_device *spi; +}; + +int ocelot_chip_reset(struct device *dev); +int ocelot_core_init(struct device *dev); + +/* SPI-specific routines that won't be necessary for other interfaces */ +struct regmap *ocelot_spi_init_regmap(struct device *dev, struct device *child, + const struct resource *res); + +#define OCELOT_SPI_BYTE_ORDER_LE 0x00000000 +#define OCELOT_SPI_BYTE_ORDER_BE 0x81818181 + +#ifdef __LITTLE_ENDIAN +#define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_LE +#else +#define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_BE +#endif diff --git a/include/linux/mfd/ocelot.h b/include/linux/mfd/ocelot.h index effa4cc0fc43..6879932a8c68 100644 --- a/include/linux/mfd/ocelot.h +++ b/include/linux/mfd/ocelot.h @@ -2,9 +2,18 @@ /* Copyright 2022 Innovative Advantage Inc. */ #include +#include #include #include +#if IS_ENABLED(CONFIG_MFD_OCELOT) +void +ocelot_platform_init_regmap_from_resource(struct platform_device *pdev, + unsigned int index, + struct regmap **map, + struct resource **res, + const struct regmap_config *config); +#else static inline void ocelot_platform_init_regmap_from_resource(struct platform_device *pdev, unsigned int index, @@ -20,3 +29,4 @@ ocelot_platform_init_regmap_from_resource(struct platform_device *pdev, else *map = ERR_PTR(ENODEV); } +#endif