From patchwork Fri Jan 17 18:21:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentine Barshak X-Patchwork-Id: 3506751 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 8ACADC02DC for ; Fri, 17 Jan 2014 18:21:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B8BF2015D for ; Fri, 17 Jan 2014 18:21:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DF8B200E9 for ; Fri, 17 Jan 2014 18:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753121AbaAQSVq (ORCPT ); Fri, 17 Jan 2014 13:21:46 -0500 Received: from mail-lb0-f169.google.com ([209.85.217.169]:58145 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753075AbaAQSVp (ORCPT ); Fri, 17 Jan 2014 13:21:45 -0500 Received: by mail-lb0-f169.google.com with SMTP id q8so3247170lbi.14 for ; Fri, 17 Jan 2014 10:21:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Dw3Nc6dhRnLPTFWPjv4e3O6iWMIxh2gFdstcxq7azQA=; b=aNvni1o1VzAC8zAVaIsVZQ2bQK7TNhN5EMeK06USrS90g3Byto3TyFYAGTjd6OXaDR twqYPrZs1aoaENrBd/UvERN57pxkaeZfLor3uEQJvK4lvspMApVZTjXUDwqlR1o6sK+z daCvYKU+iFPV9F1J3wG0PUFTkuNFE6sSHwHUO7C4HM4X7DEl6V3T2SEbB1dcQ4DgT7sS 6qzFf/clNXRcdOmN3ePj3/GfywH1TJpN4tPb0YBlBs/MzM22tM4AkkyRuZD7XtMa/6v2 p73Jh2gCqP5MlUK0/P/iJVngrxcCGeoDOI05aTO6SFm133SFYAcEY3Hla172W2TYuQRR hm7A== X-Gm-Message-State: ALoCoQnr0YZyzk+Elm9mZA3zfzOPmzmddYL9kONP++bOdkO5EDxhKxUf0mOEzAsaQKSuRyNV3+II X-Received: by 10.152.4.162 with SMTP id l2mr7255lal.75.1389982904168; Fri, 17 Jan 2014 10:21:44 -0800 (PST) Received: from black.localnet ([93.100.122.208]) by mx.google.com with ESMTPSA id qx1sm7250746lbb.15.2014.01.17.10.21.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jan 2014 10:21:43 -0800 (PST) From: Valentine Barshak To: linux-sh@vger.kernel.org Cc: Simon Horman , Magnus Damm , Kuninori Morimoto , Laurent Pinchart Subject: [PATCH V2 4/4] ARM: shmobile: koelsch: Add internal PCI support Date: Fri, 17 Jan 2014 22:21:35 +0400 Message-Id: <1389982895-20726-5-git-send-email-valentine.barshak@cogentembedded.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1389982895-20726-1-git-send-email-valentine.barshak@cogentembedded.com> References: <1389982895-20726-1-git-send-email-valentine.barshak@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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 This adds internal PCI USB host devices to R-Car M2 Koelsch board. If USBHS device is disabled, channel 0 is configured as PCI USB host. Otherwise, it is configured as USBHS. The USB phy is bound bound to either USB host or USBHS device respectively. Signed-off-by: Valentine Barshak --- arch/arm/mach-shmobile/board-koelsch.c | 67 +++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 10 deletions(-) Changes in V2: * capitalized ARM in the subject; * rebased on top the latest devel tag. diff --git a/arch/arm/mach-shmobile/board-koelsch.c b/arch/arm/mach-shmobile/board-koelsch.c index 9ec1564..cd69ff0 100644 --- a/arch/arm/mach-shmobile/board-koelsch.c +++ b/arch/arm/mach-shmobile/board-koelsch.c @@ -267,7 +267,11 @@ static struct usbhs_private usbhs_priv __initdata = { } }; -static void __init koelsch_register_usbhs(void) +/* Channel 0 is USBHS */ +#define KOELSCH_USB0_PCI 0 +#define KOELSCH_USB0_NAME "renesas_usbhs" + +static void __init koelsch_add_usb0_device(void) { usb_bind_phy("renesas_usbhs", 0, "usb_phy_rcar_gen2"); platform_device_register_resndata(&platform_bus, @@ -278,12 +282,45 @@ static void __init koelsch_register_usbhs(void) sizeof(usbhs_priv.info)); } #else /* CONFIG_USB_RENESAS_USBHS_UDC */ -static inline void koelsch_register_usbhs(void) { } + +/* Channel 0 is PCI USB host */ +#define KOELSCH_USB0_PCI 1 +#define KOELSCH_USB0_NAME "pci-rcar-gen2.0" + +/* Internal PCI0 */ +static const struct resource pci0_resources[] __initconst = { + DEFINE_RES_MEM(0xee090000, 0x10000), /* CFG */ + DEFINE_RES_MEM(0xee080000, 0x10000), /* MEM */ + DEFINE_RES_IRQ(gic_spi(108)), +}; + +static void __init koelsch_add_usb0_device(void) +{ + usb_bind_phy("0000:00:01.0", 0, "usb_phy_rcar_gen2"); + usb_bind_phy("0000:00:02.0", 0, "usb_phy_rcar_gen2"); + platform_device_register_simple("pci-rcar-gen2", + 0, pci0_resources, + ARRAY_SIZE(pci0_resources)); +} #endif /* CONFIG_USB_RENESAS_USBHS_UDC */ +/* Internal PCI1 */ +static const struct resource pci1_resources[] __initconst = { + DEFINE_RES_MEM(0xee0d0000, 0x10000), /* CFG */ + DEFINE_RES_MEM(0xee0c0000, 0x10000), /* MEM */ + DEFINE_RES_IRQ(gic_spi(113)), +}; + +static void __init koelsch_add_usb1_device(void) +{ + platform_device_register_simple("pci-rcar-gen2", + 1, pci1_resources, + ARRAY_SIZE(pci1_resources)); +} + /* USBHS PHY */ static const struct rcar_gen2_phy_platform_data usbhs_phy_pdata __initconst = { - .chan0_pci = 0, /* Channel 0 is USBHS */ + .chan0_pci = KOELSCH_USB0_PCI, .chan2_pci = 1, /* Channel 2 is PCI USB */ }; @@ -291,6 +328,18 @@ static const struct resource usbhs_phy_resources[] __initconst = { DEFINE_RES_MEM(0xe6590100, 0x100), }; +/* Add all available USB devices */ +static void __init koelsch_add_usb_devices(void) +{ + platform_device_register_resndata(&platform_bus, "usb_phy_rcar_gen2", + -1, usbhs_phy_resources, + ARRAY_SIZE(usbhs_phy_resources), + &usbhs_phy_pdata, + sizeof(usbhs_phy_pdata)); + koelsch_add_usb0_device(); + koelsch_add_usb1_device(); +} + static const struct pinctrl_map koelsch_pinctrl_map[] = { /* DU */ PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791", @@ -315,8 +364,11 @@ static const struct pinctrl_map koelsch_pinctrl_map[] = { PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7791", "scif1_data_d", "scif1"), /* USB0 */ - PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7791", + PIN_MAP_MUX_GROUP_DEFAULT(KOELSCH_USB0_NAME, "pfc-r8a7791", "usb0", "usb0"), + /* USB1 */ + PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7791", + "usb1", "usb1"), }; static void __init koelsch_add_standard_devices(void) @@ -341,12 +393,7 @@ static void __init koelsch_add_standard_devices(void) platform_device_register_full(&sata0_info); - platform_device_register_resndata(&platform_bus, "usb_phy_rcar_gen2", - -1, usbhs_phy_resources, - ARRAY_SIZE(usbhs_phy_resources), - &usbhs_phy_pdata, - sizeof(usbhs_phy_pdata)); - koelsch_register_usbhs(); + koelsch_add_usb_devices(); } /*