aboutsummaryrefslogtreecommitdiff
path: root/drivers/acorn/char
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 15:20:36 -0700
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/acorn/char
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/acorn/char')
-rw-r--r--drivers/acorn/char/Makefile6
-rw-r--r--drivers/acorn/char/defkeymap-l7200.c386
-rw-r--r--drivers/acorn/char/i2c.c369
-rw-r--r--drivers/acorn/char/pcf8583.c239
-rw-r--r--drivers/acorn/char/pcf8583.h41
5 files changed, 1041 insertions, 0 deletions
diff --git a/drivers/acorn/char/Makefile b/drivers/acorn/char/Makefile
new file mode 100644
index 00000000000..2fa9a8bf48a
--- /dev/null
+++ b/drivers/acorn/char/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the acorn character device drivers.
+#
+
+obj-$(CONFIG_ARCH_ACORN) += i2c.o pcf8583.o
+obj-$(CONFIG_L7200_KEYB) += defkeymap-l7200.o keyb_l7200.o
diff --git a/drivers/acorn/char/defkeymap-l7200.c b/drivers/acorn/char/defkeymap-l7200.c
new file mode 100644
index 00000000000..9e18ce742e3
--- /dev/null
+++ b/drivers/acorn/char/defkeymap-l7200.c
@@ -0,0 +1,386 @@
+/*
+ * linux/drivers/acorn/char/defkeymap-l7200.c
+ *
+ * Default keyboard maps for LinkUp Systems L7200 board
+ *
+ * Copyright (C) 2000 Steve Hill (sjhill@cotw.com)
+ *
+ * Changelog:
+ * 08-04-2000 SJH Created file
+ */
+
+#include <linux/types.h>
+#include <linux/keyboard.h>
+#include <linux/kd.h>
+
+/* Normal (maps 1:1 with no processing) */
+#define KTn 0xF0
+/* Function keys */
+#define KTf 0xF1
+/* Special (Performs special house-keeping funcs) */
+#define KTs 0xF2
+#define KIGNORE K(KTs, 0) /* Ignore */
+#define KENTER K(KTs, 1) /* Enter */
+#define KREGS K(KTs, 2) /* Regs */
+#define KMEM K(KTs, 3) /* Mem */
+#define KSTAT K(KTs, 4) /* State */
+#define KINTR K(KTs, 5) /* Intr */
+#define Ksl 6 /* Last console */
+#define KCAPSLK K(KTs, 7) /* Caps lock */
+#define KNUMLK K(KTs, 8) /* Num-lock */
+#define KSCRLLK K(KTs, 9) /* Scroll-lock */
+#define KSCRLFOR K(KTs,10) /* Scroll forward */
+#define KSCRLBAK K(KTs,11) /* Scroll back */
+#define KREBOOT K(KTs,12) /* Reboot */
+#define KCAPSON K(KTs,13) /* Caps on */
+#define KCOMPOSE K(KTs,14) /* Compose */
+#define KSAK K(KTs,15) /* SAK */
+#define CONS_DEC K(KTs,16) /* Dec console */
+#define CONS_INC K(KTs,17) /* Incr console */
+#define KFLOPPY K(KTs,18) /* Floppy */
+/* Key pad (0-9 = digits, 10=+, 11=-, 12=*, 13=/, 14=enter, 16=., 17=# */
+#define KTp 0xF3
+#define KPAD_0 K(KTp, 0 )
+#define KPAD_1 K(KTp, 1 )
+#define KPAD_2 K(KTp, 2 )
+#define KPAD_3 K(KTp, 3 )
+#define KPAD_4 K(KTp, 4 )
+#define KPAD_5 K(KTp, 5 )
+#define KPAD_6 K(KTp, 6 )
+#define KPAD_7 K(KTp, 7 )
+#define KPAD_8 K(KTp, 8 )
+#define KPAD_9 K(KTp, 9 )
+#define KPAD_PL K(KTp,10 )
+#define KPAD_MI K(KTp,11 )
+#define KPAD_ML K(KTp,12 )
+#define KPAD_DV K(KTp,13 )
+#define KPAD_EN K(KTp,14 )
+#define KPAD_DT K(KTp,16 )
+#define KPAD_HS K(KTp,20 )
+/* Console switching */
+#define KCn 0xF5
+/* Cursor */
+#define KTc 0xF6
+#define Kcd 0 /* Cursor down */
+#define Kcl 1 /* Cursor left */
+#define Kcr 2 /* Cursor right */
+#define Kcu 3 /* Cursor up */
+/* Shift/alt modifiers etc */
+#define KMd 0xF7
+#define KSHIFT K(KMd, 0 )
+#define KALTGR K(KMd, 1 )
+#define KCTRL K(KMd, 2 )
+#define KALT K(KMd, 3 )
+/* Meta */
+#define KMt 0xF8
+#define KAs 0xF9
+#define KPADA_0 K(KAs, 0 )
+#define KPADA_1 K(KAs, 1 )
+#define KPADA_2 K(KAs, 2 )
+#define KPADA_3 K(KAs, 3 )
+#define KPADA_4 K(KAs, 4 )
+#define KPADA_5 K(KAs, 5 )
+#define KPADA_6 K(KAs, 6 )
+#define KPADA_7 K(KAs, 7 )
+#define KPADA_8 K(KAs, 8 )
+#define KPADA_9 K(KAs, 9 )
+#define KPADB_0 K(KAs,10 )
+#define KPADB_1 K(KAs,11 )
+#define KPADB_2 K(KAs,12 )
+#define KPADB_3 K(KAs,13 )
+#define KPADB_4 K(KAs,14 )
+#define KPADB_5 K(KAs,15 )
+#define KPADB_6 K(KAs,16 )
+#define KPADB_7 K(KAs,17 )
+#define KPADB_8 K(KAs,18 )
+#define KPADB_9 K(KAs,19 )
+/* Locking keys */
+#define KLk 0xFA
+/* Letters */
+#define KTl 0xFB
+
+/*
+ * Here is the layout of the keys for the Fujitsu QWERTY
+ * style keyboard:
+ *
+ * static char Fujitsu_Key_Table[] =
+ * {
+ * KALT, '`' , KNUL, KCTL, KFUN, KESC, '1' , '2' ,
+ * '9' , '0' , '-' , '=' , KNUL, KBSP, KNUL, KNUL,
+ * KNUL, KBSL, KSHF, KNUL, KNUL, KDEL, KNUL, 't' ,
+ * 'y' , 'u' , 'i' , KRET, KSHF, KPGD, KNUL, KNUL,
+ * KNUL, KTAB, KNUL, KNUL, KNUL, 'q' , 'w' , 'e' ,
+ * 'r' , 'o' , 'p' , '[' , KNUL, ']' , KNUL, KNUL,
+ * KNUL, 'z' , KNUL, KNUL, KNUL, KSHL, KNUL, KNUL,
+ * 'k' , 'l' , ';' , KSQT, KNUL, KPGU, KNUL, KNUL,
+ * KNUL, 'a' , KNUL, KNUL, KNUL, 's' , 'd' , 'f' ,
+ * 'g' , 'h' , 'j' , '/' , KNUL, KHME, KNUL, KNUL,
+ * KNUL, 'x' , KNUL, KNUL, KNUL, 'c' , 'v' , 'b' ,
+ * 'n' , 'm' , ',' , '.' , KNUL, ' ' , KNUL, KNUL,
+ * KNUL, KNUL, KNUL, KNUL, KNUL, '3' , '4' , '5' ,
+ * '6' , '7' , '8' , KNUL, KPRG, KNUL, KEND, KNUL,
+ * };
+ */
+
+u_short plain_map[NR_KEYS]=
+{
+ 0xf703, 0xf060, 0xf200, 0xf702, 0xf200, 0xf01b, 0xf031, 0xf032,
+ 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf200, 0xf07f, 0xf200, 0xf200,
+ 0xf200, 0xf05c, 0xf700, 0xf200, 0xf200, 0xf116, 0xf000, 0xfb74,
+ 0xfb79, 0xfb75, 0xfb69, 0xf201, 0xf700, 0xf600, 0xf200, 0xf200,
+ 0xf200, 0xf009, 0xf200, 0xf200, 0xf200, 0xfb71, 0xfb77, 0xfb65,
+ 0xfb72, 0xfb6f, 0xfb70, 0xf05b, 0xf200, 0xf05d, 0xf200, 0xf200,
+ 0xf200, 0xfb7a, 0xf200, 0xf200, 0xf200, 0xf207, 0xf200, 0xf200,
+ 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf200, 0xf603, 0xf200, 0xf200,
+ 0xf200, 0xfb61, 0xf200, 0xf200, 0xf200, 0xfb73, 0xfb64, 0xfb66,
+ 0xfb67, 0xfb68, 0xfb6a, 0xf02f, 0xf200, 0xf601, 0xf200, 0xf200,
+ 0xf200, 0xfb78, 0xf200, 0xf200, 0xf200, 0xfb63, 0xfb76, 0xfb62,
+ 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf200, 0xf020, 0xf200, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf033, 0xf034, 0xf035,
+ 0xf036, 0xf037, 0xf038, 0xf200, 0xf200, 0xf200, 0xf602, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+};
+
+u_short shift_map[NR_KEYS]=
+{
+ 0xf703, 0xf07e, 0xf200, 0xf702, 0xf200, 0xf01b, 0xf021, 0xf040,
+ 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf200, 0xf07f, 0xf200, 0xf200,
+ 0xf200, 0xf07c, 0xf700, 0xf200, 0xf200, 0xf116, 0xf000, 0xfb54,
+ 0xfb59, 0xfb55, 0xfb49, 0xf201, 0xf700, 0xf600, 0xf200, 0xf200,
+ 0xf200, 0xf009, 0xf200, 0xf200, 0xf200, 0xfb51, 0xfb57, 0xfb45,
+ 0xfb52, 0xfb4f, 0xfb50, 0xf07b, 0xf200, 0xf07d, 0xf200, 0xf200,
+ 0xf200, 0xfb5a, 0xf200, 0xf200, 0xf200, 0xf207, 0xf200, 0xf200,
+ 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf200, 0xf603, 0xf200, 0xf200,
+ 0xf200, 0xfb41, 0xf200, 0xf200, 0xf200, 0xfb53, 0xfb44, 0xfb46,
+ 0xfb47, 0xfb48, 0xfb4a, 0xf03f, 0xf200, 0xf601, 0xf200, 0xf200,
+ 0xf200, 0xfb58, 0xf200, 0xf200, 0xf200, 0xfb43, 0xfb56, 0xfb42,
+ 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf200, 0xf020, 0xf200, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf023, 0xf024, 0xf025,
+ 0xf05e, 0xf026, 0xf02a, 0xf200, 0xf200, 0xf200, 0xf602, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+};
+
+u_short altgr_map[NR_KEYS]=
+{
+ KIGNORE ,K(KCn,12 ),K(KCn,13 ),K(KCn,14 ),K(KCn,15 ),K(KCn,16 ),K(KCn,17 ),K(KCn, 18),
+ K(KCn, 19),K(KCn,20 ),K(KCn,21 ),K(KCn,22 ),K(KCn,23 ),KIGNORE ,KREGS ,KINTR ,
+ KIGNORE ,KIGNORE ,K(KTn,'@'),KIGNORE ,K(KTn,'$'),KIGNORE ,KIGNORE ,K(KTn,'{'),
+ K(KTn,'['),K(KTn,']'),K(KTn,'}'),K(KTn,'\\'),KIGNORE ,KIGNORE ,KIGNORE ,K(KTf,21 ),
+ K(KTf,20 ),K(KTf,24 ),KNUMLK ,KPAD_DV ,KPAD_ML ,KPAD_HS ,KIGNORE ,K(KTl,'q'),
+ K(KTl,'w'),K(KTl,'e'),K(KTl,'r'),K(KTl,'t' ),K(KTl,'y'),K(KTl,'u'),K(KTl,'i' ),K(KTl,'o'),
+ K(KTl,'p'),KIGNORE ,K(KTn,'~'),KIGNORE ,K(KTf,22 ),K(KTf,23 ),K(KTf,25 ),KPADB_7 ,
+ KPADB_8 ,KPADB_9 ,KPAD_MI ,KCTRL ,K(KAs,20 ),K(KTl,'s'),K(KAs,23 ),K(KAs,25 ),
+ K(KTl,'g'),K(KTl,'h'),K(KTl,'j'),K(KTl,'k' ),K(KTl,'l'),KIGNORE ,KIGNORE ,KENTER ,
+ KPADB_4 ,KPADB_5 ,KPADB_6 ,KPAD_PL ,KSHIFT ,KIGNORE ,K(KTl,'z' ),K(KTl,'x'),
+ K(KAs,22 ),K(KTl,'v'),K(KTl,21 ),K(KTl,'n' ),K(KTl,'m'),KIGNORE ,KIGNORE ,KIGNORE ,
+ KSHIFT ,K(KTc,Kcu),KPADB_1 ,KPADB_2 ,KPADB_3 ,KCAPSLK ,KALT ,KIGNORE ,
+ KALTGR ,KCTRL ,K(KTc,Kcl),K(KTc,Kcd ),K(KTc,Kcr),KPADB_0 ,KPAD_DT ,KPAD_EN ,
+ KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,
+ KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,
+ KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,
+};
+
+u_short ctrl_map[NR_KEYS]=
+{
+ 0xf703, 0xf200, 0xf200, 0xf702, 0xf200, 0xf200, 0xf001, 0xf002,
+ 0xf009, 0xf000, 0xf031, 0xf200, 0xf200, 0xf07f, 0xf200, 0xf200,
+ 0xf200, 0xf01c, 0xf700, 0xf200, 0xf200, 0xf116, 0xf000, 0xf020,
+ 0xf019, 0xf015, 0xf009, 0xf201, 0xf700, 0xf600, 0xf200, 0xf200,
+ 0xf200, 0xf009, 0xf200, 0xf200, 0xf200, 0xf011, 0xf017, 0xf005,
+ 0xf012, 0xf00f, 0xf010, 0xf01b, 0xf200, 0xf01d, 0xf200, 0xf200,
+ 0xf200, 0xf01a, 0xf200, 0xf200, 0xf200, 0xf207, 0xf200, 0xf200,
+ 0xf00b, 0xf00c, 0xf200, 0xf007, 0xf200, 0xf603, 0xf200, 0xf200,
+ 0xf200, 0xf001, 0xf200, 0xf200, 0xf200, 0xf001, 0xf013, 0xf006,
+ 0xf007, 0xf008, 0xf00a, 0xf07f, 0xf200, 0xf601, 0xf200, 0xf200,
+ 0xf200, 0xf018, 0xf200, 0xf200, 0xf200, 0xf003, 0xf016, 0xf002,
+ 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf000, 0xf200, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01b, 0xf01c, 0xf01d,
+ 0xf036, 0xf037, 0xf038, 0xf200, 0xf200, 0xf200, 0xf602, 0xf200,
+ 0xf200, 0xf200, 0xf200,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KIGNORE ,KIGNORE ,KIGNORE ,KREBOOT ,K(KTf,23 ),K(KTf,25 ),KPAD_7 ,
+ KPAD_8 ,KPAD_9 ,KPAD_MI ,KCTRL ,K(KMt, 1 ),K(KMt,19 ),K(KMt, 4 ),K(KMt, 6 ),
+ K(KMt, 7 ),K(KMt, 8 ),K(KMt,10 ),K(KMt,11 ),K(KMt,12 ),KIGNORE ,KIGNORE ,KENTER ,
+ KPAD_4 ,KPAD_5 ,KPAD_6 ,KPAD_PL ,KSHIFT ,KIGNORE ,K(KMt,26 ),K(KMt,24 ),
+ K(KMt, 3 ),K(KMt,22 ),K(KMt, 2 ),K(KMt,14 ),K(KMt,13 ),KIGNORE ,KIGNORE ,KIGNORE ,
+ KSHIFT ,K(KTc,Kcu),KPAD_1 ,KPAD_2 ,KPAD_3 ,KCAPSLK ,KALT ,KIGNORE ,
+ KALTGR ,KCTRL ,K(KTc,Kcl),K(KTc,Kcd ),K(KTc,Kcr),KPAD_0 ,KREBOOT ,KPAD_EN ,
+ KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,
+ KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,
+ KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,KIGNORE ,
+};
+
+ushort *key_maps[MAX_NR_KEYMAPS] = {
+ plain_map, shift_map, altgr_map, 0,
+ ctrl_map, shift_ctrl_map, 0, 0,
+ alt_map, 0, 0, 0,
+ ctrl_alt_map, 0
+};
+
+unsigned int keymap_count = 7;
+
+/*
+ * Philosophy: most people do not define more strings, but they who do
+ * often want quite a lot of string space. So, we statically allocate
+ * the default and allocate dynamically in chunks of 512 bytes.
+ */
+
+char func_buf[] = {
+ '\033', '[', '[', 'A', 0,
+ '\033', '[', '[', 'B', 0,
+ '\033', '[', '[', 'C', 0,
+ '\033', '[', '[', 'D', 0,
+ '\033', '[', '[', 'E', 0,
+ '\033', '[', '1', '7', '~', 0,
+ '\033', '[', '1', '8', '~', 0,
+ '\033', '[', '1', '9', '~', 0,
+ '\033', '[', '2', '0', '~', 0,
+ '\033', '[', '2', '1', '~', 0,
+ '\033', '[', '2', '3', '~', 0,
+ '\033', '[', '2', '4', '~', 0,
+ '\033', '[', '2', '5', '~', 0,
+ '\033', '[', '2', '6', '~', 0,
+ '\033', '[', '2', '8', '~', 0,
+ '\033', '[', '2', '9', '~', 0,
+ '\033', '[', '3', '1', '~', 0,
+ '\033', '[', '3', '2', '~', 0,
+ '\033', '[', '3', '3', '~', 0,
+ '\033', '[', '3', '4', '~', 0,
+ '\033', '[', '1', '~', 0,
+ '\033', '[', '2', '~', 0,
+ '\033', '[', '3', '~', 0,
+ '\033', '[', '4', '~', 0,
+ '\033', '[', '5', '~', 0,
+ '\033', '[', '6', '~', 0,
+ '\033', '[', 'M', 0,
+ '\033', '[', 'P', 0,
+};
+
+char *funcbufptr = func_buf;
+int funcbufsize = sizeof(func_buf);
+int funcbufleft = 0; /* space left */
+
+char *func_table[MAX_NR_FUNC] = {
+ func_buf + 0,
+ func_buf + 5,
+ func_buf + 10,
+ func_buf + 15,
+ func_buf + 20,
+ func_buf + 25,
+ func_buf + 31,
+ func_buf + 37,
+ func_buf + 43,
+ func_buf + 49,
+ func_buf + 55,
+ func_buf + 61,
+ func_buf + 67,
+ func_buf + 73,
+ func_buf + 79,
+ func_buf + 85,
+ func_buf + 91,
+ func_buf + 97,
+ func_buf + 103,
+ func_buf + 109,
+ func_buf + 115,
+ func_buf + 120,
+ func_buf + 125,
+ func_buf + 130,
+ func_buf + 135,
+ func_buf + 140,
+ func_buf + 145,
+ 0,
+ 0,
+ func_buf + 149,
+ 0,
+};
+
+struct kbdiacr accent_table[MAX_DIACR] = {
+ {'`', 'A', '\300'}, {'`', 'a', '\340'},
+ {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
+ {'^', 'A', '\302'}, {'^', 'a', '\342'},
+ {'~', 'A', '\303'}, {'~', 'a', '\343'},
+ {'"', 'A', '\304'}, {'"', 'a', '\344'},
+ {'O', 'A', '\305'}, {'o', 'a', '\345'},
+ {'0', 'A', '\305'}, {'0', 'a', '\345'},
+ {'A', 'A', '\305'}, {'a', 'a', '\345'},
+ {'A', 'E', '\306'}, {'a', 'e', '\346'},
+ {',', 'C', '\307'}, {',', 'c', '\347'},
+ {'`', 'E', '\310'}, {'`', 'e', '\350'},
+ {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
+ {'^', 'E', '\312'}, {'^', 'e', '\352'},
+ {'"', 'E', '\313'}, {'"', 'e', '\353'},
+ {'`', 'I', '\314'}, {'`', 'i', '\354'},
+ {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
+ {'^', 'I', '\316'}, {'^', 'i', '\356'},
+ {'"', 'I', '\317'}, {'"', 'i', '\357'},
+ {'-', 'D', '\320'}, {'-', 'd', '\360'},
+ {'~', 'N', '\321'}, {'~', 'n', '\361'},
+ {'`', 'O', '\322'}, {'`', 'o', '\362'},
+ {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
+ {'^', 'O', '\324'}, {'^', 'o', '\364'},
+ {'~', 'O', '\325'}, {'~', 'o', '\365'},
+ {'"', 'O', '\326'}, {'"', 'o', '\366'},
+ {'/', 'O', '\330'}, {'/', 'o', '\370'},
+ {'`', 'U', '\331'}, {'`', 'u', '\371'},
+ {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
+ {'^', 'U', '\333'}, {'^', 'u', '\373'},
+ {'"', 'U', '\334'}, {'"', 'u', '\374'},
+ {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
+ {'T', 'H', '\336'}, {'t', 'h', '\376'},
+ {'s', 's', '\337'}, {'"', 'y', '\377'},
+ {'s', 'z', '\337'}, {'i', 'j', '\377'},
+};
+
+unsigned int accent_table_size = 68;
diff --git a/drivers/acorn/char/i2c.c b/drivers/acorn/char/i2c.c
new file mode 100644
index 00000000000..c22bb9dca1e
--- /dev/null
+++ b/drivers/acorn/char/i2c.c
@@ -0,0 +1,369 @@
+/*
+ * linux/drivers/acorn/char/i2c.c
+ *
+ * Copyright (C) 2000 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * ARM IOC/IOMD i2c driver.
+ *
+ * On Acorn machines, the following i2c devices are on the bus:
+ * - PCF8583 real time clock & static RAM
+ */
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/time.h>
+#include <linux/miscdevice.h>
+#include <linux/rtc.h>
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+#include <linux/fs.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/hardware/ioc.h>
+#include <asm/system.h>
+#include <asm/uaccess.h>
+
+#include "pcf8583.h"
+
+extern int (*set_rtc)(void);
+
+static struct i2c_client *rtc_client;
+static const unsigned char days_in_mon[] =
+ { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+#define CMOS_CHECKSUM (63)
+
+/*
+ * Acorn machines store the year in the static RAM at
+ * location 128.
+ */
+#define CMOS_YEAR (64 + 128)
+
+static inline int rtc_command(int cmd, void *data)
+{
+ int ret = -EIO;
+
+ if (rtc_client)
+ ret = rtc_client->driver->command(rtc_client, cmd, data);
+
+ return ret;
+}
+
+/*
+ * Update the century + year bytes in the CMOS RAM, ensuring
+ * that the check byte is correctly adjusted for the change.
+ */
+static int rtc_update_year(unsigned int new_year)
+{
+ unsigned char yr[2], chk;
+ struct mem cmos_year = { CMOS_YEAR, sizeof(yr), yr };
+ struct mem cmos_check = { CMOS_CHECKSUM, 1, &chk };
+ int ret;
+
+ ret = rtc_command(MEM_READ, &cmos_check);
+ if (ret)
+ goto out;
+ ret = rtc_command(MEM_READ, &cmos_year);
+ if (ret)
+ goto out;
+
+ chk -= yr[1] + yr[0];
+
+ yr[1] = new_year / 100;
+ yr[0] = new_year % 100;
+
+ chk += yr[1] + yr[0];
+
+ ret = rtc_command(MEM_WRITE, &cmos_year);
+ if (ret == 0)
+ ret = rtc_command(MEM_WRITE, &cmos_check);
+ out:
+ return ret;
+}
+
+/*
+ * Read the current RTC time and date, and update xtime.
+ */
+static void get_rtc_time(struct rtc_tm *rtctm, unsigned int *year)
+{
+ unsigned char ctrl, yr[2];
+ struct mem rtcmem = { CMOS_YEAR, sizeof(yr), yr };
+ int real_year, year_offset;
+
+ /*
+ * Ensure that the RTC is running.
+ */
+ rtc_command(RTC_GETCTRL, &ctrl);
+ if (ctrl & 0xc0) {
+ unsigned char new_ctrl = ctrl & ~0xc0;
+
+ printk(KERN_WARNING "RTC: resetting control %02x -> %02x\n",
+ ctrl, new_ctrl);
+
+ rtc_command(RTC_SETCTRL, &new_ctrl);
+ }
+
+ if (rtc_command(RTC_GETDATETIME, rtctm) ||
+ rtc_command(MEM_READ, &rtcmem))
+ return;
+
+ real_year = yr[0];
+
+ /*
+ * The RTC year holds the LSB two bits of the current
+ * year, which should reflect the LSB two bits of the
+ * CMOS copy of the year. Any difference indicates
+ * that we have to correct the CMOS version.
+ */
+ year_offset = rtctm->year_off - (real_year & 3);
+ if (year_offset < 0)
+ /*
+ * RTC year wrapped. Adjust it appropriately.
+ */
+ year_offset += 4;
+
+ *year = real_year + year_offset + yr[1] * 100;
+}
+
+static int set_rtc_time(struct rtc_tm *rtctm, unsigned int year)
+{
+ unsigned char leap;
+ int ret;
+
+ leap = (!(year % 4) && (year % 100)) || !(year % 400);
+
+ if (rtctm->mon > 12 || rtctm->mon == 0 || rtctm->mday == 0)
+ return -EINVAL;
+
+ if (rtctm->mday > (days_in_mon[rtctm->mon] + (rtctm->mon == 2 && leap)))
+ return -EINVAL;
+
+ if (rtctm->hours >= 24 || rtctm->mins >= 60 || rtctm->secs >= 60)
+ return -EINVAL;
+
+ /*
+ * The RTC's own 2-bit year must reflect the least
+ * significant two bits of the CMOS year.
+ */
+ rtctm->year_off = (year % 100) & 3;
+
+ ret = rtc_command(RTC_SETDATETIME, rtctm);
+ if (ret == 0)
+ ret = rtc_update_year(year);
+
+ return ret;
+}
+
+/*
+ * Set the RTC time only. Note that
+ * we do not touch the date.
+ */
+static int k_set_rtc_time(void)
+{
+ struct rtc_tm new_rtctm, old_rtctm;
+ unsigned long nowtime = xtime.tv_sec;
+
+ if (rtc_command(RTC_GETDATETIME, &old_rtctm))
+ return 0;
+
+ new_rtctm.cs = xtime.tv_nsec / 10000000;
+ new_rtctm.secs = nowtime % 60; nowtime /= 60;
+ new_rtctm.mins = nowtime % 60; nowtime /= 60;
+ new_rtctm.hours = nowtime % 24;
+
+ /*
+ * avoid writing when we're going to change the day
+ * of the month. We will retry in the next minute.
+ * This basically means that if the RTC must not drift
+ * by more than 1 minute in 11 minutes.
+ *
+ * [ rtc: 1/1/2000 23:58:00, real 2/1/2000 00:01:00,
+ * rtc gets set to 1/1/2000 00:01:00 ]
+ */
+ if ((old_rtctm.hours == 23 && old_rtctm.mins == 59) ||
+ (new_rtctm.hours == 23 && new_rtctm.mins == 59))
+ return 1;
+
+ return rtc_command(RTC_SETTIME, &new_rtctm);
+}
+
+static int rtc_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ unsigned int year;
+ struct rtc_time rtctm;
+ struct rtc_tm rtc_raw;
+
+ switch (cmd) {
+ case RTC_ALM_READ:
+ case RTC_ALM_SET:
+ break;
+
+ case RTC_RD_TIME:
+ memset(&rtctm, 0, sizeof(struct rtc_time));
+ get_rtc_time(&rtc_raw, &year);
+ rtctm.tm_sec = rtc_raw.secs;
+ rtctm.tm_min = rtc_raw.mins;
+ rtctm.tm_hour = rtc_raw.hours;
+ rtctm.tm_mday = rtc_raw.mday;
+ rtctm.tm_mon = rtc_raw.mon - 1; /* month starts at 0 */
+ rtctm.tm_year = year - 1900; /* starts at 1900 */
+ return copy_to_user((void *)arg, &rtctm, sizeof(rtctm))
+ ? -EFAULT : 0;
+
+ case RTC_SET_TIME:
+ if (!capable(CAP_SYS_TIME))
+ return -EACCES;
+
+ if (copy_from_user(&rtctm, (void *)arg, sizeof(rtctm)))
+ return -EFAULT;
+ rtc_raw.secs = rtctm.tm_sec;
+ rtc_raw.mins = rtctm.tm_min;
+ rtc_raw.hours = rtctm.tm_hour;
+ rtc_raw.mday = rtctm.tm_mday;
+ rtc_raw.mon = rtctm.tm_mon + 1;
+ year = rtctm.tm_year + 1900;
+ return set_rtc_time(&rtc_raw, year);
+ break;
+
+ case RTC_EPOCH_READ:
+ return put_user(1900, (unsigned long *)arg);
+
+ }
+ return -EINVAL;
+}
+
+static struct file_operations rtc_fops = {
+ .ioctl = rtc_ioctl,
+};
+
+static struct miscdevice rtc_dev = {
+ .minor = RTC_MINOR,
+ .name = "rtc",
+ .fops = &rtc_fops,
+};
+
+/* IOC / IOMD i2c driver */
+
+#define FORCE_ONES 0xdc
+#define SCL 0x02
+#define SDA 0x01
+
+/*
+ * We must preserve all non-i2c output bits in IOC_CONTROL.
+ * Note also that we need to preserve the value of SCL and
+ * SDA outputs as well (which may be different from the
+ * values read back from IOC_CONTROL).
+ */
+static u_int force_ones;
+
+static void ioc_setscl(void *data, int state)
+{
+ u_int ioc_control = ioc_readb(IOC_CONTROL) & ~(SCL | SDA);
+ u_int ones = force_ones;
+
+ if (state)
+ ones |= SCL;
+ else
+ ones &= ~SCL;
+
+ force_ones = ones;
+
+ ioc_writeb(ioc_control | ones, IOC_CONTROL);
+}
+
+static void ioc_setsda(void *data, int state)
+{
+ u_int ioc_control = ioc_readb(IOC_CONTROL) & ~(SCL | SDA);
+ u_int ones = force_ones;
+
+ if (state)
+ ones |= SDA;
+ else
+ ones &= ~SDA;
+
+ force_ones = ones;
+
+ ioc_writeb(ioc_control | ones, IOC_CONTROL);
+}
+
+static int ioc_getscl(void *data)
+{
+ return (ioc_readb(IOC_CONTROL) & SCL) != 0;
+}
+
+static int ioc_getsda(void *data)
+{
+ return (ioc_readb(IOC_CONTROL) & SDA) != 0;
+}
+
+static struct i2c_algo_bit_data ioc_data = {
+ .setsda = ioc_setsda,
+ .setscl = ioc_setscl,
+ .getsda = ioc_getsda,
+ .getscl = ioc_getscl,
+ .udelay = 80,
+ .mdelay = 80,
+ .timeout = 100
+};
+
+static int ioc_client_reg(struct i2c_client *client)
+{
+ if (client->driver->id == I2C_DRIVERID_PCF8583 &&
+ client->addr == 0x50) {
+ struct rtc_tm rtctm;
+ unsigned int year;
+ struct timespec tv;
+
+ rtc_client = client;
+ get_rtc_time(&rtctm, &year);
+
+ tv.tv_nsec = rtctm.cs * 10000000;
+ tv.tv_sec = mktime(year, rtctm.mon, rtctm.mday,
+ rtctm.hours, rtctm.mins, rtctm.secs);
+ do_settimeofday(&tv);
+ set_rtc = k_set_rtc_time;
+ }
+
+ return 0;
+}
+
+static int ioc_client_unreg(struct i2c_client *client)
+{
+ if (client == rtc_client) {
+ set_rtc = NULL;
+ rtc_client = NULL;
+ }
+
+ return 0;
+}
+
+static struct i2c_adapter ioc_ops = {
+ .id = I2C_HW_B_IOC,
+ .algo_data = &ioc_data,
+ .client_register = ioc_client_reg,
+ .client_unregister = ioc_client_unreg,
+};
+
+static int __init i2c_ioc_init(void)
+{
+ int ret;
+
+ force_ones = FORCE_ONES | SCL | SDA;
+
+ ret = i2c_bit_add_bus(&ioc_ops);
+
+ if (ret >= 0){
+ ret = misc_register(&rtc_dev);
+ if(ret < 0)
+ i2c_bit_del_bus(&ioc_ops);
+ }
+
+ return ret;
+}
+
+__initcall(i2c_ioc_init);
diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c
new file mode 100644
index 00000000000..ad7ae7ab892
--- /dev/null
+++ b/drivers/acorn/char/pcf8583.c
@@ -0,0 +1,239 @@
+/*
+ * linux/drivers/acorn/char/pcf8583.c
+ *
+ * Copyright (C) 2000 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Driver for PCF8583 RTC & RAM chip
+ */
+#include <linux/i2c.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/mc146818rtc.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/bcd.h>
+
+#include "pcf8583.h"
+
+static struct i2c_driver pcf8583_driver;
+
+static unsigned short ignore[] = { I2C_CLIENT_END };
+static unsigned short normal_addr[] = { 0x50, I2C_CLIENT_END };
+
+static struct i2c_client_address_data addr_data = {
+ .normal_i2c = normal_addr,
+ .normal_i2c_range = ignore,
+ .probe = ignore,
+ .probe_range = ignore,
+ .ignore = ignore,
+ .ignore_range = ignore,
+ .force = ignore,
+};
+
+#define DAT(x) ((unsigned int)(x->dev.driver_data))
+
+static int
+pcf8583_attach(struct i2c_adapter *adap, int addr, int kind)
+{
+ struct i2c_client *c;
+ unsigned char buf[1], ad[1] = { 0 };
+ struct i2c_msg msgs[2] = {
+ { addr, 0, 1, ad },
+ { addr, I2C_M_RD, 1, buf }
+ };
+
+ c = kmalloc(sizeof(*c), GFP_KERNEL);
+ if (!c)
+ return -ENOMEM;
+
+ memset(c, 0, sizeof(*c));
+ c->addr = addr;
+ c->adapter = adap;
+ c->driver = &pcf8583_driver;
+
+ if (i2c_transfer(c->adapter, msgs, 2) == 2)
+ DAT(c) = buf[0];
+
+ return i2c_attach_client(c);
+}
+
+static int
+pcf8583_probe(struct i2c_adapter *adap)
+{
+ return i2c_probe(adap, &addr_data, pcf8583_attach);
+}
+
+static int
+pcf8583_detach(struct i2c_client *client)
+{
+ i2c_detach_client(client);
+ kfree(client);
+ return 0;
+}
+
+static int
+pcf8583_get_datetime(struct i2c_client *client, struct rtc_tm *dt)
+{
+ unsigned char buf[8], addr[1] = { 1 };
+ struct i2c_msg msgs[2] = {
+ { client->addr, 0, 1, addr },
+ { client->addr, I2C_M_RD, 6, buf }
+ };
+ int ret = -EIO;
+
+ memset(buf, 0, sizeof(buf));
+
+ ret = i2c_transfer(client->adapter, msgs, 2);
+ if (ret == 2) {
+ dt->year_off = buf[4] >> 6;
+ dt->wday = buf[5] >> 5;
+
+ buf[4] &= 0x3f;
+ buf[5] &= 0x1f;
+
+ dt->cs = BCD_TO_BIN(buf[0]);
+ dt->secs = BCD_TO_BIN(buf[1]);
+ dt->mins = BCD_TO_BIN(buf[2]);
+ dt->hours = BCD_TO_BIN(buf[3]);
+ dt->mday = BCD_TO_BIN(buf[4]);
+ dt->mon = BCD_TO_BIN(buf[5]);
+
+ ret = 0;
+ }
+
+ return ret;
+}
+
+static int
+pcf8583_set_datetime(struct i2c_client *client, struct rtc_tm *dt, int datetoo)
+{
+ unsigned char buf[8];
+ int ret, len = 6;
+
+ buf[0] = 0;
+ buf[1] = DAT(client) | 0x80;
+ buf[2] = BIN_TO_BCD(dt->cs);
+ buf[3] = BIN_TO_BCD(dt->secs);
+ buf[4] = BIN_TO_BCD(dt->mins);
+ buf[5] = BIN_TO_BCD(dt->hours);
+
+ if (datetoo) {
+ len = 8;
+ buf[6] = BIN_TO_BCD(dt->mday) | (dt->year_off << 6);
+ buf[7] = BIN_TO_BCD(dt->mon) | (dt->wday << 5);
+ }
+
+ ret = i2c_master_send(client, (char *)buf, len);
+ if (ret == len)
+ ret = 0;
+
+ buf[1] = DAT(client);
+ i2c_master_send(client, (char *)buf, 2);
+
+ return ret;
+}
+
+static int
+pcf8583_get_ctrl(struct i2c_client *client, unsigned char *ctrl)
+{
+ *ctrl = DAT(client);
+ return 0;
+}
+
+static int
+pcf8583_set_ctrl(struct i2c_client *client, unsigned char *ctrl)
+{
+ unsigned char buf[2];
+
+ buf[0] = 0;
+ buf[1] = *ctrl;
+ DAT(client) = *ctrl;
+
+ return i2c_master_send(client, (char *)buf, 2);
+}
+
+static int
+pcf8583_read_mem(struct i2c_client *client, struct mem *mem)
+{
+ unsigned char addr[1];
+ struct i2c_msg msgs[2] = {
+ { client->addr, 0, 1, addr },
+ { client->addr, I2C_M_RD, 0, mem->data }
+ };
+
+ if (mem->loc < 8)
+ return -EINVAL;
+
+ addr[0] = mem->loc;
+ msgs[1].len = mem->nr;
+
+ return i2c_transfer(client->adapter, msgs, 2) == 2 ? 0 : -EIO;
+}
+
+static int
+pcf8583_write_mem(struct i2c_client *client, struct mem *mem)
+{
+ unsigned char addr[1];
+ struct i2c_msg msgs[2] = {
+ { client->addr, 0, 1, addr },
+ { client->addr, 0, 0, mem->data }
+ };
+
+ if (mem->loc < 8)
+ return -EINVAL;
+
+ addr[0] = mem->loc;
+ msgs[1].len = mem->nr;
+
+ return i2c_transfer(client->adapter, msgs, 2) == 2 ? 0 : -EIO;
+}
+
+static int
+pcf8583_command(struct i2c_client *client, unsigned int cmd, void *arg)
+{
+ switch (cmd) {
+ case RTC_GETDATETIME:
+ return pcf8583_get_datetime(client, arg);
+
+ case RTC_SETTIME:
+ return pcf8583_set_datetime(client, arg, 0);
+
+ case RTC_SETDATETIME:
+ return pcf8583_set_datetime(client, arg, 1);
+
+ case RTC_GETCTRL:
+ return pcf8583_get_ctrl(client, arg);
+
+ case RTC_SETCTRL:
+ return pcf8583_set_ctrl(client, arg);
+
+ case MEM_READ:
+ return pcf8583_read_mem(client, arg);
+
+ case MEM_WRITE:
+ return pcf8583_write_mem(client, arg);
+
+ default:
+ return -EINVAL;
+ }
+}
+
+static struct i2c_driver pcf8583_driver = {
+ .name = "PCF8583",
+ .id = I2C_DRIVERID_PCF8583,
+ .flags = I2C_DF_NOTIFY,
+ .attach_adapter = pcf8583_probe,
+ .detach_client = pcf8583_detach,
+ .command = pcf8583_command
+};
+
+static __init int pcf8583_init(void)
+{
+ return i2c_add_driver(&pcf8583_driver);
+}
+
+__initcall(pcf8583_init);
diff --git a/drivers/acorn/char/pcf8583.h b/drivers/acorn/char/pcf8583.h
new file mode 100644
index 00000000000..847f7fdb876
--- /dev/null
+++ b/drivers/acorn/char/pcf8583.h
@@ -0,0 +1,41 @@
+/*
+ * linux/drivers/acorn/char/pcf8583.h
+ *
+ * Copyright (C) 2000 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+struct rtc_tm {
+ unsigned char cs;
+ unsigned char secs;
+ unsigned char mins;
+ unsigned char hours;
+ unsigned char mday;
+ unsigned char mon;
+ unsigned char year_off;
+ unsigned char wday;
+};
+
+struct mem {
+ unsigned int loc;
+ unsigned int nr;
+ unsigned char *data;
+};
+
+#define RTC_GETDATETIME 0
+#define RTC_SETTIME 1
+#define RTC_SETDATETIME 2
+#define RTC_GETCTRL 3
+#define RTC_SETCTRL 4
+#define MEM_READ 5
+#define MEM_WRITE 6
+
+#define CTRL_STOP 0x80
+#define CTRL_HOLD 0x40
+#define CTRL_32KHZ 0x00
+#define CTRL_MASK 0x08
+#define CTRL_ALARMEN 0x04
+#define CTRL_ALARM 0x02
+#define CTRL_TIMER 0x01