History log of /netbsd-current/sys/dev/i2c/ihidev.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.30 29-Apr-2024 andvar

ihidev(4): make driver compile with ACPI option disabled.

This change unlikely useful in practice, but adds consistency to already
available guards. Driver won't attach currently without ACPI.


Revision tags: thorpej-ifq-base thorpej-altq-separation-base
# 1.29 01-Aug-2023 riastradh

ihidev(4): Use iic_use_direct_match as intended.

This appears to have been a mistake; there's no obvious explanation
in the commit history for why this is different from all other
iic_use_direct_match users.

Patch from Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>, thanks!

(If it really is intended to ues I2C_MATCH_DIRECT_COMPATIBLE here, we
need a clear explanation of why, written down in a nearby comment.)


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.28 12-Feb-2022 riastradh

sys: Fix various abuse of struct device internals.

Will help to make struct device opaque later.


# 1.27 15-Jan-2022 skrll

Trailing whitespace


# 1.26 14-Jan-2022 riastradh

ihidev(4): Prohibit closing an unopened ihidev.


# 1.25 14-Jan-2022 riastradh

ihidev(4): Avoid reference count overflow.


# 1.24 14-Jan-2022 riastradh

ihidev(4): Take the lock for ihidev_open, ihidev_close.

Need this to serialize access to sc_state, sc_refcnt.

XXX Should harmonize this with uhidev(4) and tighten assertions.


# 1.23 14-Jan-2022 riastradh

ihidev(4): Check kmem_alloc(..., KM_NOSLEEP) for failure.


# 1.22 14-Jan-2022 riastradh

ihidev(4): Allocate report buffer with KM_SLEEP.

Limited to 64k and only happens on attach anyway. Let's not leave a
rake to trip on here.


# 1.21 14-Jan-2022 riastradh

ihidev(4): Fix locking and interrupt handler.

- Can't run iic_exec in softint because it does cv_wait, at least on
some i2c controllers -- defer to workqueue instead.

- Fix violations of locking rules:
. Do not take a lock at higher IPL than it is defined at!
. Do not sleep under a lock!
. Definitely do not sleep under a spin lock!
In this case, sc_intr_lock was defined at IPL_VM but used at IPL_TTY,
and i2c transactions -- possibly causing sleep for cv_wait -- were
issued under it.

But in this case, the interrupt handler needs only a single bit to
mark whether the work is pending, so just use atomic_swap for that.

- Use an adaptive lock (IPL_NONE) for i2c transactions.

- Detach children, and do so before freeing anything.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.20 07-Aug-2021 thorpej

branches: 1.20.2;
Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.19 24-Apr-2021 thorpej

branches: 1.19.2; 1.19.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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.18 27-Jan-2021 thorpej

branches: 1.18.2;
Use DEVICE_COMPAT_EOL.


# 1.17 26-Jan-2021 thorpej

Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.


# 1.16 26-Jan-2021 thorpej

Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings. Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.


# 1.15 26-Jan-2021 thorpej

Back out unintended change in previous.


# 1.14 25-Jan-2021 thorpej

Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.


# 1.13 17-Jan-2021 thorpej

Use designated initializers and a consistent termination style in
compat_data[].


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.12 09-Jan-2020 thorpej

branches: 1.12.6;
Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

branches: 1.11.2;
Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.29 01-Aug-2023 riastradh

ihidev(4): Use iic_use_direct_match as intended.

This appears to have been a mistake; there's no obvious explanation
in the commit history for why this is different from all other
iic_use_direct_match users.

Patch from Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>, thanks!

(If it really is intended to ues I2C_MATCH_DIRECT_COMPATIBLE here, we
need a clear explanation of why, written down in a nearby comment.)


Revision tags: netbsd-10-base bouyer-sunxi-drm-base
# 1.28 12-Feb-2022 riastradh

sys: Fix various abuse of struct device internals.

Will help to make struct device opaque later.


# 1.27 15-Jan-2022 skrll

Trailing whitespace


# 1.26 14-Jan-2022 riastradh

ihidev(4): Prohibit closing an unopened ihidev.


# 1.25 14-Jan-2022 riastradh

ihidev(4): Avoid reference count overflow.


# 1.24 14-Jan-2022 riastradh

ihidev(4): Take the lock for ihidev_open, ihidev_close.

Need this to serialize access to sc_state, sc_refcnt.

XXX Should harmonize this with uhidev(4) and tighten assertions.


# 1.23 14-Jan-2022 riastradh

