devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Jens Kuske <jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: [PATCH 5/5] net: allwinner: emac: Claim our SRAM
Date: Tue, 24 Mar 2015 08:22:17 -0700	[thread overview]
Message-ID: <20150324152217.GC4951@lukather> (raw)
In-Reply-To: <1426877569-11493-6-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 3211 bytes --]

On Fri, Mar 20, 2015 at 07:52:49PM +0100, Hans de Goede wrote:
> From: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> 
> The SRAM the EMAC is using might not have been mapped accordingly by the
> bootloader, preventing the EMAC to work properly.
> 
> Ask for that SRAM to be mapped at probe time to make sure that this never
> happens.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> [hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org: Make sure SUNXI_SRAM gets enabled in Kconfig]
> Signed-off-by: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/net/ethernet/allwinner/sun4i-emac.c | 13 +++++++++++--
>  drivers/net/ethernet/stmicro/stmmac/Kconfig |  1 +
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
> index f3470d9..9d0136b 100644
> --- a/drivers/net/ethernet/allwinner/sun4i-emac.c
> +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
> @@ -29,6 +29,8 @@
>  #include <linux/platform_device.h>
>  #include <linux/phy.h>
>  
> +#include <linux/soc/sunxi/sunxi_sram.h>
> +
>  #include "sun4i-emac.h"
>  
>  #define DRV_NAME		"sun4i-emac"
> @@ -857,11 +859,15 @@ static int emac_probe(struct platform_device *pdev)
>  
>  	clk_prepare_enable(db->clk);
>  
> +	ret = sunxi_sram_claim(SUNXI_SRAM_EMAC, "emac");
> +	if (ret)
> +		dev_warn(&pdev->dev, "Couldn't map SRAM to device\n");
> +
>  	db->phy_node = of_parse_phandle(np, "phy", 0);
>  	if (!db->phy_node) {
>  		dev_err(&pdev->dev, "no associated PHY\n");
>  		ret = -ENODEV;
> -		goto out;
> +		goto out_release_sram;
>  	}
>  
>  	/* Read MAC-address from DT */
> @@ -893,7 +899,7 @@ static int emac_probe(struct platform_device *pdev)
>  	if (ret) {
>  		dev_err(&pdev->dev, "Registering netdev failed!\n");
>  		ret = -ENODEV;
> -		goto out;
> +		goto out_release_sram;
>  	}
>  
>  	dev_info(&pdev->dev, "%s: at %p, IRQ %d MAC: %pM\n",
> @@ -901,6 +907,8 @@ static int emac_probe(struct platform_device *pdev)
>  
>  	return 0;
>  
> +out_release_sram:
> +	sunxi_sram_release(SUNXI_SRAM_EMAC);
>  out:
>  	dev_err(db->dev, "not found (%d).\n", ret);
>  
> @@ -914,6 +922,7 @@ static int emac_remove(struct platform_device *pdev)
>  	struct net_device *ndev = platform_get_drvdata(pdev);
>  
>  	unregister_netdev(ndev);
> +	sunxi_sram_release(SUNXI_SRAM_EMAC);
>  	free_netdev(ndev);
>  
>  	dev_dbg(&pdev->dev, "released and freed device\n");
> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> index 7d3af19..785ca22 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
> @@ -16,6 +16,7 @@ if STMMAC_ETH
>  config STMMAC_PLATFORM
>  	tristate "STMMAC Platform bus support"
>  	depends on STMMAC_ETH
> +	select SUNXI_SRAM if ARCH_SUNXI
>  	default y
>  	---help---
>  	  This selects the platform specific bus support for the stmmac driver.

Shouldn't that be in emac's Kconfig option instead?

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

  parent reply	other threads:[~2015-03-24 15:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 18:52 [PATCH 0/5] ARM: sunxi: SRAM mapping support Hans de Goede
     [not found] ` <1426877569-11493-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-20 18:52   ` [PATCH 1/5] drivers: soc: sunxi: Introduce SoC driver to map SRAMs Hans de Goede
     [not found]     ` <1426877569-11493-2-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-24 15:19       ` Maxime Ripard
2015-03-26 14:37         ` Hans de Goede
2015-03-20 18:52   ` [PATCH 2/5] ARM: dts: sun4i: Add A10 SRAM and SRAM controller Hans de Goede
     [not found]     ` <1426877569-11493-3-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-24 15:20       ` Maxime Ripard
2015-03-26 14:42         ` Hans de Goede
2015-03-20 18:52   ` [PATCH 3/5] ARM: dts: sun5i: Add A13 and A10s " Hans de Goede
2015-03-20 18:52   ` [PATCH 4/5] ARM: dts: sun7i: Add A20 " Hans de Goede
2015-03-20 18:52   ` [PATCH 5/5] net: allwinner: emac: Claim our SRAM Hans de Goede
     [not found]     ` <1426877569-11493-6-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-03-20 18:53       ` Hans de Goede
2015-03-24 15:22       ` Maxime Ripard [this message]
2015-03-26 14:44         ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150324152217.GC4951@lukather \
    --to=maxime.ripard-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=wens-jdAy2FN1RRM@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).