From patchwork Fri Jun 29 09:40:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10496021 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3168D6022E for ; Fri, 29 Jun 2018 09:46:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16F6929991 for ; Fri, 29 Jun 2018 09:46:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A565299A3; Fri, 29 Jun 2018 09:46:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CB2D29991 for ; Fri, 29 Jun 2018 09:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932804AbeF2JpT (ORCPT ); Fri, 29 Jun 2018 05:45:19 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:45995 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933615AbeF2Jkz (ORCPT ); Fri, 29 Jun 2018 05:40:55 -0400 Received: by mail-wr0-f195.google.com with SMTP id u7-v6so8202568wrn.12 for ; Fri, 29 Jun 2018 02:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IZodCBu9RKMn5bFdKnytyBJMiPRX8pbpaHzSg3Yr4PI=; b=x/WEF9tdkTIPNp8gGgda7AZpr+Rrrq1SRL5EtViKu9NTHGAeUxTeH5jYOQdWgt3bvp pq9lBoZ5+SpaF4MxXYEb/NnbrEJtF4JUdhsLzciZYZ8KZdKYNpLEWQ9NC0HwIcP4aXEs 9CELn3SYbmI3SI97JiE32gcvrH1Smxs2fvhsopZfuEstt1Bbyn74APd8KEpwbzw8wvkt 3GtPQooYFw4nL9xQ65Sz8ASqUtgKGTzI/pKx0MxCJcZemnElAOs8fc66fwk4qD8fHYLh 9auMuUlWp2lJU9GqD0w4rIo/yDj0p66NYiF8u5NXMQXxOT4EvHC+eU7oqUNy9fL5mwwH ZkHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IZodCBu9RKMn5bFdKnytyBJMiPRX8pbpaHzSg3Yr4PI=; b=PequyXaPPEYE5nZAcrwsMJlWRgl5u13idjD3xzQAMU+AtQP63xIx73YjMaQg8LCqME uy3F/rDYwHKVUvjWdxLDYRRd4Txy6qEr7eqGXlKdZNsaOHfQNcRR5qtjlciGiACLpCTB Ot6zSdW8fYxmVSOGYqcAoeQCdoY7N5HTJRLVMkmaQDIKgDYA+Z7w24LGoOQUEufhBpQh 8rY3YN78KKPekRhVhCZVNUsW17CTRi/9ZLUQk3GVFbgQUqI/318J1CsV1zkvtes5jaUM ItMfWF42YHaa/qgnNu6KYrc9GqnHoT6TfRj9ay22rPaFXmjM5+hH6jsqxJhhWQaErfUp ub1g== X-Gm-Message-State: APt69E1014T9tkKldB0d+QiQLxORhCe+gnV98Xtn1WwG67cIeKssqnpT PB37ZhHNdoxO3HOYCFHDcJY6ow== X-Google-Smtp-Source: AAOMgpf/NLsHK+8sIjJYmGbtzgismMHaApEg8+FYA31F6K6e7Mvd8eLYMT/zdS8GIcQgRO+2FRRbBg== X-Received: by 2002:adf:ef50:: with SMTP id c16-v6mr10829163wrp.182.1530265254611; Fri, 29 Jun 2018 02:40:54 -0700 (PDT) Received: from brgl-bgdev.lan (LFbn-NIC-1-55-10.w2-15.abo.wanadoo.fr. [2.15.147.10]) by smtp.gmail.com with ESMTPSA id d102-v6sm1386394wma.10.2018.06.29.02.40.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 02:40:53 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Russell King , Grygorii Strashko , "David S . Miller" , Srinivas Kandagatla , Lukas Wunner , Rob Herring , Florian Fainelli , Dan Carpenter , Ivan Khoronzhuk , David Lechner , Greg Kroah-Hartman , Andrew Lunn , Jonathan Corbet Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, netdev@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 08/18] net: davinci_emac: potentially get the MAC address from MTD Date: Fri, 29 Jun 2018 11:40:29 +0200 Message-Id: <20180629094039.7543-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629094039.7543-1-brgl@bgdev.pl> References: <20180629094039.7543-1-brgl@bgdev.pl> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski On da850-evm board we can read the MAC address from MTD. It's currently done in the relevant board file, but we want to get rid of all the MAC reading callbacks from the board file (SPI and NAND). Move the reading of the MAC address from SPI to the emac driver's probe function. Signed-off-by: Bartosz Golaszewski --- drivers/net/ethernet/ti/davinci_emac.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index a1a6445b5a7e..48e6a7755811 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -67,7 +67,7 @@ #include #include #include - +#include #include #include @@ -1783,7 +1783,10 @@ static int davinci_emac_probe(struct platform_device *pdev) struct cpdma_params dma_params; struct clk *emac_clk; unsigned long emac_bus_frequency; - +#ifdef CONFIG_MTD + size_t mac_addr_len; + struct mtd_info *mtd; +#endif /* CONFIG_MTD */ /* obtain emac clock from kernel */ emac_clk = devm_clk_get(&pdev->dev, NULL); @@ -1815,6 +1818,19 @@ static int davinci_emac_probe(struct platform_device *pdev) goto err_free_netdev; } +#ifdef CONFIG_MTD + mtd = get_mtd_device_nm("MAC-Address"); + if (!IS_ERR(mtd)) { + rc = mtd_read(mtd, 0, ETH_ALEN, + &mac_addr_len, priv->mac_addr); + if (rc == 0) + dev_info(&pdev->dev, + "Read MAC addr from SPI Flash: %pM\n", + priv->mac_addr); + put_mtd_device(mtd); + } +#endif /* CONFIG_MTD */ + /* MAC addr and PHY mask , RMII enable info from platform_data */ memcpy(priv->mac_addr, pdata->mac_addr, ETH_ALEN); priv->phy_id = pdata->phy_id;