From patchwork Wed Sep 7 13:53:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 75666 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp337559qgf; Wed, 7 Sep 2016 06:54:01 -0700 (PDT) X-Received: by 10.98.5.133 with SMTP id 127mr82579361pff.40.1473256441097; Wed, 07 Sep 2016 06:54:01 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d5si9536488pfb.68.2016.09.07.06.54.00; Wed, 07 Sep 2016 06:54:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754717AbcIGNxv (ORCPT + 4 others); Wed, 7 Sep 2016 09:53:51 -0400 Received: from mail-lf0-f53.google.com ([209.85.215.53]:36645 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753899AbcIGNxt (ORCPT ); Wed, 7 Sep 2016 09:53:49 -0400 Received: by mail-lf0-f53.google.com with SMTP id g62so11400056lfe.3 for ; Wed, 07 Sep 2016 06:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=cVquxToac6x1Cv6Gxv0eD5Llf//lzHsY8w0fAFLBB9I=; b=ieq7j2vH7LEEn52K6FC5WeuKJwSRW8lOu0uoZ9keBw5k2gjj1j6q9J0Tr9Fm8cd8uL ZFan10kdGHDjp0NohBBgMhtNWVJrgFhGUwIXtmBpDH/8yi3cN/sAsFukfWmq+Mna/knJ RfFqjEjtaZz9CPaFKxzMxlBxPw3yWdmCb0Icw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cVquxToac6x1Cv6Gxv0eD5Llf//lzHsY8w0fAFLBB9I=; b=BJtfKVVwFqg33cmh+0ep5lY5YbgNINT6saeD+dyWdUXXnRpMZhXFVAHJ9ddKEzCGEH chyOBgASTIVdmE3cGsru5yZhqEqMNsziglaH0dx6z17RQHiKkPaUZHoKwNtXU8yDKbZ9 9rQVo0Fq5MVdYOwfeBA+RwgYHtyjtdQjrXZ1sqtsn8QyxFtIa/AWlVCwdQTnXONMDofZ q3mEx1zdLY1UMeV2FfwrrwFIpyxdMOWBcXntz1ooQ076WM9KqCq6ou/8aRcF2tvgk7Gh f35XhIw2MicMDmyp0PCtaajaAln4OCCFr35xKH0S5t9PRdLd9vMbBWl7HVWc2vey1fT2 YeLA== X-Gm-Message-State: AE9vXwPqaT1aFzUe/PgySOEvNRPhnxMqZ+qw0T8iBfiQ5J/i5HAsfdrxcI3V8ekuylr1cdhw X-Received: by 10.25.130.14 with SMTP id e14mr56618lfd.160.1473256427948; Wed, 07 Sep 2016 06:53:47 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-357171d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.113.53]) by smtp.gmail.com with ESMTPSA id w186sm37415lfd.5.2016.09.07.06.53.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Sep 2016 06:53:47 -0700 (PDT) From: Linus Walleij To: netdev@vger.kernel.org, "David S . Miller" , Steve Glendinning Cc: Guenter Roeck , Jeremy Linton , Kamlakant Patel , Pavel Fedin , Linus Walleij Subject: [PATCH 2/2 v3] net: smsc911x: request and deassert optional RESET GPIO Date: Wed, 7 Sep 2016 15:53:42 +0200 Message-Id: <1473256422-14012-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On some systems (such as the Qualcomm APQ8060 Dragonboard) the RESET signal of the SMSC911x is not pulled up by a resistor (or the internal pull-up that will pull it up if the pin is not even connected) but instead connected to a GPIO line, so that the operating system must explicitly deassert RESET before use. Support this in the SMSC911x driver so this ethernet connector can be used on such targets. Notice that we request the line to go logical low (deassert) whilst the line on the actual component is active low. This is managed in the respective hardware description when specifying the GPIO line with e.g. device tree or ACPI. With device tree it looks like this in one case: reset-gpios = <&tlmm 30 GPIO_ACTIVE_LOW>; Which means that logically requesting the RESET line to be deasserted will result in the line being driven high, taking the device out of reset. Cc: Jeremy Linton Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Specify in the commit message that the component has an internal pull-up that will act if the RESET line is not connected. - Specify in the commit message that the hardware description such as device tree or ACPI is responsible of flagging the line as active low. ChangeLog v1->v2: - Use devm_gpiod_request_optiona() and request the line with GPIOD_OUT_LOW so it is deasserted immediately if active. --- drivers/net/ethernet/smsc/smsc911x.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index ca3134540d2d..8ab8d4b9614b 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -62,6 +62,7 @@ #include #include #include +#include #include "smsc911x.h" @@ -147,6 +148,9 @@ struct smsc911x_data { /* regulators */ struct regulator_bulk_data supplies[SMSC911X_NUM_SUPPLIES]; + /* Reset GPIO */ + struct gpio_desc *reset_gpiod; + /* clock */ struct clk *clk; }; @@ -438,6 +442,11 @@ static int smsc911x_request_resources(struct platform_device *pdev) netdev_err(ndev, "couldn't get regulators %d\n", ret); + /* Request optional RESET GPIO */ + pdata->reset_gpiod = devm_gpiod_get_optional(&pdev->dev, + "reset", + GPIOD_OUT_LOW); + /* Request clock */ pdata->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(pdata->clk))