Patchwork The function int15 working on the Technexion's tim5690.

login
register
about
Submitter Libra Li
Date 2009-12-22 09:38:52
Message ID <df21912a0912220138r2dbc2723re4e4996bd5dac953@mail.gmail.com>
Download mbox | patch
Permalink /patch/688/
State Accepted
Headers show

Comments

Libra Li - 2009-12-22 09:38:52
Hi Marc Jones,

    This is a new patch file. I modified mainboard_interrupt_handlers and
setup_interrupt_handlers in the "util/x86emu/x86.c".

    Thanks.
    Libra.


2009/12/22 Libra Li <librali1977@gmail.com>

> Hi Marc Jones,
>
>     1.
>         +typedef struct {
>         +        int mask[256];
>         +        int (*intXX_handler[256])(struct eregs *regs);
>         +}interrupt_handlers;
>
>         The mainboard_interrupt_handlers need modification if the
> structure is not needed.
>
>     2.
>         +       if(!(*intXX_handler))
>
>         +       {
>         +               /* Set up C interrupt handlers */
>         +               setup_interrupt_handlers();
>         +       }
>
>         Yes, this is because mainboard_interrupt_handlers gets called
> first.
>
>
> 2009/12/22 Marc Jones <marcj303@gmail.com>
>
> On Mon, Dec 21, 2009 at 6:15 PM, Libra Li <librali1977@gmail.com> wrote:
>> > Hi,
>> >
>> >     The VGA BIOS is through int15 getting LCD panel ID. Then the VBIOS
>> call
>> > int15's "Get LCD panel ID".
>> >     The panel ID is selection by switch.
>> >     This function is reference "AMD RS690 ASIC Family BIOS Developer's
>> > Guide".
>> >
>> >     Thanks.
>> >
>> >     Signed-off-by: Libra Li <libra.li@technexion.com>
>>
>> Hi Libra Li,
>>
>> Thanks for making these changes. I like the idea of the mainboard
>> interrupt function. I have a few comments.
>>
>> +typedef struct {
>> +        int mask[256];
>> +        int (*intXX_handler[256])(struct eregs *regs);
>> +}interrupt_handlers;
>>
>> This is a really big structure and probably not needed. I don't think
>> anyone would override every interrupt vector, just one or two like you
>> are doing. Maybe just use a table that has the interrupt and function
>> pointer.
>>
>>
>> +       if(!(*intXX_handler))
>> +       {
>> +               /* Set up C interrupt handlers */
>> +               setup_interrupt_handlers();
>> +       }
>> +
>>
>> Is this because mainboard_interrupt_handlers gets called first and the
>> interrupts are over written? It would be better if the defaults could
>> always be loaded and then the main board interrupts get fixed up.
>>
>> Thanks,
>> Marc
>>
>>
>> --
>> http://marcjonesconsulting.com
>>
>
>
Marc Jones - 2009-12-23 19:17:29
On Tue, Dec 22, 2009 at 2:38 AM, Libra Li <librali1977@gmail.com> wrote:
> Hi Marc Jones,
>
>     This is a new patch file. I modified mainboard_interrupt_handlers and
> setup_interrupt_handlers in the "util/x86emu/x86.c".
>

Hi Libra,

This looks good and passes abuild.

Acked-by: Marc Jones <marcj303@gmail.com>

r4990

Marc

Patch

