Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/iicoc.c
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
static int iicoc_start(device_t dev, u_char slave, int timeout); | static int iicoc_start(device_t dev, u_char slave, int timeout); | ||||
static int iicoc_stop(device_t dev); | static int iicoc_stop(device_t dev); | ||||
static int iicoc_read(device_t dev, char *buf, | static int iicoc_read(device_t dev, char *buf, | ||||
int len, int *read, int last, int delay); | int len, int *read, int last, int delay); | ||||
static int iicoc_write(device_t dev, const char *buf, | static int iicoc_write(device_t dev, const char *buf, | ||||
int len, int *sent, int timeout); | int len, int *sent, int timeout); | ||||
static int iicoc_repeated_start(device_t dev, u_char slave, int timeout); | static int iicoc_repeated_start(device_t dev, u_char slave, int timeout); | ||||
struct pci_device_table iicoc_devs[] = { | |||||
{PCI_DEV(0x184e, 0x1011), | |||||
PCI_DESCR("0x1011")} | |||||
} | |||||
struct iicoc_softc { | struct iicoc_softc { | ||||
device_t dev; /* Self */ | device_t dev; /* Self */ | ||||
u_int reg_shift; /* Chip specific */ | u_int reg_shift; /* Chip specific */ | ||||
u_int clockfreq; | u_int clockfreq; | ||||
u_int i2cfreq; | u_int i2cfreq; | ||||
struct resource *mem_res; /* Memory resource */ | struct resource *mem_res; /* Memory resource */ | ||||
int mem_rid; | int mem_rid; | ||||
int sc_started; | int sc_started; | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | iicoc_init(device_t dev) | ||||
/* return 0 on success, 1 on error */ | /* return 0 on success, 1 on error */ | ||||
return ((value & OC_CONTROL_EN) == 0); | return ((value & OC_CONTROL_EN) == 0); | ||||
} | } | ||||
static int | static int | ||||
iicoc_probe(device_t dev) | iicoc_probe(device_t dev) | ||||
{ | { | ||||
struct iicoc_softc *sc; | struct iicoc_softc *sc; | ||||
const struct pci_device_table *iicd; | |||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
if ((pci_get_vendor(dev) == 0x184e) && | iicd = PCI_MATCH(dev, iicoc_devs); | ||||
(pci_get_device(dev) == 0x1011)) { | if (iicd == NULL) | ||||
return (ENXIO); | |||||
sc->clockfreq = XLP_I2C_CLKFREQ; | sc->clockfreq = XLP_I2C_CLKFREQ; | ||||
sc->i2cfreq = XLP_I2C_FREQ; | sc->i2cfreq = XLP_I2C_FREQ; | ||||
sc->reg_shift = 2; | sc->reg_shift = 2; | ||||
device_set_desc(dev, "Netlogic XLP I2C Controller"); | device_set_desc(dev, iicd->descr); | ||||
return (BUS_PROBE_DEFAULT); | return (BUS_PROBE_DEFAULT); | ||||
} | } | ||||
return (ENXIO); | |||||
} | |||||
/* | /* | ||||
* We add all the devices which we know about. | * We add all the devices which we know about. | ||||
* The generic attach routine will attach them if they are alive. | * The generic attach routine will attach them if they are alive. | ||||
*/ | */ | ||||
static int | static int | ||||
iicoc_attach(device_t dev) | iicoc_attach(device_t dev) | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | |||||
static driver_t iicoc_driver = { | static driver_t iicoc_driver = { | ||||
"iicoc", | "iicoc", | ||||
iicoc_methods, | iicoc_methods, | ||||
sizeof(struct iicoc_softc), | sizeof(struct iicoc_softc), | ||||
}; | }; | ||||
DRIVER_MODULE(iicoc, pci, iicoc_driver, iicoc_devclass, 0, 0); | DRIVER_MODULE(iicoc, pci, iicoc_driver, iicoc_devclass, 0, 0); | ||||
PCI_PNP_INFO(iicoc_devs); | |||||
DRIVER_MODULE(iicbus, iicoc, iicbus_driver, iicbus_devclass, 0, 0); | DRIVER_MODULE(iicbus, iicoc, iicbus_driver, iicbus_devclass, 0, 0); |