FreeBSD kernel IICBUS device code
acpi_iicbus.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/endian.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/rman.h>
#include <sys/sbuf.h>
#include <machine/resource.h>
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/amlcode.h>
#include <dev/acpica/acpivar.h>
#include <dev/iicbus/iiconf.h>
#include <dev/iicbus/iicbus.h>
Include dependency graph for acpi_iicbus.c:

Go to the source code of this file.

Data Structures

struct  gsb_buffer
 
struct  acpi_iicbus_softc
 
struct  acpi_iicbus_ivars
 

Macros

#define ACPI_IICBUS_LOCAL_BUFSIZE   32 /* Fits max SMBUS block size */
 
#define ResourceSource_Handle   ResourceSource.StringPtr
 
#define _COMPONENT   ACPI_BUS
 
#define AML_FIELD_ATTRIB_MASK   0x0F
 
#define AML_FIELD_ATTRIO(attr, io)   (((attr) << 16) | (io))
 

Typedefs

typedef ACPI_RESOURCE_I2C_SERIALBUS ACPI_IICBUS_RESOURCE_I2C_SERIALBUS
 

Functions

 __FBSDID ("$FreeBSD$")
 
 TUNABLE_INT ("hw.iicbus.enable_acpi_space_handler", &install_space_handler)
 
static bool acpi_resource_is_i2c_serialbus (ACPI_RESOURCE *res)
 
static int acpi_iicbus_sendb (device_t dev, u_char slave, char byte)
 
static int acpi_iicbus_recvb (device_t dev, u_char slave, char *byte)
 
static int acpi_iicbus_write (device_t dev, u_char slave, char cmd, void *buf, uint16_t buflen)
 
static int acpi_iicbus_read (device_t dev, u_char slave, char cmd, void *buf, uint16_t buflen)
 
static int acpi_iicbus_bwrite (device_t dev, u_char slave, char cmd, u_char count, char *buf)
 
static int acpi_iicbus_bread (device_t dev, u_char slave, char cmd, u_char *count, char *buf)
 
static ACPI_STATUS acpi_iicbus_space_handler (UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, UINT64 *Value, void *HandlerContext, void *RegionContext)
 
static int acpi_iicbus_install_address_space_handler (struct acpi_iicbus_softc *sc)
 
static int acpi_iicbus_remove_address_space_handler (struct acpi_iicbus_softc *sc)
 
static ACPI_STATUS acpi_iicbus_get_i2cres_cb (ACPI_RESOURCE *res, void *context)
 
static ACPI_STATUS acpi_iicbus_get_i2cres (ACPI_HANDLE handle, ACPI_RESOURCE_I2C_SERIALBUS *sb)
 
static ACPI_STATUS acpi_iicbus_parse_resources_cb (ACPI_RESOURCE *res, void *context)
 
static ACPI_STATUS acpi_iicbus_parse_resources (ACPI_HANDLE handle, device_t dev)
 
static void acpi_iicbus_dump_res (device_t dev, ACPI_IICBUS_RESOURCE_I2C_SERIALBUS *sb)
 
static device_t acpi_iicbus_add_child (device_t dev, u_int order, const char *name, int unit)
 
static ACPI_STATUS acpi_iicbus_enumerate_child (ACPI_HANDLE handle, UINT32 level, void *context, void **result)
 
static ACPI_STATUS acpi_iicbus_enumerate_children (device_t dev)
 
static void acpi_iicbus_set_power_children (device_t dev, int state, bool all_children)
 
static int acpi_iicbus_probe (device_t dev)
 
static int acpi_iicbus_attach (device_t dev)
 
static int acpi_iicbus_detach (device_t dev)
 
static int acpi_iicbus_suspend (device_t dev)
 
static int acpi_iicbus_resume (device_t dev)
 
static void acpi_iicbus_probe_nomatch (device_t bus, device_t child)
 
static void acpi_iicbus_driver_added (device_t dev, driver_t *driver)
 
