diff options
Diffstat (limited to 'firmware/target/arm/sandisk/sansa-e200/power-e200.c')
-rw-r--r-- | firmware/target/arm/sandisk/sansa-e200/power-e200.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/power-e200.c b/firmware/target/arm/sandisk/sansa-e200/power-e200.c index dfa4211a91..002dcb8407 100644 --- a/firmware/target/arm/sandisk/sansa-e200/power-e200.c +++ b/firmware/target/arm/sandisk/sansa-e200/power-e200.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "system.h" | 21 | #include "system.h" |
22 | #include "cpu.h" | 22 | #include "cpu.h" |
23 | #include "i2c-pp.h" | 23 | #include "i2c-pp.h" |
24 | #include "tuner.h" | ||
24 | 25 | ||
25 | void power_init(void) | 26 | void power_init(void) |
26 | { | 27 | { |
@@ -61,3 +62,60 @@ void ide_power_enable(bool on) | |||
61 | { | 62 | { |
62 | (void)on; | 63 | (void)on; |
63 | } | 64 | } |
65 | |||
66 | /** Tuner **/ | ||
67 | static bool powered = false; | ||
68 | |||
69 | bool tuner_power(bool status) | ||
70 | { | ||
71 | bool old_status = powered; | ||
72 | |||
73 | if (status != old_status) | ||
74 | { | ||
75 | if (status) | ||
76 | { | ||
77 | /* init mystery amplification device */ | ||
78 | outl(inl(0x70000084) | 0x1, 0x70000084); | ||
79 | udelay(5); | ||
80 | |||
81 | /* When power up, host should initialize the 3-wire bus | ||
82 | in host read mode: */ | ||
83 | |||
84 | /* 1. Set direction of the DATA-line to input-mode. */ | ||
85 | GPIOH_OUTPUT_EN &= ~(1 << 5); | ||
86 | GPIOH_ENABLE |= (1 << 5); | ||
87 | |||
88 | /* 2. Drive NR_W low */ | ||
89 | GPIOH_OUTPUT_VAL &= ~(1 << 3); | ||
90 | GPIOH_OUTPUT_EN |= (1 << 3); | ||
91 | GPIOH_ENABLE |= (1 << 3); | ||
92 | |||
93 | /* 3. Drive CLOCK high */ | ||
94 | GPIOH_OUTPUT_VAL |= (1 << 4); | ||
95 | GPIOH_OUTPUT_EN |= (1 << 4); | ||
96 | GPIOH_ENABLE |= (1 << 4); | ||
97 | |||
98 | lv24020lp_power(true); | ||
99 | } | ||
100 | else | ||
101 | { | ||
102 | lv24020lp_power(false); | ||
103 | |||
104 | /* set all as inputs */ | ||
105 | GPIOH_OUTPUT_EN &= ~((1 << 5) | (1 << 3) | (1 << 4)); | ||
106 | GPIOH_ENABLE &= ~((1 << 5) | (1 << 3) | (1 << 4)); | ||
107 | |||
108 | /* turn off mystery amplification device */ | ||
109 | outl(inl(0x70000084) & ~0x1, 0x70000084); | ||
110 | } | ||
111 | |||
112 | powered = status; | ||
113 | } | ||
114 | |||
115 | return old_status; | ||
116 | } | ||
117 | |||
118 | bool tuner_powered(void) | ||
119 | { | ||
120 | return powered; | ||
121 | } | ||