Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc64/sparc64 Move machine-specific fixes into se...



details:   https://anonhg.NetBSD.org/src/rev/be194c100f28
branches:  trunk
changeset: 1012136:be194c100f28
user:      jdc <jdc%NetBSD.org@localhost>
date:      Thu Jul 23 16:08:02 2020 +0000

description:
Move machine-specific fixes into separate functions to improve readability.

diffstat:

 sys/arch/sparc64/sparc64/autoconf.c |  200 ++++++++++++++++++-----------------
 1 files changed, 104 insertions(+), 96 deletions(-)

diffs (245 lines):

diff -r 849df6d70c0f -r be194c100f28 sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Thu Jul 23 15:24:37 2020 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Thu Jul 23 16:08:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $ */
+/*     $NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1111,6 +1111,101 @@
 }
 
 /*
+ * Add SPARCle spdmem devices (0x50 and 0x51) that are not in the OFW tree
+ */
+static void
+add_spdmem_props_sparcle(device_t busdev)
+{
+       prop_dictionary_t props = device_properties(busdev);
+       prop_array_t cfg = prop_array_create();
+       int i;
+
+       DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
+       for (i = 0x50; i <= 0x51; i++) {
+               prop_dictionary_t spd = prop_dictionary_create();
+               prop_dictionary_set_string(spd, "name", "dimm-spd");
+               prop_dictionary_set_uint32(spd, "addr", i);
+               prop_dictionary_set_uint64(spd, "cookie", 0);
+               prop_array_add(cfg, spd);
+               prop_object_release(spd);
+       }
+       prop_dictionary_set(props, "i2c-child-devices", cfg);
+       prop_object_release(cfg);
+}
+
+/*
+ * Add V210/V240 environmental sensors that are not in the OFW tree.
+ */
+static void
+add_env_sensors_v210(device_t busdev)
+{
+       prop_dictionary_t props = device_properties(busdev);
+       prop_array_t cfg = NULL;
+       prop_dictionary_t sens;
+       prop_data_t data;
+       const char name_lm[] = "i2c-lm75";
+       const char name_adm[] = "i2c-adm1026";
+
+       DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", machine_model));
+       cfg = prop_dictionary_get(props, "i2c-child-devices");
+       if (!cfg) {
+               cfg = prop_array_create();
+               prop_dictionary_set(props, "i2c-child-devices", cfg);
+               prop_dictionary_set_bool(props, "i2c-indirect-config", false);
+       }
+
+       /* ADM1026 at 0x2e */
+       sens = prop_dictionary_create();
+       prop_dictionary_set_uint32(sens, "addr", 0x2e);
+       prop_dictionary_set_uint64(sens, "cookie", 0);
+       prop_dictionary_set_string(sens, "name", "hardware-monitor");
+       data = prop_data_create_copy(&name_adm[0], sizeof(name_adm));
+       prop_dictionary_set(sens, "compatible", data);
+       prop_object_release(data);
+       prop_array_add(cfg, sens);
+       prop_object_release(sens);
+
+       /* LM75 at 0x4e */
+       sens = prop_dictionary_create();
+       prop_dictionary_set_uint32(sens, "addr", 0x4e);
+       prop_dictionary_set_uint64(sens, "cookie", 0);
+       prop_dictionary_set_string(sens, "name", "temperature-sensor");
+       data = prop_data_create_copy(&name_lm[0], sizeof(name_lm));
+       prop_dictionary_set(sens, "compatible", data);
+       prop_object_release(data);
+       prop_array_add(cfg, sens);
+       prop_object_release(sens);
+}
+
+/* Hardware specific device properties */
+static void
+set_hw_props(device_t dev)
+{
+       device_t busdev = device_parent(dev);
+
+       if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+           !strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
+               device_t busparent = device_parent(busdev);
+               prop_dictionary_t props = device_properties(dev);
+
+               if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+                   device_is_a(dev, "adm1026hm") && props != NULL) {
+                       prop_dictionary_set_uint8(props, "fan_div2", 0x55);
+                       prop_dictionary_set_bool(props, "multi_read", true);
+               }
+       }
+
+       if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) {
+               device_t busparent = device_parent(busdev);
+               prop_dictionary_t props = device_properties(dev);
+               if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+                   device_is_a(dev, "adm1026hm") && props != NULL) {
+                       prop_dictionary_set_bool(props, "multi_read", true);
+               }
+       }
+}
+
+/*
  * Called back during autoconfiguration for each device found
  */
 void
