From patchwork Mon Apr 7 21:41:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 3947161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 52AF1BFF02 for ; Mon, 7 Apr 2014 21:42:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6723F2024C for ; Mon, 7 Apr 2014 21:41:59 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BC8020225 for ; Mon, 7 Apr 2014 21:41:58 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXHIb-0005E9-I1; Mon, 07 Apr 2014 21:41:49 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXHIZ-00038X-3q; Mon, 07 Apr 2014 21:41:47 +0000 Received: from mail-lb0-f175.google.com ([209.85.217.175]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WXHIV-00037V-82 for linux-arm-kernel@lists.infradead.org; Mon, 07 Apr 2014 21:41:44 +0000 Received: by mail-lb0-f175.google.com with SMTP id w7so39171lbi.34 for ; Mon, 07 Apr 2014 14:41:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:cc:from:organization:date :mime-version:content-type:content-transfer-encoding:message-id; bh=cvDlJxHSeZc/41jKMemUJzmMAxRAdIxt8DkmlVjVK4o=; b=P566TJnN2jOU2O+YtLEoQ/eDOxNgOuqg0iugy9aUz8bCHV8GlcEZjyrmg/KNnysjh4 zjDpS2bH0E5VtJeC6nwwp6kShaTO/Bfl9BdLIBnG+QTG8eSiR9SnLf95lBrIuxhI1Rk/ sKaj1ABTEAjIXtc/w4Vfgw+/GY8biCmEw1mZd8QsV5mqkc2ONEToLKPcPtUNMd+Ot1Sx 7ApJ6opXlIdduZtC228WAWQk3QRaCmzMab/X/2p0/9btx8pHPZdQZa7Qn+Xd9VvyisQk 8fPN7G7IPY1tkvj9Vh1RWw6gPtMO4ONNmAbas9O3vm2VTAxNAQMy5fLDnIHCCHzP1j/Q qXsA== X-Gm-Message-State: ALoCoQlJawHuEo5wAgUfvVRExnxdiPWB0MmyrA4NvHC7lC2ZrCRWr+KHTKhQuqX72gfytsN0yNve X-Received: by 10.152.43.70 with SMTP id u6mr22633799lal.3.1396906880774; Mon, 07 Apr 2014 14:41:20 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp83-237-62-83.pppoe.mtu-net.ru. [83.237.62.83]) by mx.google.com with ESMTPSA id z10sm31071lbu.1.2014.04.07.14.41.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 07 Apr 2014 14:41:20 -0700 (PDT) To: horms@verge.net.au, devicetree@vger.kernel.org, robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, bhelgaas@google.com, linux-pci@vger.kernel.org Subject: [PATCH] pci-rcar-gen2: add device tree support From: Sergei Shtylyov Organization: Cogent Embedded Date: Tue, 8 Apr 2014 01:41:20 +0400 MIME-Version: 1.0 Message-Id: <201404080141.21605.sergei.shtylyov@cogentembedded.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140407_174143_564852_72608437 X-CRM114-Status: GOOD ( 22.01 ) X-Spam-Score: -1.3 (-) Cc: linux@arm.linux.org.uk, linux-doc@vger.kernel.org, linux-sh@vger.kernel.org, magnus.damm@gmail.com, ben.dooks@codethink.co.uk, rob@landley.net, grant.likely@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Ben Dooks Add device tree probing support to the 'pci-rcar-gen2' driver. Signed-off-by: Ben Dooks [Sergei: numerous fixes/cleanups] Signed-off-by: Sergei Shtylyov --- The patch is against the 'next' branch of Bjorn Helgaas' 'pci.git' repo. Changes in version 3: - added "renesas,pci-r8a7791" to the possible "compatible" property values; - removed '#ifdef CONFIG_OF' around rcar_pci_of_match[] and hence of_match_ptr() invocation too; - fixed trailing whitespace in the DT parsing code; - removed the wrong "renessas," prefix from the binding document's file name; - moved the PCI device sub-nodes from the board example to the SoC example; - fixed labels in the board example; - fixed grammar and punctuation in the binding document; - reworded the changelog, fixed the subject. Changes in version 2: - merged the binding document from a separate patch; - moved to the "bus-range" property parsing; - added example to the binding document. Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt | 54 ++++++++++++++++ drivers/pci/host/pci-rcar-gen2.c | 32 ++++++++- 2 files changed, 84 insertions(+), 2 deletions(-) Index: pci/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt =================================================================== --- /dev/null +++ pci/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt @@ -0,0 +1,54 @@ +Renesas AHB to PCI bridge +------------------------- + +This is the bridge used internally to connect the USB controllers to the +AHB. There is one bridge instance per USB port connected to the internal +OHCI and EHCI controllers. + +Required properties: +- compatible: "renesas,pci-r8a7790" for the R8A7790 SoC; + "renesas,pci-r8a7791" for the R8A7791 SoC. +- reg: A list of physical regions to access the device: the first is + the operational registers for the OHCI/EHCI controllers and the + second is for the bridge configuration and control registers. +- interrupts: interrupt for the device. +- clocks: The reference to the device clock. +- bus-range: The PCI bus number range; as this is a single bus, the range + should be specified as the same value twice. + +Example SoC configuration: + + pci0: pci@ee090000 { + compatible = "renesas,pci-r8a7790"; + clocks = <&mstp7_clks R8A7790_CLK_EHCI>; + reg = <0x0 0xee090000 0x0 0xc00>, + <0x0 0xee080000 0x0 0x1100>; + interrupts = <0 108 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + + bus-range = <0 0>; + #address-cells = <3>; + #size-cells = <2>; + + pci@0,1 { + reg = <0x800 0 0 0 0>; + device_type = "pci"; + phys = <&usbphy 0 0>; + phy-names = "usb"; + }; + + pci@0,2 { + reg = <0x1000 0 0 0 0>; + device_type = "pci"; + phys = <&usbphy 0 0>; + phy-names = "usb"; + }; + }; + +Example board setup: + +&pci0 { + status = "okay"; + pinctrl-0 = <&usb0_pins>; + pinctrl-names = "default"; +}; Index: pci/drivers/pci/host/pci-rcar-gen2.c =================================================================== --- pci.orig/drivers/pci/host/pci-rcar-gen2.c +++ pci/drivers/pci/host/pci-rcar-gen2.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -98,6 +99,7 @@ struct rcar_pci_priv { struct resource io_res; struct resource mem_res; struct resource *cfg_res; + unsigned busnr; int irq; unsigned long window_size; }; @@ -312,8 +314,8 @@ static int rcar_pci_setup(int nr, struct pci_add_resource(&sys->resources, &priv->io_res); pci_add_resource(&sys->resources, &priv->mem_res); - /* Setup bus number based on platform device id */ - sys->busnr = to_platform_device(priv->dev)->id; + /* Setup bus number based on platform device id / of bus-range */ + sys->busnr = priv->busnr; return 1; } @@ -366,6 +368,23 @@ static int rcar_pci_probe(struct platfor priv->window_size = SZ_1G; + if (pdev->dev.of_node) { + struct resource busnr; + int ret; + + ret = of_pci_parse_bus_range(pdev->dev.of_node, &busnr); + if (ret < 0) { + dev_err(&pdev->dev, "failed to parse bus-range\n"); + return ret; + } + + priv->busnr = busnr.start; + if (busnr.end != busnr.start) + dev_warn(&pdev->dev, "only one bus number supported\n"); + } else { + priv->busnr = pdev->id; + } + hw_private[0] = priv; memset(&hw, 0, sizeof(hw)); hw.nr_controllers = ARRAY_SIZE(hw_private); @@ -377,11 +396,20 @@ static int rcar_pci_probe(struct platfor return 0; } +static struct of_device_id rcar_pci_of_match[] = { + { .compatible = "renesas,pci-r8a7790", }, + { .compatible = "renesas,pci-r8a7791", }, + { }, +}; + +MODULE_DEVICE_TABLE(of, rcar_pci_of_match); + static struct platform_driver rcar_pci_driver = { .driver = { .name = "pci-rcar-gen2", .owner = THIS_MODULE, .suppress_bind_attrs = true, + .of_match_table = rcar_pci_of_match, }, .probe = rcar_pci_probe, };