From patchwork Sun Feb 28 01:50:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francisco Alecrim X-Patchwork-Id: 82759 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1S1p9rr032703 for ; Sun, 28 Feb 2010 01:51:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936382Ab0B1BvA (ORCPT ); Sat, 27 Feb 2010 20:51:00 -0500 Received: from mail-fx0-f219.google.com ([209.85.220.219]:40220 "EHLO mail-fx0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936370Ab0B1Bu7 (ORCPT ); Sat, 27 Feb 2010 20:50:59 -0500 Received: by fxm19 with SMTP id 19so1286941fxm.21 for ; Sat, 27 Feb 2010 17:50:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=24NXQlXUdew7Aabf9NXADizhBwGAUDoY9bgZF3ZTniQ=; b=aVJmEjTvWk9Hu3O0HU3vU+MCYr7s1Wv6cQbWd1t1H6A3WsvjwjvjyMzVybEFg7MrHL xgX7ZTyGtfqEXROFQcPanyz4dso+RYwFYbGlSxlAchTQ9h1GBZdtcss9XcZzG2UbmBki TasKZyXMNz5EFJeTgOfYQ/GwqJB/uTEGXU5uo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=ZfnA2sVn1+HYyKhE8QinhxN5l68GsV9J5Wz8XhrPsjfridMFtE+qy0bu+YeB4R8aPW KOMngmco2YgDMzRQIlkmjYcQrb3D+UEzZGaCqqZbFXZg5cKaZyzV/p8p2pFGSMdWY3wI mpzAOlRzNYlyex9rw3qoDgXXrU0VnXBOWBwdQ= Received: by 10.102.211.40 with SMTP id j40mr2096130mug.65.1267321856718; Sat, 27 Feb 2010 17:50:56 -0800 (PST) Received: from localhost.localdomain ([189.2.128.130]) by mx.google.com with ESMTPS id i5sm9828784mue.49.2010.02.27.17.50.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 27 Feb 2010 17:50:56 -0800 (PST) From: Francisco Alecrim To: linux-omap@vger.kernel.org Cc: Francisco Alecrim , Kalle Valo , Tony Lindgren Subject: [PATCH] board-n8x0: add USB initialization Date: Sat, 27 Feb 2010 21:50:31 -0400 Message-Id: <1267321831-2775-1-git-send-email-alecrim@gmail.com> X-Mailer: git-send-email 1.6.3.3 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 28 Feb 2010 01:51:11 +0000 (UTC) diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c index ee548dd..e1c0c71 100644 --- a/arch/arm/mach-omap2/board-n8x0.c +++ b/arch/arm/mach-omap2/board-n8x0.c @@ -32,6 +32,131 @@ #include #include + +#if defined(CONFIG_USB_MUSB_OTG) +#define BOARD_MODE MUSB_OTG +#elif defined(CONFIG_USB_MUSB_PERIPHERAL) +#define BOARD_MODE MUSB_PERIPHERAL +#else /* defined(CONFIG_USB_MUSB_HOST) */ +#define BOARD_MODE MUSB_HOST +#endif + +/* + * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and + * 1.5 V voltage regulators of PM companion chip. Companion chip will then + * provide then PGOOD signal to TUSB6010 which will release it from reset. + */ +static int tusb_set_power(int state) +{ + int i, retval = 0; + + if (state) { + gpio_set_value(TUSB6010_GPIO_ENABLE, 1); + msleep(1); + + /* Wait until TUSB6010 pulls INT pin down */ + i = 100; + while (i && gpio_get_value(TUSB6010_GPIO_INT)) { + msleep(1); + i--; + } + + if (!i) { + printk(KERN_ERR "tusb: powerup failed\n"); + retval = -ENODEV; + } + } else { + gpio_set_value(TUSB6010_GPIO_ENABLE, 0); + msleep(10); + } + + return retval; +} + + +static struct musb_hdrc_eps_bits musb_eps[] = { + { "ep1_tx", 5, }, + { "ep1_rx", 5, }, + { "ep2_tx", 5, }, + { "ep2_rx", 5, }, + { "ep3_tx", 3, }, + { "ep3_rx", 3, }, + { "ep4_tx", 3, }, + { "ep4_rx", 3, }, + { "ep5_tx", 2, }, + { "ep5_rx", 2, }, + { "ep6_tx", 2, }, + { "ep6_rx", 2, }, + { "ep7_tx", 2, }, + { "ep7_rx", 2, }, + { "ep8_tx", 2, }, + { "ep8_rx", 2, }, + { "ep9_tx", 2, }, + { "ep9_rx", 2, }, + { "ep10_tx", 2, }, + { "ep10_rx", 2, }, + { "ep11_tx", 2, }, + { "ep11_rx", 2, }, + { "ep12_tx", 2, }, + { "ep12_rx", 2, }, + { "ep13_tx", 2, }, + { "ep13_rx", 2, }, + { "ep14_tx", 2, }, + { "ep14_rx", 2, }, + { "ep15_tx", 2, }, + { "ep15_rx", 2, }, +}; + +static struct musb_hdrc_config musb_config = { + .multipoint = 1, + .dyn_fifo = 1, + .soft_con = 1, + .dma = 1, + .num_eps = 16, + .dma_channels = 7, + .ram_bits = 12, + .eps_bits = musb_eps, +}; + +static struct musb_hdrc_platform_data tusb_data = { + .mode = BOARD_MODE, + .set_power = tusb_set_power, + .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */ + .power = 100, /* Max 100 mA VBUS for host mode */ + .config = &musb_config, +}; + +static void __init n8x0_usb_init(void) +{ + int ret = 0; + static char announce[] __initdata = KERN_INFO "TUSB 6010\n"; + + /* PM companion chip power control pin */ + ret = gpio_request(TUSB6010_GPIO_ENABLE, "TUSB6010 enable"); + if (ret != 0) { + printk(KERN_ERR "Could not get TUSB power GPIO%i\n", + TUSB6010_GPIO_ENABLE); + return; + } + gpio_direction_output(TUSB6010_GPIO_ENABLE, 0); + + tusb_set_power(0); + + ret = tusb6010_setup_interface(&tusb_data, TUSB6010_REFCLK_19, 2, + TUSB6010_ASYNC_CS, TUSB6010_SYNC_CS, + TUSB6010_GPIO_INT, 0x3f); + if (ret != 0) + goto err; + + printk(announce); + + return; + +err: + gpio_free(TUSB6010_GPIO_ENABLE); +} + + static struct omap2_mcspi_device_config p54spi_mcspi_config = { .turbo_mode = 0, .single_channel = 1, @@ -148,6 +273,7 @@ static void __init n8x0_init_machine(void) omap_serial_init(); n8x0_onenand_init(); + n8x0_usb_init(); } MACHINE_START(NOKIA_N800, "Nokia N800") diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c index f12af95..d932b14 100644 --- a/arch/arm/mach-omap2/clock2420_data.c +++ b/arch/arm/mach-omap2/clock2420_data.c @@ -1841,6 +1841,7 @@ static struct omap_clk omap2420_clks[] = { CLK(NULL, "aes_ick", &aes_ick, CK_242X), CLK(NULL, "pka_ick", &pka_ick, CK_242X), CLK(NULL, "usb_fck", &usb_fck, CK_242X), + CLK("musb_hdrc", "fck", &osc_ck, CK_242X), }; /* diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index 3fdeef5..c281ce0 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -98,6 +98,10 @@ struct musb_hdrc_platform_data { #define TUSB6010_OSCCLK_60 16667 /* psec/clk @ 60.0 MHz */ #define TUSB6010_REFCLK_24 41667 /* psec/clk @ 24.0 MHz XI */ #define TUSB6010_REFCLK_19 52083 /* psec/clk @ 19.2 MHz CLKIN */ +#define TUSB6010_ASYNC_CS 1 +#define TUSB6010_SYNC_CS 4 +#define TUSB6010_GPIO_INT 58 +#define TUSB6010_GPIO_ENABLE 0 #ifdef CONFIG_ARCH_OMAP2