1
2
3
4
5
6
7
8
9
10
11
12#include <linux/init.h>
13#include <linux/mm.h>
14#include <linux/vmalloc.h>
15#include <linux/interrupt.h>
16#include <asm/io.h>
17#include <asm/irq.h>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#if defined(CONFIG_CPU_SH4)
34
35
36
37
38#if defined(CONFIG_CF_AREA6)
39#define slot_no 0
40#else
41#define slot_no 1
42#endif
43
44
45void *cf_io_base;
46
47static int __init allocate_cf_area(void)
48{
49 pgprot_t prot;
50 unsigned long paddrbase, psize;
51
52
53 paddrbase = virt_to_phys((void*)CONFIG_CF_BASE_ADDR);
54 psize = PAGE_SIZE;
55 prot = PAGE_KERNEL_PCC(slot_no, _PAGE_PCC_IO16);
56 cf_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
57 if (!cf_io_base) {
58 printk("allocate_cf_area : can't open CF I/O window!\n");
59 return -ENOMEM;
60 }
61
62
63
64
65
66 return 0;
67}
68#endif
69
70static int __init cf_init_default(void)
71{
72
73
74
75#if defined(CONFIG_CPU_SH4)
76 allocate_cf_area();
77#endif
78
79 return 0;
80}
81
82#if defined(CONFIG_SH_SOLUTION_ENGINE)
83#include <asm/se.h>
84#elif defined(CONFIG_SH_7722_SOLUTION_ENGINE)
85#include <asm/se7722.h>
86#endif
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102#if defined(CONFIG_SH_SOLUTION_ENGINE) || defined(CONFIG_SH_7722_SOLUTION_ENGINE)
103static int __init cf_init_se(void)
104{
105 if ((ctrl_inw(MRSHPC_CSR) & 0x000c) != 0)
106 return 0;
107
108 if ((ctrl_inw(MRSHPC_CSR) & 0x0080) == 0) {
109 ctrl_outw(0x0674, MRSHPC_CPWCR);
110 } else {
111 ctrl_outw(0x0678, MRSHPC_CPWCR);
112 }
113
114
115
116
117
118
119 ctrl_outw(0x8a84, MRSHPC_MW0CR1);
120 if((ctrl_inw(MRSHPC_CSR) & 0x4000) != 0)
121
122 ctrl_outw(0x0b00, MRSHPC_MW0CR2);
123 else
124
125 ctrl_outw(0x0300, MRSHPC_MW0CR2);
126
127
128 ctrl_outw(0x8a85, MRSHPC_MW1CR1);
129 if ((ctrl_inw(MRSHPC_CSR) & 0x4000) != 0)
130
131 ctrl_outw(0x0a00, MRSHPC_MW1CR2);
132 else
133
134 ctrl_outw(0x0200, MRSHPC_MW1CR2);
135
136
137 ctrl_outw(0x8a86, MRSHPC_IOWCR1);
138 ctrl_outw(0x0008, MRSHPC_CDCR);
139 if ((ctrl_inw(MRSHPC_CSR) & 0x4000) != 0)
140 ctrl_outw(0x0a00, MRSHPC_IOWCR2);
141 else
142 ctrl_outw(0x0200, MRSHPC_IOWCR2);
143
144 ctrl_outw(0x2000, MRSHPC_ICR);
145 ctrl_outb(0x00, PA_MRSHPC_MW2 + 0x206);
146 ctrl_outb(0x42, PA_MRSHPC_MW2 + 0x200);
147 return 0;
148}
149#else
150static int __init cf_init_se(void)
151{
152 return -1;
153}
154#endif
155
156int __init cf_init(void)
157{
158 if( mach_is_se() || mach_is_7722se() ){
159 return cf_init_se();
160 }
161
162 return cf_init_default();
163}
164
165__initcall (cf_init);
166