mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
hwspinlock: rockchip: support to set hwlock user in dt
With this commit, we can set hwlock user id in DT with "rockchip,hwlock-user-id" property, if it is not set, the driver use default value 0x01 instead. Change-Id: Ib7ecc3eaf23ba79d85dc82182a9db0760c6d830c Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
This commit is contained in:
@@ -22,21 +22,24 @@ struct rockchip_hwspinlock {
|
||||
|
||||
/* Hardware spinlock register offsets */
|
||||
#define HWSPINLOCK_OFFSET(x) (0x4 * (x))
|
||||
#define HWSPINLOCK_ID_MASK 0x0F
|
||||
|
||||
#define HWSPINLOCK_OWNER_ID 0x01
|
||||
#define HWLOCK_DEFAULT_USER 0x01
|
||||
|
||||
static u32 hwlock_user_id;
|
||||
|
||||
static int rockchip_hwspinlock_trylock(struct hwspinlock *lock)
|
||||
{
|
||||
void __iomem *lock_addr = lock->priv;
|
||||
|
||||
writel(HWSPINLOCK_OWNER_ID, lock_addr);
|
||||
writel(hwlock_user_id, lock_addr);
|
||||
|
||||
/*
|
||||
* Get only first 4 bits and compare to HWSPINLOCK_OWNER_ID,
|
||||
* if equal, we attempt to acquire the lock, otherwise,
|
||||
* someone else has it.
|
||||
*/
|
||||
return (HWSPINLOCK_OWNER_ID == (0x0F & readl(lock_addr)));
|
||||
return (hwlock_user_id == (readl(lock_addr) & HWSPINLOCK_ID_MASK));
|
||||
}
|
||||
|
||||
static void rockchip_hwspinlock_unlock(struct hwspinlock *lock)
|
||||
@@ -56,7 +59,7 @@ static int rockchip_hwspinlock_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct rockchip_hwspinlock *hwspin;
|
||||
struct hwspinlock *hwlock;
|
||||
int idx;
|
||||
int idx, ret;
|
||||
|
||||
hwspin = devm_kzalloc(&pdev->dev,
|
||||
struct_size(hwspin, bank.lock, HWSPINLOCK_NUMBER),
|
||||
@@ -68,6 +71,12 @@ static int rockchip_hwspinlock_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(hwspin->io_base))
|
||||
return PTR_ERR(hwspin->io_base);
|
||||
|
||||
ret = device_property_read_u32(&pdev->dev, "rockchip,hwlock-user-id",
|
||||
&hwlock_user_id);
|
||||
if (ret || !hwlock_user_id || hwlock_user_id > HWSPINLOCK_ID_MASK)
|
||||
hwlock_user_id = HWLOCK_DEFAULT_USER;
|
||||
dev_info(&pdev->dev, "hwlock user id %u\n", hwlock_user_id);
|
||||
|
||||
for (idx = 0; idx < HWSPINLOCK_NUMBER; idx++) {
|
||||
hwlock = &hwspin->bank.lock[idx];
|
||||
hwlock->priv = hwspin->io_base + HWSPINLOCK_OFFSET(idx);
|
||||
|
||||
Reference in New Issue
Block a user