]> git.ipfire.org Git - people/ms/u-boot.git/blob - include/asm-ppc/i2c.h
* Patch by Eran Liberty
[people/ms/u-boot.git] / include / asm-ppc / i2c.h
1 /*
2 * Freescale I2C Controller
3 *
4 * This software may be used and distributed according to the
5 * terms of the GNU Public License, Version 2, incorporated
6 * herein by reference.
7 *
8 * Copyright 2004 Freescale Semiconductor.
9 * (C) Copyright 2003, Motorola, Inc.
10 * author: Eran Liberty (liberty@freescale.com)
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28 #ifndef _ASM_I2C_H_
29 #define _ASM_I2C_H_
30
31 #include <asm/types.h>
32
33 typedef struct i2c
34 {
35 u8 adr; /**< I2C slave address */
36 #define I2C_ADR 0xFE
37 #define I2C_ADR_SHIFT 1
38 #define I2C_ADR_RES ~(I2C_ADR)
39 u8 res0[3];
40 u8 fdr; /**< I2C frequency divider register */
41
42 #define IC2_FDR 0x3F
43 #define IC2_FDR_SHIFT 0
44 #define IC2_FDR_RES ~(IC2_FDR)
45 u8 res1[3];
46 u8 cr; /**< I2C control redister */
47 #define I2C_CR_MEN 0x80
48 #define I2C_CR_MIEN 0x40
49 #define I2C_CR_MSTA 0x20
50 #define I2C_CR_MTX 0x10
51 #define I2C_CR_TXAK 0x08
52 #define I2C_CR_RSTA 0x04
53 #define I2C_CR_BCST 0x01
54 u8 res2[3];
55 u8 sr; /**< I2C status register */
56 #define I2C_SR_MCF 0x80
57 #define I2C_SR_MAAS 0x40
58 #define I2C_SR_MBB 0x20
59 #define I2C_SR_MAL 0x10
60 #define I2C_SR_BCSTM 0x08
61 #define I2C_SR_SRW 0x04
62 #define I2C_SR_MIF 0x02
63 #define I2C_SR_RXAK 0x01
64 u8 res3[3];
65 u8 dr; /**< I2C data register */
66 #define I2C_DR 0xFF
67 #define I2C_DR_SHIFT 0
68 #define I2C_DR_RES ~(I2C_DR)
69 u8 res4[3];
70 u8 dfsrr; /**< I2C digital filter sampling rate register */
71 #define I2C_DFSRR 0x3F
72 #define I2C_DFSRR_SHIFT 0
73 #define I2C_DFSRR_RES ~(I2C_DR)
74 u8 res5[3];
75 u8 res6[0xE8];
76 } i2c_t;
77
78 #ifndef CFG_HZ
79 #error CFG_HZ is not defined in /include/configs/${BOARD}.h
80 #endif
81 #define I2C_TIMEOUT (CFG_HZ/4)
82
83 #ifndef CFG_IMMRBAR
84 #error CFG_IMMRBAR is not defined in /include/configs/${BOARD}.h
85 #endif
86
87 #ifndef CFG_I2C_OFFSET
88 #error CFG_I2C_OFFSET is not defined in /include/configs/${BOARD}.h
89 #endif
90
91 #ifdef CONFIG_MPC8349ADS
92 /*
93 * MPC8349 have two i2c bus
94 */
95 extern i2c_t * mpc8349_i2c;
96 #define I2C mpc8349_i2c
97 #else
98 #define I2C ((i2c_t*)(CFG_IMMRBAR + CFG_I2C_OFFSET))
99 #endif
100
101 #define I2C_READ 1
102 #define I2C_WRITE 0
103
104 #endif /* _ASM_I2C_H_ */