From patchwork Thu Jun 28 14:32:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10494147 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 1413760230 for ; Thu, 28 Jun 2018 14:38:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFFB62A0A4 for ; Thu, 28 Jun 2018 14:38:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E443D2A0BE; Thu, 28 Jun 2018 14:38:42 +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 87C172A0A4 for ; Thu, 28 Jun 2018 14:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966611AbeF1Oii (ORCPT ); Thu, 28 Jun 2018 10:38:38 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:44088 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966649AbeF1OdU (ORCPT ); Thu, 28 Jun 2018 10:33:20 -0400 Received: by mail-wr0-f194.google.com with SMTP id p12-v6so5752566wrn.11 for ; Thu, 28 Jun 2018 07:33:19 -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=zArp1LhynJj6PtR0vOEIzjnAxQ8D1ftfqwxGbTe1BC8=; b=Tho2VFEoma3gScYSolCFaegTDcAIdusxa2EyCbSnryNnBYTkvc3NpDVGCVjQQ2PGAY ULGBFNug8kWtxZJRj90BdRMzf6Mvlad8HUo+8D3+5shfUxzmQIx2p2K79apVTIueBa9d aOXBePlopH3HMkhdrt2LkH0xAZNNxUymq/E8kUaEj+QCJBeRqf0Y7gvT3pY1fLldJIKY FTh+SV3eu3oG+WlwUMzG6Bj+As5XJvCBsgOl87Fh76guefu1RyMLFFieCdaNAlPwCeL2 2DwX3Mq7UzagZ0YDkuQTNl80rhpAUFtxrFgndhbpmUKyVgRUv1bh19dbVjoaduMS6or3 FQEQ== 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=zArp1LhynJj6PtR0vOEIzjnAxQ8D1ftfqwxGbTe1BC8=; b=le4JP9QGKiP8XB+Ej/n8mF7SWn8jb85PkOhPgGrXrwztXCHU7itja6EtE8RG11cv1a 2/UArpViDiZ3FS4BX/nEzrfanGs1G6Ax8DEjYgJEh6R85Gw275nSoIzPmBpHc4FuUjPk wtVLLX8hnU9kBM+DqHyXSztRJfLmVaGf70Blpdh2hA8rdn3McH8BkbXPA5K8W0VxbgDZ 862225eRWFHnAYtMBCEKn6x0qk/qxrClixYiuMmnCvGG0f9j1SmReR+TLDYWkku3GbN4 JSdDLB4Hr1GLfwxy/WrGJREZrqacVpyDGeAlWifimoJUqFPJsoL82TqNSRJBWVw4cLeg Bcbw== X-Gm-Message-State: APt69E2S1BBRb/j7NvZpHo5Vm+IvK5Ka085WzgLuWNXyF8HgGIcrxugu IMgz3DzKSGoZVGqcEZlq3CgDXQ== X-Google-Smtp-Source: AAOMgpferG7vInksNBqhlY07+BTByLC8v82b1odTpS39rwpuYeArbh8M1LBoj1wWwfwtvwXArHAa1w== X-Received: by 2002:adf:ba8c:: with SMTP id p12-v6mr2223104wrg.139.1530196399185; Thu, 28 Jun 2018 07:33:19 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-87-41.w90-86.abo.wanadoo.fr. [90.86.29.41]) by smtp.gmail.com with ESMTPSA id 4-v6sm8037499wmh.14.2018.06.28.07.33.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 07:33:18 -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 v3 08/18] net: davinci_emac: potentially get the MAC address from MTD Date: Thu, 28 Jun 2018 16:32:34 +0200 Message-Id: <20180628143244.4561-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180628143244.4561-1-brgl@bgdev.pl> References: <20180628143244.4561-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 | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index a1a6445b5a7e..17cfe093b8cf 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,18 @@ 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); + } +#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;