Home | History | Annotate | Line # | Download | only in dev
fire_i2creg.h revision 1.1
      1 /* $NetBSD: fire_i2creg.h,v 1.1 2026/06/04 13:43:24 jdc Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2026 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Julian Coleman.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _FIRE_I2C_H_
     33 #define _FIRE_I2C_H_
     34 
     35 /*
     36  * Register definitions for "Mentor Grapics MI2C / Fire I2C"
     37  * Information taken from:
     38  * - Inventra MI2C Product Specification
     39  * - Fire Programmer's Reference Manual for Fire 2.1
     40  */
     41 
     42 #include <sys/cdefs.h>
     43 __KERNEL_RCSID(0, "$NetBSD: fire_i2creg.h,v 1.1 2026/06/04 13:43:24 jdc Exp $");
     44 
     45 /* Register offsets */
     46 #define FIREI2C_ADDR		0x00	/* Slave address */
     47 #define FIREI2C_XADDR		0x08	/* Extended slave address */
     48 #define FIREI2C_DATA		0x10	/* Data byte */
     49 #define FIREI2C_CTRL		0x18	/* Control register */
     50 #define FIREI2C_STAT		0x20	/* Status register (RO) */
     51 #define FIREI2C_CCR		0x28	/* Clock cntrol register (WO) */
     52 #define FIREI2C_SRST		0x30	/* Software reset */
     53 
     54 /* 0x00 - Slave (our) address */
     55 #define FIREI2C_ADDR_GC_ENBL	0x01	/* General call address enable */
     56 #define FIREI2C_ADDR_7		0xfe	/* 7-bit addr address mask */
     57 #define FIREI2C_ADDR_SHIFT	1
     58 #define FIREI2C_XADDR_9		0x06	/* 9-bit address mask (bits 8 + 9) */
     59 #define FIREI2C_XADDR_9_SHIFT	8
     60 
     61 /* 0x08 - Extended slave address */
     62 #define FIREI2C_XADDR_7		0xff	/* 9-bit address mask (bits 0 - 7) */
     63 
     64 /* 0x10 - Data byte - sent or received on the bus (including slave addr) */
     65 #define FIREI2C_DATA_SHIFT	1
     66 
     67 /* 0x18 - Control register */
     68 #define FIREI2C_CTRL_AAK	0x04	/* Assert acknowledge */
     69 #define FIREI2C_CTRL_IFLG	0x08	/* Interrupt flag */
     70 #define FIREI2C_CTRL_STP	0x10	/* Master mode stop */
     71 #define FIREI2C_CTRL_STA	0x20	/* Master mode start */
     72 #define FIREI2C_CTRL_ENAB	0x40	/* Bus enable */
     73 #define FIREI2C_CTRL_IEN	0x80	/* Interrupt enable */
     74 
     75 /* 0x20 - Status register (RO) */
     76 #define FIREI2C_STAT_BERR	0x00	/* Bus error */
     77 #define FIREI2C_STAT_STA	0x08	/* Start transmitted */
     78 #define FIREI2C_STAT_REPSTA	0x10	/* Repeated start transmitted */
     79 #define FIREI2C_STAT_AWR_ACK	0x18	/* Addr + Write sent -> ACK rcvd */
     80 #define FIREI2C_STAT_AWR_NAK	0x20	/* Addr + Write sent -> no ACK rcvd */
     81 #define FIREI2C_STAT_DAT_ACK	0x28	/* Data sent = ACK rcvd */
     82 #define FIREI2C_STAT_DAT_NAK	0x30	/* Data sent = no ACK rcvd */
     83 #define FIREI2C_STAT_ARB_LST	0x38	/* Arbitration lost */
     84 #define FIREI2C_STAT_ARE_ACK	0x40	/* Addr + Read sent -> ACK rcvd */
     85 #define FIREI2C_STAT_ARE_NAK	0x48	/* Addr + Read sent -> no ACK rcvd */
     86 #define FIREI2C_STAT_MDAT_ACK	0x50	/* Data rcvd master -> ACK sent */
     87 #define FIREI2C_STAT_MDAT_NAK	0x58	/* Data rcvd master -> not ACK sent */
     88 #define FIREI2C_STAT_SLW_ACK	0x60	/* Slave + Write rcvd -> ACK sent */
     89 #define FIREI2C_STAT_ARB_SLW	0x68	/* Arb. lost, slv+wr rcvd, ACK sent */
     90 #define FIREI2C_STAT_GC_ACK	0x70	/* Gen. call rcvd, ACK sent */
     91 #define FIREI2C_STAT_ARB_GC	0x78	/* Arb. lost, gen call rcvd, ACK sent */
     92 #define FIREI2C_STAT_SDAT_ACK	0x80	/* Data rcvd slave -> ACK sent */
     93 #define FIREI2C_STAT_SDAT_NAK	0x88	/* Data rcvd slave -> not ACK sent */
     94 #define FIREI2C_STAT_GDAT_ACK	0x90	/* Data rcvd gen call -> ACK sent */
     95 #define FIREI2C_STAT_GDAT_NAK	0x98	/* Data rcvd gen call -> not ACK sent */
     96 #define FIREI2C_STAT_STP_REP	0xa0	/* Stop or Rep Start rcvd slave */
     97 #define FIREI2C_STAT_SLR_ACK	0xa8	/* Slave + Read rcvd -> ACK sent */
     98 #define FIREI2C_STAT_ARB_SLR	0xb0	/* Arb. lost, slv+rd rcvd, ACK sent */
     99 #define FIREI2C_STAT_SLV_ACK	0xb8	/* Data sent slave -> ACK rcvd */
    100 #define FIREI2C_STAT_SLV_NAK	0xc0	/* Data sent slave -> ACK not rcvd */
    101 #define FIREI2C_STAT_SLV_LAS	0xc8	/* Last byte sent slave -> ACK rcvd */
    102 #define FIREI2C_STAT_2AW_ACK	0xd0	/* 2nd Addr + Write sent -> ACK rcvd */
    103 #define FIREI2C_STAT_2AW_NAK	0xd8	/* 2nd Addr + Wr sent -> no ACK rcvd */
    104 #define FIREI2C_STAT_IDLE	0xf8	/* No relevant status (default) */
    105 
    106 /* 0x28 - Clock cntrol register (WO) */
    107 #define FIREI2C_CCR_POW2	0x07	/* Clock divider 1 = 2^N (sample clk) */
    108 #define FIREI2C_CCR_FACT	0x78	/* Clock divider 2 = M (i2c clock) */
    109 #define FIREI2C_CCR_FACT_SHIFT	3
    110 #define FIREI2C_CCR_POW2_MAX	7
    111 #define FIREI2C_CCR_FACT_MAX	15
    112 
    113 /* 0x30 - Software reset - write any value to reset */
    114 #define FIREI2C_SRST_RST	0x01
    115 
    116 #endif /* _FIRE_I2C_H_ */
    117