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: 3947141 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 849039F369 for ; Mon, 7 Apr 2014 21:41:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 950E620268 for ; Mon, 7 Apr 2014 21:41:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D23A20225 for ; Mon, 7 Apr 2014 21:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755336AbaDGVlX (ORCPT ); Mon, 7 Apr 2014 17:41:23 -0400 Received: from mail-la0-f46.google.com ([209.85.215.46]:44270 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755294AbaDGVlW (ORCPT ); Mon, 7 Apr 2014 17:41:22 -0400 Received: by mail-la0-f46.google.com with SMTP id hr17so37153lab.33 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=B9dVXIlbesD/844EQEFsOaRZhvL7+basF/Zo741K567Bw/DdyDwFyWHU5l54HsoVX+ 7S3QxHTWnSEZuBaGFfUTt5/zS7mJXuFN7FcREvERH0IOKg8G4VvhHYxBPqExRV0PkB3/ 0OJbihVdt8Mrl4PyyVUs5SCwZDC1j2X0cnyWseplZfniMUgJ2Ve0pSVUzOeYQLVweFrV e9kE2aM27Jg/GsmHma41TT4vJt8MnQ2y0DxUeldI7TcRfhhJoEaNv0F7RxrtOFrj9Qg1 9O7ScTiG2Rmi6rlNz7kaWZz4kRTcE4JSJ1pHGF1QllOyFr9icF4S5FgFMOvArDQlJbga 126Q== X-Gm-Message-State: ALoCoQkY8543XeUtg7THG37UC0wnaw0peODzzovotOaU17ATDgUFTFaPZkOCG6s29gQCS9FRW3JP 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 Cc: linux-sh@vger.kernel.org, magnus.damm@gmail.com, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org, ben.dooks@codethink.co.uk, linux-doc@vger.kernel.org, rob@landley.net, grant.likely@linaro.org 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> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET, 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] 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(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" 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,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, };