Home | History | Annotate | Download | only in dev
History log of /src/sys/arch/macppc/dev/pmu.c
RevisionDateAuthorComments
 1.47  21-Sep-2025  thorpej Support enumeration of i2c devices directly from the device tree.
 1.46  21-Sep-2025  thorpej It's no longer necessary to scan for sensor descriptive information
in the macppc i2c controller drivers; device_register() does it for
us.
 1.45  18-Sep-2025  thorpej In the "i2c-child-devices" array, don't pass in a "cookie" and "cookietype".
Instead, just create the appropriate devhandle and pass that along as a
data object.
 1.44  15-Sep-2025  thorpej Encapsulate what's needed to attach an I2C bus into a iicbus_attach()
inline.
 1.43  07-Sep-2025  thorpej Change todr_chip_handle::cookie -> todr_chip_handle::todr_dev, and
make it a device_t. Upcoming functional changes will require the
device_t associated with a TODR device.

Change todr_chip_handle::bus_cookie -> todr_chip_handle::todr_devaux.
Nothing was using the old field, but I decided to keep it around just
in cause something needs it in the future.

And with these largely mechanical yet semantically meaningful changes,
thus spake the Oracle: "Welcome to NetBSD 11.99.2."
 1.42  12-Aug-2025  macallan some updates and fixes:
- sprinkle volatile, mostly for clang
- on Xserve we need extra delays around i2c ops
- use combined mode for i2c reads - 2 ops instead of 3
- make sure we pass the whole compatible property to iic, not just the first
entry
 1.41  30-Aug-2023  macallan remove ancient #if 0 block
NFC
 1.40  22-Aug-2023  macallan tsleep()/wakeup() -> cv_*
 1.39  07-Aug-2021  thorpej branches: 1.39.2;
Merge thorpej-cfargs2.
 1.38  07-Aug-2021  macallan pass sensor locations to i2c devices if we can find them
tested on 2nd gen Mini
 1.37  24-Apr-2021  thorpej branches: 1.37.2; 1.37.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.36  05-Mar-2021  rin branches: 1.36.2;
Convert to intr_establish_xname().
 1.35  26-Jan-2021  thorpej There is not much point in of_compatible() returning -1 for "no match"
and >= 0 for "match". Just make it return 0 for "no match" and >0 for
"match" so it can be treated like a boolean expression.

As such of_match_compatible() (a wrapper around of_compatible()) is now
obsolete, and will be removed once all call sites are converted to an
appropriate replacement.
 1.34  14-Jul-2020  martin branches: 1.34.2;
Adapt to new proplib API
 1.33  22-Dec-2019  thorpej Cleanup i2c bus acquire / release, centralizing all of the logic into
iic_acquire_bus() / iic_release_bus(). "acquire" and "release" hooks
no longer need to be provided by back-end controller drivers (only if
they need special handling, e.g. powering on the i2c controller).
This results in the removal of a bunch of rendundant code from each
back-end controller driver.

Assert that we are not in hard interrupt context in iic_acquire_bus(),
iic_exec(), and iic_release_bus().
 1.32  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.31  28-Mar-2018  macallan branches: 1.31.2;
be less spammy on i2c errors
 1.30  16-Feb-2018  macallan branches: 1.30.2;
OF_getprop() retuns -1 on failure, not 0...
 1.29  29-Sep-2017  macallan pass the right device node to i2c devices
 1.28  01-Sep-2017  macallan support I2C bus and direct config of slave devices
 1.27  01-Jun-2016  macallan report the power button to sysmon when possible
 1.26  31-May-2016  macallan fix stupid tpyo
thanks chuq
 1.25  31-May-2016  macallan make sure we call sysmon_pswitch_event() from thread context
 1.24  14-Feb-2016  chs zero the i2c_attach_args structure before filling it in.
fixes occasional crashes in iic_attach().
 1.23  14-Mar-2014  mrg branches: 1.23.6;
remove various set-but-unused variables.
 1.22  05-Nov-2013  macallan do what cuda does - if we read garbage from the RTC try a few more times
 1.21  01-Jul-2011  dyoung branches: 1.21.2; 1.21.12; 1.21.16;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.20  18-Jun-2011  matt struct device * -> device_t
