Skip to content

Commit

Permalink
mb/google/corsola: Use common mtk_display_init()
Browse files Browse the repository at this point in the history
TEST=check FW screen on Steelix, Tentacruel and Starmie

Change-Id: I429218d59389a6ab86b522dd597c07fa5b8ea821
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79777
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
  • Loading branch information
Yidi Lin authored and felixheld committed Jan 10, 2024
1 parent ba604b5 commit cb7c4fd
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 180 deletions.
2 changes: 1 addition & 1 deletion src/mainboard/google/corsola/Makefile.inc
Expand Up @@ -19,8 +19,8 @@ romstage-y += sdram_configs.c
ramstage-y += memlayout.ld
ramstage-y += boardid.c
ramstage-y += chromeos.c
ramstage-y += display.c
ramstage-y += mainboard.c
ramstage-y += panel.c
ramstage-y += panel_anx7625.c
ramstage-y += panel_ps8640.c
ramstage-y += regulator.c
Expand Down
2 changes: 1 addition & 1 deletion src/mainboard/google/corsola/boardid.c
Expand Up @@ -6,7 +6,7 @@
#include <ec/google/chromeec/ec.h>
#include <soc/auxadc.h>

#include "display.h"
#include "panel.h"

/* board_id is provided by ec/google/chromeec/ec_boardid.c */

Expand Down
131 changes: 0 additions & 131 deletions src/mainboard/google/corsola/display.c

This file was deleted.

5 changes: 3 additions & 2 deletions src/mainboard/google/corsola/mainboard.c
Expand Up @@ -6,13 +6,14 @@
#include <fw_config.h>
#include <gpio.h>
#include <soc/bl31.h>
#include <soc/display.h>
#include <soc/i2c.h>
#include <soc/msdc.h>
#include <soc/spm.h>
#include <soc/usb.h>

#include "display.h"
#include "gpio.h"
#include "panel.h"

static void configure_alc1019(void)
{
Expand Down Expand Up @@ -65,7 +66,7 @@ static void mainboard_init(struct device *dev)
register_reset_to_bl31(GPIO_RESET.id, true);

if (display_init_required()) {
if (configure_display() < 0)
if (mtk_display_init() < 0)
printk(BIOS_ERR, "%s: Failed to init display\n", __func__);
} else {
if (CONFIG(BOARD_GOOGLE_STARYU_COMMON)) {
Expand Down
54 changes: 54 additions & 0 deletions src/mainboard/google/corsola/panel.c
@@ -0,0 +1,54 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <boardid.h>
#include <cbfs.h>
#include <console/console.h>
#include <device/i2c_simple.h>
#include <edid.h>
#include <gpio.h>
#include <soc/ddp.h>
#include <soc/dsi.h>
#include <soc/gpio_common.h>
#include <soc/mtcmos.h>

#include "gpio.h"
#include "panel.h"

void aw37503_init(unsigned int bus)
{
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x00, 0x14, 0x1F, 0);
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x01, 0x14, 0x1F, 0);
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x21, 0x4C, 0xFF, 0);
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x03, 0x43, 0xFF, 0);
i2c_write_field(bus, PMIC_AW37503_SLAVE, 0x21, 0x00, 0xFF, 0);
}

bool is_pmic_aw37503(unsigned int bus)
{
u8 vendor_id;
return (!i2c_read_field(bus, PMIC_AW37503_SLAVE,
0x04, &vendor_id, 0x0F, 0) && vendor_id == 0x01);
}

void backlight_control(void)
{
/* Set up backlight control pins as output pin and power-off by default */
gpio_output(GPIO_AP_EDP_BKLTEN, 0);
gpio_output(GPIO_BL_PWM_1V8, 0);
}

struct panel_description *get_active_panel(void)
{
/* Board-specific exceptions */
if (CONFIG(BOARD_GOOGLE_STEELIX) && board_id() < 2) /* Early builds use PS8640 */
return get_ps8640_description();

if (CONFIG(DRIVER_ANALOGIX_ANX7625))
return get_anx7625_description();

if (CONFIG(DRIVER_PARADE_PS8640))
return get_ps8640_description();

/* MIPI panels */
return get_panel_description();
}
Expand Up @@ -3,26 +3,17 @@
#ifndef __MAINBOARD_GOOGLE_CORSOLA_DISPLAY_H__
#define __MAINBOARD_GOOGLE_CORSOLA_DISPLAY_H__

#include <edid.h>
#include <mipi/panel.h>
#include <soc/display.h>
#include <soc/i2c.h>

#define BRIDGE_I2C I2C0
#define PMIC_AW37503_SLAVE 0x3E
#define PMIC_I2C_BUS I2C6

struct panel_description {
void (*power_on)(void); /* Callback to turn on panel */
int (*post_power_on)(u8 i2c_bus, struct edid *edid);
const char *name; /* Panel name in CBFS */
struct panel_serializable_data *s;
enum lb_fb_orientation orientation;
};

void aw37503_init(unsigned int bus);
bool is_pmic_aw37503(unsigned int bus);
int configure_display(void);
uint32_t panel_id(void);
void backlight_control(void);

