From patchwork Tue Jul 23 16:12:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2832082 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C392F9F4E2 for ; Tue, 23 Jul 2013 16:12:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 890EE200F0 for ; Tue, 23 Jul 2013 16:12:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F6CE200ED for ; Tue, 23 Jul 2013 16:12:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933588Ab3GWQMT (ORCPT ); Tue, 23 Jul 2013 12:12:19 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:65421 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933579Ab3GWQMM (ORCPT ); Tue, 23 Jul 2013 12:12:12 -0400 Received: from axis700.grange (dslb-094-220-153-077.pools.arcor-ip.net [94.220.153.77]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0MINbz-1Uy55m2YAh-0049BV; Tue, 23 Jul 2013 18:12:05 +0200 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id 280EB40BB3; Tue, 23 Jul 2013 18:12:05 +0200 (CEST) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1V1fC0-0003DU-VT; Tue, 23 Jul 2013 18:12:04 +0200 From: Guennadi Liakhovetski To: linux-sh@vger.kernel.org Cc: Magnus Damm , Simon Horman , Steve Glendinning , netdev@vger.kernel.org, Guennadi Liakhovetski Subject: [PATCH 1/4] net: smsc911x: add support for a reset GPIO Date: Tue, 23 Jul 2013 18:12:01 +0200 Message-Id: <1374595924-12338-2-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1374595924-12338-1-git-send-email-g.liakhovetski@gmx.de> References: <1374595924-12338-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:JXnFCsoXzmUeGkAiilQHnQU8TyeDdwLcuTksFQN0DCp mUjdKoOwu8fa4r1bdL7Q05AU8e8nQ38EZjk2XC/dybXBdv0y/6 Ia57faiWQ0OjM6M6x5pjGxN6aoVxXPyOy6Ya4cJcGyPE1xLJkT 4WJ+Dlz4J8iMJBLSYgFBjgftlLU0fzxikDBOy2yP85Su1MUGOh JoQ4tCawumGggAzdVDYgd/fUJQ1yXfWE9rxcnaukh0HdYPs2Re Pcc58tGiQWdqsD9Dfu2IezLaMxaJY6oi1qaRh6yz76kUi006UB rX0c3nW/55BG7LJM79zpDGYhnRM2qEe/4N2ydbR6ZgMR3v+eGd e3mB6g/ceiiKyQcaCUc7ijZbsoUS0E4D2WfzLSZapgt0UgRYuE X1EyF2o6wUJNg== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a reset GPIO is specified in platform data, take the controller out of reset before using it. Signed-off-by: Guennadi Liakhovetski --- drivers/net/ethernet/smsc/smsc911x.c | 19 ++++++++++++++++++- include/linux/smsc911x.h | 10 ++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-) diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index a141921..ca01c03 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -2300,6 +2300,9 @@ static int smsc911x_drv_remove(struct platform_device *pdev) free_netdev(dev); + if (pdata->config.reset_gpio_config & SMSC911X_RESET_GPIO_VALID) + gpio_free(pdata->config.reset_gpio); + return 0; } @@ -2479,10 +2482,21 @@ static int smsc911x_drv_probe(struct platform_device *pdev) goto out_disable_resources; } + if (pdata->config.reset_gpio_config & SMSC911X_RESET_GPIO_VALID) { + /* Take the chip out of hard reset */ + unsigned long flags = (pdata->config.reset_gpio_config ^ + GPIOF_INIT_HIGH) & 0xf; + retval = gpio_request_one(pdata->config.reset_gpio, + GPIOF_DIR_OUT | flags, + netdev_name(dev)); + if (retval < 0) + goto out_free_irq; + } + retval = register_netdev(dev); if (retval) { SMSC_WARN(pdata, probe, "Error %i registering device", retval); - goto out_free_irq; + goto out_free_reset; } else { SMSC_TRACE(pdata, probe, "Network interface: \"%s\"", dev->name); @@ -2531,6 +2545,9 @@ static int smsc911x_drv_probe(struct platform_device *pdev) out_unregister_netdev_5: unregister_netdev(dev); +out_free_reset: + if (pdata->config.reset_gpio_config & SMSC911X_RESET_GPIO_VALID) + gpio_free(pdata->config.reset_gpio); out_free_irq: free_irq(dev->irq, dev); out_disable_resources: diff --git a/include/linux/smsc911x.h b/include/linux/smsc911x.h index 4dde70e..4e3e49d 100644 --- a/include/linux/smsc911x.h +++ b/include/linux/smsc911x.h @@ -32,8 +32,18 @@ struct smsc911x_platform_config { unsigned int shift; phy_interface_t phy_interface; unsigned char mac[6]; + unsigned int reset_gpio; + unsigned int reset_gpio_config; }; +/* + * Bits for platform_device reest GPIO configuration: an OR of any GPIOF_* flags + * from , specifically one of GPIOF_INIT_LOW or GPIOF_INIT_HIGH + * and the below SMSC911X_RESET_GPIO_VALID flag. We define GPIOF_INIT_* as the + * level, that activates chip reset. + */ +#define SMSC911X_RESET_GPIO_VALID BIT(31) + /* Constants for platform_device irq polarity configuration */ #define SMSC911X_IRQ_POLARITY_ACTIVE_LOW 0 #define SMSC911X_IRQ_POLARITY_ACTIVE_HIGH 1