ihidev(4): Check kmem_alloc(..., KM_NOSLEEP) for failure.


# 1.22 14-Jan-2022 riastradh

ihidev(4): Allocate report buffer with KM_SLEEP.

Limited to 64k and only happens on attach anyway. Let's not leave a
rake to trip on here.


# 1.21 14-Jan-2022 riastradh

ihidev(4): Fix locking and interrupt handler.

- Can't run iic_exec in softint because it does cv_wait, at least on
some i2c controllers -- defer to workqueue instead.

- Fix violations of locking rules:
. Do not take a lock at higher IPL than it is defined at!
. Do not sleep under a lock!
. Definitely do not sleep under a spin lock!
In this case, sc_intr_lock was defined at IPL_VM but used at IPL_TTY,
and i2c transactions -- possibly causing sleep for cv_wait -- were
issued under it.

But in this case, the interrupt handler needs only a single bit to
mark whether the work is pending, so just use atomic_swap for that.

- Use an adaptive lock (IPL_NONE) for i2c transactions.

- Detach children, and do so before freeing anything.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.20 07-Aug-2021 thorpej

branches: 1.20.2;
Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.19 24-Apr-2021 thorpej

branches: 1.19.2; 1.19.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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.18 27-Jan-2021 thorpej

branches: 1.18.2;
Use DEVICE_COMPAT_EOL.


# 1.17 26-Jan-2021 thorpej

Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.


# 1.16 26-Jan-2021 thorpej

Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings. Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.


# 1.15 26-Jan-2021 thorpej

Back out unintended change in previous.


# 1.14 25-Jan-2021 thorpej

Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.


# 1.13 17-Jan-2021 thorpej

Use designated initializers and a consistent termination style in
compat_data[].


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.12 09-Jan-2020 thorpej

branches: 1.12.6;
Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

branches: 1.11.2;
Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.28 12-Feb-2022 riastradh

sys: Fix various abuse of struct device internals.

Will help to make struct device opaque later.


# 1.27 15-Jan-2022 skrll

Trailing whitespace


# 1.26 14-Jan-2022 riastradh

ihidev(4): Prohibit closing an unopened ihidev.


# 1.25 14-Jan-2022 riastradh

ihidev(4): Avoid reference count overflow.


# 1.24 14-Jan-2022 riastradh

ihidev(4): Take the lock for ihidev_open, ihidev_close.

Need this to serialize access to sc_state, sc_refcnt.

XXX Should harmonize this with uhidev(4) and tighten assertions.


# 1.23 14-Jan-2022 riastradh

ihidev(4): Check kmem_alloc(..., KM_NOSLEEP) for failure.


# 1.22 14-Jan-2022 riastradh

ihidev(4): Allocate report buffer with KM_SLEEP.

Limited to 64k and only happens on attach anyway. Let's not leave a
rake to trip on here.


# 1.21 14-Jan-2022 riastradh

ihidev(4): Fix locking and interrupt handler.

- Can't run iic_exec in softint because it does cv_wait, at least on
some i2c controllers -- defer to workqueue instead.

- Fix violations of locking rules:
. Do not take a lock at higher IPL than it is defined at!
. Do not sleep under a lock!
. Definitely do not sleep under a spin lock!
In this case, sc_intr_lock was defined at IPL_VM but used at IPL_TTY,
and i2c transactions -- possibly causing sleep for cv_wait -- were
issued under it.

But in this case, the interrupt handler needs only a single bit to
mark whether the work is pending, so just use atomic_swap for that.

- Use an adaptive lock (IPL_NONE) for i2c transactions.

- Detach children, and do so before freeing anything.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.20 07-Aug-2021 thorpej

branches: 1.20.2;
Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.19 24-Apr-2021 thorpej

branches: 1.19.2; 1.19.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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.18 27-Jan-2021 thorpej

branches: 1.18.2;
Use DEVICE_COMPAT_EOL.


# 1.17 26-Jan-2021 thorpej

Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.


# 1.16 26-Jan-2021 thorpej

Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings. Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.


# 1.15 26-Jan-2021 thorpej

Back out unintended change in previous.


# 1.14 25-Jan-2021 thorpej

Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.


# 1.13 17-Jan-2021 thorpej

Use designated initializers and a consistent termination style in
compat_data[].


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.12 09-Jan-2020 thorpej

branches: 1.12.6;
Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

branches: 1.11.2;
Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.27 15-Jan-2022 skrll

Trailing whitespace


# 1.26 14-Jan-2022 riastradh

