From patchwork Wed Nov 20 17:38:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 3214031 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 6B02CC045B for ; Wed, 20 Nov 2013 17:39:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D5C820773 for ; Wed, 20 Nov 2013 17:39:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 185D620760 for ; Wed, 20 Nov 2013 17:39:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754270Ab3KTRjV (ORCPT ); Wed, 20 Nov 2013 12:39:21 -0500 Received: from mail-bk0-f42.google.com ([209.85.214.42]:36276 "EHLO mail-bk0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754021Ab3KTRjT (ORCPT ); Wed, 20 Nov 2013 12:39:19 -0500 Received: by mail-bk0-f42.google.com with SMTP id w11so1281987bkz.15 for ; Wed, 20 Nov 2013 09:39:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zJ9TFA5ybMGoTpt2qU3DRA4PCzpef2qj1SOK0hGwihw=; b=gvii7SV+mWBiHu8903YoDtQdyxkgjy7PNpLP9HH0ENdaXODQc4m58kJz867Xqs5fvG dlwu2v9fkIFZOC269/p61mGCzStvB/MmcvFRjdORCkAaPWEvDvHd2xTgXaVW+tNNyNDN 6nLCW/ZI3qe1in0y7O2ZSH/uoYNVPP92E5geEapgwndRazq0Nzdo6F9sLX1ubZ8RhBh2 k7S2yQbAaTAUWewJgxW+FTL+lwfHOtA+WKl7PIQdx/EaKQj4YMRZwJkmRakSrzgnLR8F tUQgVvhHWwSJlRutU+a/hjwaeyzOdML6Wtpj6DrFn62WF0POG/+UFIbiUfwxSv5n5hwD WU3Q== X-Received: by 10.205.64.9 with SMTP id xg9mr5927bkb.52.1384969157542; Wed, 20 Nov 2013 09:39:17 -0800 (PST) Received: from groucho.site ([109.201.152.7]) by mx.google.com with ESMTPSA id no2sm24117885bkb.15.2013.11.20.09.39.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Nov 2013 09:39:16 -0800 (PST) From: Ulrich Hecht To: Simon Horman Cc: linux-sh@vger.kernel.org, Magnus Damm , Kuninori Morimoto , Laurent Pinchart , Valentine Barshak , linux-usb@vger.kernel.org, Felipe Balbi , Alan Stern Subject: [PATCH 5/9] arm: shmobile: lager: Add USBHS support Date: Wed, 20 Nov 2013 18:38:02 +0100 Message-Id: <1384969086-8920-6-git-send-email-ulrich.hecht@gmail.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1384969086-8920-1-git-send-email-ulrich.hecht@gmail.com> References: <1384969086-8920-1-git-send-email-ulrich.hecht@gmail.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.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 From: Valentine Barshak This adds USBHS PHY and registers USBHS device if the driver is enabled. Signed-off-by: Valentine Barshak Acked-by: Kuninori Morimoto --- arch/arm/mach-shmobile/board-lager.c | 115 +++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index 8430fbc..efe242d8 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include @@ -29,11 +30,14 @@ #include #include #include +#include #include #include #include #include #include +#include +#include #include #include #include @@ -166,6 +170,107 @@ static const struct resource ether_resources[] __initconst = { DEFINE_RES_IRQ(gic_spi(162)), }; +/* USBHS */ +#if IS_ENABLED(CONFIG_USB_RENESAS_USBHS_UDC) +static const struct resource usbhs_resources[] __initconst = { + DEFINE_RES_MEM(0xe6590000, 0x100), + DEFINE_RES_IRQ(gic_spi(107)), +}; + +struct usbhs_private { + struct renesas_usbhs_platform_info info; + struct usb_phy *phy; +}; + +#define usbhs_get_priv(pdev) \ + container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info) + +static int usbhs_power_ctrl(struct platform_device *pdev, + void __iomem *base, int enable) +{ + struct usbhs_private *priv = usbhs_get_priv(pdev); + + if (!priv->phy) + return -ENODEV; + + if (enable) { + int retval = usb_phy_init(priv->phy); + + if (!retval) + retval = usb_phy_set_suspend(priv->phy, 0); + return retval; + } + + usb_phy_set_suspend(priv->phy, 1); + usb_phy_shutdown(priv->phy); + return 0; +} + +static int usbhs_hardware_init(struct platform_device *pdev) +{ + struct usbhs_private *priv = usbhs_get_priv(pdev); + struct usb_phy *phy; + + phy = usb_get_phy(USB_PHY_TYPE_USB2); + if (IS_ERR(phy)) + return PTR_ERR(phy); + + priv->phy = phy; + return 0; +} + +static int usbhs_hardware_exit(struct platform_device *pdev) +{ + struct usbhs_private *priv = usbhs_get_priv(pdev); + + if (!priv->phy) + return 0; + + usb_put_phy(priv->phy); + priv->phy = NULL; + return 0; +} + +static int usbhs_get_id(struct platform_device *pdev) +{ + return USBHS_GADGET; +} + +static struct usbhs_private usbhs_priv __initdata = { + .info = { + .platform_callback = { + .power_ctrl = usbhs_power_ctrl, + .hardware_init = usbhs_hardware_init, + .hardware_exit = usbhs_hardware_exit, + .get_id = usbhs_get_id, + }, + .driver_param = { + .buswait_bwait = 4, + }, + } +}; + +#define lager_register_usbhs() \ + platform_device_register_resndata(&platform_bus, \ + "renesas_usbhs", -1, \ + usbhs_resources, \ + ARRAY_SIZE(usbhs_resources), \ + &usbhs_priv.info, \ + sizeof(usbhs_priv.info)) +#else /* CONFIG_USB_RENESAS_USBHS_UDC */ +#define lager_register_usbhs() +#endif /* CONFIG_USB_RENESAS_USBHS_UDC */ + +/* USBHS PHY */ +static const struct rcar_gen2_phy_platform_data usbhs_phy_pdata __initconst = { + .chan0_pci = 0, /* Channel 0 is USBHS */ + .chan2_pci = 1, /* Channel 2 is PCI USB */ +}; + +static const struct resource usbhs_phy_resources[] __initconst = { + DEFINE_RES_MEM(0xe6590100, 0x100), +}; + static const struct pinctrl_map lager_pinctrl_map[] = { /* DU (CN10: ARGB0, CN13: LVDS) */ PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790", @@ -194,6 +299,9 @@ static const struct pinctrl_map lager_pinctrl_map[] = { "eth_rmii", "eth"), PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790", "intc_irq0", "intc"), + /* USB0 */ + PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7790", + "usb0", "usb0"), }; static void __init lager_add_standard_devices(void) @@ -222,6 +330,13 @@ static void __init lager_add_standard_devices(void) ARRAY_SIZE(ether_resources), ðer_pdata, sizeof(ether_pdata)); + 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)); + lager_register_usbhs(); + lager_add_du_device(); }