static void acpi_iicbus_child_deleted (device_t bus, device_t child)
 
static int acpi_iicbus_read_ivar (device_t bus, device_t child, int which, uintptr_t *res)
 
static int acpi_iicbus_write_ivar (device_t bus, device_t child, int which, uintptr_t val)
 
static int acpi_iicbus_child_location (device_t bus, device_t child, struct sbuf *sb)
 
static int acpi_iicbus_child_pnpinfo (device_t bus, device_t child, struct sbuf *sb)
 
 DEFINE_CLASS_1 (iicbus, acpi_iicbus_driver, acpi_iicbus_methods, sizeof(struct acpi_iicbus_softc), iicbus_driver)
 
 MODULE_VERSION (acpi_iicbus, 1)
 
 MODULE_DEPEND (acpi_iicbus, acpi, 1, 1, 1)
 

Variables

struct gsb_buffer __packed
 
static int install_space_handler = 0
 
static device_method_t acpi_iicbus_methods []
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_BUS

Definition at line 61 of file acpi_iicbus.c.

◆ ACPI_IICBUS_LOCAL_BUFSIZE

#define ACPI_IICBUS_LOCAL_BUFSIZE   32 /* Fits max SMBUS block size */

Definition at line 50 of file acpi_iicbus.c.

◆ AML_FIELD_ATTRIB_MASK

#define AML_FIELD_ATTRIB_MASK   0x0F

◆ AML_FIELD_ATTRIO

#define AML_FIELD_ATTRIO (   attr,
  io 
)    (((attr) << 16) | (io))

◆ ResourceSource_Handle

#define ResourceSource_Handle   ResourceSource.StringPtr

Definition at line 58 of file acpi_iicbus.c.

Typedef Documentation

◆ ACPI_IICBUS_RESOURCE_I2C_SERIALBUS

typedef ACPI_RESOURCE_I2C_SERIALBUS ACPI_IICBUS_RESOURCE_I2C_SERIALBUS

Definition at line 57 of file acpi_iicbus.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ acpi_iicbus_add_child()

static device_t acpi_iicbus_add_child ( device_t  dev,
u_int  order,
const char *  name,
int  unit 
)
static

Definition at line 452 of file acpi_iicbus.c.

References dev, and iicbus_add_child_common().

Here is the call graph for this function:

◆ acpi_iicbus_attach()

◆ acpi_iicbus_bread()

static int acpi_iicbus_bread ( device_t  dev,
u_char  slave,
char  cmd,
u_char *  count,
char *  buf 
)
static

Definition at line 173 of file acpi_iicbus.c.

References ACPI_IICBUS_LOCAL_BUFSIZE, iic_msg::buf, buf, dev, errno2iic(), IIC_M_NOSTART, IIC_M_NOSTOP, IIC_M_RD, IIC_M_WR, IIC_WAIT, iicbus_release_bus(), iicbus_request_bus(), iicbus_transfer(), iic_msg::len, len, msgs, and slave.

Referenced by acpi_iicbus_space_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_bwrite()

static int acpi_iicbus_bwrite ( device_t  dev,
u_char  slave,
char  cmd,
u_char  count,
char *  buf 
)
static

Definition at line 158 of file acpi_iicbus.c.

References buf, bytes, dev, errno2iic(), IIC_M_NOSTART, IIC_M_NOSTOP, IIC_M_WR, iicbus_transfer(), msgs, and slave.

Referenced by acpi_iicbus_space_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_child_deleted()

static void acpi_iicbus_child_deleted ( device_t  bus,
device_t  child 
)
static

Definition at line 669 of file acpi_iicbus.c.

References acpi_iicbus_ivars::handle.

◆ acpi_iicbus_child_location()

static int acpi_iicbus_child_location ( device_t  bus,
device_t  child,
struct sbuf *  sb 
)
static

Definition at line 713 of file acpi_iicbus.c.

References acpi_iicbus_ivars::handle, and iicbus_child_location().

