Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5393047rwr; Mon, 24 Apr 2023 03:35:43 -0700 (PDT) X-Google-Smtp-Source: AKy350a5mkJLICL5Yd6p/5kdBCbHBlsW9cuXRVy+X7b9BlM4yXHKnePkCMc6uFkaDRl1GkosPWoD X-Received: by 2002:a05:6a20:2583:b0:f2:c2a3:39a with SMTP id k3-20020a056a20258300b000f2c2a3039amr10745679pzd.61.1682332543336; Mon, 24 Apr 2023 03:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682332543; cv=none; d=google.com; s=arc-20160816; b=gkBmM0GYIj6RAuU3fTOwmY9WGDeW7/Wre2I0HJz5zFJRoZcO+oVpvqDYUmmI82bAZx YVSX7Mpc//1vHiJS43hRpgD3ktBdUJyFmeuAg41S8ZAl/oWf2NKRTPrWaKcu7sfvhx/V TMgE9BSLj+ivHkEqPXwunk0fMsQ4tzuOFWicQYbX7shUGGbS/Ltb1GMq8/ejEgFHz/Lp cuUm1jkrpuoxvWAqVXdw4LV5/lf0NKZohAJTGJ6RzjTY49UfADTB1LVDy2SdnCpbYs5Z I2UJMSHTSSl2QjsfkEF6A8ENcQKnQEjJ/aaQ6hhucH39gDQQS5mr8MDoQblTZzbUi7Ww MMqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=H/MzURm8LBkdmNsr58WR1SK4CDr2JEUu6baOETb8+Wg=; b=syE/NU6BgLxvxilhybqt9EALDlfIPpNtbboo+IHYEH/Dckf7uoKDVHQ8UYxUJzqMpG FFUH5Gyxv0dJfYL73kfk/w4z212Vy9kUYGE5miZmL+HOUT2/IN0/NJuIm3o8ouG3XLSI tlrJGYP/qJYrij+XlbY5Ha2AohOQDlt9yA4dNZ0P3gYL4hl2QV8sDvlrE8HemSOTmwww pPnZo/hh58eKZYKx/k06ze4e1kiwWsHShCJkCrI66Xskrq1vESdj/m3b1W6l4rmA6VhX 6TwdHnOmgXVrIgppdRzMeFkeMTknS0fqa8H4DpLtU2yYDFJwtVCwRFDZ6CzD2gZ8+YFo PmqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@maquefel.me header.s=mail header.b=tYpH8ota; 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 25-20020a631859000000b0051b1b5917f6si10253568pgy.160.2023.04.24.03.35.32; Mon, 24 Apr 2023 03:35:43 -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=fail header.i=@maquefel.me header.s=mail header.b=tYpH8ota; 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 S231309AbjDXKfI (ORCPT + 99 others); Mon, 24 Apr 2023 06:35:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231223AbjDXKeq (ORCPT ); Mon, 24 Apr 2023 06:34:46 -0400 Received: from forward502c.mail.yandex.net (forward502c.mail.yandex.net [178.154.239.210]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E42C8E68; Mon, 24 Apr 2023 03:34:22 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:261e:0:640:2e3d:0]) by forward502c.mail.yandex.net (Yandex) with ESMTP id 2A07A5ECF3; Mon, 24 Apr 2023 12:35:52 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id JZBb1pbWwKo0-bZjfcDZh; Mon, 24 Apr 2023 12:35:51 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maquefel.me; s=mail; t=1682328951; bh=H/MzURm8LBkdmNsr58WR1SK4CDr2JEUu6baOETb8+Wg=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=tYpH8otaP3x9f/8bRSAqZu82nnrxTEkZHlayhCB9QMaQcNZBH0DY//Dg5uGzu+1ns KYepJxdWKlIOUaF3KNmwGNqIfoWpcK2LJ+vK6ddbxRuwOghoWcuZzEEEjYOl3EjVFS 1YyW/N6nmcrttqIhmnf0ys65Wv67QgrP9FIDzwT4= Authentication-Results: mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net; dkim=pass header.i=@maquefel.me From: Nikita Shubin Cc: Arnd Bergmann , Linus Walleij , Alexander Sverdlin , Hartley Sweeten , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/43] net: cirrus: add DT support for Cirrus EP93xx Date: Mon, 24 Apr 2023 15:34:35 +0300 Message-Id: <20230424123522.18302-20-nikita.shubin@maquefel.me> X-Mailer: git-send-email 2.39.2 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - find register range from the device tree - get "copy_addr" from the device tree - get phy_id from the device tree Signed-off-by: Nikita Shubin --- Notes: rfc->v0 Fixed warnings on "(base_addr == NULL)", pace required before the open parenthesis '('. Arnd Bergmann: - wildcards ep93xx to something meaningful, i.e. ep9301 - drop wrappers drivers/net/ethernet/cirrus/ep93xx_eth.c | 49 +++++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c index 8627ab19d470..b156cc75daad 100644 --- a/drivers/net/ethernet/cirrus/ep93xx_eth.c +++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -792,6 +794,8 @@ static int ep93xx_eth_probe(struct platform_device *pdev) struct net_device *dev; struct ep93xx_priv *ep; struct resource *mem; + void __iomem *base_addr; + struct device_node *np; int irq; int err; @@ -804,6 +808,38 @@ static int ep93xx_eth_probe(struct platform_device *pdev) if (!mem || irq < 0) return -ENXIO; + base_addr = ioremap(mem->start, resource_size(mem)); + if (!base_addr) { + dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n"); + return -EIO; + } + + if (!data) { + np = pdev->dev.of_node; + if (IS_ENABLED(CONFIG_OF) && np) { + u32 phy_id; + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + if (of_property_read_bool(np, "copy_addr")) { + memcpy_fromio(data->dev_addr, base_addr + 0x50, 6); + dev_info(&pdev->dev, "MAC=%pM\n", data->dev_addr); + } + + if (of_property_read_u32(np, "phy_id", &phy_id)) { + dev_err(&pdev->dev, "Failed to parse \"phy_id\"\n"); + return -ENOENT; + } + + data->phy_id = phy_id; + } + } + + if (!data) + return -ENOENT; + dev = ep93xx_dev_alloc(data); if (dev == NULL) { err = -ENOMEM; @@ -824,12 +860,7 @@ static int ep93xx_eth_probe(struct platform_device *pdev) goto err_out; } - ep->base_addr = ioremap(mem->start, resource_size(mem)); - if (ep->base_addr == NULL) { - dev_err(&pdev->dev, "Failed to ioremap ethernet registers\n"); - err = -EIO; - goto err_out; - } + ep->base_addr = base_addr; ep->irq = irq; ep->mii.phy_id = data->phy_id; @@ -859,12 +890,18 @@ static int ep93xx_eth_probe(struct platform_device *pdev) return err; } +static const struct of_device_id ep93xx_eth_of_ids[] = { + { .compatible = "cirrus,ep9301-eth" }, + {}, +}; +MODULE_DEVICE_TABLE(of, ep93xx_eth_of_ids); static struct platform_driver ep93xx_eth_driver = { .probe = ep93xx_eth_probe, .remove = ep93xx_eth_remove, .driver = { .name = "ep93xx-eth", + .of_match_table = ep93xx_eth_of_ids, }, }; -- 2.39.2