diff options
Diffstat (limited to 'firmware/target')
14 files changed, 464 insertions, 10 deletions
diff --git a/firmware/target/arm/adc-pp5020.c b/firmware/target/arm/adc-pp5020.c index 851e907246..d4b4ff5b02 100644 --- a/firmware/target/arm/adc-pp5020.c +++ b/firmware/target/arm/adc-pp5020.c | |||
@@ -59,7 +59,7 @@ unsigned short adc_scan(int channel) | |||
59 | 59 | ||
60 | adcdata[channel] = (adc_data_1<<2 | adc_data_2); | 60 | adcdata[channel] = (adc_data_1<<2 | adc_data_2); |
61 | 61 | ||
62 | #if !defined(PHILIPS_HDD1630) | 62 | #if !(defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330)) |
63 | /* ADC values read low if PLL is enabled */ | 63 | /* ADC values read low if PLL is enabled */ |
64 | if(PLL_CONTROL & 0x80000000){ | 64 | if(PLL_CONTROL & 0x80000000){ |
65 | adcdata[channel] += 0x14; | 65 | adcdata[channel] += 0x14; |
@@ -94,7 +94,7 @@ static void adc_tick(void) | |||
94 | /* Figured out from how the OF does things */ | 94 | /* Figured out from how the OF does things */ |
95 | void adc_init(void) | 95 | void adc_init(void) |
96 | { | 96 | { |
97 | #if defined(PHILIPS_HDD1630) | 97 | #if defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) |
98 | ADC_INIT = 0; | 98 | ADC_INIT = 0; |
99 | #else | 99 | #else |
100 | ADC_INIT |= 1; | 100 | ADC_INIT |= 1; |
@@ -119,7 +119,7 @@ void adc_init(void) | |||
119 | ADC_ADDR = 0; | 119 | ADC_ADDR = 0; |
120 | ADC_ADDR |= 0x40; | 120 | ADC_ADDR |= 0x40; |
121 | 121 | ||
122 | #if !defined(PHILIPS_HDD1630) | 122 | #if !(defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330)) |
123 | ADC_ADDR |= 0x20000000; | 123 | ADC_ADDR |= 0x20000000; |
124 | udelay(100); | 124 | udelay(100); |
125 | 125 | ||
@@ -155,7 +155,7 @@ void adc_init(void) | |||
155 | ADC_STATUS |= 0x20000000; | 155 | ADC_STATUS |= 0x20000000; |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | #if defined(PHILIPS_HDD1630) | 158 | #if defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) |
159 | ADC_INIT |= 0x80000000; | 159 | ADC_INIT |= 0x80000000; |
160 | udelay(100); | 160 | udelay(100); |
161 | ADC_INIT = 0; | 161 | ADC_INIT = 0; |
diff --git a/firmware/target/arm/crt0-pp-bl.S b/firmware/target/arm/crt0-pp-bl.S index 1d2909e7f4..79235a6371 100644 --- a/firmware/target/arm/crt0-pp-bl.S +++ b/firmware/target/arm/crt0-pp-bl.S | |||
@@ -156,7 +156,7 @@ cpu: | |||
156 | mov r1, #WAKE | 156 | mov r1, #WAKE |
157 | str r1, [r0] | 157 | str r1, [r0] |
158 | 158 | ||
159 | #if defined(SANSA_C200) || defined(PHILIPS_HDD1630) | 159 | #if defined(SANSA_C200) || defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) |
160 | /* Magic for loading the c200 OF */ | 160 | /* Magic for loading the c200 OF */ |
161 | ldr r0, =0xb00d10ad | 161 | ldr r0, =0xb00d10ad |
162 | mov r1, #0x700 | 162 | mov r1, #0x700 |
diff --git a/firmware/target/arm/i2c-pp.c b/firmware/target/arm/i2c-pp.c index 60497b04b9..9b92e3b8f1 100644 --- a/firmware/target/arm/i2c-pp.c +++ b/firmware/target/arm/i2c-pp.c | |||
@@ -269,8 +269,8 @@ void i2c_init(void) | |||
269 | 269 | ||
270 | #if CONFIG_I2C == I2C_PP5020 | 270 | #if CONFIG_I2C == I2C_PP5020 |
271 | outl(0x0, 0x600060a4); | 271 | outl(0x0, 0x600060a4); |
272 | #if defined(PHILIPS_HDD1630) || defined(SAMSUNG_YH820) || \ | 272 | #if defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) || \ |
273 | defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) | 273 | defined(SAMSUNG_YH820) || defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) |
274 | outl(inl(0x600060a4) | 0x20, 0x600060a4); | 274 | outl(inl(0x600060a4) | 0x20, 0x600060a4); |
275 | outl(inl(0x7000c020) | 0x3, 0x7000c020); | 275 | outl(inl(0x7000c020) | 0x3, 0x7000c020); |
276 | outl(0x55, 0x7000c02c); | 276 | outl(0x55, 0x7000c02c); |
diff --git a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c b/firmware/target/arm/philips/backlight-hdd.c index cc8f04dda9..cc8f04dda9 100644 --- a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c +++ b/firmware/target/arm/philips/backlight-hdd.c | |||
diff --git a/firmware/target/arm/philips/hdd1630/backlight-target.h b/firmware/target/arm/philips/backlight-target.h index c7aca54a23..c7aca54a23 100644 --- a/firmware/target/arm/philips/hdd1630/backlight-target.h +++ b/firmware/target/arm/philips/backlight-target.h | |||
diff --git a/firmware/target/arm/philips/hdd1630/fmradio_i2c-hdd1630.c b/firmware/target/arm/philips/fmradio_i2c-hdd.c index 98fe5f64ab..98fe5f64ab 100644 --- a/firmware/target/arm/philips/hdd1630/fmradio_i2c-hdd1630.c +++ b/firmware/target/arm/philips/fmradio_i2c-hdd.c | |||
diff --git a/firmware/target/arm/philips/hdd6330/adc-target.h b/firmware/target/arm/philips/hdd6330/adc-target.h new file mode 100644 index 0000000000..bf97081e35 --- /dev/null +++ b/firmware/target/arm/philips/hdd6330/adc-target.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #define NUM_ADC_CHANNELS 2 | ||
25 | |||
26 | #define ADC_BATTERY 0 | ||
27 | #define ADC_UNKNOWN_1 1 | ||
28 | #define ADC_UNKNOWN_2 2 | ||
29 | #define ADC_UNKNOWN_3 3 | ||
30 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
31 | |||
32 | /* Force a scan now */ | ||
33 | unsigned short adc_scan(int channel); | ||
34 | |||
35 | #endif | ||
diff --git a/firmware/target/arm/philips/hdd6330/button-hdd6330.c b/firmware/target/arm/philips/hdd6330/button-hdd6330.c new file mode 100644 index 0000000000..ab06c0cf1a --- /dev/null +++ b/firmware/target/arm/philips/hdd6330/button-hdd6330.c | |||
@@ -0,0 +1,125 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Mark Arigo | ||
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 "button.h" | ||
24 | #include "backlight.h" | ||
25 | #include "synaptics-mep.h" | ||
26 | |||
27 | /*#define LOGF_ENABLE*/ | ||
28 | #include "logf.h" | ||
29 | |||
30 | static int int_btn = BUTTON_NONE; | ||
31 | |||
32 | /* | ||
33 | * Generate a click sound from the player (not in headphones yet) | ||
34 | * TODO: integrate this with the "key click" option | ||
35 | */ | ||
36 | void button_click(void) | ||
37 | { | ||
38 | GPO32_ENABLE |= 0x2000; | ||
39 | GPO32_VAL |= 0x2000; | ||
40 | udelay(1000); | ||
41 | GPO32_VAL &= ~0x2000; | ||
42 | } | ||
43 | |||
44 | #ifndef BOOTLOADER | ||
45 | void button_init_device(void) | ||
46 | { | ||
47 | /* The touchpad is powered on and initialized in power-hdd1630.c | ||
48 | since it needs to be ready for both buttons and button lights. */ | ||
49 | } | ||
50 | |||
51 | /* | ||
52 | * Button interrupt handler | ||
53 | */ | ||
54 | void button_int(void) | ||
55 | { | ||
56 | char data[4]; | ||
57 | int val; | ||
58 | |||
59 | int_btn = BUTTON_NONE; | ||
60 | |||
61 | val = touchpad_read_device(data, 4); | ||
62 | |||
63 | if (val == MEP_BUTTON_HEADER) | ||
64 | { | ||
65 | /* Buttons packet */ | ||
66 | if (data[1] & 0x1) | ||
67 | int_btn |= BUTTON_LEFT; | ||
68 | if (data[1] & 0x2) | ||
69 | int_btn |= BUTTON_RIGHT; | ||
70 | } | ||
71 | else if (val == MEP_ABSOLUTE_HEADER) | ||
72 | { | ||
73 | /* Absolute packet - the finger is on the vertical strip. | ||
74 | Position ranges from 1-4095, with 1 at the bottom. */ | ||
75 | val = ((data[1] >> 4) << 8) | data[2]; /* position */ | ||
76 | |||
77 | if ((val > 0) && (val <= 1365)) | ||
78 | int_btn |= BUTTON_DOWN; | ||
79 | else if ((val > 1365) && (val <= 2730)) | ||
80 | int_btn |= BUTTON_SELECT; | ||
81 | else if ((val > 2730) && (val <= 4095)) | ||
82 | int_btn |= BUTTON_UP; | ||
83 | } | ||
84 | } | ||
85 | #else | ||
86 | void button_init_device(void){} | ||
87 | #endif /* bootloader */ | ||
88 | |||
89 | bool button_hold(void) | ||
90 | { | ||
91 | return !(GPIOJ_INPUT_VAL & 0x8); | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | * Get button pressed from hardware | ||
96 | */ | ||
97 | int button_read_device(void) | ||
98 | { | ||
99 | static int btn_old = BUTTON_NONE; | ||
100 | int btn = int_btn; | ||
101 | |||
102 | /* Hold */ | ||
103 | if(button_hold()) | ||
104 | return BUTTON_NONE; | ||
105 | |||
106 | /* Device buttons */ | ||
107 | if (!(GPIOA_INPUT_VAL & 0x01)) btn |= BUTTON_MENU; | ||
108 | if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_VOL_UP; | ||
109 | if (!(GPIOA_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; | ||
110 | if (!(GPIOA_INPUT_VAL & 0x08)) btn |= BUTTON_VIEW; | ||
111 | if (!(GPIOD_INPUT_VAL & 0x20)) btn |= BUTTON_PLAYLIST; | ||
112 | if (!(GPIOD_INPUT_VAL & 0x40)) btn |= BUTTON_POWER; | ||
113 | |||
114 | if ((btn != btn_old) && (btn != BUTTON_NONE)) | ||
115 | button_click(); | ||
116 | |||
117 | btn_old = btn; | ||
118 | |||
119 | return btn; | ||
120 | } | ||
121 | |||
122 | bool headphones_inserted(void) | ||
123 | { | ||
124 | return (GPIOE_INPUT_VAL & 0x80) ? true : false; | ||
125 | } | ||
diff --git a/firmware/target/arm/philips/hdd6330/button-target.h b/firmware/target/arm/philips/hdd6330/button-target.h new file mode 100644 index 0000000000..b7fc21aca2 --- /dev/null +++ b/firmware/target/arm/philips/hdd6330/button-target.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Mark Arigo | ||
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 | #ifndef _BUTTON_TARGET_H_ | ||
23 | #define _BUTTON_TARGET_H_ | ||
24 | |||
25 | #include <stdbool.h> | ||
26 | #include "config.h" | ||
27 | |||
28 | #define MEP_BUTTON_HEADER 0x19 | ||
29 | #define MEP_BUTTON_ID 0x9 | ||
30 | #define MEP_ABSOLUTE_HEADER 0x0b | ||
31 | |||
32 | #define HAS_BUTTON_HOLD | ||
33 | |||
34 | bool button_hold(void); | ||
35 | void button_init_device(void); | ||
36 | int button_read_device(void); | ||
37 | |||
38 | #ifndef BOOTLOADER | ||
39 | void button_int(void); | ||
40 | #endif | ||
41 | |||
42 | /* Main unit's buttons */ | ||
43 | #define BUTTON_POWER 0x00000001 | ||
44 | #define BUTTON_PLAYLIST 0x00000002 | ||
45 | #define BUTTON_MENU 0x00000004 | ||
46 | #define BUTTON_VIEW 0x00000008 | ||
47 | #define BUTTON_VOL_UP 0x00000010 | ||
48 | #define BUTTON_VOL_DOWN 0x00000020 | ||
49 | #define BUTTON_SELECT 0x00000040 | ||
50 | #define BUTTON_LEFT 0x00000080 | ||
51 | #define BUTTON_RIGHT 0x00000100 | ||
52 | #define BUTTON_UP 0x00000200 | ||
53 | #define BUTTON_DOWN 0x00000400 | ||
54 | |||
55 | #define BUTTON_MAIN 0x00000fff | ||
56 | |||
57 | /* No Remote control */ | ||
58 | #define BUTTON_REMOTE 0 | ||
59 | |||
60 | #define POWEROFF_BUTTON BUTTON_POWER | ||
61 | #define POWEROFF_COUNT 10 | ||
62 | |||
63 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c b/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c new file mode 100644 index 0000000000..3d9cb036f1 --- /dev/null +++ b/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c | |||
@@ -0,0 +1,159 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Mark Arigo | ||
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 "config.h" | ||
22 | #include "cpu.h" | ||
23 | #include "lcd.h" | ||
24 | #include "kernel.h" | ||
25 | #include "system.h" | ||
26 | |||
27 | /* Display status */ | ||
28 | static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; | ||
29 | |||
30 | /* wait for LCD */ | ||
31 | static inline void lcd_wait_write(void) | ||
32 | { | ||
33 | int i = 0; | ||
34 | while (LCD2_PORT & LCD2_BUSY_MASK) | ||
35 | { | ||
36 | if (i < 2000) | ||
37 | i++; | ||
38 | else | ||
39 | LCD2_PORT &= ~LCD2_BUSY_MASK; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | /* send LCD data */ | ||
44 | static void lcd_send_data(unsigned data) | ||
45 | { | ||
46 | lcd_wait_write(); | ||
47 | LCD2_PORT = LCD2_DATA_MASK | (data & 0xff); | ||
48 | } | ||
49 | |||
50 | /* send LCD command */ | ||
51 | static void lcd_send_cmd(unsigned cmd) | ||
52 | { | ||
53 | lcd_wait_write(); | ||
54 | LCD2_PORT = LCD2_CMD_MASK | (cmd & 0xff); | ||
55 | lcd_wait_write(); | ||
56 | } | ||
57 | |||
58 | static inline void lcd_send_pixel(unsigned pixel) | ||
59 | { | ||
60 | lcd_send_data(pixel >> 8); | ||
61 | lcd_send_data(pixel); | ||
62 | } | ||
63 | |||
64 | void lcd_init_device(void) | ||
65 | { | ||
66 | /* init handled by the OF bootloader */ | ||
67 | } | ||
68 | |||
69 | /*** hardware configuration ***/ | ||
70 | int lcd_default_contrast(void) | ||
71 | { | ||
72 | return DEFAULT_CONTRAST_SETTING; | ||
73 | } | ||
74 | |||
75 | void lcd_set_contrast(int val) | ||
76 | { | ||
77 | (void)val; | ||
78 | } | ||
79 | |||
80 | void lcd_set_invert_display(bool yesno) | ||
81 | { | ||
82 | (void)yesno; | ||
83 | } | ||
84 | |||
85 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
86 | void lcd_set_flip(bool yesno) | ||
87 | { | ||
88 | (void)yesno; | ||
89 | } | ||
90 | |||
91 | void lcd_yuv_set_options(unsigned options) | ||
92 | { | ||
93 | lcd_yuv_options = options; | ||
94 | } | ||
95 | |||
96 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
97 | void lcd_blit_yuv(unsigned char * const src[3], | ||
98 | int src_x, int src_y, int stride, | ||
99 | int x, int y, int width, int height) | ||
100 | { | ||
101 | (void)src; | ||
102 | (void)src_x; | ||
103 | (void)src_y; | ||
104 | (void)stride; | ||
105 | (void)x; | ||
106 | (void)y; | ||
107 | (void)width; | ||
108 | (void)height; | ||
109 | } | ||
110 | |||
111 | /* Update the display. | ||
112 | This must be called after all other LCD functions that change the display. */ | ||
113 | void lcd_update(void) | ||
114 | { | ||
115 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
116 | } | ||
117 | |||
118 | /* Update a fraction of the display. */ | ||
119 | void lcd_update_rect(int x, int y, int width, int height) | ||
120 | { | ||
121 | const fb_data *addr; | ||
122 | |||
123 | if (x + width >= LCD_WIDTH) | ||
124 | width = LCD_WIDTH - x; | ||
125 | if (y + height >= LCD_HEIGHT) | ||
126 | height = LCD_HEIGHT - y; | ||
127 | |||
128 | if ((width <= 0) || (height <= 0)) | ||
129 | return; /* Nothing left to do. */ | ||
130 | |||
131 | addr = &lcd_framebuffer[y][x]; | ||
132 | |||
133 | lcd_send_cmd(0x01); | ||
134 | lcd_send_data(0x48); | ||
135 | |||
136 | lcd_send_cmd(0x05); | ||
137 | lcd_send_data(0x0f); | ||
138 | |||
139 | lcd_send_cmd(0x08); | ||
140 | lcd_send_data(y); | ||
141 | |||
142 | lcd_send_cmd(0x09); | ||
143 | lcd_send_data(y + height - 1); | ||
144 | |||
145 | lcd_send_cmd(0x0a); | ||
146 | lcd_send_data(x + 16); | ||
147 | |||
148 | lcd_send_cmd(0x0b); | ||
149 | lcd_send_data(x + width - 1 + 16); | ||
150 | |||
151 | lcd_send_cmd(0x06); | ||
152 | do { | ||
153 | int w = width; | ||
154 | do { | ||
155 | lcd_send_pixel(*addr++); | ||
156 | } while (--w > 0); | ||
157 | addr += LCD_WIDTH - width; | ||
158 | } while (--height > 0); | ||
159 | } | ||
diff --git a/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c b/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c new file mode 100644 index 0000000000..33bbb6af48 --- /dev/null +++ b/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c | |||
@@ -0,0 +1,72 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese | ||
11 | * Revisions copyright (C) 2005 by Gerald Van Baren | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "adc.h" | ||
25 | #include "powermgmt.h" | ||
26 | |||
27 | #define SMLAL(lo, hi, x, y) \ | ||
28 | asm volatile ("smlal %0, %1, %2, %3" \ | ||
29 | : "+r" (lo), "+r" (hi) \ | ||
30 | : "%r" (x), "r" (y)) | ||
31 | |||
32 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
33 | { | ||
34 | 3550 | ||
35 | }; | ||
36 | |||
37 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
38 | { | ||
39 | 3500 | ||
40 | }; | ||
41 | |||
42 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
43 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
44 | { | ||
45 | { 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990 }, | ||
46 | }; | ||
47 | |||
48 | #if CONFIG_CHARGING | ||
49 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
50 | const unsigned short percent_to_volt_charge[11] = | ||
51 | { | ||
52 | 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990 | ||
53 | }; | ||
54 | #endif /* CONFIG_CHARGING */ | ||
55 | |||
56 | #define BATTERY_SCALE_FACTOR 4200 | ||
57 | /* full-scale ADC readout (2^10) in millivolt */ | ||
58 | |||
59 | /* Returns battery voltage from ADC [millivolts] */ | ||
60 | unsigned int battery_adc_voltage(void) | ||
61 | { | ||
62 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ | ||
63 | |||
64 | /* This may be overly complicated (pulled from the OF) */ | ||
65 | int lo = 0; | ||
66 | int val = adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR; | ||
67 | |||
68 | SMLAL(lo, val, 0x8a42f871, val); | ||
69 | val>>= 9; | ||
70 | val -= (val >> 31); | ||
71 | return val; | ||
72 | } | ||
diff --git a/firmware/target/arm/philips/hdd1630/power-hdd1630.c b/firmware/target/arm/philips/power-hdd.c index c348567529..c348567529 100644 --- a/firmware/target/arm/philips/hdd1630/power-hdd1630.c +++ b/firmware/target/arm/philips/power-hdd.c | |||
diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c index 61d4d7cb59..e2604e7633 100644 --- a/firmware/target/arm/system-pp502x.c +++ b/firmware/target/arm/system-pp502x.c | |||
@@ -143,7 +143,7 @@ void __attribute__((interrupt("IRQ"))) irq_handler(void) | |||
143 | usb_insert_int(); | 143 | usb_insert_int(); |
144 | } | 144 | } |
145 | /* end PHILIPS_SA9200 */ | 145 | /* end PHILIPS_SA9200 */ |
146 | #elif defined(PHILIPS_HDD1630) | 146 | #elif defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) |
147 | else if (CPU_HI_INT_STAT & GPIO0_MASK) { | 147 | else if (CPU_HI_INT_STAT & GPIO0_MASK) { |
148 | if (GPIOA_INT_STAT & 0x20) | 148 | if (GPIOA_INT_STAT & 0x20) |
149 | button_int(); | 149 | button_int(); |
@@ -152,7 +152,7 @@ void __attribute__((interrupt("IRQ"))) irq_handler(void) | |||
152 | if (GPIOE_INT_STAT & 0x04) | 152 | if (GPIOE_INT_STAT & 0x04) |
153 | usb_insert_int(); | 153 | usb_insert_int(); |
154 | } | 154 | } |
155 | /* end PHILIPS_HDD1630 */ | 155 | /* end PHILIPS_HDD1630 || PHILIPS_HDD6330 */ |
156 | #elif defined(SAMSUNG_YH820) || defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) | 156 | #elif defined(SAMSUNG_YH820) || defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) |
157 | else if (CPU_HI_INT_STAT & GPIO0_MASK) { | 157 | else if (CPU_HI_INT_STAT & GPIO0_MASK) { |
158 | if (GPIOD_INT_STAT & 0x10) | 158 | if (GPIOD_INT_STAT & 0x10) |
diff --git a/firmware/target/arm/usb-fw-pp502x.c b/firmware/target/arm/usb-fw-pp502x.c index e234e61031..bc15dc208d 100644 --- a/firmware/target/arm/usb-fw-pp502x.c +++ b/firmware/target/arm/usb-fw-pp502x.c | |||
@@ -70,7 +70,7 @@ | |||
70 | #define USB_GPIO_MASK 0x80 | 70 | #define USB_GPIO_MASK 0x80 |
71 | #define USB_GPIO_VAL 0x00 | 71 | #define USB_GPIO_VAL 0x00 |
72 | 72 | ||
73 | #elif defined(PHILIPS_HDD1630) | 73 | #elif defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) |
74 | /* GPIO E bit 2 is usb detect */ | 74 | /* GPIO E bit 2 is usb detect */ |
75 | #define USB_GPIO GPIOE | 75 | #define USB_GPIO GPIOE |
76 | #define USB_GPIO_MASK 0x04 | 76 | #define USB_GPIO_MASK 0x04 |