Here is the call graph for this function:

◆ acpi_iicbus_child_pnpinfo()

static int acpi_iicbus_child_pnpinfo ( device_t  bus,
device_t  child,
struct sbuf *  sb 
)
static

Definition at line 732 of file acpi_iicbus.c.

References acpi_iicbus_ivars::handle, and iicbus_child_pnpinfo().

Here is the call graph for this function:

◆ acpi_iicbus_detach()

static int acpi_iicbus_detach ( device_t  dev)
static

◆ acpi_iicbus_driver_added()

static void acpi_iicbus_driver_added ( device_t  dev,
driver_t *  driver 
)
static

Definition at line 648 of file acpi_iicbus.c.

References dev.

◆ acpi_iicbus_dump_res()

static void acpi_iicbus_dump_res ( device_t  dev,
ACPI_IICBUS_RESOURCE_I2C_SERIALBUS sb 
)
static

Definition at line 438 of file acpi_iicbus.c.

References dev.

Referenced by acpi_iicbus_enumerate_child().

Here is the caller graph for this function:

◆ acpi_iicbus_enumerate_child()

static ACPI_STATUS acpi_iicbus_enumerate_child ( ACPI_HANDLE  handle,
UINT32  level,
void *  context,
void **  result 
)
static

Definition at line 460 of file acpi_iicbus.c.

References acpi_iicbus_dump_res(), acpi_iicbus_get_i2cres(), acpi_iicbus_parse_resources(), iicbus_softc::bus_freq, and iicbus.

Referenced by acpi_iicbus_enumerate_children().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_enumerate_children()

static ACPI_STATUS acpi_iicbus_enumerate_children ( device_t  dev)
static

Definition at line 537 of file acpi_iicbus.c.

References acpi_iicbus_enumerate_child(), and dev.

Referenced by acpi_iicbus_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_get_i2cres()

static ACPI_STATUS acpi_iicbus_get_i2cres ( ACPI_HANDLE  handle,
ACPI_RESOURCE_I2C_SERIALBUS *  sb 
)
static

Definition at line 387 of file acpi_iicbus.c.

References acpi_iicbus_get_i2cres_cb().

Referenced by acpi_iicbus_enumerate_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_get_i2cres_cb()

static ACPI_STATUS acpi_iicbus_get_i2cres_cb ( ACPI_RESOURCE *  res,
void *  context 
)
static

Definition at line 361 of file acpi_iicbus.c.

References acpi_resource_is_i2c_serialbus(), and gsb_buffer::status.

Referenced by acpi_iicbus_get_i2cres().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_install_address_space_handler()

static int acpi_iicbus_install_address_space_handler ( struct acpi_iicbus_softc sc)
static

Definition at line 325 of file acpi_iicbus.c.

References acpi_iicbus_space_handler(), iicbus_softc::dev, acpi_iicbus_softc::space_handler_info, and acpi_iicbus_softc::super_sc.

Referenced by acpi_iicbus_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_parse_resources()

static ACPI_STATUS acpi_iicbus_parse_resources ( ACPI_HANDLE  handle,
device_t  dev 
)
static

Definition at line 430 of file acpi_iicbus.c.

References acpi_iicbus_parse_resources_cb(), and dev.

Referenced by acpi_iicbus_enumerate_child().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_parse_resources_cb()

static ACPI_STATUS acpi_iicbus_parse_resources_cb ( ACPI_RESOURCE *  res,
void *  context 
)
static

Definition at line 395 of file acpi_iicbus.c.

References dev, and iicbus_ivar::rl.

Referenced by acpi_iicbus_parse_resources().

Here is the caller graph for this function:

◆ acpi_iicbus_probe()

static int acpi_iicbus_probe ( device_t  dev)
static

Definition at line 561 of file acpi_iicbus.c.

References dev.

◆ acpi_iicbus_probe_nomatch()

static void acpi_iicbus_probe_nomatch ( device_t  bus,
device_t  child 
)
static

