Files

41 lines
910 B
C
Raw Permalink Normal View History

// 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>
#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>
unsigned int dcr_resource_start(const struct device_node *np,
unsigned int index)
2006-11-11 17:24:53 +11:00
{
unsigned int ds;
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
unsigned int dcr_resource_len(const struct device_node *np, unsigned int index)
2006-11-11 17:24:53 +11:00
{
unsigned int ds;
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
DEFINE_SPINLOCK(dcr_ind_lock);
EXPORT_SYMBOL_GPL(dcr_ind_lock);