From e2f198273cb2d837f3354cfd8ff2bc84a24c2447 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Mon, 26 Apr 2010 19:13:10 +0000 Subject: [PATCH] Add OF_getscsinitid(), a helper similar to OF_getetheraddr() but for obtaining the initiator ID to be used for SPI controllers from the Open Firmware device tree. --- sys/sparc64/include/ofw_machdep.h | 1 + sys/sparc64/sparc64/ofw_machdep.c | 15 ++++++++++++++- sys/sun4v/include/ofw_machdep.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/sys/sparc64/include/ofw_machdep.h b/sys/sparc64/include/ofw_machdep.h index 625b13137adc..658d9c7b0d25 100644 --- a/sys/sparc64/include/ofw_machdep.h +++ b/sys/sparc64/include/ofw_machdep.h @@ -36,6 +36,7 @@ typedef uint64_t cell_t; int OF_decode_addr(phandle_t, int, int *, bus_addr_t *); void OF_getetheraddr(device_t, u_char *); +u_int OF_getscsinitid(device_t); void cpu_shutdown(void *); int ofw_entry(void *); void ofw_exit(void *); diff --git a/sys/sparc64/sparc64/ofw_machdep.c b/sys/sparc64/sparc64/ofw_machdep.c index 07f95e20e511..88ee07267254 100644 --- a/sys/sparc64/sparc64/ofw_machdep.c +++ b/sys/sparc64/sparc64/ofw_machdep.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2001 by Thomas Moestl . - * Copyright (c) 2005 - 2009 by Marius Strobl . + * Copyright (c) 2005 - 2010 by Marius Strobl . * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,6 +68,19 @@ OF_getetheraddr(device_t dev, u_char *addr) bcopy(&idp.id_ether, addr, ETHER_ADDR_LEN); } +u_int +OF_getscsinitid(device_t dev) +{ + phandle_t node; + uint32_t id; + + for (node = ofw_bus_get_node(dev); node != 0; node = OF_parent(node)) + if (OF_getprop(node, "scsi-initiator-id", &id, + sizeof(id)) > 0) + return (id); + return (7); +} + static __inline uint32_t phys_hi_mask_space(const char *bus, uint32_t phys_hi) { diff --git a/sys/sun4v/include/ofw_machdep.h b/sys/sun4v/include/ofw_machdep.h index 625b13137adc..658d9c7b0d25 100644 --- a/sys/sun4v/include/ofw_machdep.h +++ b/sys/sun4v/include/ofw_machdep.h @@ -36,6 +36,7 @@ typedef uint64_t cell_t; int OF_decode_addr(phandle_t, int, int *, bus_addr_t *); void OF_getetheraddr(device_t, u_char *); +u_int OF_getscsinitid(device_t); void cpu_shutdown(void *); int ofw_entry(void *); void ofw_exit(void *);