blob: ddb99b824190fc8882985ec086fc64f37a9ba1be [file] [log] [blame]
Andrew Wu00bf6472013-06-26 21:24:59 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 DMP Electronics Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <console/console.h>
21#include <device/device.h>
22#include <device/pci.h>
23#include <device/pci_ops.h>
24#include <device/pci_ids.h>
25#include <pc80/mc146818rtc.h>
Andrew Wu3fa1a132013-10-09 18:57:20 +080026#include <pc80/keyboard.h>
Andrew Wu00bf6472013-06-26 21:24:59 +080027#include <string.h>
28#include "arch/io.h"
29#include "chip.h"
30#include "southbridge.h"
31
32/* IRQ number to S/B PCI Interrupt routing table reg(0x58/0xb4) mapping table. */
33static const unsigned char irq_to_int_routing[16] = {
34 0x0, 0x0, 0x0, 0x2, // IRQ0-2 is unmappable, IRQ3 = 2.
35 0x4, 0x5, 0x7, 0x6, // IRQ4-7 = 4, 5, 7, 6.
36 0x0, 0x1, 0x3, 0x9, // IRQ8 is unmappable, IRQ9-11 = 1, 3, 9.
37 0xb, 0x0, 0xd, 0xf // IRQ12 = b, IRQ13 is unmappable, IRQ14-15 = d, f.
38};
39
40/* S/B PCI Interrupt routing table reg(0x58) field bit shift. */
41#define EHCIH_IRQ_SHIFT 28
42#define OHCII_IRQ_SHIFT 24
43#define MAC_IRQ_SHIFT 16
44#define RT3_IRQ_SHIFT 12
45#define RT2_IRQ_SHIFT 8
46#define RT1_IRQ_SHIFT 4
47#define RT0_IRQ_SHIFT 0
48
49/* S/B Extend PCI Interrupt routing table reg(0xb4) field bit shift. */
Andrew Wu52914322013-07-09 21:29:25 +080050#define CAN_IRQ_SHIFT 28
51#define HDA_IRQ_SHIFT 20
Andrew Wu00bf6472013-06-26 21:24:59 +080052#define USBD_IRQ_SHIFT 16
53#define SIDE_IRQ_SHIFT 12
54#define PIDE_IRQ_SHIFT 8
55
Andrew Wu52914322013-07-09 21:29:25 +080056/* S/B function 1 Extend PCI Interrupt routing table reg 2(0xb4)
57 * field bit shift.
58 */
59#define SPI1_IRQ_SHIFT 8
60#define MOTOR_IRQ_SHIFT 0
61
Andrew Wu00bf6472013-06-26 21:24:59 +080062/* in-chip PCI device IRQs(0 for disabled). */
63#define EHCII_IRQ 5
64#define OHCII_IRQ 5
65#define MAC_IRQ 6
66
Andrew Wu52914322013-07-09 21:29:25 +080067#define CAN_IRQ 10
68#define HDA_IRQ 7
69#define USBD_IRQ 6
Andrew Wu00bf6472013-06-26 21:24:59 +080070#define PIDE_IRQ 5
71
Andrew Wu52914322013-07-09 21:29:25 +080072#define SPI1_IRQ 10
73#define MOTOR_IRQ 11
74
Andrew Wu00bf6472013-06-26 21:24:59 +080075/* RT0-3 IRQs. */
76#define RT3_IRQ 3
77#define RT2_IRQ 4
78#define RT1_IRQ 5
79#define RT0_IRQ 6
80
81/* IDE legacy mode IRQs. */
82#define IDE1_LEGACY_IRQ 14
83#define IDE2_LEGACY_IRQ 15
84
85/* Internal parallel port */
86#define LPT_INT_C 0
87#define LPT_INT_ACK_SET 0
88#define LPT_UE 1
89#define LPT_PDMAS 0
90#define LPT_DREQS 0
91
92/* Post codes */
93#define POST_KBD_FW_UPLOAD 0x06
94#define POST_KBD_CHK_READY 0x07
95#define POST_KBD_IS_READY 0x08
96#define POST_KBD_FW_VERIFY_FAILURE 0x82
97
98static u8 get_pci_dev_func(device_t dev)
99{
100 return PCI_FUNC(dev->path.pci.devfn);
101}
102
103static void verify_dmp_keyboard_error(void)
104{
105 post_code(POST_KBD_FW_VERIFY_FAILURE);
106 die("Internal keyboard firmware verify error!\n");
107}
108
109static void upload_dmp_keyboard_firmware(struct device *dev)
110{
111 u32 reg_sb_c0;
112 u32 fwptr;
113
114 // enable firmware uploading function by set bit 10.
115 post_code(POST_KBD_FW_UPLOAD);
116 reg_sb_c0 = pci_read_config32(dev, SB_REG_IPFCR);
117 pci_write_config32(dev, SB_REG_IPFCR, reg_sb_c0 | 0x400);
118
119 outw(0, 0x62); // reset upload address to 0.
120 // upload 4096 bytes from 0xFFFFE000.
121 outsb(0x66, (u8 *) 0xffffe000, 4096);
122 // upload 4096 bytes from 0xFFFFC000.
123 outsb(0x66, (u8 *) 0xffffc000, 4096);
124
125 outw(0, 0x62); // reset upload address to 0.
126 // verify 4096 bytes from 0xFFFFE000.
127 for (fwptr = 0xffffe000; fwptr < 0xfffff000; fwptr++) {
128 if (inb(0x66) != *(u8 *) fwptr) {
129 verify_dmp_keyboard_error();
130 }
131 }
132 // verify 4096 bytes from 0xFFFFC000.
133 for (fwptr = 0xffffc000; fwptr < 0xffffd000; fwptr++) {
134 if (inb(0x66) != *(u8 *) fwptr) {
135 verify_dmp_keyboard_error();
136 }
137 }
138
139 // disable firmware uploading.
140 pci_write_config32(dev, SB_REG_IPFCR, reg_sb_c0 & ~0x400L);
Andrew Wu1ce48602013-10-19 01:33:08 +0800141}
142
143static void kbc_wait_system_flag(void)
144{
145 /* wait keyboard controller ready by checking system flag
146 * (status port bit 2).
147 */
Andrew Wu00bf6472013-06-26 21:24:59 +0800148 post_code(POST_KBD_CHK_READY);
149 while ((inb(0x64) & 0x4) == 0) {
150 }
151 post_code(POST_KBD_IS_READY);
152}
153
154static void pci_routing_fixup(struct device *dev)
155{
156 const unsigned slot[3] = { 0 };
157 const unsigned char slot_irqs[1][4] = {
158 {RT0_IRQ, RT1_IRQ, RT2_IRQ, RT3_IRQ},
159 };
160 const int slot_num = 1;
161 int i;
162 u32 int_routing = 0;
163 u32 ext_int_routing = 0;
164
165 /* assign PCI-e bridge (bus#0, dev#1, fn#0) IRQ to RT0. */
166 pci_assign_irqs(0, 1, slot_irqs[0]);
167
168 /* RT0 is enabled. */
169 int_routing |= irq_to_int_routing[RT0_IRQ] << RT0_IRQ_SHIFT;
170
171 /* assign PCI slot IRQs. */
172 for (i = 0; i < slot_num; i++) {
173 pci_assign_irqs(1, slot[i], slot_irqs[i]);
174 }
175
176 /* Read PCI slot IRQs to see if RT1-3 is used, and enables it */
177 for (i = 0; i < slot_num; i++) {
178 unsigned int funct;
179 device_t pdev;
180 u8 irq;
181
182 /* Each slot may contain up to eight functions. */
183 for (funct = 0; funct < 8; funct++) {
184 pdev = dev_find_slot(1, (slot[i] << 3) + funct);
185 if (!pdev)
186 continue;
187 irq = pci_read_config8(pdev, PCI_INTERRUPT_LINE);
188 if (irq == RT1_IRQ) {
189 int_routing |= irq_to_int_routing[RT1_IRQ] << RT1_IRQ_SHIFT;
190 } else if (irq == RT2_IRQ) {
191 int_routing |= irq_to_int_routing[RT2_IRQ] << RT2_IRQ_SHIFT;
192 } else if (irq == RT3_IRQ) {
193 int_routing |= irq_to_int_routing[RT3_IRQ] << RT3_IRQ_SHIFT;
194 }
195 }
196 }
197
198 /* Setup S/B PCI Interrupt routing table reg(0x58). */
199 int_routing |= irq_to_int_routing[EHCII_IRQ] << EHCIH_IRQ_SHIFT;
200 int_routing |= irq_to_int_routing[OHCII_IRQ] << OHCII_IRQ_SHIFT;
201 int_routing |= irq_to_int_routing[MAC_IRQ] << MAC_IRQ_SHIFT;
Andrew Wu52914322013-07-09 21:29:25 +0800202 pci_write_config32(dev, SB_REG_PIRQ_ROUTE, int_routing);
Andrew Wu00bf6472013-06-26 21:24:59 +0800203
204 /* Setup S/B PCI Extend Interrupt routing table reg(0xb4). */
Andrew Wu52914322013-07-09 21:29:25 +0800205 ext_int_routing |= irq_to_int_routing[CAN_IRQ] << CAN_IRQ_SHIFT;
206 ext_int_routing |= irq_to_int_routing[HDA_IRQ] << HDA_IRQ_SHIFT;
Andrew Wu00bf6472013-06-26 21:24:59 +0800207 ext_int_routing |= irq_to_int_routing[USBD_IRQ] << USBD_IRQ_SHIFT;
208#if CONFIG_IDE_NATIVE_MODE
209 /* IDE in native mode, only uses one IRQ. */
210 ext_int_routing |= irq_to_int_routing[0] << SIDE_IRQ_SHIFT;
211 ext_int_routing |= irq_to_int_routing[PIDE_IRQ] << PIDE_IRQ_SHIFT;
212#else
213 /* IDE in legacy mode, use IRQ 14, 15. */
214 ext_int_routing |= irq_to_int_routing[IDE2_LEGACY_IRQ] << SIDE_IRQ_SHIFT;
215 ext_int_routing |= irq_to_int_routing[IDE1_LEGACY_IRQ] << PIDE_IRQ_SHIFT;
216#endif
Andrew Wu52914322013-07-09 21:29:25 +0800217 pci_write_config32(dev, SB_REG_EXT_PIRQ_ROUTE, ext_int_routing);
Andrew Wu00bf6472013-06-26 21:24:59 +0800218
219 /* Assign in-chip PCI device IRQs. */
220 if (MAC_IRQ) {
221 unsigned char irqs[4] = { MAC_IRQ, 0, 0, 0 };
222 pci_assign_irqs(0, 0x8, irqs);
223 }
224 if (OHCII_IRQ && EHCII_IRQ) {
225 unsigned char irqs[4] = { OHCII_IRQ, EHCII_IRQ, 0, 0 };
226 pci_assign_irqs(0, 0xa, irqs);
227 }
228 if (CONFIG_IDE_NATIVE_MODE && PIDE_IRQ) {
229 /* IDE in native mode, setup PCI IRQ. */
230 unsigned char irqs[4] = { PIDE_IRQ, 0, 0, 0 };
231 pci_assign_irqs(0, 0xc, irqs);
232 }
Andrew Wu52914322013-07-09 21:29:25 +0800233 if (CAN_IRQ) {
234 unsigned char irqs[4] = { CAN_IRQ, 0, 0, 0 };
235 pci_assign_irqs(0, 0x11, irqs);
236 }
237 if (HDA_IRQ) {
238 unsigned char irqs[4] = { HDA_IRQ, 0, 0, 0 };
239 pci_assign_irqs(0, 0xe, irqs);
240 }
Andrew Wu00bf6472013-06-26 21:24:59 +0800241 if (USBD_IRQ) {
242 unsigned char irqs[4] = { USBD_IRQ, 0, 0, 0 };
243 pci_assign_irqs(0, 0xf, irqs);
244 }
245}
246
247static void vortex_sb_init(struct device *dev)
248{
249 u32 lpt_reg = 0;
250
251#if CONFIG_LPT_ENABLE
252 int ppmod = 0;
253#if CONFIG_LPT_MODE_BPP
254 ppmod = 0;
255#elif CONFIG_LPT_MODE_EPP_19_AND_SPP
256 ppmod = 1;
257#elif CONFIG_LPT_MODE_ECP
258 ppmod = 2;
259#elif CONFIG_LPT_MODE_ECP_AND_EPP_19
260 ppmod = 3;
261#elif CONFIG_LPT_MODE_SPP
262 ppmod = 4;
263#elif CONFIG_LPT_MODE_EPP_17_AND_SPP
264 ppmod = 5;
265#elif CONFIG_LPT_MODE_ECP_AND_EPP_17
266 ppmod = 7;
267#else
268#error CONFIG_LPT_MODE error.
269#endif
270
271 /* Setup internal parallel port */
272 lpt_reg |= (LPT_INT_C << 28);
273 lpt_reg |= (LPT_INT_ACK_SET << 27);
274 lpt_reg |= (ppmod << 24);
275 lpt_reg |= (LPT_UE << 23);
276 lpt_reg |= (LPT_PDMAS << 22);
277 lpt_reg |= (LPT_DREQS << 20);
278 lpt_reg |= (irq_to_int_routing[CONFIG_LPT_IRQ] << 16);
279 lpt_reg |= (CONFIG_LPT_IO << 0);
280#endif // CONFIG_LPT_ENABLE
281 pci_write_config32(dev, SB_REG_IPPCR, lpt_reg);
282}
283
284#define SETUP_GPIO_ADDR(n) \
285 u32 cfg##n = (CONFIG_GPIO_P##n##_DIR_ADDR << 16) | (CONFIG_GPIO_P##n##_DATA_ADDR);\
286 outl(cfg##n, base + 4 + (n * 4));\
287 gpio_enable_mask |= (1 << n);
288
289#define INIT_GPIO(n) \
290 outb(CONFIG_GPIO_P##n##_INIT_DIR, CONFIG_GPIO_P##n##_DIR_ADDR);\
291 outb(CONFIG_GPIO_P##n##_INIT_DATA, CONFIG_GPIO_P##n##_DATA_ADDR);
292
293static void ex_sb_gpio_init(struct device *dev)
294{
295 const int base = 0xb00;
296 u32 gpio_enable_mask = 0;
297 /* S/B register 63h - 62h : GPIO Port Config IO Base Address */
298 pci_write_config16(dev, SB_REG_GPIO_CFG_IO_BASE, base | 1);
299 /* Set GPIO port 0~9 base address.
300 * Config Base + 04h, 08h, 0ch... : GPIO port 0~9 data/dir decode addr.
301 * Bit 31-16 : DBA, GPIO direction base address.
302 * Bit 15-0 : DPBA, GPIO data port base address.
303 * */
304#if CONFIG_GPIO_P0_ENABLE
305 SETUP_GPIO_ADDR(0)
306#endif
307#if CONFIG_GPIO_P1_ENABLE
308 SETUP_GPIO_ADDR(1)
309#endif
310#if CONFIG_GPIO_P2_ENABLE
311 SETUP_GPIO_ADDR(2)
312#endif
313#if CONFIG_GPIO_P3_ENABLE
314 SETUP_GPIO_ADDR(3)
315#endif
316#if CONFIG_GPIO_P4_ENABLE
317 SETUP_GPIO_ADDR(4)
318#endif
319#if CONFIG_GPIO_P5_ENABLE
320 SETUP_GPIO_ADDR(5)
321#endif
322#if CONFIG_GPIO_P6_ENABLE
323 SETUP_GPIO_ADDR(6)
324#endif
325#if CONFIG_GPIO_P7_ENABLE
326 SETUP_GPIO_ADDR(7)
327#endif
328#if CONFIG_GPIO_P8_ENABLE
329 SETUP_GPIO_ADDR(8)
330#endif
331#if CONFIG_GPIO_P9_ENABLE
332 SETUP_GPIO_ADDR(9)
333#endif
334 /* Enable GPIO port 0~9. */
335 outl(gpio_enable_mask, base);
336 /* Set GPIO port 0-9 initial dir and data. */
337#if CONFIG_GPIO_P0_ENABLE
338 INIT_GPIO(0)
339#endif
340#if CONFIG_GPIO_P1_ENABLE
341 INIT_GPIO(1)
342#endif
343#if CONFIG_GPIO_P2_ENABLE
344 INIT_GPIO(2)
345#endif
346#if CONFIG_GPIO_P3_ENABLE
347 INIT_GPIO(3)
348#endif
349#if CONFIG_GPIO_P4_ENABLE
350 INIT_GPIO(4)
351#endif
352#if CONFIG_GPIO_P5_ENABLE
353 INIT_GPIO(5)
354#endif
355#if CONFIG_GPIO_P6_ENABLE
356 INIT_GPIO(6)
357#endif
358#if CONFIG_GPIO_P7_ENABLE
359 INIT_GPIO(7)
360#endif
361#if CONFIG_GPIO_P8_ENABLE
362 INIT_GPIO(8)
363#endif
364#if CONFIG_GPIO_P9_ENABLE
365 INIT_GPIO(9)
366#endif
367 /* Disable GPIO Port Config IO Base Address. */
368 pci_write_config16(dev, SB_REG_GPIO_CFG_IO_BASE, 0x0);
369}
370
371static u32 make_uart_config(u16 base, u8 irq)
372{
373 u8 mapped_irq = irq_to_int_routing[irq];
374 u32 cfg = 0;
375 cfg |= 1 << 23; // UE = enabled.
376 cfg |= (mapped_irq << 16); // UIRT.
377 cfg |= base; // UIOA.
378 return cfg;
379}
380
381#define SETUP_UART(n) \
382 uart_cfg = make_uart_config(CONFIG_UART##n##_IO, CONFIG_UART##n##_IRQ);\
383 outl(uart_cfg, base + (n - 1) * 4);\
384 uart8250_init(CONFIG_UART##n##_IO, 115200 / CONFIG_UART##n##_BAUD);
385
386static void ex_sb_uart_init(struct device *dev)
387{
388 const int base = 0xc00;
389 u32 uart_cfg = 0;
390 /* S/B register 61h - 60h : UART Config IO Base Address */
391 pci_write_config16(dev, SB_REG_UART_CFG_IO_BASE, base | 1);
392 /* setup UART */
393#if CONFIG_UART1_ENABLE
394 SETUP_UART(1)
395#endif
396#if CONFIG_UART2_ENABLE
397 SETUP_UART(2)
398#endif
399#if CONFIG_UART3_ENABLE
400 SETUP_UART(3)
401#endif
402#if CONFIG_UART4_ENABLE
403 SETUP_UART(4)
404#endif
405#if CONFIG_UART5_ENABLE
406 SETUP_UART(5)
407#endif
408#if CONFIG_UART6_ENABLE
409 SETUP_UART(6)
410#endif
411#if CONFIG_UART7_ENABLE
412 SETUP_UART(7)
413#endif
414#if CONFIG_UART8_ENABLE
415 SETUP_UART(8)
416#endif
417#if CONFIG_UART9_ENABLE
418 SETUP_UART(9)
419#endif
420#if CONFIG_UART10_ENABLE
421 SETUP_UART(10)
422#endif
423 /* Keep UART Config I/O base address */
424 //pci_write_config16(SB, SB_REG_UART_CFG_IO_BASE, 0x0);
425}
426
427static int get_rtc_update_in_progress(void)
428{
429 if (cmos_read(RTC_REG_A) & RTC_UIP)
430 return 1;
431 return 0;
432}
433
434static void unsafe_read_cmos_rtc(u8 rtc[7])
435{
436 rtc[0] = cmos_read(RTC_CLK_ALTCENTURY);
437 rtc[1] = cmos_read(RTC_CLK_YEAR);
438 rtc[2] = cmos_read(RTC_CLK_MONTH);
439 rtc[3] = cmos_read(RTC_CLK_DAYOFMONTH);
440 rtc[4] = cmos_read(RTC_CLK_HOUR);
441 rtc[5] = cmos_read(RTC_CLK_MINUTE);
442 rtc[6] = cmos_read(RTC_CLK_SECOND);
443}
444
445static void read_cmos_rtc(u8 rtc[7])
446{
447 /* Read RTC twice and check update-in-progress flag, to make
448 * sure RTC is correct */
449 u8 rtc_old[7], rtc_new[7];
450 while (get_rtc_update_in_progress()) ;
451 unsafe_read_cmos_rtc(rtc_new);
452 do {
453 memcpy(rtc_old, rtc_new, 7);
454 while (get_rtc_update_in_progress()) ;
455 unsafe_read_cmos_rtc(rtc_new);
456 } while (memcmp(rtc_new, rtc_old, 7) != 0);
457}
458
459/*
460 * Convert a number in decimal format into the BCD format.
461 * Return 255 if not a valid BCD value.
462 */
463static u8 bcd2dec(u8 bcd)
464{
465 u8 h, l;
466 h = bcd >> 4;
467 l = bcd & 0xf;
468 if (h > 9 || l > 9)
469 return 255;
470 return h * 10 + l;
471}
472
473static void fix_cmos_rtc_time(void)
474{
475 /* Read RTC data. */
476 u8 rtc[7];
477 read_cmos_rtc(rtc);
478
479 /* Convert RTC from BCD format to binary. */
480 u8 bin_rtc[7];
481 int i;
482 for (i = 0; i < 8; i++) {
483 bin_rtc[i] = bcd2dec(rtc[i]);
484 }
485
486 /* If RTC date is invalid, fix it. */
487 if (bin_rtc[0] > 99 || bin_rtc[1] > 99 || bin_rtc[2] > 12 || bin_rtc[3] > 31) {
488 /* Set PC compatible timing mode. */
489 cmos_write(0x26, RTC_REG_A);
490 cmos_write(0x02, RTC_REG_B);
491 /* Now setup a default date 2008/08/08 08:08:08. */
492 cmos_write(0x8, RTC_CLK_SECOND);
493 cmos_write(0x8, RTC_CLK_MINUTE);
494 cmos_write(0x8, RTC_CLK_HOUR);
495 cmos_write(0x6, RTC_CLK_DAYOFWEEK); /* Friday */
496 cmos_write(0x8, RTC_CLK_DAYOFMONTH);
497 cmos_write(0x8, RTC_CLK_MONTH);
498 cmos_write(0x8, RTC_CLK_YEAR);
499 cmos_write(0x20, RTC_CLK_ALTCENTURY);
500 }
501}
502
503static void vortex86_sb_set_io_resv(device_t dev, u32 io_resv_size)
504{
505 struct resource *res;
506 res = new_resource(dev, 1);
507 res->base = 0x0UL;
508 res->size = io_resv_size;
509 res->limit = 0xffffUL;
510 res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
511}
512
513static void vortex86_sb_set_spi_flash_size(device_t dev, u32 flash_size)
514{
515 /* SPI flash is in topmost of 4G memory space */
516 struct resource *res;
517 res = new_resource(dev, 2);
518 res->base = 0x100000000LL - flash_size;
519 res->size = flash_size;
520 res->limit = 0xffffffffUL;
521 res->flags = IORESOURCE_MEM | IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
522}
523
524static void vortex86_sb_read_resources(device_t dev)
525{
526 u32 flash_size = 8 * 1024 * 1024;
527
528 pci_dev_read_resources(dev);
529
530 if (dev->device == 0x6011) {
531 /* It is EX CPU southbridge */
532 if (get_pci_dev_func(dev) != 0) {
533 /* only for function 0, skip function 1 */
534 return;
535 }
536 /* default SPI flash ROM is 64MB */
537 flash_size = 64 * 1024 * 1024;
538 }
539
540 /* Reserve space for I/O */
541 vortex86_sb_set_io_resv(dev, 0x1000UL);
542
543 /* Reserve space for flash */
544 vortex86_sb_set_spi_flash_size(dev, flash_size);
545}
546
Andrew Wu52914322013-07-09 21:29:25 +0800547static void southbridge_init_func1(struct device *dev)
548{
549 /* Handle S/B function 1 PCI IRQ routing. (SPI1/MOTOR) */
550 u32 ext_int_routing2 = 0;
551 /* Setup S/B function 1 PCI Extend Interrupt routing table reg 2(0xb4). */
552 ext_int_routing2 |= irq_to_int_routing[SPI1_IRQ] << SPI1_IRQ_SHIFT;
553 ext_int_routing2 |= irq_to_int_routing[MOTOR_IRQ] << MOTOR_IRQ_SHIFT;
554 pci_write_config32(dev, SB1_REG_EXT_PIRQ_ROUTE2, ext_int_routing2);
555
556 /* Assign in-chip PCI device IRQs. */
557 if (SPI1_IRQ || MOTOR_IRQ) {
558 unsigned char irqs[4] = { MOTOR_IRQ, SPI1_IRQ, 0, 0 };
559 pci_assign_irqs(0, 0x10, irqs);
560 }
561}
562
Andrew Wu00bf6472013-06-26 21:24:59 +0800563static void southbridge_init(struct device *dev)
564{
Andrew Wu52914322013-07-09 21:29:25 +0800565 /* Check it is function 0 or 1. (Same Vendor/Device ID) */
566 if (get_pci_dev_func(dev) != 0) {
567 southbridge_init_func1(dev);
568 return;
Andrew Wu00bf6472013-06-26 21:24:59 +0800569 }
570 upload_dmp_keyboard_firmware(dev);
571 vortex_sb_init(dev);
572 if (dev->device == 0x6011) {
573 ex_sb_gpio_init(dev);
574 ex_sb_uart_init(dev);
575 }
576 pci_routing_fixup(dev);
577
578 fix_cmos_rtc_time();
579 rtc_init(0);
Andrew Wu1ce48602013-10-19 01:33:08 +0800580 kbc_wait_system_flag();
Andrew Wu3fa1a132013-10-09 18:57:20 +0800581 pc_keyboard_init(0);
Andrew Wu00bf6472013-06-26 21:24:59 +0800582}
583
584static struct device_operations vortex_sb_ops = {
585 .read_resources = vortex86_sb_read_resources,
586 .set_resources = pci_dev_set_resources,
587 .enable_resources = pci_dev_enable_resources,
588 .init = &southbridge_init,
589 .scan_bus = scan_static_bus,
590 .enable = 0,
591 .ops_pci = 0,
592};
593
594static const struct pci_driver pci_driver_6011 __pci_driver = {
595 .ops = &vortex_sb_ops,
596 .vendor = PCI_VENDOR_ID_RDC,
597 .device = 0x6011, /* EX CPU S/B ID */
598};
599
600struct chip_operations southbridge_dmp_vortex86ex_ops = {
601 CHIP_NAME("DMP Vortex86EX Southbridge")
602 .enable_dev = 0
603};