diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-07-15 19:40:55 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-07-24 21:20:13 +0000 |
commit | 092c340a2062fa98b7387fc5fd63578ddae7d0b6 (patch) | |
tree | 98ec96946eeb2ae709cb0528cc6998e21bb9b290 /firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c | |
parent | 17f7cc92c258bc456a27c3e7c5a19c9409851879 (diff) | |
download | rockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.tar.gz rockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.zip |
[1/4] Remove SH support and all archos targets
This removes all code specific to SH targets
Change-Id: I7980523785d2596e65c06430f4638eec74a06061
Diffstat (limited to 'firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c')
-rw-r--r-- | firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c | 202 |
1 files changed, 0 insertions, 202 deletions
diff --git a/firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c b/firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c deleted file mode 100644 index b901bd0019..0000000000 --- a/firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c +++ /dev/null | |||
@@ -1,202 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * Physical interface of the Philips TEA5767 in Archos Ondio | ||
10 | * | ||
11 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "cpu.h" | ||
25 | #include "kernel.h" | ||
26 | #include "logf.h" | ||
27 | #include "system.h" | ||
28 | #include "fmradio_i2c.h" | ||
29 | |||
30 | #if (CONFIG_TUNER & TEA5767) | ||
31 | |||
32 | /* cute little functions, atomic read-modify-write */ | ||
33 | /* SDA is PB4 */ | ||
34 | #define SDA_LO and_b(~0x10, &PBDRL) | ||
35 | #define SDA_HI or_b(0x10, &PBDRL) | ||
36 | #define SDA_INPUT and_b(~0x10, &PBIORL) | ||
37 | #define SDA_OUTPUT or_b(0x10, &PBIORL) | ||
38 | #define SDA (PBDR & 0x0010) | ||
39 | |||
40 | /* SCL is PB1 */ | ||
41 | #define SCL_INPUT and_b(~0x02, &PBIORL) | ||
42 | #define SCL_OUTPUT or_b(0x02, &PBIORL) | ||
43 | #define SCL_LO and_b(~0x02, &PBDRL) | ||
44 | #define SCL_HI or_b(0x02, &PBDRL) | ||
45 | #define SCL (PBDR & 0x0002) | ||
46 | |||
47 | /* arbitrary delay loop */ | ||
48 | #define DELAY do { int _x; for(_x=0;_x<20;_x++);} while (0) | ||
49 | |||
50 | static void fmradio_i2c_start(void) | ||
51 | { | ||
52 | SDA_OUTPUT; | ||
53 | SDA_HI; | ||
54 | SCL_HI; | ||
55 | SDA_LO; | ||
56 | DELAY; | ||
57 | SCL_LO; | ||
58 | } | ||
59 | |||
60 | static void fmradio_i2c_stop(void) | ||
61 | { | ||
62 | SDA_LO; | ||
63 | SCL_HI; | ||
64 | DELAY; | ||
65 | SDA_HI; | ||
66 | } | ||
67 | |||
68 | |||
69 | static void fmradio_i2c_ack(bool nack) | ||
70 | { | ||
71 | /* Here's the deal. The slave is slow, and sometimes needs to wait | ||
72 | before it can receive the acknowledge. Therefore it forces the clock | ||
73 | low until it is ready. We need to poll the clock line until it goes | ||
74 | high before we release the ack. */ | ||
75 | |||
76 | SCL_LO; /* Set the clock low */ | ||
77 | |||
78 | if (nack) | ||
79 | SDA_HI; | ||
80 | else | ||
81 | SDA_LO; | ||
82 | |||
83 | SCL_INPUT; /* Set the clock to input */ | ||
84 | while(!SCL) /* and wait for the slave to release it */ | ||
85 | sleep(0); | ||
86 | |||
87 | DELAY; | ||
88 | SCL_OUTPUT; | ||
89 | SCL_LO; | ||
90 | } | ||
91 | |||
92 | static int fmradio_i2c_getack(void) | ||
93 | { | ||
94 | int ret = 1; | ||
95 | |||
96 | /* Here's the deal. The slave is slow, and sometimes needs to wait | ||
97 | before it can send the acknowledge. Therefore it forces the clock | ||
98 | low until it is ready. We need to poll the clock line until it goes | ||
99 | high before we read the ack. */ | ||
100 | |||
101 | SDA_INPUT; /* And set to input */ | ||
102 | SCL_INPUT; /* Set the clock to input */ | ||
103 | while(!SCL) /* and wait for the slave to release it */ | ||
104 | sleep(0); | ||
105 | |||
106 | if (SDA) | ||
107 | /* ack failed */ | ||
108 | ret = 0; | ||
109 | |||
110 | SCL_OUTPUT; | ||
111 | SCL_LO; | ||
112 | SDA_HI; | ||
113 | SDA_OUTPUT; | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | static void fmradio_i2c_outb(unsigned char byte) | ||
118 | { | ||
119 | int i; | ||
120 | |||
121 | /* clock out each bit, MSB first */ | ||
122 | for ( i=0x80; i; i>>=1 ) { | ||
123 | if ( i & byte ) | ||
124 | { | ||
125 | SDA_HI; | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | SDA_LO; | ||
130 | } | ||
131 | SCL_HI; | ||
132 | SCL_LO; | ||
133 | } | ||
134 | |||
135 | SDA_HI; | ||
136 | } | ||
137 | |||
138 | static unsigned char fmradio_i2c_inb(void) | ||
139 | { | ||
140 | int i; | ||
141 | unsigned char byte = 0; | ||
142 | |||
143 | /* clock in each bit, MSB first */ | ||
144 | for ( i=0x80; i; i>>=1 ) { | ||
145 | SDA_INPUT; /* And set to input */ | ||
146 | SCL_HI; | ||
147 | if ( SDA ) | ||
148 | byte |= i; | ||
149 | SCL_LO; | ||
150 | SDA_OUTPUT; | ||
151 | } | ||
152 | |||
153 | return byte; | ||
154 | } | ||
155 | |||
156 | int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) | ||
157 | { | ||
158 | int i,x=0; | ||
159 | |||
160 | fmradio_i2c_start(); | ||
161 | fmradio_i2c_outb(address & 0xfe); | ||
162 | if (fmradio_i2c_getack()) | ||
163 | { | ||
164 | for (i=0; i<count; i++) | ||
165 | { | ||
166 | fmradio_i2c_outb(buf[i]); | ||
167 | if (!fmradio_i2c_getack()) | ||
168 | { | ||
169 | x=-2; | ||
170 | break; | ||
171 | } | ||
172 | } | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | logf("fmradio_i2c_write() - no ack\n"); | ||
177 | x=-1; | ||
178 | } | ||
179 | fmradio_i2c_stop(); | ||
180 | return x; | ||
181 | } | ||
182 | |||
183 | int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count) | ||
184 | { | ||
185 | int i,x=0; | ||
186 | |||
187 | fmradio_i2c_start(); | ||
188 | fmradio_i2c_outb(address | 1); | ||
189 | if (fmradio_i2c_getack()) { | ||
190 | for (i=count; i>0; i--) | ||
191 | { | ||
192 | *buf++ = fmradio_i2c_inb(); | ||
193 | fmradio_i2c_ack(i == 1); | ||
194 | } | ||
195 | } | ||
196 | else | ||
197 | x=-1; | ||
198 | fmradio_i2c_stop(); | ||
199 | return x; | ||
200 | } | ||
201 | |||
202 | #endif | ||