FreeBSD kernel IICBUS device code
pcf8591.c File Reference
#include <sys/cdefs.h>
#include "opt_platform.h"
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <dev/iicbus/iicbus.h>
#include <dev/iicbus/iiconf.h>
Include dependency graph for pcf8591.c:

Go to the source code of this file.

Data Structures

struct  pcf8591_softc
 

Macros

#define CTRL_CH_SELECT_MASK   0x03
 
#define CTRL_AUTOINC_EN   0x04
 
#define CTRL_CH_CONFIG_MASK   0x30
 
#define CTRL_CH_CONFIG_4_SINGLE   0x00
 
#define CTRL_CH_CONFIG_3_DIFF   0x10
 
#define CTRL_CH_CONFIG_2_SINGLE_1_DIFF   0x20
 
#define CTRL_CH_CONFIG_2_DIFF   0x30
 
#define CTRL_OUTPUT_EN   0x40
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int pcf8591_set_config (device_t dev)
 
static int pcf8591_get_reading (device_t dev, uint8_t *reading)
 
static int pcf8591_select_channel (device_t dev, int channel)
 
static int pcf8591_channel_sysctl (SYSCTL_HANDLER_ARGS)
 
static void pcf8591_start (void *arg)
 
static int pcf8591_probe (device_t dev)
 
static int pcf8591_attach (device_t dev)
 
static int pcf8591_detach (device_t dev)
 
 DRIVER_MODULE (pcf8591, iicbus, pcf8591_driver, pcf8591_devclass, 0, 0)
 
 MODULE_DEPEND (pcf8591, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER)
 
 MODULE_VERSION (pcf8591, 1)
 

Variables

static device_method_t pcf8591_methods []
 
static driver_t pcf8591_driver
 
static devclass_t pcf8591_devclass
 

Macro Definition Documentation

◆ CTRL_AUTOINC_EN

#define CTRL_AUTOINC_EN   0x04

Definition at line 55 of file pcf8591.c.

◆ CTRL_CH_CONFIG_2_DIFF

#define CTRL_CH_CONFIG_2_DIFF   0x30

Definition at line 60 of file pcf8591.c.

◆ CTRL_CH_CONFIG_2_SINGLE_1_DIFF

#define CTRL_CH_CONFIG_2_SINGLE_1_DIFF   0x20

Definition at line 59 of file pcf8591.c.

◆ CTRL_CH_CONFIG_3_DIFF

#define CTRL_CH_CONFIG_3_DIFF   0x10

Definition at line 58 of file pcf8591.c.

◆ CTRL_CH_CONFIG_4_SINGLE

#define CTRL_CH_CONFIG_4_SINGLE   0x00

Definition at line 57 of file pcf8591.c.

◆ CTRL_CH_CONFIG_MASK

#define CTRL_CH_CONFIG_MASK   0x30

Definition at line 56 of file pcf8591.c.

◆ CTRL_CH_SELECT_MASK

#define CTRL_CH_SELECT_MASK   0x03

Definition at line 54 of file pcf8591.c.

◆ CTRL_OUTPUT_EN

#define CTRL_OUTPUT_EN   0x40

Definition at line 61 of file pcf8591.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( pcf8591  ,
iicbus  ,
pcf8591_driver  ,
pcf8591_devclass  ,
,
 
)

◆ MODULE_DEPEND()

MODULE_DEPEND ( pcf8591  ,
iicbus  ,
IICBUS_MINVER  ,
IICBUS_PREFVER  ,
IICBUS_MAXVER   
)

◆ MODULE_VERSION()

MODULE_VERSION ( pcf8591  ,
 
)

◆ pcf8591_attach()

static int pcf8591_attach ( device_t  dev)
static

Definition at line 224 of file pcf8591.c.

References dev, pcf8591_start(), pcf8591_softc::sc_addr, and pcf8591_softc::sc_dev.

Here is the call graph for this function:

◆ pcf8591_channel_sysctl()

static int pcf8591_channel_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 142 of file pcf8591.c.

References dev, pcf8591_get_reading(), pcf8591_select_channel(), and val.

Referenced by pcf8591_start().

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

◆ pcf8591_detach()

static int pcf8591_detach ( device_t  dev)
static

Definition at line 241 of file pcf8591.c.

◆ pcf8591_get_reading()

static int pcf8591_get_reading ( device_t  dev,
uint8_t *  reading 
)
static

Definition at line 100 of file pcf8591.c.

References iic_msg::buf, dev, iic_msg::flags, IIC_INTRWAIT, IIC_M_RD, iicbus_transfer_excl(), iic_msg::len, pcf8591_softc::sc_addr, and iic_msg::slave.

Referenced by pcf8591_channel_sysctl(), and pcf8591_select_channel().

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

◆ pcf8591_probe()

static int pcf8591_probe ( device_t  dev)
static

Definition at line 209 of file pcf8591.c.

References compat_data, and dev.

◆ pcf8591_select_channel()

static int pcf8591_select_channel ( device_t  dev,
int  channel 
)
static

Definition at line 118 of file pcf8591.c.

References dev, pcf8591_get_reading(), pcf8591_set_config(), pcf8591_softc::sc_cfg, and pcf8591_softc::sc_ch_count.

Referenced by pcf8591_channel_sysctl().

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

◆ pcf8591_set_config()

static int pcf8591_set_config ( device_t  dev)
static

Definition at line 79 of file pcf8591.c.

References iic_msg::buf, data, dev, iic_msg::flags, IIC_INTRWAIT, IIC_M_WR, iicbus_transfer_excl(), iic_msg::len, pcf8591_softc::sc_addr, pcf8591_softc::sc_cfg, pcf8591_softc::sc_output, and iic_msg::slave.

Referenced by pcf8591_select_channel(), and pcf8591_start().

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

◆ pcf8591_start()

static void pcf8591_start ( void *  arg)
static

Definition at line 165 of file pcf8591.c.

References buf, dev, pcf8591_channel_sysctl(), pcf8591_set_config(), pcf8591_softc::sc_cfg, pcf8591_softc::sc_ch_count, pcf8591_softc::sc_dev, and pcf8591_softc::sc_output.

Referenced by pcf8591_attach().

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

Variable Documentation

◆ pcf8591_devclass

devclass_t pcf8591_devclass
static

Definition at line 261 of file pcf8591.c.

◆ pcf8591_driver

driver_t pcf8591_driver
static
Initial value:
= {
"pcf8591",
sizeof(struct pcf8591_softc)
}
static device_method_t pcf8591_methods[]
Definition: pcf8591.c:246

Definition at line 255 of file pcf8591.c.

◆ pcf8591_methods

device_method_t pcf8591_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, pcf8591_probe),
DEVMETHOD(device_attach, pcf8591_attach),
DEVMETHOD(device_detach, pcf8591_detach),
DEVMETHOD_END
}
static int pcf8591_detach(device_t dev)
Definition: pcf8591.c:241
static int pcf8591_probe(device_t dev)
Definition: pcf8591.c:209
static int pcf8591_attach(device_t dev)
Definition: pcf8591.c:224

Definition at line 246 of file pcf8591.c.