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 | |
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')
-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_ */ |