This source file includes following definitions.
- smsc_superio_setup
1
2
3
4
5
6
7
8
9
10
11 #include <linux/init.h>
12 #include <linux/ioport.h>
13 #include <linux/io.h>
14 #include <linux/err.h>
15 #include <mach/microdev.h>
16
17 #define SMSC_CONFIG_PORT_ADDR (0x3F0)
18 #define SMSC_INDEX_PORT_ADDR SMSC_CONFIG_PORT_ADDR
19 #define SMSC_DATA_PORT_ADDR (SMSC_INDEX_PORT_ADDR + 1)
20
21 #define SMSC_ENTER_CONFIG_KEY 0x55
22 #define SMSC_EXIT_CONFIG_KEY 0xaa
23
24 #define SMCS_LOGICAL_DEV_INDEX 0x07
25 #define SMSC_DEVICE_ID_INDEX 0x20
26 #define SMSC_DEVICE_REV_INDEX 0x21
27 #define SMSC_ACTIVATE_INDEX 0x30
28 #define SMSC_PRIMARY_BASE_INDEX 0x60
29 #define SMSC_SECONDARY_BASE_INDEX 0x62
30 #define SMSC_PRIMARY_INT_INDEX 0x70
31 #define SMSC_SECONDARY_INT_INDEX 0x72
32 #define SMSC_HDCS0_INDEX 0xf0
33 #define SMSC_HDCS1_INDEX 0xf1
34
35 #define SMSC_IDE1_DEVICE 1
36 #define SMSC_IDE2_DEVICE 2
37 #define SMSC_PARALLEL_DEVICE 3
38 #define SMSC_SERIAL1_DEVICE 4
39 #define SMSC_SERIAL2_DEVICE 5
40 #define SMSC_KEYBOARD_DEVICE 7
41 #define SMSC_CONFIG_REGISTERS 8
42
43 #define SMSC_READ_INDEXED(index) ({ \
44 outb((index), SMSC_INDEX_PORT_ADDR); \
45 inb(SMSC_DATA_PORT_ADDR); })
46 #define SMSC_WRITE_INDEXED(val, index) ({ \
47 outb((index), SMSC_INDEX_PORT_ADDR); \
48 outb((val), SMSC_DATA_PORT_ADDR); })
49
50 #define IDE1_PRIMARY_BASE 0x01f0
51 #define IDE1_SECONDARY_BASE 0x03f6
52 #define IDE2_PRIMARY_BASE 0x0170
53 #define IDE2_SECONDARY_BASE 0x0376
54
55 #define SERIAL1_PRIMARY_BASE 0x03f8
56 #define SERIAL2_PRIMARY_BASE 0x02f8
57
58 #define MSB(x) ( (x) >> 8 )
59 #define LSB(x) ( (x) & 0xff )
60
61
62 #define MICRODEV_FPGA_GP_BASE 0xa6100000ul
63
64 static int __init smsc_superio_setup(void)
65 {
66
67 unsigned char devid, devrev;
68
69
70
71 outb(SMSC_ENTER_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
72
73
74 devid = SMSC_READ_INDEXED(SMSC_DEVICE_ID_INDEX);
75 devrev = SMSC_READ_INDEXED(SMSC_DEVICE_REV_INDEX);
76
77 if ((devid == 0x30) && (devrev == 0x01))
78 printk("SMSC FDC37C93xAPM SuperIO device detected\n");
79 else
80 return -ENODEV;
81
82
83 SMSC_WRITE_INDEXED(SMSC_KEYBOARD_DEVICE, SMCS_LOGICAL_DEV_INDEX);
84
85 SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
86
87 SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_KEYBOARD, SMSC_PRIMARY_INT_INDEX);
88 SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_MOUSE, SMSC_SECONDARY_INT_INDEX);
89
90
91 SMSC_WRITE_INDEXED(SMSC_SERIAL1_DEVICE, SMCS_LOGICAL_DEV_INDEX);
92
93 SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
94
95 SMSC_WRITE_INDEXED(MSB(SERIAL1_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+0);
96 SMSC_WRITE_INDEXED(LSB(SERIAL1_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+1);
97 SMSC_WRITE_INDEXED(0x00, SMSC_HDCS0_INDEX);
98
99 SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_SERIAL1, SMSC_PRIMARY_INT_INDEX);
100
101
102 SMSC_WRITE_INDEXED(SMSC_SERIAL2_DEVICE, SMCS_LOGICAL_DEV_INDEX);
103
104 SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
105
106 SMSC_WRITE_INDEXED(MSB(SERIAL2_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+0);
107 SMSC_WRITE_INDEXED(LSB(SERIAL2_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+1);
108 SMSC_WRITE_INDEXED(0x00, SMSC_HDCS0_INDEX);
109
110 SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_SERIAL2, SMSC_PRIMARY_INT_INDEX);
111
112
113 SMSC_WRITE_INDEXED(SMSC_IDE1_DEVICE, SMCS_LOGICAL_DEV_INDEX);
114
115 SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
116
117 SMSC_WRITE_INDEXED(MSB(IDE1_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+0);
118 SMSC_WRITE_INDEXED(LSB(IDE1_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+1);
119 SMSC_WRITE_INDEXED(MSB(IDE1_SECONDARY_BASE), SMSC_SECONDARY_BASE_INDEX+0);
120 SMSC_WRITE_INDEXED(LSB(IDE1_SECONDARY_BASE), SMSC_SECONDARY_BASE_INDEX+1);
121 SMSC_WRITE_INDEXED(0x0c, SMSC_HDCS0_INDEX);
122 SMSC_WRITE_INDEXED(0x00, SMSC_HDCS1_INDEX);
123
124 SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_IDE1, SMSC_PRIMARY_INT_INDEX);
125
126
127 SMSC_WRITE_INDEXED(SMSC_IDE2_DEVICE, SMCS_LOGICAL_DEV_INDEX);
128
129 SMSC_WRITE_INDEXED(1, SMSC_ACTIVATE_INDEX);
130
131 SMSC_WRITE_INDEXED(MSB(IDE2_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+0);
132 SMSC_WRITE_INDEXED(LSB(IDE2_PRIMARY_BASE), SMSC_PRIMARY_BASE_INDEX+1);
133 SMSC_WRITE_INDEXED(MSB(IDE2_SECONDARY_BASE), SMSC_SECONDARY_BASE_INDEX+0);
134 SMSC_WRITE_INDEXED(LSB(IDE2_SECONDARY_BASE), SMSC_SECONDARY_BASE_INDEX+1);
135
136 SMSC_WRITE_INDEXED(MICRODEV_FPGA_IRQ_IDE2, SMSC_PRIMARY_INT_INDEX);
137
138
139 SMSC_WRITE_INDEXED(SMSC_CONFIG_REGISTERS, SMCS_LOGICAL_DEV_INDEX);
140
141
142
143
144
145
146 SMSC_WRITE_INDEXED(0x00, 0xc2);
147 SMSC_WRITE_INDEXED(0x01, 0xc5);
148 SMSC_WRITE_INDEXED(0x00, 0xc6);
149 SMSC_WRITE_INDEXED(0x00, 0xc7);
150 SMSC_WRITE_INDEXED(0x08, 0xe8);
151
152
153 outb(SMSC_EXIT_CONFIG_KEY, SMSC_CONFIG_PORT_ADDR);
154
155 return 0;
156 }
157 device_initcall(smsc_superio_setup);