2 * This file is part of the coreboot project.
4 * Copyright (C) 2010 Tobias Diedrich <ranma+coreboot@tdiedrich.de>
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.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <device/device.h>
22 #include <device/pci.h>
23 #include <device/pci_ids.h>
24 #include <console/console.h>
25 #include "southbridge/via/vt8237r/vt8237r.h"
28 u32 vt8237_ide_80pin_detect(struct device *dev)
35 lpc_dev = dev_find_device(PCI_VENDOR_ID_VIA,
36 PCI_DEVICE_ID_VIA_VT8237A_LPC, 0);
40 acpi_io_base = pci_read_config16(lpc_dev, 0x88);
41 if (!acpi_io_base || (acpi_io_base & ~1) == 0)
45 gpio_in = inl(acpi_io_base + 0x48);
46 /* bit 9 for primary port, clear if unconnected or 80-pin cable */
47 res = gpio_in & (1<<9) ? 0 : VT8237R_IDE0_80PIN_CABLE;
48 /* bit 4 for secondary port, clear if unconnected or 80-pin cable */
49 res |= gpio_in & (1<<4) ? 0 : VT8237R_IDE1_80PIN_CABLE;
51 printk(BIOS_INFO, "Cable on %s PATA port: %d pin\n", "primary",
52 gpio_in & (1<<9) ? 40 : 80);
53 printk(BIOS_INFO, "Cable on %s PATA port: %d pin\n", "secondary",
54 gpio_in & (1<<4) ? 40 : 80);
59 struct chip_operations mainboard_ops = {