2019-05-27 08:55:05 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2006-11-11 17:24:53 +11:00
|
|
|
/*
|
|
|
|
* (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
|
|
|
|
* <benh@kernel.crashing.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2011-05-27 10:46:24 -04:00
|
|
|
#include <linux/export.h>
|
2022-03-08 20:20:25 +01:00
|
|
|
#include <linux/of_address.h>
|
2006-11-11 17:24:53 +11:00
|
|
|
#include <asm/dcr.h>
|
|
|
|
|
2008-12-19 08:17:54 +00:00
|
|
|
unsigned int dcr_resource_start(const struct device_node *np,
|
|
|
|
unsigned int index)
|
2006-11-11 17:24:53 +11:00
|
|
|
{
|
|
|
|
unsigned int ds;
|
2007-04-03 22:26:41 +10:00
|
|
|
const u32 *dr = of_get_property(np, "dcr-reg", &ds);
|
2006-11-11 17:24:53 +11:00
|
|
|
|
|
|
|
if (dr == NULL || ds & 1 || index >= (ds / 8))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return dr[index * 2];
|
|
|
|
}
|
2007-08-09 07:46:49 +10:00
|
|
|
EXPORT_SYMBOL_GPL(dcr_resource_start);
|
2006-11-11 17:24:53 +11:00
|
|
|
|
2008-12-19 08:17:54 +00:00
|
|
|
unsigned int dcr_resource_len(const struct device_node *np, unsigned int index)
|
2006-11-11 17:24:53 +11:00
|
|
|
{
|
|
|
|
unsigned int ds;
|
2007-04-03 22:26:41 +10:00
|
|
|
const u32 *dr = of_get_property(np, "dcr-reg", &ds);
|
2006-11-11 17:24:53 +11:00
|
|
|
|
|
|
|
if (dr == NULL || ds & 1 || index >= (ds / 8))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return dr[index * 2 + 1];
|
|
|
|
}
|
2007-08-09 07:46:49 +10:00
|
|
|
EXPORT_SYMBOL_GPL(dcr_resource_len);
|
2006-11-11 17:24:53 +11:00
|
|
|
|
2008-02-05 01:57:55 +11:00
|
|
|
DEFINE_SPINLOCK(dcr_ind_lock);
|
2014-08-19 23:24:15 -04:00
|
|
|
EXPORT_SYMBOL_GPL(dcr_ind_lock);
|