From patchwork Sat Aug 14 15:33:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun Kanti DebBarma X-Patchwork-Id: 119548 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7E4YCOP006145 for ; Sat, 14 Aug 2010 04:34:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750936Ab0HNEeK (ORCPT ); Sat, 14 Aug 2010 00:34:10 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:45150 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750810Ab0HNEeJ (ORCPT ); Sat, 14 Aug 2010 00:34:09 -0400 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o7E4Y4Qo013904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 13 Aug 2010 23:34:06 -0500 Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id o7E4Y1Vt028212; Sat, 14 Aug 2010 10:04:02 +0530 (IST) From: Tarun Kanti DebBarma To: linux-omap@vger.kernel.org Cc: Thara Gopinath , Partha Basak , Tarun Kanti DebBarma , Paul Walmsley , Kevin Hilman , Tony Lindgren Subject: [PATCHv2 13/13] dmtimer: hwmod: OMAP1: device registration Date: Sat, 14 Aug 2010 21:03:21 +0530 Message-Id: <1281800001-14960-1-git-send-email-tarun.kanti@ti.com> X-Mailer: git-send-email 1.6.0.4 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]); Sat, 14 Aug 2010 04:34:12 +0000 (UTC) diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile index 9a304d8..0001659 --- a/arch/arm/mach-omap1/Makefile +++ b/arch/arm/mach-omap1/Makefile @@ -4,7 +4,7 @@ # Common support obj-y := io.o id.o sram.o irq.o mux.o flash.o serial.o devices.o -obj-y += clock.o clock_data.o opp_data.o +obj-y += clock.o clock_data.o opp_data.o dmtimer.o obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o diff --git a/arch/arm/mach-omap1/dmtimer.c b/arch/arm/mach-omap1/dmtimer.c new file mode 100755 index 0000000..b06d096 --- /dev/null +++ b/arch/arm/mach-omap1/dmtimer.c @@ -0,0 +1,146 @@ +/** + * OMAP1 Dual-Mode Timers + * + * Copyright (C) 2010 Texas Instruments, Inc. + * Thara Gopinath + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +#define OMAP1610_GPTIMER1_BASE 0xfffb1400 +#define OMAP1610_GPTIMER2_BASE 0xfffb1c00 +#define OMAP1610_GPTIMER3_BASE 0xfffb2400 +#define OMAP1610_GPTIMER4_BASE 0xfffb2c00 +#define OMAP1610_GPTIMER5_BASE 0xfffb3400 +#define OMAP1610_GPTIMER6_BASE 0xfffb3c00 +#define OMAP1610_GPTIMER7_BASE 0xfffb7400 +#define OMAP1610_GPTIMER8_BASE 0xfffbd400 + +#define OMAP1_DM_TIMER_COUNT 8 + +static int omap1_dm_timer_set_clk(struct platform_device *pdev, + int source) +{ + int n = (pdev->id) << 1; + u32 l; + + l = omap_readl(MOD_CONF_CTRL_1) & ~(0x03 << n); + l |= source << n; + omap_writel(l, MOD_CONF_CTRL_1); + + return 0; +} + +int __init omap1_dm_timer_init(void) +{ + int i; + + if (!cpu_is_omap16xx()) + return 0; + + for (i = 0; i < OMAP1_DM_TIMER_COUNT; i++) { + struct platform_device *pdev; + struct omap_dmtimer_platform_data *pdata; + struct resource res[2]; + u32 base, irq; + int ret; + + switch (i) { + case 0: + base = OMAP1610_GPTIMER1_BASE; + irq = INT_1610_GPTIMER1; + break; + case 1: + base = OMAP1610_GPTIMER2_BASE; + irq = INT_1610_GPTIMER2; + break; + case 2: + base = OMAP1610_GPTIMER3_BASE; + irq = INT_1610_GPTIMER3; + break; + case 3: + base = OMAP1610_GPTIMER4_BASE; + irq = INT_1610_GPTIMER4; + break; + case 4: + base = OMAP1610_GPTIMER5_BASE; + irq = INT_1610_GPTIMER5; + break; + case 5: + base = OMAP1610_GPTIMER6_BASE; + irq = INT_1610_GPTIMER6; + break; + case 6: + base = OMAP1610_GPTIMER7_BASE; + irq = INT_1610_GPTIMER7; + break; + case 7: + base = OMAP1610_GPTIMER8_BASE; + irq = INT_1610_GPTIMER8; + break; + default: + /* Should never reach here */ + return -EINVAL; + } + + pdev = platform_device_alloc("dmtimer", i); + if (!pdev) { + pr_err("%s: Unable to device alloc for dmtimer%d\n", + __func__, i); + return -ENOMEM; + } + + memset(res, 0, 2 * sizeof(struct resource)); + res[0].start = base; + res[0].end = base + 0xff; + res[0].flags = IORESOURCE_MEM; + res[1].start = res[1].end = irq; + res[1].flags = IORESOURCE_IRQ; + ret = platform_device_add_resources(pdev, res, + ARRAY_SIZE(res)); + if (ret) { + pr_err("%s: Unable to add resources for %s%d\n", + __func__, pdev->name, pdev->id); + goto exit_device_put; + } + + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + pr_err("%s: Unable to allocate pdata for %s%d\n", + __func__, pdev->name, pdev->id); + ret = -ENOMEM; + goto exit_device_put; + } + + pdata->omap_dm_set_source_clk = omap1_dm_timer_set_clk; + ret = platform_device_add_data(pdev, pdata, sizeof(*pdata)); + if (ret) { + pr_err("%s: Unable to add platform data for %s%d\n", + __func__, pdev->name, pdev->id); + goto exit_release_pdata; + } + ret = platform_device_add(pdev); + if (ret) { + pr_err("%s: Unable to add platform device for %s%d\n", + __func__, pdev->name, pdev->id); + goto exit_release_pdata; + } + continue; +exit_release_pdata: + kfree(pdata); +exit_device_put: + platform_device_put(pdev); + return ret; + } + return 0; +} +arch_initcall(omap1_dm_timer_init); diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c index 20cfbcc..6b8ab9b --- a/arch/arm/mach-omap1/timer32k.c +++ b/arch/arm/mach-omap1/timer32k.c @@ -183,9 +183,6 @@ static __init void omap_init_32k_timer(void) */ static void __init omap_timer_init(void) { -#ifdef CONFIG_OMAP_DM_TIMER - omap_dm_timer_init(); -#endif omap_init_32k_timer(); }