Changeset View
Standalone View
sys/arm64/rockchip/rk805.c
Show All 25 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/clock.h> | #include <sys/clock.h> | ||||
#include <sys/eventhandler.h> | |||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/reboot.h> | |||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <dev/iicbus/iiconf.h> | #include <dev/iicbus/iiconf.h> | ||||
#include <dev/iicbus/iicbus.h> | #include <dev/iicbus/iicbus.h> | ||||
#include <dev/ofw/ofw_bus.h> | #include <dev/ofw/ofw_bus.h> | ||||
▲ Show 20 Lines • Show All 795 Lines • ▼ Show 20 Lines | rk805_settime(device_t dev, struct timespec *ts) | ||||
error = rk805_write(dev, RK805_RTC_SECS, data, 7); | error = rk805_write(dev, RK805_RTC_SECS, data, 7); | ||||
ctrl &= ~RK805_RTC_CTRL_STOP; | ctrl &= ~RK805_RTC_CTRL_STOP; | ||||
rk805_write(dev, RK805_RTC_CTRL, &ctrl, 1); | rk805_write(dev, RK805_RTC_CTRL, &ctrl, 1); | ||||
return (error); | return (error); | ||||
} | } | ||||
static void | |||||
rk805_poweroff(void *arg, int howto) | |||||
{ | |||||
device_t dev = arg; | |||||
int error; | |||||
uint8_t val; | |||||
if ((howto & RB_POWEROFF) == 0) | |||||
return; | |||||
device_printf(dev, "Powering off...\n"); | |||||
imp: This cast isn't needed, and could be combined with the device_t dev declaration above. | |||||
Done Inline ActionsI just copied the predominant style in the file. avg: I just copied the predominant style in the file.
But I agree. | |||||
error = rk805_read(dev, RK805_DEV_CTRL, &val, 1); | |||||
if (error == 0) { | |||||
Not Done Inline Actionsshutdown or power off here? imp: shutdown or power off here?
| |||||
Done Inline ActionsBoth should mean the same in this context. avg: Both should mean the same in this context. | |||||
Not Done Inline ActionsExcept all the other power-off functions in the system say 'power off' because 'shutdown' often means 'while(1);' or similar loop at the end, at least historically. imp: Except all the other power-off functions in the system say 'power off' because 'shutdown' often… | |||||
val |= RK805_DEV_CTRL_OFF; | |||||
error = rk805_write(dev, RK805_DEV_CTRL, &val, 1); | |||||
/* Wait a bit for the command to take effect. */ | |||||
if (error == 0) | |||||
DELAY(100); | |||||
} | |||||
Not Done Inline Actionsand you don't need two sets of elipses. imp: and you don't need two sets of elipses. | |||||
Done Inline ActionsBut this is printed (if printed at all) on a separate line. avg: But this is printed (if printed at all) on a separate line. | |||||
Not Done Inline Actionstrue. You can ignore this. imp: true. You can ignore this. | |||||
device_printf(dev, "Power off failed\n"); | |||||
} | |||||
static int | static int | ||||
rk805_attach(device_t dev) | rk805_attach(device_t dev) | ||||
{ | { | ||||
struct rk805_softc *sc; | struct rk805_softc *sc; | ||||
struct rk805_reg_sc *reg; | struct rk805_reg_sc *reg; | ||||
struct rk805_regdef *regdefs; | struct rk805_regdef *regdefs; | ||||
struct reg_list *regp; | struct reg_list *regp; | ||||
phandle_t rnode, child; | phandle_t rnode, child; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | for (i = 0; i < sc->nregs; i++) { | ||||
} | } | ||||
regp = malloc(sizeof(*regp), M_DEVBUF, M_WAITOK | M_ZERO); | regp = malloc(sizeof(*regp), M_DEVBUF, M_WAITOK | M_ZERO); | ||||
regp->reg = reg; | regp->reg = reg; | ||||
TAILQ_INSERT_TAIL(&sc->regs, regp, next); | TAILQ_INSERT_TAIL(&sc->regs, regp, next); | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(dev, "Regulator %s attached\n", | device_printf(dev, "Regulator %s attached\n", | ||||
regdefs[i].name); | regdefs[i].name); | ||||
} | } | ||||
} | |||||
if (OF_hasprop(ofw_bus_get_node(dev), | |||||
"rockchip,system-power-controller")) { | |||||
/* | |||||
* The priority is chosen to override PSCI and EFI shutdown | |||||
* methods as those two just hang without powering off on Rock64 | |||||
Not Done Inline ActionsWhy override? Is there some advantage to not trying those methods first? imp: Why override? Is there some advantage to not trying those methods first?
| |||||
Done Inline ActionsYes. See the summary / commit message. avg: Yes. See the summary / commit message.
Maybe it's not entirely clear, but both of those methods… | |||||
Not Done Inline ActionsAdd add that here explicitly. It's important enough to not be buried in the commit message, I'd think. imp: Add add that here explicitly. It's important enough to not be buried in the commit message, I'd… | |||||
* at least. | |||||
*/ | |||||
EVENTHANDLER_REGISTER(shutdown_final, rk805_poweroff, dev, | |||||
SHUTDOWN_PRI_LAST - 2); | |||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
rk805_detach(device_t dev) | rk805_detach(device_t dev) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |
This cast isn't needed, and could be combined with the device_t dev declaration above.