mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 20:55:17 -05:00
Initial commit for the YP-Z5 port
The port uses the imx233 soc, it's a STMP3650 based Samsung player Change-Id: I50b6d7e77fd292fab5ed26de87853cd5aaf9eaa4 Reviewed-on: http://gerrit.rockbox.org/490 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
This commit is contained in:
parent
15155ed100
commit
1deab73980
21 changed files with 1721 additions and 1 deletions
|
|
@ -137,6 +137,8 @@ void imx233_power_init(void)
|
|||
#endif
|
||||
/* enable vbusvalid detection method for the dcdc (improves efficiency) */
|
||||
BF_SET(POWER_5VCTRL, VBUSVALID_5VDETECT);
|
||||
/* disable shutdown on 5V fail */
|
||||
BF_CLR(POWER_5VCTRL, PWDN_5VBRNOUT);
|
||||
#ifdef USE_VBUSVALID
|
||||
/* make sure VBUSVALID is unlocked */
|
||||
BF_CLR(POWER_DEBUG, VBUSVALIDPIOLOCK);
|
||||
|
|
|
|||
31
firmware/target/arm/imx233/samsung-ypz5/audio-target.h
Normal file
31
firmware/target/arm/imx233/samsung-ypz5/audio-target.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2013 by Lorenzo Miori
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef __audio_target__
|
||||
#define __audio_target__
|
||||
|
||||
/* MUTE_ON toggles a transistor that in turns toggles a mosfet... */
|
||||
#define IMX233_AUDIO_HP_GATE_BANK 1
|
||||
#define IMX233_AUDIO_HP_GATE_PIN 22
|
||||
#define IMX233_AUDIO_HP_GATE_INVERTED
|
||||
|
||||
#define IMX233_AUDIO_COUPLING_MODE ACM_CAP
|
||||
|
||||
#endif /* __audio_target__ */
|
||||
28
firmware/target/arm/imx233/samsung-ypz5/backlight-target.h
Normal file
28
firmware/target/arm/imx233/samsung-ypz5/backlight-target.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2013 by Lorenzo Miori
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef BACKLIGHT_TARGET_H
|
||||
#define BACKLIGHT_TARGET_H
|
||||
|
||||
bool _backlight_init(void);
|
||||
void _backlight_on(void);
|
||||
void _backlight_off(void);
|
||||
void _backlight_set_brightness(int brightness);
|
||||
|
||||
#endif /* BACKLIGHT_TARGET_H */
|
||||
149
firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c
Normal file
149
firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2013 by Lorenzo Miori
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "lcd.h"
|
||||
#include "backlight.h"
|
||||
#include "backlight-target.h"
|
||||
#include "pinctrl-imx233.h"
|
||||
|
||||
/**
|
||||
* AAT3151 Backlight Controller
|
||||
*/
|
||||
|
||||
/* Timings */
|
||||
#define TIME_OFF 500
|
||||
#define TIME_LOW 50
|
||||
#define TIME_HI 50
|
||||
#define TIME_LAT 500
|
||||
|
||||
/* Number of raising edges to select the particular register */
|
||||
#define D1_D4_CURRENT_E 17
|
||||
#define D1_D3_CURRENT_E 18
|
||||
#define D4_CURRENT_E 19
|
||||
#define MAX_CURRENT_E 20
|
||||
#define LOW_CURRENT_E 21
|
||||
|
||||
/* The actual register address / number */
|
||||
#define D1_D4_CURRENT 1
|
||||
#define D1_D3_CURRENT 2
|
||||
#define D4_CURRENT 3
|
||||
#define MAX_CURRENT 4
|
||||
#define LOW_CURRENT 5
|
||||
|
||||
/* Valid values for LOW_CURRENT register */
|
||||
#define MAX_CURRENT_20 1
|
||||
#define MAX_CURRENT_30 2
|
||||
#define MAX_CURRENT_15 3
|
||||
#define MAX_CURRENT_LOW_CURRENT 4
|
||||
|
||||
static int current_level = -1;
|
||||
|
||||
static void create_raising_edges(int num)
|
||||
{
|
||||
while (num--)
|
||||
{
|
||||
/* Setting a register takes a sufficient small amount of time,
|
||||
* in the order of 50 ns. Thus the necessary 2 delays TIME_LOW/TIME_HI
|
||||
* are not strictly necessary */
|
||||
imx233_pinctrl_set_gpio(3, 13, false);
|
||||
imx233_pinctrl_set_gpio(3, 13, true);
|
||||
}
|
||||
}
|
||||
|
||||
static void aat3151_write(int addr, int data)
|
||||
{
|
||||
create_raising_edges(16 + addr);
|
||||
udelay(TIME_LAT);
|
||||
create_raising_edges(data);
|
||||
udelay(TIME_LAT);
|
||||
}
|
||||
|
||||
void _backlight_set_brightness(int level)
|
||||
{
|
||||
/* Don't try to reset backlight if not necessary
|
||||
* Moreover this helps to avoid flickering when
|
||||
* being in some screens like USB mode and
|
||||
* pressing some keys / touchpad...
|
||||
*/
|
||||
if (current_level == level) return;
|
||||
|
||||
/* Check for limits and adjust in case */
|
||||
level = MIN(MAX_BRIGHTNESS_SETTING, MAX(0, level));
|
||||
|
||||
if (level == 0)
|
||||
{
|
||||
/* Set pin low for a sufficient time, puts the device into low-power consumption state
|
||||
* In other words backlight goes off
|
||||
*/
|
||||
imx233_pinctrl_set_gpio(3, 13, false);
|
||||
udelay(TIME_OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (level > 3) {
|
||||
/* This enables 16 levels of backlight */
|
||||
aat3151_write(MAX_CURRENT, MAX_CURRENT_15);
|
||||
/* Set the value according Table 1 in datasheet
|
||||
* For MAX_CURRENT_15, the scale is from 0 mA to 15 mA in 16 steps
|
||||
*/
|
||||
aat3151_write(D1_D3_CURRENT, 19 - level);
|
||||
}
|
||||
else {
|
||||
/* This enables other 4 levels of backlight */
|
||||
aat3151_write(MAX_CURRENT, MAX_CURRENT_LOW_CURRENT);
|
||||
/* Set the value according Table 1 in datasheet
|
||||
* For LOW_CURRENT, there is no "real" scale. We have scattered values.
|
||||
* We are interested in the last 3 -> 0.5 mA; 1 mA; 2 mA
|
||||
*/
|
||||
aat3151_write(LOW_CURRENT, 13 + level);
|
||||
}
|
||||
}
|
||||
current_level = level;
|
||||
}
|
||||
|
||||
bool _backlight_init(void)
|
||||
{
|
||||
imx233_pinctrl_acquire(3, 13, "backlight");
|
||||
imx233_pinctrl_set_function(3, 13, PINCTRL_FUNCTION_GPIO);
|
||||
imx233_pinctrl_set_drive(3, 13, PINCTRL_DRIVE_4mA);
|
||||
imx233_pinctrl_enable_gpio(3, 13, true);
|
||||
imx233_pinctrl_set_gpio(3, 13, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(true); /* power on lcd + visible display */
|
||||
#endif
|
||||
/* restore the previous backlight level */
|
||||
_backlight_set_brightness(backlight_brightness);
|
||||
}
|
||||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
/* there is no real on/off but we can set to 0 brightness */
|
||||
_backlight_set_brightness(0);
|
||||
#ifdef HAVE_LCD_ENABLE
|
||||
lcd_enable(false); /* power off visible display */
|
||||
#endif
|
||||
}
|
||||
59
firmware/target/arm/imx233/samsung-ypz5/button-target.h
Normal file
59
firmware/target/arm/imx233/samsung-ypz5/button-target.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2013 by Lorenzo Miori
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _BUTTON_TARGET_H_
|
||||
#define _BUTTON_TARGET_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define HAS_BUTTON_HOLD
|
||||
#define IMX233_BUTTON_LRADC_CHANNEL 0
|
||||
#define IMX233_BUTTON_LRADC_HOLD_DET BLH_GPIO
|
||||
#define BLH_GPIO_BANK 0
|
||||
#define BLH_GPIO_PIN 13
|
||||
|
||||
#define IMX233_BUTTON_LRADC_CHANNEL 0
|
||||
|
||||
/* Main unit's buttons */
|
||||
#define BUTTON_POWER 0x00000001
|
||||
#define BUTTON_VOL_UP 0x00000002
|
||||
#define BUTTON_VOL_DOWN 0x00000004
|
||||
/* Directional buttons by touchpad */
|
||||
#define BUTTON_LEFT 0x00000008
|
||||
#define BUTTON_UP 0x00000010
|
||||
#define BUTTON_RIGHT 0x00000020
|
||||
#define BUTTON_DOWN 0x00000040
|
||||
#define BUTTON_SELECT 0x00000080
|
||||
#define BUTTON_BACK 0x00000100
|
||||
#define BUTTON_REW 0x00000200
|
||||
#define BUTTON_FF 0x00000400
|
||||
|
||||
|
||||
#define BUTTON_MAIN (BUTTON_VOL_UP | BUTTON_VOL_DOWN | BUTTON_POWER | BUTTON_LEFT | \
|
||||
BUTTON_UP | BUTTON_RIGHT | BUTTON_DOWN | BUTTON_SELECT | \
|
||||
BUTTON_BACK | BUTTON_REW | BUTTON_FF)
|
||||
|
||||
/* Software power-off */
|
||||
#define POWEROFF_BUTTON BUTTON_POWER
|
||||
#define POWEROFF_COUNT 10
|
||||
|
||||
bool button_debug_screen(void);
|
||||
|
||||
#endif /* _BUTTON_TARGET_H_ */
|
||||
273
firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c
Normal file
273
firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c
Normal file
|
|
@ -0,0 +1,273 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2013 by Lorenzo Miori
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "system.h"
|
||||
#include "lcd.h"
|
||||
#include "string.h"
|
||||
#include "pinctrl-imx233.h"
|
||||
#include "power-imx233.h"
|
||||
#include "button-lradc-imx233.h"
|
||||
#include "button-target.h"
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
#include "touchscreen.h"
|
||||
#include "touchscreen-imx233.h"
|
||||
#include "button.h"
|
||||
#include "font.h"
|
||||
#include "action.h"
|
||||
#endif
|
||||
|
||||
struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] =
|
||||
{
|
||||
{455, BUTTON_VOL_UP},
|
||||
{900, BUTTON_VOL_DOWN},
|
||||
{1410, BUTTON_BACK},
|
||||
{1868, BUTTON_FF},
|
||||
{2311, BUTTON_REW},
|
||||
{2700, 0},
|
||||
{3300, IMX233_BUTTON_LRADC_END},
|
||||
};
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
static int last_x = 0;
|
||||
static int last_y = 0;
|
||||
static bool touching = false;
|
||||
#endif /* BOOTLOADER */
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
||||
/* Touchpad extra pin initialization
|
||||
* Strange facts:
|
||||
* 1. In the fully working sample I have, it seems that pins
|
||||
* must be all set to low
|
||||
* 2. In the other sample without LCD, it seems (by measurement) that
|
||||
* not all the pins are set to low! Actually, I still need to see if
|
||||
* touchpad works in this other sample.
|
||||
*/
|
||||
void touchpad_pin_setup(void)
|
||||
{
|
||||
/* TX+ */
|
||||
imx233_pinctrl_acquire(0, 25, "touchpad X+ power low");
|
||||
imx233_pinctrl_set_function(0, 25, PINCTRL_FUNCTION_GPIO);
|
||||
imx233_pinctrl_set_drive(0, 25, PINCTRL_DRIVE_4mA);
|
||||
imx233_pinctrl_enable_gpio(0, 25, true);
|
||||
|
||||
/* TY+ */
|
||||
imx233_pinctrl_acquire(0, 26, "touchpad Y+ power high");
|
||||
imx233_pinctrl_set_function(0, 26, PINCTRL_FUNCTION_GPIO);
|
||||
imx233_pinctrl_set_drive(0, 26, PINCTRL_DRIVE_4mA);
|
||||
imx233_pinctrl_enable_gpio(0, 26, true);
|
||||
|
||||
/* TY- */
|
||||
imx233_pinctrl_acquire(1, 21, "touchpad Y- power low");
|
||||
imx233_pinctrl_set_function(1, 21, PINCTRL_FUNCTION_GPIO);
|
||||
imx233_pinctrl_set_drive(1, 21, PINCTRL_DRIVE_4mA);
|
||||
imx233_pinctrl_enable_gpio(1, 21, true);
|
||||
|
||||
/* TX- */
|
||||
imx233_pinctrl_acquire(3, 15, "touchpad X- power high");
|
||||
imx233_pinctrl_set_function(3, 15, PINCTRL_FUNCTION_GPIO);
|
||||
imx233_pinctrl_set_drive(3, 15, PINCTRL_DRIVE_4mA);
|
||||
imx233_pinctrl_enable_gpio(3, 15, true);
|
||||
|
||||
}
|
||||
#endif /* BOOTLOADER */
|
||||
|
||||
void button_init_device(void)
|
||||
{
|
||||
imx233_button_lradc_init();
|
||||
#ifndef BOOTLOADER
|
||||
touchpad_pin_setup();
|
||||
/* Now that is powered up, proceed with touchpad initialization */
|
||||
imx233_touchscreen_init();
|
||||
imx233_touchscreen_enable(true);
|
||||
#endif /* BOOTLOADER */
|
||||
}
|
||||
|
||||
bool button_hold(void)
|
||||
{
|
||||
return imx233_button_lradc_hold();
|
||||
}
|
||||
|
||||
/* X, Y, RadiusX, RadiusY */
|
||||
#define TOUCH_UP 2400, 1050, 650, 250
|
||||
#define TOUCH_DOWN 2057, 3320, 500, 350
|
||||
#define TOUCH_LEFT 3581, 2297, 300, 350
|
||||
#define TOUCH_RIGHT 1000, 2100, 400, 700
|
||||
#define TOUCH_CENTER 2682, 2167, 335, 276
|
||||
|
||||
bool coord_in_radius(int x, int y, int cx, int cy, int rx, int ry)
|
||||
{
|
||||
return ((x >= cx - rx && x <= cx + rx) && (y >= cy - ry && y <= cy + ry));
|
||||
}
|
||||
|
||||
int button_read_device(void)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
switch(imx233_power_read_pswitch())
|
||||
{
|
||||
case 1: res |= BUTTON_POWER; break;
|
||||
case 3: res |= BUTTON_SELECT; break;
|
||||
}
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
touching = imx233_touchscreen_get_touch(&last_x, &last_y);
|
||||
if(touching)
|
||||
{
|
||||
if (coord_in_radius(last_x, last_y, TOUCH_LEFT))
|
||||
{
|
||||
res |= BUTTON_LEFT;
|
||||
}
|
||||
else if (coord_in_radius(last_x, last_y, TOUCH_RIGHT))
|
||||
{
|
||||
res |= BUTTON_RIGHT;
|
||||
}
|
||||
else if (coord_in_radius(last_x, last_y, TOUCH_DOWN))
|
||||
{
|
||||
res |= BUTTON_DOWN;
|
||||
}
|
||||
else if (coord_in_radius(last_x, last_y, TOUCH_UP))
|
||||
{
|
||||
res |= BUTTON_UP;
|
||||
}
|
||||
}
|
||||
#endif /* BOOTLOADER */
|
||||
return imx233_button_lradc_read(res);
|
||||
}
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
||||
#define MAX_ENTRIES 100
|
||||
#define VIEWPORT_HEIGHT 100
|
||||
#define VIEWPORT_WIDTH 100
|
||||
#define MAX_X 3700
|
||||
#define MAX_Y 3700
|
||||
#define ADAPT_TO_VIEWPORT(cx, cy, rx, ry) ((float)(cx) / MAX_X) * VIEWPORT_WIDTH, \
|
||||
((float)(cy) / MAX_Y) * VIEWPORT_HEIGHT, \
|
||||
((float)(rx) / MAX_X) * VIEWPORT_WIDTH, \
|
||||
((float)(ry) / MAX_Y) * VIEWPORT_HEIGHT
|
||||
static void draw_calibration_rect(int cx, int cy, int rx, int ry)
|
||||
{
|
||||
if (coord_in_radius(last_x, last_y, cx, cy, rx, ry))
|
||||
lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0xff, 0xff), LCD_BLACK);
|
||||
else
|
||||
lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0, 0), LCD_BLACK);
|
||||
lcd_drawrect(ADAPT_TO_VIEWPORT(cx - rx, cy - ry, 2 * rx, 2 * ry));
|
||||
}
|
||||
|
||||
bool button_debug_screen(void)
|
||||
{
|
||||
int last = 0;
|
||||
struct point_t
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
struct point_t last_entries[MAX_ENTRIES];
|
||||
struct viewport report_vp;
|
||||
|
||||
memset(&report_vp, 0, sizeof(report_vp));
|
||||
report_vp.x = (LCD_WIDTH - VIEWPORT_WIDTH) / 2;
|
||||
report_vp.y = (LCD_HEIGHT - VIEWPORT_HEIGHT) / 2;
|
||||
report_vp.width = VIEWPORT_WIDTH;
|
||||
report_vp.height = VIEWPORT_HEIGHT;
|
||||
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
lcd_clear_display();
|
||||
|
||||
while(1)
|
||||
{
|
||||
int button = get_action(CONTEXT_STD, HZ / 10);
|
||||
switch(button)
|
||||
{
|
||||
case ACTION_STD_OK:
|
||||
case ACTION_STD_MENU:
|
||||
lcd_set_viewport(NULL);
|
||||
lcd_setfont(FONT_UI);
|
||||
lcd_clear_display();
|
||||
return true;
|
||||
case ACTION_STD_CANCEL:
|
||||
lcd_set_viewport(NULL);
|
||||
lcd_setfont(FONT_UI);
|
||||
lcd_clear_display();
|
||||
return false;
|
||||
}
|
||||
|
||||
lcd_set_viewport(NULL);
|
||||
lcd_putsf(0, 1, "(%d,%d) %s", last_x, last_y, touching ? "touching!" : "");
|
||||
lcd_putsf(0, 0, "Type %s", imx233_pinctrl_get_gpio(0, 31) ? "CAP" : "REG");
|
||||
lcd_set_viewport(&report_vp);
|
||||
lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0, 0, 0xff), LCD_BLACK);
|
||||
lcd_drawrect(0, 0, 100, 100);
|
||||
float percent_x = ((float)(last_x) / MAX_X);
|
||||
float percent_y = ((float)(last_y) / MAX_Y);
|
||||
if (touching)
|
||||
{
|
||||
lcd_set_viewport(NULL);
|
||||
if (last < MAX_ENTRIES)
|
||||
{
|
||||
last_entries[last].x = last_x;
|
||||
last_entries[last].y = last_y;
|
||||
last++;
|
||||
lcd_putsf(0, 17, "Recording: %d captures left", MAX_ENTRIES - last);
|
||||
}
|
||||
else
|
||||
{
|
||||
int min_x = 9999;
|
||||
int min_y = 9999;
|
||||
int max_x = -1;
|
||||
int max_y = -1;
|
||||
int median_x = 0;
|
||||
int median_y = 0;
|
||||
for (int i = 0; i < MAX_ENTRIES; i++)
|
||||
{
|
||||
min_x = MIN(min_x, last_entries[i].x);
|
||||
min_y = MIN(min_y, last_entries[i].y);
|
||||
max_x = MAX(max_x, last_entries[i].x);
|
||||
max_y = MAX(max_y, last_entries[i].y);
|
||||
median_x += last_entries[i].x;
|
||||
median_y += last_entries[i].y;
|
||||
}
|
||||
median_x /= MAX_ENTRIES;
|
||||
median_y /= MAX_ENTRIES;
|
||||
lcd_putsf(0, 17, "center(%d,%d)", median_x, median_y);
|
||||
lcd_putsf(0, 18, "radius(%d,%d)", median_x / 2, median_y / 2);
|
||||
}
|
||||
lcd_set_viewport(&report_vp);
|
||||
lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0x8c, 0), LCD_BLACK);
|
||||
lcd_fillrect(VIEWPORT_WIDTH * percent_x, VIEWPORT_HEIGHT * percent_y, 2, 2);
|
||||
}
|
||||
|
||||
/* Draw current calibration settings */
|
||||
lcd_set_viewport(&report_vp);
|
||||
draw_calibration_rect(TOUCH_UP);
|
||||
draw_calibration_rect(TOUCH_DOWN);
|
||||
draw_calibration_rect(TOUCH_CENTER);
|
||||
draw_calibration_rect(TOUCH_LEFT);
|
||||
draw_calibration_rect(TOUCH_RIGHT);
|
||||
|
||||
lcd_update();
|
||||
yield();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
29
firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c
Normal file
29
firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2013 by Amaury Pouly
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "system.h"
|
||||
#include "button-target.h"
|
||||
#include "lcd-target.h"
|
||||
|
||||
bool dbg_hw_target_info(void)
|
||||
{
|
||||
return button_debug_screen() && lcd_debug_screen();
|
||||
}
|
||||
31
firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h
Normal file
31
firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2013 by Amaury Pouly
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _FMRADIO_TARGET_H_
|
||||
#define _FMRADIO_TARGET_H_
|
||||
|
||||
#define IMX233_FMRADIO_I2C FMI_HW
|
||||
|
||||
#define IMX233_FMRADIO_POWER FMP_GPIO
|
||||
#define FMP_GPIO_BANK 0
|
||||
#define FMP_GPIO_PIN 10
|
||||
#define FMP_GPIO_DELAY (HZ / 5)
|
||||
|
||||
#endif /* _FMRADIO_TARGET_H_ */
|
||||
39
firmware/target/arm/imx233/samsung-ypz5/ftl-target.h
Normal file
39
firmware/target/arm/imx233/samsung-ypz5/ftl-target.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2009 by Michael Sparmann
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __FTL_TARGET_H__
|
||||
#define __FTL_TARGET_H__
|
||||
|
||||
#include "config.h"
|
||||
#include "inttypes.h"
|
||||
|
||||
#ifdef BOOTLOADER
|
||||
/* Bootloaders don't need write access */
|
||||
#define FTL_READONLY
|
||||
#endif
|
||||
|
||||
uint32_t ftl_init(void);
|
||||
uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer);
|
||||
uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer);
|
||||
uint32_t ftl_sync(void);
|
||||
|
||||
|
||||
#endif
|
||||
25
firmware/target/arm/imx233/samsung-ypz5/lcd-target.h
Normal file
25
firmware/target/arm/imx233/samsung-ypz5/lcd-target.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (c) 2013 by Amaury Pouly
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef LCD_TARGET_H
|
||||
#define LCD_TARGET_H
|
||||
|
||||
bool lcd_debug_screen(void);
|
||||
|
||||
#endif /* LCD_TARGET_H */
|
||||
294
firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c
Normal file
294
firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (c) 2013 by Lorenzo Miori
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <sys/types.h> /* off_t */
|
||||
#include <string.h>
|
||||
#include "cpu.h"
|
||||
#include "system.h"
|
||||
#include "backlight-target.h"
|
||||
#include "lcd.h"
|
||||
#include "lcdif-imx233.h"
|
||||
#include "clkctrl-imx233.h"
|
||||
#include "pinctrl-imx233.h"
|
||||
#include "dcp-imx233.h"
|
||||
#include "logf.h"
|
||||
#ifndef BOOTLOADER
|
||||
#include "button.h"
|
||||
#include "font.h"
|
||||
#include "action.h"
|
||||
#endif
|
||||
#include "dma-imx233.h"
|
||||
|
||||
#include "regs/regs-lcdif.h"
|
||||
|
||||
/**
|
||||
* NOTE
|
||||
* We don't know exact LCD models nor we have datasheets for them
|
||||
* Register function are partly guessed from the values, others are guessed from other LCD
|
||||
* drivers and others have been confirmed studying their values
|
||||
*/
|
||||
|
||||
static enum lcd_type_t
|
||||
{
|
||||
LCD_TYPE_ZERO = 0,
|
||||
LCD_TYPE_ONE = 1
|
||||
} lcd_type = LCD_TYPE_ZERO;
|
||||
|
||||
static void lcd_write_reg(uint16_t reg, uint16_t data)
|
||||
{
|
||||
imx233_lcdif_pio_send(false, 1, ®);
|
||||
if(reg != 0x22)
|
||||
imx233_lcdif_pio_send(true, 1, &data);
|
||||
}
|
||||
|
||||
/*
|
||||
* The two LCD types require different initialization sequences
|
||||
*/
|
||||
void lcd_init_seq(void)
|
||||
{
|
||||
switch (lcd_type)
|
||||
{
|
||||
case LCD_TYPE_ZERO:
|
||||
{
|
||||
lcd_write_reg(0x11, 0x1f1e);
|
||||
lcd_write_reg(0x38, 0xf0f);
|
||||
lcd_write_reg(0x12, 0x1101);
|
||||
lcd_write_reg(0x13, 0x808);
|
||||
lcd_write_reg(0x14, 0x3119);
|
||||
lcd_write_reg(0x10, 0x1a10);
|
||||
udelay(0xc350);
|
||||
lcd_write_reg(0x13, 0x83b);
|
||||
udelay(0x30d40);
|
||||
lcd_write_reg(1, 0x90c); /* Display mode */
|
||||
lcd_write_reg(2, 0x200);
|
||||
lcd_write_reg(3, 0x1030);
|
||||
lcd_write_reg(7, 5);
|
||||
lcd_write_reg(8, 0x503);
|
||||
lcd_write_reg(11, 0);
|
||||
lcd_write_reg(12, 0);
|
||||
/* Gamma control */
|
||||
lcd_write_reg(0x30, 0x606);
|
||||
lcd_write_reg(0x31, 0x606);
|
||||
lcd_write_reg(0x32, 0x305);
|
||||
lcd_write_reg(0x33, 2);
|
||||
lcd_write_reg(0x34, 0x503);
|
||||
lcd_write_reg(0x35, 0x606);
|
||||
lcd_write_reg(0x36, 0x606);
|
||||
lcd_write_reg(0x37, 0x200);
|
||||
|
||||
lcd_write_reg(0x11, 0x1f1e);
|
||||
lcd_write_reg(0x38, 0xf0f);
|
||||
/* Set initial LCD limits and RAM settings */
|
||||
lcd_write_reg(0x40, 0); //BPP ?
|
||||
lcd_write_reg(0x42, 0x9f00);
|
||||
lcd_write_reg(0x43, 0);
|
||||
lcd_write_reg(0x44, 0x7f00); /* Horizontal initial refresh zone [0 - 127] */
|
||||
lcd_write_reg(0x45, 0x9f00); /* Vertical initial refresh zone [0 - 159] */
|
||||
|
||||
lcd_write_reg(14, 0x13);
|
||||
lcd_write_reg(0xa9, 0x14);
|
||||
lcd_write_reg(0xa7, 0x30);
|
||||
lcd_write_reg(0xa8, 0x124);
|
||||
lcd_write_reg(0x6f, 0x1d00);
|
||||
lcd_write_reg(0x70, 3);
|
||||
lcd_write_reg(7, 1);
|
||||
lcd_write_reg(0x10, 0x1a10);
|
||||
udelay(0x9c40);
|
||||
lcd_write_reg(7, 0x21);
|
||||
lcd_write_reg(7, 0x23);
|
||||
udelay(0x9c40);
|
||||
lcd_write_reg(7, 0x37); /* Seems to be "power on" */
|
||||
break;
|
||||
}
|
||||
case LCD_TYPE_ONE:
|
||||
{
|
||||
lcd_write_reg(0, 1);
|
||||
udelay(0x2710);
|
||||
lcd_write_reg(0x11, 0x171b);
|
||||
lcd_write_reg(0x12, 0);
|
||||
lcd_write_reg(0x13, 0x80d);
|
||||
lcd_write_reg(0x14, 0x18);
|
||||
lcd_write_reg(0x10, 0x1a10);
|
||||
udelay(0xc350);
|
||||
lcd_write_reg(0x13, 0x81d);
|
||||
udelay(0xc350);
|
||||
lcd_write_reg(1, 0x90c); /* Display mode */
|
||||
lcd_write_reg(2, 0x200);
|
||||
lcd_write_reg(3, 0x1030);
|
||||
lcd_write_reg(7, 5);
|
||||
lcd_write_reg(8, 0x30a);
|
||||
lcd_write_reg(11, 4);
|
||||
lcd_write_reg(12, 0);
|
||||
/* Gamma control */
|
||||
lcd_write_reg(0x30, 0x300);
|
||||
lcd_write_reg(0x31, 0);
|
||||
lcd_write_reg(0x32, 0);
|
||||
lcd_write_reg(0x33, 0x404);
|
||||
lcd_write_reg(0x34, 0x707);
|
||||
lcd_write_reg(0x35, 0x700);
|
||||
lcd_write_reg(0x36, 0x703);
|
||||
lcd_write_reg(0x37, 4);
|
||||
|
||||
lcd_write_reg(0x38, 0);
|
||||
/* Set initial LCD limits and RAM settings */
|
||||
lcd_write_reg(0x40, 0);
|
||||
lcd_write_reg(0x42, 0x9f00); /* LCD Display Start Address Register 0 */
|
||||
lcd_write_reg(0x43, 0); /* LCD Display Start Address Register 1 */
|
||||
lcd_write_reg(0x44, 0x7f00); /* Horizontal initial refresh zone [0 - 127] */
|
||||
lcd_write_reg(0x45, 0x9f00); /* Vertical initial refresh zone [0 - 159] */
|
||||
|
||||
lcd_write_reg(7, 1);
|
||||
udelay(0x2710);
|
||||
lcd_write_reg(7, 0x21);
|
||||
lcd_write_reg(7, 0x23);
|
||||
udelay(0x2710);
|
||||
lcd_write_reg(7, 0x1037);
|
||||
udelay(0x2710);
|
||||
lcd_write_reg(7, 0x35);
|
||||
lcd_write_reg(7, 0x36);
|
||||
lcd_write_reg(7, 0x37);
|
||||
udelay(10000);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void send_update_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
|
||||
{
|
||||
/* Set horizontal refresh zone */
|
||||
lcd_write_reg(0x44, (x | (y + w - 1) << 0x8));
|
||||
/* Set vertical refresh zone */
|
||||
lcd_write_reg(0x45, (y | (y + h - 1) << 0x8));
|
||||
lcd_write_reg(0x21, x | y << 8);
|
||||
/* Set register index to 0x22 to write screen data. 0 is mock value */
|
||||
lcd_write_reg(0x22, 0);
|
||||
}
|
||||
|
||||
static void setup_lcd_pins(void)
|
||||
{
|
||||
imx233_lcdif_setup_system_pins(16);
|
||||
/* lcd_rd */
|
||||
imx233_pinctrl_acquire(0, 9, "lcd rd");
|
||||
imx233_pinctrl_set_function(0, 9, PINCTRL_FUNCTION_GPIO);
|
||||
imx233_pinctrl_set_gpio(0, 9, false);
|
||||
/*
|
||||
* This pin is important to know the LCD type
|
||||
* There are two types that require two different initialization sequences
|
||||
*/
|
||||
/* lcd_tp */
|
||||
imx233_pinctrl_acquire(3, 12, "lcd type");
|
||||
imx233_pinctrl_set_function(3, 12, PINCTRL_FUNCTION_GPIO);
|
||||
imx233_pinctrl_enable_gpio(3, 12, false);
|
||||
/* Sense LCD Type */
|
||||
lcd_type = imx233_pinctrl_get_gpio(3, 12) ? LCD_TYPE_ONE : LCD_TYPE_ZERO;
|
||||
}
|
||||
|
||||
static void setup_parameters(void)
|
||||
{
|
||||
imx233_lcdif_init();
|
||||
imx233_lcdif_enable(true);
|
||||
imx233_lcdif_set_word_length(16);
|
||||
imx233_lcdif_set_data_swizzle(false);
|
||||
imx233_lcdif_set_timings(2, 1, 1, 1);
|
||||
BF_WR_V(LCDIF_CTRL, MODE86, 8080_MODE);
|
||||
|
||||
imx233_lcdif_reset_lcd(true);
|
||||
udelay(50);
|
||||
imx233_lcdif_reset_lcd(false);
|
||||
udelay(10);
|
||||
imx233_lcdif_reset_lcd(true);
|
||||
}
|
||||
|
||||
void lcd_init_device(void)
|
||||
{
|
||||
/* Setup interface pins */
|
||||
setup_lcd_pins();
|
||||
/* Set LCD parameters */
|
||||
setup_parameters();
|
||||
/* Send initialization sequence to LCD */
|
||||
lcd_init_seq();
|
||||
}
|
||||
|
||||
struct lcdif_cmd_t
|
||||
{
|
||||
struct apb_dma_command_t dma;
|
||||
uint32_t ctrl0;
|
||||
uint32_t pad[4];
|
||||
} __attribute__((packed)) CACHEALIGN_ATTR;
|
||||
|
||||
struct lcdif_cmd_t lcdif_dma;
|
||||
void lcd_update(void)
|
||||
{
|
||||
unsigned size = LCD_WIDTH * LCD_HEIGHT * sizeof(fb_data);
|
||||
|
||||
send_update_rect(0,0,LCD_WIDTH,LCD_HEIGHT);
|
||||
/* We can safely do the transfer in a single shot, since 160 * 128 * 2 < 65k,
|
||||
* the maximum transfer size!
|
||||
*/
|
||||
lcdif_dma.dma.cmd |= BF_OR3(APB_CHx_CMD, CMDWORDS(1), XFER_COUNT(size), COMMAND(2));
|
||||
lcdif_dma.ctrl0 = HW_LCDIF_CTRL & ~BM_LCDIF_CTRL_COUNT;
|
||||
lcdif_dma.ctrl0 |= BF_OR2(LCDIF_CTRL, COUNT(size/2), DATA_SELECT(1));
|
||||
lcdif_dma.dma.buffer = FBADDR(0,0);
|
||||
lcdif_dma.dma.cmd |= BM_APB_CHx_CMD_SEMAPHORE;
|
||||
|
||||
imx233_dma_start_command(APB_LCDIF, &lcdif_dma.dma);
|
||||
imx233_dma_wait_completion(APB_LCDIF, HZ);
|
||||
}
|
||||
|
||||
void lcd_update_rect(int x, int y, int w, int h)
|
||||
{
|
||||
(void)x;
|
||||
(void)y;
|
||||
(void)w;
|
||||
(void)h;
|
||||
lcd_update();
|
||||
}
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
bool lcd_debug_screen(void)
|
||||
{
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
|
||||
while(1)
|
||||
{
|
||||
int button = get_action(CONTEXT_STD, HZ / 10);
|
||||
switch(button)
|
||||
{
|
||||
case ACTION_STD_NEXT:
|
||||
case ACTION_STD_PREV:
|
||||
case ACTION_STD_OK:
|
||||
case ACTION_STD_MENU:
|
||||
lcd_setfont(FONT_UI);
|
||||
return true;
|
||||
case ACTION_STD_CANCEL:
|
||||
lcd_setfont(FONT_UI);
|
||||
return false;
|
||||
}
|
||||
|
||||
lcd_clear_display();
|
||||
lcd_putsf(0, 0, "LCD type: %d", lcd_type);
|
||||
lcd_update();
|
||||
yield();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
37
firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h
Normal file
37
firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2013 by Amaury Pouly
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef POWERMGMT_TARGET_H
|
||||
#define POWERMGMT_TARGET_H
|
||||
|
||||
#include "config.h"
|
||||
#include "powermgmt-imx233.h"
|
||||
|
||||
#define IMX233_CHARGE_CURRENT 100
|
||||
#define IMX233_STOP_CURRENT 10
|
||||
#define IMX233_TOPOFF_TIMEOUT (30 * 60 * HZ)
|
||||
#define IMX233_CHARGING_TIMEOUT (4 * 3600 * HZ)
|
||||
#define IMX233_DIE_TEMP_HIGH 71
|
||||
#define IMX233_DIE_TEMP_LOW 56
|
||||
#define IMX233_BATT_TEMP_SENSOR 0
|
||||
#define IMX233_BATT_TEMP_HIGH 1100
|
||||
#define IMX233_BATT_TEMP_LOW 220
|
||||
|
||||
#endif /* POWERMGMT_TARGET_H */
|
||||
48
firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
Normal file
48
firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2013 by Amaury Pouly
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "powermgmt-target.h"
|
||||
#include "power-imx233.h"
|
||||
|
||||
|
||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3400
|
||||
};
|
||||
|
||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3300
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||
{
|
||||
/* Sansa Fuze+ Li Ion 600mAH figured from discharge curve */
|
||||
{ 3100, 3650, 3720, 3750, 3780, 3820, 3880, 4000, 4040, 4125, 4230 },
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
const unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
/* Sansa Fuze+ Li Ion 600mAH figured from charge curve */
|
||||
3480, 3790, 3845, 3880, 3900, 3935, 4005, 4070, 4150, 4250, 4335
|
||||
};
|
||||
|
|
@ -20,6 +20,9 @@
|
|||
****************************************************************************/
|
||||
#include "touchscreen-imx233.h"
|
||||
#include "stdlib.h"
|
||||
#ifdef SAMSUNG_YPZ5
|
||||
#include "pinctrl-imx233.h"
|
||||
#endif
|
||||
|
||||
/* Description:
|
||||
* the driver basically has 2 modes:
|
||||
|
|
@ -72,6 +75,24 @@ static void touch_channel_irq(int chan)
|
|||
process();
|
||||
}
|
||||
|
||||
#ifdef SAMSUNG_YPZ5
|
||||
/* On this target we need to manually setup pulldown pins,
|
||||
* using specific GPIO lines
|
||||
*/
|
||||
static void pulldown_setup(bool xminus_enable, bool yminus_enable,
|
||||
bool xplus_enable, bool yplus_enable)
|
||||
{
|
||||
/* TX+ */
|
||||
imx233_pinctrl_set_gpio(0, 25, xplus_enable);
|
||||
/* TX- */
|
||||
imx233_pinctrl_set_gpio(3, 15, xminus_enable);
|
||||
/* TY+ */
|
||||
imx233_pinctrl_set_gpio(0, 26, yplus_enable);
|
||||
/* TY- */
|
||||
imx233_pinctrl_set_gpio(1, 21, yminus_enable);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void kick_measure(bool pull_x, bool pull_y, bool detect, int src)
|
||||
{
|
||||
if(touch_chan >= 0)
|
||||
|
|
@ -84,6 +105,9 @@ static void kick_measure(bool pull_x, bool pull_y, bool detect, int src)
|
|||
imx233_icoll_enable_interrupt(INT_SRC_LRADC_CHx(touch_chan), true);
|
||||
imx233_lradc_enable_channel_irq(touch_chan, true);
|
||||
/* setup measurement: x- pull down and x+ pull up */
|
||||
#ifdef SAMSUNG_YPZ5
|
||||
pulldown_setup(pull_x, pull_y, pull_x, pull_y);
|
||||
#endif
|
||||
imx233_lradc_setup_touch(pull_x, pull_y, pull_x, pull_y, detect);
|
||||
imx233_lradc_enable_touch_detect_irq(false);
|
||||
imx233_lradc_enable_channel_irq(touch_chan, true);
|
||||
|
|
@ -102,6 +126,9 @@ static void enter_state(enum touch_state_t state)
|
|||
switch(state)
|
||||
{
|
||||
case TOUCH_STATE_WAIT:
|
||||
#ifdef SAMSUNG_YPZ5
|
||||
pulldown_setup(false, false, false, false);
|
||||
#endif
|
||||
imx233_lradc_setup_touch(false, false, false, false, true);
|
||||
imx233_lradc_enable_touch_detect_irq(true);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue