aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSesahgiri.Holi <seshagiri.holi@stericsson.com>2011-12-06 12:37:19 +0530
committerPreetham-rao K <preetham.rao@stericsson.com>2011-12-07 06:51:40 +0100
commit0f0a9c2c687750223f009cba4f9588708d683940 (patch)
tree316f8e179c2d07ee8aa11a0e549ca408f33e2399
parentb949a7e3c391a373061ec7313856064de28a1161 (diff)
downloadu-boot-ux500-0f0a9c2c687750223f009cba4f9588708d683940.tar.gz
u5500: Add backlight support
Add support to enable backlight. ST-Ericsson ID: 351748 ST-Ericsson FOSS-OUT ID: NA Change-Id: I8f4e7cacabf4d1f412b9c92effdabde124c6d9a5 Signed-off-by: Sesahgiri.Holi <seshagiri.holi@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/41115 Reviewed-by: QATOOLS Reviewed-by: Naveen Kumar GADDIPATI <naveen.gaddipati@stericsson.com> Reviewed-by: Preetham-rao K <preetham.rao@stericsson.com>
-rw-r--r--board/st-ericsson/u5500/Makefile4
-rw-r--r--board/st-ericsson/u5500/i2c.h221
-rw-r--r--board/st-ericsson/u5500/u5500.c4
-rw-r--r--board/st-ericsson/u5500/u5500_backlight.c141
-rw-r--r--board/st-ericsson/u5500/u5500_backlight.h60
-rw-r--r--board/st-ericsson/u5500/u5500_i2c.c592
-rw-r--r--include/asm-arm/arch-db5500/common.h1
-rw-r--r--include/configs/u5500.h17
8 files changed, 1038 insertions, 2 deletions
diff --git a/board/st-ericsson/u5500/Makefile b/board/st-ericsson/u5500/Makefile
index 1ba2859..bd43681 100644
--- a/board/st-ericsson/u5500/Makefile
+++ b/board/st-ericsson/u5500/Makefile
@@ -30,7 +30,9 @@ LIB = $(obj)lib$(BOARD).a
CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter
# Please keep one file per line and in alphabetical order
-COBJS := u5500.o
+COBJS += u5500.o
+COBJS += u5500_i2c.o
+COBJS += u5500_backlight.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))
diff --git a/board/st-ericsson/u5500/i2c.h b/board/st-ericsson/u5500/i2c.h
new file mode 100644
index 0000000..55f3d52
--- /dev/null
+++ b/board/st-ericsson/u5500/i2c.h
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+#ifndef _U5500_I2C_H_
+#define _U5500_I2C_H_
+
+#include <asm/types.h>
+#include <asm/io.h>
+#include <asm/errno.h>
+
+#include <asm/arch/common.h>
+
+/* Generic macros */
+
+#define I2C_WRITE_FIELD(reg_name,mask,shift,value) \
+ (reg_name = ((reg_name & ~mask) | (value << shift)))
+#define I2C_READ_FIELD(reg_name,mask,shift) ((reg_name & mask) >> shift )
+
+struct u5500_i2c_regs {
+ u32 cr; /* Control Register 0x00 */
+ u32 scr; /* Slave Address Register 0x04 */
+ u32 hsmcr; /* HS Master code Register 0x08 */
+ u32 mcr; /* Master Control Register 0x0C */
+ u32 tfr; /* Transmit Fifo Register 0x10 */
+ u32 sr; /* Status Register 0x14 */
+ u32 rfr; /* Receiver Fifo Register 0x18 */
+ u32 tftr; /* Transmit Fifo Threshold Register 0x1C */
+ u32 rftr; /* Receiver Fifo Threshold Register 0x20 */
+ u32 dmar; /* DMA register 0x24 */
+ u32 brcr; /* Baud Rate Counter Register 0x28 */
+ u32 imscr; /* Interrupt Mask Set and Clear Register 0x2C */
+ u32 risr; /* Raw interrupt status register 0x30 */
+ u32 misr; /* Masked interrupt status register 0x34 */
+ u32 icr; /* Interrupt Set and Clear Register 0x38 */
+ u32 reserved_1[(0xFE0 - 0x3c) >> 2]; /* Reserved 0x03C to 0xFE0 */
+ u32 periph_id_0; /* peripheral ID 0 0xFE0 */
+ u32 periph_id_1; /* peripheral ID 1 0xFE4 */
+ u32 periph_id_2; /* peripheral ID 2 0xFE8 */
+ u32 periph_id_3; /* peripheral ID 3 0xFEC */
+ u32 cell_id_0; /* I2C cell ID 0 0xFF0 */
+ u32 cell_id_1; /* I2C cell ID 1 0xFF4 */
+ u32 cell_id_2; /* I2C cell ID 2 0xFF8 */
+ u32 cell_id_3; /* I2C cell ID 3 0xFFC */
+};
+
+
+/* Control Register */
+
+/* Mask values for control register mask */
+#define I2C_CR_PE MASK_BIT0 /* Peripheral enable */
+#define I2C_CR_OM 0x6 /* Operation mode */
+#define I2C_CR_SAM MASK_BIT3 /* Slave Addressing mode */
+#define I2C_CR_SM 0x30 /* Speed mode */
+#define I2C_CR_SGCM MASK_BIT6 /* Slave General call mode */
+#define I2C_CR_FTX MASK_BIT7 /* Flush Transmit */
+#define I2C_CR_FRX MASK_BIT8 /* Flush Receive */
+#define I2C_CR_DMA_TX_EN MASK_BIT9 /* DMA TX Enable */
+#define I2C_CR_DMA_RX_EN MASK_BIT10 /* DMA Rx Enable */
+#define I2C_CR_DMA_SLE MASK_BIT11 /* DMA Synchronization Logic enable */
+#define I2C_CR_LM MASK_BIT12 /* Loop back mode */
+#define I2C_CR_FON 0x6000 /* Filtering On */
+
+/* shift valus for control register bit fields */
+#define I2C_CR_SHIFT_PE 0 /* Peripheral enable */
+#define I2C_CR_SHIFT_OM 1 /* Operation mode */
+#define I2C_CR_SHIFT_SAM 3 /* Slave Addressing mode */
+#define I2C_CR_SHIFT_SM 4 /* Speed mode */
+#define I2C_CR_SHIFT_SGCM 6 /* Slave General call mode */
+#define I2C_CR_SHIFT_FTX 7 /* Flush Transmit */
+#define I2C_CR_SHIFT_FRX 8 /* Flush Receive */
+#define I2C_CR_SHIFT_DMA_TX_EN 9 /* DMA TX Enable */
+#define I2C_CR_SHIFT_DMA_RX_EN 10 /* DMA Rx Enable */
+#define I2C_CR_SHIFT_DMA_SLE 11 /* DMA Synch Logic enable */
+#define I2C_CR_SHIFT_LM 12 /* Loop back mode */
+#define I2C_CR_SHIFT_FON 13 /* Filtering On */
+
+/* bus operation modes */
+#define I2C_BUS_SLAVE_MODE 0
+#define I2C_BUS_MASTER_MODE 1
+#define I2C_BUS_MASTER_SLAVE_MODE 2
+
+
+/* Slave control register*/
+
+/* Mask values slave control register */
+#define I2C_SCR_ADDR 0x3FF
+#define I2C_SCR_DATA_SETUP_TIME 0xFFFF0000
+
+/* Shift values for Slave control register */
+#define I2C_SCR_SHIFT_ADDR 0
+#define I2C_SCR_SHIFT_DATA_SETUP_TIME 16
+
+
+/* Master Control Register */
+
+/* Mask values for Master control register */
+#define I2C_MCR_OP MASK_BIT0 /* Operation */
+#define I2C_MCR_A7 0xFE /* LSB bits of the Address(7-bit ) */
+#define I2C_MCR_EA10 0x700 /* Extended Address */
+#define I2C_MCR_SB MASK_BIT11 /* Start byte procedure */
+#define I2C_MCR_AM 0x3000 /* Address type */
+#define I2C_MCR_STOP MASK_BIT14 /* stop condition */
+#define I2C_MCR_LENGTH 0x3FF8000 /* Frame length */
+#define I2C_MCR_A10 0x7FE /* Define to set the 10 bit address */
+/* mask for length field,stop and operation */
+#define I2C_MCR_LENGTH_STOP_OP 0x3FFC001
+
+/* Shift values for Master control values */
+#define I2C_MCR_SHIFT_OP 0 /* Operation */
+#define I2C_MCR_SHIFT_A7 1 /* LSB bits of the Address(7-bit ) */
+#define I2C_MCR_SHIFT_EA10 8 /* Extended Address */
+#define I2C_MCR_SHIFT_SB 11 /* Start byte procedure */
+#define I2C_MCR_SHIFT_AM 12 /* Address type */
+#define I2C_MCR_SHIFT_STOP 14 /* stop condition */
+#define I2C_MCR_SHIFT_LENGTH 15 /* Frame length */
+#define I2C_MCR_SHIFT_A10 1 /* define to set the 10 bit addres */
+
+#define I2C_MCR_SHIFT_LENGTH_STOP_OP 0
+
+
+/* Status Register */
+
+/* Mask values for Status register */
+#define I2C_SR_OP 0x3 /* Operation */
+#define I2C_SR_STATUS 0xC /* Controller Status */
+#define I2C_SR_CAUSE 0x70 /* Abort Cause */
+#define I2C_SR_TYPE 0x180 /* Receive Type */
+#define I2C_SR_LENGTH 0xFF700 /* Transfer length */
+
+/* Shift values for Status register */
+#define I2C_SR_SHIFT_OP 0 /* Operation */
+#define I2C_SR_SHIFT_STATUS 2 /* Controller Status */
+#define I2C_SR_SHIFT_CAUSE 4 /* Abort Cause */
+#define I2C_SR_SHIFT_TYPE 7 /* Receive Type */
+#define I2C_SR_SHIFT_LENGTH 9 /* Transfer length */
+
+/* abort cause */
+enum i2c_abort_cause {
+ I2C_NACK_ADDR = 0,
+ I2C_NACK_DATA = 1,
+ I2C_ACK_MCODE = 2,
+ I2C_ARB_LOST = 3,
+ I2C_BERR_START = 4,
+ I2C_BERR_STOP = 5,
+ I2C_OVFL = 6
+};
+
+
+/* Baud rate counter registers */
+
+/* Mask values for Baud rate counter register */
+#define I2C_BRCR_BRCNT2 0xFFFF /* Baud Rate Counter for HS mode */
+#define I2C_BRCR_BRCNT1 0xFFFF0000 /* counter for Standard and Fast mode */
+
+/* Shift values for the Baud rate counter register */
+#define I2C_BRCR_SHIFT_BRCNT2 0
+#define I2C_BRCR_SHIFT_BRCNT1 16
+
+
+/* Interrupt Register */
+
+/* Mask values for Interrupt registers */
+#define I2C_INT_TXFE MASK_BIT0 /* Tx fifo empty */
+#define I2C_INT_TXFNE MASK_BIT1 /* Tx Fifo nearly empty */
+#define I2C_INT_TXFF MASK_BIT2 /* Tx Fifo Full */
+#define I2C_INT_TXFOVR MASK_BIT3 /* Tx Fifo over run */
+#define I2C_INT_RXFE MASK_BIT4 /* Rx Fifo Empty */
+#define I2C_INT_RXFNF MASK_BIT5 /* Rx Fifo nearly empty */
+#define I2C_INT_RXFF MASK_BIT6 /* Rx Fifo Full */
+#define I2C_INT_RFSR MASK_BIT16 /* Read From slave request */
+#define I2C_INT_RFSE MASK_BIT17 /* Read from slave empty */
+#define I2C_INT_WTSR MASK_BIT18 /* Write to Slave request */
+#define I2C_INT_MTD MASK_BIT19 /* Master Transcation Done*/
+#define I2C_INT_STD MASK_BIT20 /* Slave Transaction Done */
+#define I2C_INT_MAL MASK_BIT24 /* Master Arbitation Lost */
+#define I2C_INT_BERR MASK_BIT25 /* Bus Error */
+#define I2C_INT_MTDWS MASK_BIT28 /* Master Transaction Done wo/ Stop */
+
+/* Shift values for Interrupt registers */
+#define I2C_INT_SHIFT_TXFE 0 /* Tx fifo empty */
+#define I2C_INT_SHIFT_TXFNE 1 /* Tx Fifo nearly empty */
+#define I2C_INT_SHIFT_TXFF 2 /* Tx Fifo Full */
+#define I2C_INT_SHIFT_TXFOVR 3 /* Tx Fifo over run */
+#define I2C_INT_SHIFT_RXFE 4 /* Rx Fifo Empty */
+#define I2C_INT_SHIFT_RXFNF 5 /* Rx Fifo nearly empty */
+#define I2C_INT_SHIFT_RXFF 6 /* Rx Fifo Full */
+#define I2C_INT_SHIFT_RFSR 16 /* Read From slave request */
+#define I2C_INT_SHIFT_RFSE 17 /* Read from slave empty */
+#define I2C_INT_SHIFT_WTSR 18 /* Write to Slave request */
+#define I2C_INT_SHIFT_MTD 19 /* Master Transcation Done */
+#define I2C_INT_SHIFT_STD 20 /* Slave Transaction Done */
+#define I2C_INT_SHIFT_MAL 24 /* Master Arbitation Lost */
+#define I2C_INT_SHIFT_BERR 25 /* Bus Error */
+#define I2C_INT_SHIFT_MTDWS 28 /* Master Transcation Done wo/ Stop */
+
+
+/* Misc defines */
+#define I2C_MAX_STANDARD_SCL 100000 /* Max clock (Hz) for Standard Mode */
+#define I2C_MAX_FAST_SCL 400000 /* Max clock (Hz) for Fast Mode */
+#define I2C_MAX_HIGH_SPEED_SCL 3400000 /* Max clock (Hz) for HS Mode */
+
+#endif /* _U5500_I2C_H_ */
diff --git a/board/st-ericsson/u5500/u5500.c b/board/st-ericsson/u5500/u5500.c
index 8f162c5..6adef1b 100644
--- a/board/st-ericsson/u5500/u5500.c
+++ b/board/st-ericsson/u5500/u5500.c
@@ -45,6 +45,8 @@ static pin_cfg_t gpio_config[] = {
GPIO218_I2C2_SCL | PIN_INPUT_PULLUP,
GPIO219_I2C2_SDA | PIN_INPUT_PULLUP,
+ /* Backlight Enable */
+ GPIO224_GPIO | PIN_OUTPUT_HIGH,
/* MMC2 (POP eMMC) */
GPIO5_MC0_DAT0 | PIN_INPUT_PULLUP,
GPIO6_MC0_DAT1 | PIN_INPUT_PULLUP,
@@ -314,7 +316,6 @@ int board_late_init(void)
/* LDO G for SD card (2.91V) */
byte = 0x3f;
(void) prcmu_abb_write(0x3, 0x78, &byte, (u8)sizeof(byte));
-
/*
* Set MMC_CARD_VSEL (GPIO185) to '0', since we use 2.9V for
* interfacing the SD-card (set '1' if it is 1.8V).
@@ -360,6 +361,7 @@ int board_late_init(void)
else
setenv("modem_boot_type", "normal");
+ backlight_init();
return 0;
}
#endif /* BOARD_LATE_INIT */
diff --git a/board/st-ericsson/u5500/u5500_backlight.c b/board/st-ericsson/u5500/u5500_backlight.c
new file mode 100644
index 0000000..0b5eda6
--- /dev/null
+++ b/board/st-ericsson/u5500/u5500_backlight.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2010
+ *
+ * Author: Sesahgiri.Holi <seshagiri.holi@stericsson.com> for ST-Ericsson
+ * License terms: GNU General Public License (GPL), version 2.
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <asm/arch/prcmu-db5500.h>
+#include "u5500_backlight.h"
+
+#define BACKLIGHT_SLAVE_ADDR 0x36
+
+#define LM3530_GEN_CONFIG 0x10
+#define LM3530_ALS_CONFIG 0x20
+#define LM3530_BRT_RAMP_RATE 0x30
+#define LM3530_ALS_ZONE_REG 0x40
+#define LM3530_ALS_IMP_SELECT 0x41
+#define LM3530_BRT_CTRL_REG 0xA0
+#define LM3530_ALS_ZB0_REG 0x60
+#define LM3530_ALS_ZB1_REG 0x61
+#define LM3530_ALS_ZB2_REG 0x62
+#define LM3530_ALS_ZB3_REG 0x63
+#define LM3530_ALS_Z0T_REG 0x70
+#define LM3530_ALS_Z1T_REG 0x71
+#define LM3530_ALS_Z2T_REG 0x72
+#define LM3530_ALS_Z3T_REG 0x73
+#define LM3530_ALS_Z4T_REG 0x74
+#define LM3530_REG_MAX 15
+
+#define ADDR_LEN 0x01
+#define DATA_LEN 0x01
+
+/* General Control Register */
+#define LM3530_EN_I2C_SHIFT (0)
+#define LM3530_RAMP_LAW_SHIFT (1)
+#define LM3530_MAX_CURR_SHIFT (2)
+#define LM3530_EN_PWM_SHIFT (5)
+#define LM3530_PWM_POL_SHIFT (6)
+#define LM3530_EN_PWM_SIMPLE_SHIFT (7)
+
+#define LM3530_ENABLE_I2C (1 << LM3530_EN_I2C_SHIFT)
+#define LM3530_ENABLE_PWM (1 << LM3530_EN_PWM_SHIFT)
+#define LM3530_POL_LOW (1 << LM3530_PWM_POL_SHIFT)
+#define LM3530_ENABLE_PWM_SIMPLE (1 << LM3530_EN_PWM_SIMPLE_SHIFT)
+
+/* ALS Config Register Options */
+#define LM3530_ALS_AVG_TIME_SHIFT (0)
+#define LM3530_EN_ALS_SHIFT (3)
+#define LM3530_ALS_SEL_SHIFT (5)
+
+#define LM3530_ENABLE_ALS (3 << LM3530_EN_ALS_SHIFT)
+
+/* Brightness Ramp Rate Register */
+#define LM3530_BRT_RAMP_FALL_SHIFT (0)
+#define LM3530_BRT_RAMP_RISE_SHIFT (3)
+
+/* ALS Resistor Select */
+#define LM3530_ALS1_IMP_SHIFT (0)
+#define LM3530_ALS2_IMP_SHIFT (4)
+
+/* Zone Boundary Register defaults */
+#define LM3530_ALS_ZB_MAX (4)
+#define LM3530_ALS_WINDOW_mV (1000)
+#define LM3530_ALS_OFFSET_mV (4)
+
+/* Zone Target Register defaults */
+#define LM3530_DEF_ZT_0 (0x7F)
+#define LM3530_DEF_ZT_1 (0x66)
+#define LM3530_DEF_ZT_2 (0x4C)
+#define LM3530_DEF_ZT_3 (0x33)
+#define LM3530_DEF_ZT_4 (0x19)
+
+#define LM3530_MAX_BRIGHTNESS (0x7F)
+
+static const u8 lm3530_reg[LM3530_REG_MAX] = {
+ LM3530_GEN_CONFIG,
+ LM3530_ALS_CONFIG,
+ LM3530_BRT_RAMP_RATE,
+ LM3530_ALS_ZONE_REG,
+ LM3530_ALS_IMP_SELECT,
+ LM3530_BRT_CTRL_REG,
+ LM3530_ALS_ZB0_REG,
+ LM3530_ALS_ZB1_REG,
+ LM3530_ALS_ZB2_REG,
+ LM3530_ALS_ZB3_REG,
+ LM3530_ALS_Z0T_REG,
+ LM3530_ALS_Z1T_REG,
+ LM3530_ALS_Z2T_REG,
+ LM3530_ALS_Z3T_REG,
+ LM3530_ALS_Z4T_REG,
+};
+
+void backlight_init(void)
+{
+ u8 gen_config;
+ u8 brt_ramp;
+ u8 byte;
+ u8 i;
+ int ret = 0;
+ u8 reg_val[LM3530_REG_MAX];
+
+ /* Enable regulator for back light*/
+ byte = 0x36;
+ (void) prcmu_abb_write(0x3, 0x7B, &byte, (u8)sizeof(byte));
+
+ i2c_set_bus_num(2);
+ i2c_set_bus_speed(CONFIG_SYS_I2C_SPEED);
+
+ gen_config = 0x1 << LM3530_RAMP_LAW_SHIFT |
+ LM3530_FS_CURR_26mA << LM3530_MAX_CURR_SHIFT |
+ LM3530_ENABLE_I2C;
+ brt_ramp = (LM3530_RAMP_TIME_260ms << LM3530_BRT_RAMP_FALL_SHIFT) |
+ (LM3530_RAMP_TIME_260ms << LM3530_BRT_RAMP_RISE_SHIFT);
+
+ reg_val[0] = gen_config; /* LM3530_GEN_CONFIG */
+ reg_val[1] = 0x00; /* LM3530_ALS_CONFIG */
+ reg_val[2] = brt_ramp; /* LM3530_BRT_RAMP_RATE */
+ reg_val[3] = 0x00; /* LM3530_ALS_ZONE_REG */
+ reg_val[4] = 0x00; /* LM3530_ALS_IMP_SELECT */
+ reg_val[5] = LM3530_MAX_BRIGHTNESS; /* LM3530_BRT_CTRL_REG */
+ reg_val[6] = 0x00; /* LM3530_ALS_ZB0_REG */
+ reg_val[7] = 0x00; /* LM3530_ALS_ZB1_REG */
+ reg_val[8] = 0x00; /* LM3530_ALS_ZB2_REG */
+ reg_val[9] = 0x00; /* LM3530_ALS_ZB3_REG */
+ reg_val[10] = LM3530_DEF_ZT_0; /* LM3530_ALS_Z0T_REG */
+ reg_val[11] = LM3530_DEF_ZT_1; /* LM3530_ALS_Z1T_REG */
+ reg_val[12] = LM3530_DEF_ZT_2; /* LM3530_ALS_Z2T_REG */
+ reg_val[13] = LM3530_DEF_ZT_3; /* LM3530_ALS_Z3T_REG */
+ reg_val[14] = LM3530_DEF_ZT_4; /* LM3530_ALS_Z4T_REG */
+
+ for (i = 0; i < LM3530_REG_MAX; i++) {
+ ret = i2c_write(BACKLIGHT_SLAVE_ADDR,
+ lm3530_reg[i], ADDR_LEN, &reg_val[i],
+ DATA_LEN);
+ if (ret)
+ break;
+ }
+ return;
+}
diff --git a/board/st-ericsson/u5500/u5500_backlight.h b/board/st-ericsson/u5500/u5500_backlight.h
new file mode 100644
index 0000000..f9ef0d7
--- /dev/null
+++ b/board/st-ericsson/u5500/u5500_backlight.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2010
+ *
+ * Author: Sesahgiri.Holi <seshagiri.holi@stericsson.com> for ST-Ericsson
+ * License terms: GNU General Public License (GPL), version 2.
+ */
+
+#ifndef __U5500_BACKLIGHT_H__
+#define __U5500_BACKLIGHT_H__
+
+#define LM3530_BL_MODE_MANUAL 0
+
+#define LM3530_FS_CURR_5mA (0) /* Full Scale Current */
+#define LM3530_FS_CURR_8mA (1)
+#define LM3530_FS_CURR_12mA (2)
+#define LM3530_FS_CURR_15mA (3)
+#define LM3530_FS_CURR_19mA (4)
+#define LM3530_FS_CURR_22mA (5)
+#define LM3530_FS_CURR_26mA (6)
+#define LM3530_FS_CURR_29mA (7)
+
+#define LM3530_ALS_AVRG_TIME_32ms (0) /* ALS Averaging Time */
+#define LM3530_ALS_AVRG_TIME_64ms (1)
+#define LM3530_ALS_AVRG_TIME_128ms (2)
+#define LM3530_ALS_AVRG_TIME_256ms (3)
+#define LM3530_ALS_AVRG_TIME_512ms (4)
+#define LM3530_ALS_AVRG_TIME_1024ms (5)
+#define LM3530_ALS_AVRG_TIME_2048ms (6)
+#define LM3530_ALS_AVRG_TIME_4096ms (7)
+
+#define LM3530_RAMP_TIME_1ms (0) /* Brigtness Ramp Time */
+#define LM3530_RAMP_TIME_130ms (1) /* Max to 0 and vice versa */
+#define LM3530_RAMP_TIME_260ms (2)
+#define LM3530_RAMP_TIME_520ms (3)
+#define LM3530_RAMP_TIME_1s (4)
+#define LM3530_RAMP_TIME_2s (5)
+#define LM3530_RAMP_TIME_4s (6)
+#define LM3530_RAMP_TIME_8s (7)
+
+/* ALS Resistor Select */
+#define LM3530_ALS_IMPD_Z (0x00) /* ALS Impedance */
+#define LM3530_ALS_IMPD_13_53kOhm (0x01)
+#define LM3530_ALS_IMPD_9_01kOhm (0x02)
+#define LM3530_ALS_IMPD_5_41kOhm (0x03)
+#define LM3530_ALS_IMPD_2_27kOhm (0x04)
+#define LM3530_ALS_IMPD_1_94kOhm (0x05)
+#define LM3530_ALS_IMPD_1_81kOhm (0x06)
+#define LM3530_ALS_IMPD_1_6kOhm (0x07)
+#define LM3530_ALS_IMPD_1_138kOhm (0x08)
+#define LM3530_ALS_IMPD_1_05kOhm (0x09)
+#define LM3530_ALS_IMPD_1_011kOhm (0x0A)
+#define LM3530_ALS_IMPD_941Ohm (0x0B)
+#define LM3530_ALS_IMPD_759Ohm (0x0C)
+#define LM3530_ALS_IMPD_719Ohm (0x0D)
+#define LM3530_ALS_IMPD_700Ohm (0x0E)
+#define LM3530_ALS_IMPD_667Ohm (0x0F)
+
+
+
+#endif /* __U5500_BACKLIGHT_H__ */
diff --git a/board/st-ericsson/u5500/u5500_i2c.c b/board/st-ericsson/u5500/u5500_i2c.c
new file mode 100644
index 0000000..88b6f5d
--- /dev/null
+++ b/board/st-ericsson/u5500/u5500_i2c.c
@@ -0,0 +1,592 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ *
+ * Basic U-Boot I2C interface for STn5500/DB5500
+ * Author: Sesahgiri.Holi <seshagiri.holi@stericsson.com> for ST-Ericsson
+ *
+ * License terms: GNU General Public License (GPL), version 2.
+ */
+
+/*
+ * Only 7-bit I2C device addresses are supported.
+ */
+
+#include <common.h>
+#include <i2c.h>
+
+/* later: #include <asm/arch/i2c.h> */
+#include "i2c.h"
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+
+#define I2C_ENDAD_COUNTER (CONFIG_SYS_HZ/100) /* I2C bus timeout */
+#define I2C_FIFO_FLUSH_COUNTER 500000 /* flush "timeout" */
+#define I2C_SCL_FREQ 100000 /* I2C bus clock frequency.*/
+#define I2C_INPUT_FREQ 48000000 /* Input clock frequency.*/
+#define TX_FIFO_THRESHOLD 0x4
+#define RX_FIFO_THRESHOLD 0x4
+#define SLAVE_SETUP_TIME 14 /* Slave data setup time, 250ns for 48MHz i2c_clk */
+
+#define SET_BIT(var, bit_mask) (var |= (bit_mask))
+#define CLR_BIT(var, bit_mask) (var &= ~(bit_mask))
+#define WRITE_FIELD(var, mask, shift, value) \
+ (var = ((var & ~(mask)) | ((value) << (shift))))
+
+static unsigned int bus_initialized[CONFIG_SYS_I2C_BUS_MAX];
+static unsigned int i2c_bus_num = 0;
+static unsigned int i2c_bus_speed[] = {
+ CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SPEED,
+ CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SPEED
+};
+static struct u5500_i2c_regs *i2c_dev[] = {
+ (struct u5500_i2c_regs *)CONFIG_SYS_I2C0_BASE,
+ (struct u5500_i2c_regs *)CONFIG_SYS_I2C1_BASE,
+ (struct u5500_i2c_regs *)CONFIG_SYS_I2C2_BASE,
+ (struct u5500_i2c_regs *)CONFIG_SYS_I2C3_BASE,
+};
+
+static struct {
+ int periph;
+ int pcken;
+ int kcken;
+} i2c_clock_bits[] = {
+ {3, 3, 3}, /* I2C0 */
+ {1, 4, 4}, /* I2C1 */
+ {5, 7, 7}, /* I2C2 */
+ {5, 8, 8}, /* I2C3 */
+};
+
+static inline void i2c_set_bit(void *reg, u32 mask)
+{
+ writel(readl(reg) | mask, reg);
+}
+
+static inline void i2c_clr_bit(void *reg, u32 mask)
+{
+ writel(readl(reg) & ~mask, reg);
+}
+
+static inline void i2c_write_field(void *reg, u32 mask, uint shift, u32 value)
+{
+ writel((readl(reg) & ~mask) | (value << shift), reg);
+}
+
+static int __i2c_set_bus_speed(unsigned int speed)
+{
+ u32 value;
+ struct u5500_i2c_regs *i2c_regs;
+
+ i2c_regs = i2c_dev[i2c_bus_num];
+
+ /* Select standard (100 kbps) speed mode */
+ i2c_write_field(&i2c_regs->cr, I2C_CR_SM, I2C_CR_SHIFT_SM, 0x0);
+
+ /*
+ * Set the Baud Rate Counter 2 value
+ * Baud rate (standard) = fi2cclk / ( (BRCNT2 x 2) + Foncycle )
+ * Foncycle = 0 (no digital filtering)
+ */
+ value = (u32) (I2C_INPUT_FREQ / (speed * 2));
+ i2c_write_field(&i2c_regs->brcr, I2C_BRCR_BRCNT2,
+ I2C_BRCR_SHIFT_BRCNT2, value);
+
+ /* ensure that BRCNT value is zero */
+ i2c_write_field(&i2c_regs->brcr, I2C_BRCR_BRCNT1,
+ I2C_BRCR_SHIFT_BRCNT1, 0);
+
+ return I2C_INPUT_FREQ/(value * 2);
+}
+
+/*
+ * i2c_init - initialize the i2c bus
+ *
+ * speed: bus speed (in HZ)
+ * slaveaddr: address of device in slave mode
+ *
+ * Slave mode is not implemented.
+ */
+void i2c_init(int speed, int slaveaddr)
+{
+ struct u5500_i2c_regs *i2c_regs;
+
+ debug("i2c_init bus %d, speed %d\n", i2c_bus_num, speed);
+ u5500_clock_enable(i2c_clock_bits[i2c_bus_num].periph,
+ i2c_clock_bits[i2c_bus_num].pcken,
+ i2c_clock_bits[i2c_bus_num].kcken);
+ i2c_regs = i2c_dev[i2c_bus_num];
+
+ /* Disable the controller */
+ i2c_clr_bit(&i2c_regs->cr, I2C_CR_PE);
+
+ /* Clear registers */
+ writel(0, &i2c_regs->cr);
+ writel(0, &i2c_regs->scr);
+ writel(0, &i2c_regs->hsmcr);
+ writel(0, &i2c_regs->tftr);
+ writel(0, &i2c_regs->rftr);
+ writel(0, &i2c_regs->dmar);
+
+ i2c_bus_speed[i2c_bus_num] = __i2c_set_bus_speed(speed);
+
+ /*
+ * Set our own address.
+ * Set slave address mode to 7 bit addressing mode
+ */
+ i2c_clr_bit(&i2c_regs->cr, I2C_CR_SAM);
+ i2c_write_field(&i2c_regs->scr, I2C_SCR_ADDR, I2C_SCR_SHIFT_ADDR,
+ slaveaddr);
+ /* Slave Data Set up Time */
+ i2c_write_field(&i2c_regs->scr, I2C_SCR_DATA_SETUP_TIME,
+ I2C_SCR_SHIFT_DATA_SETUP_TIME, SLAVE_SETUP_TIME);
+
+ /* Disable the DMA sync logic */
+ i2c_write_field(&i2c_regs->cr, I2C_CR_DMA_SLE,
+ I2C_CR_SHIFT_DMA_SLE, 0);
+
+ /* Disable interrupts */
+ writel(0, &i2c_regs->imscr);
+
+ /* Configure bus master mode */
+ i2c_write_field(&i2c_regs->cr, I2C_CR_OM, I2C_CR_SHIFT_OM,
+ I2C_BUS_MASTER_MODE);
+ /* Set FIFO threshold values */
+ writel(TX_FIFO_THRESHOLD, &i2c_regs->tftr);
+ writel(RX_FIFO_THRESHOLD, &i2c_regs->rftr);
+
+ /* Enable the I2C Controller */
+ i2c_set_bit(&i2c_regs->cr, I2C_CR_PE);
+
+ bus_initialized[i2c_bus_num] = 1;
+}
+
+
+/*
+ * loop_till_bit_clear - polls on a bit till it clears
+ * ioreg: register where you want to check status
+ * mask: bit mask for the bit you wish to check
+ * timeout: timeout in ticks/s
+ */
+static int loop_till_bit_clear(void *io_reg, u32 mask, unsigned long timeout)
+{
+ unsigned long timebase = get_timer(0);
+
+ do {
+ if ((readl(io_reg) & mask) == 0x0UL)
+ return 0;
+ } while (get_timer(timebase) < timeout);
+
+ debug("loop_till_bit_clear timed out\n");
+ return -1;
+}
+
+/*
+ * loop_till_bit_set - polls on a bit till it is set.
+ * ioreg: register where you want to check status
+ * mask: bit mask for the bit you wish to check
+ * timeout: timeout in ticks/s
+ */
+static int loop_till_bit_set(void * io_reg, u32 mask, unsigned long timeout)
+{
+ unsigned long timebase = get_timer(0);
+
+ do {
+ if ((readl(io_reg) & mask) != 0x0UL)
+ return 0;
+ } while (get_timer(timebase) < timeout);
+
+ debug("loop_till_bit_set timed out\n");
+ return -1;
+}
+
+/*
+ * flush_fifo - flush the I2C TX and RX FIFOs
+ */
+static void flush_fifo(struct u5500_i2c_regs *i2c_regs)
+{
+ int counter = I2C_FIFO_FLUSH_COUNTER;
+
+ /* Flush Tx FIFO */
+ i2c_set_bit(&i2c_regs->cr, I2C_CR_FTX);
+ /* Flush Rx FIFO */
+ i2c_set_bit(&i2c_regs->cr, I2C_CR_FRX);
+ while (counter--) {
+ if (!(readl(&i2c_regs->cr) & (I2C_CR_FTX | I2C_CR_FRX)))
+ break;
+ }
+ return;
+}
+
+#ifdef DEBUG
+static inline void print_abort_reason(struct u5500_i2c_regs *i2c_regs)
+{
+ enum i2c_abort_cause cause;
+
+ printf("abort: risr %08x, sr %08x\n", i2c_regs->risr, i2c_regs->sr);
+ cause = (readl(&i2c_regs->sr) & I2C_SR_CAUSE) >> I2C_SR_SHIFT_CAUSE;
+ switch (cause) {
+ case I2C_NACK_ADDR:
+ printf("No Ack received after Slave Address xmission\n");
+ break;
+ case I2C_NACK_DATA:
+ printf("Valid for MASTER_WRITE: No Ack received "
+ "during data phase\n");
+ break;
+ case I2C_ACK_MCODE:
+ printf("Master recv ack after xmission of master code"
+ "in hs mode\n");
+ break;
+ case I2C_ARB_LOST:
+ printf("Master Lost arbitration\n");
+ break;
+ case I2C_BERR_START:
+ printf("Slave restarts\n");
+ break;
+ case I2C_BERR_STOP:
+ printf("Slave reset\n");
+ break;
+ case I2C_OVFL:
+ printf("Overflow\n");
+ break;
+ default:
+ printf("Unknown error type\n");
+ }
+}
+#endif
+
+/*
+ * i2c_abort - called when a I2C transaction failed
+ */
+static void i2c_abort(struct u5500_i2c_regs *i2c_regs)
+{
+#ifdef DEBUG
+ print_abort_reason(i2c_regs);
+#endif
+ /* flush RX and TX fifos */
+ flush_fifo(i2c_regs);
+
+ /* Acknowledge the Master Transaction Done */
+ i2c_set_bit(&i2c_regs->icr, I2C_INT_MTD);
+
+ /* Acknowledge the Master Transaction Done Without Stop */
+ i2c_set_bit(&i2c_regs->icr, I2C_INT_MTDWS);
+
+ i2c_init(i2c_bus_speed[i2c_bus_num], CONFIG_SYS_I2C_SLAVE);
+}
+
+/*
+ * write addr, alias index, to I2C bus.
+ */
+static int i2c_write_addr(struct u5500_i2c_regs *i2c_regs, uint addr, int alen)
+{
+ while (alen--) {
+ /* Wait until the Tx Fifo is not full */
+ if (loop_till_bit_clear((void *)&i2c_regs->risr,
+ I2C_INT_TXFF, I2C_ENDAD_COUNTER))
+ {
+ i2c_abort(i2c_regs);
+ return -1;
+ }
+
+ /* MSB first */
+ writeb((addr >> (alen * 8)) & 0xff, &i2c_regs->tfr);
+ }
+
+ return 0;
+}
+
+/*
+ * Internal simplified read function:
+ * i2c_regs: Pointer to I2C registers for current bus
+ * chip: I2C chip address, range 0..127
+ * addr: Memory (register) address within the chip
+ * alen: Number of bytes to use for addr (typically 1, 2 for larger
+ * memories, 0 for register type devices with only one register)
+ * value: Where to put the data
+ *
+ * Returns: 0 on success, not 0 on failure
+ */
+static int i2c_read_byte(struct u5500_i2c_regs *i2c_regs, uchar chip,
+ uint addr, int alen, uchar *value)
+{
+ u32 mcr = 0;
+
+ /* Set the address mode to 7 bit */
+ WRITE_FIELD(mcr, I2C_MCR_AM, I2C_MCR_SHIFT_AM, 1);
+
+ /* Store the slave address in the master control register */
+ WRITE_FIELD(mcr, I2C_MCR_A7, I2C_MCR_SHIFT_A7, chip);
+
+ if (alen != 0) {
+ /* Master write operation */
+ CLR_BIT(mcr, I2C_MCR_OP);
+
+ /* Configure the Frame length to one byte */
+ WRITE_FIELD(mcr, I2C_MCR_LENGTH, I2C_MCR_SHIFT_LENGTH, 1);
+
+ /* Repeated start, no stop */
+ CLR_BIT(mcr, I2C_MCR_STOP);
+
+ /* Write Master Control Register */
+ writel(mcr, &i2c_regs->mcr);
+
+ /* send addr/index */
+ if (i2c_write_addr(i2c_regs, addr, alen) != 0)
+ return -1;
+
+ /* Check for the Master Transaction Done Without Stop */
+ if (loop_till_bit_set((void *)&i2c_regs->risr,
+ I2C_INT_MTDWS, I2C_ENDAD_COUNTER)) {
+ return -1;
+ }
+
+ /* Acknowledge the Master Transaction Done Without Stop */
+ i2c_set_bit(&i2c_regs->icr, I2C_INT_MTDWS);
+ }
+
+ /* Master control configuration for read operation */
+ SET_BIT(mcr, I2C_MCR_OP);
+
+ /* Configure the STOP condition, we read only one byte */
+ SET_BIT(mcr, I2C_MCR_STOP);
+
+ /* Set the frame length to one byte, we support only 1 byte reads */
+ WRITE_FIELD(mcr, I2C_MCR_LENGTH, I2C_MCR_SHIFT_LENGTH, 1);
+
+ i2c_write_field(&i2c_regs->mcr, I2C_MCR_LENGTH_STOP_OP,
+ I2C_MCR_SHIFT_LENGTH_STOP_OP, mcr);
+
+ /*
+ * receive_data_polling
+ */
+
+ /* Wait until the Rx FIFO is not empty */
+ if (loop_till_bit_clear((void *)&i2c_regs->risr, I2C_INT_RXFE,
+ I2C_ENDAD_COUNTER))
+ return -1;
+
+ /* Read the data byte from Rx FIFO */
+ *value = readb(&i2c_regs->rfr);
+
+ /* Wait until the work is done */
+ if (loop_till_bit_set((void *)&i2c_regs->risr, I2C_INT_MTD,
+ I2C_ENDAD_COUNTER))
+ return -1;
+
+ /* Acknowledge the Master Transaction Done */
+ i2c_set_bit(&i2c_regs->icr, I2C_INT_MTD);
+
+ /* If MTD is set, Master Transaction Done Without Stop is set too */
+ i2c_set_bit(&i2c_regs->icr, I2C_INT_MTDWS);
+
+ return 0;
+}
+
+/*
+ * Internal simplified write function:
+ * i2c_regs: Pointer to I2C registers for current bus
+ * chip: I2C chip address, range 0..127
+ * addr: Memory (register) address within the chip
+ * alen: Number of bytes to use for addr (typically 1, 2 for larger
+ * memories, 0 for register type devices with only one register)
+ * data: Where to read the data
+ * len: How many bytes to write
+ *
+ * Returns: 0 on success, not 0 on failure
+ */
+static int __i2c_write(struct u5500_i2c_regs *i2c_regs, u8 chip, uint addr,
+ int alen, u8 *data, int len)
+{
+ int i;
+ u32 mcr = 0;
+
+ /* Set the address mode to 7 bit */
+ WRITE_FIELD(mcr, I2C_MCR_AM, I2C_MCR_SHIFT_AM, 1);
+
+ /* Store the slave address in the master control register */
+ WRITE_FIELD(mcr, I2C_MCR_A7, I2C_MCR_SHIFT_A7, chip);
+
+ /* Write operation */
+ CLR_BIT(mcr, I2C_MCR_OP);
+
+ /* Current transaction is terminated by STOP condition */
+ SET_BIT(mcr, I2C_MCR_STOP);
+
+ /* Frame length: addr byte + len */
+ WRITE_FIELD(mcr, I2C_MCR_LENGTH, I2C_MCR_SHIFT_LENGTH, (alen + len));
+
+ /* Write MCR register */
+ writel(mcr, &i2c_regs->mcr);
+
+ if (i2c_write_addr(i2c_regs, addr, alen) != 0)
+ return -1;
+
+ for (i = 0; i < len; i++) {
+ /* Wait until the Tx FIFO is not full */
+ if (loop_till_bit_clear((void *)&i2c_regs->risr,
+ I2C_INT_TXFF, I2C_ENDAD_COUNTER))
+ return -1;
+
+ /* it is a 32 bit register with upper 24 reserved R/O */
+ writeb(data[i], &i2c_regs->tfr);
+ }
+
+ /* Check for Master Transaction Done */
+ if (loop_till_bit_set((void *)&i2c_regs->risr, I2C_INT_MTD,
+ I2C_ENDAD_COUNTER)) {
+ printf("i2c_write_byte error2: risr %08x\n",
+ i2c_regs->risr);
+ return -1;
+ }
+
+ /* Acknowledge Master Transaction Done */
+ i2c_set_bit(&i2c_regs->icr, I2C_INT_MTD);
+
+ /* Acknowledge Master Transaction Done Without Stop */
+ i2c_set_bit(&i2c_regs->icr, I2C_INT_MTDWS);
+
+ return 0;
+}
+
+/*
+ * Probe the given I2C chip address. Returns 0 if a chip responded,
+ * not 0 on failure.
+ */
+int i2c_probe(uchar chip)
+{
+ u32 mcr = 0;
+ struct u5500_i2c_regs *i2c_regs;
+
+ if (chip == CONFIG_SYS_I2C_SLAVE)
+ return 1;
+
+ i2c_regs = i2c_dev[i2c_bus_num];
+
+ /* Set the address mode to 7 bit */
+ WRITE_FIELD(mcr, I2C_MCR_AM, I2C_MCR_SHIFT_AM, 1);
+
+ /* Store the slave address in the master control register */
+ WRITE_FIELD(mcr, I2C_MCR_A10, I2C_MCR_SHIFT_A7, chip);
+
+ /* Read operation */
+ SET_BIT(mcr, I2C_MCR_OP);
+
+ /* Set the frame length to one byte */
+ WRITE_FIELD(mcr, I2C_MCR_LENGTH, I2C_MCR_SHIFT_LENGTH, 1);
+
+ /* Current transaction is terminated by STOP condition */
+ SET_BIT(mcr, I2C_MCR_STOP);
+
+ /* Write MCR register */
+ writel(mcr, &i2c_regs->mcr);
+
+ /* Wait until the Rx Fifo is not empty */
+ if (loop_till_bit_clear((void *)&i2c_regs->risr, I2C_INT_RXFE,
+ I2C_ENDAD_COUNTER)) {
+ i2c_abort(i2c_regs);
+ return -1;
+ }
+
+ flush_fifo(i2c_regs);
+
+ /* Acknowledge the Master Transaction Done */
+ i2c_set_bit(&i2c_regs->icr, I2C_INT_MTD);
+
+ /* Acknowledge the Master Transaction Done Without Stop */
+ i2c_set_bit(&i2c_regs->icr, I2C_INT_MTDWS);
+
+ return 0;
+}
+
+/*
+ * Read/Write interface:
+ * chip: I2C chip address, range 0..127
+ * addr: Memory (register) address within the chip
+ * alen: Number of bytes to use for addr (typically 1, 2 for larger
+ * memories, 0 for register type devices with only one
+ * register)
+ * buffer: Where to read/write the data
+ * len: How many bytes to read/write
+ *
+ * Returns: 0 on success, not 0 on failure
+ */
+int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
+{
+ int i;
+ int rc;
+ struct u5500_i2c_regs *i2c_regs;
+
+ if (alen > 2) {
+ debug("I2C read: addr len %d not supported\n", alen);
+ return 1;
+ }
+
+ i2c_regs = i2c_dev[i2c_bus_num];
+
+ for (i = 0; i < len; i++) {
+ rc = i2c_read_byte(i2c_regs, chip, addr + i, alen, &buffer[i]);
+ if (rc != 0) {
+ debug("I2C read: I/O error: %d\n", rc);
+ i2c_abort(i2c_regs);
+ return rc;
+ }
+ }
+
+ return 0;
+}
+
+int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
+{
+ int rc;
+ struct u5500_i2c_regs *i2c_regs;
+ i2c_regs = i2c_dev[i2c_bus_num];
+
+ rc = __i2c_write(i2c_regs, chip, addr, alen, buffer,
+ len);
+ if (rc != 0) {
+ debug("I2C write: I/O error\n");
+ i2c_abort(i2c_regs);
+ return rc;
+ }
+ return 0;
+}
+
+int i2c_set_bus_num(unsigned int bus)
+{
+ if (bus > ARRAY_SIZE(i2c_dev) - 1) {
+ debug("i2c_set_bus_num: only up to bus %d supported\n",
+ ARRAY_SIZE(i2c_dev)-1);
+ return -1;
+ }
+
+ i2c_bus_num = bus;
+
+ if (!bus_initialized[i2c_bus_num])
+ i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+
+ return 0;
+}
+
+int i2c_set_bus_speed(unsigned int speed)
+{
+
+ if (speed > I2C_MAX_STANDARD_SCL) {
+ debug("i2c_set_bus_speed: only up to %d supported\n",
+ I2C_MAX_STANDARD_SCL);
+ return -1;
+ }
+
+ /* sets as side effect i2c_bus_speed[i2c_bus_num] */
+ i2c_init(speed, CONFIG_SYS_I2C_SLAVE);
+
+ return 0;
+}
+
+unsigned int i2c_get_bus_num(void)
+{
+ return i2c_bus_num;
+}
+
+unsigned int i2c_get_bus_speed(void)
+{
+ return i2c_bus_speed[i2c_bus_num];
+}
diff --git a/include/asm-arm/arch-db5500/common.h b/include/asm-arm/arch-db5500/common.h
index 138fb8e..de79023 100644
--- a/include/asm-arm/arch-db5500/common.h
+++ b/include/asm-arm/arch-db5500/common.h
@@ -71,5 +71,6 @@
/* function prototypes */
int board_early_access(block_dev_desc_t *block_dev);
+void backlight_init(void);
#endif /* _DB5500_COMMON_H_ */
diff --git a/include/configs/u5500.h b/include/configs/u5500.h
index 3604df5..d45e10c 100644
--- a/include/configs/u5500.h
+++ b/include/configs/u5500.h
@@ -96,6 +96,7 @@
#define CONFIG_CMD_TOC
#define CONFIG_CMD_DATE
#define CONFIG_CMD_KEYPAD_DETECT
+#define CONFIG_CMD_I2C
#define CONFIG_RTC_PL031_ST
#define CONFIG_SYS_RTC_PL031_BASE U5500_RTC_BASE
@@ -195,6 +196,22 @@
#endif
/*-----------------------------------------------------------------------
+ * I2C
+ */
+#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C_SPEED 100000
+#define CONFIG_SYS_I2C_SLAVE 0 /* slave addr of controller */
+#define CONFIG_SYS_I2C0_BASE U5500_PRCMU_BASE /* I2C0 is used for PRCMU */
+#define CONFIG_SYS_I2C1_BASE U5500_I2C1_BASE
+#define CONFIG_SYS_I2C2_BASE U5500_I2C2_BASE
+#define CONFIG_SYS_I2C3_BASE U5500_I2C3_BASE
+#define CONFIG_SYS_I2C_BUS_MAX 4
+
+#define CONFIG_SYS_I2C_GPIOE_ADDR 0x42 /* GPIO expander chip addr */
+#define CONFIG_TC35892_GPIO
+
+
+/*-----------------------------------------------------------------------
* Physical Memory Map
*/
#define CONFIG_NR_DRAM_BANKS 1