> Date: Mon, 22 Mar 2021 17:48:56 +0100 > From: Klemens Nanni <[email protected]> > > Using our dtb package's blobs cwfg(4) won't attach on the Pinebook Pro > since linux changed it: > > https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/power/supply/cw2015_battery.yaml > > Thanks to kettenis and patrick for pointing this out. > > This diff makes the sensor attach again and both hw.sensors as well as > apm (with the other diff) show correct values. > > > NB: This used to work without this diff with whatever blob was on the > machine when it came to me; it broke after I updated/replaced it with > /usr/local/share/dtb/arm64/rockchip/rk3399-pinebook-pro.dtb . > > Feedback? OK? > > Index: cwfg.c > =================================================================== > RCS file: /cvs/src/sys/dev/fdt/cwfg.c,v > retrieving revision 1.1 > diff -u -p -r1.1 cwfg.c > --- cwfg.c 10 Jun 2020 17:51:21 -0000 1.1 > +++ cwfg.c 22 Mar 2021 16:37:17 -0000 > @@ -124,7 +124,7 @@ cwfg_match(struct device *parent, void * > { > struct i2c_attach_args *ia = aux; > > - if (strcmp(ia->ia_name, "cellwise,cw201x") == 0) > + if (strcmp(ia->ia_name, "cellwise,cw2015") == 0) > return 1; > > return 0; > @@ -143,14 +143,14 @@ cwfg_attach(struct device *parent, struc > sc->sc_addr = ia->ia_addr; > sc->sc_node = *(int *)ia->ia_cookie; > > - len = OF_getproplen(sc->sc_node, "cellwise,bat-config-info"); > + len = OF_getproplen(sc->sc_node, "cellwise,battery-profile"); > if (len <= 0) { > printf(": missing or invalid battery info\n"); > return; > } > > batinfo = malloc(len, M_TEMP, M_WAITOK); > - OF_getprop(sc->sc_node, "cellwise,bat-config-info", batinfo, len); > + OF_getprop(sc->sc_node, "cellwise,battery-profile", batinfo, len); > switch (len) { > case BATINFO_SIZE: > memcpy(sc->sc_batinfo, batinfo, BATINFO_SIZE) > @@ -167,7 +167,7 @@ cwfg_attach(struct device *parent, struc > free(batinfo, M_TEMP, len); > > sc->sc_monitor_interval = OF_getpropint(sc->sc_node, > - "cellwise,monitor-interval", CWFG_MONITOR_INTERVAL_DEFAULT); > + "cellwise,monitor-interval-ms", CWFG_MONITOR_INTERVAL_DEFAULT);
I think the old property specified the interval in seconds. So you should adjust the default value as well. The minimum allowed value is 250 so the current 8 makes no sense. You could make it 8000, but maybe using 5000 is better as this is whatis used for the pinebook pro. > sc->sc_design_capacity = OF_getpropint(sc->sc_node, > "cellwise,design-capacity", CWFG_DESIGN_CAPACITY_DEFAULT); > sc->sc_alert_level = OF_getpropint(sc->sc_node, > >
