From 075e7b2f77ab3dd2ac2d36709787064ac82631d7 Mon Sep 17 00:00:00 2001 From: QiaoChong Date: Thu, 21 Feb 2019 19:51:58 +0800 Subject: [PATCH] pci: _pci_alloc_io, _pci_alloc_mem call weak function pci_alloc_fixmemio first, to be redefined for ls2k. Change-Id: I558a4fc4fcc470de41b71524c4c264d47c08016f Signed-off-by: QiaoChong --- sys/dev/pci/pciconf.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/dev/pci/pciconf.c b/sys/dev/pci/pciconf.c index 0d93c0b6..b9c19bb1 100644 --- a/sys/dev/pci/pciconf.c +++ b/sys/dev/pci/pciconf.c @@ -87,6 +87,7 @@ static void _insertsort_window(struct pci_win **, struct pci_win *); static void _pci_device_insert(struct pci_device *parent, struct pci_device *device); pcireg_t _pci_allocate_mem __P((struct pci_device *, vm_size_t, unsigned int)); pcireg_t _pci_allocate_io __P((struct pci_device *, vm_size_t, unsigned int)); +pcireg_t __attribute__((weak)) pci_alloc_fixmemio(struct pci_win *pm); static void _setup_pcibuses(int ); static void _pci_bus_insert(struct pci_bus *); @@ -894,6 +895,11 @@ _pci_query_dev (struct pci_device *dev, int bus, int device, int initialise) } } +pcireg_t __attribute__((weak)) pci_alloc_fixmemio(struct pci_win *pm) +{ + return -1; +} + pcireg_t _pci_allocate_mem(dev, size, align) struct pci_device *dev; @@ -989,7 +995,9 @@ _pci_setup_windows (struct pci_device *dev) if(pd->bridge.child) align = ~pd->bridge.mem_mask+1; else align = 1<<(fls(pm->size)-1); - pm->address = _pci_allocate_mem (dev, pm->size, align); + pm->address = pci_alloc_fixmemio(pm); + if(pm->address == -1) + pm->address = _pci_allocate_mem (dev, pm->size, align); if (pm->address == -1) { pci_bigmem_address = (pci_bigmem_address + pm->size-1) & ~(pm->size - 1); pm->address = pci_bigmem_address; @@ -1016,8 +1024,12 @@ _pci_setup_windows (struct pci_device *dev) memory = (((pm->address+pm->size-1) >> 16) << 16) | (pm->address >> 16); _pci_conf_write(pd->pa.pa_tag, pm->reg, memory); +#ifdef LOONGSON_2K + _pci_conf_write(pd->pa.pa_tag,PCI_PMBASEL_1, memory); +#else /*set end memory bellow start memory to disable prefectable memory*/ _pci_conf_write(pd->pa.pa_tag,PCI_PMBASEL_1,0x00000010); +#endif } else if (pm->reg != PCI_MAPREG_ROM) { /* normal memory - expansion rom done below */ @@ -1104,7 +1116,9 @@ _pci_setup_windows (struct pci_device *dev) if(pd->bridge.child) align = ~pd->bridge.io_mask+1; else align = 1<<(fls(pm->size)-1); - pm->address = _pci_allocate_io (dev, pm->size, align); + pm->address = pci_alloc_fixmemio(pm); + if(pm->address == -1) + pm->address = _pci_allocate_io (dev, pm->size, align); if (pm->address == -1) { _pci_tagprintf (pd->pa.pa_tag, "not enough PCI io space (%d requested)\n",