@@ -1155,7 +1250,8 @@
 
                ofnode = (int)ia->ia_cookie;
                if (device_is_a(dev, "pcagpio")) {
-                       if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
+                       if (!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+                           !strcmp(machine_model, "SUNW,Sun-Fire-V210")) {
                                add_gpio_props_v210(dev, aux);
                        }
                } 
@@ -1344,82 +1440,13 @@
                        }
                }
 
-               /*
-                * Add SPARCle spdmem devices (0x50 and 0x51) that the
-                * firmware does not know about.
-                */
-               if (!strcmp(machine_model, "TAD,SPARCLE")) {
-                       prop_dictionary_t props = device_properties(busdev);
-                       prop_array_t cfg = prop_array_create();
-                       int i;
+               if (!strcmp(machine_model, "TAD,SPARCLE"))
+                       add_spdmem_props_sparcle(busdev);
 
-                       DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
-                       for (i = 0x50; i <= 0x51; i++) {
-                               prop_dictionary_t spd =
-                                   prop_dictionary_create();
-                               prop_dictionary_set_string(spd, "name",
-                                   "dimm-spd");
-                               prop_dictionary_set_uint32(spd, "addr", i);
-                               prop_dictionary_set_uint64(spd, "cookie", 0);
-                               prop_array_add(cfg, spd);
-                               prop_object_release(spd);
-                       }
-                       prop_dictionary_set(props, "i2c-child-devices", cfg);
-                       prop_object_release(cfg);
-                       
-               }
-
-               /*
-                * Add V210/V240 environmental sensors that are not in
-                * the OFW tree.
-                */
                if (device_is_a(busdev, "pcfiic") &&
                    (!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
-                   !strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
-                       prop_dictionary_t props = device_properties(busdev);
-                       prop_array_t cfg = NULL;
-                       prop_dictionary_t sens;
-                       prop_data_t data;
-                       const char name_lm[] = "i2c-lm75";
-                       const char name_adm[] = "i2c-adm1026";
-
-                       DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ",
-                           machine_model));
-                       cfg = prop_dictionary_get(props, "i2c-child-devices");
-                       if (!cfg) {
-                               cfg = prop_array_create();
-                               prop_dictionary_set(props, "i2c-child-devices",
-                                   cfg);
-                               prop_dictionary_set_bool(props,
-                                   "i2c-no-indirect-config", true);
-                       }
-
-                       /* ADM1026 at 0x2e */
-                       sens = prop_dictionary_create();
-                       prop_dictionary_set_uint32(sens, "addr", 0x2e);
-                       prop_dictionary_set_uint64(sens, "cookie", 0);
-                       prop_dictionary_set_string(sens, "name",
-                           "hardware-monitor");
-                       data = prop_data_create_copy(&name_adm[0],
-                           sizeof(name_adm));
-                       prop_dictionary_set(sens, "compatible", data);
-                       prop_object_release(data);
-                       prop_array_add(cfg, sens);
-                       prop_object_release(sens);
-
-                       /* LM75 at 0x4e */
-                       sens = prop_dictionary_create();
-                       prop_dictionary_set_uint32(sens, "addr", 0x4e);
-                       prop_dictionary_set_uint64(sens, "cookie", 0);
-                       prop_dictionary_set_string(sens, "name",
-                           "temperature-sensor");
-                       data = prop_data_create_copy(&name_lm[0],
-                           sizeof(name_lm));
-                       prop_dictionary_set(sens, "compatible", data);
-                       prop_object_release(data);
-                       prop_array_add(cfg, sens);
-                       prop_object_release(sens);
-               }
+                   !strcmp(machine_model, "SUNW,Sun-Fire-V210")))
+                       add_env_sensors_v210(busdev);
        }
 
        /* set properties for PCI framebuffers */
@@ -1484,26 +1511,7 @@
 #endif
        }
 
-       /* Hardware specific device properties */
-       if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
-           !strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
-               device_t busparent = device_parent(busdev);
-               prop_dictionary_t props = device_properties(dev);
-
-               if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
-                   device_is_a(dev, "adm1026hm") && props != NULL) {
-                       prop_dictionary_set_uint8(props, "fan_div2", 0x55);
-                       prop_dictionary_set_bool(props, "multi_read", true);
-               }
-       }
-       if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) {
-               device_t busparent = device_parent(busdev);
-               prop_dictionary_t props = device_properties(dev);
-               if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
-                   device_is_a(dev, "adm1026hm") && props != NULL) {
-                       prop_dictionary_set_bool(props, "multi_read", true);
-               }
-       }
+       set_hw_props(dev);
 }
 
 /*



Home | Main Index | Thread Index | Old Index