summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-05-11 22:38:09 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-05-11 22:38:09 +0000
commit86e8c283307d3d884a0d5dba3b50fed0e4ad0914 (patch)
tree5f25098df90e991df7ce5b602b3787399fdc3887 /firmware/drivers
parentbc315ad7312ab5d170c6d73bd1c40c414e780d52 (diff)
downloadrockbox-86e8c283307d3d884a0d5dba3b50fed0e4ad0914.tar.gz
rockbox-86e8c283307d3d884a0d5dba3b50fed0e4ad0914.zip
fuze+: implement Synaptics RMI driver on top of i2c, add touchpad debug screen, bootloader enters debug screen by default
Since the bootloader currently always fails at storage point (unimplemented), always enter touchpad debug screen and power off which pressing power button. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29859 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/synaptics-rmi.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/firmware/drivers/synaptics-rmi.c b/firmware/drivers/synaptics-rmi.c
new file mode 100644
index 0000000000..c6a1bae168
--- /dev/null
+++ b/firmware/drivers/synaptics-rmi.c
@@ -0,0 +1,77 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 by Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "system.h"
22#include "generic_i2c.h"
23#include "synaptics-rmi.h"
24
25static int rmi_cur_page;
26static int rmi_i2c_addr;
27static int rmi_i2c_bus;
28
29/* NOTE:
30 * RMI over i2c supports some special aliases on page 0x2 but this driver don't
31 * use them */
32
33int rmi_init(int i2c_bus_index, int i2c_dev_addr)
34{
35 rmi_i2c_bus = i2c_bus_index;
36 rmi_i2c_addr = i2c_dev_addr;
37 rmi_cur_page = 0x4;
38 return 0;
39}
40
41static int rmi_select_page(unsigned char page)
42{
43 /* Lazy page select */
44 if(page != rmi_cur_page)
45 {
46 rmi_cur_page = page;
47 return i2c_write_data(rmi_i2c_bus, rmi_i2c_addr, RMI_PAGE_SELECT, &page, 1);
48 }
49 else
50 return 0;
51}
52
53int rmi_read(int address, int byte_count, unsigned char *buffer)
54{
55 if(rmi_select_page(address >> 8) < 0)
56 return -1;
57 return i2c_read_data(rmi_i2c_bus, rmi_i2c_addr, address & 0xff, buffer, byte_count);
58}
59
60int rmi_read_single(int address)
61{
62 unsigned char c;
63 int ret = rmi_read(address, 1, &c);
64 return ret < 0 ? ret : c;
65}
66
67int rmi_write(int address, int byte_count, const unsigned char *buffer)
68{
69 if(rmi_select_page(address >> 8) < 0)
70 return -1;
71 return i2c_write_data(rmi_i2c_bus, rmi_i2c_addr, address & 0xff, buffer, byte_count);
72}
73
74int rmi_write_single(int address, unsigned char byte)
75{
76 return rmi_write(address, 1, &byte);
77}