From patchwork Fri Apr 6 11:10:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 10325857 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 DAABB60208 for ; Fri, 6 Apr 2018 11:10:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC78B292E9 for ; Fri, 6 Apr 2018 11:10:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C14AB294E8; Fri, 6 Apr 2018 11:10:32 +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 14D53294DF for ; Fri, 6 Apr 2018 11:10:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752037AbeDFLKa (ORCPT ); Fri, 6 Apr 2018 07:10:30 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53473 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751933AbeDFLK3 (ORCPT ); Fri, 6 Apr 2018 07:10:29 -0400 Received: by mail-wm0-f68.google.com with SMTP id p9so2748966wmc.3 for ; Fri, 06 Apr 2018 04:10:28 -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:organization:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lJ+ncMBAuPx0GR99dDso5RfJ91KKxZsz2hQYZFsjtXk=; b=MdS2ovHmI1g3ad3COLp0d72lFN8auaxJDNe0VKk9huT4Hm1Td4uIx9bq2c1rriUkq4 xjaOsQBR7QGyJO44NfnZpEaqMK63TbAzG9IY+l6opyhLqGecQvRbN75vn3sOas3soo8p bD3rPEbpHzf0Ex0sXdv1Ks25MzIUrgI3ahignRPfSGGEOn44inJm3UcDOwUK1h7m5NpG xUZfIlk+mmx/Znkci0qek68jyAQwHS0IJO+t5BJlJMK3F2MlUgFfGIFASOq5FJFbB/fl 5O4Fx2R+fydJuL3ggO3CQdC600Ohifg65Z3I4yGKjlOoIXaanx1zbsTLmRDSMRnzsOCz BjYA== 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:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=lJ+ncMBAuPx0GR99dDso5RfJ91KKxZsz2hQYZFsjtXk=; b=OGvPsW3wpZLFIucu/PeLO3tX9yl1sNi3Jvq3NHmzK5igsQ8tEWTtHBhUCamyN9XprH L0ouw8JRfGG+A7hwfxya/BeUwPHBcXxPR4JJ6qd9tZyyJvph4EFlMaiWq8G3A4RznqJv ECujNGr3xJtyM4secMEI2DKWqMWJN1xRProSix5OeS8kNIpIlx1g/cIiAPKo/mjR6eMm DkqpDHHLBi0hoMdyqDHIV2JIEjT0B0TY76waVIFpicA3h6bIqvzqxe+CVylFZYvHlvce qEYkBmnhJLS5685cG0zKMG/0uMRJroMzDXIhMfRZbny/vR/2p2EHJ8mULw46MOld7SSi GB3g== X-Gm-Message-State: ALQs6tC2UrFuCrn0o35dMUfsica7uiZ//9bNXREu+Xni47J2w74gWqSz /bMlF8R+6NuFT9+rxWQmLGHcqg== X-Google-Smtp-Source: AIpwx4+I4P9oiXeQKU1otn/M8o+M86Mna4hxfdGK/7eErJr36DQN6dZU4QkZfqCYbwxYcgIlp7k44Q== X-Received: by 10.46.25.28 with SMTP id p28mr9323750lje.127.1523013026681; Fri, 06 Apr 2018 04:10:26 -0700 (PDT) Received: from wasted.cogentembedded.com ([31.173.80.60]) by smtp.gmail.com with ESMTPSA id e97-v6sm2049689lfi.10.2018.04.06.04.10.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 04:10:25 -0700 (PDT) Subject: [PATCH 4/4] pcie-rcar: factor out rcar_pcie_hw_init() call From: Sergei Shtylyov To: horms@verge.net.au, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Lorenzo Pieralisi References: <23335d95-63ca-b107-e43d-f4c2621adc2c@cogentembedded.com> Organization: Cogent Embedded Message-ID: <4462b4d1-1e56-d6d2-ad38-8f02405d1d96@cogentembedded.com> Date: Fri, 6 Apr 2018 14:10:22 +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: <23335d95-63ca-b107-e43d-f4c2621adc2c@cogentembedded.com> 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 We now have rcar_pcie_hw_init_{h1|gen2|gen3}() differing only in the PCIe PHY init code and all ending with a call to rcar_pcie_hw_init(), thus it makes sense to move that call into the driver's probe() method and then rename those functions to rcar_pcie_phy_init_{h1|gen2|gen3}() -- doing this saves 48 bytes of object code (AArch64 gcc 4.8.5)... Signed-off-by: Sergei Shtylyov Reviewed-by: Geert Uytterhoeven --- drivers/pci/host/pcie-rcar.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) Index: pci/drivers/pci/host/pcie-rcar.c =================================================================== --- pci.orig/drivers/pci/host/pcie-rcar.c +++ pci/drivers/pci/host/pcie-rcar.c @@ -626,7 +626,7 @@ static int rcar_pcie_hw_init(struct rcar return 0; } -static int rcar_pcie_hw_init_h1(struct rcar_pcie *pcie) +static int rcar_pcie_phy_init_h1(struct rcar_pcie *pcie) { /* Initialize the phy */ phy_write_reg(pcie, 0, 0x42, 0x1, 0x0EC34191); @@ -646,10 +646,10 @@ static int rcar_pcie_hw_init_h1(struct r phy_write_reg(pcie, 0, 0x64, 0x1, 0x3F0F1F0F); phy_write_reg(pcie, 0, 0x66, 0x1, 0x00008000); - return rcar_pcie_hw_init(pcie); + return 0; } -static int rcar_pcie_hw_init_gen2(struct rcar_pcie *pcie) +static int rcar_pcie_phy_init_gen2(struct rcar_pcie *pcie) { /* * These settings come from the R-Car Series, 2nd Generation User's @@ -666,10 +666,10 @@ static int rcar_pcie_hw_init_gen2(struct rcar_pci_write_reg(pcie, 0x00000001, GEN2_PCIEPHYCTRL); rcar_pci_write_reg(pcie, 0x00000006, GEN2_PCIEPHYCTRL); - return rcar_pcie_hw_init(pcie); + return 0; } -static int rcar_pcie_hw_init_gen3(struct rcar_pcie *pcie) +static int rcar_pcie_phy_init_gen3(struct rcar_pcie *pcie) { int err; @@ -677,11 +677,7 @@ static int rcar_pcie_hw_init_gen3(struct if (err) return err; - err = phy_power_on(pcie->phy); - if (err) - return err; - - return rcar_pcie_hw_init(pcie); + return phy_power_on(pcie->phy); } static int rcar_msi_alloc(struct rcar_msi *chip) @@ -1082,17 +1078,18 @@ static int rcar_pcie_parse_map_dma_range } static const struct of_device_id rcar_pcie_of_match[] = { - { .compatible = "renesas,pcie-r8a7779", .data = rcar_pcie_hw_init_h1 }, + { .compatible = "renesas,pcie-r8a7779", + .data = rcar_pcie_phy_init_h1 }, { .compatible = "renesas,pcie-r8a7790", - .data = rcar_pcie_hw_init_gen2 }, + .data = rcar_pcie_phy_init_gen2 }, { .compatible = "renesas,pcie-r8a7791", - .data = rcar_pcie_hw_init_gen2 }, + .data = rcar_pcie_phy_init_gen2 }, { .compatible = "renesas,pcie-rcar-gen2", - .data = rcar_pcie_hw_init_gen2 }, + .data = rcar_pcie_phy_init_gen2 }, { .compatible = "renesas,pcie-r8a7795", - .data = rcar_pcie_hw_init_gen3 }, + .data = rcar_pcie_phy_init_gen3 }, { .compatible = "renesas,pcie-rcar-gen3", - .data = rcar_pcie_hw_init_gen3 }, + .data = rcar_pcie_phy_init_gen3 }, {}, }; @@ -1140,7 +1137,7 @@ static int rcar_pcie_probe(struct platfo struct rcar_pcie *pcie; unsigned int data; int err; - int (*hw_init_fn)(struct rcar_pcie *); + int (*phy_init_fn)(struct rcar_pcie *); struct pci_host_bridge *bridge; bridge = pci_alloc_host_bridge(sizeof(*pcie)); @@ -1174,10 +1171,15 @@ static int rcar_pcie_probe(struct platfo goto err_pm_disable; } - /* Failure to get a link might just be that no cards are inserted */ - hw_init_fn = of_device_get_match_data(dev); - err = hw_init_fn(pcie); + phy_init_fn = of_device_get_match_data(dev); + err = phy_init_fn(pcie); if (err) { + dev_err(dev, "failed to init PCIe PHY\n"); + goto err_pm_put; + } + + /* Failure to get a link might just be that no cards are inserted */ + if (rcar_pcie_hw_init(pcie)) { dev_info(dev, "PCIe link down\n"); err = -ENODEV; goto err_pm_put;