Add a driver for "simple-pm-bus" a way to enable a clock and/or power domain for a group of devices.
https://www.kernel.org/doc/Documentation/devicetree/bindings/bus/simple-pm-bus.txt This is needed to use am335x/omap4 dtbs from linux 5.11. Index: sys/dev/fdt/files.fdt =================================================================== RCS file: /cvs/src/sys/dev/fdt/files.fdt,v retrieving revision 1.146 diff -u -p -r1.146 files.fdt --- sys/dev/fdt/files.fdt 5 Feb 2021 00:05:20 -0000 1.146 +++ sys/dev/fdt/files.fdt 17 Feb 2021 00:49:02 -0000 @@ -23,6 +23,10 @@ device simplepanel attach simplepanel at fdt file dev/fdt/simplepanel.c simplepanel +device simplepmbus: fdt +attach simplepmbus at fdt +file dev/fdt/simplepmbus.c simplepmbus + device sxiccmu attach sxiccmu at fdt file dev/fdt/sxiccmu.c sxiccmu Index: share/man/man4/Makefile =================================================================== RCS file: /cvs/src/share/man/man4/Makefile,v retrieving revision 1.792 diff -u -p -r1.792 Makefile --- share/man/man4/Makefile 4 Feb 2021 16:25:38 -0000 1.792 +++ share/man/man4/Makefile 17 Feb 2021 00:49:02 -0000 @@ -72,7 +72,8 @@ MAN= aac.4 abcrtc.4 abl.4 ac97.4 acphy.4 rl.4 rlphy.4 route.4 rsu.4 rtsx.4 rum.4 run.4 rtw.4 rtwn.4 \ safe.4 safte.4 sbus.4 schsio.4 scsi.4 sd.4 \ sdmmc.4 sdhc.4 se.4 ses.4 sf.4 sili.4 \ - simpleamp.4 simpleaudio.4 simplefb.4 simplepanel.4 siop.4 sis.4 sk.4 \ + simpleamp.4 simpleaudio.4 simplefb.4 simplepanel.4 simplepmbus.4 \ + siop.4 sis.4 sk.4 \ sm.4 smsc.4 softraid.4 spdmem.4 sdtemp.4 speaker.4 sppp.4 sqphy.4 \ ssdfb.4 st.4 ste.4 stge.4 sti.4 stp.4 sv.4 switch.4 sxiccmu.4 \ sxidog.4 sximmc.4 sxipio.4 sxipwm.4 sxirsb.4 sxirtc.4 sxisid.4 \ Index: sys/arch/armv7/conf/GENERIC =================================================================== RCS file: /cvs/src/sys/arch/armv7/conf/GENERIC,v retrieving revision 1.134 diff -u -p -r1.134 GENERIC --- sys/arch/armv7/conf/GENERIC 4 Feb 2021 16:25:39 -0000 1.134 +++ sys/arch/armv7/conf/GENERIC 17 Feb 2021 00:49:02 -0000 @@ -31,6 +31,7 @@ config bsd swap generic # The main bus device mainbus0 at root simplebus* at fdt? +simplepmbus* at fdt? cpu0 at mainbus? # Cortex-A9 Index: sys/arch/armv7/conf/RAMDISK =================================================================== RCS file: /cvs/src/sys/arch/armv7/conf/RAMDISK,v retrieving revision 1.119 diff -u -p -r1.119 RAMDISK --- sys/arch/armv7/conf/RAMDISK 18 Jun 2020 08:48:04 -0000 1.119 +++ sys/arch/armv7/conf/RAMDISK 17 Feb 2021 00:49:02 -0000 @@ -30,6 +30,7 @@ config bsd root on rd0a swap on rd0b mainbus0 at root softraid0 at root simplebus* at fdt? +simplepmbus* at fdt? cpu0 at mainbus? # Cortex-A9 --- /dev/null Wed Feb 17 11:49:05 2021 +++ sys/dev/fdt/simplepmbus.c Tue Feb 16 17:24:55 2021 @@ -0,0 +1,62 @@ +/* $OpenBSD$ */ +/* + * Copyright (c) 2021 Jonathan Gray <j...@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/device.h> + +#include <machine/fdt.h> + +#include <dev/ofw/openfirm.h> +#include <dev/ofw/ofw_clock.h> +#include <dev/ofw/ofw_power.h> + +#include <arm/simplebus/simplebusvar.h> + +int simplepmbus_match(struct device *, void *, void *); +void simplepmbus_attach(struct device *, struct device *, void *); + +struct simplepmbus_softc { + struct simplebus_softc sc_bus; +}; + +struct cfattach simplepmbus_ca = { + sizeof(struct simplepmbus_softc), simplepmbus_match, simplepmbus_attach +}; + +struct cfdriver simplepmbus_cd = { + NULL, "simplepmbus", DV_DULL +}; + +int +simplepmbus_match(struct device *parent, void *cfdata, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "simple-pm-bus"); +} + +void +simplepmbus_attach(struct device *parent, struct device *self, void *aux) +{ + struct simplepmbus_softc *sc = (struct simplepmbus_softc *)self; + struct fdt_attach_args *faa = aux; + + power_domain_enable(faa->fa_node); + clock_enable_all(faa->fa_node); + + simplebus_attach(parent, &sc->sc_bus.sc_dev, faa); +} --- /dev/null Wed Feb 17 11:49:07 2021 +++ share/man/man4/simplepmbus.4 Wed Feb 17 11:31:06 2021 @@ -0,0 +1,36 @@ +.\" $OpenBSD$ +.\" +.\" Copyright (c) 2021 Jonathan Gray <j...@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate$ +.Dt SIMPLEPMBUS 4 +.Os +.Sh NAME +.Nm simplepmbus +.Nd simple power managed bus +.Sh SYNOPSIS +.Cd "simplepmbus* at fdt?" +.Sh DESCRIPTION +The +.Nm +driver provides an abstraction to enable a clock and/or power domain for +a group of devices. +.Sh SEE ALSO +.Xr mainbus 4 +.Sh HISTORY +The +.Nm +driver first appeared in +.Ox 6.9 .