Definition at line 637 of file acpi_iicbus.c.

References iicbus_probe_nomatch().

Here is the call graph for this function:

◆ acpi_iicbus_read()

static int acpi_iicbus_read ( device_t  dev,
u_char  slave,
char  cmd,
void *  buf,
uint16_t  buflen 
)
static

Definition at line 134 of file acpi_iicbus.c.

References ACPI_IICBUS_LOCAL_BUFSIZE, iic_msg::buf, buf, dev, IIC_M_NOSTOP, IIC_M_RD, IIC_M_WR, iicbus_transfer(), msgs, and slave.

Referenced by acpi_iicbus_space_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_read_ivar()

static int acpi_iicbus_read_ivar ( device_t  bus,
device_t  child,
int  which,
uintptr_t *  res 
)
static

Definition at line 678 of file acpi_iicbus.c.

References acpi_iicbus_ivars::handle, and iicbus_read_ivar().

Here is the call graph for this function:

◆ acpi_iicbus_recvb()

static int acpi_iicbus_recvb ( device_t  dev,
u_char  slave,
char *  byte 
)
static

Definition at line 106 of file acpi_iicbus.c.

References buf, dev, IIC_M_RD, iicbus_transfer(), msgs, and slave.

Referenced by acpi_iicbus_space_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_remove_address_space_handler()

static int acpi_iicbus_remove_address_space_handler ( struct acpi_iicbus_softc sc)
static

Definition at line 343 of file acpi_iicbus.c.

References acpi_iicbus_space_handler(), iicbus_softc::dev, and acpi_iicbus_softc::super_sc.

Referenced by acpi_iicbus_detach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_resume()

static int acpi_iicbus_resume ( device_t  dev)
static

Definition at line 624 of file acpi_iicbus.c.

References acpi_iicbus_set_power_children(), and dev.

Here is the call graph for this function:

◆ acpi_iicbus_sendb()

static int acpi_iicbus_sendb ( device_t  dev,
u_char  slave,
char  byte 
)
static

Definition at line 96 of file acpi_iicbus.c.

References dev, IIC_M_WR, iicbus_transfer(), msgs, and slave.

Referenced by acpi_iicbus_space_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_set_power_children()

static void acpi_iicbus_set_power_children ( device_t  dev,
int  state,
bool  all_children 
)
static

Definition at line 545 of file acpi_iicbus.c.

References dev.

Referenced by acpi_iicbus_attach(), acpi_iicbus_detach(), acpi_iicbus_resume(), and acpi_iicbus_suspend().

Here is the caller graph for this function:

◆ acpi_iicbus_space_handler()

static ACPI_STATUS acpi_iicbus_space_handler ( UINT32  Function,
ACPI_PHYSICAL_ADDRESS  Address,
UINT32  BitWidth,
UINT64 *  Value,
void *  HandlerContext,
void *  RegionContext 
)
static

◆ acpi_iicbus_suspend()

static int acpi_iicbus_suspend ( device_t  dev)
static

Definition at line 612 of file acpi_iicbus.c.

References acpi_iicbus_set_power_children(), and dev.

Here is the call graph for this function:

◆ acpi_iicbus_write()

static int acpi_iicbus_write ( device_t  dev,
u_char  slave,
char  cmd,
void *  buf,
uint16_t  buflen 
)
static

Definition at line 122 of file acpi_iicbus.c.

References buf, dev, IIC_M_NOSTART, IIC_M_NOSTOP, IIC_M_WR, iicbus_transfer(), msgs, and slave.

Referenced by acpi_iicbus_space_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ acpi_iicbus_write_ivar()

static int acpi_iicbus_write_ivar ( device_t  bus,
device_t  child,
int  which,
uintptr_t  val 
)
static

Definition at line 694 of file acpi_iicbus.c.

References acpi_iicbus_ivars::handle, iicbus_write_ivar(), and val.

Here is the call graph for this function:

