diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2019-09-07 13:29:09 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2019-09-07 13:29:09 +0000 |
commit | 899512ab5713f678d9d9d477fdf0ff11b185e85c (patch) | |
tree | 4be4a7bf5788267aef3dc3375a1d659189f37a2a /sys/dev/ofw/ofw_misc.c | |
parent | e316a30450b49aae38824207b0724e527b5ff6ab (diff) |
Add an SFP framework which allows SFP providers to provide a
method to access its pages.
ok kettenis@
Diffstat (limited to 'sys/dev/ofw/ofw_misc.c')
-rw-r--r-- | sys/dev/ofw/ofw_misc.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/sys/dev/ofw/ofw_misc.c b/sys/dev/ofw/ofw_misc.c index b988d3b0789..4f4a781a924 100644 --- a/sys/dev/ofw/ofw_misc.c +++ b/sys/dev/ofw/ofw_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_misc.c,v 1.8 2019/09/07 13:27:23 patrick Exp $ */ +/* $OpenBSD: ofw_misc.c,v 1.9 2019/09/07 13:29:08 patrick Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -241,3 +241,33 @@ i2c_byphandle(uint32_t phandle) return NULL; } + +/* + * SFP support. + */ + +LIST_HEAD(, sfp_device) sfp_devices = + LIST_HEAD_INITIALIZER(sfp_devices); + +void +sfp_register(struct sfp_device *sd) +{ + sd->sd_phandle = OF_getpropint(sd->sd_node, "phandle", 0); + if (sd->sd_phandle == 0) + return; + + LIST_INSERT_HEAD(&sfp_devices, sd, sd_list); +} + +int +sfp_get_sffpage(uint32_t phandle, struct if_sffpage *sff) +{ + struct sfp_device *sd; + + LIST_FOREACH(sd, &sfp_devices, sd_list) { + if (sd->sd_phandle == phandle) + return sd->sd_get_sffpage(sd->sd_cookie, sff); + } + + return ENXIO; +} |