Tobias Diedrich | 4e6305f | 2010-11-07 20:08:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2010 Tobias Diedrich <ranma+coreboot@tdiedrich.de> |
| 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. |
Tobias Diedrich | 4e6305f | 2010-11-07 20:08:45 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Tobias Diedrich | 5d72eb5 | 2010-11-14 14:17:29 +0000 | [diff] [blame] | 16 | #include <arch/io.h> |
Tobias Diedrich | 4e6305f | 2010-11-07 20:08:45 +0000 | [diff] [blame] | 17 | #include <device/device.h> |
Tobias Diedrich | 5d72eb5 | 2010-11-14 14:17:29 +0000 | [diff] [blame] | 18 | #include <device/pci.h> |
| 19 | #include <device/pci_ids.h> |
| 20 | #include <console/console.h> |
| 21 | #include "southbridge/via/vt8237r/vt8237r.h" |
Tobias Diedrich | 4e6305f | 2010-11-07 20:08:45 +0000 | [diff] [blame] | 22 | |
Tobias Diedrich | 5d72eb5 | 2010-11-14 14:17:29 +0000 | [diff] [blame] | 23 | u32 vt8237_ide_80pin_detect(struct device *dev) |
| 24 | { |
| 25 | device_t lpc_dev; |
| 26 | u16 acpi_io_base; |
| 27 | u32 gpio_in; |
| 28 | u32 res; |
| 29 | |
| 30 | lpc_dev = dev_find_device(PCI_VENDOR_ID_VIA, |
| 31 | PCI_DEVICE_ID_VIA_VT8237A_LPC, 0); |
| 32 | if (!lpc_dev) |
Rudolf Marek | 727edb0 | 2010-11-14 14:39:29 +0000 | [diff] [blame] | 33 | return 0; |
Tobias Diedrich | 5d72eb5 | 2010-11-14 14:17:29 +0000 | [diff] [blame] | 34 | |
Florian Zumbiehl | f8ed903 | 2011-11-01 20:17:13 +0100 | [diff] [blame] | 35 | acpi_io_base = pci_read_config16(lpc_dev, 0x88) & ~1; |
| 36 | if (!acpi_io_base) |
Rudolf Marek | 727edb0 | 2010-11-14 14:39:29 +0000 | [diff] [blame] | 37 | return 0; |
Tobias Diedrich | 5d72eb5 | 2010-11-14 14:17:29 +0000 | [diff] [blame] | 38 | |
| 39 | gpio_in = inl(acpi_io_base + 0x48); |
| 40 | /* bit 9 for primary port, clear if unconnected or 80-pin cable */ |
| 41 | res = gpio_in & (1<<9) ? 0 : VT8237R_IDE0_80PIN_CABLE; |
| 42 | /* bit 4 for secondary port, clear if unconnected or 80-pin cable */ |
| 43 | res |= gpio_in & (1<<4) ? 0 : VT8237R_IDE1_80PIN_CABLE; |
| 44 | |
| 45 | printk(BIOS_INFO, "Cable on %s PATA port: %d pin\n", "primary", |
Florian Zumbiehl | f8ed903 | 2011-11-01 20:17:13 +0100 | [diff] [blame] | 46 | res & VT8237R_IDE0_80PIN_CABLE ? 80 : 40); |
Tobias Diedrich | 5d72eb5 | 2010-11-14 14:17:29 +0000 | [diff] [blame] | 47 | printk(BIOS_INFO, "Cable on %s PATA port: %d pin\n", "secondary", |
Florian Zumbiehl | f8ed903 | 2011-11-01 20:17:13 +0100 | [diff] [blame] | 48 | res & VT8237R_IDE1_80PIN_CABLE ? 80 : 40); |
Tobias Diedrich | 5d72eb5 | 2010-11-14 14:17:29 +0000 | [diff] [blame] | 49 | |
| 50 | return res; |
| 51 | } |