Samsung YP-R0 hosted target code refactoring

As per title this patch aims at splitting common target
code and specific target code in a better way to
support future ports within the same environment
(e.g. Samsung YP-R1 where the Linux and the SoC
are the same, with differences in hardware devices
handling)

Change-Id: I67b4918c46403b184d3d8f42ab5aae7d01037fd0
Reviewed-on: http://gerrit.rockbox.org/409
Reviewed-by: Thomas Martitz <kugel@rockbox.org>
Tested-by: Thomas Martitz <kugel@rockbox.org>
This commit is contained in:
Lorenzo Miori 2013-02-23 16:59:49 +01:00 committed by Thomas Martitz
parent 3e4be68f8b
commit 60592165ca
25 changed files with 45 additions and 38 deletions

View file

@ -82,19 +82,19 @@ target/hosted/rtc.c
target/hosted/kernel-unix.c
target/hosted/filesystem-unix.c
target/hosted/lc-unix.c
target/hosted/ypr0/button-ypr0.c
target/hosted/ypr0/lcd-ypr0.c
target/hosted/ypr0/system-ypr0.c
target/hosted/samsungypr/ypr0/button-ypr0.c
target/hosted/samsungypr/lcd-ypr.c
target/hosted/samsungypr/ypr0/system-ypr0.c
thread.c
#ifdef HAVE_BACKLIGHT
target/hosted/ypr0/backlight-ypr0.c
target/hosted/samsungypr/ypr0/backlight-ypr0.c
#endif
target/hosted/ypr0/ascodec-ypr0.c
target/hosted/ypr0/powermgmt-ypr0.c
target/hosted/ypr0/gpio_ypr0.c
target/hosted/ypr0/audio-ypr0.c
target/hosted/samsungypr/ypr0/ascodec-ypr0.c
target/hosted/samsungypr/ypr0/powermgmt-ypr0.c
target/hosted/samsungypr/gpio_ypr.c
target/hosted/samsungypr/ypr0/audio-ypr0.c
#if CONFIG_TUNER
target/hosted/ypr0/radio-ypr0.c
target/hosted/samsungypr/radio-ypr.c
#endif
#endif

View file

@ -12,9 +12,6 @@
#define MODEL_NAME "Samsung YP-R0"
/* Indeed to check that */
/*TODO: R0 should charge battery automatically, no software stuff to manage that. Just to know about some as3543 registers, that should be set after loading samsung's afe.ko module
*/
/*TODO: implement USB data transfer management -> see safe mode script and think a way to implemtent it in the code */
#define USB_NONE
@ -94,20 +91,26 @@
#define HAVE_AS3514
#define HAVE_AS3543
/* We don't have hardware controls */
#define HAVE_SW_TONE_CONTROLS
/* We have the Si4709, which supports RDS */
#define CONFIG_TUNER SI4700
#define HAVE_TUNER_PWR_CTRL
#define HAVE_RDS_CAP
/* Define this for FM radio input available */
#define HAVE_FMRADIO_IN
#define INPUT_SRC_CAPS SRC_CAP_FMRADIO
/* We have a GPIO that detects it */
/* We have a GPIO pin that detects this */
#define HAVE_HEADPHONE_DETECTION
/* FIXME
* Lot of people reports bad battery life and funny charging times.
* Check what's going on...
*/
#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */
#define BATTERY_CAPACITY_MIN 600 /* min. capacity selectable */
#define BATTERY_CAPACITY_MAX 600 /* max. capacity selectable */

View file

@ -5,7 +5,7 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: backlight-target.h 19322 2008-12-04 04:16:53Z jethead71 $
* $Id$
*
* Copyright (C) 2011 by Lorenzo Miori
*

View file

@ -23,7 +23,7 @@
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <gpio_ypr0.h> /* includes r0GPIOioctl.h */
#include <gpio-target.h> /* includes common ioctl device definitions */
#include <sys/ioctl.h>
static int r0_gpio_dev = 0;

View file

@ -6,7 +6,8 @@
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Module wrapper for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko) of Samsung YP-R0
* Module wrapper for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko)
* Samsung YP-R0 & Samsung YP-R1
*
* Copyright (c) 2012 Lorenzo Miori
*
@ -27,7 +28,7 @@
#include "string.h"
#include "kernel.h"
#include "radio-ypr0.h"
#include "radio-ypr.h"
#include "rds.h"
#include "si4700.h"
#include "power.h"

