summaryrefslogtreecommitdiffstats
path: root/firmware/drivers
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2018-06-28 06:24:26 -0400
committerMichael Giacomelli <giac2000@hotmail.com>2018-07-28 10:56:31 -0400
commit0662793ca0050e823cd1207cc4689a1cba5068bd (patch)
tree08cd2ec59c9044c96b697b5bf8d0640841d044e0 /firmware/drivers
parentb3e2bd619b1b7ea94ef29d32db48e80b347a1990 (diff)
downloadrockbox-0662793ca0050e823cd1207cc4689a1cba5068bd.tar.gz
rockbox-0662793ca0050e823cd1207cc4689a1cba5068bd.tar.bz2
rockbox-0662793ca0050e823cd1207cc4689a1cba5068bd.zip
Add cleaned-up xDuoo X3 support
Cleaned up, rebased, and forward-ported from the xvortex fork. (original credit to vsoftster@gmail.com) Change-Id: Ibcc023a0271ea81e901450a88317708c2683236d Signed-off-by: Solomon Peachy <pizza@shaftnet.org>
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/audio/cs4398.c41
-rw-r--r--firmware/drivers/audio/sdl.c4
-rw-r--r--firmware/drivers/nand_id.c29
-rw-r--r--firmware/drivers/rtc/rtc_jz4760.c124
4 files changed, 189 insertions, 9 deletions
diff --git a/firmware/drivers/audio/cs4398.c b/firmware/drivers/audio/cs4398.c
new file mode 100644
index 0000000000..35aa99d08c
--- /dev/null
+++ b/firmware/drivers/audio/cs4398.c
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2016 by Roman Stolyarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "system.h"
+#include "cs4398.h"
+#include "config.h"
+#include "audio.h"
+#include "audiohw.h"
+#include "i2c.h"
+
+void cs4398_write_reg(uint8_t reg, uint8_t val)
+{
+ unsigned char buf[2] = {reg, val};
+ i2c_write(CS4398_I2C_ADDR, (unsigned char *)&buf, 2);
+}
+
+uint8_t cs4398_read_reg(uint8_t reg)
+{
+ unsigned char buf[2] = {reg, 0xff};
+ i2c_write(CS4398_I2C_ADDR, (unsigned char *)&buf[0], 1);
+ i2c_read(CS4398_I2C_ADDR, (unsigned char *)&buf[1], 1);
+ return buf[1];
+}
diff --git a/firmware/drivers/audio/sdl.c b/firmware/drivers/audio/sdl.c
index ae66380d16..a8fd2ffa07 100644
--- a/firmware/drivers/audio/sdl.c
+++ b/firmware/drivers/audio/sdl.c
@@ -122,6 +122,10 @@ void audiohw_set_depth_3d(int value)
void audiohw_set_lineout_volume(int vol_l, int vol_r)
{ (void)vol_l; (void)vol_r; }
#endif
+#if defined(AUDIOHW_HAVE_FILTER_ROLL_OFF)
+void audiohw_set_filter_roll_off(int value)
+ { (void)value; }
+#endif
void audiohw_close(void) {}
diff --git a/firmware/drivers/nand_id.c b/firmware/drivers/nand_id.c
index f2b9861c7c..56132ab090 100644
--- a/firmware/drivers/nand_id.c
+++ b/firmware/drivers/nand_id.c
@@ -34,27 +34,38 @@ static const struct nand_info samsung[] =
/*
id1, id2
pages/block, blocks, page_size, spare_size, col_cycles, row_cycles, planes
-*/
+*/
{0xDC, 0x10, /* K9F4G08UOM */
64, 4096, 2048, 64, 2, 3, 1 },
-
+
{0xD3, 0x51, /* K9K8G08UOM */
64, 8192, 2048, 64, 2, 3, 1 },
-
+
{0xD5, 0x14, /* K9GAG08UOM */
128, 4096, 4096, 128, 2, 3, 2 },
-
+
{0xD5, 0x55, /* K9LAG08UOM, K9HBG08U1M, K9MCG08U5M */
128, 8192, 2048, 64, 2, 3, 4 },
-
+
{0xD7, 0x55, /* K9LBG08UOM */
128, 8192, 4096, 128, 2, 3, 4 },
};
+static const struct nand_info gigadevice[] =
+{
+/*
+ id1, id2
+ pages/block, blocks, page_size, spare_size, col_cycles, row_cycles, planes
+*/
+ {0xB1, 0x80, /* MD5N01G51MSD1B */
+ 64, 1024, 2048, 64, 2, 2, 1 },
+};
+
#define NI(id, x) {id, (struct nand_info*)x, (sizeof(x)/sizeof(struct nand_info))}
static const struct nand_manufacturer all[] =
{
NI(0xEC, samsung),
+ NI(0x98, gigadevice),
};
// -----------------------------------------------------------------------------
@@ -63,7 +74,7 @@ struct nand_info* nand_identify(unsigned char data[5])
{
unsigned int i;
int found = -1;
-
+
for(i = 0; i < (sizeof(all)/sizeof(struct nand_manufacturer)); i++)
{
if(data[0] == all[i].id)
@@ -72,16 +83,16 @@ struct nand_info* nand_identify(unsigned char data[5])
break;
}
}
-
+
if(found < 0)
return NULL;
-
+
for(i = 0; i < all[found].total; i++)
{
if(data[1] == all[found].info[i].dev_id &&
data[2] == all[found].info[i].dev_id2)
return &all[found].info[i];
}
-
+
return NULL;
}
diff --git a/firmware/drivers/rtc/rtc_jz4760.c b/firmware/drivers/rtc/rtc_jz4760.c
new file mode 100644
index 0000000000..cda618d617
--- /dev/null
+++ b/firmware/drivers/rtc/rtc_jz4760.c
@@ -0,0 +1,124 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2016 by Roman Stolyarov
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/*
+ * Real Time Clock interface for Jz4760.
+ *
+ */
+
+#include "config.h"
+#include "cpu.h"
+#include "rtc.h"
+#include "timefuncs.h"
+#include "logf.h"
+
+#define RTC_FREQ_DIVIDER (32768 - 1)
+
+/* Stolen from dietlibc-0.29/libugly/gmtime_r.c (GPLv2) */
+#define SPD (24*60*60)
+#define ISLEAP(year) (!(year%4) && ((year%100) || !(year%400)))
+static void _localtime(const time_t t, struct tm *r)
+{
+ time_t i;
+ register time_t work = t % SPD;
+ static int m_to_d[12] = /* This could be shared with mktime() */
+ {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
+
+ r->tm_sec = work % 60;
+ work /= 60;
+ r->tm_min = work % 60;
+ r->tm_hour = work / 60;
+ work = t / SPD;
+ r->tm_wday = (4 + work) % 7;
+
+ for (i=1970; ; ++i)
+ {
+ register time_t k = ISLEAP(i) ? 366 : 365;
+
+ if (work >= k)
+ work -= k;
+ else
+ break;
+ }
+
+ r->tm_year = i - 1900;
+ r->tm_yday = work;
+
+ r->tm_mday = 1;
+ if (ISLEAP(i) && (work>58))
+ {
+ if (work==59)
+ r->tm_mday=2; /* 29.2. */
+
+ work-=1;
+ }
+
+ for (i=11; i && (m_to_d[i] > work); --i);
+ r->tm_mon = i;
+ r->tm_mday += work - m_to_d[i];
+}
+
+int rtc_read_datetime(struct tm *tm)
+{
+ _localtime(rtc_read_reg(RTC_RTCSR), tm);
+
+ return 1;
+}
+
+int rtc_write_datetime(const struct tm *tm)
+{
+ rtc_write_reg(RTC_RTCSR, mktime((struct tm*)tm));
+
+ return 0;
+}
+
+void rtc_init(void)
+{
+ unsigned int cfc,hspr,rgr_1hz;
+
+ __cpm_select_rtcclk_rtc();
+
+ cfc = HSPR_RTCV;
+ hspr = rtc_read_reg(RTC_HSPR);
+ rgr_1hz = rtc_read_reg(RTC_RTCGR) & RTCGR_NC1HZ_MASK;
+
+ if((hspr != cfc) || (rgr_1hz != RTC_FREQ_DIVIDER))
+ {
+ /* We are powered on for the first time !!! */
+
+ /* Set 32768 rtc clocks per seconds */
+ rtc_write_reg(RTC_RTCGR, RTC_FREQ_DIVIDER);
+
+ /* Set minimum wakeup_n pin low-level assertion time for wakeup: 100ms */
+ rtc_write_reg(RTC_HWFCR, HWFCR_WAIT_TIME(100));
+ rtc_write_reg(RTC_HRCR, HRCR_WAIT_TIME(60));
+
+ /* Reset to the default time */
+ rtc_write_reg(RTC_RTCSR, 946681200); /* 01/01/2000 */
+
+ /* start rtc */
+ rtc_write_reg(RTC_RTCCR, RTCCR_RTCE);
+ rtc_write_reg(RTC_HSPR, cfc);
+ }
+
+ /* clear all rtc flags */
+ rtc_write_reg(RTC_HWRSR, 0);
+}