Merge tag 'md-3.10-fixes' of git://neil.brown.name/md
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-omap2 / hwspinlock.c
CommitLineData
7bb412a6
SQ
1/*
2 * OMAP hardware spinlock device initialization
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
5 *
6 * Contact: Simon Que <sque@ti.com>
7 * Hari Kanigeri <h-kanigeri2@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 */
18
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/err.h>
c3c1250e 22#include <linux/hwspinlock.h>
7bb412a6 23
13fba955 24#include "soc.h"
2a296c8f 25#include "omap_hwmod.h"
25c7d49e 26#include "omap_device.h"
7bb412a6 27
c3c1250e
OBC
28static struct hwspinlock_pdata omap_hwspinlock_pdata __initdata = {
29 .base_id = 0,
30};
31
8c3d4534 32static int __init hwspinlocks_init(void)
7bb412a6
SQ
33{
34 int retval = 0;
35 struct omap_hwmod *oh;
3528c58e 36 struct platform_device *pdev;
7bb412a6
SQ
37 const char *oh_name = "spinlock";
38 const char *dev_name = "omap_hwspinlock";
39
40 /*
41 * Hwmod lookup will fail in case our platform doesn't support the
42 * hardware spinlock module, so it is safe to run this initcall
43 * on all omaps
44 */
45 oh = omap_hwmod_lookup(oh_name);
46 if (oh == NULL)
47 return -EINVAL;
48
3f8ddb03 49 pdev = omap_device_build(dev_name, 0, oh, &omap_hwspinlock_pdata,
c1d1cd59 50 sizeof(struct hwspinlock_pdata));
3528c58e 51 if (IS_ERR(pdev)) {
7bb412a6
SQ
52 pr_err("Can't build omap_device for %s:%s\n", dev_name,
53 oh_name);
3528c58e 54 retval = PTR_ERR(pdev);
7bb412a6
SQ
55 }
56
57 return retval;
58}
59/* early board code might need to reserve specific hwspinlock instances */
b76c8b19 60omap_postcore_initcall(hwspinlocks_init);