summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2009-10-02 23:04:30 +0000
committerDave Chapman <dave@dchapman.com>2009-10-02 23:04:30 +0000
commitf5feb13cc507220fee7d45b6b3a6e6c1ad721fdf (patch)
treefb8d75db6f478292221f80b414ea7dc6f5a7b673 /firmware/target/arm
parentf690cfdb4405f08792cfc73b0ae3dac3824bb8d1 (diff)
Unify the button driver for the Nano 2G with the driver for earlier clickwheel ipods. The clickwheel hardware appears to be the same - the differences are just related to the hardware init and how the data is read.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22878 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/ipod/button-clickwheel.c95
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c82
2 files changed, 79 insertions, 98 deletions
diff --git a/firmware/target/arm/ipod/button-clickwheel.c b/firmware/target/arm/ipod/button-clickwheel.c
index aaf9aefd4e..001f599878 100644
--- a/firmware/target/arm/ipod/button-clickwheel.c
+++ b/firmware/target/arm/ipod/button-clickwheel.c
@@ -40,15 +40,36 @@
#include "power.h"
#include "powermgmt.h"
+#ifdef CPU_PP
+/* PortalPlayer uses the USEC timer */
#define WHEEL_FAST_OFF_TIMEOUT 250000 /* timeout for acceleration = 250ms */
#define WHEEL_REPEAT_TIMEOUT 250000 /* timeout for button repeat = 250ms */
#define WHEEL_UNTOUCH_TIMEOUT 150000 /* timeout for untouching wheel = 150ms */
+#else
+/* Other targets use current_tick */
+#define WHEEL_FAST_OFF_TIMEOUT (HZ/4) /* timeout for acceleration = 250ms */
+#define WHEEL_REPEAT_TIMEOUT (HZ/4) /* timeout for button repeat = 250ms */
+#define WHEEL_UNTOUCH_TIMEOUT ((HZ*15)/100) /* timeout for untouching wheel = 150ms */
+
+#endif
+
+#ifdef CPU_PP
+#define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x7000c140))
+#elif CONFIG_CPU==S5L8701
+#define CLICKWHEEL00 (*(volatile unsigned long*)(0x3c200000))
+#define CLICKWHEEL10 (*(volatile unsigned long*)(0x3c200010))
+#define CLICKWHEELINT (*(volatile unsigned long*)(0x3c200014))
+#define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x3c200018))
+#else
+#error CPU architecture not supported!
+#endif
+
#define WHEELCLICKS_PER_ROTATION 96 /* wheelclicks per full rotation */
/* This amount of clicks is needed for at least scrolling 1 item. Choose small values
* to have high sensitivity but few precision, choose large values to have less
* sensitivity and good precision. */
-#if defined(IPOD_NANO)
+#if defined(IPOD_NANO) || defined(IPOD_NANO2G)
#define WHEEL_SENSITIVITY 6 /* iPod nano has smaller wheel, lower sensitivity needed */
#else
#define WHEEL_SENSITIVITY 4 /* default sensitivity */
@@ -71,6 +92,7 @@ int int_btn = BUTTON_NONE;
static bool send_events = true;
#endif
+#ifdef CPU_PP
static void opto_i2c_init(void)
{
DEV_EN |= DEV_OPTO;
@@ -82,19 +104,18 @@ static void opto_i2c_init(void)
outl(0xc00a1f00, 0x7000c100);
outl(0x01000000, 0x7000c104);
}
+#endif
static inline int ipod_4g_button_read(void)
{
int whl = -1;
int btn = BUTTON_NONE;
-
- /* The following delay was 250 in the ipodlinux source, but 50 seems to
- work fine - tested on Nano, Color/Photo and Video. */
- udelay(50);
+#ifdef CPU_PP
if ((inl(0x7000c104) & 0x04000000) != 0)
{
- unsigned status = inl(0x7000c140);
+#endif
+ unsigned status = CLICKWHEEL_DATA;
if ((status & 0x800000ff) == 0x8000001a)
{
@@ -110,7 +131,11 @@ static inline int ipod_4g_button_read(void)
btn |= BUTTON_MENU;
if (status & 0x40000000)
{
+#ifdef CPU_PP
unsigned long usec = USEC_TIMER;
+#else
+ unsigned long usec = current_tick;
+#endif
/* Highest wheel = 0x5F, clockwise increases */
new_wheel_value = (status >> 16) & 0x7f;
@@ -239,7 +264,9 @@ static inline int ipod_4g_button_read(void)
}
}
+#ifdef CPU_PP
}
+#endif
#ifdef HAVE_WHEEL_POSITION
/* Save the new absolute wheel position */
@@ -260,10 +287,15 @@ void wheel_send_events(bool send)
}
#endif
+#ifdef CPU_PP
void ipod_4g_button_int(void)
{
CPU_HI_INT_DIS = I2C_MASK;
+ /* The following delay was 250 in the ipodlinux source, but 50 seems to
+ work fine - tested on Nano, Color/Photo and Video. */
+ udelay(50);
+
int_btn = ipod_4g_button_read();
outl(inl(0x7000c104) | 0x0c000000, 0x7000c104);
@@ -285,6 +317,43 @@ void button_init_device(void)
CPU_HI_INT_EN = I2C_MASK;
}
+bool button_hold(void)
+{
+ return (GPIOA_INPUT_VAL & 0x20)?false:true;
+}
+
+bool headphones_inserted(void)
+{
+ return (GPIOA_INPUT_VAL & 0x80)?true:false;
+}
+#else
+void INT_SPI(void)
+{
+ int clickwheel_events = CLICKWHEELINT;
+
+ /* Clear interrupts */
+ if (clickwheel_events & 4) CLICKWHEELINT = 4;
+ if (clickwheel_events & 2) CLICKWHEELINT = 2;
+ if (clickwheel_events & 1) CLICKWHEELINT = 1;
+
+ int_btn = ipod_4g_button_read();
+}
+
+void button_init_device(void)
+{
+ CLICKWHEEL00 = 0x280000;
+ CLICKWHEEL10 = 3;
+ INTMOD = 0;
+ INTMSK |= (1<<26);
+ PCON10 &= ~0xF00;
+}
+
+bool button_hold(void)
+{
+ return ((PDAT14 & (1 << 6)) == 0);
+}
+#endif
+
/*
* Get button pressed from hardware
*/
@@ -303,14 +372,18 @@ int button_read_device(void)
if (hold_button)
{
+#ifdef CPU_PP
/* lock -> disable wheel sensor */
DEV_EN &= ~DEV_OPTO;
+#endif
}
else
{
+#ifdef CPU_PP
/* unlock -> enable wheel sensor */
DEV_EN |= DEV_OPTO;
opto_i2c_init();
+#endif
}
}
@@ -321,13 +394,3 @@ int button_read_device(void)
return int_btn;
#endif
}
-
-bool button_hold(void)
-{
- return (GPIOA_INPUT_VAL & 0x20)?false:true;
-}
-
-bool headphones_inserted(void)
-{
- return (GPIOA_INPUT_VAL & 0x80)?true:false;
-}
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c
deleted file mode 100644
index 739b48b511..0000000000
--- a/firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id: button-m3.c 21787 2009-07-11 20:00:07Z bertrik $
- *
- * Copyright (C) 2009 Dave Chapman
- *
- * 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 <stdbool.h>
-#include "config.h"
-
-#include "s5l8700.h"
-#include "button-target.h"
-
-#define CLICKWHEEL00 (*(volatile unsigned long*)(0x3c200000))
-#define CLICKWHEEL10 (*(volatile unsigned long*)(0x3c200010))
-#define CLICKWHEELINT (*(volatile unsigned long*)(0x3c200014))
-#define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x3c200018))
-
-static int buttons = 0;
-
-void INT_SPI(void)
-{
- int clickwheel_events;
- int btn =0;
- int status;
-
- clickwheel_events = CLICKWHEELINT;
-
- if (clickwheel_events & 4) CLICKWHEELINT = 4;
- if (clickwheel_events & 2) CLICKWHEELINT = 2;
- if (clickwheel_events & 1) CLICKWHEELINT = 1;
-
- status = CLICKWHEEL_DATA;
- if ((status & 0x800000ff) == 0x8000001a)
- {
- if (status & 0x00000100)
- btn |= BUTTON_SELECT;
- if (status & 0x00000200)
- btn |= BUTTON_RIGHT;
- if (status & 0x00000400)
- btn |= BUTTON_LEFT;
- if (status & 0x00000800)
- btn |= BUTTON_PLAY;
- if (status & 0x00001000)
- btn |= BUTTON_MENU;
- }
-
- buttons = btn;
-}
-
-void button_init_device(void)
-{
- CLICKWHEEL00 = 0x280000;
- CLICKWHEEL10 = 3;
- INTMOD = 0;
- INTMSK |= (1<<26);
- PCON10 &= ~0xF00;
-}
-
-int button_read_device(void)
-{
- return buttons;
-}
-
-bool button_hold(void)
-{
- return ((PDAT14 & (1 << 6)) == 0);
-}