Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 1 | /* |
| 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 Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 14 | */ |
| 15 | #include <cbfs.h> |
| 16 | #include <console/console.h> |
| 17 | #include <string.h> |
Ben Gardner | fa6014a | 2015-12-08 21:20:25 -0600 | [diff] [blame] | 18 | #include "soc/gpio.h" |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 19 | #include "lcd_panel.h" |
| 20 | #include "ptn3460.h" |
| 21 | |
Werner Zeh | bf13d3f | 2016-04-25 12:24:17 +0200 | [diff] [blame] | 22 | |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 23 | /** \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 | */ |
| 27 | u8 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 Menzel | e8e219d | 2016-05-07 08:27:54 +0200 | [diff] [blame] | 39 | /** \brief Set up LCD panel |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 40 | * @param no parameters |
| 41 | * @return 0 on success otherwise error value |
| 42 | */ |
| 43 | int setup_lcd_panel(void) |
| 44 | { |
Werner Zeh | bf13d3f | 2016-04-25 12:24:17 +0200 | [diff] [blame] | 45 | u8 lcd_type; |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 46 | int status; |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 47 | char blockname[33]; |
| 48 | |
| 49 | lcd_type = get_lcd_panel_type(); |
| 50 | printk(BIOS_INFO, "LCD: Found panel type %d\n", lcd_type); |
Paul Menzel | 7bb37ef | 2016-05-07 08:24:49 +0200 | [diff] [blame] | 51 | |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 52 | 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 Zeh | 70ca32e | 2016-05-09 08:14:45 +0200 | [diff] [blame] | 70 | return 1; |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 71 | break; |
| 72 | } |
Paul Menzel | 7bb37ef | 2016-05-07 08:24:49 +0200 | [diff] [blame] | 73 | |
Paul Menzel | e8e219d | 2016-05-07 08:27:54 +0200 | [diff] [blame] | 74 | /* Now that we have the panel type, set up the DP2LVDS converter */ |
Werner Zeh | bf13d3f | 2016-04-25 12:24:17 +0200 | [diff] [blame] | 75 | status = ptn3460_init(blockname); |
| 76 | if (status) |
| 77 | printk(BIOS_ERR, "LCD: Setup PTN with status 0x%x\n", status); |
| 78 | else |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 79 | printk(BIOS_INFO, "LCD: Setup PTN with status 0x%x\n", status); |
Werner Zeh | bf13d3f | 2016-04-25 12:24:17 +0200 | [diff] [blame] | 80 | |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 81 | return status; |
| 82 | } |