Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Bonito64: Make Loongson independent from Bonito64 code.

The built-in Loongson 2E/2F northbridge in is bonito64-compatible but not
identical with it. To avoid influencing the original bonito64 support and
make the loongson support more maintainable, it's better to separate the
Bonito64 code from the Loongson code.

This also prepares the kernel for the coming Loongson 2f machines family
support.

Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: Linux-MIPS <linux-mips@linux-mips.org>
Cc: yanh@lemote.com
Cc: huhb@lemote.com
Cc: Zhang Le <r0bertz@gentoo.org>
Cc: zhangfx@lemote.com,
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Wu Zhangjin and committed by
Ralf Baechle
e2fee572 e8be5283

+352 -55
+168 -14
arch/mips/include/asm/mach-loongson/loongson.h
··· 15 15 #include <linux/io.h> 16 16 #include <linux/init.h> 17 17 18 - /* there is an internal bonito64-compatiable northbridge in loongson2e/2f */ 19 - #include <asm/mips-boards/bonito64.h> 20 - 21 18 /* loongson internal northbridge initialization */ 22 19 extern void bonito_irq_init(void); 23 20 ··· 38 41 extern void __init mach_init_irq(void); 39 42 extern void mach_irq_dispatch(unsigned int pending); 40 43 44 + #define LOONGSON_REG(x) \ 45 + (*(volatile u32 *)((char *)CKSEG1ADDR(LOONGSON_REG_BASE) + (x))) 46 + 47 + #define LOONGSON_IRQ_BASE 32 48 + #define LOONGSON2_PERFCNT_IRQ (MIPS_CPU_IRQ_BASE + 6) /* cpu perf counter */ 49 + 50 + #define LOONGSON_FLASH_BASE 0x1c000000 51 + #define LOONGSON_FLASH_SIZE 0x02000000 /* 32M */ 52 + #define LOONGSON_FLASH_TOP (LOONGSON_FLASH_BASE+LOONGSON_FLASH_SIZE-1) 53 + 54 + #define LOONGSON_LIO0_BASE 0x1e000000 55 + #define LOONGSON_LIO0_SIZE 0x01C00000 /* 28M */ 56 + #define LOONGSON_LIO0_TOP (LOONGSON_LIO0_BASE+LOONGSON_LIO0_SIZE-1) 57 + 58 + #define LOONGSON_BOOT_BASE 0x1fc00000 59 + #define LOONGSON_BOOT_SIZE 0x00100000 /* 1M */ 60 + #define LOONGSON_BOOT_TOP (LOONGSON_BOOT_BASE+LOONGSON_BOOT_SIZE-1) 61 + #define LOONGSON_REG_BASE 0x1fe00000 62 + #define LOONGSON_REG_SIZE 0x00100000 /* 256Bytes + 256Bytes + ??? */ 63 + #define LOONGSON_REG_TOP (LOONGSON_REG_BASE+LOONGSON_REG_SIZE-1) 64 + 65 + #define LOONGSON_LIO1_BASE 0x1ff00000 66 + #define LOONGSON_LIO1_SIZE 0x00100000 /* 1M */ 67 + #define LOONGSON_LIO1_TOP (LOONGSON_LIO1_BASE+LOONGSON_LIO1_SIZE-1) 68 + 69 + #define LOONGSON_PCILO0_BASE 0x10000000 70 + #define LOONGSON_PCILO1_BASE 0x14000000 71 + #define LOONGSON_PCILO2_BASE 0x18000000 72 + #define LOONGSON_PCILO_BASE LOONGSON_PCILO0_BASE 73 + #define LOONGSON_PCILO_SIZE 0x0c000000 /* 64M * 3 */ 74 + #define LOONGSON_PCILO_TOP (LOONGSON_PCILO0_BASE+LOONGSON_PCILO_SIZE-1) 75 + 76 + #define LOONGSON_PCICFG_BASE 0x1fe80000 77 + #define LOONGSON_PCICFG_SIZE 0x00000800 /* 2K */ 78 + #define LOONGSON_PCICFG_TOP (LOONGSON_PCICFG_BASE+LOONGSON_PCICFG_SIZE-1) 79 + #define LOONGSON_PCIIO_BASE 0x1fd00000 80 + #define LOONGSON_PCIIO_SIZE 0x00100000 /* 1M */ 81 + #define LOONGSON_PCIIO_TOP (LOONGSON_PCIIO_BASE+LOONGSON_PCIIO_SIZE-1) 82 + 83 + /* Loongson Register Bases */ 84 + 85 + #define LOONGSON_PCICONFIGBASE 0x00 86 + #define LOONGSON_REGBASE 0x100 87 + 41 88 /* PCI Configuration Registers */ 42 - #define LOONGSON_PCI_ISR4C BONITO_PCI_REG(0x4c) 89 + 90 + #define LOONGSON_PCI_REG(x) LOONGSON_REG(LOONGSON_PCICONFIGBASE + (x)) 91 + #define LOONGSON_PCIDID LOONGSON_PCI_REG(0x00) 92 + #define LOONGSON_PCICMD LOONGSON_PCI_REG(0x04) 93 + #define LOONGSON_PCICLASS LOONGSON_PCI_REG(0x08) 94 + #define LOONGSON_PCILTIMER LOONGSON_PCI_REG(0x0c) 95 + #define LOONGSON_PCIBASE0 LOONGSON_PCI_REG(0x10) 96 + #define LOONGSON_PCIBASE1 LOONGSON_PCI_REG(0x14) 97 + #define LOONGSON_PCIBASE2 LOONGSON_PCI_REG(0x18) 98 + #define LOONGSON_PCIBASE3 LOONGSON_PCI_REG(0x1c) 99 + #define LOONGSON_PCIBASE4 LOONGSON_PCI_REG(0x20) 100 + #define LOONGSON_PCIEXPRBASE LOONGSON_PCI_REG(0x30) 101 + #define LOONGSON_PCIINT LOONGSON_PCI_REG(0x3c) 102 + 103 + #define LOONGSON_PCI_ISR4C LOONGSON_PCI_REG(0x4c) 104 + 105 + #define LOONGSON_PCICMD_PERR_CLR 0x80000000 106 + #define LOONGSON_PCICMD_SERR_CLR 0x40000000 107 + #define LOONGSON_PCICMD_MABORT_CLR 0x20000000 108 + #define LOONGSON_PCICMD_MTABORT_CLR 0x10000000 109 + #define LOONGSON_PCICMD_TABORT_CLR 0x08000000 110 + #define LOONGSON_PCICMD_MPERR_CLR 0x01000000 111 + #define LOONGSON_PCICMD_PERRRESPEN 0x00000040 112 + #define LOONGSON_PCICMD_ASTEPEN 0x00000080 113 + #define LOONGSON_PCICMD_SERREN 0x00000100 114 + #define LOONGSON_PCILTIMER_BUSLATENCY 0x0000ff00 115 + #define LOONGSON_PCILTIMER_BUSLATENCY_SHIFT 8 116 + 117 + /* Loongson h/w Configuration */ 118 + 119 + #define LOONGSON_GENCFG_OFFSET 0x4 120 + #define LOONGSON_GENCFG LOONGSON_REG(LOONGSON_REGBASE + LOONGSON_GENCFG_OFFSET) 121 + 122 + #define LOONGSON_GENCFG_DEBUGMODE 0x00000001 123 + #define LOONGSON_GENCFG_SNOOPEN 0x00000002 124 + #define LOONGSON_GENCFG_CPUSELFRESET 0x00000004 125 + 126 + #define LOONGSON_GENCFG_FORCE_IRQA 0x00000008 127 + #define LOONGSON_GENCFG_IRQA_ISOUT 0x00000010 128 + #define LOONGSON_GENCFG_IRQA_FROM_INT1 0x00000020 129 + #define LOONGSON_GENCFG_BYTESWAP 0x00000040 130 + 131 + #define LOONGSON_GENCFG_UNCACHED 0x00000080 132 + #define LOONGSON_GENCFG_PREFETCHEN 0x00000100 133 + #define LOONGSON_GENCFG_WBEHINDEN 0x00000200 134 + #define LOONGSON_GENCFG_CACHEALG 0x00000c00 135 + #define LOONGSON_GENCFG_CACHEALG_SHIFT 10 136 + #define LOONGSON_GENCFG_PCIQUEUE 0x00001000 137 + #define LOONGSON_GENCFG_CACHESTOP 0x00002000 138 + #define LOONGSON_GENCFG_MSTRBYTESWAP 0x00004000 139 + #define LOONGSON_GENCFG_BUSERREN 0x00008000 140 + #define LOONGSON_GENCFG_NORETRYTIMEOUT 0x00010000 141 + #define LOONGSON_GENCFG_SHORTCOPYTIMEOUT 0x00020000 142 + 143 + /* PCI address map control */ 144 + 145 + #define LOONGSON_PCIMAP LOONGSON_REG(LOONGSON_REGBASE + 0x10) 146 + #define LOONGSON_PCIMEMBASECFG LOONGSON_REG(LOONGSON_REGBASE + 0x14) 147 + #define LOONGSON_PCIMAP_CFG LOONGSON_REG(LOONGSON_REGBASE + 0x18) 148 + 149 + /* GPIO Regs - r/w */ 150 + 151 + #define LOONGSON_GPIODATA LOONGSON_REG(LOONGSON_REGBASE + 0x1c) 152 + #define LOONGSON_GPIOIE LOONGSON_REG(LOONGSON_REGBASE + 0x20) 153 + 154 + /* ICU Configuration Regs - r/w */ 155 + 156 + #define LOONGSON_INTEDGE LOONGSON_REG(LOONGSON_REGBASE + 0x24) 157 + #define LOONGSON_INTSTEER LOONGSON_REG(LOONGSON_REGBASE + 0x28) 158 + #define LOONGSON_INTPOL LOONGSON_REG(LOONGSON_REGBASE + 0x2c) 159 + 160 + /* ICU Enable Regs - IntEn & IntISR are r/o. */ 161 + 162 + #define LOONGSON_INTENSET LOONGSON_REG(LOONGSON_REGBASE + 0x30) 163 + #define LOONGSON_INTENCLR LOONGSON_REG(LOONGSON_REGBASE + 0x34) 164 + #define LOONGSON_INTEN LOONGSON_REG(LOONGSON_REGBASE + 0x38) 165 + #define LOONGSON_INTISR LOONGSON_REG(LOONGSON_REGBASE + 0x3c) 166 + 167 + /* ICU */ 168 + #define LOONGSON_ICU_MBOXES 0x0000000f 169 + #define LOONGSON_ICU_MBOXES_SHIFT 0 170 + #define LOONGSON_ICU_DMARDY 0x00000010 171 + #define LOONGSON_ICU_DMAEMPTY 0x00000020 172 + #define LOONGSON_ICU_COPYRDY 0x00000040 173 + #define LOONGSON_ICU_COPYEMPTY 0x00000080 174 + #define LOONGSON_ICU_COPYERR 0x00000100 175 + #define LOONGSON_ICU_PCIIRQ 0x00000200 176 + #define LOONGSON_ICU_MASTERERR 0x00000400 177 + #define LOONGSON_ICU_SYSTEMERR 0x00000800 178 + #define LOONGSON_ICU_DRAMPERR 0x00001000 179 + #define LOONGSON_ICU_RETRYERR 0x00002000 180 + #define LOONGSON_ICU_GPIOS 0x01ff0000 181 + #define LOONGSON_ICU_GPIOS_SHIFT 16 182 + #define LOONGSON_ICU_GPINS 0x7e000000 183 + #define LOONGSON_ICU_GPINS_SHIFT 25 184 + #define LOONGSON_ICU_MBOX(N) (1<<(LOONGSON_ICU_MBOXES_SHIFT+(N))) 185 + #define LOONGSON_ICU_GPIO(N) (1<<(LOONGSON_ICU_GPIOS_SHIFT+(N))) 186 + #define LOONGSON_ICU_GPIN(N) (1<<(LOONGSON_ICU_GPINS_SHIFT+(N))) 187 + 188 + /* PCI prefetch window base & mask */ 189 + 190 + #define LOONGSON_MEM_WIN_BASE_L LOONGSON_REG(LOONGSON_REGBASE + 0x40) 191 + #define LOONGSON_MEM_WIN_BASE_H LOONGSON_REG(LOONGSON_REGBASE + 0x44) 192 + #define LOONGSON_MEM_WIN_MASK_L LOONGSON_REG(LOONGSON_REGBASE + 0x48) 193 + #define LOONGSON_MEM_WIN_MASK_H LOONGSON_REG(LOONGSON_REGBASE + 0x4c) 43 194 44 195 /* PCI_Hit*_Sel_* */ 45 196 46 - #define LOONGSON_PCI_HIT0_SEL_L BONITO(BONITO_REGBASE + 0x50) 47 - #define LOONGSON_PCI_HIT0_SEL_H BONITO(BONITO_REGBASE + 0x54) 48 - #define LOONGSON_PCI_HIT1_SEL_L BONITO(BONITO_REGBASE + 0x58) 49 - #define LOONGSON_PCI_HIT1_SEL_H BONITO(BONITO_REGBASE + 0x5c) 50 - #define LOONGSON_PCI_HIT2_SEL_L BONITO(BONITO_REGBASE + 0x60) 51 - #define LOONGSON_PCI_HIT2_SEL_H BONITO(BONITO_REGBASE + 0x64) 197 + #define LOONGSON_PCI_HIT0_SEL_L LOONGSON_REG(LOONGSON_REGBASE + 0x50) 198 + #define LOONGSON_PCI_HIT0_SEL_H LOONGSON_REG(LOONGSON_REGBASE + 0x54) 199 + #define LOONGSON_PCI_HIT1_SEL_L LOONGSON_REG(LOONGSON_REGBASE + 0x58) 200 + #define LOONGSON_PCI_HIT1_SEL_H LOONGSON_REG(LOONGSON_REGBASE + 0x5c) 201 + #define LOONGSON_PCI_HIT2_SEL_L LOONGSON_REG(LOONGSON_REGBASE + 0x60) 202 + #define LOONGSON_PCI_HIT2_SEL_H LOONGSON_REG(LOONGSON_REGBASE + 0x64) 52 203 53 204 /* PXArb Config & Status */ 54 205 55 - #define LOONGSON_PXARB_CFG BONITO(BONITO_REGBASE + 0x68) 56 - #define LOONGSON_PXARB_STATUS BONITO(BONITO_REGBASE + 0x6c) 206 + #define LOONGSON_PXARB_CFG LOONGSON_REG(LOONGSON_REGBASE + 0x68) 207 + #define LOONGSON_PXARB_STATUS LOONGSON_REG(LOONGSON_REGBASE + 0x6c) 57 208 58 - /* loongson2-specific perf counter IRQ */ 59 - #define LOONGSON2_PERFCNT_IRQ (MIPS_CPU_IRQ_BASE + 6) 209 + /* pcimap */ 210 + 211 + #define LOONGSON_PCIMAP_PCIMAP_LO0 0x0000003f 212 + #define LOONGSON_PCIMAP_PCIMAP_LO0_SHIFT 0 213 + #define LOONGSON_PCIMAP_PCIMAP_LO1 0x00000fc0 214 + #define LOONGSON_PCIMAP_PCIMAP_LO1_SHIFT 6 215 + #define LOONGSON_PCIMAP_PCIMAP_LO2 0x0003f000 216 + #define LOONGSON_PCIMAP_PCIMAP_LO2_SHIFT 12 217 + #define LOONGSON_PCIMAP_PCIMAP_2 0x00040000 218 + #define LOONGSON_PCIMAP_WIN(WIN, ADDR) \ 219 + ((((ADDR)>>26) & LOONGSON_PCIMAP_PCIMAP_LO0) << ((WIN)*6)) 60 220 61 221 #endif /* __ASM_MACH_LOONGSON_LOONGSON_H */
+1 -1
arch/mips/include/asm/mach-loongson/machine.h
··· 13 13 14 14 #ifdef CONFIG_LEMOTE_FULOONG2E 15 15 16 - #define LOONGSON_UART_BASE (BONITO_PCIIO_BASE + 0x3f8) 16 + #define LOONGSON_UART_BASE (LOONGSON_PCIIO_BASE + 0x3f8) 17 17 18 18 #define LOONGSON_MACHTYPE MACH_LEMOTE_FL2E 19 19
+3 -3
arch/mips/include/asm/mach-loongson/pci.h
··· 22 22 #ifndef __ASM_MACH_LOONGSON_PCI_H_ 23 23 #define __ASM_MACH_LOONGSON_PCI_H_ 24 24 25 - extern struct pci_ops bonito64_pci_ops; 25 + extern struct pci_ops loongson_pci_ops; 26 26 27 27 #ifdef CONFIG_LEMOTE_FULOONG2E 28 28 29 29 /* this pci memory space is mapped by pcimap in pci.c */ 30 - #define LOONGSON_PCI_MEM_START BONITO_PCILO1_BASE 31 - #define LOONGSON_PCI_MEM_END (BONITO_PCILO1_BASE + 0x04000000 * 2) 30 + #define LOONGSON_PCI_MEM_START LOONGSON_PCILO1_BASE 31 + #define LOONGSON_PCI_MEM_END (LOONGSON_PCILO1_BASE + 0x04000000 * 2) 32 32 /* this is an offset from mips_io_port_base */ 33 33 #define LOONGSON_PCI_IO_START 0x00004000UL 34 34
-5
arch/mips/include/asm/mips-boards/bonito64.h
··· 26 26 /* offsets from base register */ 27 27 #define BONITO(x) (x) 28 28 29 - #elif defined(CONFIG_LEMOTE_FULOONG2E) 30 - 31 - #define BONITO(x) (*(volatile u32 *)((char *)CKSEG1ADDR(BONITO_REG_BASE) + (x))) 32 - #define BONITO_IRQ_BASE 32 33 - 34 29 #else 35 30 36 31 /*
+4 -4
arch/mips/loongson/common/bonito-irq.c
··· 17 17 18 18 static inline void bonito_irq_enable(unsigned int irq) 19 19 { 20 - BONITO_INTENSET = (1 << (irq - BONITO_IRQ_BASE)); 20 + LOONGSON_INTENSET = (1 << (irq - LOONGSON_IRQ_BASE)); 21 21 mmiowb(); 22 22 } 23 23 24 24 static inline void bonito_irq_disable(unsigned int irq) 25 25 { 26 - BONITO_INTENCLR = (1 << (irq - BONITO_IRQ_BASE)); 26 + LOONGSON_INTENCLR = (1 << (irq - LOONGSON_IRQ_BASE)); 27 27 mmiowb(); 28 28 } 29 29 ··· 44 44 { 45 45 u32 i; 46 46 47 - for (i = BONITO_IRQ_BASE; i < BONITO_IRQ_BASE + 32; i++) 47 + for (i = LOONGSON_IRQ_BASE; i < LOONGSON_IRQ_BASE + 32; i++) 48 48 set_irq_chip_and_handler(i, &bonito_irq_type, handle_level_irq); 49 49 50 - setup_irq(BONITO_IRQ_BASE + 10, &dma_timeout_irqaction); 50 + setup_irq(LOONGSON_IRQ_BASE + 10, &dma_timeout_irqaction); 51 51 }
+1 -1
arch/mips/loongson/common/init.c
··· 18 18 { 19 19 /* init base address of io space */ 20 20 set_io_port_base((unsigned long) 21 - ioremap(BONITO_PCIIO_BASE, BONITO_PCIIO_SIZE)); 21 + ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE)); 22 22 23 23 prom_init_cmdline(); 24 24 prom_init_env();
+6 -6
arch/mips/loongson/common/irq.c
··· 20 20 int i; 21 21 22 22 /* workaround the IO dma problem: let cpu looping to allow DMA finish */ 23 - int_status = BONITO_INTISR; 23 + int_status = LOONGSON_INTISR; 24 24 if (int_status & (1 << 10)) { 25 25 while (int_status & (1 << 10)) { 26 26 udelay(1); 27 - int_status = BONITO_INTISR; 27 + int_status = LOONGSON_INTISR; 28 28 } 29 29 } 30 30 31 31 /* Get pending sources, masked by current enables */ 32 - int_status = BONITO_INTISR & BONITO_INTEN; 32 + int_status = LOONGSON_INTISR & LOONGSON_INTEN; 33 33 34 34 if (int_status != 0) { 35 35 i = __ffs(int_status); 36 36 int_status &= ~(1 << i); 37 - do_IRQ(BONITO_IRQ_BASE + i); 37 + do_IRQ(LOONGSON_IRQ_BASE + i); 38 38 } 39 39 } 40 40 ··· 60 60 set_irq_trigger_mode(); 61 61 62 62 /* no steer */ 63 - BONITO_INTSTEER = 0; 63 + LOONGSON_INTSTEER = 0; 64 64 65 65 /* 66 66 * Mask out all interrupt by writing "1" to all bit position in 67 67 * the interrupt reset reg. 68 68 */ 69 - BONITO_INTENCLR = ~0; 69 + LOONGSON_INTENCLR = ~0; 70 70 71 71 /* machine specific irq init */ 72 72 mach_init_irq();
+6 -6
arch/mips/loongson/common/pci.c
··· 27 27 }; 28 28 29 29 static struct pci_controller loongson_pci_controller = { 30 - .pci_ops = &bonito64_pci_ops, 30 + .pci_ops = &loongson_pci_ops, 31 31 .io_resource = &loongson_pci_io_resource, 32 32 .mem_resource = &loongson_pci_mem_resource, 33 33 .mem_offset = 0x00000000UL, ··· 44 44 * pcimap: PCI_MAP2 PCI_Mem_Lo2 PCI_Mem_Lo1 PCI_Mem_Lo0 45 45 * [<2G] [384M,448M] [320M,384M] [0M,64M] 46 46 */ 47 - BONITO_PCIMAP = BONITO_PCIMAP_PCIMAP_2 | 48 - BONITO_PCIMAP_WIN(2, BONITO_PCILO2_BASE) | 49 - BONITO_PCIMAP_WIN(1, BONITO_PCILO1_BASE) | 50 - BONITO_PCIMAP_WIN(0, 0); 47 + LOONGSON_PCIMAP = LOONGSON_PCIMAP_PCIMAP_2 | 48 + LOONGSON_PCIMAP_WIN(2, LOONGSON_PCILO2_BASE) | 49 + LOONGSON_PCIMAP_WIN(1, LOONGSON_PCILO1_BASE) | 50 + LOONGSON_PCIMAP_WIN(0, 0); 51 51 52 52 /* 53 53 * PCI-DMA to local mapping: [2G,2G+256M] -> [0M,256M] 54 54 */ 55 - BONITO_PCIBASE0 = 0x80000000ul; /* base: 2G -> mmap: 0M */ 55 + LOONGSON_PCIBASE0 = 0x80000000ul; /* base: 2G -> mmap: 0M */ 56 56 /* size: 256M, burst transmission, pre-fetch enable, 64bit */ 57 57 LOONGSON_PCI_HIT0_SEL_L = 0xc000000cul; 58 58 LOONGSON_PCI_HIT0_SEL_H = 0xfffffffful;
+1 -1
arch/mips/loongson/common/reset.c
··· 22 22 mach_prepare_reboot(); 23 23 24 24 /* reboot via jumping to boot base address */ 25 - ((void (*)(void))ioremap_nocache(BONITO_BOOT_BASE, 4)) (); 25 + ((void (*)(void))ioremap_nocache(LOONGSON_BOOT_BASE, 4)) (); 26 26 } 27 27 28 28 static void loongson_halt(void)
+2 -2
arch/mips/loongson/fuloong-2e/irq.c
··· 47 47 void __init set_irq_trigger_mode(void) 48 48 { 49 49 /* most bonito irq should be level triggered */ 50 - BONITO_INTEDGE = BONITO_ICU_SYSTEMERR | BONITO_ICU_MASTERERR | 51 - BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES; 50 + LOONGSON_INTEDGE = LOONGSON_ICU_SYSTEMERR | LOONGSON_ICU_MASTERERR | 51 + LOONGSON_ICU_RETRYERR | LOONGSON_ICU_MBOXES; 52 52 } 53 53 54 54 void __init mach_init_irq(void)
+2 -2
arch/mips/loongson/fuloong-2e/reset.c
··· 14 14 15 15 void mach_prepare_reboot(void) 16 16 { 17 - BONITO_BONGENCFG &= ~(1 << 2); 18 - BONITO_BONGENCFG |= (1 << 2); 17 + LOONGSON_GENCFG &= ~(1 << 2); 18 + LOONGSON_GENCFG |= (1 << 2); 19 19 } 20 20 21 21 void mach_prepare_shutdown(void)
+1 -1
arch/mips/pci/Makefile
··· 28 28 obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o 29 29 obj-$(CONFIG_SOC_AU1550) += fixup-au1000.o ops-au1000.o 30 30 obj-$(CONFIG_SOC_PNX8550) += fixup-pnx8550.o ops-pnx8550.o 31 - obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-bonito64.o 31 + obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-fuloong2e.o 32 32 obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o 33 33 obj-$(CONFIG_PMC_MSP7120_GW) += fixup-pmcmsp.o ops-pmcmsp.o 34 34 obj-$(CONFIG_PMC_MSP7120_EVAL) += fixup-pmcmsp.o ops-pmcmsp.o
+3 -2
arch/mips/pci/fixup-fuloong2e.c
··· 13 13 */ 14 14 #include <linux/init.h> 15 15 #include <linux/pci.h> 16 - #include <asm/mips-boards/bonito64.h> 16 + 17 + #include <loongson.h> 17 18 18 19 /* South bridge slot number is set by the pci probe process */ 19 20 static u8 sb_slot = 5; ··· 36 35 break; 37 36 } 38 37 } else { 39 - irq = BONITO_IRQ_BASE + 25 + pin; 38 + irq = LOONGSON_IRQ_BASE + 25 + pin; 40 39 } 41 40 return irq; 42 41
-7
arch/mips/pci/ops-bonito64.c
··· 29 29 #define PCI_ACCESS_READ 0 30 30 #define PCI_ACCESS_WRITE 1 31 31 32 - #ifdef CONFIG_LEMOTE_FULOONG2E 33 - #define CFG_SPACE_REG(offset) (void *)CKSEG1ADDR(BONITO_PCICFG_BASE | (offset)) 34 - #define ID_SEL_BEGIN 11 35 - #else 36 32 #define CFG_SPACE_REG(offset) (void *)CKSEG1ADDR(_pcictrl_bonito_pcicfg + (offset)) 37 33 #define ID_SEL_BEGIN 10 38 - #endif 39 34 #define MAX_DEV_NUM (31 - ID_SEL_BEGIN) 40 35 41 36 ··· 72 77 addrp = CFG_SPACE_REG(addr & 0xffff); 73 78 if (access_type == PCI_ACCESS_WRITE) { 74 79 writel(cpu_to_le32(*data), addrp); 75 - #ifndef CONFIG_LEMOTE_FULOONG2E 76 80 /* Wait till done */ 77 81 while (BONITO_PCIMSTAT & 0xF); 78 - #endif 79 82 } else { 80 83 *data = le32_to_cpu(readl(addrp)); 81 84 }
+154
arch/mips/pci/ops-fuloong2e.c
··· 1 + /* 2 + * fuloong2e specific PCI support. 3 + * 4 + * Copyright (C) 1999, 2000, 2004 MIPS Technologies, Inc. 5 + * All rights reserved. 6 + * Authors: Carsten Langgaard <carstenl@mips.com> 7 + * Maciej W. Rozycki <macro@mips.com> 8 + * 9 + * Copyright (C) 2009 Lemote Inc. 10 + * Author: Wu Zhangjin <wuzj@lemote.com> 11 + * 12 + * This program is free software; you can distribute it and/or modify it 13 + * under the terms of the GNU General Public License (Version 2) as 14 + * published by the Free Software Foundation. 15 + */ 16 + #include <linux/types.h> 17 + #include <linux/pci.h> 18 + #include <linux/kernel.h> 19 + #include <linux/init.h> 20 + 21 + #include <loongson.h> 22 + 23 + #define PCI_ACCESS_READ 0 24 + #define PCI_ACCESS_WRITE 1 25 + 26 + #define CFG_SPACE_REG(offset) \ 27 + (void *)CKSEG1ADDR(LOONGSON_PCICFG_BASE | (offset)) 28 + #define ID_SEL_BEGIN 11 29 + #define MAX_DEV_NUM (31 - ID_SEL_BEGIN) 30 + 31 + 32 + static int loongson_pcibios_config_access(unsigned char access_type, 33 + struct pci_bus *bus, 34 + unsigned int devfn, int where, 35 + u32 *data) 36 + { 37 + u32 busnum = bus->number; 38 + u32 addr, type; 39 + u32 dummy; 40 + void *addrp; 41 + int device = PCI_SLOT(devfn); 42 + int function = PCI_FUNC(devfn); 43 + int reg = where & ~3; 44 + 45 + if (busnum == 0) { 46 + /* Type 0 configuration for onboard PCI bus */ 47 + if (device > MAX_DEV_NUM) 48 + return -1; 49 + 50 + addr = (1 << (device + ID_SEL_BEGIN)) | (function << 8) | reg; 51 + type = 0; 52 + } else { 53 + /* Type 1 configuration for offboard PCI bus */ 54 + addr = (busnum << 16) | (device << 11) | (function << 8) | reg; 55 + type = 0x10000; 56 + } 57 + 58 + /* Clear aborts */ 59 + LOONGSON_PCICMD |= LOONGSON_PCICMD_MABORT_CLR | \ 60 + LOONGSON_PCICMD_MTABORT_CLR; 61 + 62 + LOONGSON_PCIMAP_CFG = (addr >> 16) | type; 63 + 64 + /* Flush Bonito register block */ 65 + dummy = LOONGSON_PCIMAP_CFG; 66 + mmiowb(); 67 + 68 + addrp = CFG_SPACE_REG(addr & 0xffff); 69 + if (access_type == PCI_ACCESS_WRITE) 70 + writel(cpu_to_le32(*data), addrp); 71 + else 72 + *data = le32_to_cpu(readl(addrp)); 73 + 74 + /* Detect Master/Target abort */ 75 + if (LOONGSON_PCICMD & (LOONGSON_PCICMD_MABORT_CLR | 76 + LOONGSON_PCICMD_MTABORT_CLR)) { 77 + /* Error occurred */ 78 + 79 + /* Clear bits */ 80 + LOONGSON_PCICMD |= (LOONGSON_PCICMD_MABORT_CLR | 81 + LOONGSON_PCICMD_MTABORT_CLR); 82 + 83 + return -1; 84 + } 85 + 86 + return 0; 87 + 88 + } 89 + 90 + 91 + /* 92 + * We can't address 8 and 16 bit words directly. Instead we have to 93 + * read/write a 32bit word and mask/modify the data we actually want. 94 + */ 95 + static int loongson_pcibios_read(struct pci_bus *bus, unsigned int devfn, 96 + int where, int size, u32 *val) 97 + { 98 + u32 data = 0; 99 + 100 + if ((size == 2) && (where & 1)) 101 + return PCIBIOS_BAD_REGISTER_NUMBER; 102 + else if ((size == 4) && (where & 3)) 103 + return PCIBIOS_BAD_REGISTER_NUMBER; 104 + 105 + if (loongson_pcibios_config_access(PCI_ACCESS_READ, bus, devfn, where, 106 + &data)) 107 + return -1; 108 + 109 + if (size == 1) 110 + *val = (data >> ((where & 3) << 3)) & 0xff; 111 + else if (size == 2) 112 + *val = (data >> ((where & 3) << 3)) & 0xffff; 113 + else 114 + *val = data; 115 + 116 + return PCIBIOS_SUCCESSFUL; 117 + } 118 + 119 + static int loongson_pcibios_write(struct pci_bus *bus, unsigned int devfn, 120 + int where, int size, u32 val) 121 + { 122 + u32 data = 0; 123 + 124 + if ((size == 2) && (where & 1)) 125 + return PCIBIOS_BAD_REGISTER_NUMBER; 126 + else if ((size == 4) && (where & 3)) 127 + return PCIBIOS_BAD_REGISTER_NUMBER; 128 + 129 + if (size == 4) 130 + data = val; 131 + else { 132 + if (loongson_pcibios_config_access(PCI_ACCESS_READ, bus, devfn, 133 + where, &data)) 134 + return -1; 135 + 136 + if (size == 1) 137 + data = (data & ~(0xff << ((where & 3) << 3))) | 138 + (val << ((where & 3) << 3)); 139 + else if (size == 2) 140 + data = (data & ~(0xffff << ((where & 3) << 3))) | 141 + (val << ((where & 3) << 3)); 142 + } 143 + 144 + if (loongson_pcibios_config_access(PCI_ACCESS_WRITE, bus, devfn, where, 145 + &data)) 146 + return -1; 147 + 148 + return PCIBIOS_SUCCESSFUL; 149 + } 150 + 151 + struct pci_ops loongson_pci_ops = { 152 + .read = loongson_pcibios_read, 153 + .write = loongson_pcibios_write 154 + };