blob: c3688903f3d4b188d754b29c301c61f160ee3efa [file] [log] [blame]
Simon Que7bb412a2011-02-17 09:52:03 -08001/*
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>
Ohad Ben-Cohenc3c12502011-09-05 23:15:06 +030022#include <linux/hwspinlock.h>
Simon Que7bb412a2011-02-17 09:52:03 -080023
Tony Lindgren2a296c82012-10-02 17:41:35 -070024#include "omap_hwmod.h"
Tony Lindgren25c7d492012-10-02 17:25:48 -070025#include "omap_device.h"
Simon Que7bb412a2011-02-17 09:52:03 -080026
Ohad Ben-Cohenc3c12502011-09-05 23:15:06 +030027static struct hwspinlock_pdata omap_hwspinlock_pdata __initdata = {
28 .base_id = 0,
29};
30
Paul Walmsley8c3d4532012-04-13 06:34:26 -060031static int __init hwspinlocks_init(void)
Simon Que7bb412a2011-02-17 09:52:03 -080032{
33 int retval = 0;
34 struct omap_hwmod *oh;
Kevin Hilman3528c582011-07-21 13:48:45 -070035 struct platform_device *pdev;
Simon Que7bb412a2011-02-17 09:52:03 -080036 const char *oh_name = "spinlock";
37 const char *dev_name = "omap_hwspinlock";
38
39 /*
40 * Hwmod lookup will fail in case our platform doesn't support the
41 * hardware spinlock module, so it is safe to run this initcall
42 * on all omaps
43 */
44 oh = omap_hwmod_lookup(oh_name);
45 if (oh == NULL)
46 return -EINVAL;
47
Linus Torvalds3f8ddb02011-11-03 08:05:35 -070048 pdev = omap_device_build(dev_name, 0, oh, &omap_hwspinlock_pdata,
Paul Walmsleyc1d1cd52013-01-26 00:48:53 -070049 sizeof(struct hwspinlock_pdata));
Kevin Hilman3528c582011-07-21 13:48:45 -070050 if (IS_ERR(pdev)) {
Simon Que7bb412a2011-02-17 09:52:03 -080051 pr_err("Can't build omap_device for %s:%s\n", dev_name,
52 oh_name);
Kevin Hilman3528c582011-07-21 13:48:45 -070053 retval = PTR_ERR(pdev);
Simon Que7bb412a2011-02-17 09:52:03 -080054 }
55
56 return retval;
57}
58/* early board code might need to reserve specific hwspinlock instances */
59postcore_initcall(hwspinlocks_init);