diff options
Diffstat (limited to 'firmware/target/coldfire/iriver/udacodec-iriver.c')
-rw-r--r-- | firmware/target/coldfire/iriver/udacodec-iriver.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iriver/udacodec-iriver.c b/firmware/target/coldfire/iriver/udacodec-iriver.c new file mode 100644 index 0000000000..6c41964ffa --- /dev/null +++ b/firmware/target/coldfire/iriver/udacodec-iriver.c | |||
@@ -0,0 +1,76 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Bertrik Sikken | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "kernel.h" | ||
24 | #include "i2c-coldfire.h" | ||
25 | #include "pcf50606.h" | ||
26 | #include "uda1380.h" | ||
27 | #include "udacodec.h" | ||
28 | |||
29 | void udacodec_reset(void) | ||
30 | { | ||
31 | #ifdef IRIVER_H300_SERIES | ||
32 | int mask = disable_irq_save(); | ||
33 | pcf50606_write(0x3b, 0x00); /* GPOOD2 high Z */ | ||
34 | pcf50606_write(0x3b, 0x07); /* GPOOD2 low */ | ||
35 | restore_irq(mask); | ||
36 | #else | ||
37 | /* RESET signal */ | ||
38 | or_l(1<<29, &GPIO_OUT); | ||
39 | or_l(1<<29, &GPIO_ENABLE); | ||
40 | or_l(1<<29, &GPIO_FUNCTION); | ||
41 | sleep(HZ/100); | ||
42 | and_l(~(1<<29), &GPIO_OUT); | ||
43 | #endif | ||
44 | } | ||
45 | |||
46 | int udacodec_write(unsigned char reg, unsigned short value) | ||
47 | { | ||
48 | unsigned char data[3]; | ||
49 | |||
50 | data[0] = reg; | ||
51 | data[1] = value >> 8; | ||
52 | data[2] = value & 0xff; | ||
53 | |||
54 | if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 3) != 3) { | ||
55 | return -1; | ||
56 | } | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | int udacodec_write2(unsigned char reg, | ||
61 | unsigned short value1, unsigned short value2) | ||
62 | { | ||
63 | unsigned char data[5]; | ||
64 | |||
65 | data[0] = reg; | ||
66 | data[1] = value1 >> 8; | ||
67 | data[2] = value1 & 0xFF; | ||
68 | data[3] = value2 >> 8; | ||
69 | data[4] = value2 & 0xFF; | ||
70 | |||
71 | if (i2c_write(I2C_IFACE_0, UDA1380_ADDR, data, 5) != 5) { | ||
72 | return -1; | ||
73 | } | ||
74 | return 0; | ||
75 | } | ||
76 | |||