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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/
* Dave Gerlach <d-gerlach@ti.com>
*/
#ifndef __SOC_H
#define __SOC_H
#define SOC_MAX_STR_SIZE 128
/**
* struct soc_attr - Contains SoC identify information to be used in
* SoC matching. An array of these structs
* representing different SoCs can be passed to
* soc_device_match and the struct matching the SoC
* in use will be returned.
*
* @family - Name of SoC family that can include multiple related SoC
* variants. Example: am33
* @machine - Name of a specific SoC. Example: am3352
* @revision - Name of a specific SoC revision. Example: SR1.1
* @data - A pointer to user data for the SoC variant
*/
struct soc_attr {
const char *family;
const char *machine;
const char *revision;
const void *data;
};
struct soc_ops {
/**
* get_machine() - Get machine name of an SOC
*
* @dev: Device to check (UCLASS_SOC)
* @buf: Buffer to place string
* @size: Size of string space
* @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
int (*get_machine)(struct udevice *dev, char *buf, int size);
/**
* get_revision() - Get revision name of a SOC
*
* @dev: Device to check (UCLASS_SOC)
* @buf: Buffer to place string
* @size: Size of string space
* @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
int (*get_revision)(struct udevice *dev, char *buf, int size);
/**
* get_family() - Get family name of an SOC
*
* @dev: Device to check (UCLASS_SOC)
* @buf: Buffer to place string
* @size: Size of string space
* @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
int (*get_family)(struct udevice *dev, char *buf, int size);
};
#define soc_get_ops(dev) ((struct soc_ops *)(dev)->driver->ops)
#ifdef CONFIG_SOC_DEVICE
/**
* soc_get() - Return the soc device for the soc in use.
* @devp: Pointer to structure to receive the soc device.
*
* Since there can only be at most one SOC instance, the API can supply a
* function that returns the unique device.
*
* Return: 0 if OK, -ve on error.
*/
int soc_get(struct udevice **devp);
/**
* soc_get_machine() - Get machine name of an SOC
* @dev: Device to check (UCLASS_SOC)
* @buf: Buffer to place string
* @size: Size of string space
*
* Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
int soc_get_machine(struct udevice *dev, char *buf, int size);
/**
* soc_get_revision() - Get revision name of an SOC
* @dev: Device to check (UCLASS_SOC)
* @buf: Buffer to place string
* @size: Size of string space
*
* Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
int soc_get_revision(struct udevice *dev, char *buf, int size);
/**
* soc_get_family() - Get family name of an SOC
* @dev: Device to check (UCLASS_SOC)
* @buf: Buffer to place string
* @size: Size of string space
*
* Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
*/
int soc_get_family(struct udevice *dev, char *buf, int size);
/**
* soc_device_match() - Return match from an array of soc_attr
* @matches: Array with any combination of family, revision or machine set
*
* Return: Pointer to struct from matches array with set attributes matching
* those provided by the soc device, or NULL if no match found.
*/
const struct soc_attr *
soc_device_match(const struct soc_attr *matches);
#else
static inline int soc_get(struct udevice **devp)
{
return -ENOSYS;
}
static inline int soc_get_machine(struct udevice *dev, char *buf, int size)
{
return -ENOSYS;
}
static inline int soc_get_revision(struct udevice *dev, char *buf, int size)
{
return -ENOSYS;
}
static inline int soc_get_family(struct udevice *dev, char *buf, int size)
{
return -ENOSYS;
}
static inline const struct soc_attr *
soc_device_match(const struct soc_attr *matches)
{
return NULL;
}
#endif
#endif /* _SOC_H */
|