1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/
4 * Dave Gerlach <d-gerlach@ti.com>
10 #define SOC_MAX_STR_SIZE 128
15 * struct soc_attr - Contains SoC identify information to be used in
16 * SoC matching. An array of these structs
17 * representing different SoCs can be passed to
18 * soc_device_match and the struct matching the SoC
19 * in use will be returned.
21 * @family - Name of SoC family that can include multiple related SoC
22 * variants. Example: am33
23 * @machine - Name of a specific SoC. Example: am3352
24 * @revision - Name of a specific SoC revision. Example: SR1.1
25 * @data - A pointer to user data for the SoC variant
36 * get_machine() - Get machine name of an SOC
38 * @dev: Device to check (UCLASS_SOC)
39 * @buf: Buffer to place string
40 * @size: Size of string space
41 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
43 int (*get_machine)(struct udevice *dev, char *buf, int size);
46 * get_revision() - Get revision name of a SOC
48 * @dev: Device to check (UCLASS_SOC)
49 * @buf: Buffer to place string
50 * @size: Size of string space
51 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
53 int (*get_revision)(struct udevice *dev, char *buf, int size);
56 * get_family() - Get family name of an SOC
58 * @dev: Device to check (UCLASS_SOC)
59 * @buf: Buffer to place string
60 * @size: Size of string space
61 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
63 int (*get_family)(struct udevice *dev, char *buf, int size);
66 #define soc_get_ops(dev) ((struct soc_ops *)(dev)->driver->ops)
68 #ifdef CONFIG_SOC_DEVICE
70 * soc_get() - Return the soc device for the soc in use.
71 * @devp: Pointer to structure to receive the soc device.
73 * Since there can only be at most one SOC instance, the API can supply a
74 * function that returns the unique device.
76 * Return: 0 if OK, -ve on error.
78 int soc_get(struct udevice **devp);
81 * soc_get_machine() - Get machine name of an SOC
82 * @dev: Device to check (UCLASS_SOC)
83 * @buf: Buffer to place string
84 * @size: Size of string space
86 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
88 int soc_get_machine(struct udevice *dev, char *buf, int size);
91 * soc_get_revision() - Get revision name of an SOC
92 * @dev: Device to check (UCLASS_SOC)
93 * @buf: Buffer to place string
94 * @size: Size of string space
96 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
98 int soc_get_revision(struct udevice *dev, char *buf, int size);
101 * soc_get_family() - Get family name of an SOC
102 * @dev: Device to check (UCLASS_SOC)
103 * @buf: Buffer to place string
104 * @size: Size of string space
106 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
108 int soc_get_family(struct udevice *dev, char *buf, int size);
111 * soc_device_match() - Return match from an array of soc_attr
112 * @matches: Array with any combination of family, revision or machine set
114 * Return: Pointer to struct from matches array with set attributes matching
115 * those provided by the soc device, or NULL if no match found.
117 const struct soc_attr *
118 soc_device_match(const struct soc_attr *matches);
121 static inline int soc_get(struct udevice **devp)
126 static inline int soc_get_machine(struct udevice *dev, char *buf, int size)
131 static inline int soc_get_revision(struct udevice *dev, char *buf, int size)
136 static inline int soc_get_family(struct udevice *dev, char *buf, int size)
141 static inline const struct soc_attr *
142 soc_device_match(const struct soc_attr *matches)