From 397b1dcc449082ce3f720c548da9c59db01cb739 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 22 Sep 2008 09:04:43 +0200 Subject: ALSA: oxygen: add UART I/O functions Add functions to allow model drivers to communicate with external chips by doing I/O with the not-used-for-MIDI UART. Signed-off-by: Clemens Ladisch --- sound/pci/oxygen/oxygen_io.c | 21 +++++++++++++++++++++ 1 file changed, 21 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 83f135f80df4..deba7389aec3 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "oxygen.h" @@ -232,3 +233,23 @@ void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data) device | OXYGEN_2WIRE_DIR_WRITE); } EXPORT_SYMBOL(oxygen_write_i2c); + +static void _write_uart(struct oxygen *chip, unsigned int port, u8 data) +{ + if (oxygen_read8(chip, OXYGEN_MPU401 + 1) & MPU401_TX_FULL) + msleep(1); + oxygen_write8(chip, OXYGEN_MPU401 + port, data); +} + +void oxygen_reset_uart(struct oxygen *chip) +{ + _write_uart(chip, 1, MPU401_RESET); + _write_uart(chip, 1, MPU401_ENTER_UART); +} +EXPORT_SYMBOL(oxygen_reset_uart); + +void oxygen_write_uart(struct oxygen *chip, u8 data) +{ + _write_uart(chip, 0, data); +} +EXPORT_SYMBOL(oxygen_write_uart); -- cgit v1.2.2 From cdad5b8db91ac46a8e226306d062fe4c896b2bed Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 24 Sep 2008 15:25:28 +0200 Subject: ALSA: oxygen: wait for ACK when resetting UART After sending a reset command to the UART, wait some time for the ACK to be generated (and to be read and dropped by the interrupt handler) before sending the next command. Signed-off-by: Clemens Ladisch --- sound/pci/oxygen/oxygen_io.c | 1 + 1 file changed, 1 insertion(+) (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 deba7389aec3..3126c4b403dd 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c @@ -244,6 +244,7 @@ static void _write_uart(struct oxygen *chip, unsigned int port, u8 data) void oxygen_reset_uart(struct oxygen *chip) { _write_uart(chip, 1, MPU401_RESET); + msleep(1); /* wait for ACK */ _write_uart(chip, 1, MPU401_ENTER_UART); } EXPORT_SYMBOL(oxygen_reset_uart); -- cgit v1.2.2