Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2006 Freescale Semiconductor. |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 6 | #include <pci.h> |
| 7 | |
| 8 | /* Config the VIA chip */ |
Jon Loeliger | 3a0cf25 | 2006-10-10 17:02:22 -0500 | [diff] [blame] | 9 | void mpc85xx_config_via(struct pci_controller *hose, |
| 10 | pci_dev_t dev, struct pci_config_table *tab) |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 11 | { |
| 12 | pci_dev_t bridge; |
Andy Fleming | 4eabb1f | 2007-08-14 01:50:09 -0500 | [diff] [blame] | 13 | unsigned int cmdstat; |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 14 | |
| 15 | /* Enable USB and IDE functions */ |
| 16 | pci_hose_write_config_byte(hose, dev, 0x48, 0x08); |
| 17 | |
Andy Fleming | 4eabb1f | 2007-08-14 01:50:09 -0500 | [diff] [blame] | 18 | pci_hose_read_config_dword(hose, dev, PCI_COMMAND, &cmdstat); |
| 19 | cmdstat |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY| PCI_COMMAND_MASTER; |
| 20 | pci_hose_write_config_dword(hose, dev, PCI_COMMAND, cmdstat); |
| 21 | pci_hose_write_config_byte(hose, dev, PCI_CACHE_LINE_SIZE, 0x08); |
| 22 | pci_hose_write_config_byte(hose, dev, PCI_LATENCY_TIMER, 0x80); |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 23 | |
| 24 | /* |
| 25 | * Force the backplane P2P bridge to have a window |
| 26 | * open from 0x00000000-0x00001fff in PCI I/O space. |
| 27 | * This allows legacy I/O (i8259, etc) on the VIA |
| 28 | * southbridge to be accessed. |
| 29 | */ |
Tom Rini | fe3ddcc | 2022-03-23 17:19:58 -0400 | [diff] [blame] | 30 | #ifdef CONFIG_TARGET_MPC8548CDS_LEGACY |
| 31 | bridge = PCI_BDF(0, 17, 0); |
| 32 | #else |
| 33 | bridge = PCI_BDF(0, 28, 0); |
| 34 | #endif |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 35 | pci_hose_write_config_byte(hose, bridge, PCI_IO_BASE, 0); |
| 36 | pci_hose_write_config_word(hose, bridge, PCI_IO_BASE_UPPER16, 0); |
| 37 | pci_hose_write_config_byte(hose, bridge, PCI_IO_LIMIT, 0x10); |
| 38 | pci_hose_write_config_word(hose, bridge, PCI_IO_LIMIT_UPPER16, 0); |
| 39 | } |
| 40 | |
| 41 | /* Function 1, IDE */ |
Jon Loeliger | 3a0cf25 | 2006-10-10 17:02:22 -0500 | [diff] [blame] | 42 | void mpc85xx_config_via_usbide(struct pci_controller *hose, |
| 43 | pci_dev_t dev, struct pci_config_table *tab) |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 44 | { |
| 45 | pciauto_config_device(hose, dev); |
| 46 | /* |
| 47 | * Since the P2P window was forced to cover the fixed |
| 48 | * legacy I/O addresses, it is necessary to manually |
| 49 | * place the base addresses for the IDE and USB functions |
| 50 | * within this window. |
| 51 | */ |
| 52 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_0, 0x1ff8); |
| 53 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_1, 0x1ff4); |
| 54 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_2, 0x1fe8); |
| 55 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_3, 0x1fe4); |
| 56 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_4, 0x1fd0); |
| 57 | } |
| 58 | |
| 59 | /* Function 2, USB ports 0-1 */ |
Jon Loeliger | 3a0cf25 | 2006-10-10 17:02:22 -0500 | [diff] [blame] | 60 | void mpc85xx_config_via_usb(struct pci_controller *hose, |
| 61 | pci_dev_t dev, struct pci_config_table *tab) |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 62 | { |
| 63 | pciauto_config_device(hose, dev); |
| 64 | |
| 65 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_4, 0x1fa0); |
| 66 | } |
| 67 | |
| 68 | /* Function 3, USB ports 2-3 */ |
Jon Loeliger | 3a0cf25 | 2006-10-10 17:02:22 -0500 | [diff] [blame] | 69 | void mpc85xx_config_via_usb2(struct pci_controller *hose, |
| 70 | pci_dev_t dev, struct pci_config_table *tab) |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 71 | { |
| 72 | pciauto_config_device(hose, dev); |
| 73 | |
| 74 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_4, 0x1f80); |
| 75 | } |
| 76 | |
| 77 | /* Function 5, Power Management */ |
Jon Loeliger | 3a0cf25 | 2006-10-10 17:02:22 -0500 | [diff] [blame] | 78 | void mpc85xx_config_via_power(struct pci_controller *hose, |
| 79 | pci_dev_t dev, struct pci_config_table *tab) |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 80 | { |
| 81 | pciauto_config_device(hose, dev); |
| 82 | |
| 83 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_0, 0x1e00); |
| 84 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_1, 0x1dfc); |
| 85 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_2, 0x1df8); |
| 86 | } |
| 87 | |
| 88 | /* Function 6, AC97 Interface */ |
Jon Loeliger | 3a0cf25 | 2006-10-10 17:02:22 -0500 | [diff] [blame] | 89 | void mpc85xx_config_via_ac97(struct pci_controller *hose, |
| 90 | pci_dev_t dev, struct pci_config_table *tab) |
Matthew McClintock | aa6dd06 | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 91 | { |
| 92 | pciauto_config_device(hose, dev); |
| 93 | |
| 94 | pci_hose_write_config_dword(hose, dev, PCI_BASE_ADDRESS_0, 0x1c00); |
| 95 | } |