diff options
-rw-r--r-- | firmware/SOURCES | 16 | ||||
-rw-r--r-- | firmware/export/config-ipod1g2g.h | 8 | ||||
-rw-r--r-- | firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c | 100 | ||||
-rw-r--r-- | firmware/target/arm/ipod/1g2g/adc-target.h | 34 | ||||
-rw-r--r-- | firmware/target/arm/ipod/adc-ipod-pcf.c (renamed from firmware/target/arm/ipod/adc-ipod.c) | 10 |
5 files changed, 146 insertions, 22 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index b73a82a15c..91cead088d 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -562,7 +562,7 @@ target/arm/wmcodec-pp.c | |||
562 | target/arm/i2s-pp.c | 562 | target/arm/i2s-pp.c |
563 | target/arm/ata-as-arm.S | 563 | target/arm/ata-as-arm.S |
564 | target/arm/ata-pp5020.c | 564 | target/arm/ata-pp5020.c |
565 | target/arm/ipod/adc-ipod.c | 565 | target/arm/ipod/adc-ipod-pcf.c |
566 | target/arm/ipod/backlight-4g_color.c | 566 | target/arm/ipod/backlight-4g_color.c |
567 | target/arm/ipod/button-clickwheel.c | 567 | target/arm/ipod/button-clickwheel.c |
568 | target/arm/ipod/lcd-gray.c | 568 | target/arm/ipod/lcd-gray.c |
@@ -578,7 +578,7 @@ target/arm/ata-as-arm.S | |||
578 | target/arm/ata-pp5020.c | 578 | target/arm/ata-pp5020.c |
579 | target/arm/wmcodec-pp.c | 579 | target/arm/wmcodec-pp.c |
580 | target/arm/i2s-pp.c | 580 | target/arm/i2s-pp.c |
581 | target/arm/ipod/adc-ipod.c | 581 | target/arm/ipod/adc-ipod-pcf.c |
582 | target/arm/ipod/backlight-4g_color.c | 582 | target/arm/ipod/backlight-4g_color.c |
583 | target/arm/ipod/button-clickwheel.c | 583 | target/arm/ipod/button-clickwheel.c |
584 | target/arm/ipod/lcd-color_nano.c | 584 | target/arm/ipod/lcd-color_nano.c |
@@ -594,7 +594,7 @@ target/arm/ata-as-arm.S | |||
594 | target/arm/ata-pp5020.c | 594 | target/arm/ata-pp5020.c |
595 | target/arm/wmcodec-pp.c | 595 | target/arm/wmcodec-pp.c |
596 | target/arm/i2s-pp.c | 596 | target/arm/i2s-pp.c |
597 | target/arm/ipod/adc-ipod.c | 597 | target/arm/ipod/adc-ipod-pcf.c |
598 | target/arm/ipod/backlight-nano_video.c | 598 | target/arm/ipod/backlight-nano_video.c |
599 | target/arm/ipod/button-clickwheel.c | 599 | target/arm/ipod/button-clickwheel.c |
600 | target/arm/ipod/lcd-color_nano.c | 600 | target/arm/ipod/lcd-color_nano.c |
@@ -610,7 +610,7 @@ target/arm/ata-as-arm.S | |||
610 | target/arm/ata-pp5020.c | 610 | target/arm/ata-pp5020.c |
611 | target/arm/wmcodec-pp.c | 611 | target/arm/wmcodec-pp.c |
612 | target/arm/i2s-pp.c | 612 | target/arm/i2s-pp.c |
613 | target/arm/ipod/adc-ipod.c | 613 | target/arm/ipod/adc-ipod-pcf.c |
614 | target/arm/ipod/backlight-nano_video.c | 614 | target/arm/ipod/backlight-nano_video.c |
615 | target/arm/ipod/button-clickwheel.c | 615 | target/arm/ipod/button-clickwheel.c |
616 | target/arm/ipod/power-ipod.c | 616 | target/arm/ipod/power-ipod.c |
@@ -625,7 +625,7 @@ drivers/pcf50605.c | |||
625 | target/arm/ata-pp5002.c | 625 | target/arm/ata-pp5002.c |
626 | target/arm/wmcodec-pp.c | 626 | target/arm/wmcodec-pp.c |
627 | target/arm/i2s-pp.c | 627 | target/arm/i2s-pp.c |
628 | target/arm/ipod/adc-ipod.c | 628 | target/arm/ipod/adc-ipod-pcf.c |
629 | target/arm/ipod/3g/backlight-3g.c | 629 | target/arm/ipod/3g/backlight-3g.c |
630 | target/arm/ipod/button-1g-3g.c | 630 | target/arm/ipod/button-1g-3g.c |
631 | target/arm/ipod/lcd-gray.c | 631 | target/arm/ipod/lcd-gray.c |
@@ -639,7 +639,7 @@ target/arm/usb-pp.c | |||
639 | target/arm/ata-pp5002.c | 639 | target/arm/ata-pp5002.c |
640 | target/arm/wmcodec-pp.c | 640 | target/arm/wmcodec-pp.c |
641 | target/arm/i2s-pp.c | 641 | target/arm/i2s-pp.c |
642 | target/arm/ipod/adc-ipod.c | 642 | target/arm/ipod/1g2g/adc-ipod-1g2g.c |
643 | target/arm/ipod/1g2g/backlight-1g2g.c | 643 | target/arm/ipod/1g2g/backlight-1g2g.c |
644 | target/arm/ipod/button-1g-3g.c | 644 | target/arm/ipod/button-1g-3g.c |
645 | target/arm/ipod/lcd-gray.c | 645 | target/arm/ipod/lcd-gray.c |
@@ -654,7 +654,7 @@ target/arm/ata-as-arm.S | |||
654 | target/arm/ata-pp5020.c | 654 | target/arm/ata-pp5020.c |
655 | target/arm/wmcodec-pp.c | 655 | target/arm/wmcodec-pp.c |
656 | target/arm/i2s-pp.c | 656 | target/arm/i2s-pp.c |
657 | target/arm/ipod/adc-ipod.c | 657 | target/arm/ipod/adc-ipod-pcf.c |
658 | target/arm/ipod/backlight-mini1g_mini2g.c | 658 | target/arm/ipod/backlight-mini1g_mini2g.c |
659 | target/arm/ipod/button-mini1g.c | 659 | target/arm/ipod/button-mini1g.c |
660 | target/arm/ipod/lcd-gray.c | 660 | target/arm/ipod/lcd-gray.c |
@@ -670,7 +670,7 @@ target/arm/ata-as-arm.S | |||
670 | target/arm/ata-pp5020.c | 670 | target/arm/ata-pp5020.c |
671 | target/arm/wmcodec-pp.c | 671 | target/arm/wmcodec-pp.c |
672 | target/arm/i2s-pp.c | 672 | target/arm/i2s-pp.c |
673 | target/arm/ipod/adc-ipod.c | 673 | target/arm/ipod/adc-ipod-pcf.c |
674 | target/arm/ipod/backlight-mini1g_mini2g.c | 674 | target/arm/ipod/backlight-mini1g_mini2g.c |
675 | target/arm/ipod/button-clickwheel.c | 675 | target/arm/ipod/button-clickwheel.c |
676 | target/arm/ipod/lcd-gray.c | 676 | target/arm/ipod/lcd-gray.c |
diff --git a/firmware/export/config-ipod1g2g.h b/firmware/export/config-ipod1g2g.h index b69d401f36..188c3930f6 100644 --- a/firmware/export/config-ipod1g2g.h +++ b/firmware/export/config-ipod1g2g.h | |||
@@ -81,11 +81,11 @@ | |||
81 | 81 | ||
82 | /* Type of mobile power */ | 82 | /* Type of mobile power */ |
83 | #define CONFIG_BATTERY BATT_LIPOL1300 | 83 | #define CONFIG_BATTERY BATT_LIPOL1300 |
84 | #define BATTERY_CAPACITY_MIN 630 /* min. capacity selectable */ | 84 | #define BATTERY_CAPACITY_MIN 1200 /* min. capacity selectable */ |
85 | #define BATTERY_CAPACITY_MAX 1000 /* max. capacity selectable */ | 85 | #define BATTERY_CAPACITY_MAX 1900 /* max. capacity selectable */ |
86 | #define BATTERY_CAPACITY_INC 10 /* capacity increment */ | 86 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ |
87 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 87 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
88 | #define BATTERY_SCALE_FACTOR 5865 | 88 | #define BATTERY_SCALE_FACTOR 25882 |
89 | 89 | ||
90 | /* Hardware controlled charging? FIXME */ | 90 | /* Hardware controlled charging? FIXME */ |
91 | //#define CONFIG_CHARGING CHARGING_SIMPLE | 91 | //#define CONFIG_CHARGING CHARGING_SIMPLE |
diff --git a/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c b/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c new file mode 100644 index 0000000000..759b6fb592 --- /dev/null +++ b/firmware/target/arm/ipod/1g2g/adc-ipod-1g2g.c | |||
@@ -0,0 +1,100 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Jens Arnold | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | #include "hwcompat.h" | ||
23 | #include "kernel.h" | ||
24 | |||
25 | static struct mutex adc_mutex NOCACHEBSS_ATTR; | ||
26 | |||
27 | unsigned short adc_scan(int channel) | ||
28 | { | ||
29 | int i, j; | ||
30 | unsigned short data = 0; | ||
31 | unsigned pval; | ||
32 | |||
33 | (void)channel; /* there is only one */ | ||
34 | spinlock_lock(&adc_mutex); | ||
35 | |||
36 | if ((IPOD_HW_REVISION >> 16) == 1) | ||
37 | { | ||
38 | pval = GPIOB_OUTPUT_VAL; | ||
39 | GPIOB_OUTPUT_VAL = pval | 0x04; /* B2 -> high */ | ||
40 | for (i = 32; i > 0; --i); | ||
41 | |||
42 | GPIOB_OUTPUT_VAL = pval; /* B2 -> low */ | ||
43 | for (i = 200; i > 0; --i); | ||
44 | |||
45 | for (j = 0; j < 8; j++) | ||
46 | { | ||
47 | GPIOB_OUTPUT_VAL = pval | 0x02; /* B1 -> high */ | ||
48 | for (i = 8; i > 0; --i); | ||
49 | |||
50 | data = (data << 1) | ((GPIOB_INPUT_VAL & 0x08) >> 3); | ||
51 | |||
52 | GPIOB_OUTPUT_VAL = pval; /* B1 -> low */ | ||
53 | for (i = 320; i > 0; --i); | ||
54 | } | ||
55 | } | ||
56 | else if ((IPOD_HW_REVISION >> 16) == 2) | ||
57 | { | ||
58 | pval = GPIOB_OUTPUT_VAL; | ||
59 | GPIOB_OUTPUT_VAL = pval | 0x0a; /* B1, B3 -> high */ | ||
60 | while (!(GPIOB_INPUT_VAL & 0x04)); /* wait for B2 == 1 */ | ||
61 | |||
62 | GPIOB_OUTPUT_VAL = pval; /* B1, B3 -> low */ | ||
63 | while (GPIOB_INPUT_VAL & 0x04); /* wait for B2 == 0 */ | ||
64 | |||
65 | for (j = 0; j < 8; j++) | ||
66 | { | ||
67 | GPIOB_OUTPUT_VAL = pval | 0x02; /* B1 -> high */ | ||
68 | while (!(GPIOB_INPUT_VAL & 0x04)); /* wait for B2 == 1 */ | ||
69 | |||
70 | data = (data << 1) | ((GPIOB_INPUT_VAL & 0x10) >> 4); | ||
71 | |||
72 | GPIOB_OUTPUT_VAL = pval; /* B1 -> low */ | ||
73 | while (GPIOB_INPUT_VAL & 0x04); /* wait for B2 == 0 */ | ||
74 | } | ||
75 | } | ||
76 | spinlock_unlock(&adc_mutex); | ||
77 | return data; | ||
78 | } | ||
79 | |||
80 | void adc_init(void) | ||
81 | { | ||
82 | spinlock_init(&adc_mutex); | ||
83 | |||
84 | GPIOB_ENABLE |= 0x1e; /* enable B1..B4 */ | ||
85 | |||
86 | if ((IPOD_HW_REVISION >> 16) == 1) | ||
87 | { | ||
88 | GPIOB_OUTPUT_EN = (GPIOB_OUTPUT_EN & ~0x08) | 0x16; | ||
89 | /* B1, B2, B4 -> output, B3 -> input */ | ||
90 | GPIOB_OUTPUT_VAL = (GPIOB_OUTPUT_VAL & ~0x06) | 0x10; | ||
91 | /* B1, B2 -> low, B4 -> high */ | ||
92 | } | ||
93 | else if ((IPOD_HW_REVISION >> 16) == 2) | ||
94 | { | ||
95 | GPIOB_OUTPUT_EN = (GPIOB_OUTPUT_EN & ~0x14) | 0x0a; | ||
96 | /* B1, B3 -> output, B2, B4 -> input */ | ||
97 | GPIOB_OUTPUT_VAL &= ~0x0a; /* B1, B3 -> low */ | ||
98 | while (GPIOB_INPUT_VAL & 0x04); /* wait for B2 == 0 */ | ||
99 | } | ||
100 | } | ||
diff --git a/firmware/target/arm/ipod/1g2g/adc-target.h b/firmware/target/arm/ipod/1g2g/adc-target.h new file mode 100644 index 0000000000..b3f6cd6303 --- /dev/null +++ b/firmware/target/arm/ipod/1g2g/adc-target.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Jens Arnold | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef _ADC_TARGET_H_ | ||
21 | #define _ADC_TARGET_H_ | ||
22 | |||
23 | #define NUM_ADC_CHANNELS 1 | ||
24 | |||
25 | #define ADC_BATTERY 0 | ||
26 | #define ADC_UNREG_POWER ADC_BATTERY | ||
27 | |||
28 | /* Force a scan now */ | ||
29 | unsigned short adc_scan(int channel); | ||
30 | static inline unsigned short adc_read(int channel) | ||
31 | { | ||
32 | return adc_scan(channel); | ||
33 | } | ||
34 | #endif | ||
diff --git a/firmware/target/arm/ipod/adc-ipod.c b/firmware/target/arm/ipod/adc-ipod-pcf.c index 39463af30b..bc2524de5d 100644 --- a/firmware/target/arm/ipod/adc-ipod.c +++ b/firmware/target/arm/ipod/adc-ipod-pcf.c | |||
@@ -36,7 +36,6 @@ static struct adc_struct adcdata[NUM_ADC_CHANNELS] IDATA_ATTR; | |||
36 | 36 | ||
37 | static unsigned short _adc_read(struct adc_struct *adc) | 37 | static unsigned short _adc_read(struct adc_struct *adc) |
38 | { | 38 | { |
39 | #ifndef IPOD_1G2G | ||
40 | if (adc->timeout < current_tick) { | 39 | if (adc->timeout < current_tick) { |
41 | unsigned char data[2]; | 40 | unsigned char data[2]; |
42 | unsigned short value; | 41 | unsigned short value; |
@@ -56,7 +55,6 @@ static unsigned short _adc_read(struct adc_struct *adc) | |||
56 | adc->data = value; | 55 | adc->data = value; |
57 | return value; | 56 | return value; |
58 | } else | 57 | } else |
59 | #endif | ||
60 | { | 58 | { |
61 | return adc->data; | 59 | return adc->data; |
62 | } | 60 | } |
@@ -66,19 +64,11 @@ static unsigned short _adc_read(struct adc_struct *adc) | |||
66 | unsigned short adc_scan(int channel) { | 64 | unsigned short adc_scan(int channel) { |
67 | struct adc_struct *adc = &adcdata[channel]; | 65 | struct adc_struct *adc = &adcdata[channel]; |
68 | adc->timeout = 0; | 66 | adc->timeout = 0; |
69 | #ifdef IPOD_1G2G | ||
70 | if (channel == ADC_UNREG_POWER) | ||
71 | return 681; /* FIXME fake 4.00V */ | ||
72 | #endif | ||
73 | return _adc_read(adc); | 67 | return _adc_read(adc); |
74 | } | 68 | } |
75 | 69 | ||
76 | /* Retrieve the ADC value, only does a scan periodically */ | 70 | /* Retrieve the ADC value, only does a scan periodically */ |
77 | unsigned short adc_read(int channel) { | 71 | unsigned short adc_read(int channel) { |
78 | #ifdef IPOD_1G2G | ||
79 | if (channel == ADC_UNREG_POWER) | ||
80 | return 681; /* FIXME fake 4.00V */ | ||
81 | #endif | ||
82 | return _adc_read(&adcdata[channel]); | 72 | return _adc_read(&adcdata[channel]); |
83 | } | 73 | } |
84 | 74 | ||