wdenk | e69b4b8 | 2002-09-17 21:26:59 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 ELTEC Elektronik AG |
| 3 | * Frank Gottschling <fgottschling@eltec.de> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | e69b4b8 | 2002-09-17 21:26:59 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * PCI initialisation for the MPC10x. |
| 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <pci.h> |
| 14 | #include <mpc106.h> |
| 15 | |
| 16 | #ifdef CONFIG_PCI |
| 17 | |
| 18 | struct pci_controller local_hose; |
| 19 | |
stroese | f5dd410 | 2003-02-14 11:21:23 +0000 | [diff] [blame] | 20 | void pci_init_board(void) |
wdenk | e69b4b8 | 2002-09-17 21:26:59 +0000 | [diff] [blame] | 21 | { |
| 22 | struct pci_controller* hose = (struct pci_controller *)&local_hose; |
| 23 | u16 reg16; |
| 24 | |
| 25 | hose->first_busno = 0; |
| 26 | hose->last_busno = 0xff; |
| 27 | |
| 28 | pci_set_region(hose->regions + 0, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 29 | CONFIG_SYS_PCI_MEMORY_BUS, |
| 30 | CONFIG_SYS_PCI_MEMORY_PHYS, |
| 31 | CONFIG_SYS_PCI_MEMORY_SIZE, |
Kumar Gala | efa1f1d | 2009-02-06 09:49:31 -0600 | [diff] [blame] | 32 | PCI_REGION_MEM | PCI_REGION_SYS_MEMORY); |
wdenk | e69b4b8 | 2002-09-17 21:26:59 +0000 | [diff] [blame] | 33 | |
| 34 | /* PCI memory space */ |
| 35 | pci_set_region(hose->regions + 1, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 36 | CONFIG_SYS_PCI_MEM_BUS, |
| 37 | CONFIG_SYS_PCI_MEM_PHYS, |
| 38 | CONFIG_SYS_PCI_MEM_SIZE, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 39 | PCI_REGION_MEM); |
wdenk | e69b4b8 | 2002-09-17 21:26:59 +0000 | [diff] [blame] | 40 | |
| 41 | /* ISA/PCI memory space */ |
| 42 | pci_set_region(hose->regions + 2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 43 | CONFIG_SYS_ISA_MEM_BUS, |
| 44 | CONFIG_SYS_ISA_MEM_PHYS, |
| 45 | CONFIG_SYS_ISA_MEM_SIZE, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 46 | PCI_REGION_MEM); |
wdenk | e69b4b8 | 2002-09-17 21:26:59 +0000 | [diff] [blame] | 47 | |
| 48 | /* PCI I/O space */ |
| 49 | pci_set_region(hose->regions + 3, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 50 | CONFIG_SYS_PCI_IO_BUS, |
| 51 | CONFIG_SYS_PCI_IO_PHYS, |
| 52 | CONFIG_SYS_PCI_IO_SIZE, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 53 | PCI_REGION_IO); |
wdenk | e69b4b8 | 2002-09-17 21:26:59 +0000 | [diff] [blame] | 54 | |
| 55 | /* ISA/PCI I/O space */ |
| 56 | pci_set_region(hose->regions + 4, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 57 | CONFIG_SYS_ISA_IO_BUS, |
| 58 | CONFIG_SYS_ISA_IO_PHYS, |
| 59 | CONFIG_SYS_ISA_IO_SIZE, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 60 | PCI_REGION_IO); |
wdenk | e69b4b8 | 2002-09-17 21:26:59 +0000 | [diff] [blame] | 61 | |
| 62 | hose->region_count = 5; |
| 63 | |
| 64 | pci_setup_indirect(hose, |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 65 | MPC106_REG_ADDR, |
| 66 | MPC106_REG_DATA); |
wdenk | e69b4b8 | 2002-09-17 21:26:59 +0000 | [diff] [blame] | 67 | |
| 68 | pci_register_hose(hose); |
| 69 | |
| 70 | hose->last_busno = pci_hose_scan(hose); |
| 71 | |
| 72 | /* Initialises the MPC10x PCI Configuration regs. */ |
| 73 | pci_read_config_word (PCI_BDF(0,0,0), PCI_COMMAND, ®16); |
| 74 | reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY; |
| 75 | pci_write_config_word(PCI_BDF(0,0,0), PCI_COMMAND, reg16); |
| 76 | |
| 77 | /* Clear non-reserved bits in status register */ |
| 78 | pci_write_config_word(PCI_BDF(0,0,0), PCI_STATUS, 0xffff); |
| 79 | } |
| 80 | |
| 81 | #endif /* CONFIG_PCI */ |