summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-09-27 17:18:19 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-10-16 16:58:19 -0400
commit7a5130a27722b95f0de965e99e1fd7cb322cafcf (patch)
tree34abc836f0862540a71d2622a2b64bc0cdaeabe4
parentbf54002bc19b6dde4c9e3ad5b5c505facd1af95a (diff)
downloadrockbox-7a5130a27722b95f0de965e99e1fd7cb322cafcf.tar.gz
rockbox-7a5130a27722b95f0de965e99e1fd7cb322cafcf.zip
x1000: fix broken OST2 timer prescaler
It turns out the prescaler fields in OST_CTRL are 2 bits wide, not 3. The programming manual (as usual) is ambiguous and its diagram shows 2-bit wide fields, but the bit positions in the text give a 3-bit wide field. Ingenic's Linux code and my own testing shows that they are, in fact, 2 bits wide. This caused the OST2 divisor to be 16 instead of 4; the OST1 divisor was correct. This means that all udelay/mdelay calls took 4x longer than they should've. After this change the OST2 prescaler will be 4, as intended, and udelay/mdelay calls will wait for the intended duration. Change-Id: I2ac0a9190f49b59a840c649bf586131f5f9fde82
-rw-r--r--firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c4
-rw-r--r--firmware/target/mips/ingenic_x1000/x1000/ost.h10
-rw-r--r--utils/reggen-ng/x1000.reggen4
3 files changed, 9 insertions, 9 deletions
diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c
index 4354257f7b..04e3102d42 100644
--- a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c
+++ b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c
@@ -45,11 +45,11 @@
45#define STATE_SCROLLING 4 45#define STATE_SCROLLING 4
46 46
47/* Assume there's no active touch if no event is reported in this time */ 47/* Assume there's no active touch if no event is reported in this time */
48#define AUTORELEASE_TIME (10000 * OST_TICKS_PER_US) 48#define AUTORELEASE_TIME (40 * 1000 * OST_TICKS_PER_US)
49 49
50/* If there's no significant motion on the scrollbar for this time, 50/* If there's no significant motion on the scrollbar for this time,
51 * then report it as a button press instead */ 51 * then report it as a button press instead */
52#define SCROLL_PRESS_TIME (100000 * OST_TICKS_PER_US) 52#define SCROLL_PRESS_TIME (400 * 1000 * OST_TICKS_PER_US)
53 53
54/* If a press on the scrollbar moves more than this during SCROLL_PRESS_TIME, 54/* If a press on the scrollbar moves more than this during SCROLL_PRESS_TIME,
55 * then we enter scrolling mode. */ 55 * then we enter scrolling mode. */
diff --git a/firmware/target/mips/ingenic_x1000/x1000/ost.h b/firmware/target/mips/ingenic_x1000/x1000/ost.h
index 8f2619e0e7..9444712e86 100644
--- a/firmware/target/mips/ingenic_x1000/x1000/ost.h
+++ b/firmware/target/mips/ingenic_x1000/x1000/ost.h
@@ -31,21 +31,21 @@
31#define JT_OST_CTRL JIO_32_RW 31#define JT_OST_CTRL JIO_32_RW
32#define JN_OST_CTRL OST_CTRL 32#define JN_OST_CTRL OST_CTRL
33#define JI_OST_CTRL 33#define JI_OST_CTRL
34#define BP_OST_CTRL_PRESCALE2 3 34#define BP_OST_CTRL_PRESCALE2 2
35#define BM_OST_CTRL_PRESCALE2 0x38 35#define BM_OST_CTRL_PRESCALE2 0xc
36#define BV_OST_CTRL_PRESCALE2__BY_1 0x0 36#define BV_OST_CTRL_PRESCALE2__BY_1 0x0
37#define BV_OST_CTRL_PRESCALE2__BY_4 0x1 37#define BV_OST_CTRL_PRESCALE2__BY_4 0x1
38#define BV_OST_CTRL_PRESCALE2__BY_16 0x2 38#define BV_OST_CTRL_PRESCALE2__BY_16 0x2
39#define BF_OST_CTRL_PRESCALE2(v) (((v) & 0x7) << 3) 39#define BF_OST_CTRL_PRESCALE2(v) (((v) & 0x3) << 2)
40#define BFM_OST_CTRL_PRESCALE2(v) BM_OST_CTRL_PRESCALE2 40#define BFM_OST_CTRL_PRESCALE2(v) BM_OST_CTRL_PRESCALE2
41#define BF_OST_CTRL_PRESCALE2_V(e) BF_OST_CTRL_PRESCALE2(BV_OST_CTRL_PRESCALE2__##e) 41#define BF_OST_CTRL_PRESCALE2_V(e) BF_OST_CTRL_PRESCALE2(BV_OST_CTRL_PRESCALE2__##e)
42#define BFM_OST_CTRL_PRESCALE2_V(v) BM_OST_CTRL_PRESCALE2 42#define BFM_OST_CTRL_PRESCALE2_V(v) BM_OST_CTRL_PRESCALE2
43#define BP_OST_CTRL_PRESCALE1 0 43#define BP_OST_CTRL_PRESCALE1 0
44#define BM_OST_CTRL_PRESCALE1 0x7 44#define BM_OST_CTRL_PRESCALE1 0x3
45#define BV_OST_CTRL_PRESCALE1__BY_1 0x0 45#define BV_OST_CTRL_PRESCALE1__BY_1 0x0
46#define BV_OST_CTRL_PRESCALE1__BY_4 0x1 46#define BV_OST_CTRL_PRESCALE1__BY_4 0x1
47#define BV_OST_CTRL_PRESCALE1__BY_16 0x2 47#define BV_OST_CTRL_PRESCALE1__BY_16 0x2
48#define BF_OST_CTRL_PRESCALE1(v) (((v) & 0x7) << 0) 48#define BF_OST_CTRL_PRESCALE1(v) (((v) & 0x3) << 0)
49#define BFM_OST_CTRL_PRESCALE1(v) BM_OST_CTRL_PRESCALE1 49#define BFM_OST_CTRL_PRESCALE1(v) BM_OST_CTRL_PRESCALE1
50#define BF_OST_CTRL_PRESCALE1_V(e) BF_OST_CTRL_PRESCALE1(BV_OST_CTRL_PRESCALE1__##e) 50#define BF_OST_CTRL_PRESCALE1_V(e) BF_OST_CTRL_PRESCALE1(BV_OST_CTRL_PRESCALE1__##e)
51#define BFM_OST_CTRL_PRESCALE1_V(v) BM_OST_CTRL_PRESCALE1 51#define BFM_OST_CTRL_PRESCALE1_V(v) BM_OST_CTRL_PRESCALE1
diff --git a/utils/reggen-ng/x1000.reggen b/utils/reggen-ng/x1000.reggen
index d34a0eb7bc..8c6c49e27d 100644
--- a/utils/reggen-ng/x1000.reggen
+++ b/utils/reggen-ng/x1000.reggen
@@ -807,8 +807,8 @@ node OST {
807 addr 0xb2000000 807 addr 0xb2000000
808 808
809 reg CTRL 0x00 { 809 reg CTRL 0x00 {
810 field 5 3 PRESCALE2 { enum BY_1 0; enum BY_4 1; enum BY_16 2; } 810 field 3 2 PRESCALE2 { enum BY_1 0; enum BY_4 1; enum BY_16 2; }
811 field 2 0 PRESCALE1 { enum BY_1 0; enum BY_4 1; enum BY_16 2; } 811 field 1 0 PRESCALE1 { enum BY_1 0; enum BY_4 1; enum BY_16 2; }
812 } 812 }
813 813
814 reg ENABLE 0x04 { 814 reg ENABLE 0x04 {