From patchwork Tue Feb 7 19:25:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 139999 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 707C1B6F13 for ; Wed, 8 Feb 2012 06:25:52 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756681Ab2BGTZu (ORCPT ); Tue, 7 Feb 2012 14:25:50 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:55234 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756613Ab2BGTZt (ORCPT ); Tue, 7 Feb 2012 14:25:49 -0500 Received: by eaah12 with SMTP id h12so2938261eaa.19 for ; Tue, 07 Feb 2012 11:25:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Trz5HCQPHZ3/ayd/UUHvErBqJriF/X+sgOT1b4o911Y=; b=A/bCJbMEDIXn0pUkFoiIITVKjHQdzKtL2VkWuZTg1ZAQARnIokdDwC+cx5TY+l1pcg i/Zfsp5XzviAXnlWPTro3A23gvn6Fz56SymT9CM0LboPr454QiUgly8OZfJJGRxuWZ99 zGUY3eZmw052vUMRw8KQhenWqYyjRrPa2czmQ= MIME-Version: 1.0 Received: by 10.213.19.140 with SMTP id a12mr3935802ebb.58.1328642748559; Tue, 07 Feb 2012 11:25:48 -0800 (PST) Received: by 10.213.20.144 with HTTP; Tue, 7 Feb 2012 11:25:48 -0800 (PST) In-Reply-To: <20120203111133.GD3151@opensource.wolfsonmicro.com> References: <20120203074408.GD1990@pengutronix.de> <20120203111133.GD3151@opensource.wolfsonmicro.com> Date: Tue, 7 Feb 2012 17:25:48 -0200 Message-ID: Subject: Re: Regulator support for smsc911x From: Fabio Estevam To: Mark Brown Cc: Sascha Hauer , robert.marklund@stericsson.com, netdev@vger.kernel.org, Sascha Hauer Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi Mark, On Fri, Feb 3, 2012 at 9:11 AM, Mark Brown wrote: > There's also options c) set up the regulators for the board and d) don't > enable the regulator API if the board doesn't use regulators. Option c would require that we change every single board. The patch below does option d. What do you think? --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 5c00712..3fdd1c2 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -157,7 +157,8 @@ static struct platform_device snowball_key_dev = { static struct smsc911x_platform_config snowball_sbnet_cfg = { .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, - .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY, + .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY | + SMSC911X_USE_REGULATOR, .shift = 1, }; diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 6a1cd23..b9f6e67 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -377,8 +377,9 @@ static int smsc911x_enable_resources(struct platform_device *pdev) struct smsc911x_data *pdata = netdev_priv(ndev); int ret = 0; - ret = regulator_bulk_enable(ARRAY_SIZE(pdata->supplies), - pdata->supplies); + if (pdata->config.flags & SMSC911X_USE_REGULATOR) + ret = regulator_bulk_enable(ARRAY_SIZE(pdata->supplies), + pdata->supplies); if (ret) netdev_err(ndev, "failed to enable regulators %d\n", ret); @@ -394,8 +395,9 @@ static int smsc911x_disable_resources(struct platform_device *pdev) struct smsc911x_data *pdata = netdev_priv(ndev); int ret = 0; - ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies), - pdata->supplies); + if (pdata->config.flags & SMSC911X_USE_REGULATOR) + ret = regulator_bulk_disable(ARRAY_SIZE(pdata->supplies), + pdata->supplies); return ret; } @@ -415,9 +417,11 @@ static int smsc911x_request_resources(struct platform_device *pdev) /* Request regulators */ pdata->supplies[0].supply = "vdd33a"; pdata->supplies[1].supply = "vddvario"; - ret = regulator_bulk_get(&pdev->dev, - ARRAY_SIZE(pdata->supplies), - pdata->supplies); + + if (pdata->config.flags & SMSC911X_USE_REGULATOR) + ret = regulator_bulk_get(&pdev->dev, + ARRAY_SIZE(pdata->supplies), + pdata->supplies); if (ret) netdev_err(ndev, "couldn't get regulators %d\n", ret); @@ -434,8 +438,9 @@ static void smsc911x_free_resources(struct platform_device *pdev) struct smsc911x_data *pdata = netdev_priv(ndev); /* Free regulators */ - regulator_bulk_free(ARRAY_SIZE(pdata->supplies), - pdata->supplies); + if (pdata->config.flags & SMSC911X_USE_REGULATOR) + regulator_bulk_free(ARRAY_SIZE(pdata->supplies), + pdata->supplies); } /* waits for MAC not busy, with timeout. Only called by smsc911x_mac_read diff --git a/include/linux/smsc911x.h b/include/linux/smsc911x.h index 4dde70e..91c59d9 100644 --- a/include/linux/smsc911x.h +++ b/include/linux/smsc911x.h @@ -48,6 +48,7 @@ struct smsc911x_platform_config { #define SMSC911X_FORCE_INTERNAL_PHY (BIT(2)) #define SMSC911X_FORCE_EXTERNAL_PHY (BIT(3)) #define SMSC911X_SAVE_MAC_ADDRESS (BIT(4)) +#define SMSC911X_USE_REGULATOR (BIT(5)) /* * SMSC911X_SWAP_FIFO: