mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 09:15:11 +07:00
2874c5fd28
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 3029 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
78 lines
1.8 KiB
C
78 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Copyright (C) 2016 Maxime Ripard
|
|
* Maxime Ripard <maxime.ripard@free-electrons.com>
|
|
*/
|
|
|
|
#include <linux/delay.h>
|
|
#include <linux/io.h>
|
|
#include <linux/reset-controller.h>
|
|
|
|
#include "ccu_reset.h"
|
|
|
|
static int ccu_reset_assert(struct reset_controller_dev *rcdev,
|
|
unsigned long id)
|
|
{
|
|
struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
|
|
const struct ccu_reset_map *map = &ccu->reset_map[id];
|
|
unsigned long flags;
|
|
u32 reg;
|
|
|
|
spin_lock_irqsave(ccu->lock, flags);
|
|
|
|
reg = readl(ccu->base + map->reg);
|
|
writel(reg & ~map->bit, ccu->base + map->reg);
|
|
|
|
spin_unlock_irqrestore(ccu->lock, flags);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ccu_reset_deassert(struct reset_controller_dev *rcdev,
|
|
unsigned long id)
|
|
{
|
|
struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
|
|
const struct ccu_reset_map *map = &ccu->reset_map[id];
|
|
unsigned long flags;
|
|
u32 reg;
|
|
|
|
spin_lock_irqsave(ccu->lock, flags);
|
|
|
|
reg = readl(ccu->base + map->reg);
|
|
writel(reg | map->bit, ccu->base + map->reg);
|
|
|
|
spin_unlock_irqrestore(ccu->lock, flags);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ccu_reset_reset(struct reset_controller_dev *rcdev,
|
|
unsigned long id)
|
|
{
|
|
ccu_reset_assert(rcdev, id);
|
|
udelay(10);
|
|
ccu_reset_deassert(rcdev, id);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ccu_reset_status(struct reset_controller_dev *rcdev,
|
|
unsigned long id)
|
|
{
|
|
struct ccu_reset *ccu = rcdev_to_ccu_reset(rcdev);
|
|
const struct ccu_reset_map *map = &ccu->reset_map[id];
|
|
|
|
/*
|
|
* The reset control API expects 0 if reset is not asserted,
|
|
* which is the opposite of what our hardware uses.
|
|
*/
|
|
return !(map->bit & readl(ccu->base + map->reg));
|
|
}
|
|
|
|
const struct reset_control_ops ccu_reset_ops = {
|
|
.assert = ccu_reset_assert,
|
|
.deassert = ccu_reset_deassert,
|
|
.reset = ccu_reset_reset,
|
|
.status = ccu_reset_status,
|
|
};
|