From patchwork Mon Aug 5 00:43:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 2838498 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 0C9A0BF535 for ; Mon, 5 Aug 2013 00:43:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DDA72016D for ; Mon, 5 Aug 2013 00:43:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D52F20168 for ; Mon, 5 Aug 2013 00:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754049Ab3HEAnj (ORCPT ); Sun, 4 Aug 2013 20:43:39 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:38185 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754041Ab3HEAnj (ORCPT ); Sun, 4 Aug 2013 20:43:39 -0400 Received: by mail-pa0-f53.google.com with SMTP id lb1so2646386pab.26 for ; Sun, 04 Aug 2013 17:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:sender:message-id:to:cc:in-reply-to:references:from:subject :user-agent:mime-version:content-type; bh=JMdRo52Ad7qRRXBfhdSD6K3z5ecUUhDsT19ggdHCiFU=; b=I0vFF92s2guPiU4AT0QYAkm5yNnJVihV2/LS+qc/1ot1iKWABjmOXkzZZL1KklyT8n NwycKk5xjoB8YZLjB1fJK8oVbW2dDJtmlYmAqiuwtWaVKPfqtnGX7lIDmhSaZew6hM8N JcYwRQNNoMk7uelE55D7ZCFV0Pw/jPdhU/l8bFENnajjvBFZau55iVYlbMwHWo/RDmmB qk7E7+qMdJvkRlupMUE0Hv3HiU+Fnc/aPuYXaKuHNLfgrCZSRKXy0B/rPBPiDjUA4pRc 9R37ebT6VpxTBiMqsuw8P3EFokNKo/u3yWs9u/hwQgrSVM7xJ3Gd3U+SDbuBKXQPVjAU QnNg== X-Received: by 10.66.43.76 with SMTP id u12mr10894773pal.130.1375663418709; Sun, 04 Aug 2013 17:43:38 -0700 (PDT) Received: from morimoto-Dell-XPS420.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id om2sm23885997pbc.30.2013.08.04.17.43.36 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 04 Aug 2013 17:43:37 -0700 (PDT) Date: Sun, 04 Aug 2013 17:43:37 -0700 (PDT) Message-ID: <8761vlt1ah.wl%kuninori.morimoto.gx@renesas.com> To: Simon Cc: Magnus , linux-sh@vger.kernel.org, Kuninori Morimoto In-Reply-To: <87a9kxt1dg.wl%kuninori.morimoto.gx@renesas.com> References: <87oba9fqsg.wl%kuninori.morimoto.gx@renesas.com> <87a9kxt1dg.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 3/3 v4] ARM: shmobile: bockw: add USB Function support User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Bock-W USB1 (CN29) can be USB Host/Func by SW98/SW99 settings. USB Func will be enabled if CONFIG_USB_RENESAS_USBHS_UDC[_MODULE] was selected on this patch Signed-off-by: Kuninori Morimoto --- v3 -> v4 - no change arch/arm/mach-shmobile/board-bockw.c | 81 ++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c index 07009f5..8094803 100644 --- a/arch/arm/mach-shmobile/board-bockw.c +++ b/arch/arm/mach-shmobile/board-bockw.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,16 @@ * SW19 (MMC) 1 pin */ +/* + * USB + * + * USB1 (CN29) can be Host/Function + * + * Host Func + * SW98 1 2 + * SW99 1 3 + */ + /* Dummy supplies, where voltage doesn't matter */ static struct regulator_consumer_supply dummy_supplies[] = { REGULATOR_SUPPLY("vddvario", "smsc911x"), @@ -79,13 +90,71 @@ static struct resource smsc911x_resources[] = { DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */ }; +#if IS_ENABLED(CONFIG_USB_RENESAS_USBHS_UDC) +/* + * When USB1 is Func + */ +static int usbhsf_get_id(struct platform_device *pdev) +{ + return USBHS_GADGET; +} + +#define SUSPMODE 0x102 +static int usbhsf_power_ctrl(struct platform_device *pdev, + void __iomem *base, int enable) +{ + enable = !!enable; + + r8a7778_usb_phy_power(enable); + + iowrite16(enable << 14, base + SUSPMODE); + + return 0; +} + +static struct resource usbhsf_resources[] __initdata = { + DEFINE_RES_MEM(0xffe60000, 0x110), + DEFINE_RES_IRQ(gic_iid(0x4f)), +}; + +static struct renesas_usbhs_platform_info usbhs_info __initdata = { + .platform_callback = { + .get_id = usbhsf_get_id, + .power_ctrl = usbhsf_power_ctrl, + }, + .driver_param = { + .buswait_bwait = 4, + }, +}; + +#define USB_PHY_SETTING {.port1_func = 1, .ovc_pin[1].active_high = 1,} +#define USB1_DEVICE "renesas_usbhs" +#define ADD_USB_FUNC_DEVICE_IF_POSSIBLE() \ + platform_device_register_resndata( \ + &platform_bus, "renesas_usbhs", -1, \ + usbhsf_resources, \ + ARRAY_SIZE(usbhsf_resources), \ + &usbhs_info, sizeof(struct renesas_usbhs_platform_info)) + +#else +/* + * When USB1 is Host + */ +#define USB_PHY_SETTING { } +#define USB1_DEVICE "ehci-platform" +#define ADD_USB_FUNC_DEVICE_IF_POSSIBLE() + +#endif + /* USB */ static struct resource usb_phy_resources[] __initdata = { DEFINE_RES_MEM(0xffe70800, 0x100), DEFINE_RES_MEM(0xffe76000, 0x100), }; -static struct rcar_phy_platform_data usb_phy_platform_data __initdata; +static struct rcar_phy_platform_data usb_phy_platform_data __initdata = + USB_PHY_SETTING; + /* SDHI */ static struct sh_mobile_sdhi_info sdhi0_info = { @@ -181,7 +250,7 @@ static const struct pinctrl_map bockw_pinctrl_map[] = { /* USB */ PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778", "usb0", "usb0"), - PIN_MAP_MUX_GROUP_DEFAULT("ehci-platform", "pfc-r8a7778", + PIN_MAP_MUX_GROUP_DEFAULT(USB1_DEVICE, "pfc-r8a7778", "usb1", "usb1"), /* SDHI0 */ PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778", @@ -270,6 +339,12 @@ static void __init bockw_init(void) } } +static void __init bockw_init_late(void) +{ + r8a7778_init_late(); + ADD_USB_FUNC_DEVICE_IF_POSSIBLE(); +} + static const char *bockw_boards_compat_dt[] __initdata = { "renesas,bockw", NULL, @@ -281,5 +356,5 @@ DT_MACHINE_START(BOCKW_DT, "bockw") .init_machine = bockw_init, .init_time = shmobile_timer_init, .dt_compat = bockw_boards_compat_dt, - .init_late = r8a7778_init_late, + .init_late = bockw_init_late, MACHINE_END