mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-12-23 15:42:25 +02:00
qi-6410-i2c-bitbang.patch
Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
parent
acaa3b4507
commit
31f03046d5
3
qiboot/include/i2c-bitbang-s3c6410.h
Normal file
3
qiboot/include/i2c-bitbang-s3c6410.h
Normal file
@ -0,0 +1,3 @@
|
||||
#include <i2c-bitbang.h>
|
||||
|
||||
extern struct i2c_bitbang bb_s3c6410;
|
@ -2,7 +2,7 @@
|
||||
* (C) Copyright 2007 OpenMoko, Inc.
|
||||
* Author: Andy Green <andy@openmoko.com>
|
||||
*
|
||||
* s3c24xx-specific i2c shared by, eg, GTA02 and GTA03
|
||||
* s3c24xx-specific i2c used by, eg, GTA02
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
|
69
qiboot/src/cpu/s3c6410/i2c-bitbang-s3c6410.c
Normal file
69
qiboot/src/cpu/s3c6410/i2c-bitbang-s3c6410.c
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* (C) Copyright 2007 OpenMoko, Inc.
|
||||
* Author: Andy Green <andy@openmoko.com>
|
||||
*
|
||||
* s3c6410-specific i2c
|
||||
*
|
||||
* 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 program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <qi.h>
|
||||
#include <i2c-bitbang.h>
|
||||
#include <s3c6410.h>
|
||||
|
||||
static char i2c_read_sda_s3c6410(void)
|
||||
{
|
||||
return !!(__REG(GPBDAT) & (1 << 6));
|
||||
}
|
||||
|
||||
static void i2c_set_s3c6410(char clock, char data)
|
||||
{
|
||||
if (clock) /* SCL <- input */
|
||||
__REG(GPBCON) = (__REG(GPBCON) & ~(3 << (5 * 4)));
|
||||
else { /* SCL <- output 0 */
|
||||
__REG(GPBDAT) = (__REG(GPBDAT) & ~(1 << 5));
|
||||
__REG(GPBCON) = (__REG(GPBCON) & ~(3 << (5 * 4))) | (1 << (5 * 4));
|
||||
}
|
||||
if (data) /* SDA <- input */
|
||||
__REG(GPBCON) = (__REG(GPBCON) & ~(3 << (6 * 4)));
|
||||
else { /* SDA <- output 0 */
|
||||
__REG(GPBDAT) = (__REG(GPBDAT) & ~(1 << 6));
|
||||
__REG(GPBCON) = (__REG(GPBCON) & ~(3 << (6 * 4))) | (1 << (6 * 4));
|
||||
}
|
||||
}
|
||||
|
||||
static void i2c_close_s3c6410(void)
|
||||
{
|
||||
/* set back to hardware I2C ready for Linux */
|
||||
__REG(GPBCON) = (__REG(GPBCON) & ~(3 << (5 * 4))) | (2 << (5 * 4));
|
||||
__REG(GPBCON) = (__REG(GPBCON) & ~(3 << (6 * 4))) | (2 << (6 * 4));
|
||||
}
|
||||
|
||||
static void i2c_spin_s3c6410(void)
|
||||
{
|
||||
int n;
|
||||
|
||||
for (n = 0; n < 1000; n++)
|
||||
__REG(GPBDAT) = __REG(GPBDAT);
|
||||
}
|
||||
|
||||
struct i2c_bitbang bb_s3c6410 = {
|
||||
.read_sda = i2c_read_sda_s3c6410,
|
||||
.set = i2c_set_s3c6410,
|
||||
.spin = i2c_spin_s3c6410,
|
||||
.close = i2c_close_s3c6410,
|
||||
};
|
Loading…
Reference in New Issue
Block a user