struct cfdata * -> cfdata_t
use device accessors, use device_private.
some softc/device_t splits (macppc needs a bunch more)
aprint*_dev used considerably more
 1.19  09-Nov-2010  macallan branches: 1.19.6;
add support for controlling power to the modem in some PowerBooks
works at least with my Pismo, probably others
 1.18  14-Sep-2010  macallan report lid open/close events to sysmon
 1.17  12-Dec-2009  tsutsui branches: 1.17.2; 1.17.4;
Remove `volatile' qualifier from argument types of
struct timeval passed to todr_gettime(9) and todr_settime(9).
We no longer have an ancient and volatile struct timeval `time'
global since we have switched to MI timercounter(9) on all port.

XXX1: some of these RTC drivers still assume 32bit time_t
XXX2: some of these should be rewritten to use todr_[gs]ettime_ymdhms()
XXX3: todr(9) man page doesn't mention todr_[gs]ettime_ymdhms()
 1.16  18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.15  11-Jan-2009  macallan branches: 1.15.2;
fix format instead of casting wildly
 1.14  11-Jan-2009  macallan deal with 64bit time_t
Noticed by Wojciech Galazka
 1.13  29-Apr-2008  martin branches: 1.13.8;
Convert to new 2 clause license
 1.12  30-Mar-2008  macallan branches: 1.12.2; 1.12.4;
don't splhigh() in the interrupt handler, instead spltty() in adb_poll()
 1.11  06-Dec-2007  ad branches: 1.11.12;
lockmgr -> mutex
 1.10  07-Nov-2007  garbled branches: 1.10.2;
Convert macppc to shared ofw_autoconf.c. Compile tested only.
 1.9  17-Oct-2007  garbled branches: 1.9.2;
Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.8  08-Aug-2007  macallan branches: 1.8.2; 1.8.4; 1.8.6;
sync with ppcoea-renovation
 1.7  09-Jul-2007  ad branches: 1.7.4; 1.7.8;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.6  09-May-2007  macallan add an optional callback from pmu's worker thread, use it to poll AC power
status on legacy batteries where we don't get environment interrupts. Also
report AC status changes to powerd.
 1.5  03-Apr-2007  macallan branches: 1.5.4;
cleanup a bit, fix some stupid pasto
thanks to jmcneill for finding the problem
 1.4  25-Mar-2007  macallan attach smartbat* when appropriate
 1.3  15-Feb-2007  macallan branches: 1.3.2; 1.3.4; 1.3.8; 1.3.10; 1.3.12;
- don't use IPL_HIGH
- attach batteries when present
- some cleanup
 1.2  18-Jan-2007  macallan branches: 1.2.2;
make some tables static to avoid collisions
 1.1  17-Jan-2007  macallan new drivers for pmu and cuda
 1.2.2.2  01-Feb-2007  ad Sync with head.
 1.2.2.1  18-Jan-2007  ad file pmu.c was added on branch newlock2 on 2007-02-01 08:48:08 +0000
 1.3.12.2  09-Dec-2007  reinoud Pullup to HEAD
 1.3.12.1  29-Mar-2007  reinoud Pullup to -current
 1.3.10.1  11-Jul-2007  mjf Sync with head.
 1.3.8.6  03-Dec-2007  ad Sync with HEAD.
 1.3.8.5  23-Oct-2007  ad Sync with head.
 1.3.8.4  20-Aug-2007  ad Sync with HEAD.
 1.3.8.3  15-Jul-2007  ad Sync with head.
 1.3.8.2  27-May-2007  ad Sync with head.
 1.3.8.1  10-Apr-2007  ad Sync with head.
 1.3.4.6  07-Dec-2007  yamt sync with head
 1.3.4.5  15-Nov-2007  yamt sync with head.
 1.3.4.4  27-Oct-2007  yamt sync with head.
 1.3.4.3  03-Sep-2007  yamt sync with head.
 1.3.4.2  26-Feb-2007  yamt sync with head.
 1.3.4.1  15-Feb-2007  yamt file pmu.c was added on branch yamt-lazymbuf on 2007-02-26 09:07:21 +0000
 1.3.2.2  17-May-2007  yamt sync with head.
 1.3.2.1  15-Apr-2007  yamt sync with head.
 1.5.4.7  03-Oct-2007  garbled Sync with HEAD
 1.5.4.6  08-Aug-2007  macallan set display brightness on attach
 1.5.4.5  02-Aug-2007  macallan sync with HEAD
 1.5.4.4  14-Jun-2007  macallan fix some bus_spacification fallout
 1.5.4.3  22-May-2007  matt Update to HEAD.
 1.5.4.2  11-May-2007  macallan request the correct interrupt type in a couple drivers - necessary since
