diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-04-07 04:23:37 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-04-24 06:00:31 -0400 |
commit | 10e6d5f9b6edd4a12d678716d7fdb94278a83227 (patch) | |
tree | 710a7e4d1ed50ec72f441b5e809132c40e77f7ca /sound/pci/oxygen/oxygen_io.c | |
parent | 7a4356747298d1c899a12a25260d5ff1b4feeb5e (diff) |
[ALSA] oxygen: add I2C support
Add a function to write I2C registers.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/oxygen/oxygen_io.c')
-rw-r--r-- | sound/pci/oxygen/oxygen_io.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c index 74e23ef9c946..5569606ee87f 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c | |||
@@ -190,12 +190,31 @@ void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data) | |||
190 | --count; | 190 | --count; |
191 | } | 191 | } |
192 | 192 | ||
193 | spin_lock_irq(&chip->reg_lock); | ||
194 | oxygen_write8(chip, OXYGEN_SPI_DATA1, data); | 193 | oxygen_write8(chip, OXYGEN_SPI_DATA1, data); |
195 | oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); | 194 | oxygen_write8(chip, OXYGEN_SPI_DATA2, data >> 8); |
196 | if (control & OXYGEN_SPI_DATA_LENGTH_3) | 195 | if (control & OXYGEN_SPI_DATA_LENGTH_3) |
197 | oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); | 196 | oxygen_write8(chip, OXYGEN_SPI_DATA3, data >> 16); |
198 | oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); | 197 | oxygen_write8(chip, OXYGEN_SPI_CONTROL, control); |
199 | spin_unlock_irq(&chip->reg_lock); | ||
200 | } | 198 | } |
201 | EXPORT_SYMBOL(oxygen_write_spi); | 199 | EXPORT_SYMBOL(oxygen_write_spi); |
200 | |||
201 | void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data) | ||
202 | { | ||
203 | unsigned long timeout; | ||
204 | |||
205 | /* should not need more than about 300 us */ | ||
206 | timeout = jiffies + msecs_to_jiffies(1); | ||
207 | do { | ||
208 | if (!(oxygen_read16(chip, OXYGEN_2WIRE_BUS_STATUS) | ||
209 | & OXYGEN_2WIRE_BUSY)) | ||
210 | break; | ||
211 | udelay(1); | ||
212 | cond_resched(); | ||
213 | } while (time_after_eq(timeout, jiffies)); | ||
214 | |||
215 | oxygen_write8(chip, OXYGEN_2WIRE_MAP, map); | ||
216 | oxygen_write8(chip, OXYGEN_2WIRE_DATA, data); | ||
217 | oxygen_write8(chip, OXYGEN_2WIRE_CONTROL, | ||
218 | device | OXYGEN_2WIRE_DIR_WRITE); | ||
219 | } | ||
220 | EXPORT_SYMBOL(oxygen_write_i2c); | ||