Index: src/mainboard/technexion/tim5690/vgabios.h
===================================================================
--- src/mainboard/technexion/tim5690/vgabios.h	(revision 0)
+++ src/mainboard/technexion/tim5690/vgabios.h	(revision 0)
@@ -0,0 +1,37 @@ 
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2009 coresystems GmbH
+ * Copyright (C) 2009 Libra Li <libra.li@technexion.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+/* AMD Chipset */
+#define AMD_RS690_INT15 0x4E08
+
+typedef struct __rs690_int15_regs__
+{
+        u8 fun00_panel_id;      // Callback Sub-Function 00h - Get LCD Panel ID
+        u8 fun05_tv_standard;   // Callback Sub-Function 05h - Select Boot-up TV Standard
+}rs690_int15_regs;
+
+typedef struct __rs690_vbios_regs__
+{
+        rs690_int15_regs        int15_regs;
+}rs690_vbios_regs;
+
+/* Initialization VBIOS function */
+extern void vgabios_init(rs690_vbios_regs *vbios_regs);
Index: src/mainboard/technexion/tim5690/Makefile.inc
===================================================================
--- src/mainboard/technexion/tim5690/Makefile.inc	(revision 4981)
+++ src/mainboard/technexion/tim5690/Makefile.inc	(working copy)
@@ -33,6 +33,7 @@ 
 obj-y += tn_post_code.o
 
 obj-y += speaker.o
+obj-y += vgabios.o
 
 # This is part of the conversion to init-obj and away from included code.
 
Index: src/mainboard/technexion/tim5690/cache_as_ram_auto.c
===================================================================
--- src/mainboard/technexion/tim5690/cache_as_ram_auto.c	(revision 4981)
+++ src/mainboard/technexion/tim5690/cache_as_ram_auto.c	(working copy)
@@ -145,20 +145,6 @@ 
 }
 #endif				/* CONFIG_USE_FALLBACK_IMAGE == 1 */
 
-/* Early mainboard specific GPIO setup. */
-static void mb_gpio_init(void)
-{
-	/* Init Super I/O GPIOs. Done early. */
-	it8712f_enter_conf();
-	outb(IT8712F_CONFIG_REG_LDN, SIO_INDEX);
-	outb(IT8712F_GPIO, SIO_DATA);
-	outb(0x62, SIO_INDEX); // set Simple I/O Base Address 0x200
-	outb(0x02, SIO_DATA);
-	outb(0x63, SIO_INDEX);
-	outb(0x00, SIO_DATA);
-	it8712f_exit_conf();
-}
-
 void real_main(unsigned long bist, unsigned long cpu_init_detectedx);
 
 void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx)
@@ -191,7 +177,6 @@ 
 
 	/* it8712f_enable_serial does not use its 1st parameter. */
 	it8712f_enable_serial(0, CONFIG_TTYS0_BASE);
-	mb_gpio_init();
 	it8712f_kill_watchdog();
 	uart_init();
 	console_init();
Index: src/mainboard/technexion/tim5690/vgabios.c
===================================================================
--- src/mainboard/technexion/tim5690/vgabios.c	(revision 0)
+++ src/mainboard/technexion/tim5690/vgabios.c	(revision 0)
@@ -0,0 +1,77 @@ 
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2009 coresystems GmbH
+ * Copyright (C) 2009 Libra Li <libra.li@technexion.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <console/console.h>
+#include <arch/interrupt.h>
+#include "vgabios.h"
+
+
+int tim5690_int15_handler(struct eregs *regs);
+
+static rs690_vbios_regs vbios_regs_local;
+
+/* Initialization interrupt function */
+static void vbios_fun_init(rs690_vbios_regs *vbios_regs)
+{
+        vbios_regs_local.int15_regs.fun00_panel_id = vbios_regs->int15_regs.fun00_panel_id;
+        vbios_regs_local.int15_regs.fun05_tv_standard = vbios_regs->int15_regs.fun05_tv_standard;
+}
+/* BIOS int15 function */
+int tim5690_int15_handler(struct eregs *regs)
+{
+        int res = -1;
+
+        printk(BIOS_DEBUG, "tim5690_int15_handler\n");
+
+        switch (regs->eax & 0xffff) {
+        case AMD_RS690_INT15:
+                switch (regs->ebx & 0xff) {
+                case 0x00:
+                        regs->eax &= ~(0xff);
+                        regs->ebx = (regs->ebx & ~(0xff)) | vbios_regs_local.int15_regs.fun00_panel_id;
+                        res = 0;
+                        break;
+                case 0x05:
+                        regs->eax &= ~(0xff);
+                        regs->ebx = (regs->ebx & ~(0xff)) | vbios_regs_local.int15_regs.fun05_tv_standard;
+                        res = 0;
+                        break;
+                }
+                break;
+        default:
+                printk(BIOS_DEBUG, "Unknown INT15 function %04x!\n",
+                                regs->eax & 0xffff);
+		break;
+        }
+
+        return res;
+}
+
+/* Initialization VBIOS function */
+void vgabios_init(rs690_vbios_regs *vbios_regs)
+{
+	printk(BIOS_DEBUG, "vgabios_init\n");
+
+	mainboard_interrupt_handlers(0x15, &tim5690_int15_handler);
+	vbios_fun_init(vbios_regs);
+}
Index: src/mainboard/technexion/tim5690/mainboard.c
===================================================================
--- src/mainboard/technexion/tim5690/mainboard.c	(revision 4981)
+++ src/mainboard/technexion/tim5690/mainboard.c	(working copy)
@@ -26,13 +26,56 @@ 
 #include <cpu/amd/mtrr.h>
 #include <device/pci_def.h>
 #include <../southbridge/amd/sb600/sb600.h>
