summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2009-03-03 18:00:17 +0000
committerBertrik Sikken <bertrik@sikken.nl>2009-03-03 18:00:17 +0000
commit1fb8242d968a3ee7091ef86db37b3e8f593eaeeb (patch)
tree886690cbfe9ec3294989c9d1da9b29a1da0a93d9 /firmware/target/arm
parent527b2dd270edebc7fcff1fe10e784a14e5046d7b (diff)
downloadrockbox-1fb8242d968a3ee7091ef86db37b3e8f593eaeeb.tar.gz
rockbox-1fb8242d968a3ee7091ef86db37b3e8f593eaeeb.zip
Simplify generic_i2c, removing the link between i2c address and i2c interface, adding the concept of an i2c bus index.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20193 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/as3525/fmradio-i2c-as3525.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/firmware/target/arm/as3525/fmradio-i2c-as3525.c b/firmware/target/arm/as3525/fmradio-i2c-as3525.c
index 72775eda75..528e8c79a3 100644
--- a/firmware/target/arm/as3525/fmradio-i2c-as3525.c
+++ b/firmware/target/arm/as3525/fmradio-i2c-as3525.c
@@ -22,7 +22,7 @@
22/* 22/*
23 This is the fmradio_i2c interface, used by the radio driver 23 This is the fmradio_i2c interface, used by the radio driver
24 to communicate with the radio tuner chip. 24 to communicate with the radio tuner chip.
25 25
26 It is implemented using the generic i2c driver, which does "bit-banged" 26 It is implemented using the generic i2c driver, which does "bit-banged"
27 I2C with a couple of GPIO pins. 27 I2C with a couple of GPIO pins.
28 */ 28 */
@@ -53,6 +53,8 @@
53#error no FM I2C GPIOPIN defines 53#error no FM I2C GPIOPIN defines
54#endif 54#endif
55 55
56static int fm_i2c_bus;
57
56static void fm_scl_hi(void) 58static void fm_scl_hi(void)
57{ 59{
58 I2C_GPIO(I2C_SCL_PIN) = 1 << I2C_SCL_PIN; 60 I2C_GPIO(I2C_SCL_PIN) = 1 << I2C_SCL_PIN;
@@ -107,22 +109,14 @@ static int fm_scl(void)
107static void fm_delay(void) 109static void fm_delay(void)
108{ 110{
109 volatile int i; 111 volatile int i;
110 112
111 /* this loop is uncalibrated and could use more sophistication */ 113 /* this loop is uncalibrated and could use more sophistication */
112 for (i = 0; i < 100; i++) { 114 for (i = 0; i < 100; i++) {
113 } 115 }
114} 116}
115 117
116/* interface towards the generic i2c driver */ 118/* interface towards the generic i2c driver */
117static struct i2c_interface fm_i2c_interface = { 119static const struct i2c_interface fm_i2c_interface = {
118#if defined(SANSA_CLIP) || defined(SANSA_FUZE) || defined(SANSA_E200V2)
119 .address = 0x10 << 1,
120#elif defined(SANSA_M200V4)
121 .address = 0xC0,
122#elif
123#error no fm i2c address defined
124#endif
125
126 .scl_hi = fm_scl_hi, 120 .scl_hi = fm_scl_hi,
127 .scl_lo = fm_scl_lo, 121 .scl_lo = fm_scl_lo,
128 .sda_hi = fm_sda_hi, 122 .sda_hi = fm_sda_hi,
@@ -133,7 +127,7 @@ static struct i2c_interface fm_i2c_interface = {
133 .scl_output = fm_scl_output, 127 .scl_output = fm_scl_output,
134 .scl = fm_scl, 128 .scl = fm_scl,
135 .sda = fm_sda, 129 .sda = fm_sda,
136 130
137 .delay_hd_sta = fm_delay, 131 .delay_hd_sta = fm_delay,
138 .delay_hd_dat = fm_delay, 132 .delay_hd_dat = fm_delay,
139 .delay_su_dat = fm_delay, 133 .delay_su_dat = fm_delay,
@@ -145,17 +139,17 @@ static struct i2c_interface fm_i2c_interface = {
145/* initialise i2c for fmradio */ 139/* initialise i2c for fmradio */
146void fmradio_i2c_init(void) 140void fmradio_i2c_init(void)
147{ 141{
148 i2c_add_node(&fm_i2c_interface); 142 fm_i2c_bus = i2c_add_node(&fm_i2c_interface);
149} 143}
150 144
151int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) 145int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
152{ 146{
153 return i2c_write_data(address, -1, buf, count); 147 return i2c_write_data(fm_i2c_bus, address, -1, buf, count);
154} 148}
155 149
156int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count) 150int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
157{ 151{
158 return i2c_read_data(address, -1, buf, count); 152 return i2c_read_data(fm_i2c_bus, address, -1, buf, count);
159} 153}
160 154
161 155