View file

@ -8,7 +8,7 @@
*
* Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0
*
* Copyright (c) 2011 Lorenzo Miori
* Copyright (c) 2011-2013 Lorenzo Miori
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -29,11 +29,10 @@
#include "ascodec.h"
int afe_dev = -1;
static int afe_dev = -1;
/* ioctl parameter struct */
/* Structure used for ioctl module call */
struct codec_req_struct {
/* This works for every kind of afe.ko module requests */
unsigned char reg; /* Main register address */
unsigned char subreg; /* Set this only if you are reading/writing a PMU register*/
unsigned char value; /* To be read if reading a register; to be set if writing to a register */
@ -49,28 +48,31 @@ struct codec_req_struct {
/* Read from a PMU register */
#define IOCTL_SUBREG_READ 0x80034103
/* Open device */
void ascodec_init(void)
{
afe_dev = open("/dev/afe", O_RDWR);
}
/* Close device */
void ascodec_close(void)
{
if (afe_dev >= 0) {
if (afe_dev >= 0)
close(afe_dev);
}
}
/* Read functions returns -1 if fail, otherwise the register's value if success */
/* Write functions return >= 0 if success, otherwise -1 if fail */
/* Write register.
* Returns >= 0 if success, -1 if fail
*/
int ascodec_write(unsigned int reg, unsigned int value)
{
struct codec_req_struct r = { .reg = reg, .value = value };
return ioctl(afe_dev, IOCTL_REG_WRITE, &r);
}
/* Read register.
* Returns -1 if fail, otherwise the register's value if success
*/
int ascodec_read(unsigned int reg)
{
struct codec_req_struct r = { .reg = reg };
@ -81,6 +83,7 @@ int ascodec_read(unsigned int reg)
return retval;
}
/* Write PMU register */
void ascodec_write_pmu(unsigned int index, unsigned int subreg,
unsigned int value)
{
@ -88,6 +91,7 @@ void ascodec_write_pmu(unsigned int index, unsigned int subreg,
ioctl(afe_dev, IOCTL_SUBREG_WRITE, &r);
}
/* Read PMU register */
int ascodec_read_pmu(unsigned int index, unsigned int subreg)
{
struct codec_req_struct r = { .reg = index, .subreg = subreg, };

View file

@ -24,7 +24,7 @@
#include "kernel.h"
#include "system.h"
#include "button-target.h"
#include <gpio_ypr0.h> /* For headphones sense and buttons */
#include <gpio-target.h> /* For headphones sense and buttons */
int button_read_device(void)
{

View file

@ -5,7 +5,6 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: powermgmt-sim.c 29543 2011-03-08 19:33:30Z thomasjfox $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,7 +23,7 @@
#include "file.h"
#include "adc.h"
#include "sc900776.h"
#include "radio-ypr0.h"
#include "radio-ypr.h"
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
{

View file

@ -5,9 +5,8 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: system-sdl.c 29925 2011-05-25 20:11:03Z thomasjfox $
*
* Copyright (C) 2006 by Daniel Everton <dan@iocaine.org>
* Copyright (C) 2011-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
@ -31,7 +30,7 @@
#endif
#include "ascodec.h"
#include "gpio_ypr0.h"
#include "gpio-target.h"
void power_off(void)
{
@ -52,6 +51,7 @@ void system_init(void)
#if defined(HAVE_SDL_AUDIO) || defined(HAVE_SDL_THREADS) || defined(HAVE_SDL)
SDL_Init(0); /* need this if using any SDL subsystem */
#endif
/* Here begins our platform specific initilization for various things */
ascodec_init();
gpio_init();

4
tools/configure vendored
View file

@ -3347,8 +3347,8 @@ fi
swcodec="yes"
# architecture, manufacturer and model for the target-tree build
t_cpu="hosted"
t_manufacturer="ypr0"
t_model="app"
t_manufacturer="samsungypr"
t_model="ypr0"
;;
206|androidmips)

View file

@ -120,7 +120,7 @@ else
endif
ifneq (,$(findstring ypr0,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/ypr0/ypr0.make
include $(ROOTDIR)/firmware/target/hosted/samsungypr/ypr0/ypr0.make
endif
ifneq (,$(findstring android, $(APP_TYPE)))