blob: 214773aa2683f6c89214c7deca298b6e1a97a7dd [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
39/** \brief Setup LCD panel
40 * @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);
51 switch (lcd_type) {
52 case LCD_PANEL_TYPE_10_INCH:
53 strcpy(blockname, "hwinfo10.hex");
54 break;
55 case LCD_PANEL_TYPE_12_INCH:
56 strcpy(blockname, "hwinfo12.hex");
57 break;
58 case LCD_PANEL_TYPE_15_INCH:
59 strcpy(blockname, "hwinfo15.hex");
60 break;
61 case LCD_PANEL_TYPE_19_INCH:
62 strcpy(blockname, "hwinfo19.hex");
63 break;
64 case LCD_PANEL_TYPE_EDID:
65 strcpy(blockname, "hwinfo.hex");
66 break;
67 default:
68 printk(BIOS_ERR, "LCD: No supported panel found.\n");
69 status = 1;
70 break;
71 }
Werner Zehbf13d3f2016-04-25 12:24:17 +020072 /* Now that we have the panel type, setup the DP2LVDS converter */
73 status = ptn3460_init(blockname);
74 if (status)
75 printk(BIOS_ERR, "LCD: Setup PTN with status 0x%x\n", status);
76 else
Werner Zehc42a6132015-02-12 12:40:15 +010077 printk(BIOS_INFO, "LCD: Setup PTN with status 0x%x\n", status);
Werner Zehbf13d3f2016-04-25 12:24:17 +020078
Werner Zehc42a6132015-02-12 12:40:15 +010079 return status;
80}