1 1.5 kiyohara /* $NetBSD: pxa2x0_i2c.h,v 1.5 2011/08/06 03:42:11 kiyohara Exp $ */ 2 1.1 peter /* $OpenBSD: pxa2x0_i2c.h,v 1.2 2005/05/26 03:52:07 pascoe Exp $ */ 3 1.1 peter 4 1.1 peter /* 5 1.1 peter * Copyright (c) 2005 Christopher Pascoe <pascoe (at) openbsd.org> 6 1.1 peter * 7 1.1 peter * Permission to use, copy, modify, and distribute this software for any 8 1.1 peter * purpose with or without fee is hereby granted, provided that the above 9 1.1 peter * copyright notice and this permission notice appear in all copies. 10 1.1 peter * 11 1.1 peter * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 1.1 peter * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 1.1 peter * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 1.1 peter * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 1.1 peter * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 1.1 peter * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 1.1 peter * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 1.1 peter */ 19 1.1 peter 20 1.1 peter #ifndef _PXA2X0_I2C_H_ 21 1.1 peter #define _PXA2X0_I2C_H_ 22 1.1 peter 23 1.3 nonaka #include <sys/bus.h> 24 1.1 peter 25 1.1 peter struct pxa2x0_i2c_softc { 26 1.3 nonaka device_t sc_dev; 27 1.1 peter bus_space_tag_t sc_iot; 28 1.1 peter bus_space_handle_t sc_ioh; 29 1.3 nonaka 30 1.4 kiyohara bus_addr_t sc_addr; 31 1.1 peter bus_size_t sc_size; 32 1.3 nonaka 33 1.3 nonaka uint32_t sc_icr; 34 1.5 kiyohara uint32_t sc_isar; /* I2C Slave Address */ 35 1.5 kiyohara 36 1.5 kiyohara enum { 37 1.5 kiyohara PI2C_STAT_UNKNOWN = -2, 38 1.5 kiyohara PI2C_STAT_ERROR = -1, 39 1.5 kiyohara PI2C_STAT_INIT = 0, 40 1.5 kiyohara PI2C_STAT_SEND, 41 1.5 kiyohara PI2C_STAT_RECEIVE, 42 1.5 kiyohara PI2C_STAT_STOP, 43 1.5 kiyohara } sc_stat; 44 1.3 nonaka 45 1.3 nonaka uint32_t sc_flags; 46 1.3 nonaka #define PI2CF_FAST_MODE (1U << 0) 47 1.1 peter }; 48 1.1 peter 49 1.1 peter int pxa2x0_i2c_attach_sub(struct pxa2x0_i2c_softc *); 50 1.1 peter int pxa2x0_i2c_detach_sub(struct pxa2x0_i2c_softc *); 51 1.1 peter void pxa2x0_i2c_init(struct pxa2x0_i2c_softc *); 52 1.1 peter void pxa2x0_i2c_open(struct pxa2x0_i2c_softc *); 53 1.1 peter void pxa2x0_i2c_close(struct pxa2x0_i2c_softc *); 54 1.5 kiyohara int pxa2x0_i2c_read(struct pxa2x0_i2c_softc *, u_char, u_char *); 55 1.1 peter int pxa2x0_i2c_write(struct pxa2x0_i2c_softc *, u_char, u_char); 56 1.1 peter int pxa2x0_i2c_write_2(struct pxa2x0_i2c_softc *, u_char, u_short); 57 1.5 kiyohara int pxa2x0_i2c_quick(struct pxa2x0_i2c_softc *, u_char, u_char); 58 1.3 nonaka 59 1.3 nonaka int pxa2x0_i2c_send_start(struct pxa2x0_i2c_softc *, int flags); 60 1.3 nonaka int pxa2x0_i2c_send_stop(struct pxa2x0_i2c_softc *, int flags); 61 1.3 nonaka int pxa2x0_i2c_initiate_xfer(struct pxa2x0_i2c_softc *, uint16_t, int); 62 1.3 nonaka int pxa2x0_i2c_read_byte(struct pxa2x0_i2c_softc *, uint8_t *, int); 63 1.3 nonaka int pxa2x0_i2c_write_byte(struct pxa2x0_i2c_softc *, uint8_t, int); 64 1.3 nonaka 65 1.3 nonaka void pxa2x0_i2c_reset(struct pxa2x0_i2c_softc *); 66 1.3 nonaka int pxa2x0_i2c_wait(struct pxa2x0_i2c_softc *, int, int); 67 1.1 peter 68 1.5 kiyohara int pxa2x0_i2c_poll(struct pxa2x0_i2c_softc *, int, char *, int); 69 1.5 kiyohara int pxa2x0_i2c_intr_sub(struct pxa2x0_i2c_softc *, int *, uint8_t *); 70 1.5 kiyohara 71 1.3 nonaka #endif /* _PXA2X0_I2C_H_ */ 72