Lines Matching refs:chip
16 u8 oxygen_read8(struct oxygen *chip, unsigned int reg)
18 return inb(chip->addr + reg);
22 u16 oxygen_read16(struct oxygen *chip, unsigned int reg)
24 return inw(chip->addr + reg);
28 u32 oxygen_read32(struct oxygen *chip, unsigned int reg)
30 return inl(chip->addr + reg);
34 void oxygen_write8(struct oxygen *chip, unsigned int reg, u8 value)
36 outb(value, chip->addr + reg);
37 chip->saved_registers._8[reg] = value;
41 void oxygen_write16(struct oxygen *chip, unsigned int reg, u16 value)
43 outw(value, chip->addr + reg);
44 chip->saved_registers._16[reg / 2] = cpu_to_le16(value);
48 void oxygen_write32(struct oxygen *chip, unsigned int reg, u32 value)
50 outl(value, chip->addr + reg);
51 chip->saved_registers._32[reg / 4] = cpu_to_le32(value);
55 void oxygen_write8_masked(struct oxygen *chip, unsigned int reg,
58 u8 tmp = inb(chip->addr + reg);
61 outb(tmp, chip->addr + reg);
62 chip->saved_registers._8[reg] = tmp;
66 void oxygen_write16_masked(struct oxygen *chip, unsigned int reg,
69 u16 tmp = inw(chip->addr + reg);
72 outw(tmp, chip->addr + reg);
73 chip->saved_registers._16[reg / 2] = cpu_to_le16(tmp);
77 void oxygen_write32_masked(struct oxygen *chip, unsigned int reg,
80 u32 tmp = inl(chip->addr + reg);
83 outl(tmp, chip->addr + reg);
84 chip->saved_registers._32[reg / 4] = cpu_to_le32(tmp);
88 static int oxygen_ac97_wait(struct oxygen *chip, unsigned int mask)
96 wait_event_timeout(chip->ac97_waitqueue,
97 ({ status |= oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS);
104 status |= oxygen_read8(chip, OXYGEN_AC97_INTERRUPT_STATUS);
117 void oxygen_write_ac97(struct oxygen *chip, unsigned int codec,
130 oxygen_write32(chip, OXYGEN_AC97_REGS, reg);
132 if (oxygen_ac97_wait(chip, OXYGEN_AC97_INT_WRITE_DONE) >= 0 &&
134 chip->saved_ac97_registers[codec][index / 2] = data;
138 dev_err(chip->card->dev, "AC'97 write timeout\n");
142 u16 oxygen_read_ac97(struct oxygen *chip, unsigned int codec,
154 oxygen_write32(chip, OXYGEN_AC97_REGS, reg);
156 if (oxygen_ac97_wait(chip, OXYGEN_AC97_INT_READ_DONE) >= 0) {
157 u16 value = oxygen_read16(chip, OXYGEN_AC97_REGS);
170 dev_err(chip->card->dev, "AC'97 read timeout on codec %u\n", codec);
175 void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec,
178 u16 value = oxygen_read_ac97(chip, codec, index);
181 oxygen_write_ac97(chip, codec, index, value);
185 static int oxygen_wait_spi(struct oxygen *chip)
195 if ((oxygen_read8(chip, OXYGEN_SPI_CONTROL) &
199 dev_err(chip->card->dev, "oxygen: SPI wait timeout\n");
203 int oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data)
209 oxygen_write8(chip, OXYGEN_SPI_DATA1, data);
210 oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8);
212 oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16);
213 oxygen_write8(chip, OXYGEN_SPI_CONTROL, control);
214 return oxygen_wait_spi(chip);
218 void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data)
223 oxygen_write8(chip, OXYGEN_2WIRE_MAP, map);
224 oxygen_write8(chip, OXYGEN_2WIRE_DATA, data);
225 oxygen_write8(chip, OXYGEN_2WIRE_CONTROL,
230 static void _write_uart(struct oxygen *chip, unsigned int port, u8 data)
232 if (oxygen_read8(chip, OXYGEN_MPU401 + 1) & MPU401_TX_FULL)
234 oxygen_write8(chip, OXYGEN_MPU401 + port, data);
237 void oxygen_reset_uart(struct oxygen *chip)
239 _write_uart(chip, 1, MPU401_RESET);
241 _write_uart(chip, 1, MPU401_ENTER_UART);
245 void oxygen_write_uart(struct oxygen *chip, u8 data)
247 _write_uart(chip, 0, data);
251 u16 oxygen_read_eeprom(struct oxygen *chip, unsigned int index)
255 oxygen_write8(chip, OXYGEN_EEPROM_CONTROL,
259 if (!(oxygen_read8(chip, OXYGEN_EEPROM_STATUS)
263 return oxygen_read16(chip, OXYGEN_EEPROM_DATA);
266 void oxygen_write_eeprom(struct oxygen *chip, unsigned int index, u16 value)
270 oxygen_write16(chip, OXYGEN_EEPROM_DATA, value);
271 oxygen_write8(chip, OXYGEN_EEPROM_CONTROL,
275 if (!(oxygen_read8(chip, OXYGEN_EEPROM_STATUS)
279 dev_err(chip->card->dev, "EEPROM write timeout\n");