Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/powerpc/sysdev/dcr.c
26442 views
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
/*
3
* (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
4
* <[email protected]>
5
*/
6
7
#undef DEBUG
8
9
#include <linux/kernel.h>
10
#include <linux/export.h>
11
#include <linux/of_address.h>
12
#include <asm/dcr.h>
13
14
unsigned int dcr_resource_start(const struct device_node *np,
15
unsigned int index)
16
{
17
unsigned int ds;
18
const u32 *dr = of_get_property(np, "dcr-reg", &ds);
19
20
if (dr == NULL || ds & 1 || index >= (ds / 8))
21
return 0;
22
23
return dr[index * 2];
24
}
25
EXPORT_SYMBOL_GPL(dcr_resource_start);
26
27
unsigned int dcr_resource_len(const struct device_node *np, unsigned int index)
28
{
29
unsigned int ds;
30
const u32 *dr = of_get_property(np, "dcr-reg", &ds);
31
32
if (dr == NULL || ds & 1 || index >= (ds / 8))
33
return 0;
34
35
return dr[index * 2 + 1];
36
}
37
EXPORT_SYMBOL_GPL(dcr_resource_len);
38
39
DEFINE_SPINLOCK(dcr_ind_lock);
40
EXPORT_SYMBOL_GPL(dcr_ind_lock);
41
42