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 | |
| 39 | /** \brief Setup LCD panel |
| 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); |
| 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 Zeh | bf13d3f | 2016-04-25 12:24:17 +0200 | [diff] [blame^] | 72 | /* 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 Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 77 | printk(BIOS_INFO, "LCD: Setup PTN with status 0x%x\n", status); |
Werner Zeh | bf13d3f | 2016-04-25 12:24:17 +0200 | [diff] [blame^] | 78 | |
Werner Zeh | c42a613 | 2015-02-12 12:40:15 +0100 | [diff] [blame] | 79 | return status; |
| 80 | } |