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> |
| 22 | |
| 23 | #include <plat/omap_hwmod.h> |
| 24 | #include <plat/omap_device.h> |
| 25 | |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 26 | int __init hwspinlocks_init(void) |
| 27 | { |
| 28 | int retval = 0; |
| 29 | struct omap_hwmod *oh; |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 30 | struct platform_device *pdev; |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 31 | const char *oh_name = "spinlock"; |
| 32 | const char *dev_name = "omap_hwspinlock"; |
| 33 | |
| 34 | /* |
| 35 | * Hwmod lookup will fail in case our platform doesn't support the |
| 36 | * hardware spinlock module, so it is safe to run this initcall |
| 37 | * on all omaps |
| 38 | */ |
| 39 | oh = omap_hwmod_lookup(oh_name); |
| 40 | if (oh == NULL) |
| 41 | return -EINVAL; |
| 42 | |
Benoit Cousson | f718e2c | 2011-08-10 15:30:09 +0200 | [diff] [blame] | 43 | pdev = omap_device_build(dev_name, 0, oh, NULL, 0, NULL, 0, false); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 44 | if (IS_ERR(pdev)) { |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 45 | pr_err("Can't build omap_device for %s:%s\n", dev_name, |
| 46 | oh_name); |
Kevin Hilman | 3528c58 | 2011-07-21 13:48:45 -0700 | [diff] [blame] | 47 | retval = PTR_ERR(pdev); |
Simon Que | 7bb412a | 2011-02-17 09:52:03 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | return retval; |
| 51 | } |
| 52 | /* early board code might need to reserve specific hwspinlock instances */ |
| 53 | postcore_initcall(hwspinlocks_init); |