summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/sansa-fuzeplus
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx233/sansa-fuzeplus')
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c76
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/fmradio-target.h35
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/power-fuzeplus.c53
3 files changed, 36 insertions, 128 deletions
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/sansa-fuzeplus/fmradio-target.h b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-target.h
new file mode 100644
index 0000000000..4c3aa0b4e5
--- /dev/null
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-target.h
@@ -0,0 +1,35 @@
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_TARGET_H_
22#define _FMRADIO_TARGET_H_
23
24#define IMX233_FMRADIO_I2C FMI_SW
25#define FMI_SW_SDA_BANK 1
26#define FMI_SW_SDA_PIN 24
27#define FMI_SW_SCL_BANK 1
28#define FMI_SW_SCL_PIN 22
29
30#define IMX233_FMRADIO_POWER FMP_GPIO
31#define FMP_GPIO_BANK 0
32#define FMP_GPIO_PIN 29
33#define FMP_GPIO_DELAY (HZ / 10)
34
35#endif /* _FMRADIO_TARGET_H_ */
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}