From patchwork Thu Jun 1 05:34:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Shubin X-Patchwork-Id: 101721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp71157vqr; Wed, 31 May 2023 22:47:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6d/LeqxYTlfBP2QLgnZbXdFLgacK/7AYcSVOc/HSblixNeSE9NcO5UirYhU9OPvxfhh74h X-Received: by 2002:a17:902:ea0b:b0:1b0:7cc:982a with SMTP id s11-20020a170902ea0b00b001b007cc982amr1183610plg.5.1685598439467; Wed, 31 May 2023 22:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685598439; cv=none; d=google.com; s=arc-20160816; b=J1j1NgZlOnRtPNUioJI0o5KBAbAap9STAOAax/2o6NxY6dIa5V2BxLqdXa5SnXuGAZ VuvIo6pbRMeXDI+HfahMMopU1ZDTkn0+S2gQRR7Kkfqz5Xpc5fOtFdPKOhQpdiO0TyW9 oJ58WCXwZBG3ldXnAOlqJgdpEfKRe58qKFV0jGm6n7ZPs3m4dPo0gWTLe4ktwbWd5Prb CjkZoyfWhH5GlME8+XmgylZgrzyu4d6NQ8//sWjOhkpIaTjF5CWsM8Td1LBrO8ZnP92s eBw7mrwmjYyGQkaMS7mfk8eWgh039GnI0YWs2KPmApUMEfdNelbb1gonULYIy6D17kao JzEg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l12-20020a170902d34c00b001adeb1635e1si2133988plk.155.2023.05.31.22.47.07; Wed, 31 May 2023 22:47:19 -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 S231442AbjFAFio (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764052711570701806?= X-GMAIL-MSGID: =?utf-8?q?1767478069253261068?= - 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,