From 08585e417b4e545752ff9478d28c4da3e8c09844 Mon Sep 17 00:00:00 2001 From: Mark Arigo Date: Fri, 12 Dec 2008 04:56:25 +0000 Subject: FS#9591 by Anton Veretenenko for the Philips GoGear HDD1620/1630 (with a few changes by me). Fixes boot problem, pixel format, sound, and a few other things. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19395 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/adc-pp5020.c | 22 ++++++++------- .../target/arm/philips/hdd1630/backlight-hdd1630.c | 4 +++ .../target/arm/philips/hdd1630/button-hdd1630.c | 33 ++++++++++++++++++++-- firmware/target/arm/philips/hdd1630/lcd-hdd1630.c | 1 + .../target/arm/philips/hdd1630/power-hdd1630.c | 27 ++++++++++++++++-- .../target/arm/philips/hdd1630/powermgmt-hdd1630.c | 8 ++++-- firmware/target/arm/wmcodec-pp.c | 7 +++-- 7 files changed, 82 insertions(+), 20 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/adc-pp5020.c b/firmware/target/arm/adc-pp5020.c index a8fe8c1560..33950014dc 100644 --- a/firmware/target/arm/adc-pp5020.c +++ b/firmware/target/arm/adc-pp5020.c @@ -35,28 +35,28 @@ unsigned short adc_scan(int channel) /* Start conversion */ ADC_ADDR |= 0x80000000; - + /* Wait for conversion to complete */ while((ADC_STATUS & (0x40<<8*channel))==0); - + /* Stop conversion */ ADC_ADDR &=~ 0x80000000; - + /* ADC_DATA_1 and ADC_DATA_2 are both four bytes, one byte per channel. For each channel, ADC_DATA_1 stores the 8-bit msb, ADC_DATA_2 stores the 2-bit lsb (in bits 0 and 1). Each channel is 10 bits total. */ adc_data_1 = ((ADC_DATA_1 >> (8*channel)) & 0xff); adc_data_2 = ((ADC_DATA_2 >> (8*channel+6)) & 0x3); - + adcdata[channel] = (adc_data_1<<2 | adc_data_2); - + /* ADC values read low if PLL is enabled */ if(PLL_CONTROL & 0x80000000){ adcdata[channel] += 0x14; if(adcdata[channel] > 0x400) adcdata[channel] = 0x400; } - + return adcdata[channel]; } @@ -83,17 +83,18 @@ static void adc_tick(void) /* Figured out from how the OF does things */ void adc_init(void) { + ADC_INIT |= 1; ADC_INIT |= 0x40000000; udelay(100); - + /* Reset ADC */ DEV_RS2 |= 0x20; udelay(100); - + DEV_RS2 &=~ 0x20; udelay(100); - + /* Enable ADC */ DEV_EN2 |= 0x20; udelay(100); @@ -121,7 +122,8 @@ void adc_init(void) ADC_ADDR |= 0x2000000; ADC_STATUS |= 0x2000; -#if defined (IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(MROBE_100) +#if defined (IRIVER_H10) || defined(IRIVER_H10_5GB) || \ + defined(MROBE_100) || defined(PHILIPS_HDD1630) /* Enable channel 2 (H10:remote) */ DEV_INIT1 &=~0x300; DEV_INIT1 |= 0x100; diff --git a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c b/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c index 0c49e65563..eb2c2731ac 100755 --- a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c @@ -34,10 +34,14 @@ void _backlight_set_brightness(int brightness) void _backlight_on(void) { + GPO32_VAL &= ~0x1000000; + GPO32_ENABLE &= ~0x1000000; } void _backlight_off(void) { + GPO32_VAL |= 0x1000000; + GPO32_ENABLE |= 0x1000000; } #ifdef HAVE_BUTTON_LIGHT diff --git a/firmware/target/arm/philips/hdd1630/button-hdd1630.c b/firmware/target/arm/philips/hdd1630/button-hdd1630.c index 3a8f7c5408..84cb8f0c06 100755 --- a/firmware/target/arm/philips/hdd1630/button-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/button-hdd1630.c @@ -23,6 +23,21 @@ #include "button.h" #include "backlight.h" +/* Remember last buttons, to make single buzz sound */ +int btn_old; + +/* + * Generate a click sound from the player (not in headphones yet) + * TODO: integrate this with the "key click" option + */ +void button_click(void) +{ + GPO32_ENABLE |= 0x2000; + GPIOD_OUTPUT_VAL |= 0x8; + udelay(1000); + GPO32_VAL &= ~0x2000; +} + void button_init_device(void) { /* TODO...for now, hardware initialisation is done by the bootloader */ @@ -49,19 +64,33 @@ int button_read_device(void) /* device buttons */ if (!hold_button) { + /* These are the correct button definitions if (!(GPIOA_INPUT_VAL & 0x01)) btn |= BUTTON_MENU; if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_VOL_UP; if (!(GPIOA_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; if (!(GPIOA_INPUT_VAL & 0x08)) btn |= BUTTON_VIEW; - if (!(GPIOD_INPUT_VAL & 0x20)) btn |= BUTTON_PLAYLIST; if (!(GPIOD_INPUT_VAL & 0x40)) btn |= BUTTON_POWER; + */ + + /* This is a hack until the touchpad works */ + if (!(GPIOA_INPUT_VAL & 0x01)) btn |= BUTTON_LEFT; /* BUTTON_MENU */ + if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_UP; /* BUTTON_VOL_UP */ + if (!(GPIOA_INPUT_VAL & 0x04)) btn |= BUTTON_DOWN; /* BUTTON_VOL_DOWN */ + if (!(GPIOA_INPUT_VAL & 0x08)) btn |= BUTTON_RIGHT; /* BUTTON_VIEW */ + if (!(GPIOD_INPUT_VAL & 0x20)) btn |= BUTTON_SELECT; /* BUTTON_PLAYLIST */ + if (!(GPIOD_INPUT_VAL & 0x40)) btn |= BUTTON_POWER; } + if ((btn != btn_old) && (btn != BUTTON_NONE)) + button_click(); + + btn_old = btn; + return btn; } bool headphones_inserted(void) { - return true; + return (GPIOE_INPUT_VAL & 0x80) ? true : false; } diff --git a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c index d7dee2036d..827e3ef8c4 100755 --- a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c @@ -84,6 +84,7 @@ void lcd_init_device(void) LCD2_BLOCK_CTRL = 0x10008080; LCD2_BLOCK_CONFIG = 0xF00000; + /* lcd power */ GPIOJ_ENABLE |= 0x4; GPIOJ_OUTPUT_VAL |= 0x4; GPIOJ_OUTPUT_EN |= 0x4; diff --git a/firmware/target/arm/philips/hdd1630/power-hdd1630.c b/firmware/target/arm/philips/hdd1630/power-hdd1630.c index ade2536154..03a5794791 100755 --- a/firmware/target/arm/philips/hdd1630/power-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/power-hdd1630.c @@ -35,11 +35,30 @@ bool charger_enabled; void power_init(void) { + /* power off bit */ + GPIOB_ENABLE |= 0x80; + GPIOB_OUTPUT_VAL |= 0x80; + GPIOB_OUTPUT_EN |= 0x80; + + /* charger inserted bit */ + GPIOE_ENABLE |= 0x20; + GPIOE_INPUT_VAL |= 0x20; } unsigned int power_input_status(void) -{ - return POWER_INPUT_NONE; +{ + unsigned int status = POWER_INPUT_NONE; + + /* AC charger */ + if (GPIOE_INPUT_VAL & 0x20) + status |= POWER_INPUT_MAIN_CHARGER; + + /* Do nothing with USB for now + if (GPIOE_INPUT_VAL & 0x4) + status |= POWER_INPUT_USB_CHARGER; + */ + + return status; } void ide_power_enable(bool on) @@ -57,4 +76,8 @@ bool ide_powered(void) void power_off(void) { + /* power off bit */ + GPIOB_ENABLE |= 0x80; + GPIOB_OUTPUT_VAL &= ~0x80; + GPIOB_OUTPUT_EN |= 0x80; } diff --git a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c index c8d5584305..0bb9458fe7 100644 --- a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c @@ -26,7 +26,7 @@ const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { - 3450 + 3450 }; const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = @@ -44,7 +44,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ const unsigned short percent_to_volt_charge[11] = { - 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990 + 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990 }; #endif /* CONFIG_CHARGING */ @@ -60,5 +60,7 @@ const unsigned short percent_to_volt_charge[11] = /* Returns battery voltage from ADC [millivolts] */ unsigned int battery_adc_voltage(void) { - return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; + /* For now, assume as battery full (we need to calibrate) */ + /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ + return 3990; } diff --git a/firmware/target/arm/wmcodec-pp.c b/firmware/target/arm/wmcodec-pp.c index 031f5c8d47..bd3d4e6579 100644 --- a/firmware/target/arm/wmcodec-pp.c +++ b/firmware/target/arm/wmcodec-pp.c @@ -32,11 +32,12 @@ #include "i2s.h" #include "wmcodec.h" -#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(MROBE_100) +#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || \ + defined(MROBE_100) || defined(PHILIPS_HDD1630) /* The H10's audio codec uses an I2C address of 0x1b */ #define I2C_AUDIO_ADDRESS 0x1b #else -/* The iPod's audio codecs use an I2C address of 0x1a */ +/* The iPod's audio codecs use an I2C address of 0x1a */ #define I2C_AUDIO_ADDRESS 0x1a #endif @@ -100,7 +101,7 @@ void audiohw_init(void) /* reset the I2S controller into known state */ i2s_reset(); - + audiohw_preinit(); } -- cgit v1.2.3