Sun Jul 5 09:27:11 2020 UTC ()
Adapt to proplib api changes


(martin)
diff -r1.219 -r1.220 src/sys/arch/sparc64/sparc64/autoconf.c

cvs diff -r1.219 -r1.220 src/sys/arch/sparc64/sparc64/autoconf.c (expand / switch to unified diff)

--- src/sys/arch/sparc64/sparc64/autoconf.c 2020/06/12 03:32:30 1.219
+++ src/sys/arch/sparc64/sparc64/autoconf.c 2020/07/05 09:27:11 1.220
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: autoconf.c,v 1.219 2020/06/12 03:32:30 thorpej Exp $ */ 1/* $NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 4 * Copyright (c) 1996
5 * The President and Fellows of Harvard College. All rights reserved. 5 * The President and Fellows of Harvard College. All rights reserved.
6 * Copyright (c) 1992, 1993 6 * Copyright (c) 1992, 1993
7 * The Regents of the University of California. All rights reserved. 7 * The Regents of the University of California. All rights reserved.
8 * 8 *
9 * This software was developed by the Computer Systems Engineering group 9 * This software was developed by the Computer Systems Engineering group
10 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 10 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
11 * contributed to Berkeley. 11 * contributed to Berkeley.
12 * 12 *
13 * All advertising materials mentioning features or use of this software 13 * All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement: 14 * must display the following acknowledgement:
@@ -38,27 +38,27 @@ @@ -38,27 +38,27 @@
38 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 38 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 40 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 41 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 43 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 * SUCH DAMAGE. 45 * SUCH DAMAGE.
46 * 46 *
47 * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 47 * @(#)autoconf.c 8.4 (Berkeley) 10/1/93
48 */ 48 */
49 49
50#include <sys/cdefs.h> 50#include <sys/cdefs.h>
51__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.219 2020/06/12 03:32:30 thorpej Exp $"); 51__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $");
52 52
53#include "opt_ddb.h" 53#include "opt_ddb.h"
54#include "opt_kgdb.h" 54#include "opt_kgdb.h"
55#include "opt_modular.h" 55#include "opt_modular.h"
56#include "opt_multiprocessor.h" 56#include "opt_multiprocessor.h"
57 57
58#include <sys/param.h> 58#include <sys/param.h>
59#include <sys/kernel.h> 59#include <sys/kernel.h>
60#include <sys/systm.h> 60#include <sys/systm.h>
61#include <sys/buf.h> 61#include <sys/buf.h>
62#include <sys/disklabel.h> 62#include <sys/disklabel.h>
63#include <sys/device.h> 63#include <sys/device.h>
64#include <sys/disk.h> 64#include <sys/disk.h>
@@ -1040,27 +1040,27 @@ device_setofnode(device_t dev, int node) @@ -1040,27 +1040,27 @@ device_setofnode(device_t dev, int node)
1040 obj = prop_number_create_signed(node); 1040 obj = prop_number_create_signed(node);
1041 if (obj == NULL) 1041 if (obj == NULL)
1042 return; 1042 return;
1043 prop_dictionary_set(props, OFNODEKEY, obj); 1043 prop_dictionary_set(props, OFNODEKEY, obj);
1044 prop_object_release(obj); 1044 prop_object_release(obj);
1045 DPRINTF(ACDB_BOOTDEV, (" [device %s has node %x] ", 1045 DPRINTF(ACDB_BOOTDEV, (" [device %s has node %x] ",
1046 device_xname(dev), node)); 1046 device_xname(dev), node));
1047} 1047}
1048 1048
1049static void 1049static void
1050add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def) 1050add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def)
1051{ 1051{
1052 prop_dictionary_t pin = prop_dictionary_create(); 1052 prop_dictionary_t pin = prop_dictionary_create();
1053 prop_dictionary_set_cstring(pin, "name", name); 1053 prop_dictionary_set_string(pin, "name", name);
1054 prop_dictionary_set_uint32(pin, "type", 0); /* 0 for LED, for now */ 1054 prop_dictionary_set_uint32(pin, "type", 0); /* 0 for LED, for now */
1055 prop_dictionary_set_uint32(pin, "pin", num); 1055 prop_dictionary_set_uint32(pin, "pin", num);
1056 prop_dictionary_set_bool(pin, "active_high", act); 1056 prop_dictionary_set_bool(pin, "active_high", act);
1057 if (def != -1) 1057 if (def != -1)
1058 prop_dictionary_set_int32(pin, "default_state", def); 1058 prop_dictionary_set_int32(pin, "default_state", def);
1059 prop_array_add(pins, pin); 1059 prop_array_add(pins, pin);
1060 prop_object_release(pin); 1060 prop_object_release(pin);
1061} 1061}
1062  1062
1063static void 1063static void
1064add_gpio_props_v210(device_t dev, void *aux) 1064add_gpio_props_v210(device_t dev, void *aux)
1065{ 1065{
1066 struct i2c_attach_args *ia = aux; 1066 struct i2c_attach_args *ia = aux;
@@ -1096,27 +1096,27 @@ add_drivebay_props_v210(device_t dev, in @@ -1096,27 +1096,27 @@ add_drivebay_props_v210(device_t dev, in
1096 char path[256]= ""; 1096 char path[256]= "";
1097 1097
1098 OF_package_to_path(ofnode, path, sizeof(path)); 1098 OF_package_to_path(ofnode, path, sizeof(path));
1099 1099
1100 /* see if we're on the onboard controller's 1st channel */ 1100 /* see if we're on the onboard controller's 1st channel */
1101 if (strcmp(path, "/pci@1c,600000/scsi@2") != 0) 1101 if (strcmp(path, "/pci@1c,600000/scsi@2") != 0)
1102 return; 1102 return;
1103 /* yes, yes we are */ 1103 /* yes, yes we are */
1104 if ( target < 2) { 1104 if ( target < 2) {
1105 prop_dictionary_t dict = device_properties(dev); 1105 prop_dictionary_t dict = device_properties(dev);
1106 char name[16]; 1106 char name[16];
1107 1107
1108 snprintf(name, sizeof(name), "bay%d", target);  1108 snprintf(name, sizeof(name), "bay%d", target);
1109 prop_dictionary_set_cstring(dict, "location", name); 1109 prop_dictionary_set_string(dict, "location", name);
1110 } 1110 }
1111} 1111}
1112 1112
1113/* 1113/*
1114 * Called back during autoconfiguration for each device found 1114 * Called back during autoconfiguration for each device found
1115 */ 1115 */
1116void 1116void
1117device_register(device_t dev, void *aux) 1117device_register(device_t dev, void *aux)
1118{ 1118{
1119 device_t busdev = device_parent(dev); 1119 device_t busdev = device_parent(dev);
1120 int ofnode = 0; 1120 int ofnode = 0;
1121 1121
1122 /* 1122 /*
@@ -1248,27 +1248,27 @@ device_register(device_t dev, void *aux) @@ -1248,27 +1248,27 @@ device_register(device_t dev, void *aux)
1248 1248
1249 /* 1249 /*
1250 * Is it a network interface with FCode? 1250 * Is it a network interface with FCode?
1251 */ 1251 */
1252 if (strcmp(tmpstr, "network") == 0 || 1252 if (strcmp(tmpstr, "network") == 0 ||
1253 strcmp(tmpstr2, "network") == 0) { 1253 strcmp(tmpstr2, "network") == 0) {
1254 prop_dictionary_set_bool(dict, 1254 prop_dictionary_set_bool(dict,
1255 "without-seeprom", true); 1255 "without-seeprom", true);
1256 prom_getether(ofnode, eaddr); 1256 prom_getether(ofnode, eaddr);
1257 } else { 1257 } else {
1258 if (!prom_get_node_ether(ofnode, eaddr)) 1258 if (!prom_get_node_ether(ofnode, eaddr))
1259 goto noether; 1259 goto noether;
1260 } 1260 }
1261 blob = prop_data_create_data(eaddr, ETHER_ADDR_LEN); 1261 blob = prop_data_create_copy(eaddr, ETHER_ADDR_LEN);
1262 prop_dictionary_set(dict, "mac-address", blob); 1262 prop_dictionary_set(dict, "mac-address", blob);
1263 prop_object_release(blob); 1263 prop_object_release(blob);
1264 of_to_dataprop(dict, ofnode, "shared-pins", 1264 of_to_dataprop(dict, ofnode, "shared-pins",
1265 "shared-pins"); 1265 "shared-pins");
1266 } 1266 }
1267noether: 1267noether:
1268 1268
1269 /* is this a FC node? */ 1269 /* is this a FC node? */
1270 if (strcmp(tmpstr, "scsi-fcp") == 0) { 1270 if (strcmp(tmpstr, "scsi-fcp") == 0) {
1271 1271
1272 dict = device_properties(dev); 1272 dict = device_properties(dev);
1273 1273
1274 if (OF_getprop(ofnode, "port-wwn", &pwwn, sizeof(pwwn)) 1274 if (OF_getprop(ofnode, "port-wwn", &pwwn, sizeof(pwwn))
@@ -1347,27 +1347,27 @@ noether: @@ -1347,27 +1347,27 @@ noether:
1347 /* 1347 /*
1348 * Add SPARCle spdmem devices (0x50 and 0x51) that the 1348 * Add SPARCle spdmem devices (0x50 and 0x51) that the
1349 * firmware does not know about. 1349 * firmware does not know about.
1350 */ 1350 */
1351 if (!strcmp(machine_model, "TAD,SPARCLE")) { 1351 if (!strcmp(machine_model, "TAD,SPARCLE")) {
1352 prop_dictionary_t props = device_properties(busdev); 1352 prop_dictionary_t props = device_properties(busdev);
1353 prop_array_t cfg = prop_array_create(); 1353 prop_array_t cfg = prop_array_create();
1354 int i; 1354 int i;
1355 1355
1356 DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle ")); 1356 DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
1357 for (i = 0x50; i <= 0x51; i++) { 1357 for (i = 0x50; i <= 0x51; i++) {
1358 prop_dictionary_t spd = 1358 prop_dictionary_t spd =
1359 prop_dictionary_create(); 1359 prop_dictionary_create();
1360 prop_dictionary_set_cstring(spd, "name", 1360 prop_dictionary_set_string(spd, "name",
1361 "dimm-spd"); 1361 "dimm-spd");
1362 prop_dictionary_set_uint32(spd, "addr", i); 1362 prop_dictionary_set_uint32(spd, "addr", i);
1363 prop_dictionary_set_uint64(spd, "cookie", 0); 1363 prop_dictionary_set_uint64(spd, "cookie", 0);
1364 prop_array_add(cfg, spd); 1364 prop_array_add(cfg, spd);
1365 prop_object_release(spd); 1365 prop_object_release(spd);
1366 } 1366 }
1367 prop_dictionary_set(props, "i2c-child-devices", cfg); 1367 prop_dictionary_set(props, "i2c-child-devices", cfg);
1368 prop_object_release(cfg); 1368 prop_object_release(cfg);
1369  1369
1370 } 1370 }
1371 1371
1372 /* 1372 /*
1373 * Add V210/V240 environmental sensors that are not in 1373 * Add V210/V240 environmental sensors that are not in
@@ -1388,40 +1388,40 @@ noether: @@ -1388,40 +1388,40 @@ noether:
1388 cfg = prop_dictionary_get(props, "i2c-child-devices"); 1388 cfg = prop_dictionary_get(props, "i2c-child-devices");
1389 if (!cfg) { 1389 if (!cfg) {
1390 cfg = prop_array_create(); 1390 cfg = prop_array_create();
1391 prop_dictionary_set(props, "i2c-child-devices", 1391 prop_dictionary_set(props, "i2c-child-devices",
1392 cfg); 1392 cfg);
1393 prop_dictionary_set_bool(props, 1393 prop_dictionary_set_bool(props,
1394 "i2c-no-indirect-config", true); 1394 "i2c-no-indirect-config", true);
1395 } 1395 }
1396 1396
1397 /* ADM1026 at 0x2e */ 1397 /* ADM1026 at 0x2e */
1398 sens = prop_dictionary_create(); 1398 sens = prop_dictionary_create();
1399 prop_dictionary_set_uint32(sens, "addr", 0x2e); 1399 prop_dictionary_set_uint32(sens, "addr", 0x2e);
1400 prop_dictionary_set_uint64(sens, "cookie", 0); 1400 prop_dictionary_set_uint64(sens, "cookie", 0);
1401 prop_dictionary_set_cstring(sens, "name", 1401 prop_dictionary_set_string(sens, "name",
1402 "hardware-monitor"); 1402 "hardware-monitor");
1403 data = prop_data_create_data(&name_adm[0], 1403 data = prop_data_create_copy(&name_adm[0],
1404 sizeof(name_adm)); 1404 sizeof(name_adm));
1405 prop_dictionary_set(sens, "compatible", data); 1405 prop_dictionary_set(sens, "compatible", data);
1406 prop_object_release(data); 1406 prop_object_release(data);
1407 prop_array_add(cfg, sens); 1407 prop_array_add(cfg, sens);
1408 prop_object_release(sens); 1408 prop_object_release(sens);
1409 1409
1410 /* LM75 at 0x4e */ 1410 /* LM75 at 0x4e */
1411 sens = prop_dictionary_create(); 1411 sens = prop_dictionary_create();
1412 prop_dictionary_set_uint32(sens, "addr", 0x4e); 1412 prop_dictionary_set_uint32(sens, "addr", 0x4e);
1413 prop_dictionary_set_uint64(sens, "cookie", 0); 1413 prop_dictionary_set_uint64(sens, "cookie", 0);
1414 prop_dictionary_set_cstring(sens, "name", 1414 prop_dictionary_set_string(sens, "name",
1415 "temperature-sensor"); 1415 "temperature-sensor");
1416 data = prop_data_create_data(&name_lm[0], 1416 data = prop_data_create_data(&name_lm[0],
1417 sizeof(name_lm)); 1417 sizeof(name_lm));
1418 prop_dictionary_set(sens, "compatible", data); 1418 prop_dictionary_set(sens, "compatible", data);
1419 prop_object_release(data); 1419 prop_object_release(data);
1420 prop_array_add(cfg, sens); 1420 prop_array_add(cfg, sens);
1421 prop_object_release(sens); 1421 prop_object_release(sens);
1422 } 1422 }
1423 } 1423 }
1424 1424
1425 /* set properties for PCI framebuffers */ 1425 /* set properties for PCI framebuffers */
1426 if (device_is_a(busdev, "pci")) { 1426 if (device_is_a(busdev, "pci")) {
1427 /* see if this is going to be console */ 1427 /* see if this is going to be console */
@@ -1659,23 +1659,23 @@ copyprops(device_t busdev, int node, pro @@ -1659,23 +1659,23 @@ copyprops(device_t busdev, int node, pro
1659 1659
1660 if (!is_console) 1660 if (!is_console)
1661 return; 1661 return;
1662 1662
1663 options = OF_finddevice("/options"); 1663 options = OF_finddevice("/options");
1664 if ((options == 0) || (options == -1)) 1664 if ((options == 0) || (options == -1))
1665 return; 1665 return;
1666 if (OF_getprop(options, "output-device", output_device, OFPATHLEN) == 0) 1666 if (OF_getprop(options, "output-device", output_device, OFPATHLEN) == 0)
1667 return; 1667 return;
1668 /* find the mode string if there is one */ 1668 /* find the mode string if there is one */
1669 pos = strstr(output_device, ":r"); 1669 pos = strstr(output_device, ":r");
1670 if (pos == NULL) 1670 if (pos == NULL)
1671 return; 1671 return;
1672 prop_dictionary_set_cstring(dict, "videomode", pos + 2); 1672 prop_dictionary_set_string(dict, "videomode", pos + 2);
1673} 1673}
1674 1674
1675static void 1675static void
1676of_set_palette(void *cookie, int index, int r, int g, int b) 1676of_set_palette(void *cookie, int index, int r, int g, int b)
1677{ 1677{
1678 int ih = (int)((intptr_t)cookie); 1678 int ih = (int)((intptr_t)cookie);
1679 1679
1680 OF_call_method_1("color!", ih, 4, r, g, b, index); 1680 OF_call_method_1("color!", ih, 4, r, g, b, index);
1681} 1681}