1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2025-04-21 12:27:27 +03:00

fixes and improvements

This commit is contained in:
Bas Wijnen
2009-07-25 22:00:32 +02:00
parent df38266bb8
commit 283b97955d
4 changed files with 194 additions and 110 deletions

View File

@@ -1399,8 +1399,15 @@ static void __map_io (unsigned physical, unsigned mapping):
#define I2C_SR_DRF (1 << 1)
#define I2C_SR_ACKF (1 << 0)
#define I2C_WRITE 0
#define I2C_READ 1
/* I2C devices */
#define I2C_DEV_MCU 0x48
/* I2C device registers */
#define I2C_MCU_SHUTDOWN 0xd8
#define I2C_MCU_BAT_STATUS 0xdb
#define I2C_MCU_BAT_CHARGE 0xd9
/*************************************************************************
* UDC usb device controller (unused in trendtac)
@@ -2821,8 +2828,8 @@ static __inline__ unsigned msc_calc_slow_clk_divisor (bool is_sd):
#define GPIO_PW_I_PORT 3
#define GPIO_PW_I 1
#define GPIO_PW_O_PORT 2
#define GPIO_PW_O 2
#define GPIO_MCU_PORT 2
#define GPIO_MCU 1
#define GPIO_LED_EN_PORT 2
#define GPIO_LED_EN 28
#define GPIO_DISP_OFF_N_PORT 2
@@ -2847,6 +2854,15 @@ static __inline__ unsigned msc_calc_slow_clk_divisor (bool is_sd):
#define GPIO_TP_LEFT 16
#define GPIO_TP_RIGHT_PORT 0
#define GPIO_TP_RIGHT 13
#define GPIO_PWM_ENABLE_PORT 2
#define GPIO_PWM_ENABLE 30
#define GPIO_KBD_NUM_ROWS 8
#define GPIO_KBD_NUM_COLS 17
#define GPIO_KBD_COL_PORT 3
#define GPIO_KBD_COL_MASK 0x2000ffff
#define GPIO_KBD_ROW_PORT 0
#define GPIO_KBD_ROW_MASK 0x000000ff
#define GPIO_KBD_ROW_HALF 0x00005555
#define GPIO_HALF(x) (((x) & 0xf) << 1)
@@ -3012,6 +3028,48 @@ static __inline__ void gpio_as_cim ():
#define i2c_read() ( I2C_DR )
#define i2c_write(val) ( I2C_DR = (val) )
#ifndef __KERNEL
static __inline__ void i2c_open ():
i2c_set_clk (JZ_EXTAL, 10000)
i2c_enable ()
// Note that this kills messages from the queue.
static __inline__ void i2c_close ():
Message msg
receiver_set_alarm (__my_receiver, 3 * HZ / 10)
call_00 (0)
i2c_disable ()
static __inline__ bool i2c_send (unsigned data):
unsigned timeout = 10000
i2c_write (data)
i2c_set_drf ()
while i2c_check_drf () != 0:
while !i2c_transmit_ended ():
while !i2c_received_ack ():
if !--timeout:
return false
return true
static __inline__ unsigned i2c_write_page (unsigned dev, unsigned addr, char const *data, unsigned count):
unsigned timeout = 5
i2c_send_start ()
if !i2c_send ((dev << 1) | I2C_WRITE):
i2c_send_stop ()
return 0
if !i2c_send (addr):
i2c_send_stop ()
return 0
if count > 8:
count = 8
unsigned i
for i = 0; i < count; ++i:
if !i2c_send (*data++):
break
i2c_send_stop ()
return i
#endif
/***************************************************************************
* UDC
***************************************************************************/