|
| 1 | +/* |
| 2 | + * OMAP hardware spinlock device initialization |
| 3 | + * |
| 4 | + * Copyright (C) 2010 Texas Instruments. All rights reserved. |
| 5 | + * |
| 6 | + * Contact: Simon Que <[email protected]> |
| 7 | + * |
| 8 | + * This program is free software; you can redistribute it and/or |
| 9 | + * modify it under the terms of the GNU General Public License |
| 10 | + * version 2 as published by the Free Software Foundation. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, but |
| 13 | + * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | + * General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program; if not, write to the Free Software |
| 19 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 | + * 02110-1301 USA |
| 21 | + * |
| 22 | + */ |
| 23 | + |
| 24 | +#include <linux/module.h> |
| 25 | +#include <linux/interrupt.h> |
| 26 | +#include <linux/device.h> |
| 27 | +#include <linux/delay.h> |
| 28 | +#include <linux/io.h> |
| 29 | +#include <linux/slab.h> |
| 30 | + |
| 31 | +#include <plat/hwspinlock.h> |
| 32 | +#include <plat/omap_device.h> |
| 33 | +#include <plat/omap_hwmod.h> |
| 34 | + |
| 35 | +/* Spinlock register offsets */ |
| 36 | +#define REVISION_OFFSET 0x0000 |
| 37 | +#define SYSCONFIG_OFFSET 0x0010 |
| 38 | +#define SYSSTATUS_OFFSET 0x0014 |
| 39 | +#define LOCK_BASE_OFFSET 0x0800 |
| 40 | +#define LOCK_OFFSET(i) (LOCK_BASE_OFFSET + 0x4 * (i)) |
| 41 | + |
| 42 | +/* Initialization function */ |
| 43 | +int __init hwspinlocks_init(void) |
| 44 | +{ |
| 45 | + int retval = 0; |
| 46 | + |
| 47 | + struct hwspinlock_plat_info *pdata; |
| 48 | + struct omap_hwmod *oh; |
| 49 | + char *oh_name, *pdev_name; |
| 50 | + |
| 51 | + oh_name = "spinlock"; |
| 52 | + oh = omap_hwmod_lookup(oh_name); |
| 53 | + if (WARN_ON(oh == NULL)) |
| 54 | + return -EINVAL; |
| 55 | + |
| 56 | + pdev_name = "hwspinlock"; |
| 57 | + |
| 58 | + /* Pass data to device initialization */ |
| 59 | + pdata = kzalloc(sizeof(struct hwspinlock_plat_info), GFP_KERNEL); |
| 60 | + if (WARN_ON(pdata == NULL)) |
| 61 | + return -ENOMEM; |
| 62 | + pdata->sysstatus_offset = SYSSTATUS_OFFSET; |
| 63 | + pdata->lock_base_offset = LOCK_BASE_OFFSET; |
| 64 | + |
| 65 | + omap_device_build(pdev_name, 0, oh, pdata, |
| 66 | + sizeof(struct hwspinlock_plat_info), NULL, 0, false); |
| 67 | + |
| 68 | + return retval; |
| 69 | +} |
| 70 | +module_init(hwspinlocks_init); |
0 commit comments