From patchwork Thu May 3 19:40:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10379041 X-Patchwork-Delegate: bhelgaas@google.com 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 D1DBE603B4 for ; Thu, 3 May 2018 19:41:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8C8829265 for ; Thu, 3 May 2018 19:41:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD82E2926B; Thu, 3 May 2018 19:41:02 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 5B36529265 for ; Thu, 3 May 2018 19:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751240AbeECTlA (ORCPT ); Thu, 3 May 2018 15:41:00 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36896 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751214AbeECTk7 (ORCPT ); Thu, 3 May 2018 15:40:59 -0400 Received: by mail-lf0-f68.google.com with SMTP id b23-v6so27677957lfg.4 for ; Thu, 03 May 2018 12:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:from:to:references:cc:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pINP9kkjEbEHzbN0LsFdgZGIl7xTqIqLyqQ3GoSAayk=; b=QkKJ7sGKf/RKM54EaIycZdHtbFWTl6w0eh0cUfemiHtg4IzSTyvg9mIeXuQhUGg9zT KSAFKuEBkdnzOufywrUjsil/KEQmlUoD3xIbATff/wmOb/c6FwvcnST2VSfQIyZt8s8y 9IXL87qFUu1PVk+jv4C3TqqIlvsZ/b+RQIByXmNorIG8tAXJTeHCXHglnayCuOD8jz5L f+QuCjCcgoY1+m8BONzzqDzoKT1k4Q2hjItklaxxxUFEhnwq+lfGS77yzVA7T9jS+8vG SNu7TSViSLINgn3tNmDwhWR+lHr0GNnWpCAMlr34em81mwGush9IfNJ9n7t51ggpFgs3 NCqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:cc:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=pINP9kkjEbEHzbN0LsFdgZGIl7xTqIqLyqQ3GoSAayk=; b=gEYu/HT4zUv+9/dxKPjVBNh2hMgFmuEMiIZ0rCj4aPqmw3ecIwjQda7zNEo7+uLPvt DX5MkRCRO9Atc02ZfEHqsZp4s5+bCLK0TgXc2skMJjxXGHCOKRk6nayTS1oE+KMoYejm WAg5LrzOt/60hcd0gjeRycOVCin6jhLiWNLp0lZu9V8x2lLmHRgV3TDat8h66F2YdedU Z0L7f63K32czRNnBMjZ3f6cI4kViWelTMNby+Wzg1s8qyuqT3+alEXNDX7HuNE+Q9wbJ YsK813KSN7fFy5k4gdgLNj3HMhTgOt97gkZoPJ+jItbMSGYlP1QlUHKR+X0BAMVlRAzL v6ig== X-Gm-Message-State: ALQs6tBXrAS+ft5lmJfrhW5YANtncSmgXmoXwCQRLx/4qd5QfXd6O/R/ syomHjx8xNNA3qaoUzFBHkzagw== X-Google-Smtp-Source: AB8JxZrLfOQV/sp07TsmeOCncfuaGZMygxCXPl7I8CVQQPy93mq3ElSa8P5gJEMThlDRELE84yxMQw== X-Received: by 2002:a19:4b41:: with SMTP id y62-v6mr15789954lfa.11.1525376457880; Thu, 03 May 2018 12:40:57 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.85.138]) by smtp.gmail.com with ESMTPSA id e18-v6sm2953002ljk.57.2018.05.03.12.40.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 12:40:57 -0700 (PDT) Subject: [PATCH v3 3/5] pcie-rcar: add R-Car gen3 PHY support From: Sergei Shtylyov To: horms@verge.net.au, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , devicetree@vger.kernel.org References: Cc: Mark Rutland Organization: Cogent Embedded Message-ID: Date: Thu, 3 May 2018 22:40:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-MW Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On R-Car gen3 SoCs the PCIe PHY has its own register region -- and I have written a generic PHY driver for it, thus we need to add the corresponding code in rcar_pcie_hw_init_gen3() and call devm_phy_optional_get() at the driver's probing time, so that the existing R-Car gen3 device trees (not having a PHY node) would still work (we only need to power up the PHY on R-Car V3H). Signed-off-by: Sergei Shtylyov Reviewed-by: Simon Horman Reviewed-by: Rob Herring --- Changes in version 3: - removed double spaces in the patch description; - added Simon's tag; - refreshed atop of the recent driver/bindings patches. Changes in version 2: - updated the bindings. Documentation/devicetree/bindings/pci/rcar-pci.txt | 5 +++ drivers/pci/host/pcie-rcar.c | 27 +++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) Index: pci/Documentation/devicetree/bindings/pci/rcar-pci.txt =================================================================== --- pci.orig/Documentation/devicetree/bindings/pci/rcar-pci.txt +++ pci/Documentation/devicetree/bindings/pci/rcar-pci.txt @@ -32,6 +32,11 @@ compatible: "renesas,pcie-r8a7743" for t and PCIe bus clocks. - clock-names: from common clock binding: should be "pcie" and "pcie_bus". +Optional properties: +- phys: from common PHY binding: PHY phandle and specifier (only make sense + for R-Car gen3 SoCs where the PCIe PHYs have their own register blocks). +- phy-names: from common PHY binding: should be "pcie". + Example: SoC-specific DT Entry: Index: pci/drivers/pci/host/pcie-rcar.c =================================================================== --- pci.orig/drivers/pci/host/pcie-rcar.c +++ pci/drivers/pci/host/pcie-rcar.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -141,6 +142,7 @@ static inline struct rcar_msi *to_rcar_m /* Structure representing the PCIe interface */ struct rcar_pcie { struct device *dev; + struct phy *phy; void __iomem *base; struct list_head resources; int root_bus_nr; @@ -667,6 +669,21 @@ static int rcar_pcie_hw_init_gen2(struct return rcar_pcie_hw_init(pcie); } +static int rcar_pcie_hw_init_gen3(struct rcar_pcie *pcie) +{ + int err; + + err = phy_init(pcie->phy); + if (err) + return err; + + err = phy_power_on(pcie->phy); + if (err) + return err; + + return rcar_pcie_hw_init(pcie); +} + static int rcar_msi_alloc(struct rcar_msi *chip) { int msi; @@ -916,6 +933,10 @@ static int rcar_pcie_get_resources(struc struct resource res; int err, i; + pcie->phy = devm_phy_optional_get(dev, "pcie"); + if (IS_ERR(pcie->phy)) + return PTR_ERR(pcie->phy); + err = of_address_to_resource(dev->of_node, 0, &res); if (err) return err; @@ -1056,8 +1077,10 @@ static const struct of_device_id rcar_pc .data = rcar_pcie_hw_init_gen2 }, { .compatible = "renesas,pcie-rcar-gen2", .data = rcar_pcie_hw_init_gen2 }, - { .compatible = "renesas,pcie-r8a7795", .data = rcar_pcie_hw_init }, - { .compatible = "renesas,pcie-rcar-gen3", .data = rcar_pcie_hw_init }, + { .compatible = "renesas,pcie-r8a7795", + .data = rcar_pcie_hw_init_gen3 }, + { .compatible = "renesas,pcie-rcar-gen3", + .data = rcar_pcie_hw_init_gen3 }, {}, };