From 30459d7b1843cbdea56ca120c8cac10dc5613e90 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 19 Feb 2009 08:42:44 +0100 Subject: sound: oxygen: handle cards with broken EEPROM Under as yet unknown circumstances, the first word of the sound card's EEPROM gets overwritten. When this has happened, we cannot rely on the subsystem IDs that the kernel reads from the PCI configuration registers. Instead, we read the IDs directly from the EEPROM and do the ID matching manually. Because the model-specific driver cannot determine the model before calling oxygen_pci_probe(), that function now gets a get_model() callback as parameter. The customizing of the model structure, which was formerly done by the probe() callback, also has moved into get_model(). Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_io.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sound/pci/oxygen/oxygen_io.c') diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c index 3126c4b403dd..05f48ef1a442 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c @@ -254,3 +254,18 @@ void oxygen_write_uart(struct oxygen *chip, u8 data) _write_uart(chip, 0, data); } EXPORT_SYMBOL(oxygen_write_uart); + +u16 oxygen_read_eeprom(struct oxygen *chip, unsigned int index) +{ + unsigned int timeout; + + oxygen_write8(chip, OXYGEN_EEPROM_CONTROL, + index | OXYGEN_EEPROM_DIR_READ); + for (timeout = 0; timeout < 100; ++timeout) { + udelay(1); + if (!(oxygen_read8(chip, OXYGEN_EEPROM_STATUS) + & OXYGEN_EEPROM_BUSY)) + break; + } + return oxygen_read16(chip, OXYGEN_EEPROM_DATA); +} -- cgit v1.2.3-59-g8ed1b