summaryrefslogtreecommitdiffstats
path: root/firmware/target/mips/ingenic_x1000/i2c-x1000.h
blob: 9b9ba5e0888cf107246f72bc6a584c9fd20824fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2021 Aidan MacDonald
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#ifndef __I2C_X1000_H__
#define __I2C_X1000_H__

#include "i2c-async.h"

#define I2C_FREQ_100K 100000
#define I2C_FREQ_400K 400000

extern void i2c_init(void) INIT_ATTR;

/* Configure the I2C controller prior to use.
 *
 * - freq: frequency of SCL, should be <= 400 KHz and >= 25 KHz
 *   - use I2C_FREQ_100K for 100 KHz
 *   - use I2C_FREQ_400K for 400 Khz
 *   - use 0 to disable the controller completely
 *   - frequencies below 25 KHz will violate timing constraints
 *
 * TODO: move this to the i2c-async API, it's simple enough
 */
extern void i2c_x1000_set_freq(int chn, int freq);

#endif /* __I2C_X1000_H__ */