diff options
author | 2019-09-07 13:29:08 +0000 | |
---|---|---|
committer | 2019-09-07 13:29:08 +0000 | |
commit | 5296b96a337c9e135a507b51f8b0d745910c671d (patch) | |
tree | 74dae66d1d89353864ad1f88e3e2cddcc3224f4a /sys | |
parent | Register mviic(4) in the I2C framework. (diff) | |
download | wireguard-openbsd-5296b96a337c9e135a507b51f8b0d745910c671d.tar.xz wireguard-openbsd-5296b96a337c9e135a507b51f8b0d745910c671d.zip |
Add an SFP framework which allows SFP providers to provide a
method to access its pages.
ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ofw/ofw_misc.c | 32 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_misc.h | 18 |
2 files changed, 48 insertions, 2 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; +} diff --git a/sys/dev/ofw/ofw_misc.h b/sys/dev/ofw/ofw_misc.h index c97e04f0b48..7a572dbd7d5 100644 --- a/sys/dev/ofw/ofw_misc.h +++ b/sys/dev/ofw/ofw_misc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_misc.h,v 1.5 2019/09/07 13:27:23 patrick Exp $ */ +/* $OpenBSD: ofw_misc.h,v 1.6 2019/09/07 13:29:08 patrick Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -70,4 +70,20 @@ void i2c_register(struct i2c_bus *); struct i2c_controller *i2c_bynode(int); struct i2c_controller *i2c_byphandle(uint32_t); +/* SFP support */ + +struct if_sffpage; +struct sfp_device { + int sd_node; + void *sd_cookie; + int (*sd_get_sffpage)(void *, struct if_sffpage *); + + LIST_ENTRY(sfp_device) sd_list; + uint32_t sd_phandle; +}; + +void sfp_register(struct sfp_device *); + +int sfp_get_sffpage(uint32_t, struct if_sffpage *); + #endif /* _DEV_OFW_MISC_H_ */ |