+#include <../superio/ite/it8712f/it8712f.h>
 #include "chip.h"
 #include "tn_post_code.h"
+#include "vgabios.h"
 
 #define ADT7461_ADDRESS 0x4C
 #define ARA_ADDRESS     0x0C /* Alert Response Address */
 #define SMBUS_IO_BASE 0x1000
 
+
+/* Video BIOS Function Extensions Specification
+ */
+//Callback Sub-Function 00h - Get LCD Panel ID
+#define LCD_PANEL_ID_NO 0x00	/* No LCD */
+#define LCD_PANEL_ID_01 0x01	/* 1024x768, 24 bits, 1 channel */
+#define LCD_PANEL_ID_02 0x02	/* 1280x1024, 24 bits, 2 channels */
+#define LCD_PANEL_ID_03 0x03	/* 1440x900, 24 bits, 2 channels */
+#define LCD_PANEL_ID_04 0x04	/* 1680x1050, 24 bits, 2 channels */
+#define LCD_PANEL_ID_05 0x05	/* 1920x1200, 24 bits, 2 channels */
+#define LCD_PANEL_ID_06 0x06	/* 1920x1080, 24 bits, 2 channels */
+//Callback Sub-Function 05h – Select Boot-up TV Standard
+#define TV_MODE_00	0x00	/* NTSC */
+#define TV_MODE_01	0x01	/* PAL */
+#define TV_MODE_02	0x02	/* PALM */
+#define TV_MODE_03	0x03	/* PAL60 */
+#define TV_MODE_04	0x04	/* NTSCJ */
+#define TV_MODE_05	0x05	/* PALCN */
+#define TV_MODE_06	0x06	/* PALN */
+#define TV_MODE_09	0x09	/* SCART-RGB */
+#define TV_MODE_NO	0xff	/* No TV Support */
+
+
+/* The base address is 0x2e or 0x4e, depending on config bytes. */
+#define SIO_BASE                     0x2e
+#define SIO_INDEX                    SIO_BASE
+#define SIO_DATA                     SIO_BASE+1
+
+/* Global configuration registers. */
+#define IT8712F_CONFIG_REG_CC        0x02 /* Configure Control (write-only). */
+#define IT8712F_CONFIG_REG_LDN       0x07 /* Logical Device Number. */
+#define IT8712F_CONFIG_REG_CONFIGSEL 0x22 /* Configuration Select. */
+#define IT8712F_CONFIG_REG_CLOCKSEL  0x23 /* Clock Selection. */
+#define IT8712F_CONFIG_REG_SWSUSP    0x24 /* Software Suspend, Flash I/F. */
+#define IT8712F_CONFIG_REG_MFC       0x2a /* Multi-function control */
+#define IT8712F_CONFIG_REG_WATCHDOG  0x72 /* Watchdog control. */
+
+#define IT8712F_CONFIGURATION_PORT   0x2e /* Write-only. */
+#define IT8712F_SIMPLE_IO_BASE       0x200 /* Simple I/O base address */
+
+
 extern int do_smbus_read_byte(u32 smbus_io_base, u32 device, u32 address);
 extern int do_smbus_write_byte(u32 smbus_io_base, u32 device, u32 address,
 			       u8 val);
