]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
cpu: Add get_vendor callback
authorAlexander Graf <agraf@suse.de>
Thu, 18 Aug 2016 23:23:27 +0000 (01:23 +0200)
committerAlexander Graf <agraf@suse.de>
Wed, 19 Oct 2016 07:01:51 +0000 (09:01 +0200)
The CPU udevice already has a few callbacks to retreive information
about the currently running CPUs. This patch adds a new get_vendor()
call that returns the vendor of the main CPUs.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
arch/x86/cpu/baytrail/cpu.c
arch/x86/cpu/broadwell/cpu.c
arch/x86/cpu/cpu_x86.c
arch/x86/cpu/ivybridge/model_206ax.c
arch/x86/include/asm/cpu_x86.h
drivers/cpu/cpu-uclass.c
include/cpu.h

index 2837709d6d14abd5f8094a1428070c10c43a6967..0bb08524f8df4a5d668a0b03ea0183da22192087 100644 (file)
@@ -189,6 +189,7 @@ static const struct cpu_ops cpu_x86_baytrail_ops = {
        .get_desc       = cpu_x86_get_desc,
        .get_info       = baytrail_get_info,
        .get_count      = baytrail_get_count,
+       .get_vendor     = cpu_x86_get_vendor,
 };
 
 static const struct udevice_id cpu_x86_baytrail_ids[] = {
index 3ba21aacecd2f2519b758a6f53c4f77866cbafb0..6977e860321fa3d83187c45ff41f7f1c75c8b99f 100644 (file)
@@ -743,6 +743,7 @@ static const struct cpu_ops cpu_x86_broadwell_ops = {
        .get_desc       = cpu_x86_get_desc,
        .get_info       = broadwell_get_info,
        .get_count      = broadwell_get_count,
+       .get_vendor     = cpu_x86_get_vendor,
 };
 
 static const struct udevice_id cpu_x86_broadwell_ids[] = {
index 39004ee5f0f5f889362b440444abdc9a43171440..157f3de6d81e00dbd2f2e3651157fd84d389dbe1 100644 (file)
@@ -27,6 +27,18 @@ int cpu_x86_bind(struct udevice *dev)
        return 0;
 }
 
+int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size)
+{
+       const char *vendor = cpu_vendor_name(gd->arch.x86_vendor);
+
+       if (size < (strlen(vendor) + 1))
+               return -ENOSPC;
+
+       strcpy(buf, vendor);
+
+       return 0;
+}
+
 int cpu_x86_get_desc(struct udevice *dev, char *buf, int size)
 {
        if (size < CPU_MAX_NAME_LEN)
@@ -65,6 +77,7 @@ static int cpu_x86_get_count(struct udevice *dev)
 static const struct cpu_ops cpu_x86_ops = {
        .get_desc       = cpu_x86_get_desc,
        .get_count      = cpu_x86_get_count,
+       .get_vendor     = cpu_x86_get_vendor,
 };
 
 static const struct udevice_id cpu_x86_ids[] = {
index b0743674ffe4dac9b81eb19b3a33d7dca31c63cb..09b534255ca0cffb1431a53fe2af3f6a26e5e28a 100644 (file)
@@ -477,6 +477,7 @@ static const struct cpu_ops cpu_x86_model_206ax_ops = {
        .get_desc       = cpu_x86_get_desc,
        .get_info       = model_206ax_get_info,
        .get_count      = model_206ax_get_count,
+       .get_vendor     = cpu_x86_get_vendor,
 };
 
 static const struct udevice_id cpu_x86_model_206ax_ids[] = {
index 19404805c51328f6aaeb2933d59e87e788b3fa76..74b82edceb2c05cf09132aae3975cb2e9d6a56de 100644 (file)
@@ -31,4 +31,17 @@ int cpu_x86_bind(struct udevice *dev);
  */
 int cpu_x86_get_desc(struct udevice *dev, char *buf, int size);
 
+/**
+ * cpu_x86_get_vendor() - Get a vendor string for an x86 CPU
+ *
+ * This uses cpu_vendor_name() and is suitable to use as the get_vendor()
+ * method for the CPU uclass.
+ *
+ * @dev:       Device to check (UCLASS_CPU)
+ * @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 cpu_x86_get_vendor(struct udevice *dev, char *buf, int size);
+
 #endif /* _ASM_CPU_X86_H */
index 7660f99ef5956804685b6cd7b3789fa1b99a82fc..c57ac16b3a7ed797f6533c6ab4f73e0a3be7e5db 100644 (file)
@@ -44,6 +44,16 @@ int cpu_get_count(struct udevice *dev)
        return ops->get_count(dev);
 }
 
+int cpu_get_vendor(struct udevice *dev, char *buf, int size)
+{
+       struct cpu_ops *ops = cpu_get_ops(dev);
+
+       if (!ops->get_vendor)
+               return -ENOSYS;
+
+       return ops->get_vendor(dev, buf, size);
+}
+
 U_BOOT_DRIVER(cpu_bus) = {
        .name   = "cpu_bus",
        .id     = UCLASS_SIMPLE_BUS,
index 7d4486bbf3394c3ecb0adfdd80549419268c1071..954257715a4197dab2d999324af020cf7c2c7d4a 100644 (file)
@@ -73,6 +73,16 @@ struct cpu_ops {
         * @return CPU count if OK, -ve on error
         */
        int (*get_count)(struct udevice *dev);
+
+       /**
+        * get_vendor() - Get vendor name of a CPU
+        *
+        * @dev:        Device to check (UCLASS_CPU)
+        * @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_vendor)(struct udevice *dev, char *buf, int size);
 };
 
 #define cpu_get_ops(dev)        ((struct cpu_ops *)(dev)->driver->ops)
@@ -104,4 +114,14 @@ int cpu_get_info(struct udevice *dev, struct cpu_info *info);
  */
 int cpu_get_count(struct udevice *dev);
 
+/**
+ * cpu_get_vendor() - Get vendor name of a CPU
+ *
+ * @dev:       Device to check (UCLASS_CPU)
+ * @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 cpu_get_vendor(struct udevice *dev, char *buf, int size);
+
 #endif