2011-02-17 17:52:03 +00:00
|
|
|
/*
|
|
|
|
* OMAP hardware spinlock device initialization
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
|
|
|
|
*
|
|
|
|
* Contact: Simon Que <sque@ti.com>
|
|
|
|
* Hari Kanigeri <h-kanigeri2@ti.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/err.h>
|
hwspinlock/core/omap: fix id issues on multiple hwspinlock devices
hwspinlock devices provide system-wide hardware locks that are used
by remote processors that have no other way to achieve synchronization.
To achieve that, each physical lock must have a system-wide id number
that is agreed upon, otherwise remote processors can't possibly assume
they're using the same hardware lock.
Usually boards have a single hwspinlock device, which provides several
hwspinlocks, and in this case, they can be trivially numbered 0 to
(num-of-locks - 1).
In case boards have several hwspinlocks devices, a different base id
should be used for each hwspinlock device (they can't all use 0 as
a starting id!).
While this is certainly not common, it's just plain wrong to just
silently use 0 as a base id whenever the hwspinlock driver is probed.
This patch provides a hwspinlock_pdata structure, that boards can use
to set a different base id for each of the hwspinlock devices they may
have, and demonstrates how to use it with the omap hwspinlock driver.
While we're at it, make sure the hwspinlock core prints an explicit
error message in case an hwspinlock is registered with an id number
that already exists; this will help users catch such base id issues.
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Acked-by: Tony Lindgren <tony@atomide.com>
2011-09-05 20:15:06 +00:00
|
|
|
#include <linux/hwspinlock.h>
|
2011-02-17 17:52:03 +00:00
|
|
|
|
|
|
|
#include <plat/omap_hwmod.h>
|
|
|
|
#include <plat/omap_device.h>
|
|
|
|
|
hwspinlock/core/omap: fix id issues on multiple hwspinlock devices
hwspinlock devices provide system-wide hardware locks that are used
by remote processors that have no other way to achieve synchronization.
To achieve that, each physical lock must have a system-wide id number
that is agreed upon, otherwise remote processors can't possibly assume
they're using the same hardware lock.
Usually boards have a single hwspinlock device, which provides several
hwspinlocks, and in this case, they can be trivially numbered 0 to
(num-of-locks - 1).
In case boards have several hwspinlocks devices, a different base id
should be used for each hwspinlock device (they can't all use 0 as
a starting id!).
While this is certainly not common, it's just plain wrong to just
silently use 0 as a base id whenever the hwspinlock driver is probed.
This patch provides a hwspinlock_pdata structure, that boards can use
to set a different base id for each of the hwspinlock devices they may
have, and demonstrates how to use it with the omap hwspinlock driver.
While we're at it, make sure the hwspinlock core prints an explicit
error message in case an hwspinlock is registered with an id number
that already exists; this will help users catch such base id issues.
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Acked-by: Tony Lindgren <tony@atomide.com>
2011-09-05 20:15:06 +00:00
|
|
|
static struct hwspinlock_pdata omap_hwspinlock_pdata __initdata = {
|
|
|
|
.base_id = 0,
|
|
|
|
};
|
|
|
|
|
2011-02-17 17:52:03 +00:00
|
|
|
int __init hwspinlocks_init(void)
|
|
|
|
{
|
|
|
|
int retval = 0;
|
|
|
|
struct omap_hwmod *oh;
|
2011-07-21 20:48:45 +00:00
|
|
|
struct platform_device *pdev;
|
2011-02-17 17:52:03 +00:00
|
|
|
const char *oh_name = "spinlock";
|
|
|
|
const char *dev_name = "omap_hwspinlock";
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hwmod lookup will fail in case our platform doesn't support the
|
|
|
|
* hardware spinlock module, so it is safe to run this initcall
|
|
|
|
* on all omaps
|
|
|
|
*/
|
|
|
|
oh = omap_hwmod_lookup(oh_name);
|
|
|
|
if (oh == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-11-03 15:05:35 +00:00
|
|
|
pdev = omap_device_build(dev_name, 0, oh, &omap_hwspinlock_pdata,
|
hwspinlock/core/omap: fix id issues on multiple hwspinlock devices
hwspinlock devices provide system-wide hardware locks that are used
by remote processors that have no other way to achieve synchronization.
To achieve that, each physical lock must have a system-wide id number
that is agreed upon, otherwise remote processors can't possibly assume
they're using the same hardware lock.
Usually boards have a single hwspinlock device, which provides several
hwspinlocks, and in this case, they can be trivially numbered 0 to
(num-of-locks - 1).
In case boards have several hwspinlocks devices, a different base id
should be used for each hwspinlock device (they can't all use 0 as
a starting id!).
While this is certainly not common, it's just plain wrong to just
silently use 0 as a base id whenever the hwspinlock driver is probed.
This patch provides a hwspinlock_pdata structure, that boards can use
to set a different base id for each of the hwspinlock devices they may
have, and demonstrates how to use it with the omap hwspinlock driver.
While we're at it, make sure the hwspinlock core prints an explicit
error message in case an hwspinlock is registered with an id number
that already exists; this will help users catch such base id issues.
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Acked-by: Tony Lindgren <tony@atomide.com>
2011-09-05 20:15:06 +00:00
|
|
|
sizeof(struct hwspinlock_pdata),
|
2011-11-03 15:05:35 +00:00
|
|
|
NULL, 0, false);
|
2011-07-21 20:48:45 +00:00
|
|
|
if (IS_ERR(pdev)) {
|
2011-02-17 17:52:03 +00:00
|
|
|
pr_err("Can't build omap_device for %s:%s\n", dev_name,
|
|
|
|
oh_name);
|
2011-07-21 20:48:45 +00:00
|
|
|
retval = PTR_ERR(pdev);
|
2011-02-17 17:52:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
/* early board code might need to reserve specific hwspinlock instances */
|
|
|
|
postcore_initcall(hwspinlocks_init);
|