2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-15 08:44:14 +08:00
linux-next/arch/arm/mach-omap1/timer.c
Olof Johansson cba3309e38 Sparse and cppcheck warning fixes
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQIcBAABAgAGBQJPqEJlAAoJEBvUPslcq6Vz8oYP/RuLK0emKF0efxZxIyIm/Vi8
 XJteTnxbptFhCm8tnBoQq0F68eJuvxJKa60tmqjiODFfBXpZZLZewsByogo5cbq3
 dUCxXJbCQWGOwvTrhf2k31S+Bysp/fG+CHlOZgfHWq6XQYvZxUZUsyCCxZC/5h+k
 9df3t2Kjm7wtcOHWTqmoLI5xZM+XbUUQdCdOjiShpiF2+lu22U3g6xj5k0ryJEOH
 YQRU35zNSaI+g1jEe7alyTGGMVE3WMm4dDin62RhRVoFRm/JxiP+8S0BuOQBI8IS
 vY46mvKG5baw2v6VKFh3O8sXDAZ8ZMWV9Hc/9WEHf2aQljB0J+he2alsC4FC0BsX
 R467DZj4jwh0KuN/N2OiDr8/rufMkc4CMYneEAfPdZoOaa5f5OplL5YPKPmi4LVB
 sYNbvJKwrDS/aRY4iBjdxDnQyZ89chYYQWV+43Fsq/ffp0LJPqZYPKwIbtGcIa4E
 KoMARTQyY1PN8l3NhcqPwmK2Xa5RjwO+an8arPPY9H7BLCpzt8/HINc3sz3wZiUQ
 SjrTYwqsT6eHD2A9ciwQiaFNKie/rYj6zaZ5212RXjX/Nl0RyQz2W1vIbzZ/c776
 zsoTwzvjHy5O9UuqT/HUjaxLQOctWFZT5+5HMqCixcjH9sCWjsnq+h8DCjicFvWX
 q1ajdKcZM/29soH3r2VL
 =MQ+t
 -----END PGP SIGNATURE-----

Merge tag 'omap-cleanup-sparse-for-v3.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into next/cleanup

Sparse and cppcheck warning fixes

By Paul Walmsley
via Paul Walmsley (1) and Tony Lindgren (1)
* tag 'omap-cleanup-sparse-for-v3.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap:
  ARM: OMAP2+: clean up some cppcheck warnings
  ARM: OMAP1: board files: deduplicate and clean some NAND-related code
  ARM: OMAP: USB: remove unnecessary sideways include
  ARM: OMAP: DMA: use constant array maximum, drop some LCD DMA code
  ARM: OMAP: OCM RAM: use memset_io() when clearing SRAM
  ARM: OMAP: fix 'using plain integer as NULL pointer' sparse warnings
  ARM: OMAP2+: GPMC: resolve type-conversion warning from sparse
  ARM: OMAP1: OHCI: use platform_data fn ptr to enable OCPI bus
  ARM: OMAP1: OCPI: move to mach-omap1/
  ARM: OMAP: add includes for missing prototypes
  ARM: OMAP2+: declare file-local functions as static

Signed-off-by: Olof Johansson <olof@lixom.net>
2012-05-09 02:28:46 -07:00

173 lines
4.0 KiB
C

/**
* OMAP1 Dual-Mode Timers - platform device registration
*
* Contains first level initialization routines which internally
* generates timer device information and registers with linux
* device model. It also has low level function to chnage the timer
* input clock source.
*
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* Tarun Kanti DebBarma <tarun.kanti@ti.com>
* Thara Gopinath <thara@ti.com>
*
* 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.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether express or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <mach/irqs.h>
#include <plat/dmtimer.h>
#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_src(struct platform_device *pdev,
int source)
{
int n = (pdev->id - 1) << 1;
u32 l;
l = omap_readl(MOD_CONF_CTRL_1) & ~(0x03 << n);
l |= source << n;
omap_writel(l, MOD_CONF_CTRL_1);
return 0;
}
static int __init omap1_dm_timer_init(void)
{
int i;
int ret;
struct dmtimer_platform_data *pdata;
struct platform_device *pdev;
if (!cpu_is_omap16xx())
return 0;
for (i = 1; i <= OMAP1_DM_TIMER_COUNT; i++) {
struct resource res[2];
u32 base, irq;
switch (i) {
case 1:
base = OMAP1610_GPTIMER1_BASE;
irq = INT_1610_GPTIMER1;
break;
case 2:
base = OMAP1610_GPTIMER2_BASE;
irq = INT_1610_GPTIMER2;
break;
case 3:
base = OMAP1610_GPTIMER3_BASE;
irq = INT_1610_GPTIMER3;
break;
case 4:
base = OMAP1610_GPTIMER4_BASE;
irq = INT_1610_GPTIMER4;
break;
case 5:
base = OMAP1610_GPTIMER5_BASE;
irq = INT_1610_GPTIMER5;
break;
case 6:
base = OMAP1610_GPTIMER6_BASE;
irq = INT_1610_GPTIMER6;
break;
case 7:
base = OMAP1610_GPTIMER7_BASE;
irq = INT_1610_GPTIMER7;
break;
case 8:
base = OMAP1610_GPTIMER8_BASE;
irq = INT_1610_GPTIMER8;
break;
default:
/*
* not supposed to reach here.
* this is to remove warning.
*/
return -EINVAL;
}
pdev = platform_device_alloc("omap_timer", i);
if (!pdev) {
pr_err("%s: Failed 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 + 0x46;
res[0].flags = IORESOURCE_MEM;
res[1].start = irq;
res[1].end = irq;
res[1].flags = IORESOURCE_IRQ;
ret = platform_device_add_resources(pdev, res,
ARRAY_SIZE(res));
if (ret) {
dev_err(&pdev->dev, "%s: Failed to add resources.\n",
__func__);
goto err_free_pdev;
}
pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
if (!pdata) {
dev_err(&pdev->dev, "%s: Failed to allocate pdata.\n",
__func__);
ret = -ENOMEM;
goto err_free_pdata;
}
pdata->set_timer_src = omap1_dm_timer_set_src;
pdata->needs_manual_reset = 1;
ret = platform_device_add_data(pdev, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "%s: Failed to add platform data.\n",
__func__);
goto err_free_pdata;
}
ret = platform_device_add(pdev);
if (ret) {
dev_err(&pdev->dev, "%s: Failed to add platform device.\n",
__func__);
goto err_free_pdata;
}
dev_dbg(&pdev->dev, " Registered.\n");
}
return 0;
err_free_pdata:
kfree(pdata);
err_free_pdev:
platform_device_unregister(pdev);
return ret;
}
arch_initcall(omap1_dm_timer_init);