Hi,
how should/could this be done?
if bindings like "netbsd,..." are unwanted, i'll just hardcode and be
done with this, np. :]
use-case example called from _attach() below, see /* XXX .. */.
-Artturi
/*
* node examples for i2c controllers in DT:
* pressure@76 {
* compatible = "bosch,bme280";
* reg = <0x76>;
* netbsd,bmx-forced = < 0x01 >;
* netbsd,bmx-period = < 0x08 >;
* netbsd,bmx-standby = < 0x3d090 >;
* netbsd,bmx-oversample-temp = < 0x01 >;
* netbsd,bmx-oversample-pres = < 0x00 >;
* netbsd,bmx-oversample-humi = < 0x01 >;
* };
* pressure@77 {
* compatible = "bosch,bmp280";
* reg = <0x77>;
* netbsd,bmx-period = < 0x04 >;
* netbsd,bmx-standby = < 0x3d0900 >;
* netbsd,bmx-oversample-temp = < 0x01 >;
* netbsd,bmx-oversample-pres = < 0x01 >;
* };
*/
void
bmx_getconfig(struct bmx_softc *sc)
{
int ph = sc->sc_node;
/* XXX OF_getpropint ... */
#define OF_getpropint(x,y,z) ((z)) /* XXX replace with ? z == default */
int forced = OF_getpropint(ph, "netbsd,bmx-forced", 0);
int period = OF_getpropint(ph, "netbsd,bmx-period", 1);
uint32_t iirfilt = OF_getpropint(ph, "netbsd,bmx-filter", 0);
uint32_t standby = OF_getpropint(ph, "netbsd,bmx-standby", 1000000);
uint32_t os_temp = OF_getpropint(ph, "netbsd,bmx-oversample-temp", 1);
uint32_t os_pres = OF_getpropint(ph, "netbsd,bmx-oversample-pres", 1);
uint32_t os_humi = OF_getpropint(ph, "netbsd,bmx-oversample-humi", 1);
sc->sc_node = ph; /* because __unused for now.. */
if (sc->sc_state & BMX_S_GOTPARAMS)
return;
sc->sc_state |= BMX_S_GOTPARAMS;
sc->sc_mode =
forced ? BMX280_CTRL_MEAS_FORCED : BMX280_CTRL_MEAS_NORMAL;
iirfilt = bmx_config_filter(iirfilt);
standby = bmx_config_standby(standby, BMX_W_HUMI(sc));
sc->sc_config[0] = iirfilt | standby;
os_humi = bmx_oversample(os_humi, BMX_HUMI);
sc->sc_config[1] = os_humi;
os_temp = bmx_oversample(os_temp, BMX_TEMP);
os_pres = bmx_oversample(os_pres, BMX_PRES);
sc->sc_config[2] = os_temp | os_pres;
}