summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-11-19 20:39:10 +0000
committerAmaury Pouly <amaury.pouly@gmail.com>2013-11-19 20:39:10 +0000
commit446f352abda2dbc9de90c35a02100ed5e9aad77c (patch)
tree7ee2b4dae98376e0380b0b8bc44e1e688d10ede2 /firmware/target/arm
parentc2c2274e0adacc1a0c5bdb57fa1367badb7b047f (diff)
downloadrockbox-446f352abda2dbc9de90c35a02100ed5e9aad77c.tar.gz
rockbox-446f352abda2dbc9de90c35a02100ed5e9aad77c.zip
imx233: factor fmradio i2c and tuner power code
Choices are limited for those: i2c is either generic software or imx233 hardware and power is either none or with a gpio. So factor ever possible combination in a single common file and use fmradio-target.h to supply the required parameters. This will remove a bunch of duplicate code. Change-Id: If12faeb2e371631cd39cc18a4c1d859812007934
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/imx233/creative-zen/fmradio-target.h (renamed from firmware/target/arm/imx233/sony-nwz/power-nwz.c)32
-rw-r--r--firmware/target/arm/imx233/creative-zen/power-zen.c38
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c40
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi2/fmradio-target.h (renamed from firmware/target/arm/imx233/creative-zenxfi3/power-zenxfi3.c)26
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c40
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi3/fmradio-target.h (renamed from firmware/target/arm/imx233/creative-zenxfi2/power-zenxfi2.c)26
-rw-r--r--firmware/target/arm/imx233/fmradio-imx233.c162
-rw-r--r--firmware/target/arm/imx233/fmradio-imx233.h64
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c76
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/fmradio-target.h (renamed from firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c)29
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c53
-rw-r--r--firmware/target/arm/imx233/sony-nwz/fmradio-target.h (renamed from firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c)22
12 files changed, 269 insertions, 339 deletions
diff --git a/firmware/target/arm/imx233/sony-nwz/power-nwz.c b/firmware/target/arm/imx233/creative-zen/fmradio-target.h
index 88644919ad..c2b75b3ed4 100644
--- a/firmware/target/arm/imx233/sony-nwz/power-nwz.c
+++ b/firmware/target/arm/imx233/creative-zen/fmradio-target.h
@@ -18,25 +18,19 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#ifndef _FMRADIO_TARGET_H_
22#define _FMRADIO_TARGET_H_
21 23
22#include "system.h" 24#define IMX233_FMRADIO_I2C FMI_HW
23#include "power.h"
24#include "tuner.h"
25#include "fmradio_i2c.h"
26#include "pinctrl-imx233.h"
27 25
28static bool tuner_enable = false; 26#ifdef CREATIVE_ZENMOZAIC
27#define IMX233_FMRADIO_POWER FMP_GPIO
28#define FMP_GPIO_BANK 2
29#define FMP_GPIO_PIN 15
30#define FMP_GPIO_DELAY (HZ / 5)
31#else
32#define IMX233_FMRADIO_POWER FMP_NONE
33#endif
29 34
30bool tuner_power(bool enable) 35#endif /* _FMRADIO_TARGET_H_ */
31{ 36 \ No newline at end of file
32 if(enable != tuner_enable)
33 {
34 tuner_enable = enable;
35 }
36 return tuner_enable;
37}
38
39bool tuner_powered(void)
40{
41 return tuner_enable;
42}
diff --git a/firmware/target/arm/imx233/creative-zen/power-zen.c b/firmware/target/arm/imx233/creative-zen/power-zen.c
index c1ad5989c0..15da6ab201 100644
--- a/firmware/target/arm/imx233/creative-zen/power-zen.c
+++ b/firmware/target/arm/imx233/creative-zen/power-zen.c
@@ -21,44 +21,6 @@
21 21
22#include "system.h" 22#include "system.h"
23#include "power.h" 23#include "power.h"
24#include "tuner.h"
25#include "fmradio_i2c.h"
26#include "pinctrl-imx233.h"
27#include "power-imx233.h"
28
29static bool tuner_enable = false;
30static bool initialised = false;
31
32static void init(void)
33{
34#ifdef CREATIVE_ZENMOZAIC
35 /* CE is B2P15 (active high) */
36 imx233_pinctrl_acquire(2, 15, "tuner power");
37 imx233_pinctrl_set_function(2, 15, PINCTRL_FUNCTION_GPIO);
38 imx233_pinctrl_enable_gpio(2, 15, true);
39#endif
40 initialised = true;
41}
42
43bool tuner_power(bool enable)
44{
45 if(!initialised)
46 init();
47 if(tuner_enable != enable)
48 {
49#ifdef CREATIVE_ZENMOZAIC
50 imx233_pinctrl_set_gpio(2, 15, enable);
51 sleep(HZ / 5);
52#endif
53 tuner_enable = enable;
54 }
55 return tuner_enable;
56}
57
58bool tuner_powered(void)
59{
60 return tuner_enable;
61}
62 24
63void ide_power_enable(bool on) 25void ide_power_enable(bool on)
64{ 26{
diff --git a/firmware/target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c b/firmware/target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c
deleted file mode 100644
index 58ac8e6a08..0000000000
--- a/firmware/target/arm/imx233/creative-zenxfi2/fmradio-i2c-zenxfi2.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2012 by Amaury Pouly
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 "system.h"
24#include "fmradio_i2c.h"
25#include "pinctrl-imx233.h"
26#include "i2c.h"
27
28void fmradio_i2c_init(void)
29{
30}
31
32int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
33{
34 return i2c_write(address, buf, count);
35}
36
37int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
38{
39 return i2c_read(address, buf, count);
40}
diff --git a/firmware/target/arm/imx233/creative-zenxfi3/power-zenxfi3.c b/firmware/target/arm/imx233/creative-zenxfi2/fmradio-target.h
index 26f2159cec..e6869dc2a5 100644
--- a/firmware/target/arm/imx233/creative-zenxfi3/power-zenxfi3.c
+++ b/firmware/target/arm/imx233/creative-zenxfi2/fmradio-target.h
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2012 by Amaury Pouly 10 * Copyright (C) 2013 by Amaury Pouly
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -18,25 +18,11 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#ifndef _FMRADIO_TARGET_H_
22#define _FMRADIO_TARGET_H_
21 23
22#include "system.h" 24#define IMX233_FMRADIO_I2C FMI_HW
23#include "power.h"
24#include "tuner.h"
25#include "fmradio_i2c.h"
26#include "pinctrl-imx233.h"
27 25
28static bool tuner_enable = false; 26#define IMX233_FMRADIO_POWER FMP_NONE
29 27
30bool tuner_power(bool enable) 28#endif /* _FMRADIO_TARGET_H_ */
31{
32 if(enable != tuner_enable)
33 {
34 tuner_enable = enable;
35 }
36 return tuner_enable;
37}
38
39bool tuner_powered(void)
40{
41 return tuner_enable;
42}
diff --git a/firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c b/firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c
deleted file mode 100644
index 58ac8e6a08..0000000000
--- a/firmware/target/arm/imx233/creative-zenxfi3/fmradio-i2c-zenxfi3.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2012 by Amaury Pouly
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 "system.h"
24#include "fmradio_i2c.h"
25#include "pinctrl-imx233.h"
26#include "i2c.h"
27
28void fmradio_i2c_init(void)
29{
30}
31
32int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
33{
34 return i2c_write(address, buf, count);
35}
36
37int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
38{
39 return i2c_read(address, buf, count);
40}
diff --git a/firmware/target/arm/imx233/creative-zenxfi2/power-zenxfi2.c b/firmware/target/arm/imx233/creative-zenxfi3/fmradio-target.h
index 180b7f9d4c..e6869dc2a5 100644
--- a/firmware/target/arm/imx233/creative-zenxfi2/power-zenxfi2.c
+++ b/firmware/target/arm/imx233/creative-zenxfi3/fmradio-target.h
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2011 by Amaury Pouly 10 * Copyright (C) 2013 by Amaury Pouly
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -18,25 +18,11 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#ifndef _FMRADIO_TARGET_H_
22#define _FMRADIO_TARGET_H_
21 23
22#include "system.h" 24#define IMX233_FMRADIO_I2C FMI_HW
23#include "power.h"
24#include "tuner.h"
25#include "fmradio_i2c.h"
26#include "pinctrl-imx233.h"
27 25
28static bool tuner_enable = false; 26#define IMX233_FMRADIO_POWER FMP_NONE
29 27
30bool tuner_power(bool enable) 28#endif /* _FMRADIO_TARGET_H_ */
31{
32 if(enable != tuner_enable)
33 {
34 tuner_enable = enable;
35 }
36 return tuner_enable;
37}
38
39bool tuner_powered(void)
40{
41 return tuner_enable;
42}
diff --git a/firmware/target/arm/imx233/fmradio-imx233.c b/firmware/target/arm/imx233/fmradio-imx233.c
new file mode 100644
index 0000000000..28ac4a4893
--- /dev/null
+++ b/firmware/target/arm/imx233/fmradio-imx233.c
@@ -0,0 +1,162 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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#include "fmradio-imx233.h"
22#include "fmradio-target.h"
23#include "pinctrl-imx233.h"
24#include "i2c.h"
25#include "generic_i2c.h"
26
27#ifndef IMX233_FMRADIO_I2C
28#error You must define IMX233_FMRADIO_I2C in fmradio-target.h
29#endif
30
31#ifndef IMX233_FMRADIO_POWER
32#error You must define IMX233_FMRADIO_POWER in fmradio-target.h
33#endif
34
35/** Hardware I2C */
36#if IMX233_FMRADIO_I2C == FMI_HW
37void fmradio_i2c_init(void)
38{
39}
40
41int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
42{
43 return i2c_write(address, buf, count);
44}
45
46int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
47{
48 return i2c_read(address, buf, count);
49}
50/** Software I2C */
51#elif IMX233_FMRADIO_I2C == FMI_SW
52#if !defined(FMI_SW_SDA_BANK) || !defined(FMI_SW_SDA_PIN) || \
53 !defined(FMI_SW_SCL_BANK) || !defined(FMI_SW_SCL_PIN)
54#error You must define FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, FMI_SW_SCL_BANK and FMI_SW_SCL_PIN
55#endif
56static int fmradio_i2c_bus = -1;
57
58static void i2c_scl_dir(bool out)
59{
60 imx233_pinctrl_enable_gpio(FMI_SW_SCL_BANK, FMI_SW_SCL_PIN, out);
61}
62
63static void i2c_sda_dir(bool out)
64{
65 imx233_pinctrl_enable_gpio(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, out);
66}
67
68static void i2c_scl_out(bool high)
69{
70 imx233_pinctrl_set_gpio(FMI_SW_SCL_BANK, FMI_SW_SCL_PIN, high);
71}
72
73static void i2c_sda_out(bool high)
74{
75 imx233_pinctrl_set_gpio(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, high);
76}
77
78static bool i2c_scl_in(void)
79{
80 return imx233_pinctrl_get_gpio(FMI_SW_SCL_BANK, FMI_SW_SCL_PIN);
81}
82
83static bool i2c_sda_in(void)
84{
85 return imx233_pinctrl_get_gpio(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN);
86}
87
88static void i2c_delay(int d)
89{
90 udelay(d);
91}
92
93struct i2c_interface fmradio_i2c =
94{
95 .scl_dir = i2c_scl_dir,
96 .sda_dir = i2c_sda_dir,
97 .scl_out = i2c_scl_out,
98 .sda_out = i2c_sda_out,
99 .scl_in = i2c_scl_in,
100 .sda_in = i2c_sda_in,
101 .delay = i2c_delay,
102 .delay_hd_sta = 4,
103 .delay_hd_dat = 5,
104 .delay_su_dat = 1,
105 .delay_su_sto = 4,
106 .delay_su_sta = 5,
107 .delay_thigh = 4
108};
109
110void fmradio_i2c_init(void)
111{
112 imx233_pinctrl_acquire(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, "fmradio_i2c_sda");
113 imx233_pinctrl_acquire(FMI_SW_SCL_BANK, FMI_SW_SCL_BANK, "fmradio_i2c_scl");
114 imx233_pinctrl_set_function(FMI_SW_SDA_BANK, FMI_SW_SDA_PIN, PINCTRL_FUNCTION_GPIO);
115 imx233_pinctrl_set_function(FMI_SW_SCL_BANK, FMI_SW_SCL_BANK, PINCTRL_FUNCTION_GPIO);
116 fmradio_i2c_bus = i2c_add_node(&fmradio_i2c);
117}
118
119int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
120{
121 return i2c_write_data(fmradio_i2c_bus, address, -1, buf, count);
122}
123
124int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
125{
126 return i2c_read_data(fmradio_i2c_bus, address, -1, buf, count);
127}
128#else
129#error Invalid value for IMX233_FMRADIO_I2C
130#endif
131
132static bool tuner_enable = false;
133
134bool tuner_power(bool enable)
135{
136 if(enable != tuner_enable)
137 {
138 tuner_enable = enable;
139#if IMX233_FMRADIO_POWER == FMP_GPIO
140 static bool init = false;
141 if(!init)
142 {
143 /* CE is B0P29 (active high) */
144 imx233_pinctrl_acquire(FMP_GPIO_BANK, FMP_GPIO_PIN, "tuner_power");
145 imx233_pinctrl_set_function(FMP_GPIO_BANK, FMP_GPIO_PIN, PINCTRL_FUNCTION_GPIO);
146 imx233_pinctrl_enable_gpio(FMP_GPIO_BANK, FMP_GPIO_PIN, true);
147 }
148 imx233_pinctrl_set_gpio(FMP_GPIO_BANK, FMP_GPIO_PIN, enable);
149 /* power up delay */
150 sleep(FMP_GPIO_DELAY);
151#elif IMX233_FMRADIO_POWER == FMP_NONE
152#else
153#error Invalid value for IMX233_FMRADIO_POWER
154#endif
155 }
156 return tuner_enable;
157}
158
159bool tuner_powered(void)
160{
161 return tuner_enable;
162}
diff --git a/firmware/target/arm/imx233/fmradio-imx233.h b/firmware/target/arm/imx233/fmradio-imx233.h
new file mode 100644
index 0000000000..d53336dd40
--- /dev/null
+++ b/firmware/target/arm/imx233/fmradio-imx233.h
@@ -0,0 +1,64 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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#ifndef __fmradio_imx233__
22#define __fmradio_imx233__
23
24#include "config.h"
25#include "tuner.h"
26#include "fmradio_i2c.h"
27#include "tuner.h"
28
29/** This driver implements fmradio i2c and tuner power in a generic way. It
30 * currently provides two possible implementation of i2c:
31 * - hardware using i2c-imx233 driver
32 * - software using generic-i2c driver
33 * And it provides tuner power by toggling an optional GPIO.
34 * It can be tweaked using the following defines
35 * and variables:
36 * - IMX233_FMRADIO_I2C
37 * - IMX233_FMRADIO_POWER
38 *
39 * The available values of IMX233_FMRADIO_I2C are:
40 * - FMI_HW: use hardware i2c driver
41 * - FMI_SW: use software i2c driver, needs additional defines:
42 * + FMI_SW_SDA_BANK: the SDA pin bank
43 * + FMI_SW_SDA_PIN: the SDA pin within bank
44 * + FMI_SW_SCL_BANK: the SCL pin bank
45 * + FMI_SW_SCL_PIN: the SCL pin bank
46 * The available values of IMX233_FMRADIO_POWER are:
47 * - FMP_NONE: tuner has no power control
48 * - FMP_GPIO: tuner power is controlled by a GPIO, needs additional defines:
49 * + FMP_GPIO_BANK: pin bank
50 * + FMP_GPIO_PIN: pin within bank
51 * + FMP_GPIO_INVERTED: define if inverted, default is active high
52 * + FMP_GPIO_DELAY: delay to power up/down (in ticks)
53 */
54
55/* i2c method */
56#define FMI_HW 0
57#define FMI_SW 1
58
59/* power method */
60#define FMP_NONE 0
61#define FMP_GPIO 1
62
63#endif /* __fmradio_imx233__ */
64
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c
index 15e061103f..2167bb6897 100644
--- a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c
@@ -21,91 +21,17 @@
21 21
22#include "config.h" 22#include "config.h"
23#include "system.h" 23#include "system.h"
24#include "fmradio_i2c.h"
25#include "pinctrl-imx233.h" 24#include "pinctrl-imx233.h"
26#include "generic_i2c.h"
27#include "rds.h" 25#include "rds.h"
28#include "si4700.h" 26#include "si4700.h"
29 27
30/** 28/**
31 * Sansa Fuze+ fmradio uses the following pins: 29 * Sansa Fuze+ fmradio uses the following pins:
32 * - B0P29 as CE apparently (active high) 30 * - B0P29 as CE (active high)
33 * - B1P24 as SDA 31 * - B1P24 as SDA
34 * - B1P22 as SCL 32 * - B1P22 as SCL
35 * - B2P27 as STC/RDS 33 * - B2P27 as STC/RDS
36 */ 34 */
37static int fmradio_i2c_bus = -1;
38
39static void i2c_scl_dir(bool out)
40{
41 imx233_pinctrl_enable_gpio(1, 22, out);
42}
43
44static void i2c_sda_dir(bool out)
45{
46 imx233_pinctrl_enable_gpio(1, 24, out);
47}
48
49static void i2c_scl_out(bool high)
50{
51 imx233_pinctrl_set_gpio(1, 22, high);
52}
53
54static void i2c_sda_out(bool high)
55{
56 imx233_pinctrl_set_gpio(1, 24, high);
57}
58
59static bool i2c_scl_in(void)
60{
61 return imx233_pinctrl_get_gpio(1, 22);
62}
63
64static bool i2c_sda_in(void)
65{
66 return imx233_pinctrl_get_gpio(1, 24);
67}
68
69static void i2c_delay(int d)
70{
71 udelay(d);
72}
73
74struct i2c_interface fmradio_i2c =
75{
76 .scl_dir = i2c_scl_dir,
77 .sda_dir = i2c_sda_dir,
78 .scl_out = i2c_scl_out,
79 .sda_out = i2c_sda_out,
80 .scl_in = i2c_scl_in,
81 .sda_in = i2c_sda_in,
82 .delay = i2c_delay,
83 .delay_hd_sta = 4,
84 .delay_hd_dat = 5,
85 .delay_su_dat = 1,
86 .delay_su_sto = 4,
87 .delay_su_sta = 5,
88 .delay_thigh = 4
89};
90
91void fmradio_i2c_init(void)
92{
93 imx233_pinctrl_acquire(1, 24, "fmradio i2c");
94 imx233_pinctrl_acquire(1, 22, "fmradio i2c");
95 imx233_pinctrl_set_function(1, 24, PINCTRL_FUNCTION_GPIO);
96 imx233_pinctrl_set_function(1, 22, PINCTRL_FUNCTION_GPIO);
97 fmradio_i2c_bus = i2c_add_node(&fmradio_i2c);
98}
99
100int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
101{
102 return i2c_write_data(fmradio_i2c_bus, address, -1, buf, count);
103}
104
105int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
106{
107 return i2c_read_data(fmradio_i2c_bus, address, -1, buf, count);
108}
109 35
110#ifdef HAVE_RDS_CAP 36#ifdef HAVE_RDS_CAP
111/* Low-level RDS Support */ 37/* Low-level RDS Support */
diff --git a/firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-target.h
index a1377ce1f2..4c3aa0b4e5 100644
--- a/firmware/target/arm/imx233/creative-zen/fmradio-i2c-zen.c
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-target.h
@@ -18,23 +18,18 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#ifndef _FMRADIO_TARGET_H_
22#define _FMRADIO_TARGET_H_
21 23
22#include "config.h" 24#define IMX233_FMRADIO_I2C FMI_SW
23#include "system.h" 25#define FMI_SW_SDA_BANK 1
24#include "fmradio_i2c.h" 26#define FMI_SW_SDA_PIN 24
25#include "pinctrl-imx233.h" 27#define FMI_SW_SCL_BANK 1
26#include "i2c.h" 28#define FMI_SW_SCL_PIN 22
27 29
28void fmradio_i2c_init(void) 30#define IMX233_FMRADIO_POWER FMP_GPIO
29{ 31#define FMP_GPIO_BANK 0
30} 32#define FMP_GPIO_PIN 29
33#define FMP_GPIO_DELAY (HZ / 10)
31 34
32int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) 35#endif /* _FMRADIO_TARGET_H_ */
33{
34 return i2c_write(address, buf, count);
35}
36
37int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
38{
39 return i2c_read(address, buf, count);
40}
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c
deleted file mode 100644
index be087eb140..0000000000
--- a/firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c
+++ /dev/null
@@ -1,53 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 by Amaury Pouly
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 "system.h"
23#include "power.h"
24#include "tuner.h"
25#include "fmradio_i2c.h"
26#include "pinctrl-imx233.h"
27#include "power-imx233.h"
28
29static bool tuner_enable = false;
30
31bool tuner_power(bool enable)
32{
33 if(enable != tuner_enable)
34 {
35 /* CE is B0P29 (active high) */
36 imx233_pinctrl_acquire(0, 29, "tuner power");
37 imx233_pinctrl_set_function(0, 29, PINCTRL_FUNCTION_GPIO);
38 imx233_pinctrl_set_drive(0, 29, PINCTRL_DRIVE_4mA);
39 imx233_pinctrl_enable_gpio(0, 29, enable);
40 imx233_pinctrl_set_gpio(0, 29, enable);
41 tuner_enable = enable;
42 /* give time to power up, datasheet states than minimum timing time is
43 * around 100µs so 1 tick should do */
44 sleep(1);
45 //imx233_power_set_dcdc_freq(enable, HW_POWER_MISC__FREQSEL__24MHz);
46 }
47 return tuner_enable;
48}
49
50bool tuner_powered(void)
51{
52 return tuner_enable;
53}
diff --git a/firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c b/firmware/target/arm/imx233/sony-nwz/fmradio-target.h
index a1377ce1f2..e6869dc2a5 100644
--- a/firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c
+++ b/firmware/target/arm/imx233/sony-nwz/fmradio-target.h
@@ -18,23 +18,11 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#ifndef _FMRADIO_TARGET_H_
22#define _FMRADIO_TARGET_H_
21 23
22#include "config.h" 24#define IMX233_FMRADIO_I2C FMI_HW
23#include "system.h"
24#include "fmradio_i2c.h"
25#include "pinctrl-imx233.h"
26#include "i2c.h"
27 25
28void fmradio_i2c_init(void) 26#define IMX233_FMRADIO_POWER FMP_NONE
29{
30}
31 27
32int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) 28#endif /* _FMRADIO_TARGET_H_ */
33{
34 return i2c_write(address, buf, count);
35}
36
37int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
38{
39 return i2c_read(address, buf, count);
40}