summaryrefslogtreecommitdiff
path: root/board/st/u8500/mcde_display.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/st/u8500/mcde_display.c')
-rw-r--r--board/st/u8500/mcde_display.c163
1 files changed, 142 insertions, 21 deletions
diff --git a/board/st/u8500/mcde_display.c b/board/st/u8500/mcde_display.c
index 40f7570d6..b3116a03c 100644
--- a/board/st/u8500/mcde_display.c
+++ b/board/st/u8500/mcde_display.c
@@ -21,6 +21,7 @@
#include <asm/arch/ab8500.h>
#include "common.h"
+
#ifdef CONFIG_SYS_VIDEO_USE_GIMP_HEADER
#include <asm/arch/mcde_video_logo_gimp.h>
#else
@@ -50,7 +51,7 @@ static struct mcde_port port0 = {
struct mcde_display_generic_platform_data main_display_data = {
.reset_gpio = TC35892_PIN_KPY7,
- .reset_delay = 1,
+ .reset_delay = 10,
};
struct mcde_display_device main_display = {
@@ -59,8 +60,8 @@ struct mcde_display_device main_display = {
.fifo = MCDE_FIFO_A,
.default_pixel_format = MCDE_OVLYPIXFMT_RGB565,
.port_pixel_format = MCDE_PORTPIXFMT_DSI_24BPP,
- .native_x_res = 864,
- .native_y_res = 480,
+ .native_x_res = CONFIG_SYS_DISPLAY_NATIVE_X_RES,
+ .native_y_res = CONFIG_SYS_DISPLAY_NATIVE_Y_RES,
};
static int mcde_enable_gpio(void)
@@ -116,9 +117,10 @@ static int mcde_turn_on_display(void)
return ret;
}
-#define LDO_VAUX1_MASK 0x1
-#define LDO_VAUX1_ENABLE 0x1
-#define VAUX1_VOLTAGE_2_5V 0x08
+/* aux supplies */
+#define MASK_LDO_VAUX1 (0x3)
+#define MASK_LDO_VAUX1_SHIFT (0x0)
+#define VAUXSEL_VOLTAGE_MASK (0xf)
#define VANA_ENABLE_IN_HP_MODE 0x05
@@ -126,45 +128,165 @@ static int mcde_turn_on_display(void)
#define PWM_DUTY_LOW_1024_1024 0xFF
#define PWM_DUTY_HI_1024_1024 0x03
+/*
+ * regulator layout
+ * @voltage: supported voltage
+ * @regval: register value to be written
+ */
+struct regulator_voltage {
+ int voltage;
+ int regval;
+};
+
+/* voltage table for VAUXn regulators */
+static struct regulator_voltage vauxn_table[] = {
+ { .voltage = 1100000, .regval = 0x0, },
+ { .voltage = 1200000, .regval = 0x1, },
+ { .voltage = 1300000, .regval = 0x2, },
+ { .voltage = 1400000, .regval = 0x3, },
+ { .voltage = 1500000, .regval = 0x4, },
+ { .voltage = 1800000, .regval = 0x5, },
+ { .voltage = 1850000, .regval = 0x6, },
+ { .voltage = 1900000, .regval = 0x7, },
+ { .voltage = 2500000, .regval = 0x8, },
+ { .voltage = 2650000, .regval = 0x9, },
+ { .voltage = 2700000, .regval = 0xa, },
+ { .voltage = 2750000, .regval = 0xb, },
+ { .voltage = 2800000, .regval = 0xc, },
+ { .voltage = 2900000, .regval = 0xd, },
+ { .voltage = 3000000, .regval = 0xe, },
+ { .voltage = 3300000, .regval = 0xf, },
+};
+
+
+/*
+ * This code is derived from the handling of AB8500_LDO_VAUX1 in
+ * ab8500_ldo_is_enabled in Linux.
+ */
+static int mcde_is_vaux1_enabled(void)
+{
+ int val;
+ val = ab8500_read(AB8500_REGU_CTRL2,
+ AB8500_REGU_VAUX12_REGU_REG);
+ if (val & MASK_LDO_VAUX1)
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * This code is derived from the handling of AB8500_LDO_VAUX1 in
+ * ab8500_ldo_get_voltage in Linux.
+ */
+static int mcde_get_vaux1_voltage(void)
+{
+ int val;
+ val = ab8500_read(AB8500_REGU_CTRL2,
+ AB8500_REGU_VAUX1_SEL_REG);
+ return vauxn_table[val & VAUXSEL_VOLTAGE_MASK].voltage;
+}
+
static int mcde_display_power_init(void)
{
- int ret;
int val;
+ int i;
+ int ret;
if (!cpu_is_u8500v11())
return 0;
- /* Vaux12Regu */
- ret = ab8500_read(AB8500_REGU_CTRL2, AB8500_REGU_VAUX12_REGU_REG);
- if (ret < 0)
+ /*
+ * On v1.1 HREF boards (HREF+), Vaux1 needs to be enabled for the
+ * display to work. This is done by enabling the regulators in the
+ * AB8500 via PRCMU I2C transactions.
+ *
+ * This code is derived from the handling of AB8500_LDO_VAUX1 in
+ * ab8500_ldo_enable(), ab8500_ldo_disable() and
+ * ab8500_get_best_voltage in Linux.
+ *
+ * Turn off and delay is required to have it work across soft reboots.
+ */
+
+ ret = ab8500_read(AB8500_REGU_CTRL2,
+ AB8500_REGU_VAUX12_REGU_REG);
+ if (ret < 0) {
+ printf("Read vaux1 status failed\n");
goto out;
+ }
val = ret;
- /* Vaux1 & Vaux2 HP mode */
+ /* Turn off */
ret = ab8500_write(AB8500_REGU_CTRL2, AB8500_REGU_VAUX12_REGU_REG,
- val | LDO_VAUX1_ENABLE);
- if (ret < 0)
+ val & ~MASK_LDO_VAUX1);
+ if (ret < 0) {
+ printf("Turn off Vaux1 failed\n");
goto out;
+ }
udelay(10 * 1000);
- /* Set the voltage to 2.5V */
+
+ /* Find voltage from vauxn table */
+ for (i = 0; i < ARRAY_SIZE(vauxn_table) ; i++) {
+ if (vauxn_table[i].voltage == CONFIG_SYS_DISPLAY_VOLTAGE) {
+ ret = ab8500_write(AB8500_REGU_CTRL2,
+ AB8500_REGU_VAUX1_SEL_REG,
+ vauxn_table[i].regval);
+ if (ret < 0) {
+ printf("AB8500_REGU_VAUX1_SEL_REG failed\n");
+ goto out;
+ }
+ break;
+ }
+ }
+
+ val = val & ~MASK_LDO_VAUX1;
+ val = val | (1 << MASK_LDO_VAUX1_SHIFT);
+
+ /* Turn on the supply */
ret = ab8500_write(AB8500_REGU_CTRL2,
- AB8500_REGU_VAUX1_SEL_REG, VAUX1_VOLTAGE_2_5V);
- if (ret < 0)
+ AB8500_REGU_VAUX12_REGU_REG, val);
+ if (ret < 0) {
+ printf("Turn on Vaux1 failed\n");
goto out;
+ }
/* DCI & CSI (DSI / PLL / Camera) */ /* Vana & Vpll HP mode */
- ab8500_write(AB8500_REGU_CTRL2, AB8500_REGU_VPLLVANA_REGU_REG,
+ ret = ab8500_write(AB8500_REGU_CTRL2, AB8500_REGU_VPLLVANA_REGU_REG,
VANA_ENABLE_IN_HP_MODE);
+ if (ret < 0) {
+ printf("Turn on Vana failed\n");
+ goto out;
+ }
/* Enable the PWM control for the backlight Main display */
- ab8500_write(AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG, ENABLE_PWM1);
- ab8500_write(AB8500_MISC, AB8500_PWM_OUT_CTRL1_REG,
+ ret = ab8500_write(AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG, ENABLE_PWM1);
+ if (ret < 0) {
+ printf("Enable PWM1 failed\n");
+ goto out;
+ }
+ ret = ab8500_write(AB8500_MISC, AB8500_PWM_OUT_CTRL1_REG,
PWM_DUTY_LOW_1024_1024);
- ab8500_write(AB8500_MISC, AB8500_PWM_OUT_CTRL2_REG,
+ if (ret < 0) {
+ printf("PWM_DUTY_LOW_1024_1024 failed\n");
+ goto out;
+ }
+ ret = ab8500_write(AB8500_MISC, AB8500_PWM_OUT_CTRL2_REG,
PWM_DUTY_HI_1024_1024);
+ if (ret < 0) {
+ printf("PWM_DUTY_HI_1024_1024 failed\n");
+ goto out;
+ }
+
+ if (!mcde_is_vaux1_enabled() || mcde_get_vaux1_voltage()
+ != CONFIG_SYS_DISPLAY_VOLTAGE) {
+ printf("VAUX is %d and is set to %d V should be %d\n"
+ , mcde_is_vaux1_enabled(), mcde_get_vaux1_voltage()
+ , CONFIG_SYS_DISPLAY_VOLTAGE);
+ return -EINVAL;
+ }
+
+ return 0;
out:
return ret;
}
@@ -174,7 +296,6 @@ int mcde_startup(void)
{
u8 num_dsilinks;
int ret;
- u32 i;
num_dsilinks = main_display.port->phy.dsi.num_data_lanes;
mcde_init(num_dsilinks);