summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES12
-rw-r--r--firmware/export/config.h4
-rw-r--r--firmware/export/config/samsungypz5.h201
-rw-r--r--firmware/target/arm/imx233/power-imx233.c2
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/audio-target.h31
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/backlight-target.h28
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c149
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/button-target.h59
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c273
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c29
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h31
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/ftl-target.h39
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/lcd-target.h25
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c294
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h37
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c48
-rw-r--r--firmware/target/arm/imx233/touchscreen-imx233.c27
17 files changed, 1289 insertions, 0 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 843e5cca22..64041e448e 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1443,6 +1443,18 @@ target/arm/imx233/sansa-fuzeplus/debug-fuzeplus.c
target/arm/imx233/sansa-fuzeplus/powermgmt-fuzeplus.c
#endif
+#ifdef SAMSUNG_YPZ5
+target/arm/imx233/samsung-ypz5/backlight-ypz5.c
+target/arm/imx233/samsung-ypz5/lcd-ypz5.c
+target/arm/imx233/samsung-ypz5/button-ypz5.c
+target/arm/imx233/samsung-ypz5/debug-ypz5.c
+target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
+target/arm/imx233/button-lradc-imx233.c
+#ifndef BOOTLOADER
+target/arm/imx233/fmradio-imx233.c
+#endif
+#endif
+
#ifdef SANSA_CLIPZIP
target/arm/as3525/sansa-clipzip/lcd-clipzip.c
target/arm/as3525/sansa-clipzip/button-clipzip.c
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 3c4c72c054..23ee56fc75 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -150,6 +150,7 @@
#define MA_PAD 56
#define SONY_NWZ_PAD 57
#define CREATIVE_ZEN_PAD 58
+#define SAMSUNG_YPZ5_PAD 59
/* CONFIG_REMOTE_KEYPAD */
#define H100_REMOTE 1
@@ -258,6 +259,7 @@
#define LCD_CREATIVEZENMOZAIC 56 /* as used by the Creative ZEN Mozaic (FGD0801) */
#define LCD_ILI9342C 57 /* another type of lcd used by HiFi E.T MA9/MA8 */
#define LCD_CREATIVEZENV 58 /* as used by the Creativr Zen V (Plus) */
+#define LCD_SAMSUNGYPZ5 59 /* as used by Samsung YP-Z5 */
/* LCD_PIXELFORMAT */
#define HORIZONTAL_PACKING 1
@@ -546,6 +548,8 @@ Lyre prototype 1 */
#include "config/sonynwze370.h"
#elif defined(SONY_NWZE360)
#include "config/sonynwze360.h"
+#elif defined(SAMSUNG_YPZ5)
+#include "config/samsungypz5.h"
#else
/* no known platform */
#endif
diff --git a/firmware/export/config/samsungypz5.h b/firmware/export/config/samsungypz5.h
new file mode 100644
index 0000000000..651ae21ba3
--- /dev/null
+++ b/firmware/export/config/samsungypz5.h
@@ -0,0 +1,201 @@
+/*
+ * This config file is for the Samsung YP-Z5
+ */
+#define IMX233_SUBTARGET 3600
+#define IMX233_PACKAGE IMX233_BGA169
+#define IMX233_PARTITIONS IMX233_FREESCALE
+
+/* For Rolo and boot loader */
+#define MODEL_NUMBER 84
+#define MODEL_NAME "Samsung YP-Z5"
+
+#define HW_SAMPR_CAPS SAMPR_CAP_ALL
+
+/* define this if you have recording possibility */
+#define HAVE_RECORDING
+
+#define REC_SAMPR_CAPS SAMPR_CAP_ALL
+
+/* Default recording levels */
+#define DEFAULT_REC_MIC_GAIN 23
+#define DEFAULT_REC_LEFT_GAIN 23
+#define DEFAULT_REC_RIGHT_GAIN 23
+
+/* Define bitmask of input sources - recordable bitmask can be defined
+ explicitly if different */
+#define HAVE_FMRADIO_IN
+#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO)
+
+/* define this if you have a bitmap LCD display */
+#define HAVE_LCD_BITMAP
+/* define this if you have a colour LCD */
+#define HAVE_LCD_COLOR
+
+#ifndef BOOTLOADER
+#define HAVE_ALBUMART
+
+/* define this to enable bitmap scaling */
+#define HAVE_BMP_SCALING
+
+/* define this to enable JPEG decoding */
+#define HAVE_JPEG
+
+/* Define this if a programmable hotkey is mapped */
+#define HAVE_HOTKEY
+
+/* define this if you have access to the quickscreen */
+#define HAVE_QUICKSCREEN
+
+/* define this if you would like tagcache to build on this target */
+#define HAVE_TAGCACHE
+
+/* define this if the target has volume keys which can be used in the lists */
+#define HAVE_VOLUME_IN_LIST
+
+/* define this if you have LCD enable function */
+//#define HAVE_LCD_ENABLE
+
+/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
+ should be defined as well.
+#define HAVE_LCD_SLEEP
+#define HAVE_LCD_SLEEP_SETTING
+*/
+
+/* define this if you can flip your LCD
+#define HAVE_LCD_FLIP
+*/
+
+/* define this if you can invert the colours on your LCD
+#define HAVE_LCD_INVERT
+*/
+
+/* define this if you have a real-time clock */
+#define CONFIG_RTC RTC_IMX233
+
+/* define this if you have a real-time clock with alarm facilities */
+#define HAVE_RTC_ALARM
+
+#endif /* !BOOTLOADER */
+
+/* define this if you have an i.MX23 codec */
+#define HAVE_IMX233_CODEC
+
+#define CONFIG_TUNER TEA5767
+#define CONFIG_TUNER_XTAL 32768
+
+/* There is no hardware tone control */
+#define HAVE_SW_TONE_CONTROLS
+
+#define CONFIG_KEYPAD SAMSUNG_YPZ5_PAD
+#define HAVE_TOUCHPAD_IMX233
+
+/* Define this to enable morse code input */
+#define HAVE_MORSE_INPUT
+
+/* Define this if you do software codec */
+#define CONFIG_CODEC SWCODEC
+
+/* LCD dimensions */
+#define LCD_WIDTH 128
+#define LCD_HEIGHT 160
+#define LCD_DEPTH 16 /* 65536 colours */
+#define LCD_PIXELFORMAT RGB565 /* rgb565 */
+
+/* Define this if you have a software controlled poweroff */
+#define HAVE_SW_POWEROFF
+
+/* Some devices seem to be FAT16 formatted */
+#define HAVE_FAT16SUPPORT
+
+/* The number of bytes reserved for loadable codecs */
+#define CODEC_SIZE 0
+
+/* The number of bytes reserved for loadable plugins */
+#define PLUGIN_BUFFER_SIZE 0
+
+#define AB_REPEAT_ENABLE
+
+/* Define this for LCD backlight available */
+#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Main LCD backlight brightness range and defaults */
+#define MIN_BRIGHTNESS_SETTING 1
+#define MAX_BRIGHTNESS_SETTING 18
+#define DEFAULT_BRIGHTNESS_SETTING 5
+
+/* Which backlight fading type? */
+#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
+
+/* define this if you have a flash memory storage */
+//#define HAVE_FLASH_STORAGE
+
+#define CONFIG_STORAGE (STORAGE_RAMDISK)
+//#define CONFIG_NAND NAND_IMX233
+//#define NUM_DRIVES 0
+
+/* Extra threads: touchpad and rds */
+//#define TARGET_EXTRA_THREADS 2
+
+/* todo */
+#define BATTERY_CAPACITY_DEFAULT 550 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 550 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 550 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 0 /* capacity increment */
+#define BATTERY_TYPES_COUNT 1 /* only one type */
+
+#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
+
+/* Charging implemented in a target-specific algorithm */
+#define CONFIG_CHARGING CHARGING_TARGET
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+/* Define this if you have an IMX233*/
+#define CONFIG_CPU IMX233
+
+/* Define this if you want to use the IMX233 i2c interface */
+#define CONFIG_I2C I2C_IMX233
+
+/* define current usage levels (based on battery bench) */
+#define CURRENT_NORMAL 35
+#define CURRENT_BACKLIGHT 30
+#define CURRENT_RECORD CURRENT_NORMAL
+
+/* maximum charging current */
+#define CURRENT_MAX_CHG 200
+
+/* Define this to the CPU frequency */
+#define CPU_FREQ 454000000
+
+/* Type of LCD */
+#define CONFIG_LCD LCD_SAMSUNGYPZ5
+
+/* Offset ( in the firmware file's header ) to the file CRC and data. These are
+ only used when loading the old format rockbox.e200 file */
+#define FIRMWARE_OFFSET_FILE_CRC 0x0
+#define FIRMWARE_OFFSET_FILE_DATA 0x8
+
+/* USB On-the-go */
+#define CONFIG_USBOTG USBOTG_ARC
+
+/* enable these for the experimental usb stack */
+#define HAVE_USBSTACK
+#define USE_ROCKBOX_USB
+#define USB_VENDOR_ID 0x04e8
+#define USB_PRODUCT_ID 0x5041
+#define HAVE_USB_HID_MOUSE
+#define HAVE_BOOTLOADER_USB_MODE
+
+/* Define this if you have adjustable CPU frequency */
+//#define HAVE_ADJUSTABLE_CPU_FREQ
+
+/* Virtual LED (icon) */
+#define CONFIG_LED LED_VIRTUAL
+
+#define BOOTFILE_EXT "samsung"
+#define BOOTFILE "rockbox." BOOTFILE_EXT
+#define BOOTDIR "/.rockbox"
+
+#define INCLUDE_TIMEOUT_API
diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c
index af333dea59..9ad8734823 100644
--- a/firmware/target/arm/imx233/power-imx233.c
+++ b/firmware/target/arm/imx233/power-imx233.c
@@ -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);
diff --git a/firmware/target/arm/imx233/samsung-ypz5/audio-target.h b/firmware/target/arm/imx233/samsung-ypz5/audio-target.h
new file mode 100644
index 0000000000..c0bee26e45
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/audio-target.h
@@ -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__ */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/backlight-target.h b/firmware/target/arm/imx233/samsung-ypz5/backlight-target.h
new file mode 100644
index 0000000000..5fa2ed38f9
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/backlight-target.h
@@ -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 */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c
new file mode 100644
index 0000000000..27a7ecedfc
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c
@@ -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
+}
diff --git a/firmware/target/arm/imx233/samsung-ypz5/button-target.h b/firmware/target/arm/imx233/samsung-ypz5/button-target.h
new file mode 100644
index 0000000000..2f94f5fb31
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/button-target.h
@@ -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_ */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c
new file mode 100644
index 0000000000..cee82e2e9f
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c
@@ -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
diff --git a/firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c
new file mode 100644
index 0000000000..c125eac973
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c
@@ -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();
+}
diff --git a/firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h b/firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h
new file mode 100644
index 0000000000..66bceb4071
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h
@@ -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_ */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/ftl-target.h b/firmware/target/arm/imx233/samsung-ypz5/ftl-target.h
new file mode 100644
index 0000000000..cb943e34f2
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/ftl-target.h
@@ -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
diff --git a/firmware/target/arm/imx233/samsung-ypz5/lcd-target.h b/firmware/target/arm/imx233/samsung-ypz5/lcd-target.h
new file mode 100644
index 0000000000..9993b7d731
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/lcd-target.h
@@ -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 */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c
new file mode 100644
index 0000000000..4f7d9b88b5
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c
@@ -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, &reg);
+ 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
diff --git a/firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h
new file mode 100644
index 0000000000..5d32bc5e9c
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h
@@ -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 */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
new file mode 100644
index 0000000000..9d9ed7de99
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
@@ -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
+};
diff --git a/firmware/target/arm/imx233/touchscreen-imx233.c b/firmware/target/arm/imx233/touchscreen-imx233.c
index c4d2f4d726..53d9d0e320 100644
--- a/firmware/target/arm/imx233/touchscreen-imx233.c
+++ b/firmware/target/arm/imx233/touchscreen-imx233.c
@@ -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;