From 60592165ca998875e4bc46c4396c5a123a7e9dbb Mon Sep 17 00:00:00 2001 From: Lorenzo Miori Date: Sat, 23 Feb 2013 16:59:49 +0100 Subject: 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 Tested-by: Thomas Martitz --- firmware/SOURCES | 18 +- firmware/export/config/samsungypr0.h | 13 +- firmware/target/hosted/samsungypr/adc-target.h | 0 .../target/hosted/samsungypr/backlight-target.h | 29 ++++ firmware/target/hosted/samsungypr/dir-target.h | 49 ++++++ firmware/target/hosted/samsungypr/gpio_ypr.c | 53 ++++++ firmware/target/hosted/samsungypr/lcd-target.h | 26 +++ firmware/target/hosted/samsungypr/lcd-ypr.c | 96 +++++++++++ firmware/target/hosted/samsungypr/radio-ypr.c | 126 ++++++++++++++ firmware/target/hosted/samsungypr/radio-ypr.h | 36 ++++ firmware/target/hosted/samsungypr/si4709.h | 82 +++++++++ firmware/target/hosted/samsungypr/system-target.h | 28 ++++ .../target/hosted/samsungypr/ypr0/ascodec-ypr0.c | 167 +++++++++++++++++++ .../target/hosted/samsungypr/ypr0/audio-ypr0.c | 69 ++++++++ .../target/hosted/samsungypr/ypr0/backlight-ypr0.c | 88 ++++++++++ .../target/hosted/samsungypr/ypr0/button-target.h | 45 +++++ .../target/hosted/samsungypr/ypr0/button-ypr0.c | 87 ++++++++++ .../target/hosted/samsungypr/ypr0/gpio-target.h | 62 +++++++ .../target/hosted/samsungypr/ypr0/powermgmt-ypr0.c | 107 ++++++++++++ .../target/hosted/samsungypr/ypr0/r0GPIOIoctl.h | 185 +++++++++++++++++++++ firmware/target/hosted/samsungypr/ypr0/sc900776.h | 134 +++++++++++++++ .../target/hosted/samsungypr/ypr0/system-ypr0.c | 104 ++++++++++++ firmware/target/hosted/samsungypr/ypr0/ypr0.make | 24 +++ firmware/target/hosted/ypr0/adc-target.h | 0 firmware/target/hosted/ypr0/ascodec-ypr0.c | 163 ------------------ firmware/target/hosted/ypr0/audio-ypr0.c | 69 -------- firmware/target/hosted/ypr0/backlight-target.h | 29 ---- firmware/target/hosted/ypr0/backlight-ypr0.c | 88 ---------- firmware/target/hosted/ypr0/button-target.h | 45 ----- firmware/target/hosted/ypr0/button-ypr0.c | 87 ---------- firmware/target/hosted/ypr0/dir-target.h | 49 ------ firmware/target/hosted/ypr0/gpio_ypr0.c | 53 ------ firmware/target/hosted/ypr0/gpio_ypr0.h | 62 ------- firmware/target/hosted/ypr0/lcd-target.h | 26 --- firmware/target/hosted/ypr0/lcd-ypr0.c | 96 ----------- firmware/target/hosted/ypr0/powermgmt-ypr0.c | 108 ------------ firmware/target/hosted/ypr0/r0GPIOIoctl.h | 185 --------------------- firmware/target/hosted/ypr0/radio-ypr0.c | 125 -------------- firmware/target/hosted/ypr0/radio-ypr0.h | 36 ---- firmware/target/hosted/ypr0/sc900776.h | 134 --------------- firmware/target/hosted/ypr0/si4709.h | 82 --------- firmware/target/hosted/ypr0/system-target.h | 28 ---- firmware/target/hosted/ypr0/system-ypr0.c | 104 ------------ firmware/target/hosted/ypr0/ypr0.make | 24 --- tools/configure | 4 +- tools/root.make | 2 +- 46 files changed, 1617 insertions(+), 1610 deletions(-) create mode 100644 firmware/target/hosted/samsungypr/adc-target.h create mode 100644 firmware/target/hosted/samsungypr/backlight-target.h create mode 100644 firmware/target/hosted/samsungypr/dir-target.h create mode 100644 firmware/target/hosted/samsungypr/gpio_ypr.c create mode 100644 firmware/target/hosted/samsungypr/lcd-target.h create mode 100644 firmware/target/hosted/samsungypr/lcd-ypr.c create mode 100644 firmware/target/hosted/samsungypr/radio-ypr.c create mode 100644 firmware/target/hosted/samsungypr/radio-ypr.h create mode 100644 firmware/target/hosted/samsungypr/si4709.h create mode 100644 firmware/target/hosted/samsungypr/system-target.h create mode 100644 firmware/target/hosted/samsungypr/ypr0/ascodec-ypr0.c create mode 100644 firmware/target/hosted/samsungypr/ypr0/audio-ypr0.c create mode 100644 firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c create mode 100644 firmware/target/hosted/samsungypr/ypr0/button-target.h create mode 100644 firmware/target/hosted/samsungypr/ypr0/button-ypr0.c create mode 100644 firmware/target/hosted/samsungypr/ypr0/gpio-target.h create mode 100644 firmware/target/hosted/samsungypr/ypr0/powermgmt-ypr0.c create mode 100644 firmware/target/hosted/samsungypr/ypr0/r0GPIOIoctl.h create mode 100644 firmware/target/hosted/samsungypr/ypr0/sc900776.h create mode 100644 firmware/target/hosted/samsungypr/ypr0/system-ypr0.c create mode 100644 firmware/target/hosted/samsungypr/ypr0/ypr0.make delete mode 100644 firmware/target/hosted/ypr0/adc-target.h delete mode 100644 firmware/target/hosted/ypr0/ascodec-ypr0.c delete mode 100644 firmware/target/hosted/ypr0/audio-ypr0.c delete mode 100644 firmware/target/hosted/ypr0/backlight-target.h delete mode 100644 firmware/target/hosted/ypr0/backlight-ypr0.c delete mode 100644 firmware/target/hosted/ypr0/button-target.h delete mode 100644 firmware/target/hosted/ypr0/button-ypr0.c delete mode 100644 firmware/target/hosted/ypr0/dir-target.h delete mode 100644 firmware/target/hosted/ypr0/gpio_ypr0.c delete mode 100644 firmware/target/hosted/ypr0/gpio_ypr0.h delete mode 100644 firmware/target/hosted/ypr0/lcd-target.h delete mode 100644 firmware/target/hosted/ypr0/lcd-ypr0.c delete mode 100644 firmware/target/hosted/ypr0/powermgmt-ypr0.c delete mode 100644 firmware/target/hosted/ypr0/r0GPIOIoctl.h delete mode 100644 firmware/target/hosted/ypr0/radio-ypr0.c delete mode 100644 firmware/target/hosted/ypr0/radio-ypr0.h delete mode 100644 firmware/target/hosted/ypr0/sc900776.h delete mode 100644 firmware/target/hosted/ypr0/si4709.h delete mode 100644 firmware/target/hosted/ypr0/system-target.h delete mode 100644 firmware/target/hosted/ypr0/system-ypr0.c delete mode 100644 firmware/target/hosted/ypr0/ypr0.make diff --git a/firmware/SOURCES b/firmware/SOURCES index 887445b53c..8ba45af533 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -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 diff --git a/firmware/export/config/samsungypr0.h b/firmware/export/config/samsungypr0.h index debe9a3f80..c81fc645bb 100644 --- a/firmware/export/config/samsungypr0.h +++ b/firmware/export/config/samsungypr0.h @@ -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 */ diff --git a/firmware/target/hosted/samsungypr/adc-target.h b/firmware/target/hosted/samsungypr/adc-target.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/firmware/target/hosted/samsungypr/backlight-target.h b/firmware/target/hosted/samsungypr/backlight-target.h new file mode 100644 index 0000000000..21db75c8c9 --- /dev/null +++ b/firmware/target/hosted/samsungypr/backlight-target.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2011 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/hosted/samsungypr/dir-target.h b/firmware/target/hosted/samsungypr/dir-target.h new file mode 100644 index 0000000000..7df9554e92 --- /dev/null +++ b/firmware/target/hosted/samsungypr/dir-target.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 by Thomas Martitz + * + * 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 __DIR_TARGET_H__ +#define __DIR_TARGET_H__ + +#include +/* including unistd.h is too noisy */ +extern int rmdir(const char* name); + + +#define dirent_uncached dirent +#define DIR_UNCACHED DIR +#define opendir_uncached _opendir +#define readdir_uncached _readdir +#define closedir_uncached _closedir +#define mkdir_uncached _mkdir +#define rmdir_uncached rmdir + +extern DIR* _opendir(const char* name); +extern int _mkdir(const char* name); +extern int _rmdir(const char* name); +extern int _closedir(DIR* dir); +extern struct dirent *_readdir(DIR* dir); +extern void fat_size(unsigned long *size, unsigned long *free); + +#define DIRFUNCTIONS_DEFINED +#define DIRENT_DEFINED +#define DIR_DEFINED + +#endif /* __DIR_TARGET_H__ */ diff --git a/firmware/target/hosted/samsungypr/gpio_ypr.c b/firmware/target/hosted/samsungypr/gpio_ypr.c new file mode 100644 index 0000000000..0d4a7eceae --- /dev/null +++ b/firmware/target/hosted/samsungypr/gpio_ypr.c @@ -0,0 +1,53 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 + * + * Copyright (c) 2011 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 +#include +#include +#include /* includes common ioctl device definitions */ +#include + +static int r0_gpio_dev = 0; + +void gpio_init(void) +{ + r0_gpio_dev = open("/dev/r0GPIO", O_RDONLY); + if (r0_gpio_dev < 0) + printf("/dev/r0GPIO open error!"); +} + +void gpio_close(void) +{ + if (r0_gpio_dev < 0) + close(r0_gpio_dev); +} + +int gpio_control_struct(int request, R0GPIOInfo r) +{ + return ioctl(r0_gpio_dev, request, &r); +} + +int gpio_control(int request, int num, int mode, int val) +{ + R0GPIOInfo r = { .num = num, .mode = mode, .val = val, }; + return ioctl(r0_gpio_dev, request, &r); +} diff --git a/firmware/target/hosted/samsungypr/lcd-target.h b/firmware/target/hosted/samsungypr/lcd-target.h new file mode 100644 index 0000000000..c8a6de74f9 --- /dev/null +++ b/firmware/target/hosted/samsungypr/lcd-target.h @@ -0,0 +1,26 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * 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__ + +extern fb_data *dev_fb; +#define LCD_FRAMEBUF_ADDR(col, row) (dev_fb + row*LCD_WIDTH + col) + +#endif diff --git a/firmware/target/hosted/samsungypr/lcd-ypr.c b/firmware/target/hosted/samsungypr/lcd-ypr.c new file mode 100644 index 0000000000..40528c298a --- /dev/null +++ b/firmware/target/hosted/samsungypr/lcd-ypr.c @@ -0,0 +1,96 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $ + * + * Copyright (C) 2011 Lorenzo Miori, Thomas Martitz + * + * 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 +#include +#include +#include "string.h" +#include +#include +#include + +#include "file.h" +#include "debug.h" +#include "system.h" +#include "screendump.h" +#include "lcd.h" + +static int dev_fd = 0; +fb_data *dev_fb = 0; + +void lcd_shutdown(void) +{ + printf("FB closed."); + munmap(dev_fb, FRAMEBUFFER_SIZE); + close(dev_fd); +} + +void lcd_init_device(void) +{ + size_t screensize; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + + /* Open the framebuffer device */ + dev_fd = open("/dev/fb0", O_RDWR); + if (dev_fd == -1) { + perror("Error: cannot open framebuffer device"); + exit(1); + } + printf("The framebuffer device was opened successfully.\n"); + + /* Get the fixed properties */ + if (ioctl(dev_fd, FBIOGET_FSCREENINFO, &finfo) == -1) { + perror("Error reading fixed information"); + exit(2); + } + + /* Now we get the settable settings, and we set 16 bit bpp */ + if (ioctl(dev_fd, FBIOGET_VSCREENINFO, &vinfo) == -1) { + perror("Error reading variable information"); + exit(3); + } + + vinfo.bits_per_pixel = 16; + + if (ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo)) { + perror("fbset(ioctl)"); + exit(4); + } + + printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel); + + /* Figure out the size of the screen in bytes */ + screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; + if (screensize != FRAMEBUFFER_SIZE) + { + exit(4); + perror("Display and framebuffer mismatch!\n"); + } + + /* Map the device to memory */ + dev_fb = mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, dev_fd, 0); + if ((int)dev_fb == -1) { + perror("Error: failed to map framebuffer device to memory"); + exit(4); + } + printf("The framebuffer device was mapped to memory successfully.\n"); +} diff --git a/firmware/target/hosted/samsungypr/radio-ypr.c b/firmware/target/hosted/samsungypr/radio-ypr.c new file mode 100644 index 0000000000..1929bb7c90 --- /dev/null +++ b/firmware/target/hosted/samsungypr/radio-ypr.c @@ -0,0 +1,126 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Module wrapper for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko) + * Samsung YP-R0 & Samsung YP-R1 + * + * Copyright (c) 2012 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 +#include +#include +#include "stdint.h" +#include "string.h" +#include "kernel.h" + +#include "radio-ypr.h" +#include "rds.h" +#include "si4700.h" +#include "power.h" + +static int radio_dev = -1; + +void radiodev_open(void) { + radio_dev = open("/dev/si470x", O_RDWR); +} + +void radiodev_close(void) { + close(radio_dev); +} + +/* High-level registers access */ +void si4709_write_reg(int addr, uint16_t value) { + sSi4709_t r = { .addr = addr, .value = value }; + ioctl(radio_dev, IOCTL_SI4709_WRITE_BYTE, &r); +} + +uint16_t si4709_read_reg(int addr) { + sSi4709_t r = { .addr = addr, .value = 0 }; + ioctl(radio_dev, IOCTL_SI4709_READ_BYTE, &r); + return r.value; +} + +/* Low-level i2c channel access */ +int fmradio_i2c_write(unsigned char address, unsigned char* buf, int count) +{ + (void)address; + sSi4709_i2c_t r = { .size = count, .buf = buf }; + return ioctl(radio_dev, IOCTL_SI4709_I2C_WRITE, &r); +} + +int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count) +{ + (void)address; + sSi4709_i2c_t r = { .size = count, .buf = buf }; + return ioctl(radio_dev, IOCTL_SI4709_I2C_READ, &r); +} + +#ifdef HAVE_RDS_CAP + +/* Register we are going to poll */ +#define STATUSRSSI 0xA +#define STATUSRSSI_RDSR (0x1 << 15) + +/* Low-level RDS Support */ +static struct event_queue rds_queue; +static uint32_t rds_stack[DEFAULT_STACK_SIZE / sizeof(uint32_t)]; +static uint16_t rds_data[4]; + +enum { + Q_POWERUP, +}; + +static void NORETURN_ATTR rds_thread(void) +{ + /* start up frozen */ + int timeout = TIMEOUT_BLOCK; + struct queue_event ev; + + while (true) { + queue_wait_w_tmo(&rds_queue, &ev, timeout); + switch (ev.id) { + case Q_POWERUP: + /* power up: timeout after 1 tick, else block indefinitely */ + timeout = ev.data ? 1 : TIMEOUT_BLOCK; + break; + case SYS_TIMEOUT: + /* Captures RDS data and processes it */ + if ((si4709_read_reg(STATUSRSSI) & STATUSRSSI_RDSR) >> 8) { + if (si4700_rds_read_raw(rds_data) && rds_process(rds_data)) + si4700_rds_set_event(); + } + break; + } + } +} + +/* true after full radio power up, and false before powering down */ +void si4700_rds_powerup(bool on) +{ + queue_post(&rds_queue, Q_POWERUP, on); +} + +/* One-time RDS init at startup */ +void si4700_rds_init(void) +{ + queue_init(&rds_queue, false); + create_thread(rds_thread, rds_stack, sizeof(rds_stack), 0, "rds" + IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU)); + rds_init(); +} +#endif /* HAVE_RDS_CAP */ diff --git a/firmware/target/hosted/samsungypr/radio-ypr.h b/firmware/target/hosted/samsungypr/radio-ypr.h new file mode 100644 index 0000000000..13bcb6dc72 --- /dev/null +++ b/firmware/target/hosted/samsungypr/radio-ypr.h @@ -0,0 +1,36 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Module wrapper for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko) of Samsung YP-R0 + * + * Copyright (c) 2012 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 __RADIO_YPR0_H__ +#define __RADIO_YPR0_H__ + +#include "si4709.h" +#include "stdint.h" +#include "rds.h" +#include "si4700.h" + +void radiodev_open(void); +void radiodev_close(void); +void si4709_write_reg(int addr, uint16_t value); +uint16_t si4709_read_reg(int addr); + +#endif /*__RADIO-YPR0_H__*/ \ No newline at end of file diff --git a/firmware/target/hosted/samsungypr/si4709.h b/firmware/target/hosted/samsungypr/si4709.h new file mode 100644 index 0000000000..c27472e856 --- /dev/null +++ b/firmware/target/hosted/samsungypr/si4709.h @@ -0,0 +1,82 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Module header for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko) of Samsung YP-R0 + * + * Copyright (c) 2012 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 __SI4709_H__ +#define __SI4709_H__ + +#include "stdint.h" + +/* 7bits I2C address */ +#define SI4709_I2C_SLAVE_ADDR 0x10 + +#define SI4702_DEVICEID 0x00 +#define SI4702_CHIPID 0x01 +#define SI4702_POWERCFG 0x02 +#define SI4702_CHANNEL 0x03 +#define SI4702_SYSCONFIG1 0x04 +#define SI4702_SYSCONFIG2 0x05 +#define SI4702_SYSCONFIG3 0x06 +#define SI4702_TEST1 0x07 +#define SI4702_TEST2 0x08 +#define SI4702_B00TCONFIG 0x09 +#define SI4702_STATUSRSSI 0x0A +#define SI4702_READCHAN 0x0B +#define SI4709_REG_NUM 0x10 +#define SI4702_REG_BYTE (SI4709_REG_NUM * 2) +#define SI4702_DEVICE_ID 0x1242 +#define SI4702_RW_REG_NUM (SI4702_STATUSRSSI - SI4702_POWERCFG) +#define SI4702_RW_OFFSET \ + (SI4709_REG_NUM - SI4702_STATUSRSSI + SI4702_POWERCFG) +#define BYTE_TO_WORD(hi, lo) (((hi) << 8) & 0xFF00) | ((lo) & 0x00FF) + +typedef struct { + int addr; + uint16_t value; +}__attribute__((packed)) sSi4709_t; + +typedef struct { + int size; + unsigned char *buf; +}__attribute__((packed)) sSi4709_i2c_t; + +typedef enum +{ + IOCTL_SI4709_INIT = 0, + IOCTL_SI4709_CLOSE, + IOCTL_SI4709_WRITE_BYTE, + IOCTL_SI4709_READ_BYTE, + IOCTL_SI4709_I2C_WRITE, + IOCTL_SI4709_I2C_READ, + + E_IOCTL_SI4709_MAX +} eSi4709_ioctl_t; + +#define DRV_IOCTL_SI4709_MAGIC 'S' + +#define IOCTL_SI4709_INIT _IO(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_INIT) +#define IOCTL_SI4709_CLOSE _IO(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_CLOSE) +#define IOCTL_SI4709_WRITE_BYTE _IOW(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_WRITE_BYTE, sSi4709_t) +#define IOCTL_SI4709_READ_BYTE _IOR(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_READ_BYTE, sSi4709_t) +#define IOCTL_SI4709_I2C_WRITE _IOW(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_I2C_WRITE, sSi4709_i2c_t) +#define IOCTL_SI4709_I2C_READ _IOR(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_I2C_READ, sSi4709_i2c_t) + +#endif /* __SI4709_H__ */ \ No newline at end of file diff --git a/firmware/target/hosted/samsungypr/system-target.h b/firmware/target/hosted/samsungypr/system-target.h new file mode 100644 index 0000000000..1ef8b9aeda --- /dev/null +++ b/firmware/target/hosted/samsungypr/system-target.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2010 by Thomas Martitz + * + * 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 __SYSTEM_TARGET_H__ +#define __SYSTEM_TARGET_H__ + +#include "kernel-unix.h" +#include "system-hosted.h" + +#define NEED_GENERIC_BYTESWAPS +#endif /* __SYSTEM_TARGET_H__ */ diff --git a/firmware/target/hosted/samsungypr/ypr0/ascodec-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/ascodec-ypr0.c new file mode 100644 index 0000000000..24362af0c0 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/ascodec-ypr0.c @@ -0,0 +1,167 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0 + * + * 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 + * 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 "fcntl.h" +#include "unistd.h" +#include "stdio.h" +#include "string.h" +#include "sys/ioctl.h" +#include "stdlib.h" + +#include "ascodec.h" + +static int afe_dev = -1; + +/* Structure used for ioctl module call */ +struct codec_req_struct { + 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 */ +} __attribute__((packed)); + + +/* Write to a normal register */ +#define IOCTL_REG_WRITE 0x40034101 +/* Write to a PMU register */ +#define IOCTL_SUBREG_WRITE 0x40034103 +/* Read from a normal register */ +#define IOCTL_REG_READ 0x80034102 +/* 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) + close(afe_dev); +} + +/* 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 }; + int retval = ioctl(afe_dev, IOCTL_REG_READ, &r); + if (retval >= 0) + return r.value; + else + return retval; +} + +/* Write PMU register */ +void ascodec_write_pmu(unsigned int index, unsigned int subreg, + unsigned int value) +{ + struct codec_req_struct r = {.reg = index, .subreg = subreg, .value = value}; + 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, }; + int retval = ioctl(afe_dev, IOCTL_SUBREG_READ, &r); + if (retval >= 0) + return r.value; + else + return retval; +} + +int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data) +{ + int i, val, ret = 0; + + for (i = 0; i < (int)len; i++) + { + val = ascodec_read(i + index); + if (val >= 0) data[i] = val; + else ret = -1; + } + + return (ret ?: (int)len); +} + +/* + * NOTE: + * After the conversion to interrupts, ascodec_(lock|unlock) are only used by + * adc-as3514.c to protect against other threads corrupting the result by using + * the ADC at the same time. this adc_read() doesn't yield but blocks, so + * lock/unlock is not needed + * + * Additionally, concurrent ascodec_?(read|write) calls are instead protected + * by the R0's Kernel I2C driver for ascodec (mutexed), so it's automatically + * safe + */ + +void ascodec_lock(void) +{ +} + +void ascodec_unlock(void) +{ +} + +bool ascodec_chg_status(void) +{ + return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS; +} + +bool ascodec_endofch(void) +{ + return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH; +} + +void ascodec_monitor_endofch(void) +{ + ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH); +} + + +void ascodec_write_charger(int value) +{ + ascodec_write_pmu(AS3543_CHARGER, 1, value); +} + +int ascodec_read_charger(void) +{ + return ascodec_read_pmu(AS3543_CHARGER, 1); +} + +void ascodec_wait_adc_finished(void) +{ +} diff --git a/firmware/target/hosted/samsungypr/ypr0/audio-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/audio-ypr0.c new file mode 100644 index 0000000000..dfd63ef5cd --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/audio-ypr0.c @@ -0,0 +1,69 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 by Bertrik Sikken + * + * 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 "cpu.h" +#include "audio.h" +#include "audiohw.h" +#include "sound.h" + +int audio_channels = 2; +int audio_output_source = AUDIO_SRC_PLAYBACK; + +void audio_set_output_source(int source) +{ + if ((unsigned)source >= AUDIO_NUM_SOURCES) + source = AUDIO_SRC_PLAYBACK; + + audio_output_source = source; +} /* audio_set_output_source */ + +void audio_input_mux(int source, unsigned flags) +{ + static int last_source = AUDIO_SRC_PLAYBACK; + + (void)flags; + + switch (source) + { + default: /* playback - no recording */ + source = AUDIO_SRC_PLAYBACK; + case AUDIO_SRC_PLAYBACK: + audio_channels = 2; + if (source != last_source) + { + audiohw_set_monitor(false); + + } + break; + + case AUDIO_SRC_FMRADIO: /* recording and playback */ + audio_channels = 2; + if (source == last_source) + break; + + audiohw_set_monitor(true); + break; + } /* end switch */ + + last_source = source; +} /* audio_input_mux */ + diff --git a/firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c new file mode 100644 index 0000000000..551b386f19 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/backlight-ypr0.c @@ -0,0 +1,88 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2011 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 "backlight.h" +#include "backlight-target.h" +#include "lcd.h" +#include "as3514.h" +#include "ascodec.h" +#include +#include "unistd.h" + +static bool backlight_on_status = true; /* Is on or off? */ + +/*TODO: see if LCD sleep could be implemented in a better way -> ie using a rockbox feature */ +/* Turn off LCD power supply */ +static void _backlight_lcd_sleep(void) +{ + int fp = open("/sys/class/graphics/fb0/blank", O_RDWR); + write(fp, "1", 1); + close(fp); +} +/* Turn on LCD screen */ +static void _backlight_lcd_power(void) +{ + int fp = open("/sys/class/graphics/fb0/blank", O_RDWR); + write(fp, "0", 1); + close(fp); +} + +bool _backlight_init(void) +{ + /* We have nothing to do */ + return true; +} + +void _backlight_on(void) +{ + if (!backlight_on_status) + { + /* Turn on lcd power before backlight */ + _backlight_lcd_power(); + /* Original app sets this to 0xb1 when backlight is on... */ + ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0xb1); + } + + backlight_on_status = true; + +} + +void _backlight_off(void) +{ + if (backlight_on_status) { + /* Disabling the DCDC15 completely, keeps brightness register value */ + ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0x00); + /* Turn off lcd power then */ + _backlight_lcd_sleep(); + } + + backlight_on_status = false; +} + +void _backlight_set_brightness(int brightness) +{ + /* Just another check... */ + if (brightness > MAX_BRIGHTNESS_SETTING) + brightness = MAX_BRIGHTNESS_SETTING; + if (brightness < MIN_BRIGHTNESS_SETTING) + brightness = MIN_BRIGHTNESS_SETTING; + ascodec_write_pmu(AS3543_BACKLIGHT, 0x3, brightness << 3 & 0xf8); +} diff --git a/firmware/target/hosted/samsungypr/ypr0/button-target.h b/firmware/target/hosted/samsungypr/ypr0/button-target.h new file mode 100644 index 0000000000..3a3866932a --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/button-target.h @@ -0,0 +1,45 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2011 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_ + +void button_close_device(void); + +/* Logical buttons key codes */ +#define BUTTON_UP 0x00000001 +#define BUTTON_DOWN 0x00000002 +#define BUTTON_LEFT 0x00000004 +#define BUTTON_RIGHT 0x00000008 +#define BUTTON_USER 0x00000010 +#define BUTTON_MENU 0x00000020 +#define BUTTON_BACK 0x00000040 +#define BUTTON_POWER 0x00000080 +#define BUTTON_SELECT 0x00000100 + +#define BUTTON_MAIN (BUTTON_UP|BUTTON_DOWN|BUTTON_LEFT|BUTTON_RIGHT|BUTTON_USER|BUTTON_MENU|BUTTON_BACK|BUTTON_POWER|BUTTON_SELECT) /* all buttons */ + +/* Software power-off */ +#define POWEROFF_BUTTON BUTTON_POWER +/* About 3 seconds */ +#define POWEROFF_COUNT 10 + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/hosted/samsungypr/ypr0/button-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/button-ypr0.c new file mode 100644 index 0000000000..e3ad309187 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/button-ypr0.c @@ -0,0 +1,87 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: button-sdl.c 30482 2011-09-08 14:53:28Z kugel $ + * + * Copyright (C) 2011 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 "button.h" +#include "kernel.h" +#include "system.h" +#include "button-target.h" +#include /* For headphones sense and buttons */ + +int button_read_device(void) +{ + int key = BUTTON_NONE; + + /* Check for all the keys */ + if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_USER_KEY, 0, 0)) { + key |= BUTTON_USER; + } + if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_CENTRAL_KEY, 0, 0)) { + key |= BUTTON_SELECT; + } + if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_UP_KEY, 0, 0)) { + key |= BUTTON_UP; + } + if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_DOWN_KEY, 0, 0)) { + key |= BUTTON_DOWN; + } + if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_LEFT_KEY, 0, 0)) { + key |= BUTTON_LEFT; + } + if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_RIGHT_KEY, 0, 0)) { + key |= BUTTON_RIGHT; + } + if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_MENU_KEY, 0, 0)) { + key |= BUTTON_MENU; + } + if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_BACK_KEY, 0, 0)) { + key |= BUTTON_BACK; + } + if (gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_POWER_KEY, 0, 0)) { + key |= BUTTON_POWER; + } + + return key; +} + +bool headphones_inserted(void) +{ + /* GPIO low - 0 - means headphones inserted */ + return !gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_HEADPHONE_SENSE, 0, 0); +} + +void button_init_device(void) +{ + /* Setup GPIO pin for headphone sense, copied from OF */ + gpio_control(DEV_CTRL_GPIO_SET_MUX, GPIO_HEADPHONE_SENSE, CONFIG_SION, PAD_CTL_47K_PU); + gpio_control(DEV_CTRL_GPIO_SET_INPUT, GPIO_HEADPHONE_SENSE, CONFIG_SION, PAD_CTL_47K_PU); + + /* No need to initialize any GPIO pin, since this is done loading the r0Btn module */ +} + +#ifdef BUTTON_DRIVER_CLOSE +/* I'm not sure it's called at shutdown...give a check! */ +void button_close_device(void) +{ + /* Don't know the precise meaning, but it's done as in the OF, so copied there */ + gpio_control(DEV_CTRL_GPIO_UNSET_MUX, GPIO_HEADPHONE_SENSE, CONFIG_SION, 0); +} +#endif /* BUTTON_DRIVER_CLOSE */ diff --git a/firmware/target/hosted/samsungypr/ypr0/gpio-target.h b/firmware/target/hosted/samsungypr/ypr0/gpio-target.h new file mode 100644 index 0000000000..3c2033baff --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/gpio-target.h @@ -0,0 +1,62 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 + * + * Copyright (c) 2011 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 GPIO_YPR0_H +#define GPIO_YPR0_H + +#include "r0GPIOIoctl.h" + +/* Some meaningful pins used in the R0 */ + +#define GPIO_HEADPHONE_SENSE GPIO1_5 +#define GPIO_EXT_PWR_SENSE GPIO1_26 +#define GPIO_SD_SENSE GPIO2_27 +#define GPIO_AS3543_INTERUPT GPIO1_25 +#define GPIO_PCB_VER_DETECT GPIO_10 +/* I2C bus for AS3543 codec */ +#define GPIO_I2C_CLK0 GPIO_1_0 +#define GPIO_I2C_DAT0 GPIO_1_1 +/* I2C bus for the SI4079 FM radio chip */ +#define GPIO_I2C_CLK1 GPIO_2_12 +#define GPIO_I2C_DAT1 GPIO_2_13 +#define GPIO_FM_SEARCH GPIO1_4 +#define GPIO_FM_BUS_EN GPIO2_19 + +/* Keypad */ + +#define GPIO_BACK_KEY GPIO2_29 +#define GPIO_USER_KEY GPIO2_30 +#define GPIO_MENU_KEY GPIO2_31 +#define GPIO_POWER_KEY GPIO2_16 +#define GPIO_CENTRAL_KEY GPIO3_5 +#define GPIO_UP_KEY GPIO3_9 +#define GPIO_DOWN_KEY GPIO3_8 +#define GPIO_LEFT_KEY GPIO2_28 +#define GPIO_RIGHT_KEY GPIO3_7 + + +void gpio_init(void); +void gpio_close(void); +int gpio_control_struct(int request, R0GPIOInfo pin); +int gpio_control(int request, int num, int mode, int val); + +#endif diff --git a/firmware/target/hosted/samsungypr/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/powermgmt-ypr0.c new file mode 100644 index 0000000000..6e04d25f58 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/powermgmt-ypr0.c @@ -0,0 +1,107 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * 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 +#include "kernel.h" +#include "powermgmt.h" +#include "power.h" +#include "file.h" +#include "adc.h" +#include "sc900776.h" +#include "radio-ypr.h" + +const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ + 3470 +}; + +/* the OF shuts down at this voltage */ +const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = +{ + 3450 +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ +const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = +{ + { 3450, 3502, 3550, 3587, 3623, 3669, 3742, 3836, 3926, 4026, 4200 } +}; + +#if CONFIG_CHARGING +/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ +const unsigned short const percent_to_volt_charge[11] = +{ + 3450, 3670, 3721, 3751, 3782, 3821, 3876, 3941, 4034, 4125, 4200 +}; + +unsigned int power_input_status(void) +{ + unsigned status = POWER_INPUT_NONE; + int fd = open("/dev/minivet", O_RDONLY); + if (fd >= 0) + { + if (ioctl(fd, IOCTL_MINIVET_DET_VBUS, NULL) > 0) + status = POWER_INPUT_MAIN_CHARGER; + close(fd); + } + return status; +} + +#endif /* CONFIG_CHARGING */ + + +/* Returns battery voltage from ADC [millivolts], + * adc returns voltage in 5mV steps */ +int _battery_voltage(void) +{ + return adc_read(3) * 5; +} + +bool charging_state(void) +{ + const unsigned short charged_thres = 4170; + bool ret = (power_input_status() == POWER_INPUT_MAIN_CHARGER); + /* dont indicate for > ~95% */ + return ret && (_battery_voltage() <= charged_thres); +} + +#if CONFIG_TUNER +static bool tuner_on = false; + +bool tuner_power(bool status) +{ + if (status != tuner_on) + { + tuner_on = status; + status = !status; + if (tuner_on) { + radiodev_open(); + } + else { + radiodev_close(); + } + } + + return status; +} + +bool tuner_powered(void) +{ + return tuner_on; +} +#endif /* #if CONFIG_TUNER */ \ No newline at end of file diff --git a/firmware/target/hosted/samsungypr/ypr0/r0GPIOIoctl.h b/firmware/target/hosted/samsungypr/ypr0/r0GPIOIoctl.h new file mode 100644 index 0000000000..e77f35fbb7 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/r0GPIOIoctl.h @@ -0,0 +1,185 @@ +/* This file originates from the linux kernel provided in Samsung's YP-R0 Open + * Source package (second release, which includes some driver modules sources). + */ + +#ifndef __IOCTL_GPIO_H__ +#define __IOCTL_GPIO_H__ + +#include +//#include "iomux.h" + +typedef struct { + int num; + int mode; + int val; +}__attribute__((packed)) R0GPIOInfo; + + +#define IOCTL_GPIO_MAGIC 'G' + +#define E_IOCTL_GPIO_SET_MUX 0 +#define E_IOCTL_GPIO_UNSET_MUX 1 +#define E_IOCTL_GPIO_SET_TYPE 2 +#define E_IOCTL_GPIO_SET_OUTPUT 3 +#define E_IOCTL_GPIO_SET_INPUT 4 +#define E_IOCTL_GPIO_SET_HIGH 5 +#define E_IOCTL_GPIO_SET_LOW 6 +#define E_IOCTL_GPIO_GET_VAL 7 +#define E_IOCTL_GPIO_IS_HIGH 8 +#define E_IOCTL_GPIO_MAX_NR 9 + +#define DEV_CTRL_GPIO_SET_MUX _IOW(IOCTL_GPIO_MAGIC, 0, R0GPIOInfo) +#define DEV_CTRL_GPIO_UNSET_MUX _IOW(IOCTL_GPIO_MAGIC, 1, R0GPIOInfo) +#define DEV_CTRL_GPIO_SET_TYPE _IOW(IOCTL_GPIO_MAGIC, 2, R0GPIOInfo) +#define DEV_CTRL_GPIO_SET_OUTPUT _IOW(IOCTL_GPIO_MAGIC, 3, R0GPIOInfo) +#define DEV_CTRL_GPIO_SET_INPUT _IOW(IOCTL_GPIO_MAGIC, 4, R0GPIOInfo) +#define DEV_CTRL_GPIO_SET_HIGH _IOW(IOCTL_GPIO_MAGIC, 5, R0GPIOInfo) +#define DEV_CTRL_GPIO_SET_LOW _IOW(IOCTL_GPIO_MAGIC, 6, R0GPIOInfo) +#define DEV_CTRL_GPIO_GET_VAL _IOW(IOCTL_GPIO_MAGIC, 7, R0GPIOInfo) +#define DEV_CTRL_GPIO_IS_HIGH _IOW(IOCTL_GPIO_MAGIC, 8, R0GPIOInfo) + + +typedef enum +{ + GPIO1_0 = 0, /* GPIO group 1 start */ + GPIO1_1, + GPIO1_2, + GPIO1_3, + GPIO1_4, + GPIO1_5, + GPIO1_6, + GPIO1_7, + GPIO1_8, + GPIO1_9, + GPIO1_10, + GPIO1_11, + GPIO1_12, + GPIO1_13, + GPIO1_14, + GPIO1_15, + GPIO1_16, + GPIO1_17, + GPIO1_18, + GPIO1_19, + GPIO1_20, + GPIO1_21, + GPIO1_22, + GPIO1_23, + GPIO1_24, + GPIO1_25, + GPIO1_26, + GPIO1_27, + GPIO1_28, + GPIO1_29, + GPIO1_30, + GPIO1_31, + GPIO2_0, /* GPIO group 2 start */ + GPIO2_1, + GPIO2_2, + GPIO2_3, + GPIO2_4, + GPIO2_5, + GPIO2_6, + GPIO2_7, + GPIO2_8, + GPIO2_9, + GPIO2_10, + GPIO2_11, + GPIO2_12, + GPIO2_13, + GPIO2_14, + GPIO2_15, + GPIO2_16, + GPIO2_17, + GPIO2_18, + GPIO2_19, + GPIO2_20, + GPIO2_21, + GPIO2_22, + GPIO2_23, + GPIO2_24, + GPIO2_25, + GPIO2_26, + GPIO2_27, + GPIO2_28, + GPIO2_29, + GPIO2_30, + GPIO2_31, + GPIO3_0, /* GPIO group 3 start */ + GPIO3_1, + GPIO3_2, + GPIO3_3, + GPIO3_4, + GPIO3_5, + GPIO3_6, + GPIO3_7, + GPIO3_8, + GPIO3_9, + GPIO3_10, + GPIO3_11, + GPIO3_12, + GPIO3_13, + GPIO3_14, + GPIO3_15, + GPIO3_16, + GPIO3_17, + GPIO3_18, + GPIO3_19, + GPIO3_20, + GPIO3_21, + GPIO3_22, + GPIO3_23, + GPIO3_24, + GPIO3_25, + GPIO3_26, + GPIO3_27, + GPIO3_28, + GPIO3_29, + GPIO3_30, + GPIO3_31, +}R0_MX37_GPIO; + +typedef enum +{ + CONFIG_ALT0, + CONFIG_ALT1, + CONFIG_ALT2, + CONFIG_ALT3, + CONFIG_ALT4, + CONFIG_ALT5, + CONFIG_ALT6, + CONFIG_ALT7, + CONFIG_GPIO, + CONFIG_SION = 0x01 << 4, + CONFIG_DEFAULT +} R0_MX37_PIN_CONFIG; + +#ifndef __MACH_MX37_IOMUX_H__ +typedef enum +{ + PAD_CTL_SRE_SLOW = 0x0 << 0, + PAD_CTL_SRE_FAST = 0x1 << 0, + PAD_CTL_DRV_LOW = 0x0 << 1, + PAD_CTL_DRV_MEDIUM = 0x1 << 1, + PAD_CTL_DRV_HIGH = 0x2 << 1, + PAD_CTL_DRV_MAX = 0x3 << 1, + PAD_CTL_ODE_OPENDRAIN_NONE = 0x0 << 3, + PAD_CTL_ODE_OPENDRAIN_ENABLE = 0x1 << 3, + PAD_CTL_100K_PD = 0x0 << 4, + PAD_CTL_47K_PU = 0x1 << 4, + PAD_CTL_100K_PU = 0x2 << 4, + PAD_CTL_22K_PU = 0x3 << 4, + PAD_CTL_PUE_KEEPER = 0x0 << 6, + PAD_CTL_PUE_PULL = 0x1 << 6, + PAD_CTL_PKE_NONE = 0x0 << 7, + PAD_CTL_PKE_ENABLE = 0x1 << 7, + PAD_CTL_HYS_NONE = 0x0 << 8, + PAD_CTL_HYS_ENABLE = 0x1 << 8, + PAD_CTL_DDR_INPUT_CMOS = 0x0 << 9, + PAD_CTL_DDR_INPUT_DDR = 0x1 << 9, + PAD_CTL_DRV_VOT_LOW = 0x0 << 13, + PAD_CTL_DRV_VOT_HIGH = 0x1 << 13, +} R0_MX37_PAD_CONFIG; +#endif + +#endif /* __IOCTL_GPIO__H__ */ diff --git a/firmware/target/hosted/samsungypr/ypr0/sc900776.h b/firmware/target/hosted/samsungypr/ypr0/sc900776.h new file mode 100644 index 0000000000..32eb90f797 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/sc900776.h @@ -0,0 +1,134 @@ +/* This file originates from the linux kernel provided in Samsung's YP-R0 Open + * Source package. + */ + +/* +* Bigbang project +* Copyright (c) 2009 VPS R&D Group, Samsung Electronics, Inc. +* All rights reserved. +*/ + +/** +* This file defines data structures and APIs for Freescale SC900776 +* +* @name sc900776.h +* @author Eung Chan Kim (eungchan.kim@samsung.com) +* @version 0.1 +* @see +*/ + +#ifndef __SC900776_H__ +#define __SC900776_H__ + + +typedef enum +{ + SC900776_DEVICE_ID = 0x01, /* 01h R */ + SC900776_CONTROL, /* 02h R/W */ + SC900776_INTERRUPT1, /* 03h R/C */ + SC900776_INTERRUPT2, /* 04h R/C */ + SC900776_INTERRUPT_MASK1, /* 05h R/W */ + SC900776_INTERRUPT_MASK2, /* 06h R/W */ + SC900776_ADC_RESULT, /* 07h R */ + SC900776_TIMING_SET1, /* 08h R/W */ + SC900776_TIMING_SET2, /* 09h R/W */ + SC900776_DEVICE_TYPE1, /* 0Ah R */ + SC900776_DEVICE_TYPE2, /* 0Bh R */ + SC900776_BUTTON1, /* 0Ch R/C */ + SC900776_BUTTON2, /* 0Dh R/C */ + /* 0Eh ~ 12h : reserved */ + SC900776_MANUAL_SWITCH1 = 0x13, /* 13h R/W */ + SC900776_MANUAL_SWITCH2, /* 14h R/W */ + /* 15h ~ 1Fh : reserved */ + SC900776_FSL_STATUS = 0x20, /* 20h R */ + SC900776_FSL_CONTROL, /* 21h R/W */ + SC900776_TIME_DELAY, /* 22h R/W */ + SC900776_DEVICE_MODE, /* 23h R/W */ + + SC900776_REG_MAX +} eSc900776_register_t; + +typedef enum +{ + DEVICETYPE1_UNDEFINED = 0, + DEVICETYPE1_USB, // 0x04 0x00 // normal usb cable & ad200 + DEVICETYPE1_DEDICATED, // 0x40 0x00 // dedicated charger cable + DEVICETYPE2_JIGUARTON, // 0x00 0x08 // Anygate_UART jig + DEVICETYPE2_JIGUSBOFF, // 0x00 0x01 // USB jig(AS center) + DEVICETYPE2_JIGUSBON, // 0x00 0x02 // Anygate_USB jig with boot-on, not tested +} eMinivet_device_t; + +/* + * sc900776 register bit definitions + */ +#define MINIVET_DEVICETYPE1_USBOTG 0x80 /* 1: a USBOTG device is attached */ +#define MINIVET_DEVICETYPE1_DEDICATED 0x40 /* 1: a dedicated charger is attached */ +#define MINIVET_DEVICETYPE1_USBCHG 0x20 /* 1: a USB charger is attached */ +#define MINIVET_DEVICETYPE1_5WCHG 0x10 /* 1: a 5-wire charger (type 1 or 2) is attached */ +#define MINIVET_DEVICETYPE1_UART 0x08 /* 1: a UART cable is attached */ +#define MINIVET_DEVICETYPE1_USB 0x04 /* 1: a USB host is attached */ +#define MINIVET_DEVICETYPE1_AUDIO2 0x02 /* 1: an audio accessory type 2 is attached */ +#define MINIVET_DEVICETYPE1_AUDIO1 0x01 /* 1: an audio accessory type 1 is attached */ + +#define MINIVET_DEVICETYPE2_AV 0x40 /* 1: an audio/video cable is attached */ +#define MINIVET_DEVICETYPE2_TTY 0x20 /* 1: a TTY converter is attached */ +#define MINIVET_DEVICETYPE2_PPD 0x10 /* 1: a phone powered device is attached */ +#define MINIVET_DEVICETYPE2_JIGUARTON 0x08 /* 1: a UART jig cable with the BOOT-on option is attached */ +#define MINIVET_DEVICETYPE2_JIGUARTOFF 0x04 /* 1: a UART jig cable with the BOOT-off option is attached */ +#define MINIVET_DEVICETYPE2_JIGUSBON 0x02 /* 1: a USB jig cable with the BOOT-on option is attached */ +#define MINIVET_DEVICETYPE2_JIGUSBOFF 0x01 /* 1: a USB jig cable with the BOOT-off option is attached */ + +#define MINIVET_FSLSTATUS_FETSTATUS 0x40 /* 1: The on status of the power MOSFET */ +#define MINIVET_FSLSTATUS_IDDETEND 0x20 /* 1: ID resistance detection finished */ +#define MINIVET_FSLSTATUS_VBUSDETEND 0x10 /* 1: VBUS power supply type identification completed */ +#define MINIVET_FSLSTATUS_IDGND 0x08 /* 1: ID pin is shorted to ground */ +#define MINIVET_FSLSTATUS_IDFLOAT 0x04 /* 1: ID line is floating */ +#define MINIVET_FSLSTATUS_VBUSDET 0x02 /* 1: VBUS voltage is higher than the POR */ +#define MINIVET_FSLSTATUS_ADCSTATUS 0x01 /* 1: ADC conversion completed */ + + +#define SC900776_I2C_SLAVE_ADDR 0x25 + +typedef struct { + unsigned char addr; + unsigned char value; +}__attribute__((packed)) sMinivet_t; + + +#define DRV_IOCTL_MINIVET_MAGIC 'M' + + +typedef enum +{ + E_IOCTL_MINIVET_INIT = 0, + E_IOCTL_MINIVET_WRITE_BYTE, + E_IOCTL_MINIVET_READ_BYTE, + E_IOCTL_MINIVET_DET_VBUS, + E_IOCTL_MINIVET_MANUAL_USB, + E_IOCTL_MINIVET_MANUAL_UART, + + E_IOCTL_MINIVET_MAX +} eSc900776_ioctl_t; + +#define IOCTL_MINIVET_INIT _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_INIT) +#define IOCTL_MINIVET_WRITE_BYTE _IOW(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_WRITE_BYTE, sMinivet_t) +#define IOCTL_MINIVET_READ_BYTE _IOR(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_READ_BYTE, sMinivet_t) +#define IOCTL_MINIVET_DET_VBUS _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_DET_VBUS) +#define IOCTL_MINIVET_MANUAL_USB _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_MANUAL_USB) +#define IOCTL_MINIVET_MANUAL_UART _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_MANUAL_UART) + + +#ifndef __MINIVET_ENUM__ +#define __MINIVET_ENUM__ +enum +{ + EXT_PWR_UNPLUGGED = 0, + EXT_PWR_PLUGGED, + EXT_PWR_NOT_OVP, + EXT_PWR_OVP, +}; + +#endif /* __MINIVET_ENUM__ */ + + +#endif /* __MINIVET_IOCTL_H__ */ diff --git a/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c b/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c new file mode 100644 index 0000000000..7ee2697a24 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/system-ypr0.c @@ -0,0 +1,104 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * 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 + * 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 +#include +#include +#include "system.h" +#include "panic.h" +#include "debug.h" + +#if defined(HAVE_SDL_AUDIO) || defined(HAVE_SDL_THREADS) || defined(HAVE_SDL) +#include +#endif + +#include "ascodec.h" +#include "gpio-target.h" + +void power_off(void) +{ + /* Something that we need to do before exit on our platform YPR0 */ + ascodec_close(); + gpio_close(); + exit(EXIT_SUCCESS); +} + +uintptr_t *stackbegin; +uintptr_t *stackend; +void system_init(void) +{ + int *s; + /* fake stack, OS manages size (and growth) */ + stackbegin = stackend = (uintptr_t*)&s; + +#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(); +} + + +void system_reboot(void) +{ + power_off(); +} + +void system_exception_wait(void) +{ + system_reboot(); +} + +#ifdef HAVE_ADJUSTABLE_CPU_FREQ +#include +#include "file.h" +/* This is the Linux Kernel CPU governor... */ +static void set_cpu_freq(int speed) +{ + char temp[10]; + int cpu_dev; + cpu_dev = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", O_WRONLY); + if (cpu_dev < 0) + return; + write(cpu_dev, temp, sprintf(temp, "%d", speed) + 1); + close(cpu_dev); +} + +void set_cpu_frequency(long frequency) +{ + switch (frequency) + { + case CPUFREQ_MAX: + set_cpu_freq(532000); + cpu_frequency = CPUFREQ_MAX; + break; + case CPUFREQ_NORMAL: + set_cpu_freq(400000); + cpu_frequency = CPUFREQ_NORMAL; + break; + default: + set_cpu_freq(200000); + cpu_frequency = CPUFREQ_DEFAULT; + break; + } +} +#endif diff --git a/firmware/target/hosted/samsungypr/ypr0/ypr0.make b/firmware/target/hosted/samsungypr/ypr0/ypr0.make new file mode 100644 index 0000000000..67ff326de0 --- /dev/null +++ b/firmware/target/hosted/samsungypr/ypr0/ypr0.make @@ -0,0 +1,24 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id$ +# + +INCLUDES += -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR) + +SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS) + +.SECONDEXPANSION: # $$(OBJ) is not populated until after this + +$(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) + $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \ + -L$(BUILDDIR)/firmware -lfirmware \ + -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ + -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \ + $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map + +$(BUILDDIR)/rockbox : $(BUILDDIR)/rockbox.elf + $(call PRINTS,OC $(@F))$(call objcopy,$^,$@) diff --git a/firmware/target/hosted/ypr0/adc-target.h b/firmware/target/hosted/ypr0/adc-target.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/firmware/target/hosted/ypr0/ascodec-ypr0.c b/firmware/target/hosted/ypr0/ascodec-ypr0.c deleted file mode 100644 index cc923842df..0000000000 --- a/firmware/target/hosted/ypr0/ascodec-ypr0.c +++ /dev/null @@ -1,163 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0 - * - * Copyright (c) 2011 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 "fcntl.h" -#include "unistd.h" -#include "stdio.h" -#include "string.h" -#include "sys/ioctl.h" -#include "stdlib.h" - -#include "ascodec.h" - -int afe_dev = -1; - -/* ioctl parameter struct */ -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 */ -} __attribute__((packed)); - - -/* Write to a normal register */ -#define IOCTL_REG_WRITE 0x40034101 -/* Write to a PMU register */ -#define IOCTL_SUBREG_WRITE 0x40034103 -/* Read from a normal register */ -#define IOCTL_REG_READ 0x80034102 -/* Read from a PMU register */ -#define IOCTL_SUBREG_READ 0x80034103 - - -void ascodec_init(void) -{ - afe_dev = open("/dev/afe", O_RDWR); -} - -void ascodec_close(void) -{ - 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 */ - -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); -} - -int ascodec_read(unsigned int reg) -{ - struct codec_req_struct r = { .reg = reg }; - int retval = ioctl(afe_dev, IOCTL_REG_READ, &r); - if (retval >= 0) - return r.value; - else - return retval; -} - -void ascodec_write_pmu(unsigned int index, unsigned int subreg, - unsigned int value) -{ - struct codec_req_struct r = {.reg = index, .subreg = subreg, .value = value}; - ioctl(afe_dev, IOCTL_SUBREG_WRITE, &r); -} - -int ascodec_read_pmu(unsigned int index, unsigned int subreg) -{ - struct codec_req_struct r = { .reg = index, .subreg = subreg, }; - int retval = ioctl(afe_dev, IOCTL_SUBREG_READ, &r); - if (retval >= 0) - return r.value; - else - return retval; -} - -int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data) -{ - int i, val, ret = 0; - - for (i = 0; i < (int)len; i++) - { - val = ascodec_read(i + index); - if (val >= 0) data[i] = val; - else ret = -1; - } - - return (ret ?: (int)len); -} - -/* - * NOTE: - * After the conversion to interrupts, ascodec_(lock|unlock) are only used by - * adc-as3514.c to protect against other threads corrupting the result by using - * the ADC at the same time. this adc_read() doesn't yield but blocks, so - * lock/unlock is not needed - * - * Additionally, concurrent ascodec_?(read|write) calls are instead protected - * by the R0's Kernel I2C driver for ascodec (mutexed), so it's automatically - * safe - */ - -void ascodec_lock(void) -{ -} - -void ascodec_unlock(void) -{ -} - -bool ascodec_chg_status(void) -{ - return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS; -} - -bool ascodec_endofch(void) -{ - return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH; -} - -void ascodec_monitor_endofch(void) -{ - ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH); -} - - -void ascodec_write_charger(int value) -{ - ascodec_write_pmu(AS3543_CHARGER, 1, value); -} - -int ascodec_read_charger(void) -{ - return ascodec_read_pmu(AS3543_CHARGER, 1); -} - -void ascodec_wait_adc_finished(void) -{ -} diff --git a/firmware/target/hosted/ypr0/audio-ypr0.c b/firmware/target/hosted/ypr0/audio-ypr0.c deleted file mode 100644 index dfd63ef5cd..0000000000 --- a/firmware/target/hosted/ypr0/audio-ypr0.c +++ /dev/null @@ -1,69 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2009 by Bertrik Sikken - * - * 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 "cpu.h" -#include "audio.h" -#include "audiohw.h" -#include "sound.h" - -int audio_channels = 2; -int audio_output_source = AUDIO_SRC_PLAYBACK; - -void audio_set_output_source(int source) -{ - if ((unsigned)source >= AUDIO_NUM_SOURCES) - source = AUDIO_SRC_PLAYBACK; - - audio_output_source = source; -} /* audio_set_output_source */ - -void audio_input_mux(int source, unsigned flags) -{ - static int last_source = AUDIO_SRC_PLAYBACK; - - (void)flags; - - switch (source) - { - default: /* playback - no recording */ - source = AUDIO_SRC_PLAYBACK; - case AUDIO_SRC_PLAYBACK: - audio_channels = 2; - if (source != last_source) - { - audiohw_set_monitor(false); - - } - break; - - case AUDIO_SRC_FMRADIO: /* recording and playback */ - audio_channels = 2; - if (source == last_source) - break; - - audiohw_set_monitor(true); - break; - } /* end switch */ - - last_source = source; -} /* audio_input_mux */ - diff --git a/firmware/target/hosted/ypr0/backlight-target.h b/firmware/target/hosted/ypr0/backlight-target.h deleted file mode 100644 index 561e159e8c..0000000000 --- a/firmware/target/hosted/ypr0/backlight-target.h +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: backlight-target.h 19322 2008-12-04 04:16:53Z jethead71 $ - * - * Copyright (C) 2011 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/hosted/ypr0/backlight-ypr0.c b/firmware/target/hosted/ypr0/backlight-ypr0.c deleted file mode 100644 index 551b386f19..0000000000 --- a/firmware/target/hosted/ypr0/backlight-ypr0.c +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2011 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 "backlight.h" -#include "backlight-target.h" -#include "lcd.h" -#include "as3514.h" -#include "ascodec.h" -#include -#include "unistd.h" - -static bool backlight_on_status = true; /* Is on or off? */ - -/*TODO: see if LCD sleep could be implemented in a better way -> ie using a rockbox feature */ -/* Turn off LCD power supply */ -static void _backlight_lcd_sleep(void) -{ - int fp = open("/sys/class/graphics/fb0/blank", O_RDWR); - write(fp, "1", 1); - close(fp); -} -/* Turn on LCD screen */ -static void _backlight_lcd_power(void) -{ - int fp = open("/sys/class/graphics/fb0/blank", O_RDWR); - write(fp, "0", 1); - close(fp); -} - -bool _backlight_init(void) -{ - /* We have nothing to do */ - return true; -} - -void _backlight_on(void) -{ - if (!backlight_on_status) - { - /* Turn on lcd power before backlight */ - _backlight_lcd_power(); - /* Original app sets this to 0xb1 when backlight is on... */ - ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0xb1); - } - - backlight_on_status = true; - -} - -void _backlight_off(void) -{ - if (backlight_on_status) { - /* Disabling the DCDC15 completely, keeps brightness register value */ - ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0x00); - /* Turn off lcd power then */ - _backlight_lcd_sleep(); - } - - backlight_on_status = false; -} - -void _backlight_set_brightness(int brightness) -{ - /* Just another check... */ - if (brightness > MAX_BRIGHTNESS_SETTING) - brightness = MAX_BRIGHTNESS_SETTING; - if (brightness < MIN_BRIGHTNESS_SETTING) - brightness = MIN_BRIGHTNESS_SETTING; - ascodec_write_pmu(AS3543_BACKLIGHT, 0x3, brightness << 3 & 0xf8); -} diff --git a/firmware/target/hosted/ypr0/button-target.h b/firmware/target/hosted/ypr0/button-target.h deleted file mode 100644 index 3a3866932a..0000000000 --- a/firmware/target/hosted/ypr0/button-target.h +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2011 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_ - -void button_close_device(void); - -/* Logical buttons key codes */ -#define BUTTON_UP 0x00000001 -#define BUTTON_DOWN 0x00000002 -#define BUTTON_LEFT 0x00000004 -#define BUTTON_RIGHT 0x00000008 -#define BUTTON_USER 0x00000010 -#define BUTTON_MENU 0x00000020 -#define BUTTON_BACK 0x00000040 -#define BUTTON_POWER 0x00000080 -#define BUTTON_SELECT 0x00000100 - -#define BUTTON_MAIN (BUTTON_UP|BUTTON_DOWN|BUTTON_LEFT|BUTTON_RIGHT|BUTTON_USER|BUTTON_MENU|BUTTON_BACK|BUTTON_POWER|BUTTON_SELECT) /* all buttons */ - -/* Software power-off */ -#define POWEROFF_BUTTON BUTTON_POWER -/* About 3 seconds */ -#define POWEROFF_COUNT 10 - -#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/hosted/ypr0/button-ypr0.c b/firmware/target/hosted/ypr0/button-ypr0.c deleted file mode 100644 index e66ca22737..0000000000 --- a/firmware/target/hosted/ypr0/button-ypr0.c +++ /dev/null @@ -1,87 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: button-sdl.c 30482 2011-09-08 14:53:28Z kugel $ - * - * Copyright (C) 2011 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 "button.h" -#include "kernel.h" -#include "system.h" -#include "button-target.h" -#include /* For headphones sense and buttons */ - -int button_read_device(void) -{ - int key = BUTTON_NONE; - - /* Check for all the keys */ - if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_USER_KEY, 0, 0)) { - key |= BUTTON_USER; - } - if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_CENTRAL_KEY, 0, 0)) { - key |= BUTTON_SELECT; - } - if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_UP_KEY, 0, 0)) { - key |= BUTTON_UP; - } - if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_DOWN_KEY, 0, 0)) { - key |= BUTTON_DOWN; - } - if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_LEFT_KEY, 0, 0)) { - key |= BUTTON_LEFT; - } - if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_RIGHT_KEY, 0, 0)) { - key |= BUTTON_RIGHT; - } - if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_MENU_KEY, 0, 0)) { - key |= BUTTON_MENU; - } - if (!gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_BACK_KEY, 0, 0)) { - key |= BUTTON_BACK; - } - if (gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_POWER_KEY, 0, 0)) { - key |= BUTTON_POWER; - } - - return key; -} - -bool headphones_inserted(void) -{ - /* GPIO low - 0 - means headphones inserted */ - return !gpio_control(DEV_CTRL_GPIO_IS_HIGH, GPIO_HEADPHONE_SENSE, 0, 0); -} - -void button_init_device(void) -{ - /* Setup GPIO pin for headphone sense, copied from OF */ - gpio_control(DEV_CTRL_GPIO_SET_MUX, GPIO_HEADPHONE_SENSE, CONFIG_SION, PAD_CTL_47K_PU); - gpio_control(DEV_CTRL_GPIO_SET_INPUT, GPIO_HEADPHONE_SENSE, CONFIG_SION, PAD_CTL_47K_PU); - - /* No need to initialize any GPIO pin, since this is done loading the r0Btn module */ -} - -#ifdef BUTTON_DRIVER_CLOSE -/* I'm not sure it's called at shutdown...give a check! */ -void button_close_device(void) -{ - /* Don't know the precise meaning, but it's done as in the OF, so copied there */ - gpio_control(DEV_CTRL_GPIO_UNSET_MUX, GPIO_HEADPHONE_SENSE, CONFIG_SION, 0); -} -#endif /* BUTTON_DRIVER_CLOSE */ diff --git a/firmware/target/hosted/ypr0/dir-target.h b/firmware/target/hosted/ypr0/dir-target.h deleted file mode 100644 index 7df9554e92..0000000000 --- a/firmware/target/hosted/ypr0/dir-target.h +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 by Thomas Martitz - * - * 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 __DIR_TARGET_H__ -#define __DIR_TARGET_H__ - -#include -/* including unistd.h is too noisy */ -extern int rmdir(const char* name); - - -#define dirent_uncached dirent -#define DIR_UNCACHED DIR -#define opendir_uncached _opendir -#define readdir_uncached _readdir -#define closedir_uncached _closedir -#define mkdir_uncached _mkdir -#define rmdir_uncached rmdir - -extern DIR* _opendir(const char* name); -extern int _mkdir(const char* name); -extern int _rmdir(const char* name); -extern int _closedir(DIR* dir); -extern struct dirent *_readdir(DIR* dir); -extern void fat_size(unsigned long *size, unsigned long *free); - -#define DIRFUNCTIONS_DEFINED -#define DIRENT_DEFINED -#define DIR_DEFINED - -#endif /* __DIR_TARGET_H__ */ diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.c b/firmware/target/hosted/ypr0/gpio_ypr0.c deleted file mode 100644 index 3ee371d562..0000000000 --- a/firmware/target/hosted/ypr0/gpio_ypr0.c +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 - * - * Copyright (c) 2011 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 -#include -#include -#include /* includes r0GPIOioctl.h */ -#include - -static int r0_gpio_dev = 0; - -void gpio_init(void) -{ - r0_gpio_dev = open("/dev/r0GPIO", O_RDONLY); - if (r0_gpio_dev < 0) - printf("/dev/r0GPIO open error!"); -} - -void gpio_close(void) -{ - if (r0_gpio_dev < 0) - close(r0_gpio_dev); -} - -int gpio_control_struct(int request, R0GPIOInfo r) -{ - return ioctl(r0_gpio_dev, request, &r); -} - -int gpio_control(int request, int num, int mode, int val) -{ - R0GPIOInfo r = { .num = num, .mode = mode, .val = val, }; - return ioctl(r0_gpio_dev, request, &r); -} diff --git a/firmware/target/hosted/ypr0/gpio_ypr0.h b/firmware/target/hosted/ypr0/gpio_ypr0.h deleted file mode 100644 index 3c2033baff..0000000000 --- a/firmware/target/hosted/ypr0/gpio_ypr0.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Module wrapper for GPIO, using /dev/r0GPIO (r0Gpio.ko) of Samsung YP-R0 - * - * Copyright (c) 2011 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 GPIO_YPR0_H -#define GPIO_YPR0_H - -#include "r0GPIOIoctl.h" - -/* Some meaningful pins used in the R0 */ - -#define GPIO_HEADPHONE_SENSE GPIO1_5 -#define GPIO_EXT_PWR_SENSE GPIO1_26 -#define GPIO_SD_SENSE GPIO2_27 -#define GPIO_AS3543_INTERUPT GPIO1_25 -#define GPIO_PCB_VER_DETECT GPIO_10 -/* I2C bus for AS3543 codec */ -#define GPIO_I2C_CLK0 GPIO_1_0 -#define GPIO_I2C_DAT0 GPIO_1_1 -/* I2C bus for the SI4079 FM radio chip */ -#define GPIO_I2C_CLK1 GPIO_2_12 -#define GPIO_I2C_DAT1 GPIO_2_13 -#define GPIO_FM_SEARCH GPIO1_4 -#define GPIO_FM_BUS_EN GPIO2_19 - -/* Keypad */ - -#define GPIO_BACK_KEY GPIO2_29 -#define GPIO_USER_KEY GPIO2_30 -#define GPIO_MENU_KEY GPIO2_31 -#define GPIO_POWER_KEY GPIO2_16 -#define GPIO_CENTRAL_KEY GPIO3_5 -#define GPIO_UP_KEY GPIO3_9 -#define GPIO_DOWN_KEY GPIO3_8 -#define GPIO_LEFT_KEY GPIO2_28 -#define GPIO_RIGHT_KEY GPIO3_7 - - -void gpio_init(void); -void gpio_close(void); -int gpio_control_struct(int request, R0GPIOInfo pin); -int gpio_control(int request, int num, int mode, int val); - -#endif diff --git a/firmware/target/hosted/ypr0/lcd-target.h b/firmware/target/hosted/ypr0/lcd-target.h deleted file mode 100644 index c8a6de74f9..0000000000 --- a/firmware/target/hosted/ypr0/lcd-target.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * 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__ - -extern fb_data *dev_fb; -#define LCD_FRAMEBUF_ADDR(col, row) (dev_fb + row*LCD_WIDTH + col) - -#endif diff --git a/firmware/target/hosted/ypr0/lcd-ypr0.c b/firmware/target/hosted/ypr0/lcd-ypr0.c deleted file mode 100644 index 40528c298a..0000000000 --- a/firmware/target/hosted/ypr0/lcd-ypr0.c +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $ - * - * Copyright (C) 2011 Lorenzo Miori, Thomas Martitz - * - * 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 -#include -#include -#include "string.h" -#include -#include -#include - -#include "file.h" -#include "debug.h" -#include "system.h" -#include "screendump.h" -#include "lcd.h" - -static int dev_fd = 0; -fb_data *dev_fb = 0; - -void lcd_shutdown(void) -{ - printf("FB closed."); - munmap(dev_fb, FRAMEBUFFER_SIZE); - close(dev_fd); -} - -void lcd_init_device(void) -{ - size_t screensize; - struct fb_var_screeninfo vinfo; - struct fb_fix_screeninfo finfo; - - /* Open the framebuffer device */ - dev_fd = open("/dev/fb0", O_RDWR); - if (dev_fd == -1) { - perror("Error: cannot open framebuffer device"); - exit(1); - } - printf("The framebuffer device was opened successfully.\n"); - - /* Get the fixed properties */ - if (ioctl(dev_fd, FBIOGET_FSCREENINFO, &finfo) == -1) { - perror("Error reading fixed information"); - exit(2); - } - - /* Now we get the settable settings, and we set 16 bit bpp */ - if (ioctl(dev_fd, FBIOGET_VSCREENINFO, &vinfo) == -1) { - perror("Error reading variable information"); - exit(3); - } - - vinfo.bits_per_pixel = 16; - - if (ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo)) { - perror("fbset(ioctl)"); - exit(4); - } - - printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel); - - /* Figure out the size of the screen in bytes */ - screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; - if (screensize != FRAMEBUFFER_SIZE) - { - exit(4); - perror("Display and framebuffer mismatch!\n"); - } - - /* Map the device to memory */ - dev_fb = mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, dev_fd, 0); - if ((int)dev_fb == -1) { - perror("Error: failed to map framebuffer device to memory"); - exit(4); - } - printf("The framebuffer device was mapped to memory successfully.\n"); -} diff --git a/firmware/target/hosted/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/ypr0/powermgmt-ypr0.c deleted file mode 100644 index 347e5fa146..0000000000 --- a/firmware/target/hosted/ypr0/powermgmt-ypr0.c +++ /dev/null @@ -1,108 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * 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 - * 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 -#include "kernel.h" -#include "powermgmt.h" -#include "power.h" -#include "file.h" -#include "adc.h" -#include "sc900776.h" -#include "radio-ypr0.h" - -const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = -{ - 3470 -}; - -/* the OF shuts down at this voltage */ -const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = -{ - 3450 -}; - -/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ -const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = -{ - { 3450, 3502, 3550, 3587, 3623, 3669, 3742, 3836, 3926, 4026, 4200 } -}; - -#if CONFIG_CHARGING -/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ -const unsigned short const percent_to_volt_charge[11] = -{ - 3450, 3670, 3721, 3751, 3782, 3821, 3876, 3941, 4034, 4125, 4200 -}; - -unsigned int power_input_status(void) -{ - unsigned status = POWER_INPUT_NONE; - int fd = open("/dev/minivet", O_RDONLY); - if (fd >= 0) - { - if (ioctl(fd, IOCTL_MINIVET_DET_VBUS, NULL) > 0) - status = POWER_INPUT_MAIN_CHARGER; - close(fd); - } - return status; -} - -#endif /* CONFIG_CHARGING */ - - -/* Returns battery voltage from ADC [millivolts], - * adc returns voltage in 5mV steps */ -int _battery_voltage(void) -{ - return adc_read(3) * 5; -} - -bool charging_state(void) -{ - const unsigned short charged_thres = 4170; - bool ret = (power_input_status() == POWER_INPUT_MAIN_CHARGER); - /* dont indicate for > ~95% */ - return ret && (_battery_voltage() <= charged_thres); -} - -#if CONFIG_TUNER -static bool tuner_on = false; - -bool tuner_power(bool status) -{ - if (status != tuner_on) - { - tuner_on = status; - status = !status; - if (tuner_on) { - radiodev_open(); - } - else { - radiodev_close(); - } - } - - return status; -} - -bool tuner_powered(void) -{ - return tuner_on; -} -#endif /* #if CONFIG_TUNER */ \ No newline at end of file diff --git a/firmware/target/hosted/ypr0/r0GPIOIoctl.h b/firmware/target/hosted/ypr0/r0GPIOIoctl.h deleted file mode 100644 index e77f35fbb7..0000000000 --- a/firmware/target/hosted/ypr0/r0GPIOIoctl.h +++ /dev/null @@ -1,185 +0,0 @@ -/* This file originates from the linux kernel provided in Samsung's YP-R0 Open - * Source package (second release, which includes some driver modules sources). - */ - -#ifndef __IOCTL_GPIO_H__ -#define __IOCTL_GPIO_H__ - -#include -//#include "iomux.h" - -typedef struct { - int num; - int mode; - int val; -}__attribute__((packed)) R0GPIOInfo; - - -#define IOCTL_GPIO_MAGIC 'G' - -#define E_IOCTL_GPIO_SET_MUX 0 -#define E_IOCTL_GPIO_UNSET_MUX 1 -#define E_IOCTL_GPIO_SET_TYPE 2 -#define E_IOCTL_GPIO_SET_OUTPUT 3 -#define E_IOCTL_GPIO_SET_INPUT 4 -#define E_IOCTL_GPIO_SET_HIGH 5 -#define E_IOCTL_GPIO_SET_LOW 6 -#define E_IOCTL_GPIO_GET_VAL 7 -#define E_IOCTL_GPIO_IS_HIGH 8 -#define E_IOCTL_GPIO_MAX_NR 9 - -#define DEV_CTRL_GPIO_SET_MUX _IOW(IOCTL_GPIO_MAGIC, 0, R0GPIOInfo) -#define DEV_CTRL_GPIO_UNSET_MUX _IOW(IOCTL_GPIO_MAGIC, 1, R0GPIOInfo) -#define DEV_CTRL_GPIO_SET_TYPE _IOW(IOCTL_GPIO_MAGIC, 2, R0GPIOInfo) -#define DEV_CTRL_GPIO_SET_OUTPUT _IOW(IOCTL_GPIO_MAGIC, 3, R0GPIOInfo) -#define DEV_CTRL_GPIO_SET_INPUT _IOW(IOCTL_GPIO_MAGIC, 4, R0GPIOInfo) -#define DEV_CTRL_GPIO_SET_HIGH _IOW(IOCTL_GPIO_MAGIC, 5, R0GPIOInfo) -#define DEV_CTRL_GPIO_SET_LOW _IOW(IOCTL_GPIO_MAGIC, 6, R0GPIOInfo) -#define DEV_CTRL_GPIO_GET_VAL _IOW(IOCTL_GPIO_MAGIC, 7, R0GPIOInfo) -#define DEV_CTRL_GPIO_IS_HIGH _IOW(IOCTL_GPIO_MAGIC, 8, R0GPIOInfo) - - -typedef enum -{ - GPIO1_0 = 0, /* GPIO group 1 start */ - GPIO1_1, - GPIO1_2, - GPIO1_3, - GPIO1_4, - GPIO1_5, - GPIO1_6, - GPIO1_7, - GPIO1_8, - GPIO1_9, - GPIO1_10, - GPIO1_11, - GPIO1_12, - GPIO1_13, - GPIO1_14, - GPIO1_15, - GPIO1_16, - GPIO1_17, - GPIO1_18, - GPIO1_19, - GPIO1_20, - GPIO1_21, - GPIO1_22, - GPIO1_23, - GPIO1_24, - GPIO1_25, - GPIO1_26, - GPIO1_27, - GPIO1_28, - GPIO1_29, - GPIO1_30, - GPIO1_31, - GPIO2_0, /* GPIO group 2 start */ - GPIO2_1, - GPIO2_2, - GPIO2_3, - GPIO2_4, - GPIO2_5, - GPIO2_6, - GPIO2_7, - GPIO2_8, - GPIO2_9, - GPIO2_10, - GPIO2_11, - GPIO2_12, - GPIO2_13, - GPIO2_14, - GPIO2_15, - GPIO2_16, - GPIO2_17, - GPIO2_18, - GPIO2_19, - GPIO2_20, - GPIO2_21, - GPIO2_22, - GPIO2_23, - GPIO2_24, - GPIO2_25, - GPIO2_26, - GPIO2_27, - GPIO2_28, - GPIO2_29, - GPIO2_30, - GPIO2_31, - GPIO3_0, /* GPIO group 3 start */ - GPIO3_1, - GPIO3_2, - GPIO3_3, - GPIO3_4, - GPIO3_5, - GPIO3_6, - GPIO3_7, - GPIO3_8, - GPIO3_9, - GPIO3_10, - GPIO3_11, - GPIO3_12, - GPIO3_13, - GPIO3_14, - GPIO3_15, - GPIO3_16, - GPIO3_17, - GPIO3_18, - GPIO3_19, - GPIO3_20, - GPIO3_21, - GPIO3_22, - GPIO3_23, - GPIO3_24, - GPIO3_25, - GPIO3_26, - GPIO3_27, - GPIO3_28, - GPIO3_29, - GPIO3_30, - GPIO3_31, -}R0_MX37_GPIO; - -typedef enum -{ - CONFIG_ALT0, - CONFIG_ALT1, - CONFIG_ALT2, - CONFIG_ALT3, - CONFIG_ALT4, - CONFIG_ALT5, - CONFIG_ALT6, - CONFIG_ALT7, - CONFIG_GPIO, - CONFIG_SION = 0x01 << 4, - CONFIG_DEFAULT -} R0_MX37_PIN_CONFIG; - -#ifndef __MACH_MX37_IOMUX_H__ -typedef enum -{ - PAD_CTL_SRE_SLOW = 0x0 << 0, - PAD_CTL_SRE_FAST = 0x1 << 0, - PAD_CTL_DRV_LOW = 0x0 << 1, - PAD_CTL_DRV_MEDIUM = 0x1 << 1, - PAD_CTL_DRV_HIGH = 0x2 << 1, - PAD_CTL_DRV_MAX = 0x3 << 1, - PAD_CTL_ODE_OPENDRAIN_NONE = 0x0 << 3, - PAD_CTL_ODE_OPENDRAIN_ENABLE = 0x1 << 3, - PAD_CTL_100K_PD = 0x0 << 4, - PAD_CTL_47K_PU = 0x1 << 4, - PAD_CTL_100K_PU = 0x2 << 4, - PAD_CTL_22K_PU = 0x3 << 4, - PAD_CTL_PUE_KEEPER = 0x0 << 6, - PAD_CTL_PUE_PULL = 0x1 << 6, - PAD_CTL_PKE_NONE = 0x0 << 7, - PAD_CTL_PKE_ENABLE = 0x1 << 7, - PAD_CTL_HYS_NONE = 0x0 << 8, - PAD_CTL_HYS_ENABLE = 0x1 << 8, - PAD_CTL_DDR_INPUT_CMOS = 0x0 << 9, - PAD_CTL_DDR_INPUT_DDR = 0x1 << 9, - PAD_CTL_DRV_VOT_LOW = 0x0 << 13, - PAD_CTL_DRV_VOT_HIGH = 0x1 << 13, -} R0_MX37_PAD_CONFIG; -#endif - -#endif /* __IOCTL_GPIO__H__ */ diff --git a/firmware/target/hosted/ypr0/radio-ypr0.c b/firmware/target/hosted/ypr0/radio-ypr0.c deleted file mode 100644 index 14d56826c1..0000000000 --- a/firmware/target/hosted/ypr0/radio-ypr0.c +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Module wrapper for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko) of Samsung YP-R0 - * - * Copyright (c) 2012 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 -#include -#include -#include "stdint.h" -#include "string.h" -#include "kernel.h" - -#include "radio-ypr0.h" -#include "rds.h" -#include "si4700.h" -#include "power.h" - -static int radio_dev = -1; - -void radiodev_open(void) { - radio_dev = open("/dev/si470x", O_RDWR); -} - -void radiodev_close(void) { - close(radio_dev); -} - -/* High-level registers access */ -void si4709_write_reg(int addr, uint16_t value) { - sSi4709_t r = { .addr = addr, .value = value }; - ioctl(radio_dev, IOCTL_SI4709_WRITE_BYTE, &r); -} - -uint16_t si4709_read_reg(int addr) { - sSi4709_t r = { .addr = addr, .value = 0 }; - ioctl(radio_dev, IOCTL_SI4709_READ_BYTE, &r); - return r.value; -} - -/* Low-level i2c channel access */ -int fmradio_i2c_write(unsigned char address, unsigned char* buf, int count) -{ - (void)address; - sSi4709_i2c_t r = { .size = count, .buf = buf }; - return ioctl(radio_dev, IOCTL_SI4709_I2C_WRITE, &r); -} - -int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count) -{ - (void)address; - sSi4709_i2c_t r = { .size = count, .buf = buf }; - return ioctl(radio_dev, IOCTL_SI4709_I2C_READ, &r); -} - -#ifdef HAVE_RDS_CAP - -/* Register we are going to poll */ -#define STATUSRSSI 0xA -#define STATUSRSSI_RDSR (0x1 << 15) - -/* Low-level RDS Support */ -static struct event_queue rds_queue; -static uint32_t rds_stack[DEFAULT_STACK_SIZE / sizeof(uint32_t)]; -static uint16_t rds_data[4]; - -enum { - Q_POWERUP, -}; - -static void NORETURN_ATTR rds_thread(void) -{ - /* start up frozen */ - int timeout = TIMEOUT_BLOCK; - struct queue_event ev; - - while (true) { - queue_wait_w_tmo(&rds_queue, &ev, timeout); - switch (ev.id) { - case Q_POWERUP: - /* power up: timeout after 1 tick, else block indefinitely */ - timeout = ev.data ? 1 : TIMEOUT_BLOCK; - break; - case SYS_TIMEOUT: - /* Captures RDS data and processes it */ - if ((si4709_read_reg(STATUSRSSI) & STATUSRSSI_RDSR) >> 8) { - if (si4700_rds_read_raw(rds_data) && rds_process(rds_data)) - si4700_rds_set_event(); - } - break; - } - } -} - -/* true after full radio power up, and false before powering down */ -void si4700_rds_powerup(bool on) -{ - queue_post(&rds_queue, Q_POWERUP, on); -} - -/* One-time RDS init at startup */ -void si4700_rds_init(void) -{ - queue_init(&rds_queue, false); - create_thread(rds_thread, rds_stack, sizeof(rds_stack), 0, "rds" - IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU)); - rds_init(); -} -#endif /* HAVE_RDS_CAP */ diff --git a/firmware/target/hosted/ypr0/radio-ypr0.h b/firmware/target/hosted/ypr0/radio-ypr0.h deleted file mode 100644 index 13bcb6dc72..0000000000 --- a/firmware/target/hosted/ypr0/radio-ypr0.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Module wrapper for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko) of Samsung YP-R0 - * - * Copyright (c) 2012 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 __RADIO_YPR0_H__ -#define __RADIO_YPR0_H__ - -#include "si4709.h" -#include "stdint.h" -#include "rds.h" -#include "si4700.h" - -void radiodev_open(void); -void radiodev_close(void); -void si4709_write_reg(int addr, uint16_t value); -uint16_t si4709_read_reg(int addr); - -#endif /*__RADIO-YPR0_H__*/ \ No newline at end of file diff --git a/firmware/target/hosted/ypr0/sc900776.h b/firmware/target/hosted/ypr0/sc900776.h deleted file mode 100644 index 32eb90f797..0000000000 --- a/firmware/target/hosted/ypr0/sc900776.h +++ /dev/null @@ -1,134 +0,0 @@ -/* This file originates from the linux kernel provided in Samsung's YP-R0 Open - * Source package. - */ - -/* -* Bigbang project -* Copyright (c) 2009 VPS R&D Group, Samsung Electronics, Inc. -* All rights reserved. -*/ - -/** -* This file defines data structures and APIs for Freescale SC900776 -* -* @name sc900776.h -* @author Eung Chan Kim (eungchan.kim@samsung.com) -* @version 0.1 -* @see -*/ - -#ifndef __SC900776_H__ -#define __SC900776_H__ - - -typedef enum -{ - SC900776_DEVICE_ID = 0x01, /* 01h R */ - SC900776_CONTROL, /* 02h R/W */ - SC900776_INTERRUPT1, /* 03h R/C */ - SC900776_INTERRUPT2, /* 04h R/C */ - SC900776_INTERRUPT_MASK1, /* 05h R/W */ - SC900776_INTERRUPT_MASK2, /* 06h R/W */ - SC900776_ADC_RESULT, /* 07h R */ - SC900776_TIMING_SET1, /* 08h R/W */ - SC900776_TIMING_SET2, /* 09h R/W */ - SC900776_DEVICE_TYPE1, /* 0Ah R */ - SC900776_DEVICE_TYPE2, /* 0Bh R */ - SC900776_BUTTON1, /* 0Ch R/C */ - SC900776_BUTTON2, /* 0Dh R/C */ - /* 0Eh ~ 12h : reserved */ - SC900776_MANUAL_SWITCH1 = 0x13, /* 13h R/W */ - SC900776_MANUAL_SWITCH2, /* 14h R/W */ - /* 15h ~ 1Fh : reserved */ - SC900776_FSL_STATUS = 0x20, /* 20h R */ - SC900776_FSL_CONTROL, /* 21h R/W */ - SC900776_TIME_DELAY, /* 22h R/W */ - SC900776_DEVICE_MODE, /* 23h R/W */ - - SC900776_REG_MAX -} eSc900776_register_t; - -typedef enum -{ - DEVICETYPE1_UNDEFINED = 0, - DEVICETYPE1_USB, // 0x04 0x00 // normal usb cable & ad200 - DEVICETYPE1_DEDICATED, // 0x40 0x00 // dedicated charger cable - DEVICETYPE2_JIGUARTON, // 0x00 0x08 // Anygate_UART jig - DEVICETYPE2_JIGUSBOFF, // 0x00 0x01 // USB jig(AS center) - DEVICETYPE2_JIGUSBON, // 0x00 0x02 // Anygate_USB jig with boot-on, not tested -} eMinivet_device_t; - -/* - * sc900776 register bit definitions - */ -#define MINIVET_DEVICETYPE1_USBOTG 0x80 /* 1: a USBOTG device is attached */ -#define MINIVET_DEVICETYPE1_DEDICATED 0x40 /* 1: a dedicated charger is attached */ -#define MINIVET_DEVICETYPE1_USBCHG 0x20 /* 1: a USB charger is attached */ -#define MINIVET_DEVICETYPE1_5WCHG 0x10 /* 1: a 5-wire charger (type 1 or 2) is attached */ -#define MINIVET_DEVICETYPE1_UART 0x08 /* 1: a UART cable is attached */ -#define MINIVET_DEVICETYPE1_USB 0x04 /* 1: a USB host is attached */ -#define MINIVET_DEVICETYPE1_AUDIO2 0x02 /* 1: an audio accessory type 2 is attached */ -#define MINIVET_DEVICETYPE1_AUDIO1 0x01 /* 1: an audio accessory type 1 is attached */ - -#define MINIVET_DEVICETYPE2_AV 0x40 /* 1: an audio/video cable is attached */ -#define MINIVET_DEVICETYPE2_TTY 0x20 /* 1: a TTY converter is attached */ -#define MINIVET_DEVICETYPE2_PPD 0x10 /* 1: a phone powered device is attached */ -#define MINIVET_DEVICETYPE2_JIGUARTON 0x08 /* 1: a UART jig cable with the BOOT-on option is attached */ -#define MINIVET_DEVICETYPE2_JIGUARTOFF 0x04 /* 1: a UART jig cable with the BOOT-off option is attached */ -#define MINIVET_DEVICETYPE2_JIGUSBON 0x02 /* 1: a USB jig cable with the BOOT-on option is attached */ -#define MINIVET_DEVICETYPE2_JIGUSBOFF 0x01 /* 1: a USB jig cable with the BOOT-off option is attached */ - -#define MINIVET_FSLSTATUS_FETSTATUS 0x40 /* 1: The on status of the power MOSFET */ -#define MINIVET_FSLSTATUS_IDDETEND 0x20 /* 1: ID resistance detection finished */ -#define MINIVET_FSLSTATUS_VBUSDETEND 0x10 /* 1: VBUS power supply type identification completed */ -#define MINIVET_FSLSTATUS_IDGND 0x08 /* 1: ID pin is shorted to ground */ -#define MINIVET_FSLSTATUS_IDFLOAT 0x04 /* 1: ID line is floating */ -#define MINIVET_FSLSTATUS_VBUSDET 0x02 /* 1: VBUS voltage is higher than the POR */ -#define MINIVET_FSLSTATUS_ADCSTATUS 0x01 /* 1: ADC conversion completed */ - - -#define SC900776_I2C_SLAVE_ADDR 0x25 - -typedef struct { - unsigned char addr; - unsigned char value; -}__attribute__((packed)) sMinivet_t; - - -#define DRV_IOCTL_MINIVET_MAGIC 'M' - - -typedef enum -{ - E_IOCTL_MINIVET_INIT = 0, - E_IOCTL_MINIVET_WRITE_BYTE, - E_IOCTL_MINIVET_READ_BYTE, - E_IOCTL_MINIVET_DET_VBUS, - E_IOCTL_MINIVET_MANUAL_USB, - E_IOCTL_MINIVET_MANUAL_UART, - - E_IOCTL_MINIVET_MAX -} eSc900776_ioctl_t; - -#define IOCTL_MINIVET_INIT _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_INIT) -#define IOCTL_MINIVET_WRITE_BYTE _IOW(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_WRITE_BYTE, sMinivet_t) -#define IOCTL_MINIVET_READ_BYTE _IOR(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_READ_BYTE, sMinivet_t) -#define IOCTL_MINIVET_DET_VBUS _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_DET_VBUS) -#define IOCTL_MINIVET_MANUAL_USB _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_MANUAL_USB) -#define IOCTL_MINIVET_MANUAL_UART _IO(DRV_IOCTL_MINIVET_MAGIC, E_IOCTL_MINIVET_MANUAL_UART) - - -#ifndef __MINIVET_ENUM__ -#define __MINIVET_ENUM__ -enum -{ - EXT_PWR_UNPLUGGED = 0, - EXT_PWR_PLUGGED, - EXT_PWR_NOT_OVP, - EXT_PWR_OVP, -}; - -#endif /* __MINIVET_ENUM__ */ - - -#endif /* __MINIVET_IOCTL_H__ */ diff --git a/firmware/target/hosted/ypr0/si4709.h b/firmware/target/hosted/ypr0/si4709.h deleted file mode 100644 index c27472e856..0000000000 --- a/firmware/target/hosted/ypr0/si4709.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Module header for SI4709 FM Radio Chip, using /dev/si470x (si4709.ko) of Samsung YP-R0 - * - * Copyright (c) 2012 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 __SI4709_H__ -#define __SI4709_H__ - -#include "stdint.h" - -/* 7bits I2C address */ -#define SI4709_I2C_SLAVE_ADDR 0x10 - -#define SI4702_DEVICEID 0x00 -#define SI4702_CHIPID 0x01 -#define SI4702_POWERCFG 0x02 -#define SI4702_CHANNEL 0x03 -#define SI4702_SYSCONFIG1 0x04 -#define SI4702_SYSCONFIG2 0x05 -#define SI4702_SYSCONFIG3 0x06 -#define SI4702_TEST1 0x07 -#define SI4702_TEST2 0x08 -#define SI4702_B00TCONFIG 0x09 -#define SI4702_STATUSRSSI 0x0A -#define SI4702_READCHAN 0x0B -#define SI4709_REG_NUM 0x10 -#define SI4702_REG_BYTE (SI4709_REG_NUM * 2) -#define SI4702_DEVICE_ID 0x1242 -#define SI4702_RW_REG_NUM (SI4702_STATUSRSSI - SI4702_POWERCFG) -#define SI4702_RW_OFFSET \ - (SI4709_REG_NUM - SI4702_STATUSRSSI + SI4702_POWERCFG) -#define BYTE_TO_WORD(hi, lo) (((hi) << 8) & 0xFF00) | ((lo) & 0x00FF) - -typedef struct { - int addr; - uint16_t value; -}__attribute__((packed)) sSi4709_t; - -typedef struct { - int size; - unsigned char *buf; -}__attribute__((packed)) sSi4709_i2c_t; - -typedef enum -{ - IOCTL_SI4709_INIT = 0, - IOCTL_SI4709_CLOSE, - IOCTL_SI4709_WRITE_BYTE, - IOCTL_SI4709_READ_BYTE, - IOCTL_SI4709_I2C_WRITE, - IOCTL_SI4709_I2C_READ, - - E_IOCTL_SI4709_MAX -} eSi4709_ioctl_t; - -#define DRV_IOCTL_SI4709_MAGIC 'S' - -#define IOCTL_SI4709_INIT _IO(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_INIT) -#define IOCTL_SI4709_CLOSE _IO(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_CLOSE) -#define IOCTL_SI4709_WRITE_BYTE _IOW(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_WRITE_BYTE, sSi4709_t) -#define IOCTL_SI4709_READ_BYTE _IOR(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_READ_BYTE, sSi4709_t) -#define IOCTL_SI4709_I2C_WRITE _IOW(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_I2C_WRITE, sSi4709_i2c_t) -#define IOCTL_SI4709_I2C_READ _IOR(DRV_IOCTL_SI4709_MAGIC, IOCTL_SI4709_I2C_READ, sSi4709_i2c_t) - -#endif /* __SI4709_H__ */ \ No newline at end of file diff --git a/firmware/target/hosted/ypr0/system-target.h b/firmware/target/hosted/ypr0/system-target.h deleted file mode 100644 index 1ef8b9aeda..0000000000 --- a/firmware/target/hosted/ypr0/system-target.h +++ /dev/null @@ -1,28 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2010 by Thomas Martitz - * - * 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 __SYSTEM_TARGET_H__ -#define __SYSTEM_TARGET_H__ - -#include "kernel-unix.h" -#include "system-hosted.h" - -#define NEED_GENERIC_BYTESWAPS -#endif /* __SYSTEM_TARGET_H__ */ diff --git a/firmware/target/hosted/ypr0/system-ypr0.c b/firmware/target/hosted/ypr0/system-ypr0.c deleted file mode 100644 index 11275c7809..0000000000 --- a/firmware/target/hosted/ypr0/system-ypr0.c +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: system-sdl.c 29925 2011-05-25 20:11:03Z thomasjfox $ - * - * Copyright (C) 2006 by Daniel Everton - * - * 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 -#include -#include -#include "system.h" -#include "panic.h" -#include "debug.h" - -#if defined(HAVE_SDL_AUDIO) || defined(HAVE_SDL_THREADS) || defined(HAVE_SDL) -#include -#endif - -#include "ascodec.h" -#include "gpio_ypr0.h" - -void power_off(void) -{ - /* Something that we need to do before exit on our platform YPR0 */ - ascodec_close(); - gpio_close(); - exit(EXIT_SUCCESS); -} - -uintptr_t *stackbegin; -uintptr_t *stackend; -void system_init(void) -{ - int *s; - /* fake stack, OS manages size (and growth) */ - stackbegin = stackend = (uintptr_t*)&s; - -#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(); -} - - -void system_reboot(void) -{ - power_off(); -} - -void system_exception_wait(void) -{ - system_reboot(); -} - -#ifdef HAVE_ADJUSTABLE_CPU_FREQ -#include -#include "file.h" -/* This is the Linux Kernel CPU governor... */ -static void set_cpu_freq(int speed) -{ - char temp[10]; - int cpu_dev; - cpu_dev = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", O_WRONLY); - if (cpu_dev < 0) - return; - write(cpu_dev, temp, sprintf(temp, "%d", speed) + 1); - close(cpu_dev); -} - -void set_cpu_frequency(long frequency) -{ - switch (frequency) - { - case CPUFREQ_MAX: - set_cpu_freq(532000); - cpu_frequency = CPUFREQ_MAX; - break; - case CPUFREQ_NORMAL: - set_cpu_freq(400000); - cpu_frequency = CPUFREQ_NORMAL; - break; - default: - set_cpu_freq(200000); - cpu_frequency = CPUFREQ_DEFAULT; - break; - } -} -#endif diff --git a/firmware/target/hosted/ypr0/ypr0.make b/firmware/target/hosted/ypr0/ypr0.make deleted file mode 100644 index 67ff326de0..0000000000 --- a/firmware/target/hosted/ypr0/ypr0.make +++ /dev/null @@ -1,24 +0,0 @@ -# __________ __ ___. -# Open \______ \ ____ ____ | | _\_ |__ _______ ___ -# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / -# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < -# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ -# \/ \/ \/ \/ \/ -# $Id$ -# - -INCLUDES += -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR) - -SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS) - -.SECONDEXPANSION: # $$(OBJ) is not populated until after this - -$(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) - $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \ - -L$(BUILDDIR)/firmware -lfirmware \ - -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \ - -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \ - $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map - -$(BUILDDIR)/rockbox : $(BUILDDIR)/rockbox.elf - $(call PRINTS,OC $(@F))$(call objcopy,$^,$@) diff --git a/tools/configure b/tools/configure index 442b23899b..353b991b04 100755 --- a/tools/configure +++ b/tools/configure @@ -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) diff --git a/tools/root.make b/tools/root.make index c8c4eb4f89..b62cb4d589 100644 --- a/tools/root.make +++ b/tools/root.make @@ -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))) -- cgit v1.2.3