From patchwork Tue May 1 12:07:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Afzal X-Patchwork-Id: 156064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C2AF4B6F9D for ; Tue, 1 May 2012 22:33:25 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SPCEn-0002Xq-1p; Tue, 01 May 2012 12:31:25 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SPC89-0006EU-KR; Tue, 01 May 2012 12:24:35 +0000 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id q41COMPS026076; Tue, 1 May 2012 07:24:22 -0500 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q41COMB5014482; Tue, 1 May 2012 07:24:22 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Tue, 1 May 2012 07:24:22 -0500 Received: from ucmsshproxy.india.ext.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with SMTP id q41COG7V005054; Tue, 1 May 2012 07:24:17 -0500 Received: from symphony.india.ext.ti.com (unknown [192.168.247.13]) by ucmsshproxy.india.ext.ti.com (Postfix) with ESMTP id C4608158002; Tue, 1 May 2012 17:54:15 +0530 (IST) Received: from linux-psp-server.india.ext.ti.com (linux-psp-server [192.168.247.76]) by symphony.india.ext.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id q41COFI18373; Tue, 1 May 2012 17:54:15 +0530 (IST) From: Afzal Mohammed To: , , , , , , , , , , , , , , , , Subject: [PATCH 12/39] ARM: OMAP2+: gpmc-tusb6010: Adapt to gpmc driver Date: Tue, 1 May 2012 17:37:32 +0530 Message-ID: <9d28cfec31eac2b7975e34c37aad884c75c3cdac.1335873032.git.afzal@ti.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.152 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Afzal Mohammed X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently gpmc is configured in platform for tusb6010. As configuring gpmc has been moved to gpmc driver, populate details needed for the driver to configure gpmc. gpmc driver would configure based on this information. Signed-off-by: Afzal Mohammed --- arch/arm/mach-omap2/usb-tusb6010.c | 177 ++++++++++++++---------------------- include/linux/usb/musb.h | 4 +- 2 files changed, 70 insertions(+), 111 deletions(-) diff --git a/arch/arm/mach-omap2/usb-tusb6010.c b/arch/arm/mach-omap2/usb-tusb6010.c index db84a46..d7817d2 100644 --- a/arch/arm/mach-omap2/usb-tusb6010.c +++ b/arch/arm/mach-omap2/usb-tusb6010.c @@ -22,6 +22,24 @@ #include "mux.h" +static struct resource tusb_resources = { + .name = "mc", + .flags = IORESOURCE_IRQ, +}; + +#define TUSB_GPMC_CS_ASYNC_IDX 1 +#define TUSB_GPMC_CS_SYNC_IDX 2 +#define TUSB_GPMC_CS_NUM 2 + +static struct gpmc_cs_data gpmc_tusb_cs_data[TUSB_GPMC_CS_NUM]; + +static struct gpmc_device_pdata gpmc_tusb_data = { + .name = "musb-tusb", + .id = -1, + .per_res = &tusb_resources, + .per_res_cnt = 1, +}; + static u8 async_cs, sync_cs; static unsigned refclk_psec; @@ -51,9 +69,9 @@ next_clk(unsigned t1_NS, unsigned t2_ps, unsigned fclk_ps) /* NOTE: timings are from tusb 6010 datasheet Rev 1.8, 12-Sept 2006 */ -static int tusb_set_async_mode(unsigned sysclk_ps, unsigned fclk_ps) +static void tusb_set_async_mode(unsigned sysclk_ps, unsigned fclk_ps) { - struct gpmc_timings t; + static struct gpmc_timings t; unsigned t_acsnh_advnh = sysclk_ps + 3000; unsigned tmp; @@ -106,12 +124,12 @@ static int tusb_set_async_mode(unsigned sysclk_ps, unsigned fclk_ps) tmp = t.cs_wr_off * 1000 + 7000 /* t_acsn_rdy_z */; t.wr_cycle = next_clk(t.cs_wr_off, tmp, fclk_ps); - return gpmc_cs_set_timings(async_cs, &t); + gpmc_tusb_cs_data[TUSB_GPMC_CS_ASYNC_IDX].timing = &t; } static int tusb_set_sync_mode(unsigned sysclk_ps, unsigned fclk_ps) { - struct gpmc_timings t; + static struct gpmc_timings t; unsigned t_scsnh_advnh = sysclk_ps + 3000; unsigned tmp; @@ -174,71 +192,30 @@ static int tusb_set_sync_mode(unsigned sysclk_ps, unsigned fclk_ps) tmp = t.cs_wr_off * 1000 + 7000 /* t_scsn_rdy_z */; t.wr_cycle = next_clk(t.cs_wr_off, tmp, fclk_ps); - return gpmc_cs_set_timings(sync_cs, &t); + gpmc_tusb_cs_data[TUSB_GPMC_CS_SYNC_IDX].timing = &t; + + return 0; } extern unsigned long gpmc_get_fclk_period(void); /* tusb driver calls this when it changes the chip's clocking */ -int tusb6010_platform_retime(unsigned is_refclk) +static int tusb6010_platform_retime(unsigned is_refclk) { - static const char error[] = - KERN_ERR "tusb6010 %s retime error %d\n"; - unsigned fclk_ps = gpmc_get_fclk_period(); unsigned sysclk_ps; - int status; if (!refclk_psec || fclk_ps == 0) return -ENODEV; sysclk_ps = is_refclk ? refclk_psec : TUSB6010_OSCCLK_60; - status = tusb_set_async_mode(sysclk_ps, fclk_ps); - if (status < 0) { - printk(error, "async", status); - goto done; - } - status = tusb_set_sync_mode(sysclk_ps, fclk_ps); - if (status < 0) - printk(error, "sync", status); -done: - return status; + tusb_set_async_mode(sysclk_ps, fclk_ps); + return tusb_set_sync_mode(sysclk_ps, fclk_ps); } -EXPORT_SYMBOL_GPL(tusb6010_platform_retime); - -static struct resource tusb_resources[] = { - /* Order is significant! The start/end fields - * are updated during setup.. - */ - { /* Asynchronous access */ - .flags = IORESOURCE_MEM, - }, - { /* Synchronous access */ - .flags = IORESOURCE_MEM, - }, - { /* IRQ */ - .name = "mc", - .flags = IORESOURCE_IRQ, - }, -}; - -static u64 tusb_dmamask = ~(u32)0; - -static struct platform_device tusb_device = { - .name = "musb-tusb", - .id = -1, - .dev = { - .dma_mask = &tusb_dmamask, - .coherent_dma_mask = 0xffffffff, - }, - .num_resources = ARRAY_SIZE(tusb_resources), - .resource = tusb_resources, -}; - /* this may be called only from board-*.c setup code */ -int __init +__init struct gpmc_device_pdata * tusb6010_setup_interface(struct musb_hdrc_platform_data *data, unsigned ps_refclk, unsigned waitpin, unsigned async, unsigned sync, @@ -249,82 +226,72 @@ tusb6010_setup_interface(struct musb_hdrc_platform_data *data, KERN_ERR "tusb6010 init error %d, %d\n"; /* ASYNC region, primarily for PIO */ - status = gpmc_cs_request(async, SZ_16M, (unsigned long *) - &tusb_resources[0].start); - if (status < 0) { - printk(error, 1, status); - return status; - } - tusb_resources[0].end = tusb_resources[0].start + 0x9ff; + gpmc_tusb_cs_data[TUSB_GPMC_CS_ASYNC_IDX].cs = async; + gpmc_tusb_cs_data[TUSB_GPMC_CS_ASYNC_IDX].mem_size = 0x1000; + async_cs = async; - gpmc_cs_write_reg(async, GPMC_CS_CONFIG1, - GPMC_CONFIG1_PAGE_LEN(2) - | GPMC_CONFIG1_WAIT_READ_MON - | GPMC_CONFIG1_WAIT_WRITE_MON - | GPMC_CONFIG1_WAIT_PIN_SEL(waitpin) - | GPMC_CONFIG1_READTYPE_ASYNC - | GPMC_CONFIG1_WRITETYPE_ASYNC - | GPMC_CONFIG1_DEVICESIZE_16 - | GPMC_CONFIG1_DEVICETYPE_NOR - | GPMC_CONFIG1_MUXADDDATA); + gpmc_tusb_cs_data[TUSB_GPMC_CS_ASYNC_IDX].have_config = true; + gpmc_tusb_cs_data[TUSB_GPMC_CS_ASYNC_IDX].config = GPMC_DEVICESIZE_16 | + GPMC_WAIT_READ_MON | + GPMC_WAIT_WRITE_MON | + GPMC_READTYPE_ASYNC | + GPMC_WRITETYPE_ASYNC | + GPMC_DEVICETYPE_NOR | + GPMC_MUXADDDATA | + GPMC_PAGE_LEN_16 | + waitpin; /* SYNC region, primarily for DMA */ - status = gpmc_cs_request(sync, SZ_16M, (unsigned long *) - &tusb_resources[1].start); - if (status < 0) { - printk(error, 2, status); - return status; - } - tusb_resources[1].end = tusb_resources[1].start + 0x9ff; + gpmc_tusb_cs_data[TUSB_GPMC_CS_SYNC_IDX].cs = sync; + gpmc_tusb_cs_data[TUSB_GPMC_CS_SYNC_IDX].mem_size = 0x1000; + sync_cs = sync; - gpmc_cs_write_reg(sync, GPMC_CS_CONFIG1, - GPMC_CONFIG1_READMULTIPLE_SUPP - | GPMC_CONFIG1_READTYPE_SYNC - | GPMC_CONFIG1_WRITEMULTIPLE_SUPP - | GPMC_CONFIG1_WRITETYPE_SYNC - | GPMC_CONFIG1_CLKACTIVATIONTIME(1) - | GPMC_CONFIG1_PAGE_LEN(2) - | GPMC_CONFIG1_WAIT_READ_MON - | GPMC_CONFIG1_WAIT_WRITE_MON - | GPMC_CONFIG1_WAIT_PIN_SEL(waitpin) - | GPMC_CONFIG1_DEVICESIZE_16 - | GPMC_CONFIG1_DEVICETYPE_NOR - | GPMC_CONFIG1_MUXADDDATA - /* fclk divider gets set later */ - ); + + gpmc_tusb_cs_data[TUSB_GPMC_CS_SYNC_IDX].have_config = true; + /* fclk divider gets set later */ + gpmc_tusb_cs_data[TUSB_GPMC_CS_SYNC_IDX].config = GPMC_DEVICESIZE_16 | + GPMC_WAIT_READ_MON | + GPMC_WAIT_WRITE_MON | + GPMC_READTYPE_SYNC | + GPMC_WRITETYPE_SYNC | + GPMC_DEVICETYPE_NOR | + GPMC_MUXADDDATA | + GPMC_PAGE_LEN_16 | + GPMC_CLOCKACTIVATION_TIME_1 | + GPMC_READMULTIPLE | + GPMC_WRITEMULTIPLE | + waitpin; /* IRQ */ status = gpio_request_one(irq, GPIOF_IN, "TUSB6010 irq"); if (status < 0) { printk(error, 3, status); - return status; + return NULL; } - tusb_resources[2].start = irq + IH_GPIO_BASE; + tusb_resources.start = irq + IH_GPIO_BASE; /* set up memory timings ... can speed them up later */ if (!ps_refclk) { printk(error, 4, status); - return -ENODEV; + return NULL; } refclk_psec = ps_refclk; status = tusb6010_platform_retime(1); if (status < 0) { printk(error, 5, status); - return status; + return NULL; } - /* finish device setup ... */ if (!data) { printk(error, 6, status); - return -ENODEV; + return NULL; } - tusb_device.dev.platform_data = data; + gpmc_tusb_data.pdata = data; + gpmc_tusb_data.pdata_size = sizeof(*data); /* REVISIT let the driver know what DMA channels work */ - if (!dmachan) - tusb_device.dev.dma_mask = NULL; - else { + if (dmachan) { /* assume OMAP 2420 ES2.0 and later */ if (dmachan & (1 << 0)) omap_mux_init_signal("sys_ndmareq0", 0); @@ -340,11 +307,5 @@ tusb6010_setup_interface(struct musb_hdrc_platform_data *data, omap_mux_init_signal("sys_ndmareq5", 0); } - /* so far so good ... register the device */ - status = platform_device_register(&tusb_device); - if (status < 0) { - printk(error, 7, status); - return status; - } - return 0; + return &gpmc_tusb_data; } diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index eb50525..a7de510 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -139,14 +139,12 @@ struct musb_hdrc_platform_data { #ifdef CONFIG_ARCH_OMAP2 -extern int __init tusb6010_setup_interface( +extern __init struct gpmc_device_pdata *tusb6010_setup_interface( struct musb_hdrc_platform_data *data, unsigned ps_refclk, unsigned waitpin, unsigned async_cs, unsigned sync_cs, unsigned irq, unsigned dmachan); -extern int tusb6010_platform_retime(unsigned is_refclk); - #endif /* OMAP2 */ #endif /* __LINUX_USB_MUSB_H */