[coreboot] [patch] asus m2v: autodetect ide cable type

Tobias Diedrich ranma+coreboot at tdiedrich.de
Sat Nov 13 02:42:09 CET 2010


Read gpi4 and gpi9 to determine the 40/80-pin cable type.

Signed-off-by: Tobias Diedrich <ranma+coreboot at tdiedrich.de>

---

Index: src/mainboard/asus/m2v/mainboard.c
===================================================================
--- src/mainboard/asus/m2v/mainboard.c.orig	2010-11-13 02:22:19.000000000 +0100
+++ src/mainboard/asus/m2v/mainboard.c	2010-11-13 02:31:10.000000000 +0100
@@ -17,9 +17,41 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <arch/io.h>
 #include <device/device.h>
+#include <device/pci.h>
+#include <device/pci_ids.h>
+#include <console/console.h>
+#include "southbridge/via/vt8237r/vt8237r.h"
 #include "chip.h"
 
+void vt8237_pata_80pin_detect(struct southbridge_via_vt8237r_config *sb)
+{
+	device_t dev;
+	u16 acpi_io_base;
+	u32 gpio_in;
+
+	dev = dev_find_device(PCI_VENDOR_ID_VIA,
+				PCI_DEVICE_ID_VIA_VT8237A_LPC, 0);
+	if (!dev)
+		return;
+
+	acpi_io_base = pci_read_config16(dev, 0x88);
+	if (!acpi_io_base || (acpi_io_base & ~1) == 0)
+		return;
+	acpi_io_base &= ~1;
+
+	gpio_in = inl(acpi_io_base + 0x48);
+	/* bit 9 for primary port, clear if unconnected or 80-pin cable */
+	sb->ide0_80pin_cable = !(gpio_in & (1<<9));
+	/* bit 4 for secondary port, clear if unconnected or 80-pin cable */
+	sb->ide1_80pin_cable = !(gpio_in & (1<<4));
+	printk(BIOS_INFO, "Cable on %s PATA port: %d pin\n", "primary",
+		sb->ide0_80pin_cable ? 80 : 40);
+	printk(BIOS_INFO, "Cable on %s PATA port: %d pin\n", "secondary",
+		sb->ide1_80pin_cable ? 80 : 40);
+}
+
 struct chip_operations mainboard_ops = {
 	CHIP_NAME("ASUS M2V")
 };
Index: src/southbridge/via/vt8237r/vt8237r.h
===================================================================
--- src/southbridge/via/vt8237r/vt8237r.h.orig	2010-11-13 02:22:19.000000000 +0100
+++ src/southbridge/via/vt8237r/vt8237r.h	2010-11-13 02:29:47.000000000 +0100
@@ -21,6 +21,7 @@
 #define SOUTHBRIDGE_VIA_VT8237R_VT8237R_H
 
 #include <stdint.h>
+#include "chip.h"
 
 /* Static resources for the VT8237R southbridge */
 
@@ -118,6 +119,13 @@
 #include <device/device.h>
 void writeback(struct device *dev, u16 where, u8 what);
 void dump_south(device_t dev);
+#if CONFIG_HAVE_PATA_CABLETYPE_DETECT
+void vt8237_pata_80pin_detect(struct southbridge_via_vt8237r_config *sb);
+#else
+static inline void vt8237_pata_80pin_detect(struct southbridge_via_vt8237r_config *sb)
+{
+}
+#endif
 #endif
 
 #endif
Index: src/southbridge/via/vt8237r/vt8237r_ide.c
===================================================================
--- src/southbridge/via/vt8237r/vt8237r_ide.c.orig	2010-11-13 02:22:19.000000000 +0100
+++ src/southbridge/via/vt8237r/vt8237r_ide.c	2010-11-13 02:32:31.000000000 +0100
@@ -38,6 +38,8 @@
 	u8 enables;
 	u32 cablesel;
 
+	vt8237_pata_80pin_detect(sb);
+
 	printk(BIOS_INFO, "%s IDE interface %s\n", "Primary",
 		    sb->ide0_enable ? "enabled" : "disabled");
 	printk(BIOS_INFO, "%s IDE interface %s\n", "Secondary",
Index: src/mainboard/asus/m2v/Kconfig
===================================================================
--- src/mainboard/asus/m2v/Kconfig.orig	2010-11-13 02:22:19.000000000 +0100
+++ src/mainboard/asus/m2v/Kconfig	2010-11-13 02:29:47.000000000 +0100
@@ -21,6 +21,7 @@
 	select PIRQ_ROUTE
 	select HAVE_ACPI_TABLES
 	select HAVE_MP_TABLE
+	select HAVE_PATA_CABLETYPE_DETECT
 
 config MAINBOARD_DIR
 	string
Index: src/southbridge/via/vt8237r/Kconfig
===================================================================
--- src/southbridge/via/vt8237r/Kconfig.orig	2010-11-13 02:22:19.000000000 +0100
+++ src/southbridge/via/vt8237r/Kconfig	2010-11-13 02:29:47.000000000 +0100
@@ -27,6 +27,11 @@
 	default n
 	depends on SOUTHBRIDGE_VIA_VT8237R
 
+config HAVE_PATA_CABLETYPE_DETECT
+	bool
+	default n
+	depends on SOUTHBRIDGE_VIA_VT8237R
+
 config BOOTBLOCK_SOUTHBRIDGE_INIT
 	string
 	default "southbridge/via/vt8237r/bootblock.c"




More information about the coreboot mailing list