From 5d72eb5e8eda5e7b8a653a4e9b3bba2d4adbba9e Mon Sep 17 00:00:00 2001 From: Tobias Diedrich Date: Sun, 14 Nov 2010 14:17:29 +0000 Subject: Move cable detect logic to a weak function in vt8237r_ide.c and add an override function in m2v/mainboard.c Signed-off-by: Tobias Diedrich Acked-by: Rudolf Marek git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6069 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/southbridge/via/vt8237r/vt8237r.h | 5 +++++ src/southbridge/via/vt8237r/vt8237r_ide.c | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src/southbridge/via') diff --git a/src/southbridge/via/vt8237r/vt8237r.h b/src/southbridge/via/vt8237r/vt8237r.h index ba7089b414..d187ce6dcf 100644 --- a/src/southbridge/via/vt8237r/vt8237r.h +++ b/src/southbridge/via/vt8237r/vt8237r.h @@ -45,6 +45,10 @@ #define IDE_MISC_II 0x45 #define IDE_UDMA 0x50 +#define VT8237R_IDE0_80PIN_CABLE ((1UL<<28)|(1UL<<20)) +#define VT8237R_IDE1_80PIN_CABLE ((1UL<<12)|(1UL<< 4)) +#define VT8237R_IDE_CABLESEL_MASK (VT8237R_IDE0_80PIN_CABLE|VT8237R_IDE1_80PIN_CABLE) + /* SMBus */ #define VT8237R_PSON 0x82 #define VT8237R_POWER_WELL 0x94 @@ -118,6 +122,7 @@ int vt8237_early_network_init(struct vt8237_network_rom *rom); #include void writeback(struct device *dev, u16 where, u8 what); void dump_south(device_t dev); +u32 vt8237_ide_80pin_detect(struct device *dev); #endif #endif diff --git a/src/southbridge/via/vt8237r/vt8237r_ide.c b/src/southbridge/via/vt8237r/vt8237r_ide.c index ecbcfffc8c..209437b729 100644 --- a/src/southbridge/via/vt8237r/vt8237r_ide.c +++ b/src/southbridge/via/vt8237r/vt8237r_ide.c @@ -26,6 +26,19 @@ #include "vt8237r.h" #include "chip.h" +/** + * Cable type detect function, weak so it can be overloaded in mainboard.c + */ +u32 __attribute__((weak)) vt8237_ide_80pin_detect(struct device *dev) +{ + struct southbridge_via_vt8237r_config *sb = + (struct southbridge_via_vt8237r_config *)dev->chip_info; + u32 res; + res = sb->ide0_80pin_cable ? VT8237R_IDE0_80PIN_CABLE : 0; + res |= sb->ide1_80pin_cable ? VT8237R_IDE1_80PIN_CABLE : 0; + return res; +} + /** * No native mode. Interrupts from unconnected HDDs might occur if * IRQ14/15 is used for PCI. Therefore no native mode support. @@ -88,11 +101,8 @@ static void ide_init(struct device *dev) /* Cable guy... */ cablesel = pci_read_config32(dev, IDE_UDMA); - cablesel &= ~((1 << 28) | (1 << 20) | (1 << 12) | (1 << 4)); - cablesel |= (sb->ide0_80pin_cable << 28) | - (sb->ide0_80pin_cable << 20) | - (sb->ide1_80pin_cable << 12) | - (sb->ide1_80pin_cable << 4); + cablesel &= ~VT8237R_IDE_CABLESEL_MASK; + cablesel |= vt8237_ide_80pin_detect(dev); pci_write_config32(dev, IDE_UDMA, cablesel); #if CONFIG_EPIA_VT8237R_INIT -- cgit v1.2.3