Skip to content

Commit

Permalink
Add support to ACPI-hinted iicbus(4) driver (not publically available…
Browse files Browse the repository at this point in the history
… yet)

It can be enabled with adding of -DHAVE_ACPI_IICBUS to CFLAGS
  • Loading branch information
wulf7 committed Aug 11, 2019
1 parent 36b1184 commit 6f5c3d3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions iichid.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ acpi_is_iichid(ACPI_HANDLE handle)
return (false); return (false);
} }


#ifndef HAVE_ACPI_IICBUS
static ACPI_STATUS static ACPI_STATUS
iichid_addr_cb(ACPI_RESOURCE *res, void *context) iichid_addr_cb(ACPI_RESOURCE *res, void *context)
{ {
Expand Down Expand Up @@ -127,6 +128,7 @@ acpi_get_iichid_addr(ACPI_HANDLE handle)


return (addr); return (addr);
} }
#endif /* HAVE_ACPI_IICBUS */


static int static int
iichid_get_hw(ACPI_HANDLE handle, struct iichid_hw *hw) iichid_get_hw(ACPI_HANDLE handle, struct iichid_hw *hw)
Expand Down Expand Up @@ -216,6 +218,7 @@ iichid_set_acpi_power(ACPI_HANDLE handle, int state)
return (AcpiEvaluateObject(method_handle, NULL, NULL, NULL)); return (AcpiEvaluateObject(method_handle, NULL, NULL, NULL));
} }


#ifndef HAVE_ACPI_IICBUS
static ACPI_STATUS static ACPI_STATUS
iichid_get_handle_cb(ACPI_HANDLE handle, UINT32 level, void *context, iichid_get_handle_cb(ACPI_HANDLE handle, UINT32 level, void *context,
void **retval) void **retval)
Expand Down Expand Up @@ -252,6 +255,7 @@ iichid_get_handle(device_t dev)


return (dev_handle); return (dev_handle);
} }
#endif /* HAVE_ACPI_IICBUS */


static int static int
iichid_fetch_buffer(device_t dev, void* cmd, int cmdlen, void *buf, int buflen) iichid_fetch_buffer(device_t dev, void* cmd, int cmdlen, void *buf, int buflen)
Expand Down Expand Up @@ -812,17 +816,26 @@ iichid_probe(device_t dev)
sc->probe_done = true; sc->probe_done = true;
sc->probe_result = ENXIO; sc->probe_result = ENXIO;


if (acpi_disabled("iichid"))
return (ENXIO);
if (addr == 0) if (addr == 0)
return (ENXIO); return (ENXIO);


sc->dev = dev; sc->dev = dev;
sc->ibuf = NULL; sc->ibuf = NULL;


/* Fetch hardware settings from ACPI */ /* Fetch hardware settings from ACPI */
#ifdef HAVE_ACPI_IICBUS
handle = acpi_get_handle(dev);
#else
handle = iichid_get_handle(dev); handle = iichid_get_handle(dev);
#endif
if (handle == NULL) if (handle == NULL)
return (ENXIO); return (ENXIO);


if (!acpi_is_iichid(handle))
return (ENXIO);

if (ACPI_FAILURE(iichid_get_hw(handle, &sc->hw))) if (ACPI_FAILURE(iichid_get_hw(handle, &sc->hw)))
return (ENXIO); return (ENXIO);


Expand Down Expand Up @@ -904,6 +917,7 @@ iichid_detach(device_t dev)
return (0); return (0);
} }


#ifndef HAVE_ACPI_IICBUS
static ACPI_STATUS static ACPI_STATUS
iichid_identify_cb(ACPI_HANDLE handle, UINT32 level, void *context, iichid_identify_cb(ACPI_HANDLE handle, UINT32 level, void *context,
void **status) void **status)
Expand Down Expand Up @@ -977,6 +991,7 @@ iichid_identify(driver_t *driver, device_t parent)
AcpiWalkNamespace(ACPI_TYPE_DEVICE, ctrl_handle, AcpiWalkNamespace(ACPI_TYPE_DEVICE, ctrl_handle,
1, iichid_identify_cb, NULL, parent, NULL); 1, iichid_identify_cb, NULL, parent, NULL);
} }
#endif /* HAVE_ACPI_IICBUS */


int int
iichid_suspend(device_t dev) iichid_suspend(device_t dev)
Expand Down Expand Up @@ -1030,6 +1045,7 @@ MODULE_DEPEND(iichid, acpi, 1, 1, 1);
MODULE_DEPEND(iichid, usb, 1, 1, 1); MODULE_DEPEND(iichid, usb, 1, 1, 1);
MODULE_VERSION(iichid, 1); MODULE_VERSION(iichid, 1);


#ifndef HAVE_ACPI_IICBUS
/* /*
* Dummy ACPI driver. Used as bus resources holder for iichid. * Dummy ACPI driver. Used as bus resources holder for iichid.
*/ */
Expand Down Expand Up @@ -1088,3 +1104,5 @@ static driver_t acpi_iichid_driver = {
DRIVER_MODULE(acpi_iichid, acpi, acpi_iichid_driver, acpi_iichid_devclass, NULL, 0); DRIVER_MODULE(acpi_iichid, acpi, acpi_iichid_driver, acpi_iichid_devclass, NULL, 0);
MODULE_DEPEND(acpi_iichid, acpi, 1, 1, 1); MODULE_DEPEND(acpi_iichid, acpi, 1, 1, 1);
MODULE_VERSION(acpi_iichid, 1); MODULE_VERSION(acpi_iichid, 1);

#endif /* HAVE_ACPI_IICBUS */
2 changes: 2 additions & 0 deletions iichid.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ int iichid_get_report(device_t, void *, int, uint8_t, uint8_t);
int iichid_set_report(device_t, void *, int, uint8_t, uint8_t); int iichid_set_report(device_t, void *, int, uint8_t, uint8_t);


/* Newbus device method stubs */ /* Newbus device method stubs */
#ifndef HAVE_ACPI_IICBUS
device_identify_t iichid_identify; device_identify_t iichid_identify;
#endif
device_probe_t iichid_probe; device_probe_t iichid_probe;
device_attach_t iichid_attach; device_attach_t iichid_attach;
device_detach_t iichid_detach; device_detach_t iichid_detach;
Expand Down
2 changes: 2 additions & 0 deletions imt.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ static devclass_t imt_devclass;


static device_method_t imt_methods[] = { static device_method_t imt_methods[] = {


#ifndef HAVE_ACPI_IICBUS
DEVMETHOD(device_identify, iichid_identify), DEVMETHOD(device_identify, iichid_identify),
#endif
DEVMETHOD(device_probe, imt_probe), DEVMETHOD(device_probe, imt_probe),
DEVMETHOD(device_attach, imt_attach), DEVMETHOD(device_attach, imt_attach),
DEVMETHOD(device_detach, imt_detach), DEVMETHOD(device_detach, imt_detach),
Expand Down

0 comments on commit 6f5c3d3

Please sign in to comment.