-/* $OpenBSD: rkpmic.c,v 1.3 2017/11/18 20:29:51 kettenis Exp $ */
+/* $OpenBSD: rkpmic.c,v 1.4 2018/02/25 20:43:33 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
*
uint32_t base, delta;
};
+struct rkpmic_regdata rk805_regdata[] = {
+ { "DCDC_REG1", 0x2f, 0x3f, 712500, 12500 },
+ { "DCDC_REG2", 0x33, 0x3f, 712500, 12500 },
+ { "DCDC_REG4", 0x38, 0x1f, 800000, 100000 },
+ { "LDO_REG1", 0x3b, 0x1f, 800000, 100000 },
+ { "LDO_REG2", 0x3d, 0x1f, 800000, 100000 },
+ { "LDO_REG3", 0x3f, 0x1f, 800000, 100000 },
+ { }
+};
+
struct rkpmic_regdata rk808_regdata[] = {
{ "DCDC_REG1", 0x2f, 0x3f, 712500, 12500 },
{ "DCDC_REG2", 0x33, 0x3f, 712500, 12500 },
{ "LDO_REG6", 0x45, 0x1f, 800000, 100000 },
{ "LDO_REG7", 0x47, 0x1f, 800000, 100000 },
{ "LDO_REG8", 0x49, 0x1f, 1800000, 100000 },
+ { }
};
struct rkpmic_softc {
i2c_addr_t sc_addr;
struct todr_chip_handle sc_todr;
+ struct rkpmic_regdata *sc_regdata;
};
int rkpmic_match(struct device *, void *, void *);
struct i2c_attach_args *ia = aux;
int node = *(int *)ia->ia_cookie;
- return (OF_is_compatible(node, "rockchip,rk808"));
+ return (OF_is_compatible(node, "rockchip,rk805") ||
+ OF_is_compatible(node, "rockchip,rk808"));
}
void
struct rkpmic_softc *sc = (struct rkpmic_softc *)self;
struct i2c_attach_args *ia = aux;
int node = *(int *)ia->ia_cookie;
+ const char *chip;
sc->sc_tag = ia->ia_tag;
sc->sc_addr = ia->ia_addr;
- printf("\n");
-
sc->sc_todr.cookie = sc;
sc->sc_todr.todr_gettime = rkpmic_gettime;
sc->sc_todr.todr_settime = rkpmic_settime;
todr_handle = &sc->sc_todr;
+ if (OF_is_compatible(node, "rockchip,rk805")) {
+ chip = "RK805";
+ sc->sc_regdata = rk805_regdata;
+ } else {
+ chip = "RK808";
+ sc->sc_regdata = rk808_regdata;
+ }
+ printf(": %s\n", chip);
+
node = OF_getnodebyname(node, "regulators");
if (node == 0)
return;
name[0] = 0;
OF_getprop(node, "name", name, sizeof(name));
name[sizeof(name) - 1] = 0;
- for (i = 0; i < nitems(rk808_regdata); i++) {
- if (strcmp(rk808_regdata[i].name, name) == 0)
+ for (i = 0; sc->sc_regdata[i].name; i++) {
+ if (strcmp(sc->sc_regdata[i].name, name) == 0)
break;
}
- if (i == nitems(rk808_regdata))
+ if (sc->sc_regdata[i].name == NULL)
return;
rr = malloc(sizeof(*rr), M_DEVBUF, M_WAITOK | M_ZERO);
rr->rr_sc = sc;
- rr->rr_reg = rk808_regdata[i].reg;
- rr->rr_mask = rk808_regdata[i].mask;
- rr->rr_base = rk808_regdata[i].base;
- rr->rr_delta = rk808_regdata[i].delta;
+ rr->rr_reg = sc->sc_regdata[i].reg;
+ rr->rr_mask = sc->sc_regdata[i].mask;
+ rr->rr_base = sc->sc_regdata[i].base;
+ rr->rr_delta = sc->sc_regdata[i].delta;
rr->rr_rd.rd_node = node;
rr->rr_rd.rd_cookie = rr;