From patchwork Mon Oct 7 23:27:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentine Barshak X-Patchwork-Id: 2999611 Return-Path: X-Original-To: patchwork-linux-sh@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 B93349F1E1 for ; Mon, 7 Oct 2013 23:27:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC168201B4 for ; Mon, 7 Oct 2013 23:27:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C53AF201B3 for ; Mon, 7 Oct 2013 23:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753253Ab3JGX1P (ORCPT ); Mon, 7 Oct 2013 19:27:15 -0400 Received: from mail-lb0-f175.google.com ([209.85.217.175]:52766 "EHLO mail-lb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753249Ab3JGX1M (ORCPT ); Mon, 7 Oct 2013 19:27:12 -0400 Received: by mail-lb0-f175.google.com with SMTP id y6so6099872lbh.6 for ; Mon, 07 Oct 2013 16:27:10 -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:to:cc:subject:date:message-id:in-reply-to :references; bh=IOCYFTgiDq3JJzs+uTLE3fp6JEO+XdYbPZtbTTYYrIU=; b=Si5r99d9CFAygj7QQhB+EBMpfjR7UuAvAKljxFOsbXkPsLuIYn5f97nV9imraWQLeG vf3jaOgUG7VThVjGSHkJ1c36Y1kCzkJce3DY8rZJOBVOvaCtn1m8aoIC2m9ACHYTq9pr h95kE0cs/liLEm9qHbrbGReGV4fMYwBj6aenRxx3btz3QGl7ibcFkgn/1byzU92c+7K8 bZbhDSk+YjOlIOTwrDde5q1mwb02UudaT8gFjJShZMieYLl9YLfv+gbtxiWRhBAozrYw /mUKmIbd9ZOtltIP04pp9moG3N9RgfrhiBOnYFAIIear6ejETrPE4jZw9B5vb6zyMIYh R4QQ== X-Gm-Message-State: ALoCoQmcfVdneLBUl/hxyuEB6+PV5Dg32iFPmJqucyAWpP19z6g/3+eNoqpCxiNLjqncESV/n47R X-Received: by 10.152.28.7 with SMTP id x7mr4756295lag.26.1381188430466; Mon, 07 Oct 2013 16:27:10 -0700 (PDT) Received: from black.localnet ([93.100.122.208]) by mx.google.com with ESMTPSA id vs11sm27372735lac.3.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 07 Oct 2013 16:27:09 -0700 (PDT) From: Valentine Barshak To: linux-sh@vger.kernel.org, linux-usb@vger.kernel.org Cc: Simon Horman , Magnus Damm , Kuninori Morimoto , Laurent Pinchart , Guennadi Liakhovetski , Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH 3/3] arm: shmobile: lager: Add USBHS support Date: Tue, 8 Oct 2013 03:27:03 +0400 Message-Id: <1381188423-1867-4-git-send-email-valentine.barshak@cogentembedded.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1381188423-1867-1-git-send-email-valentine.barshak@cogentembedded.com> References: <1381188423-1867-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.1 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 USBHS PHY and registers USBHS device if the driver is enabled. Signed-off-by: Valentine Barshak --- arch/arm/mach-shmobile/board-lager.c | 106 +++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index a8d3ce6..15a98ac 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 @@ -165,6 +169,98 @@ 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; + + return usb_phy_set_suspend(priv->phy, !enable); +} + +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 usb_phy_init(priv->phy); +} + +static int usbhs_hardware_exit(struct platform_device *pdev) +{ + struct usbhs_private *priv = usbhs_get_priv(pdev); + + if (!priv->phy) + return 0; + + usb_phy_shutdown(priv->phy); + 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", @@ -193,6 +289,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) @@ -221,6 +320,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(); }