ihidev(4): Prohibit closing an unopened ihidev.


# 1.25 14-Jan-2022 riastradh

ihidev(4): Avoid reference count overflow.


# 1.24 14-Jan-2022 riastradh

ihidev(4): Take the lock for ihidev_open, ihidev_close.

Need this to serialize access to sc_state, sc_refcnt.

XXX Should harmonize this with uhidev(4) and tighten assertions.


# 1.23 14-Jan-2022 riastradh

ihidev(4): Check kmem_alloc(..., KM_NOSLEEP) for failure.


# 1.22 14-Jan-2022 riastradh

ihidev(4): Allocate report buffer with KM_SLEEP.

Limited to 64k and only happens on attach anyway. Let's not leave a
rake to trip on here.


# 1.21 14-Jan-2022 riastradh

ihidev(4): Fix locking and interrupt handler.

- Can't run iic_exec in softint because it does cv_wait, at least on
some i2c controllers -- defer to workqueue instead.

- Fix violations of locking rules:
. Do not take a lock at higher IPL than it is defined at!
. Do not sleep under a lock!
. Definitely do not sleep under a spin lock!
In this case, sc_intr_lock was defined at IPL_VM but used at IPL_TTY,
and i2c transactions -- possibly causing sleep for cv_wait -- were
issued under it.

But in this case, the interrupt handler needs only a single bit to
mark whether the work is pending, so just use atomic_swap for that.

- Use an adaptive lock (IPL_NONE) for i2c transactions.

- Detach children, and do so before freeing anything.


Revision tags: thorpej-i2c-spi-conf2-base
# 1.20 07-Aug-2021 thorpej

branches: 1.20.2;
Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.19 24-Apr-2021 thorpej

branches: 1.19.2; 1.19.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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.18 27-Jan-2021 thorpej

branches: 1.18.2;
Use DEVICE_COMPAT_EOL.


# 1.17 26-Jan-2021 thorpej

Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.


# 1.16 26-Jan-2021 thorpej

Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings. Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.


# 1.15 26-Jan-2021 thorpej

Back out unintended change in previous.


# 1.14 25-Jan-2021 thorpej

Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.


# 1.13 17-Jan-2021 thorpej

Use designated initializers and a consistent termination style in
compat_data[].


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.12 09-Jan-2020 thorpej

branches: 1.12.6;
Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

branches: 1.11.2;
Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.20 07-Aug-2021 thorpej

Merge thorpej-cfargs2.


Revision tags: thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.19 24-Apr-2021 thorpej

branches: 1.19.2; 1.19.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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.18 27-Jan-2021 thorpej

branches: 1.18.2;
Use DEVICE_COMPAT_EOL.


# 1.17 26-Jan-2021 thorpej

Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.


# 1.16 26-Jan-2021 thorpej

Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings. Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.


# 1.15 26-Jan-2021 thorpej

Back out unintended change in previous.


# 1.14 25-Jan-2021 thorpej

Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.


# 1.13 17-Jan-2021 thorpej

Use designated initializers and a consistent termination style in
compat_data[].


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.12 09-Jan-2020 thorpej

branches: 1.12.6;
Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

branches: 1.11.2;
Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.19 24-Apr-2021 thorpej

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?).


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.18 27-Jan-2021 thorpej

branches: 1.18.2;
Use DEVICE_COMPAT_EOL.


# 1.17 26-Jan-2021 thorpej

Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.


# 1.16 26-Jan-2021 thorpej

Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings. Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.


# 1.15 26-Jan-2021 thorpej

Back out unintended change in previous.


# 1.14 25-Jan-2021 thorpej

Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.


# 1.13 17-Jan-2021 thorpej

Use designated initializers and a consistent termination style in
compat_data[].


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.12 09-Jan-2020 thorpej

branches: 1.12.6;
Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

branches: 1.11.2;
Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.18 27-Jan-2021 thorpej

Use DEVICE_COMPAT_EOL.


# 1.17 26-Jan-2021 thorpej

Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.


# 1.16 26-Jan-2021 thorpej

Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings. Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.


# 1.15 26-Jan-2021 thorpej

Back out unintended change in previous.


# 1.14 25-Jan-2021 thorpej

Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.


# 1.13 17-Jan-2021 thorpej

Use designated initializers and a consistent termination style in
compat_data[].


Revision tags: thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.12 09-Jan-2020 thorpej

Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

branches: 1.11.2;
Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.17 26-Jan-2021 thorpej

Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.


# 1.16 26-Jan-2021 thorpej

Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings. Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.


