Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 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> |
Ohad Ben-Cohen | c3c1250 | 2011-09-05 23:15:06 +0300 | [diff] [blame] | 22 | #include <linux/hwspinlock.h> |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 23 | |
Tony Lindgren | 13fba95 | 2013-02-05 09:51:26 -0800 | [diff] [blame] | 24 | #include "soc.h" |
Tony Lindgren | 2a296c8 | 2012-10-02 17:41:35 -0700 | [diff] [blame] | 25 | #include "omap_hwmod.h" |
Tony Lindgren | 25c7d49 | 2012-10-02 17:25:48 -0700 | [diff] [blame] | 26 | #include "omap_device.h" |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 27 | |
Ohad Ben-Cohen | c3c1250 | 2011-09-05 23:15:06 +0300 | [diff] [blame] | 28 | static struct hwspinlock_pdata omap_hwspinlock_pdata __initdata = { |
| 29 | .base_id = 0, |
| 30 | }; |
| 31 | |
Paul Walmsley | 8c3d453 | 2012-04-13 06:34:26 -0600 | [diff] [blame] | 32 | static int __init hwspinlocks_init(void) |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 33 | { |
| 34 | int retval = 0; |
| 35 | struct omap_hwmod *oh; |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 36 | struct platform_device *pdev; |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 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 | |
Linus Torvalds | 3f8ddb0 | 2011-11-03 08:05:35 -0700 | [diff] [blame] | 49 | pdev = omap_device_build(dev_name, 0, oh, &omap_hwspinlock_pdata, |
Paul Walmsley | c1d1cd5 | 2013-01-26 00:48:53 -0700 | [diff] [blame] | 50 | sizeof(struct hwspinlock_pdata)); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 51 | if (IS_ERR(pdev)) { |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 52 | pr_err("Can't build omap_device for %s:%s\n", dev_name, |
| 53 | oh_name); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 54 | retval = PTR_ERR(pdev); |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | return retval; |
| 58 | } |
| 59 | /* early board code might need to reserve specific hwspinlock instances */ |
Tony Lindgren | b76c8b1 | 2013-01-11 11:24:18 -0800 | [diff] [blame] | 60 | omap_postcore_initcall(hwspinlocks_init); |