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
13 * struct soc_attr - Contains SoC identify information to be used in
14 * SoC matching. An array of these structs
15 * representing different SoCs can be passed to
16 * soc_device_match and the struct matching the SoC
17 * in use will be returned.
19 * @family - Name of SoC family that can include multiple related SoC
20 * variants. Example: am33
21 * @machine - Name of a specific SoC. Example: am3352
22 * @revision - Name of a specific SoC revision. Example: SR1.1
23 * @data - A pointer to user data for the SoC variant
34 * get_machine() - Get machine name of an SOC
36 * @dev: Device to check (UCLASS_SOC)
37 * @buf: Buffer to place string
38 * @size: Size of string space
39 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
41 int (*get_machine)(struct udevice *dev, char *buf, int size);
44 * get_revision() - Get revision name of a SOC
46 * @dev: Device to check (UCLASS_SOC)
47 * @buf: Buffer to place string
48 * @size: Size of string space
49 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
51 int (*get_revision)(struct udevice *dev, char *buf, int size);
54 * get_family() - Get family name of an SOC
56 * @dev: Device to check (UCLASS_SOC)
57 * @buf: Buffer to place string
58 * @size: Size of string space
59 * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error
61 int (*get_family)(struct udevice *dev, char *buf, int size);
64 #define soc_get_ops(dev) ((struct soc_ops *)(dev)->driver->ops)
66 #ifdef CONFIG_SOC_DEVICE
68 * soc_get() - Return the soc device for the soc in use.
69 * @devp: Pointer to structure to receive the soc device.
71 * Since there can only be at most one SOC instance, the API can supply a
72 * function that returns the unique device.
74 * Return: 0 if OK, -ve on error.
76 int soc_get(struct udevice **devp);
79 * soc_get_machine() - Get machine name of an SOC
80 * @dev: Device to check (UCLASS_SOC)
81 * @buf: Buffer to place string
82 * @size: Size of string space
84 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
86 int soc_get_machine(struct udevice *dev, char *buf, int size);
89 * soc_get_revision() - Get revision name of an SOC
90 * @dev: Device to check (UCLASS_SOC)
91 * @buf: Buffer to place string
92 * @size: Size of string space
94 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
96 int soc_get_revision(struct udevice *dev, char *buf, int size);
99 * soc_get_family() - Get family name of an SOC
100 * @dev: Device to check (UCLASS_SOC)
101 * @buf: Buffer to place string
102 * @size: Size of string space
104 * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error
106 int soc_get_family(struct udevice *dev, char *buf, int size);
109 * soc_device_match() - Return match from an array of soc_attr
110 * @matches: Array with any combination of family, revision or machine set
112 * Return: Pointer to struct from matches array with set attributes matching
113 * those provided by the soc device, or NULL if no match found.
115 const struct soc_attr *
116 soc_device_match(const struct soc_attr *matches);
119 static inline int soc_get(struct udevice **devp)
124 static inline int soc_get_machine(struct udevice *dev, char *buf, int size)
129 static inline int soc_get_revision(struct udevice *dev, char *buf, int size)
134 static inline int soc_get_family(struct udevice *dev, char *buf, int size)
139 static inline const struct soc_attr *
140 soc_device_match(const struct soc_attr *matches)