/* Return the mipi panel description from given panel id */
struct panel_description *get_panel_description(void);
Expand All @@ -33,7 +24,4 @@ struct panel_description *get_anx7625_description(void);
/* Return the PS8640 bridge description */
struct panel_description *get_ps8640_description(void);

/* Load panel serializable data from CBFS */
struct panel_description *get_panel_from_cbfs(struct panel_description *desc);

#endif
29 changes: 16 additions & 13 deletions src/mainboard/google/corsola/panel_anx7625.c
Expand Up @@ -7,8 +7,8 @@
#include <gpio.h>
#include <soc/i2c.h>

#include "display.h"
#include "gpio.h"
#include "panel.h"

static void bridge_anx7625_power_on(void)
{
Expand All @@ -23,39 +23,42 @@ static void bridge_anx7625_power_on(void)
gpio_output(GPIO_EDPBRDG_RST_L, 1);
}

static int bridge_anx7625_get_edid(u8 i2c_bus, struct edid *edid)
static int bridge_anx7625_get_edid(struct edid *edid)
{
if (anx7625_init(i2c_bus) < 0) {
if (anx7625_init(BRIDGE_I2C) < 0) {
printk(BIOS_ERR, "%s: Can't init ANX7625 bridge\n", __func__);
return -1;
}
if (anx7625_dp_get_edid(i2c_bus, edid) < 0) {
if (anx7625_dp_get_edid(BRIDGE_I2C, edid) < 0) {
printk(BIOS_ERR, "%s: Can't get panel's edid\n", __func__);
return -1;
}
return 0;
}

static int bridge_anx7625_post_power_on(u8 i2c_bus, struct edid *edid)
static int bridge_anx7625_post_power_on(const struct edid *edid)
{
return anx7625_dp_start(i2c_bus, edid);
return anx7625_dp_start(BRIDGE_I2C, edid);
}

static struct panel_serializable_data anx7625_data;
static void panel_power_on(void)
{
/* Turn on the panel */
gpio_output(GPIO_EN_PP3300_DISP_X, 1);
bridge_anx7625_power_on();
}

static struct panel_description anx7625_bridge = {
.s = &anx7625_data,
.configure_backlight = backlight_control,
.power_on = panel_power_on,
.get_edid = bridge_anx7625_get_edid,
.post_power_on = bridge_anx7625_post_power_on,
.disp_path = DISP_PATH_MIPI,
.orientation = LB_FB_ORIENTATION_NORMAL,
};

struct panel_description *get_anx7625_description(void)
{
mtk_i2c_bus_init(BRIDGE_I2C, I2C_SPEED_FAST);
bridge_anx7625_power_on();
if (bridge_anx7625_get_edid(BRIDGE_I2C, &anx7625_bridge.s->edid) < 0) {
printk(BIOS_ERR, "Can't get panel's edid\n");
return NULL;
}
return &anx7625_bridge;
}
27 changes: 15 additions & 12 deletions src/mainboard/google/corsola/panel_ps8640.c
Expand Up @@ -8,8 +8,8 @@
#include <soc/i2c.h>
#include <soc/regulator.h>

#include "display.h"
#include "gpio.h"
#include "panel.h"

static void bridge_ps8640_power_on(void)
{
Expand Down Expand Up @@ -45,35 +45,38 @@ static void bridge_ps8640_power_on(void)
gpio_output(GPIO_EDPBRDG_RST_L, 1);
}

static int bridge_ps8640_get_edid(u8 i2c_bus, struct edid *edid)
static void panel_power_on(void)
{
/* Turn on the panel */
gpio_output(GPIO_EN_PP3300_DISP_X, 1);
bridge_ps8640_power_on();
}

static int bridge_ps8640_get_edid(struct edid *edid)
{
const u8 chip = 0x8;

if (ps8640_init(i2c_bus, chip) < 0) {
if (ps8640_init(BRIDGE_I2C, chip) < 0) {
printk(BIOS_ERR, "%s: Can't init PS8640 bridge\n", __func__);
return -1;
}
if (ps8640_get_edid(i2c_bus, chip, edid) < 0) {
if (ps8640_get_edid(BRIDGE_I2C, chip, edid) < 0) {
printk(BIOS_ERR, "%s: Can't get panel's edid\n", __func__);
return -1;
}
return 0;
}

static struct panel_serializable_data ps8640_data;

static struct panel_description ps8640_bridge = {
.s = &ps8640_data,
.configure_backlight = backlight_control,
.power_on = panel_power_on,
.get_edid = bridge_ps8640_get_edid,
.disp_path = DISP_PATH_MIPI,
.orientation = LB_FB_ORIENTATION_NORMAL,
};

struct panel_description *get_ps8640_description(void)
{
mtk_i2c_bus_init(BRIDGE_I2C, I2C_SPEED_FAST);
bridge_ps8640_power_on();
if (bridge_ps8640_get_edid(BRIDGE_I2C, &ps8640_bridge.s->edid) < 0) {
printk(BIOS_ERR, "Can't get panel's edid\n");
return NULL;
}
return &ps8640_bridge;
}

0 comments on commit cb7c4fd

Please sign in to comment.