Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/icee.c
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | static struct ofw_compat_data compat_data[] = { | ||||
{"atmel,24c1024", (uintptr_t)(&type_desc[10])}, | {"atmel,24c1024", (uintptr_t)(&type_desc[10])}, | ||||
{NULL, (uintptr_t)NULL}, | {NULL, (uintptr_t)NULL}, | ||||
}; | }; | ||||
#endif | #endif | ||||
#define CDEV2SOFTC(dev) ((dev)->si_drv1) | #define CDEV2SOFTC(dev) ((dev)->si_drv1) | ||||
/* cdev routines */ | /* cdev routines */ | ||||
static d_open_t icee_open; | |||||
static d_close_t icee_close; | |||||
static d_read_t icee_read; | static d_read_t icee_read; | ||||
static d_write_t icee_write; | static d_write_t icee_write; | ||||
static struct cdevsw icee_cdevsw = | static struct cdevsw icee_cdevsw = | ||||
{ | { | ||||
.d_version = D_VERSION, | .d_version = D_VERSION, | ||||
.d_flags = D_TRACKCLOSE, | |||||
.d_open = icee_open, | |||||
.d_close = icee_close, | |||||
.d_read = icee_read, | .d_read = icee_read, | ||||
.d_write = icee_write | .d_write = icee_write | ||||
}; | }; | ||||
#ifdef FDT | #ifdef FDT | ||||
static int | static int | ||||
icee_probe(device_t dev) | icee_probe(device_t dev) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
icee_detach(device_t dev) | icee_detach(device_t dev) | ||||
{ | { | ||||
struct icee_softc *sc = device_get_softc(dev); | struct icee_softc *sc = device_get_softc(dev); | ||||
destroy_dev(sc->cdev); | destroy_dev(sc->cdev); | ||||
return (0); | |||||
} | |||||
static int | |||||
icee_open(struct cdev *dev, int oflags, int devtype, struct thread *td) | |||||
{ | |||||
struct icee_softc *sc; | |||||
sc = CDEV2SOFTC(dev); | |||||
if (device_get_state(sc->dev) < DS_BUSY) | |||||
device_busy(sc->dev); | |||||
return (0); | |||||
} | |||||
static int | |||||
icee_close(struct cdev *dev, int fflag, int devtype, struct thread *td) | |||||
{ | |||||
struct icee_softc *sc; | |||||
sc = CDEV2SOFTC(dev); | |||||
device_unbusy(sc->dev); | |||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
icee_read(struct cdev *dev, struct uio *uio, int ioflag) | icee_read(struct cdev *dev, struct uio *uio, int ioflag) | ||||
{ | { | ||||
struct icee_softc *sc; | struct icee_softc *sc; | ||||
uint8_t addr[2]; | uint8_t addr[2]; | ||||
▲ Show 20 Lines • Show All 136 Lines • Show Last 20 Lines |