| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <device/azalia_device.h> |
| 5 |
#include <device/mmio.h> |
| 6 |
#include <types.h> |
| 7 |
|
| 8 |
#include "hda_verb.h" |
| 9 |
|
| 10 |
int hda_codec_detect(u8 *base) |
| 11 |
{ |
| 12 |
u8 reg8; |
| 13 |
|
| 14 |
|
| 15 |
if (azalia_exit_reset(base) != CB_SUCCESS) |
| 16 |
goto no_codec; |
| 17 |
|
| 18 |
|
| 19 |
write16(base + HDA_GCAP_REG, read16(base + HDA_GCAP_REG)); |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
write8(base + HDA_STATESTS_REG, 0xf); |
| 26 |
|
| 27 |
|
| 28 |
if (azalia_enter_reset(base) != CB_SUCCESS) |
| 29 |
goto no_codec; |
| 30 |
|
| 31 |
|
| 32 |
if (azalia_exit_reset(base) != CB_SUCCESS) |
| 33 |
goto no_codec; |
| 34 |
|
| 35 |
|
| 36 |
reg8 = read8(base + HDA_STATESTS_REG); |
| 37 |
reg8 &= 0x0f; |
| 38 |
if (!reg8) |
| 39 |
goto no_codec; |
| 40 |
|
| 41 |
return reg8; |
| 42 |
|
| 43 |
no_codec: |
| 44 |
|
| 45 |
azalia_enter_reset(base); |
| 46 |
printk(BIOS_DEBUG, "HDA: No codec!\n"); |
| 47 |
return 0; |
| 48 |
} |