these days we actually do something with the type argument
 1.5.4.1  09-May-2007  macallan sync with HEAD
 1.7.8.4  09-Dec-2007  jmcneill Sync with HEAD.
 1.7.8.3  11-Nov-2007  joerg Sync with HEAD.
 1.7.8.2  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.7.8.1  09-Aug-2007  jmcneill Sync with HEAD.
 1.7.4.1  15-Aug-2007  skrll Sync with HEAD.
 1.8.6.2  13-Nov-2007  bouyer Sync with HEAD
 1.8.6.1  25-Oct-2007  bouyer Sync with HEAD.
 1.8.4.1  18-Oct-2007  yamt sync with head.
 1.8.2.3  09-Jan-2008  matt sync with HEAD
 1.8.2.2  08-Nov-2007  matt sync with -HEAD
 1.8.2.1  06-Nov-2007  matt sync with HEAD
 1.9.2.2  08-Dec-2007  mjf Sync with HEAD.
 1.9.2.1  19-Nov-2007  mjf Sync with HEAD.
 1.10.2.1  08-Dec-2007  ad Sync with head.
 1.11.12.3  17-Jan-2009  mjf Sync with HEAD.
 1.11.12.2  02-Jun-2008  mjf Sync with HEAD.
 1.11.12.1  03-Apr-2008  mjf Sync with HEAD.
 1.12.4.4  09-Oct-2010  yamt sync with head
 1.12.4.3  11-Mar-2010  yamt sync with head
 1.12.4.2  04-May-2009  yamt sync with head.
 1.12.4.1  16-May-2008  yamt sync with head.
 1.12.2.1  18-May-2008  yamt sync with head.
 1.13.8.2  28-Apr-2009  skrll Sync with HEAD.
 1.13.8.1  19-Jan-2009  skrll Sync with HEAD.
 1.15.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.17.4.1  05-Mar-2011  rmind sync with head
 1.17.2.1  22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.19.6.1  23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.21.16.1  18-May-2014  rmind sync with head
 1.21.12.2  03-Dec-2017  jdolecek update from HEAD
 1.21.12.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.6.2  09-Jul-2016  skrll Sync with HEAD
 1.23.6.1  19-Mar-2016  skrll Sync with HEAD
 1.30.2.2  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.30.2.1  30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.31.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.31.2.1  10-Jun-2019  christos Sync with HEAD
 1.34.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.36.2.1  02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.37.8.1  04-Aug-2021  thorpej Adapt to CFARGS().
 1.37.2.2  14-May-2021  thorpej Deal with quirks / differences in OpenFirmware implementations'
interpreation of the i2c "reg" property by embedding knowledge
of those quicks directly, rather than forcing lots of drivers
to provide their own devhandle implementations. We default to
assuming the Device Tree bindings, and tweak based on platform-
specific #ifdefs.

Start with __HAVE_OPENFIRMWARE_VARIANT_AAPL (all i2c "reg" properties
encode an address that's shifted left 1 bit to account for the R/W bit
that appears on the wire).
 1.37.2.1  08-May-2021  thorpej Adapt the pmu driver to the new i2c device enumeration mechanism. This
follows the OpenFirmware bindings for the most part, but has the i2c
addresses of children shifted left one bit as it would appear on the
wire (for the r/w bit).
 1.39.2.1  09-Aug-2021  thorpej Port over the changes from thorpej-i2c-spi-conf to thorpej-i2c-spi-conf2,
which is based on a newer HEAD revision.

RSS XML Feed