From patchwork Sun Nov 22 21:28:44 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cory Maccarrone X-Patchwork-Id: 62079 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAMLSmBc027377 for ; Sun, 22 Nov 2009 21:28:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755777AbZKVV2k (ORCPT ); Sun, 22 Nov 2009 16:28:40 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755789AbZKVV2k (ORCPT ); Sun, 22 Nov 2009 16:28:40 -0500 Received: from mail-pw0-f42.google.com ([209.85.160.42]:50176 "EHLO mail-pw0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755614AbZKVV2k (ORCPT ); Sun, 22 Nov 2009 16:28:40 -0500 Received: by pwi3 with SMTP id 3so3058423pwi.21 for ; Sun, 22 Nov 2009 13:28:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=ejj82KIk9ZixFJjjoVeDpr0QbRTqvVi/Ea8A5G55ylM=; b=jiUPyRSDts9n4yF0Uy8Z5aVbDjzdFUtBN9qCrv4US8+ry/cVypk8H5t1qUcS4/p3/u D3VNKkPxvwZ/zDwCXAmuRLVTtzIbHzhdbN0TijagSI8jhH/qVPFsmM1mv+swQ9QM+O3K mbfcz/tncfJqDEZI/KQXeQc8hPSOPQLqxClxw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; b=T3vQljluIWXdZMbCxIFs0tD41L9hUQOWh280nwhJ/2l9XmlGRsFWxM4LgC2AaJ8jmo D+Tm9MHnTVskrSVKFiANhfs8H8jDvNJ2uIxaCIfnTt5mMcdWpvWf1limbfX8JksWujQ/ 4w6Hrd8ovei5PiZy4VkMC3a2xnHilm0+y19aM= Received: by 10.114.9.16 with SMTP id 16mr6948016wai.114.1258925326304; Sun, 22 Nov 2009 13:28:46 -0800 (PST) Received: from ?192.168.0.102? (97-126-104-157.tukw.qwest.net [97.126.104.157]) by mx.google.com with ESMTPS id 23sm2437960pxi.13.2009.11.22.13.28.45 (version=SSLv3 cipher=RC4-MD5); Sun, 22 Nov 2009 13:28:45 -0800 (PST) Subject: [PATCH 3/3] [OMAP] HTCHERALD: Add USB configuration to HTC Herald From: Cory Maccarrone To: linux-omap@vger.kernel.org Date: Sun, 22 Nov 2009 13:28:44 -0800 Message-ID: <1258925324.11242.6.camel@runt> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/arch/arm/mach-omap1/board-htcherald.c b/arch/arm/mach-omap1/board-htcherald.c index 5f28a5c..8949570 100644 --- a/arch/arm/mach-omap1/board-htcherald.c +++ b/arch/arm/mach-omap1/board-htcherald.c @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -140,6 +141,15 @@ static struct platform_device kp_device = { .resource = kp_resources, }; +/* USB Device */ +static struct omap_usb_config htcherald_usb_config __initdata = { + .otg = 0, + .register_host = 0, + .register_dev = 1, + .hmc_mode = 4, + .pins[0] = 2, +}; + /* LCD Device resources */ static struct platform_device lcd_device = { .name = "lcd_htcherald", @@ -214,6 +224,63 @@ static void __init htcherald_disable_watchdog(void) } } +#define HTCHERALD_GPIO_USB_EN1 33 +#define HTCHERALD_GPIO_USB_EN2 73 +#define HTCHERALD_GPIO_USB_DM 35 +#define HTCHERALD_GPIO_USB_DP 36 + +static void __init htcherald_usb_enable(void) +{ + unsigned int tries = 20; + unsigned int value = 0; + + /* Request the GPIOs we need to control here */ + if (gpio_request(HTCHERALD_GPIO_USB_EN1, "herald_usb") < 0) { + printk(KERN_WARNING "Unable to request HTCHERALD_GPIO_USB_EN1, USB will be unavailable\n"); + goto done; + } + + if (gpio_request(HTCHERALD_GPIO_USB_EN2, "herald_usb") < 0) { + printk(KERN_WARNING "Unable to request HTCHERALD_GPIO_USB_EN2, USB will be unavailable\n"); + goto err1; + } + + if (gpio_request(HTCHERALD_GPIO_USB_DM, "herald_usb") < 0) { + printk(KERN_WARNING "Unable to request HTCHERALD_GPIO_USB_DM, USB will be unavailable\n"); + goto err2; + } + + if (gpio_request(HTCHERALD_GPIO_USB_DP, "herald_usb") < 0) { + printk(KERN_WARNING "Unable to request HTCHERALD_GPIO_USB_DP, USB will be unavailable\n"); + goto err3; + } + + /* force USB_EN GPIO to 0 */ + do { + gpio_direction_output(HTCHERALD_GPIO_USB_EN1, 0); /* output low */ + } while((value = gpio_get_value(HTCHERALD_GPIO_USB_EN1)) == 1 && --tries); + + if (value == 1) { + printk(KERN_WARNING "unable to reset USB_EN GPIO after 20 tries.\n"); + printk(KERN_WARNING "I will try to continue anyway: USB may not be available.\n"); + } + + gpio_direction_output(HTCHERALD_GPIO_USB_EN2, 0); /* output low */ + gpio_direction_input(HTCHERALD_GPIO_USB_DM); /* input */ + gpio_direction_input(HTCHERALD_GPIO_USB_DP); /* input */ + + goto done; + +err3: + gpio_free(HTCHERALD_GPIO_USB_DM); +err2: + gpio_free(HTCHERALD_GPIO_USB_EN2); +err1: + gpio_free(HTCHERALD_GPIO_USB_EN1); +done: + printk(KERN_INFO "USB setup complete.\n"); +} + static void __init htcherald_init(void) { printk(KERN_INFO "HTC Herald init.\n"); @@ -225,6 +292,9 @@ static void __init htcherald_init(void) platform_add_devices(devices, ARRAY_SIZE(devices)); htcherald_disable_watchdog(); + + htcherald_usb_enable(); + omap_usb_init(&htcherald_usb_config); } static void __init htcherald_init_irq(void)