◆ acpi_resource_is_i2c_serialbus()

static bool acpi_resource_is_i2c_serialbus ( ACPI_RESOURCE *  res)
inlinestatic

Definition at line 85 of file acpi_iicbus.c.

Referenced by acpi_iicbus_get_i2cres_cb(), and acpi_iicbus_space_handler().

Here is the caller graph for this function:

◆ DEFINE_CLASS_1()

DEFINE_CLASS_1 ( iicbus  ,
acpi_iicbus_driver  ,
acpi_iicbus_methods  ,
sizeof(struct acpi_iicbus_softc ,
iicbus_driver   
)

◆ MODULE_DEPEND()

MODULE_DEPEND ( acpi_iicbus  ,
acpi  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( acpi_iicbus  ,
 
)

◆ TUNABLE_INT()

TUNABLE_INT ( "hw.iicbus.enable_acpi_space_handler"  ,
install_space_handler 
)

Variable Documentation

◆ __packed

struct gsb_buffer __packed

◆ acpi_iicbus_methods

device_method_t acpi_iicbus_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, acpi_iicbus_probe),
DEVMETHOD(device_attach, acpi_iicbus_attach),
DEVMETHOD(device_detach, acpi_iicbus_detach),
DEVMETHOD(device_suspend, acpi_iicbus_suspend),
DEVMETHOD(device_resume, acpi_iicbus_resume),
DEVMETHOD(bus_add_child, acpi_iicbus_add_child),
DEVMETHOD(bus_probe_nomatch, acpi_iicbus_probe_nomatch),
DEVMETHOD(bus_driver_added, acpi_iicbus_driver_added),
DEVMETHOD(bus_child_deleted, acpi_iicbus_child_deleted),
DEVMETHOD(bus_read_ivar, acpi_iicbus_read_ivar),
DEVMETHOD(bus_write_ivar, acpi_iicbus_write_ivar),
DEVMETHOD(bus_child_location, acpi_iicbus_child_location),
DEVMETHOD(bus_child_pnpinfo, acpi_iicbus_child_pnpinfo),
DEVMETHOD(bus_get_device_path, acpi_get_acpi_device_path),
DEVMETHOD_END,
}
static int acpi_iicbus_detach(device_t dev)
Definition: acpi_iicbus.c:600
static void acpi_iicbus_probe_nomatch(device_t bus, device_t child)
Definition: acpi_iicbus.c:637
static int acpi_iicbus_attach(device_t dev)
Definition: acpi_iicbus.c:582
static int acpi_iicbus_suspend(device_t dev)
Definition: acpi_iicbus.c:612
static int acpi_iicbus_write_ivar(device_t bus, device_t child, int which, uintptr_t val)
Definition: acpi_iicbus.c:694
static device_t acpi_iicbus_add_child(device_t dev, u_int order, const char *name, int unit)
Definition: acpi_iicbus.c:452
static int acpi_iicbus_probe(device_t dev)
Definition: acpi_iicbus.c:561
static int acpi_iicbus_child_pnpinfo(device_t bus, device_t child, struct sbuf *sb)
Definition: acpi_iicbus.c:732
static void acpi_iicbus_driver_added(device_t dev, driver_t *driver)
Definition: acpi_iicbus.c:648
static int acpi_iicbus_read_ivar(device_t bus, device_t child, int which, uintptr_t *res)
Definition: acpi_iicbus.c:678
static int acpi_iicbus_child_location(device_t bus, device_t child, struct sbuf *sb)
Definition: acpi_iicbus.c:713
static int acpi_iicbus_resume(device_t dev)
Definition: acpi_iicbus.c:624
static void acpi_iicbus_child_deleted(device_t bus, device_t child)
Definition: acpi_iicbus.c:669

Definition at line 750 of file acpi_iicbus.c.

◆ install_space_handler

int install_space_handler = 0
static

Definition at line 81 of file acpi_iicbus.c.

Referenced by acpi_iicbus_attach().