From patchwork Mon May 19 21:10: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: 4206441 Return-Path: X-Original-To: patchwork-linux-sh@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 2CE46BEEAB for ; Mon, 19 May 2014 21:10:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4709A2021B for ; Mon, 19 May 2014 21:10:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E43D120304 for ; Mon, 19 May 2014 21:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751844AbaESVK3 (ORCPT ); Mon, 19 May 2014 17:10:29 -0400 Received: from mail-lb0-f178.google.com ([209.85.217.178]:47974 "EHLO mail-lb0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751662AbaESVKY (ORCPT ); Mon, 19 May 2014 17:10:24 -0400 Received: by mail-lb0-f178.google.com with SMTP id w7so4537239lbi.9 for ; Mon, 19 May 2014 14:10:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:organization:to:subject:date:user-agent:cc :mime-version:content-type:content-transfer-encoding:message-id; bh=Q4vEpRu1bCMT553FOvmR4exmWV1eEE42ptdtLbaXkNk=; b=NTC2g/597DAtmOrYXjv4YYMpw/RxpJvD1OL2GwjapxZYhliEXhItsXIxj14pcbtYO0 TBuXfSrh7Jt6QAHbX7w1b0wl9Gw6a6YAOQrGOv+8gPVRcV/d5Ncu5yo7MEKClcUZzK9f X6bMBdjwakXEbwGLLOMy84Z4VvCQ2whNBtavBSzZYEE0XOYh5Xdw4BAxW+OanxMc+A5Q yuO1/z0zYXqt9JEPGYpmBuIC16om2UXo74X6DmlngwWgiN71yBOPO8DVjoPhTTKiaLux lNorcmB3gYeBlJHnKH8WN6brizOOv/ZhQQcJmTXlzLS76D46pMcc42qXjJeBzhKC+JIU 935Q== X-Gm-Message-State: ALoCoQmqeP00vxEjvtzd9pJGk663aIIaEIZdTDdz5gvAPTdRjCuelNDbDjSOn6zUwgw2vjNMn8D/ X-Received: by 10.152.121.72 with SMTP id li8mr18540778lab.45.1400533822764; Mon, 19 May 2014 14:10:22 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp83-237-62-7.pppoe.mtu-net.ru. [83.237.62.7]) by mx.google.com with ESMTPSA id i10sm20935281lah.13.2014.05.19.14.10.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 19 May 2014 14:10:22 -0700 (PDT) From: Sergei Shtylyov Organization: Cogent Embedded To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, horms@verge.net.au, bhelgaas@google.com, grant.likely@linaro.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v4] pci-rcar-gen2: add device tree support Date: Tue, 20 May 2014 01:10:20 +0400 User-Agent: KMail/1.13.5 (Linux/2.6.32.26-175.fc12.i686.PAE; KDE/4.4.5; i686; ; ) Cc: rdunlap@infradead.org, linux-doc@vger.kernel.org, linux-sh@vger.kernel.org MIME-Version: 1.0 Message-Id: <201405200110.21914.sergei.shtylyov@cogentembedded.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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/additions] Signed-off-by: Sergei Shtylyov Acked-by: Simon Horman Acked-by: Arnd Bergmann --- The patch is against the 'next' branch of Bjorn Helgaas' 'pci.git' repo. Changes in version 4: - added the descriptions for the #{address|size|interrupt}-cells and #interrupt-map[-mask] properties to the binding document; - added the interrupt-related properties to the example; - refreshed the patch. 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 | 66 ++++++++++++++++ drivers/pci/host/pci-rcar-gen2.c | 31 +++++++ 2 files changed, 95 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: pci/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt =================================================================== --- /dev/null +++ pci/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt @@ -0,0 +1,66 @@ +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. +- #address-cells: must be 3. +- #size-cells: must be 2. +- #interrupt-cells: must be 1. +- interrupt-map: standard property used to define the mapping of the PCI + interrupts to the GIC interrupts. +- interrupt-map-mask: standard property that helps to define the interrupt + mapping. + +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>; + #interrupt-cells = <1>; + interrupt-map-mask = <0xff00 0 0 0x7>; + interrupt-map = <0x0000 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH + 0x0800 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH + 0x1000 0 0 2 &gic 0 108 IRQ_TYPE_LEVEL_HIGH>; + + 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 @@ -98,6 +98,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 +313,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 +367,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 +395,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, };