@@ -54,6 +97,36 @@ 
 uint64_t uma_memory_base, uma_memory_size;
 
 
+/* The content of IT8712F_CONFIG_REG_LDN (index 0x07) must be set to the
+   LDN the register belongs to, before you can access the register. */
+static void it8712f_sio_write(uint8_t ldn, uint8_t index, uint8_t value)
+{
+        outb(IT8712F_CONFIG_REG_LDN, SIO_BASE);
+        outb(ldn, SIO_DATA);
+        outb(index, SIO_BASE);
+        outb(value, SIO_DATA);
+}
+
+static void it8712f_enter_conf(void)
+{
+        /*  Enter the configuration state (MB PnP mode). */
+
+        /* Perform MB PnP setup to put the SIO chip at 0x2e. */
+        /* Base address 0x2e: 0x87 0x01 0x55 0x55. */
+        /* Base address 0x4e: 0x87 0x01 0x55 0xaa. */
+        outb(0x87, IT8712F_CONFIGURATION_PORT);
+        outb(0x01, IT8712F_CONFIGURATION_PORT);
+        outb(0x55, IT8712F_CONFIGURATION_PORT);
+        outb(0x55, IT8712F_CONFIGURATION_PORT);
+}
+
+static void it8712f_exit_conf(void)
+{
+        /* Exit the configuration state (MB PnP mode). */
+        it8712f_sio_write(0x00, IT8712F_CONFIG_REG_CC, 0x02);
+}
+
+
 /* set thermal config
  */
 static void set_thermal_config(void)
@@ -117,6 +190,48 @@ 
 	 */
 }
 
+/* Mainboard specific GPIO setup. */
+void mb_gpio_init(u16 *iobase)
+{
+        /* Init Super I/O GPIOs. */
+        it8712f_enter_conf();
+        outb(IT8712F_CONFIG_REG_LDN, SIO_INDEX);
+        outb(IT8712F_GPIO, SIO_DATA);
+        outb(0x62, SIO_INDEX); 
+        outb((*iobase >> 8), SIO_DATA);
+        outb(0x63, SIO_INDEX);
+        outb((*iobase & 0xff), SIO_DATA);
+        it8712f_exit_conf();
+}
+
+/* The LCD's panel id seletion. */
+void lcd_panel_id(rs690_vbios_regs *vbios_regs, u8 num_id)
+{
+	switch (num_id) {
+	case 0x1:
+		vbios_regs->int15_regs.fun00_panel_id = LCD_PANEL_ID_01;
+		break;
+	case 0x2:
+		vbios_regs->int15_regs.fun00_panel_id = LCD_PANEL_ID_02;
+		break;
+	case 0x3:
+		vbios_regs->int15_regs.fun00_panel_id = LCD_PANEL_ID_03;
+		break;
+	case 0x4:
+		vbios_regs->int15_regs.fun00_panel_id = LCD_PANEL_ID_04;
+		break;
+	case 0x5:
+		vbios_regs->int15_regs.fun00_panel_id = LCD_PANEL_ID_05;
+		break;
+	case 0x6:
+		vbios_regs->int15_regs.fun00_panel_id = LCD_PANEL_ID_06;
+		break;
+	default:
+		vbios_regs->int15_regs.fun00_panel_id = LCD_PANEL_ID_NO;
+		break;
+	}
+}
+
 /*************************************************
 * enable the dedicated function in tim5690 board.
 * This function called early than rs690_enable.
@@ -126,8 +241,21 @@ 
 	struct mainboard_config *mainboard =
 	    (struct mainboard_config *)dev->chip_info;
 
+	rs690_vbios_regs vbios_regs;
+	u16 gpio_base = IT8712F_SIMPLE_IO_BASE;
+	u8 port2;
+
 	printk_info("Mainboard tim5690 Enable. dev=0x%p\n", dev);
 
+	mb_gpio_init(&gpio_base);
+
+	/* The LCD's panel id seletion by switch. */
+	port2 = inb(gpio_base+1);
+	lcd_panel_id(&vbios_regs, ((~port2) & 0xf));
+	/* No support TV */
+	vbios_regs.int15_regs.fun05_tv_standard = TV_MODE_NO;
+	vgabios_init(&vbios_regs);
+
 #if (CONFIG_GFXUMA == 1)
 	msr_t msr, msr2;
 