# 1.15 26-Jan-2021 thorpej

Back out unintended change in previous.


# 1.14 25-Jan-2021 thorpej

Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.


# 1.13 17-Jan-2021 thorpej

Use designated initializers and a consistent termination style in
compat_data[].


Revision tags: thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.12 09-Jan-2020 thorpej

Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

branches: 1.11.2;
Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.13 17-Jan-2021 thorpej

Use designated initializers and a consistent termination style in
compat_data[].


Revision tags: thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3 ad-namecache-base2 ad-namecache-base1
# 1.12 09-Jan-2020 thorpej

Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

branches: 1.11.2;
Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.12 09-Jan-2020 thorpej

Re-enable the intr / mask / softint / unmask dance now that the x86
interrupt issue is fixed. Verified working by ryoon@ (thanks!).


Revision tags: ad-namecache-base
# 1.11 25-Dec-2019 thorpej

Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.11 25-Dec-2019 thorpej

Revert previous until issues can be sorted out.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.10 22-Dec-2019 thorpej

The hid-over-i2c spec specifies that compliant devices use level-sensitive
interrupts. However, it's not safe to do i2c bus access in hard interrupt
context, and we must read the event data off the device in order to clear
the interrupt condition.

Address this by using acpi_intr_mask() to mask off the interrupt source
while a softint is pending to service the events, re-enabling it once
servicing is completed.

While here, re-factor the interrupt setup / tear-down code a bit to
eventually once day simplify supporting the FDT bindings for hid-over-i2c.


Revision tags: phil-wifi-20191119
# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.9 01-Oct-2019 chs

in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

branches: 1.7.4;
Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.8 26-Sep-2019 bouyer

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

branches: 1.5.2;
In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.7 16-Nov-2018 jmcneill

Use acpi_md_intr_establish/disestablish to handle device IRQs. The existing
code abused AcpiOsInstallInterruptHandler, which is meant for installing
the SCI handler.


# 1.6 15-Nov-2018 jakllsch

Correctly handle signed/unsigned quantities in kernel HID parser.

Should fix PR kern/53605.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.5 26-Jun-2018 thorpej

In my quest to make device_compatible_entry (and associated goo)
super-general, it turns out I also made it a little to cumbersome
to use (if my tired fingers are any indication). So, this is a
course-correction -- one string per entry (like of_compat_data,
which it will soon replace), and remove the over-verbose macros.


Revision tags: pgoyette-compat-0625
# 1.4 18-Jun-2018 thorpej

- Rename iic_compat_match() to iic_compatible_match() and change it
to use the new device_compatible_match() routine. A pointer to
the matching device_compatible_entry is returned if a match is
found.
- Adjust iic_use_direct_match() accordingly.
- i2c drivers now provide device_compatible_entry tables when performing
direct-config matching.
- In the dsrtc driver, take advantage of this new capability to greatly
simplify model selection.

(I'm coming for you next, of_compat_data...)


# 1.3 16-Jun-2018 thorpej

More cleanup to i2c autoconfiguration:

- Get all of the drivers onto the new match quality constants.
- Introduce a new helper function, iic_use_direct_match(), that has
all of the logic for direct-config matching. If it returns true,
the driver returns the match result (which may be 0). If it returns
false, the driver does indirect-config matching.
- iic_compat_match() now returns a weighted match quality; matches to
lower-indexed "compatible" device property are more-specific matches,
and return a better match quality accordingly.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.2 20-Mar-2018 bouyer

Allow registering ACPI interrupt handlers with a xname.
AcpiOsInstallInterruptHandler(), part of ACPICA API, doesn't allow passing
the xname. I extend the API with AcpiOsInstallInterruptHandler_xname()
for this purpose, and change acpi_md_OsInstallInterruptHandler() to
accept and use the xname (ia64 doens't use it).
The xname was hardcoded to "acpi SCI" in the
x86 acpi_md_OsInstallInterruptHandler(), so I make
AcpiOsInstallInterruptHandler() call
AcpiOsInstallInterruptHandler_xname with xname = "acpi SCI".

Now 'vmstat -i' shows the device's name instead of "acpi SCI" for for i2c HID
interrupts.

Proposed on tech-kern@ on Dec 29.


Revision tags: pgoyette-compat-0315 pgoyette-compat-base
# 1.1 10-Dec-2017 bouyer

branches: 1.1.2;
Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.


# 1.1 10-Dec-2017 bouyer

Add drivers for HID over I2C devices, and a driver for I2C mices.
From OpenBSD.