summaryrefslogtreecommitdiff
path: root/xen/arch/arm/include/asm/device.h
blob: b5d451e08776a1b85dc426e59db5ee1653027cca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef __ASM_ARM_DEVICE_H
#define __ASM_ARM_DEVICE_H

enum device_type
{
    DEV_DT,
    DEV_PCI,
};

struct dev_archdata {
    void *iommu;    /* IOMMU private data */
};

/* struct device - The basic device structure */
struct device
{
    enum device_type type;
#ifdef CONFIG_HAS_DEVICE_TREE
    struct dt_device_node *of_node; /* Used by drivers imported from Linux */
#endif
    struct dev_archdata archdata;
    struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
};

typedef struct device device_t;

#include <xen/device_tree.h>

#define dev_is_pci(dev) ((dev)->type == DEV_PCI)
#define dev_is_dt(dev)  ((dev)->type == DEV_DT)

enum device_class
{
    DEVICE_SERIAL,
    DEVICE_IOMMU,
    DEVICE_GIC,
    DEVICE_PCI_HOSTBRIDGE,
    /* Use for error */
    DEVICE_UNKNOWN,
};

struct device_desc {
    /* Device name */
    const char *name;
    /* Device class */
    enum device_class class;
    /* List of devices supported by this driver */
    const struct dt_device_match *dt_match;
    /*
     * Device initialization.
     *
     * -EAGAIN is used to indicate that device probing is deferred.
     */
    int (*init)(struct dt_device_node *dev, const void *data);
};

struct acpi_device_desc {
    /* Device name */
    const char *name;
    /* Device class */
    enum device_class class;
    /* type of device supported by the driver */
    const int class_type;
    /* Device initialization */
    int (*init)(const void *data);
};

/**
 *  acpi_device_init - Initialize a device
 *  @class: class of the device (serial, network...)
 *  @data: specific data for initializing the device
 *
 *  Return 0 on success.
 */
int acpi_device_init(enum device_class class,
                     const void *data, int class_type);

/**
 *  device_init - Initialize a device
 *  @dev: device to initialize
 *  @class: class of the device (serial, network...)
 *  @data: specific data for initializing the device
 *
 *  Return 0 on success.
 */
int device_init(struct dt_device_node *dev, enum device_class class,
                const void *data);

/**
 * device_get_type - Get the type of the device
 * @dev: device to match
 *
 * Return the device type on success or DEVICE_ANY on failure
 */
enum device_class device_get_class(const struct dt_device_node *dev);

#define DT_DEVICE_START(_name, _namestr, _class)                    \
static const struct device_desc __dev_desc_##_name __used           \
__section(".dev.info") = {                                          \
    .name = _namestr,                                               \
    .class = _class,                                                \

#define DT_DEVICE_END                                               \
};

#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
static const struct acpi_device_desc __dev_desc_##_name __used           \
__section(".adev.info") = {                       \
    .name = _namestr,                                               \
    .class = _class,                                                \

#define ACPI_DEVICE_END                                               \
};

#endif /* __ASM_ARM_DEVICE_H */

/*
 * Local variables:
 * mode: C
 * c-file-style: "BSD"
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 */