Index: src/arch/i386/include/arch/interrupt.h
===================================================================
--- src/arch/i386/include/arch/interrupt.h	(revision 0)
+++ src/arch/i386/include/arch/interrupt.h	(revision 0)
@@ -0,0 +1,25 @@ 
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2009 coresystems GmbH
+ * Copyright (C) 2009 Libra Li <libra.li@technexion.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include "registers.h"
+
+/* setup interrupt handlers for mainboard */
+extern void mainboard_interrupt_handlers(int intXX, void *intXX_func);
Index: util/x86emu/x86.c
===================================================================
--- util/x86emu/x86.c	(revision 4981)
+++ util/x86emu/x86.c	(working copy)
@@ -29,6 +29,8 @@ 
 #include <console.h>
 #endif
 
+#include <arch/interrupt.h>
+
 #define REALMODE_BASE ((void *)0x600)
 
 struct realmode_idt {
@@ -64,6 +66,12 @@ 
 	return -1;
 }
 
+/* setup interrupt handlers for mainboard */
+void mainboard_interrupt_handlers(int intXX, void *intXX_func)
+{
+	intXX_handler[intXX] = intXX_func;
+}
+
 int int12_handler(struct eregs *regs);
 int int15_handler(struct eregs *regs);
 int int1a_handler(struct eregs *regs);
@@ -80,16 +88,32 @@ 
 	
 	/* Mark all other intXX calls as unknown first */
 	for (i = 0x10; i < 0x100; i++)
-		intXX_handler[i] = &intXX_unknown_handler;
-
-	/* Now set the default functions that are actually
-	 * needed to initialize the option roms. This is very
-	 * slick, as it allows us to implement mainboard specific
-	 * interrupt handlers, such as the int15
-	 */
-	intXX_handler[0x12] = &int12_handler;
-	intXX_handler[0x15] = &int15_handler;
-	intXX_handler[0x1a] = &int1a_handler;
+	{
+		/* If the mainboard_interrupt_handler isn't called first.
+		 */
+		if(!intXX_handler[i])
+		{
+			/* Now set the default functions that are actually
+			 * needed to initialize the option roms. This is very
+			 * slick, as it allows us to implement mainboard specific
+			 * interrupt handlers, such as the int15
+			 */
+			switch (i) {
+			case 0x12:
+				intXX_handler[0x12] = &int12_handler;
+				break;
+			case 0x15:
+				intXX_handler[0x15] = &int15_handler;
+				break;
+			case 0x1a:
+				intXX_handler[0x1a] = &int1a_handler;
+				break;
+			default:
+				intXX_handler[i] = &intXX_unknown_handler;
+				break;
+			}
+		}
+	}
 }
 
 static void write_idt_stub(void *target, u8 intnum)
@@ -127,7 +151,7 @@ 
 {
 	/* clear vga bios data area */
 	memset((void *)0x400, 0, 0x200);
-	
+
 	/* Set up C interrupt handlers */
 	setup_interrupt_handlers();