blob: f48bd56386c00ca32867db8d814a39ab687d740e [file] [log] [blame]
Werner Zehc42a6132015-02-12 12:40:15 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Siemens AG
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Werner Zehc42a6132015-02-12 12:40:15 +010014 */
15#include <cbfs.h>
16#include <console/console.h>
17#include <string.h>
Ben Gardnerfa6014a2015-12-08 21:20:25 -060018#include "soc/gpio.h"
Werner Zehc42a6132015-02-12 12:40:15 +010019#include "lcd_panel.h"
20#include "ptn3460.h"
21
Werner Zehbf13d3f2016-04-25 12:24:17 +020022
Werner Zehc42a6132015-02-12 12:40:15 +010023/** \brief Reads GPIOs used for LCD panel encoding and returns the 4 bit value
24 * @param no parameters
25 * @return LCD panel type encoded in 4 bits
26 */
27u8 get_lcd_panel_type(void)
28{
29 u8 lcd_type_gpio;
30
31 lcd_type_gpio = ((read_ssus_gpio(LCD_TYPE_GPIO_BIT3) << 3) |
32 (read_ssus_gpio(LCD_TYPE_GPIO_BIT2) << 2) |
33 (read_ssus_gpio(LCD_TYPE_GPIO_BIT1) << 1) |
34 (read_ssus_gpio(LCD_TYPE_GPIO_BIT0)));
35 /* There is an inverter in this signals so we need to invert them as well */
36 return ((~lcd_type_gpio) & 0x0f);
37}
38
Paul Menzele8e219d2016-05-07 08:27:54 +020039/** \brief Set up LCD panel
Werner Zehc42a6132015-02-12 12:40:15 +010040 * @param no parameters
41 * @return 0 on success otherwise error value
42 */
43int setup_lcd_panel(void)
44{
Werner Zehbf13d3f2016-04-25 12:24:17 +020045 u8 lcd_type;
Werner Zehc42a6132015-02-12 12:40:15 +010046 int status;
Werner Zehc42a6132015-02-12 12:40:15 +010047 char blockname[33];
48
49 lcd_type = get_lcd_panel_type();
50 printk(BIOS_INFO, "LCD: Found panel type %d\n", lcd_type);
Paul Menzel7bb37ef2016-05-07 08:24:49 +020051
Werner Zehc42a6132015-02-12 12:40:15 +010052 switch (lcd_type) {
53 case LCD_PANEL_TYPE_10_INCH:
54 strcpy(blockname, "hwinfo10.hex");
55 break;
56 case LCD_PANEL_TYPE_12_INCH:
57 strcpy(blockname, "hwinfo12.hex");
58 break;
59 case LCD_PANEL_TYPE_15_INCH:
60 strcpy(blockname, "hwinfo15.hex");
61 break;
62 case LCD_PANEL_TYPE_19_INCH:
63 strcpy(blockname, "hwinfo19.hex");
64 break;
65 case LCD_PANEL_TYPE_EDID:
66 strcpy(blockname, "hwinfo.hex");
67 break;
68 default:
69 printk(BIOS_ERR, "LCD: No supported panel found.\n");
Werner Zeh70ca32e2016-05-09 08:14:45 +020070 return 1;
Werner Zehc42a6132015-02-12 12:40:15 +010071 break;
72 }
Paul Menzel7bb37ef2016-05-07 08:24:49 +020073
Paul Menzele8e219d2016-05-07 08:27:54 +020074 /* Now that we have the panel type, set up the DP2LVDS converter */
Werner Zehbf13d3f2016-04-25 12:24:17 +020075 status = ptn3460_init(blockname);
76 if (status)
77 printk(BIOS_ERR, "LCD: Setup PTN with status 0x%x\n", status);
78 else
Werner Zehc42a6132015-02-12 12:40:15 +010079 printk(BIOS_INFO, "LCD: Setup PTN with status 0x%x\n", status);
Werner Zehbf13d3f2016-04-25 12:24:17 +020080
Werner Zehc42a6132015-02-12 12:40:15 +010081 return status;
82}