From patchwork Thu Jan 19 03:51:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Larson X-Patchwork-Id: 45581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp136457wrn; Wed, 18 Jan 2023 20:29:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXsesDqaAQBXisG9hi188U4SbH5jLERKu6MD8efboEiPD3mBUw70PYvHN9p4b5KrdYBzUT66 X-Received: by 2002:a17:906:6c8b:b0:867:f167:43be with SMTP id s11-20020a1709066c8b00b00867f16743bemr8517177ejr.77.1674102545686; Wed, 18 Jan 2023 20:29:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674102545; cv=pass; d=google.com; s=arc-20160816; b=vprRuNDY6j8WPLZHYOZaynRI2VQOPhdAsvLYBlRZyjTvcYbRvgs1EelHt5uZBcSsGn JQTV5mpAKmeM2oFqBnVacTtxKHNILcjK/JJiMxLGzf1Cpl6xq1/TTk1vTBQJiV8ScHEe NYLQ9OYiaQydRcf0QBSayZoTr+OjToF/K6fFuqfSrfj1v9Gj0S0P/aUhAYLsb0YS3uC3 voEwqVhudvRL5fZVkhe+YLFTWMPWY9Fn+af9aphSfEOc2b0y8ReSCVSEjQPcF6c9fUDp JMeR6S7ZFrHErr5Me/4avL/42ekDAlK1eRlm8YgbFSpBNOknRY6g5qNZgMJ92b0ZzlyB RDvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HoxgLjiKMEnBReX8y4HZGzgpLE7NIwrXXlAdWPhN3h8=; b=j9znLTheDXXiFVCUor6eZO3knLQpRjA6DwuwZSM9+XlM1GfKaY7RQx56IxhK5urvaS OJoTWW1On6J6/KFN1vBTVvlT4iJn2aMzOrHGk7otuqS6TFTu8TFOqs3ljViYjv6qoNeq m2Por7CsVTuoUXG1INAdCz8s2wH+OzSu1pDiqEjoiwQQs1YrGnpcS3nTAlo5zjw8Sx4n CZeyaohccoiq6ZPDu9juHiBAlWKjl42woOwms8MI6+FUH+Z8FoYXCjiilRoE5TbIq/C6 lvdKeLvJmK5ZSPyH57XTzEyw9xM6fUOu0+1QxXWZPyr1Wz+EqkI8FL9KpFwLG9bvi6sP cp7w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lWBlTS7O; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt17-20020a170907729100b0084d1d7fbd27si42482612ejc.205.2023.01.18.20.28.41; Wed, 18 Jan 2023 20:29:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lWBlTS7O; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229937AbjASE1v (ORCPT + 99 others); Wed, 18 Jan 2023 23:27:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbjASEIq (ORCPT ); Wed, 18 Jan 2023 23:08:46 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32DA569B09; Wed, 18 Jan 2023 20:03:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nr5dBrb6PM87SH0GSxfeai4SmGFS10Q8iHPdcmgEVm6tuOOjaoQpXJ1nLorU2iq87/isErJ1FnVqUwintTgQvmd7LAuMteEGT0o6nMr2ChbPocbco45zN12VuDuc8hu04eyxmBaY85CfAEvwWeAB3gdEWj8bR7ZJuN2oYKil8jPi6HMB7YrwRC9u6MdsNpE7DvTDARcSqnJP7s2eBXu1bx1gb8XPwBJhvEPbnnAhvW3EFdzx4FRbMLZX3N6bcKyFE4u8jnGjQF6W3JWp7ntCWhC19I7fXKQf7GHrm7dAAsBmp2b1G0GwCveLsfaQsXehVrwVuyjNr3ZVlRcJSXV5Zg== 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=HoxgLjiKMEnBReX8y4HZGzgpLE7NIwrXXlAdWPhN3h8=; b=m40rkfcNwQK3o1zqI7WtktDzZS/fpymlX5+JBBGwW3BKu/6IsWUOFSBAqnwwD5WmYUgYGXa/Ppn+7AhN6zGtVk7eE993Wv4+nKWy6orX1Zi7Yc3Um0ndkGELNNPfiIH72+JMgM1WbvkJagTnMyseFdgfgbeEEE6knrnh3OIHkL4Oqf1btxMrcRqq+AOnssQpVEgnqmYl+eE+Cu1JNUcjAfihp8MdfsgGH4inARdfPyZTZD3UAr7CWhBUMrZAfmux72aFFQxykJTFjcoGfcymvNl9SJECip1lS52fqn6wdVKTw0WJDBim9szfkjkwETs+mhxtDCH/+4MauXBqRRuZhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HoxgLjiKMEnBReX8y4HZGzgpLE7NIwrXXlAdWPhN3h8=; b=lWBlTS7OAmJrINY4lbXJxXZrzItydlDvmBME0xsN+Jk9LIBS9z5KbBKs4yYw5EnqPY3fikOdA2mxppxAQaoX4oldAWiz5DJ93onJaD1stWKjOGgyp6kglqXcOjZomTy600uNJMM5KKoAYnb3y3QZOE89ebd+P+/NTn1JEweqItI= Received: from MW4PR04CA0321.namprd04.prod.outlook.com (2603:10b6:303:82::26) by SA1PR12MB6918.namprd12.prod.outlook.com (2603:10b6:806:24d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Thu, 19 Jan 2023 03:52:56 +0000 Received: from CO1NAM11FT027.eop-nam11.prod.protection.outlook.com (2603:10b6:303:82:cafe::9e) by MW4PR04CA0321.outlook.office365.com (2603:10b6:303:82::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Thu, 19 Jan 2023 03:52:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT027.mail.protection.outlook.com (10.13.174.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6002.13 via Frontend Transport; Thu, 19 Jan 2023 03:52:56 +0000 Received: from platform-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 18 Jan 2023 21:52:51 -0600 From: Brad Larson To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 11/15] spi: dw: Add support for AMD Pensando Elba SoC Date: Wed, 18 Jan 2023 19:51:32 -0800 Message-ID: <20230119035136.21603-12-blarson@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230119035136.21603-1-blarson@amd.com> References: <20230119035136.21603-1-blarson@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT027:EE_|SA1PR12MB6918:EE_ X-MS-Office365-Filtering-Correlation-Id: cf8082cd-80d4-4fdc-2983-08daf9d0a639 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BdzrqELtXJ9EP2LCwBqVkjlXKlQeapygif4NgIiVtDC2LfOd3305nhYR97vLuWn2IZNodcI1qMbaX5ONmzfOXkMmwJd8R//izUKZ4ym+n2/2cbZpMVHzqnUsQK31zhkIxdqbQ0mzZDjpzvodsl62YD9nMzWyT3JEYsl6lJTqdQCfXuQT/VFSGY0CO6tuPpS8kgZhIGAmH8tpa0CUK5MsDbQlvFiqiLP5X8dCsdg+GVxj0InFtf+RxMC5RponzjnPCnYT1JcrRfD73H71w4JLhafxT0ypP5ZgkvikH0Mbdddhl4B27/FwfkLkxAirnEL7TBYWslcs9Tyj+0AxwF+hkQ7QCumrxD0oY0cDFU3iRVqhUjoSE0h67hgRh/N3hwpwtZy7rme0AYklOKZFU8AVaASsDwVZRNqtVpaWipZDFy0EBrMhl9CVMjgksnBiUsNH2vnfIctDGD+mjyyZvjtOzHbx79DPXnUwzfZO7vGqZEDfMSU/ZNE9+CQh901lNT+49O3b7zJ3t3WRDBtMxoBNChJkkAMjNcIssVEO/9CbFPM2HJUW6M+9mWCjBH254SXOLa1C48n9sSDVS/ykSG3E4+F9w9fzbEuYb0EXy1Y5Dl9Q5V8O13x56w4R2/m8ztkffrzz1T3MD0JYthpa3nhGWqpXzDC0K3KYJBPppZ+YP6aaDi0/IzG9H9771H9dTEH3eqS0bdW5jtZzDnFtEU1nvWB5dw4T5InzY0Vk+Bgl6Hs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(346002)(396003)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(82310400005)(36756003)(4326008)(2616005)(426003)(47076005)(6916009)(41300700001)(16526019)(70206006)(70586007)(26005)(8676002)(186003)(83380400001)(7416002)(316002)(2906002)(6666004)(478600001)(7406005)(356005)(40480700001)(54906003)(40460700003)(81166007)(36860700001)(336012)(8936002)(1076003)(82740400003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 03:52:56.2218 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf8082cd-80d4-4fdc-2983-08daf9d0a639 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT027.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6918 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755423751129415942?= X-GMAIL-MSGID: =?utf-8?q?1755423751129415942?= The AMD Pensando Elba SoC includes a DW apb_ssi v4 controller with device specific chip-select control. The Elba SoC provides four chip-selects where the native DW IP supports two chip-selects. The Elba DW_SPI instance has two native CS signals that are always overridden. Signed-off-by: Brad Larson --- Changes since v6: - Add use of macros GENMASK() and BIT() - Change ELBA_SPICS_SHIFT() to ELBA_SPICS_OFFSET() --- drivers/spi/spi-dw-mmio.c | 78 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 26c40ea6dd12..9b6f876227e8 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -53,6 +53,24 @@ struct dw_spi_mscc { void __iomem *spi_mst; /* Not sparx5 */ }; +struct dw_spi_elba { + struct regmap *syscon; +}; + +/* + * Elba SoC does not use ssi, pin override is used for cs 0,1 and + * gpios for cs 2,3 as defined in the device tree. + * + * cs: | 1 0 + * bit: |---3-------2-------1-------0 + * | cs1 cs1_ovr cs0 cs0_ovr + */ +#define ELBA_SPICS_REG 0x2468 +#define ELBA_SPICS_OFFSET(cs) ((cs) << 1) +#define ELBA_SPICS_MASK(cs) (GENMASK(1, 0) << ELBA_SPICS_OFFSET(cs)) +#define ELBA_SPICS_SET(cs, val) \ + ((((val) << 1) | BIT(0)) << ELBA_SPICS_OFFSET(cs)) + /* * The Designware SPI controller (referred to as master in the documentation) * automatically deasserts chip select when the tx fifo is empty. The chip @@ -237,6 +255,65 @@ static int dw_spi_canaan_k210_init(struct platform_device *pdev, return 0; } +static void dw_spi_elba_override_cs(struct dw_spi_elba *dwselba, int cs, int enable) +{ + regmap_update_bits(dwselba->syscon, ELBA_SPICS_REG, ELBA_SPICS_MASK(cs), + ELBA_SPICS_SET(cs, enable)); + +} + +static void dw_spi_elba_set_cs(struct spi_device *spi, bool enable) +{ + struct dw_spi *dws = spi_master_get_devdata(spi->master); + struct dw_spi_mmio *dwsmmio = container_of(dws, struct dw_spi_mmio, dws); + struct dw_spi_elba *dwselba = dwsmmio->priv; + u8 cs; + + cs = spi->chip_select; + if (cs < 2) + dw_spi_elba_override_cs(dwselba, spi->chip_select, enable); + + /* + * The DW SPI controller needs a native CS bit selected to start + * the serial engine. + */ + spi->chip_select = 0; + dw_spi_set_cs(spi, enable); + spi->chip_select = cs; +} + +static int dw_spi_elba_init(struct platform_device *pdev, + struct dw_spi_mmio *dwsmmio) +{ + const char *syscon_name = "amd,pensando-elba-syscon"; + struct device_node *np = pdev->dev.of_node; + struct dw_spi_elba *dwselba; + struct device_node *node; + struct regmap *regmap; + + node = of_parse_phandle(np, syscon_name, 0); + if (!node) { + dev_err(&pdev->dev, "failed to find %s\n", syscon_name); + return -ENODEV; + } + + regmap = syscon_node_to_regmap(node); + if (IS_ERR(regmap)) { + dev_err(&pdev->dev, "syscon regmap lookup failed\n"); + return PTR_ERR(regmap); + } + + dwselba = devm_kzalloc(&pdev->dev, sizeof(*dwselba), GFP_KERNEL); + if (!dwselba) + return -ENOMEM; + + dwselba->syscon = regmap; + dwsmmio->priv = dwselba; + dwsmmio->dws.set_cs = dw_spi_elba_set_cs; + + return 0; +} + static int dw_spi_mmio_probe(struct platform_device *pdev) { int (*init_func)(struct platform_device *pdev, @@ -352,6 +429,7 @@ static const struct of_device_id dw_spi_mmio_of_match[] = { { .compatible = "intel,thunderbay-ssi", .data = dw_spi_intel_init}, { .compatible = "microchip,sparx5-spi", dw_spi_mscc_sparx5_init}, { .compatible = "canaan,k210-spi", dw_spi_canaan_k210_init}, + { .compatible = "amd,pensando-elba-spi", .data = dw_spi_elba_init}, { /* end of table */} }; MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match);