diff options
Diffstat (limited to 'arch/mips/txx9/generic')
-rw-r--r-- | arch/mips/txx9/generic/Makefile | 10 | ||||
-rw-r--r-- | arch/mips/txx9/generic/dbgio.c | 48 | ||||
-rw-r--r-- | arch/mips/txx9/generic/irq_tx4927.c | 64 | ||||
-rw-r--r-- | arch/mips/txx9/generic/irq_tx4938.c | 48 | ||||
-rw-r--r-- | arch/mips/txx9/generic/mem_tx4927.c | 141 | ||||
-rw-r--r-- | arch/mips/txx9/generic/mem_tx4938.c | 124 | ||||
-rw-r--r-- | arch/mips/txx9/generic/smsc_fdc37m81x.c | 172 |
7 files changed, 607 insertions, 0 deletions
diff --git a/arch/mips/txx9/generic/Makefile b/arch/mips/txx9/generic/Makefile new file mode 100644 index 000000000000..8cb4a7e81473 --- /dev/null +++ b/arch/mips/txx9/generic/Makefile | |||
@@ -0,0 +1,10 @@ | |||
1 | # | ||
2 | # Makefile for common code for TXx9 based systems | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_TOSHIBA_RBTX4927) += mem_tx4927.o irq_tx4927.o | ||
6 | obj-$(CONFIG_TOSHIBA_RBTX4938) += mem_tx4938.o irq_tx4938.o | ||
7 | obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o | ||
8 | obj-$(CONFIG_KGDB) += dbgio.o | ||
9 | |||
10 | EXTRA_CFLAGS += -Werror | ||
diff --git a/arch/mips/txx9/generic/dbgio.c b/arch/mips/txx9/generic/dbgio.c new file mode 100644 index 000000000000..33b9c672a322 --- /dev/null +++ b/arch/mips/txx9/generic/dbgio.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/tx4938/common/dbgio.c | ||
3 | * | ||
4 | * kgdb interface for gdb | ||
5 | * | ||
6 | * Author: MontaVista Software, Inc. | ||
7 | * source@mvista.com | ||
8 | * | ||
9 | * Copyright 2005 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the | ||
13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
14 | * option) any later version. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
24 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
25 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | * You should have received a copy of the GNU General Public License along | ||
28 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
29 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
30 | * | ||
31 | * Support for TX4938 in 2.6 - Hiroshi DOYU <Hiroshi_DOYU@montavista.co.jp> | ||
32 | */ | ||
33 | |||
34 | #include <linux/types> | ||
35 | |||
36 | extern u8 txx9_sio_kdbg_rd(void); | ||
37 | extern int txx9_sio_kdbg_wr( u8 ch ); | ||
38 | |||
39 | u8 getDebugChar(void) | ||
40 | { | ||
41 | return (txx9_sio_kdbg_rd()); | ||
42 | } | ||
43 | |||
44 | int putDebugChar(u8 byte) | ||
45 | { | ||
46 | return (txx9_sio_kdbg_wr(byte)); | ||
47 | } | ||
48 | |||
diff --git a/arch/mips/txx9/generic/irq_tx4927.c b/arch/mips/txx9/generic/irq_tx4927.c new file mode 100644 index 000000000000..685ecc2ed551 --- /dev/null +++ b/arch/mips/txx9/generic/irq_tx4927.c | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Common tx4927 irq handler | ||
3 | * | ||
4 | * Author: MontaVista Software, Inc. | ||
5 | * source@mvista.com | ||
6 | * | ||
7 | * under the terms of the GNU General Public License as published by the | ||
8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
9 | * option) any later version. | ||
10 | * | ||
11 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
12 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
13 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
14 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
15 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
16 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
17 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
18 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
19 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
20 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License along | ||
23 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
24 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <asm/irq_cpu.h> | ||
29 | #include <asm/mipsregs.h> | ||
30 | #ifdef CONFIG_TOSHIBA_RBTX4927 | ||
31 | #include <asm/txx9/rbtx4927.h> | ||
32 | #endif | ||
33 | |||
34 | void __init tx4927_irq_init(void) | ||
35 | { | ||
36 | mips_cpu_irq_init(); | ||
37 | txx9_irq_init(TX4927_IRC_REG); | ||
38 | set_irq_chained_handler(TX4927_IRQ_NEST_PIC_ON_CP0, handle_simple_irq); | ||
39 | } | ||
40 | |||
41 | asmlinkage void plat_irq_dispatch(void) | ||
42 | { | ||
43 | unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM; | ||
44 | |||
45 | if (pending & STATUSF_IP7) /* cpu timer */ | ||
46 | do_IRQ(TX4927_IRQ_CPU_TIMER); | ||
47 | else if (pending & STATUSF_IP2) { /* tx4927 pic */ | ||
48 | int irq = txx9_irq(); | ||
49 | #ifdef CONFIG_TOSHIBA_RBTX4927 | ||
50 | if (irq == TX4927_IRQ_NEST_EXT_ON_PIC) | ||
51 | irq = toshiba_rbtx4927_irq_nested(irq); | ||
52 | #endif | ||
53 | if (unlikely(irq < 0)) { | ||
54 | spurious_interrupt(); | ||
55 | return; | ||
56 | } | ||
57 | do_IRQ(irq); | ||
58 | } else if (pending & STATUSF_IP0) /* user line 0 */ | ||
59 | do_IRQ(TX4927_IRQ_USER0); | ||
60 | else if (pending & STATUSF_IP1) /* user line 1 */ | ||
61 | do_IRQ(TX4927_IRQ_USER1); | ||
62 | else | ||
63 | spurious_interrupt(); | ||
64 | } | ||
diff --git a/arch/mips/txx9/generic/irq_tx4938.c b/arch/mips/txx9/generic/irq_tx4938.c new file mode 100644 index 000000000000..0886d9138818 --- /dev/null +++ b/arch/mips/txx9/generic/irq_tx4938.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/tx4938/common/irq.c | ||
3 | * | ||
4 | * Common tx4938 irq handler | ||
5 | * Copyright (C) 2000-2001 Toshiba Corporation | ||
6 | * | ||
7 | * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the | ||
8 | * terms of the GNU General Public License version 2. This program is | ||
9 | * licensed "as is" without any warranty of any kind, whether express | ||
10 | * or implied. | ||
11 | * | ||
12 | * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) | ||
13 | */ | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <asm/irq_cpu.h> | ||
17 | #include <asm/mipsregs.h> | ||
18 | #include <asm/txx9/rbtx4938.h> | ||
19 | |||
20 | void __init | ||
21 | tx4938_irq_init(void) | ||
22 | { | ||
23 | mips_cpu_irq_init(); | ||
24 | txx9_irq_init(TX4938_IRC_REG); | ||
25 | set_irq_chained_handler(TX4938_IRQ_NEST_PIC_ON_CP0, handle_simple_irq); | ||
26 | } | ||
27 | |||
28 | int toshiba_rbtx4938_irq_nested(int irq); | ||
29 | |||
30 | asmlinkage void plat_irq_dispatch(void) | ||
31 | { | ||
32 | unsigned int pending = read_c0_cause() & read_c0_status(); | ||
33 | |||
34 | if (pending & STATUSF_IP7) | ||
35 | do_IRQ(TX4938_IRQ_CPU_TIMER); | ||
36 | else if (pending & STATUSF_IP2) { | ||
37 | int irq = txx9_irq(); | ||
38 | if (irq == TX4938_IRQ_PIC_BEG + TX4938_IR_INT(0)) | ||
39 | irq = toshiba_rbtx4938_irq_nested(irq); | ||
40 | if (irq >= 0) | ||
41 | do_IRQ(irq); | ||
42 | else | ||
43 | spurious_interrupt(); | ||
44 | } else if (pending & STATUSF_IP1) | ||
45 | do_IRQ(TX4938_IRQ_USER1); | ||
46 | else if (pending & STATUSF_IP0) | ||
47 | do_IRQ(TX4938_IRQ_USER0); | ||
48 | } | ||
diff --git a/arch/mips/txx9/generic/mem_tx4927.c b/arch/mips/txx9/generic/mem_tx4927.c new file mode 100644 index 000000000000..12dfc377bf2f --- /dev/null +++ b/arch/mips/txx9/generic/mem_tx4927.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/tx4927/common/tx4927_prom.c | ||
3 | * | ||
4 | * common tx4927 memory interface | ||
5 | * | ||
6 | * Author: MontaVista Software, Inc. | ||
7 | * source@mvista.com | ||
8 | * | ||
9 | * Copyright 2001-2002 MontaVista Software Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the | ||
13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
14 | * option) any later version. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
24 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
25 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | * You should have received a copy of the GNU General Public License along | ||
28 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
29 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
30 | */ | ||
31 | |||
32 | #include <linux/init.h> | ||
33 | #include <linux/types.h> | ||
34 | #include <linux/io.h> | ||
35 | |||
36 | static unsigned int __init tx4927_process_sdccr(unsigned long addr) | ||
37 | { | ||
38 | u64 val; | ||
39 | unsigned int sdccr_ce; | ||
40 | unsigned int sdccr_bs; | ||
41 | unsigned int sdccr_rs; | ||
42 | unsigned int sdccr_cs; | ||
43 | unsigned int sdccr_mw; | ||
44 | unsigned int bs = 0; | ||
45 | unsigned int rs = 0; | ||
46 | unsigned int cs = 0; | ||
47 | unsigned int mw = 0; | ||
48 | unsigned int msize = 0; | ||
49 | |||
50 | val = __raw_readq((void __iomem *)addr); | ||
51 | |||
52 | /* MVMCP -- need #defs for these bits masks */ | ||
53 | sdccr_ce = ((val & (1 << 10)) >> 10); | ||
54 | sdccr_bs = ((val & (1 << 8)) >> 8); | ||
55 | sdccr_rs = ((val & (3 << 5)) >> 5); | ||
56 | sdccr_cs = ((val & (3 << 2)) >> 2); | ||
57 | sdccr_mw = ((val & (1 << 0)) >> 0); | ||
58 | |||
59 | if (sdccr_ce) { | ||
60 | switch (sdccr_bs) { | ||
61 | case 0:{ | ||
62 | bs = 2; | ||
63 | break; | ||
64 | } | ||
65 | case 1:{ | ||
66 | bs = 4; | ||
67 | break; | ||
68 | } | ||
69 | } | ||
70 | switch (sdccr_rs) { | ||
71 | case 0:{ | ||
72 | rs = 2048; | ||
73 | break; | ||
74 | } | ||
75 | case 1:{ | ||
76 | rs = 4096; | ||
77 | break; | ||
78 | } | ||
79 | case 2:{ | ||
80 | rs = 8192; | ||
81 | break; | ||
82 | } | ||
83 | case 3:{ | ||
84 | rs = 0; | ||
85 | break; | ||
86 | } | ||
87 | } | ||
88 | switch (sdccr_cs) { | ||
89 | case 0:{ | ||
90 | cs = 256; | ||
91 | break; | ||
92 | } | ||
93 | case 1:{ | ||
94 | cs = 512; | ||
95 | break; | ||
96 | } | ||
97 | case 2:{ | ||
98 | cs = 1024; | ||
99 | break; | ||
100 | } | ||
101 | case 3:{ | ||
102 | cs = 2048; | ||
103 | break; | ||
104 | } | ||
105 | } | ||
106 | switch (sdccr_mw) { | ||
107 | case 0:{ | ||
108 | mw = 8; | ||
109 | break; | ||
110 | } /* 8 bytes = 64 bits */ | ||
111 | case 1:{ | ||
112 | mw = 4; | ||
113 | break; | ||
114 | } /* 4 bytes = 32 bits */ | ||
115 | } | ||
116 | } | ||
117 | |||
118 | /* bytes per chip MB per chip num chips */ | ||
119 | msize = (((rs * cs * mw) / (1024 * 1024)) * bs); | ||
120 | |||
121 | return (msize); | ||
122 | } | ||
123 | |||
124 | |||
125 | unsigned int __init tx4927_get_mem_size(void) | ||
126 | { | ||
127 | unsigned int c0; | ||
128 | unsigned int c1; | ||
129 | unsigned int c2; | ||
130 | unsigned int c3; | ||
131 | unsigned int total; | ||
132 | |||
133 | /* MVMCP -- need #defs for these registers */ | ||
134 | c0 = tx4927_process_sdccr(0xff1f8000); | ||
135 | c1 = tx4927_process_sdccr(0xff1f8008); | ||
136 | c2 = tx4927_process_sdccr(0xff1f8010); | ||
137 | c3 = tx4927_process_sdccr(0xff1f8018); | ||
138 | total = c0 + c1 + c2 + c3; | ||
139 | |||
140 | return (total); | ||
141 | } | ||
diff --git a/arch/mips/txx9/generic/mem_tx4938.c b/arch/mips/txx9/generic/mem_tx4938.c new file mode 100644 index 000000000000..20baeaeba4cd --- /dev/null +++ b/arch/mips/txx9/generic/mem_tx4938.c | |||
@@ -0,0 +1,124 @@ | |||
1 | /* | ||
2 | * linux/arch/mips/tx4938/common/prom.c | ||
3 | * | ||
4 | * common tx4938 memory interface | ||
5 | * Copyright (C) 2000-2001 Toshiba Corporation | ||
6 | * | ||
7 | * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the | ||
8 | * terms of the GNU General Public License version 2. This program is | ||
9 | * licensed "as is" without any warranty of any kind, whether express | ||
10 | * or implied. | ||
11 | * | ||
12 | * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) | ||
13 | */ | ||
14 | |||
15 | #include <linux/init.h> | ||
16 | #include <linux/types.h> | ||
17 | #include <linux/io.h> | ||
18 | |||
19 | static unsigned int __init | ||
20 | tx4938_process_sdccr(u64 * addr) | ||
21 | { | ||
22 | u64 val; | ||
23 | unsigned int sdccr_ce; | ||
24 | unsigned int sdccr_rs; | ||
25 | unsigned int sdccr_cs; | ||
26 | unsigned int sdccr_mw; | ||
27 | unsigned int rs = 0; | ||
28 | unsigned int cs = 0; | ||
29 | unsigned int mw = 0; | ||
30 | unsigned int bc = 4; | ||
31 | unsigned int msize = 0; | ||
32 | |||
33 | val = ____raw_readq((void __iomem *)addr); | ||
34 | |||
35 | /* MVMCP -- need #defs for these bits masks */ | ||
36 | sdccr_ce = ((val & (1 << 10)) >> 10); | ||
37 | sdccr_rs = ((val & (3 << 5)) >> 5); | ||
38 | sdccr_cs = ((val & (7 << 2)) >> 2); | ||
39 | sdccr_mw = ((val & (1 << 0)) >> 0); | ||
40 | |||
41 | if (sdccr_ce) { | ||
42 | switch (sdccr_rs) { | ||
43 | case 0:{ | ||
44 | rs = 2048; | ||
45 | break; | ||
46 | } | ||
47 | case 1:{ | ||
48 | rs = 4096; | ||
49 | break; | ||
50 | } | ||
51 | case 2:{ | ||
52 | rs = 8192; | ||
53 | break; | ||
54 | } | ||
55 | default:{ | ||
56 | rs = 0; | ||
57 | break; | ||
58 | } | ||
59 | } | ||
60 | switch (sdccr_cs) { | ||
61 | case 0:{ | ||
62 | cs = 256; | ||
63 | break; | ||
64 | } | ||
65 | case 1:{ | ||
66 | cs = 512; | ||
67 | break; | ||
68 | } | ||
69 | case 2:{ | ||
70 | cs = 1024; | ||
71 | break; | ||
72 | } | ||
73 | case 3:{ | ||
74 | cs = 2048; | ||
75 | break; | ||
76 | } | ||
77 | case 4:{ | ||
78 | cs = 4096; | ||
79 | break; | ||
80 | } | ||
81 | default:{ | ||
82 | cs = 0; | ||
83 | break; | ||
84 | } | ||
85 | } | ||
86 | switch (sdccr_mw) { | ||
87 | case 0:{ | ||
88 | mw = 8; | ||
89 | break; | ||
90 | } /* 8 bytes = 64 bits */ | ||
91 | case 1:{ | ||
92 | mw = 4; | ||
93 | break; | ||
94 | } /* 4 bytes = 32 bits */ | ||
95 | } | ||
96 | } | ||
97 | |||
98 | /* bytes per chip MB per chip bank count */ | ||
99 | msize = (((rs * cs * mw) / (1024 * 1024)) * (bc)); | ||
100 | |||
101 | /* MVMCP -- bc hard coded to 4 from table 9.3.1 */ | ||
102 | /* boad supports bc=2 but no way to detect */ | ||
103 | |||
104 | return (msize); | ||
105 | } | ||
106 | |||
107 | unsigned int __init | ||
108 | tx4938_get_mem_size(void) | ||
109 | { | ||
110 | unsigned int c0; | ||
111 | unsigned int c1; | ||
112 | unsigned int c2; | ||
113 | unsigned int c3; | ||
114 | unsigned int total; | ||
115 | |||
116 | /* MVMCP -- need #defs for these registers */ | ||
117 | c0 = tx4938_process_sdccr((u64 *) 0xff1f8000); | ||
118 | c1 = tx4938_process_sdccr((u64 *) 0xff1f8008); | ||
119 | c2 = tx4938_process_sdccr((u64 *) 0xff1f8010); | ||
120 | c3 = tx4938_process_sdccr((u64 *) 0xff1f8018); | ||
121 | total = c0 + c1 + c2 + c3; | ||
122 | |||
123 | return (total); | ||
124 | } | ||
diff --git a/arch/mips/txx9/generic/smsc_fdc37m81x.c b/arch/mips/txx9/generic/smsc_fdc37m81x.c new file mode 100644 index 000000000000..69e487467fa5 --- /dev/null +++ b/arch/mips/txx9/generic/smsc_fdc37m81x.c | |||
@@ -0,0 +1,172 @@ | |||
1 | /* | ||
2 | * Interface for smsc fdc48m81x Super IO chip | ||
3 | * | ||
4 | * Author: MontaVista Software, Inc. source@mvista.com | ||
5 | * | ||
6 | * 2001-2003 (c) MontaVista Software, Inc. This file is licensed under | ||
7 | * the terms of the GNU General Public License version 2. This program | ||
8 | * is licensed "as is" without any warranty of any kind, whether express | ||
9 | * or implied. | ||
10 | * | ||
11 | * Copyright 2004 (c) MontaVista Software, Inc. | ||
12 | */ | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <asm/io.h> | ||
16 | #include <asm/txx9/smsc_fdc37m81x.h> | ||
17 | |||
18 | #define DEBUG | ||
19 | |||
20 | /* Common Registers */ | ||
21 | #define SMSC_FDC37M81X_CONFIG_INDEX 0x00 | ||
22 | #define SMSC_FDC37M81X_CONFIG_DATA 0x01 | ||
23 | #define SMSC_FDC37M81X_CONF 0x02 | ||
24 | #define SMSC_FDC37M81X_INDEX 0x03 | ||
25 | #define SMSC_FDC37M81X_DNUM 0x07 | ||
26 | #define SMSC_FDC37M81X_DID 0x20 | ||
27 | #define SMSC_FDC37M81X_DREV 0x21 | ||
28 | #define SMSC_FDC37M81X_PCNT 0x22 | ||
29 | #define SMSC_FDC37M81X_PMGT 0x23 | ||
30 | #define SMSC_FDC37M81X_OSC 0x24 | ||
31 | #define SMSC_FDC37M81X_CONFPA0 0x26 | ||
32 | #define SMSC_FDC37M81X_CONFPA1 0x27 | ||
33 | #define SMSC_FDC37M81X_TEST4 0x2B | ||
34 | #define SMSC_FDC37M81X_TEST5 0x2C | ||
35 | #define SMSC_FDC37M81X_TEST1 0x2D | ||
36 | #define SMSC_FDC37M81X_TEST2 0x2E | ||
37 | #define SMSC_FDC37M81X_TEST3 0x2F | ||
38 | |||
39 | /* Logical device numbers */ | ||
40 | #define SMSC_FDC37M81X_FDD 0x00 | ||
41 | #define SMSC_FDC37M81X_SERIAL1 0x04 | ||
42 | #define SMSC_FDC37M81X_SERIAL2 0x05 | ||
43 | #define SMSC_FDC37M81X_KBD 0x07 | ||
44 | |||
45 | /* Logical device Config Registers */ | ||
46 | #define SMSC_FDC37M81X_ACTIVE 0x30 | ||
47 | #define SMSC_FDC37M81X_BASEADDR0 0x60 | ||
48 | #define SMSC_FDC37M81X_BASEADDR1 0x61 | ||
49 | #define SMSC_FDC37M81X_INT 0x70 | ||
50 | #define SMSC_FDC37M81X_INT2 0x72 | ||
51 | #define SMSC_FDC37M81X_MODE 0xF0 | ||
52 | |||
53 | /* Chip Config Values */ | ||
54 | #define SMSC_FDC37M81X_CONFIG_ENTER 0x55 | ||
55 | #define SMSC_FDC37M81X_CONFIG_EXIT 0xaa | ||
56 | #define SMSC_FDC37M81X_CHIP_ID 0x4d | ||
57 | |||
58 | static unsigned long g_smsc_fdc37m81x_base = 0; | ||
59 | |||
60 | static inline unsigned char smsc_fdc37m81x_rd(unsigned char index) | ||
61 | { | ||
62 | outb(index, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX); | ||
63 | |||
64 | return inb(g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_DATA); | ||
65 | } | ||
66 | |||
67 | static inline void smsc_dc37m81x_wr(unsigned char index, unsigned char data) | ||
68 | { | ||
69 | outb(index, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX); | ||
70 | outb(data, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_DATA); | ||
71 | } | ||
72 | |||
73 | void smsc_fdc37m81x_config_beg(void) | ||
74 | { | ||
75 | if (g_smsc_fdc37m81x_base) { | ||
76 | outb(SMSC_FDC37M81X_CONFIG_ENTER, | ||
77 | g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | void smsc_fdc37m81x_config_end(void) | ||
82 | { | ||
83 | if (g_smsc_fdc37m81x_base) | ||
84 | outb(SMSC_FDC37M81X_CONFIG_EXIT, | ||
85 | g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX); | ||
86 | } | ||
87 | |||
88 | u8 smsc_fdc37m81x_config_get(u8 reg) | ||
89 | { | ||
90 | u8 val = 0; | ||
91 | |||
92 | if (g_smsc_fdc37m81x_base) | ||
93 | val = smsc_fdc37m81x_rd(reg); | ||
94 | |||
95 | return val; | ||
96 | } | ||
97 | |||
98 | void smsc_fdc37m81x_config_set(u8 reg, u8 val) | ||
99 | { | ||
100 | if (g_smsc_fdc37m81x_base) | ||
101 | smsc_dc37m81x_wr(reg, val); | ||
102 | } | ||
103 | |||
104 | unsigned long __init smsc_fdc37m81x_init(unsigned long port) | ||
105 | { | ||
106 | const int field = sizeof(unsigned long) * 2; | ||
107 | u8 chip_id; | ||
108 | |||
109 | if (g_smsc_fdc37m81x_base) | ||
110 | printk("smsc_fdc37m81x_init() stepping on old base=0x%0*lx\n", | ||
111 | field, g_smsc_fdc37m81x_base); | ||
112 | |||
113 | g_smsc_fdc37m81x_base = port; | ||
114 | |||
115 | smsc_fdc37m81x_config_beg(); | ||
116 | |||
117 | chip_id = smsc_fdc37m81x_rd(SMSC_FDC37M81X_DID); | ||
118 | if (chip_id == SMSC_FDC37M81X_CHIP_ID) | ||
119 | smsc_fdc37m81x_config_end(); | ||
120 | else { | ||
121 | printk("smsc_fdc37m81x_init() unknow chip id 0x%02x\n", | ||
122 | chip_id); | ||
123 | g_smsc_fdc37m81x_base = 0; | ||
124 | } | ||
125 | |||
126 | return g_smsc_fdc37m81x_base; | ||
127 | } | ||
128 | |||
129 | #ifdef DEBUG | ||
130 | void smsc_fdc37m81x_config_dump_one(char *key, u8 dev, u8 reg) | ||
131 | { | ||
132 | printk("%s: dev=0x%02x reg=0x%02x val=0x%02x\n", key, dev, reg, | ||
133 | smsc_fdc37m81x_rd(reg)); | ||
134 | } | ||
135 | |||
136 | void smsc_fdc37m81x_config_dump(void) | ||
137 | { | ||
138 | u8 orig; | ||
139 | char *fname = "smsc_fdc37m81x_config_dump()"; | ||
140 | |||
141 | smsc_fdc37m81x_config_beg(); | ||
142 | |||
143 | orig = smsc_fdc37m81x_rd(SMSC_FDC37M81X_DNUM); | ||
144 | |||
145 | printk("%s: common\n", fname); | ||
146 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
147 | SMSC_FDC37M81X_DNUM); | ||
148 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
149 | SMSC_FDC37M81X_DID); | ||
150 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
151 | SMSC_FDC37M81X_DREV); | ||
152 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
153 | SMSC_FDC37M81X_PCNT); | ||
154 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE, | ||
155 | SMSC_FDC37M81X_PMGT); | ||
156 | |||
157 | printk("%s: keyboard\n", fname); | ||
158 | smsc_dc37m81x_wr(SMSC_FDC37M81X_DNUM, SMSC_FDC37M81X_KBD); | ||
159 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD, | ||
160 | SMSC_FDC37M81X_ACTIVE); | ||
161 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD, | ||
162 | SMSC_FDC37M81X_INT); | ||
163 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD, | ||
164 | SMSC_FDC37M81X_INT2); | ||
165 | smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD, | ||
166 | SMSC_FDC37M81X_LDCR_F0); | ||
167 | |||
168 | smsc_dc37m81x_wr(SMSC_FDC37M81X_DNUM, orig); | ||
169 | |||
170 | smsc_fdc37m81x_config_end(); | ||
171 | } | ||
172 | #endif | ||