Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp243860rwd; Wed, 31 May 2023 22:44:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Vt/icgbIE7QIAPaV0DWyWbmIFeOEMx3/CBQv0g6yF/uG/iHvcjp5A1YDCMnP0ZN8QsM+G X-Received: by 2002:a05:6a00:1493:b0:63f:2959:a271 with SMTP id v19-20020a056a00149300b0063f2959a271mr1104700pfu.6.1685598291143; Wed, 31 May 2023 22:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685598291; cv=none; d=google.com; s=arc-20160816; b=CmM+M81UEi0roPiAWMV1yM1tqxp1T7C3eBXZe7JRs4TXXSxJY+gmX6ILWLf1uQbMwt JIfBNwgDVu1j5QKZgRY96EmuEW0pd/7jGCuBZEB8shDPDkemH11LMeQb0yphlFG0BQCp BQb0fRMSoxnmSqQHvelUUAromu3RLQlFF6wsTV7oAAyDNOLEGck4hJ7iGQe0i6PvdFub xGIWoXvWSvpd3wRwoPf6WaAt39vyZeAsvjDJPlnfERCpOx/Jv5ltEE7Ca4irs8Xgx6TC OKsPe9XIOQ37tIhGgN10lP93HlgwL75kRcq5fQCMSG9i6tc4x2KgA6NqhFeN+c732AGW pg9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ut6yym3zcUOE3+YHsTvO+xo70T8aulUJvbdj7iY9758=; b=r5Dnb6bt7jaid76FtlTzeL6gBLgTTljcYE2NU1iaYnsQ9Hhb6S+g9KClCYrJ2V4I6Z tMdDwESSrsUoWZMWisNT9PnizIxFSB+PyBB7grS2SJXSHIV+eJKyhEoSty0cfWvLT3CU kXbY8+BDQZrmD/KLXBj3Uj43JBEW62Y3QYpyE7Ta6OlmPoqf+Rkl2iS38WoC5XHuP6gN 3Hr6g4NJlblJQ6Ck7pCgb5wNtPoCb6XvppnzatAiBVd1A/5B/N1HED46yrw+3+OXJatX onxb3brE+G9iSKPOynx7AetaGWA8faE3JIhazS6Rf+WEqZscER+RlbSIA0SFp6v2rz24 7gzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maquefel.me header.s=mail header.b=ZUcpBJda; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d190-20020a621dc7000000b0064f51d5ac1fsi4837553pfd.363.2023.05.31.22.44.39; Wed, 31 May 2023 22:44:51 -0700 (PDT) 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=@maquefel.me header.s=mail header.b=ZUcpBJda; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231592AbjFAFio (ORCPT + 99 others); Thu, 1 Jun 2023 01:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231424AbjFAFiP (ORCPT ); Thu, 1 Jun 2023 01:38:15 -0400 Received: from forward101b.mail.yandex.net (forward101b.mail.yandex.net [178.154.239.148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1C611B7; Wed, 31 May 2023 22:37:22 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-45.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-45.sas.yp-c.yandex.net [IPv6:2a02:6b8:c14:c83:0:640:84f9:0]) by forward101b.mail.yandex.net (Yandex) with ESMTP id 45ECA6003A; Thu, 1 Jun 2023 08:37:18 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-45.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id OaGNfZvWv8c0-hi0yiAvP; Thu, 01 Jun 2023 08:37:17 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maquefel.me; s=mail; t=1685597837; bh=ut6yym3zcUOE3+YHsTvO+xo70T8aulUJvbdj7iY9758=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=ZUcpBJdaklRlnAd4zG0N2XCPtDdO/eYPLWnUQJ14D8sBoqD66TSnS9FXTqeIDLsVM vt2VS5+mkuPbu+ASOYxjf7hYupa6wsSusTcdBcFFbNLaFLyUFF+ymJ7v9qK1RcwGcA bk9yln47YbnYFDaznXsdSCWt3ZbItAjKk0ZCO6+c= Authentication-Results: mail-nwsmtp-smtp-production-main-45.sas.yp-c.yandex.net; dkim=pass header.i=@maquefel.me From: Nikita Shubin To: Alexander Sverdlin , Arnd Bergmann , Linus Walleij , Mark Brown Cc: Nikita Shubin , Michael Peters , Kris Bahnsen , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 18/43] spi: ep93xx: add DT support for Cirrus EP93xx Date: Thu, 1 Jun 2023 08:34:09 +0300 Message-Id: <20230601053546.9574-19-nikita.shubin@maquefel.me> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20230424123522.18302-1-nikita.shubin@maquefel.me> References: <20230424123522.18302-1-nikita.shubin@maquefel.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 - find register range from the device tree - provide clock access via of - use_dma as a DT node Reviewed-by: Linus Walleij Signed-off-by: Nikita Shubin --- Notes: v0 -> v1: - dropped coma in ep93xx_spi_of_ids - renamed use_dma to "ep9301,use-dma" drivers/spi/spi-ep93xx.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index 1615fd22f9a2..bd8049fe9c91 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -644,6 +645,25 @@ static void ep93xx_spi_release_dma(struct ep93xx_spi *espi) free_page((unsigned long)espi->zeropage); } +#ifdef CONFIG_OF +static struct ep93xx_spi_info dt_spi_info; + +static struct ep93xx_spi_info *ep93xx_spi_get_platdata(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + + if (np && of_property_read_bool(np, "ep9301,use-dma")) + dt_spi_info.use_dma = 1; + + return &dt_spi_info; +} +#else +static struct ep93xx_spi_info *ep93xx_spi_get_platdata(struct platform_device *pdev) +{ + return dev_get_platdata(&pdev->dev); +} +#endif + static int ep93xx_spi_probe(struct platform_device *pdev) { struct spi_master *master; @@ -653,7 +673,7 @@ static int ep93xx_spi_probe(struct platform_device *pdev) int irq; int error; - info = dev_get_platdata(&pdev->dev); + info = ep93xx_spi_get_platdata(pdev); if (!info) { dev_err(&pdev->dev, "missing platform data\n"); return -EINVAL; @@ -726,6 +746,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev) /* make sure that the hardware is disabled */ writel(0, espi->mmio + SSPCR1); + master->dev.of_node = pdev->dev.of_node; + error = devm_spi_register_master(&pdev->dev, master); if (error) { dev_err(&pdev->dev, "failed to register SPI master\n"); @@ -753,9 +775,16 @@ static void ep93xx_spi_remove(struct platform_device *pdev) ep93xx_spi_release_dma(espi); } +static const struct of_device_id ep93xx_spi_of_ids[] = { + { .compatible = "cirrus,ep9301-spi" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ep93xx_spi_of_ids); + static struct platform_driver ep93xx_spi_driver = { .driver = { .name = "ep93xx-spi", + .of_match_table = ep93xx_spi_of_ids, }, .probe = ep93xx_spi_probe, .remove_new = ep93xx_spi_remove, -- 2.37.4