Lines Matching +full:chip +full:- +full:to +full:- +full:chip

2  * C-Media CMI8788 driver - helper functions
16 * along with this driver; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 u8 oxygen_read8(struct oxygen *chip, unsigned int reg) in oxygen_read8() argument
30 return inb(chip->addr + reg); in oxygen_read8()
34 u16 oxygen_read16(struct oxygen *chip, unsigned int reg) in oxygen_read16() argument
36 return inw(chip->addr + reg); in oxygen_read16()
40 u32 oxygen_read32(struct oxygen *chip, unsigned int reg) in oxygen_read32() argument
42 return inl(chip->addr + reg); in oxygen_read32()
46 void oxygen_write8(struct oxygen *chip, unsigned int reg, u8 value) in oxygen_write8() argument
48 outb(value, chip->addr + reg); in oxygen_write8()
49 chip->saved_registers._8[reg] = value; in oxygen_write8()
53 void oxygen_write16(struct oxygen *chip, unsigned int reg, u16 value) in oxygen_write16() argument
55 outw(value, chip->addr + reg); in oxygen_write16()
56 chip->saved_registers._16[reg / 2] = cpu_to_le16(value); in oxygen_write16()
60 void oxygen_write32(struct oxygen *chip, unsigned int reg, u32 value) in oxygen_write32() argument
62 outl(value, chip->addr + reg); in oxygen_write32()
63 chip->saved_registers._32[reg / 4] = cpu_to_le32(value); in oxygen_write32()
67 void oxygen_write8_masked(struct oxygen *chip, unsigned int reg, in oxygen_write8_masked() argument
70 u8 tmp = inb(chip->addr + reg); in oxygen_write8_masked()
73 outb(tmp, chip->addr + reg); in oxygen_write8_masked()
74 chip->saved_registers._8[reg] = tmp; in oxygen_write8_masked()
78 void oxygen_write16_masked(struct oxygen *chip, unsigned int reg, in oxygen_write16_masked() argument
81 u16 tmp = inw(chip->addr + reg); in oxygen_write16_masked()
84 outw(tmp, chip->addr + reg); in oxygen_write16_masked()
85 chip->saved_registers._16[reg / 2] = cpu_to_le16(tmp); in oxygen_write16_masked()
89 void oxygen_write32_masked(struct oxygen *chip, unsigned int reg, in oxygen_write32_masked() argument
92 u32 tmp = inl(chip->addr + reg); in oxygen_write32_masked()
95 outl(tmp, chip->addr + reg); in oxygen_write32_masked()
96 chip->saved_registers._32[reg / 4] = cpu_to_le32(tmp); in oxygen_write32_masked()
100 static int oxygen_ac97_wait(struct oxygen *chip, unsigned int mask) in oxygen_ac97_wait() argument
105 * Reading the status register also clears the bits, so we have to save in oxygen_ac97_wait()
108 wait_event_timeout(chip->ac97_waitqueue, in oxygen_ac97_wait()
109 ({ status |= oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS); in oxygen_ac97_wait()
114 * the AC'97 interrupt to be enabled. in oxygen_ac97_wait()
116 status |= oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS); in oxygen_ac97_wait()
117 return status & mask ? 0 : -EIO; in oxygen_ac97_wait()
121 * About 10% of AC'97 register reads or writes fail to complete, but even those
122 * where the controller indicates completion aren't guaranteed to have actually
125 * It's hard to assign blame to either the controller or the codec because both
126 * were made by C-Media ...
129 void oxygen_write_ac97(struct oxygen *chip, unsigned int codec, in oxygen_write_ac97() argument
140 for (count = 5; count > 0; --count) { in oxygen_write_ac97()
142 oxygen_write32(chip, OXYGEN_AC97_REGS, reg); in oxygen_write_ac97()
143 /* require two "completed" writes, just to be sure */ in oxygen_write_ac97()
144 if (oxygen_ac97_wait(chip, OXYGEN_AC97_INT_WRITE_DONE) >= 0 && in oxygen_write_ac97()
146 chip->saved_ac97_registers[codec][index / 2] = data; in oxygen_write_ac97()
154 u16 oxygen_read_ac97(struct oxygen *chip, unsigned int codec, in oxygen_read_ac97() argument
164 for (count = 5; count > 0; --count) { in oxygen_read_ac97()
166 oxygen_write32(chip, OXYGEN_AC97_REGS, reg); in oxygen_read_ac97()
168 if (oxygen_ac97_wait(chip, OXYGEN_AC97_INT_READ_DONE) >= 0) { in oxygen_read_ac97()
169 u16 value = oxygen_read16(chip, OXYGEN_AC97_REGS); in oxygen_read_ac97()
175 * Invert the register value bits to make sure that two in oxygen_read_ac97()
187 void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec, in oxygen_write_ac97_masked() argument
190 u16 value = oxygen_read_ac97(chip, codec, index); in oxygen_write_ac97_masked()
193 oxygen_write_ac97(chip, codec, index, value); in oxygen_write_ac97_masked()
197 void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data) in oxygen_write_spi() argument
203 while ((oxygen_read8(chip, OXYGEN_SPI_CONTROL) & OXYGEN_SPI_BUSY) in oxygen_write_spi()
206 --count; in oxygen_write_spi()
209 oxygen_write8(chip, OXYGEN_SPI_DATA1, data); in oxygen_write_spi()
210 oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); in oxygen_write_spi()
212 oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); in oxygen_write_spi()
213 oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); in oxygen_write_spi()
217 void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data) in oxygen_write_i2c() argument
222 oxygen_write8(chip, OXYGEN_2WIRE_MAP, map); in oxygen_write_i2c()
223 oxygen_write8(chip, OXYGEN_2WIRE_DATA, data); in oxygen_write_i2c()
224 oxygen_write8(chip, OXYGEN_2WIRE_CONTROL, in oxygen_write_i2c()
229 static void _write_uart(struct oxygen *chip, unsigned int port, u8 data) in _write_uart() argument
231 if (oxygen_read8(chip, OXYGEN_MPU401 + 1) & MPU401_TX_FULL) in _write_uart()
233 oxygen_write8(chip, OXYGEN_MPU401 + port, data); in _write_uart()
236 void oxygen_reset_uart(struct oxygen *chip) in oxygen_reset_uart() argument
238 _write_uart(chip, 1, MPU401_RESET); in oxygen_reset_uart()
240 _write_uart(chip, 1, MPU401_ENTER_UART); in oxygen_reset_uart()
244 void oxygen_write_uart(struct oxygen *chip, u8 data) in oxygen_write_uart() argument
246 _write_uart(chip, 0, data); in oxygen_write_uart()
250 u16 oxygen_read_eeprom(struct oxygen *chip, unsigned int index) in oxygen_read_eeprom() argument
254 oxygen_write8(chip, OXYGEN_EEPROM_CONTROL, in oxygen_read_eeprom()
258 if (!(oxygen_read8(chip, OXYGEN_EEPROM_STATUS) in oxygen_read_eeprom()
262 return oxygen_read16(chip, OXYGEN_EEPROM_DATA); in oxygen_read_eeprom()
265 void oxygen_write_eeprom(struct oxygen *chip, unsigned int index, u16 value) in oxygen_write_eeprom() argument
269 oxygen_write16(chip, OXYGEN_EEPROM_DATA, value); in oxygen_write_eeprom()
270 oxygen_write8(chip, OXYGEN_EEPROM_CONTROL, in oxygen_write_eeprom()
274 if (!(oxygen_read8(chip, OXYGEN_EEPROM_STATUS) in oxygen_write_eeprom()