Browse Source

ls2k remove some useless code.

Change-Id: I6ef07ced1412d9e957b83074eb6f1437706d8eaf
master
zhangbaoqi 7 years ago
parent
commit
7b9a766d45
  1. 4
      Targets/LS2K/conf/ls2k
  2. 17
      pmon/dev/kbd.c
  3. 2
      sys/dev/bus_dma.c
  4. 4
      sys/dev/gmac/synopGMAC_network_interface.c
  5. 27
      sys/dev/pci/ahci.c
  6. 88
      sys/dev/pci/pciconf.c
  7. 4
      sys/dev/pci/pciide.c
  8. 4
      sys/dev/pci/pcivar.h
  9. 46
      sys/dev/usb/usb-ohci.c
  10. 2
      sys/dev/usb/usb_storage.c

4
Targets/LS2K/conf/ls2k

@ -168,8 +168,8 @@ ahci* at pci? dev ? function ?
ahci_sd* at ahci?
ahci_cdrom* at ahci?
lohci* at pci? dev ? function ? # OHCI
usb* at lohci?
ohci* at pci? dev ? function ? # OHCI
usb* at ohci?
#lehci* at pci? dev ? function ? # EHCI
#usb* at lehci?

17
pmon/dev/kbd.c

@ -2,9 +2,6 @@
#include<linux/types.h>
#include<linux/io.h>
#include"kbd.h"
#if defined(LOONGSON_2K)
#include "mod_usb_ohci.h"
#endif
/*
* Translation of escaped scancodes to keycodes.
@ -171,15 +168,8 @@ static void kbd_wait(void)
if (!(status & KBD_STAT_IBF))
return;
delay(1000); // don not exceed 100ms,or usb keyboard may suspend when you press
#if defined(LOONGSON_2K)
#if NMOD_USB_OHCI
if(ohci_index) // deal with usb kbd
dl_ohci_kbd();
#endif
#else
if(ohci_index) // deal with usb kbd
dl_ohci_kbd();
#endif
timeout--;
} while (timeout);
}
@ -241,15 +231,8 @@ static int kbd_wait_for_input(void)
if (retval >= 0)
return retval;
delay(1000); //don not exceed 100ms, or usb kbd may suspend
#if defined(LOONGSON_2K)
#if NMOD_USB_OHCI
if(ohci_index) // deal with usb kbd
dl_ohci_kbd();
#endif
#else
if(ohci_index) // deal with usb kbd
dl_ohci_kbd();
#endif
} while (--timeout);
return -1;
}

2
sys/dev/bus_dma.c

@ -453,9 +453,7 @@ _dmamem_free(t, segs, nsegs)
int curseg;
for (curseg = 0; curseg < nsegs; curseg++) {
#if defined(LOONGSON_2K)
addr = segs[curseg].ds_addr;
#endif
free((void *)addr, M_DMAMAP);
}
}

4
sys/dev/gmac/synopGMAC_network_interface.c

@ -40,10 +40,6 @@
#include "target/ls1a.h"
#endif
#if defined(LOONGSON_2K)
#include "target/ls2k.h"
#endif
//sw: ioctl in linux to be fixed
#define SIOCDEVPRIVATE 0x89f0
#define IOCTL_READ_REGISTER SIOCDEVPRIVATE+1

27
sys/dev/pci/ahci.c

@ -110,14 +110,10 @@ static int ahci_match(struct device *parent, void *match, void *aux)
{
struct pci_attach_args *pa = aux;
#if defined(LOONGSON_2K)
if((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SATA && PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SATA) || (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_2KSATA && PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_2KSATA))
#else
printf("%s:%d \n", __FUNCTION__, __LINE__);
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SATA &&
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SATA)
#endif
if((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SATA && PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SATA) ||
(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_2KSATA && PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_2KSATA))
return 1;
return 0;
}
@ -132,25 +128,16 @@ static void ahci_attach(struct device *parent, struct device *self, void *aux)
u32 linkmap;
ahci_sata_info_t info;
#if defined(LOONGSON_2K)
if((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_2KSATA && PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_2KSATA))
{
if (pci_mem_find(NULL, pa->pa_tag, 0x10, &membasep, &memsizep, NULL)) {
printf(" Can't find mem space\n");
return;
}
}
else if (pci_mem_find(NULL, pa->pa_tag, 0x24, &membasep, &memsizep, NULL)) {
printf(" Can't find mem space\n");
if (pci_mem_find(NULL, pa->pa_tag, 0x10, &membasep, &memsizep, NULL)) {
printf(" Can't find mem space\n");
return;
}
#else
printf("\n~~~~~~~~~~~~~~~~~ahcisata_attach~~~~~~~~~~~~~~~~~~\n");
if (pci_mem_find(NULL, pa->pa_tag, 0x24, &membasep, &memsizep, NULL)) {
}
} else if (pci_mem_find(NULL, pa->pa_tag, 0x24, &membasep, &memsizep, NULL)) {
printf(" Can't find mem space\n");
return;
}
#endif
printf("Found memory space: memt->bus_base=0x%x, baseaddr=0x%x"
"size=0x%x\n", memt->bus_base, (u32) (membasep),
(u32) (memsizep));

88
sys/dev/pci/pciconf.c

@ -85,13 +85,8 @@ static int _pci_setupIntRouting(struct pci_device *);
static void _pci_scan_dev(struct pci_device *dev, int bus, int device, int initialise);
static void _insertsort_window(struct pci_win **, struct pci_win *);
static void _pci_device_insert(struct pci_device *parent, struct pci_device *device);
#if defined(LOONGSON_2K)
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));
#else
pcireg_t _pci_allocate_mem __P((struct pci_device *, vm_size_t));
pcireg_t _pci_allocate_io __P((struct pci_device *, vm_size_t));
#endif
static void _setup_pcibuses(int );
static void _pci_bus_insert(struct pci_bus *);
@ -111,11 +106,7 @@ bool is_pcie_vga_card();
#define VPRINTF vprintf
#ifndef PCIVERBOSE
#if defined(LOONGSON_2K)
#define _PCIVERBOSE 5
#else
#define _PCIVERBOSE 0
#endif
#else
#define _PCIVERBOSE PCIVERBOSE
#endif
@ -417,41 +408,28 @@ if(pm_io == NULL) {
/* Sum up I/O Space needed */
#if defined(LOONGSON_2K)
int max=0;
#endif
for(pm = pd->bridge.iospace; pm != NULL; pm = pm->next) {
#if defined(LOONGSON_2K)
if(max < pm->align)
max = pm->align;
#endif
pm_io->size += pm->size;
}
#if defined(LOONGSON_2K)
pm_io->size = (pm_io->size + max -1) & ~(max-1);
if(max < 0x1000) max = 0x1000;
pd->bridge.io_mask = ~(max-1);
pm_io->align = max;
#endif
/* Sum up Memory Space needed */
#if defined(LOONGSON_2K)
max=0;
#endif
for(pm = pd->bridge.memspace; pm != NULL; pm = pm->next) {
#if defined(LOONGSON_2K)
if(max < pm->align)
max = pm->align;
#endif
pm_mem->size += pm->size;
}
#if defined(LOONGSON_2K)
pm_mem->size = (pm_mem->size + max -1) & ~(max-1);
if(max<0x100000) max = 0x100000;
pd->bridge.mem_mask = ~(max-1);
pm_mem->align = max;
#endif
/* Round to minimum granularity requierd for a bridge */
pm_io->size = _pci_roundup(pm_io->size, 0x1000);
pm_mem->size = _pci_roundup(pm_mem->size, 0x100000);
@ -518,9 +496,7 @@ if(pm_io == NULL) {
pm->reg = reg;
pm->flags = PCI_MAPREG_TYPE_IO;
pm->size = -(PCI_MAPREG_IO_ADDR(mask));
#if defined(LOONGSON_2K)
pm->align = pm->size;
#endif
_insertsort_window(&pd->parent->bridge.iospace, pm);
}
else {
@ -560,9 +536,7 @@ if(pm_io == NULL) {
}
}
#endif
#if defined(LOONGSON_2K)
pm->align = pm->size;
#endif
pm->align = pm->size;
_insertsort_window(&pd->parent->bridge.memspace, pm);
}
}
@ -589,9 +563,7 @@ if(pm_io == NULL) {
pm->device = pd;
pm->reg = reg;
pm->size = -(PCI_MAPREG_ROM_ADDR(mask));
#if defined(LOONGSON_2K)
pm->align = pm->size;
#endif
_insertsort_window(&pd->parent->bridge.memspace, pm);
}
}
@ -710,22 +682,15 @@ _pci_query_dev (struct pci_device *dev, int bus, int device, int initialise)
pcireg_t
#if defined(LOONGSON_2K)
_pci_allocate_mem(struct pci_device *dev, vm_size_t size, unsigned int align)
#else
_pci_allocate_mem(dev, size)
_pci_allocate_mem(dev, size, align)
struct pci_device *dev;
vm_size_t size;
#endif
unsigned int align;
{
pcireg_t address,address1;
#ifdef PCI_ALLOC_MEM_DOWNWARDS
/* allocate downwards, then round to size boundary */
#if defined(LOONGSON_2K)
address = (dev->bridge.secbus->nextpcimemaddr - size) & ~(align - 1);
#else
address = (dev->bridge.secbus->nextpcimemaddr - size) & ~(size - 1);
#endif
if (address > dev->bridge.secbus->nextpcimemaddr ||
address < dev->bridge.secbus->minpcimemaddr) {
return(-1);
@ -733,11 +698,7 @@ _pci_allocate_mem(dev, size)
dev->bridge.secbus->nextpcimemaddr = address;
#else
/* allocate upwards, then round to size boundary */
#if defined(LOONGSON_2K)
address = (dev->bridge.secbus->minpcimemaddr + size-1) & ~(size - 1);
#else
address = (dev->bridge.secbus->minpcimemaddr + size-1) & ~(size - 1);
#endif
address = (dev->bridge.secbus->minpcimemaddr + align-1) & ~(align - 1);
address1 = address + size;
if (address1 > dev->bridge.secbus->nextpcimemaddr ||
address1 < dev->bridge.secbus->minpcimemaddr) {
@ -751,22 +712,12 @@ _pci_allocate_mem(dev, size)
pcireg_t
#if defined(LOONGSON_2K)
_pci_allocate_io(struct pci_device *dev, vm_size_t size, unsigned int align)
#else
_pci_allocate_io(dev, size)
struct pci_device *dev;
vm_size_t size;
#endif
{
pcireg_t address,address1;
#ifdef PCI_ALLOC_IO_DOWNWARDS
/* allocate downwards, then round to size boundary */
#if defined(LOONGSON_2K)
address = (dev->bridge.secbus->nextpciioaddr - align) & ~(align - 1);
#else
address = (dev->bridge.secbus->nextpciioaddr - size) & ~(size - 1);
#endif
if (address > dev->bridge.secbus->nextpciioaddr ||
address < dev->bridge.secbus->minpciioaddr) {
return -1;
@ -774,11 +725,7 @@ _pci_allocate_io(dev, size)
dev->bridge.secbus->nextpciioaddr = address;
#else
/* allocate upwards, then round to size boundary */
#if defined(LOONGSON_2K)
address = (dev->bridge.secbus->nextpciioaddr - align) & ~(align - 1);
#else
address=(dev->bridge.secbus->minpciioaddr+size-1)& ~(size - 1);
#endif
address=(dev->bridge.secbus->minpciioaddr+align-1)& ~(align - 1);
address1 = address+size;
if (address1 > dev->bridge.secbus->nextpciioaddr ||
address1 < dev->bridge.secbus->minpciioaddr) {
@ -798,11 +745,7 @@ _insertsort_window(pm_list, pm)
pm1 = (struct pci_win *)pm_list;
while((pm2 = pm1->next)) {
#if defined(LOONGSON_2K)
if(pm->align >= pm2->align) {
#else
if(pm->size >= pm2->size) {
#endif
break;
}
pm1 = pm2;
@ -816,31 +759,23 @@ _insertsort_window(pm_list, pm)
#define PCI_BIGMEM_ADDRESS 0x40000000
#endif
static pci_bigmem_address=PCI_BIGMEM_ADDRESS;
#if defined(LOONGSON_2K)
static pci_bigio_address=0x10000;
#endif
static void
_pci_setup_windows (struct pci_device *dev)
{
struct pci_win *pm;
struct pci_win *next;
struct pci_device *pd;
#if defined(LOONGSON_2K)
unsigned int align;
#endif
for(pm = dev->bridge.memspace; pm != NULL; pm = next) {
pd = pm->device;
next = pm->next;
#if defined(LOONGSON_2K)
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);
#else
pm->address = _pci_allocate_mem (dev, pm->size);
#endif
if (pm->address == -1) {
pci_bigmem_address = (pci_bigmem_address + pm->size-1) & ~(pm->size - 1);
pm->address = pci_bigmem_address;
@ -854,11 +789,7 @@ _pci_setup_windows (struct pci_device *dev)
//continue;
}
if (_pciverbose >= 2)
#if defined(LOONGSON_2K)
_pci_tagprintf (pd->pa.pa_tag, "mem @%p, reg 0x%x %d bytes\n", pm->address, pm->reg, pm->size);
#else
_pci_tagprintf (pd->pa.pa_tag, "mem @%p, %d bytes\n", pm->address, pm->size);
#endif
#if defined(LOONGSON_2K)
if ((PCI_ISCLASS(pd->pa.pa_class, PCI_CLASS_BRIDGE, PCI_SUBCLASS_BRIDGE_PCI) || PCI_ISCLASS(pd->pa.pa_class, PCI_CLASS_PROCESSOR, 0x30)) &&
@ -963,25 +894,16 @@ _pci_setup_windows (struct pci_device *dev)
pd = pm->device;
next = pm->next;
#if defined(LOONGSON_2K)
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);
#else
pm->address = _pci_allocate_io (dev, pm->size);
#endif
if (pm->address == -1) {
_pci_tagprintf (pd->pa.pa_tag,
"not enough PCI io space (%d requested)\n",
pm->size);
#if defined(LOONGSON_2K)
pm->address = pci_bigio_address;
pci_bigio_address += pm->size;
#else
pfree(pm);
continue;
#endif
}
if (_pciverbose >= 2)
#if defined(LOONGSON_2K)

4
sys/dev/pci/pciide.c

@ -302,7 +302,6 @@ const struct pciide_product_desc pciide_amd_products[] = {
},
};
#ifndef LOONGSON_2K
const struct pciide_product_desc pciide_cmd_products[] = {
{ PCI_PRODUCT_CMDTECH_640, /* CMD Technology PCI0640 */
0,
@ -321,7 +320,6 @@ const struct pciide_product_desc pciide_cmd_products[] = {
cmd0643_6_chip_map
}
};
#endif
#ifndef PMON
const struct pciide_product_desc pciide_via_products[] = {
@ -399,10 +397,8 @@ const struct pciide_vendor_desc pciide_vendors[] = {
sizeof(pciide_intel_products)/sizeof(pciide_intel_products[0]) },
{ PCI_VENDOR_AMD, pciide_amd_products,
sizeof(pciide_amd_products)/sizeof(pciide_amd_products[0]) },
#ifndef LOONGSON_2K
{ PCI_VENDOR_CMDTECH, pciide_cmd_products,
sizeof(pciide_cmd_products)/sizeof(pciide_cmd_products[0]) },
#endif
#ifndef PMON
{ PCI_VENDOR_VIATECH, pciide_via_products,
sizeof(pciide_via_products)/sizeof(pciide_via_products[0]) },

4
sys/dev/pci/pcivar.h

@ -227,9 +227,7 @@ struct pci_win {
int flags;
vm_size_t size;
pcireg_t address;
#if defined(LOONGSON_2K)
unsigned int align;
#endif
struct pci_device *device;
};
@ -244,10 +242,8 @@ struct pci_bridge {
struct pci_device *child;
struct pci_win *memspace;
struct pci_win *iospace;
#if defined(LOONGSON_2K)
u_int32_t mem_mask;//yang23 2013-11-26
u_int32_t io_mask;//yang23 2013-11-26
#endif
};
/*

46
sys/dev/usb/usb-ohci.c

@ -469,6 +469,9 @@ static int ohci_match(struct device *parent, void *match, void *aux)
return 1;
}
}
//for match loongson usb controler
if(PCI_VENDOR(pa->pa_id) == 0x14 && PCI_PRODUCT(pa->pa_id) == 0x7a24)
return 1;
#ifdef CONFIG_SM502_USB_HCD
if ((no502 = getenv("no502")) && strtoul(no502, NULL, 0))
return 0;
@ -482,60 +485,28 @@ static int ohci_match(struct device *parent, void *match, void *aux)
extern struct hostcontroller host_controller;
extern struct usb_device *usb_alloc_new_device(void *hc_private);
#if (defined LOONGSON_3A2H) || (defined LOONGSON_3C2H) \
|| (defined LOONGSON_2G1A) || (defined LOONGSON_2F1A) || (LOONGSON_2K)
|| (defined LOONGSON_2G1A) || (defined LOONGSON_2F1A)
static int lohci_match(struct device *parent, void *match, void *aux)
{
#if defined(LOONGSON_2K)
struct pci_attach_args *pa = aux;
if(PCI_VENDOR(pa->pa_id) == 0x14 && PCI_PRODUCT(pa->pa_id) == 0x7a24)
return 1;
return 0;
#else
return 1;
#endif
}
static void lohci_attach(struct device *parent, struct device *self, void *aux)
{
struct ohci *ohci = (struct ohci *)self;
struct confargs *cf = (struct confargs *)aux;
static int ohci_dev_index = 0;
int val;
#if defined(LOONGSON_2K)
struct pci_attach_args *pa = (struct pci_attach_args *)aux;
#define OHCI_PCI_MMBA 0x10
pci_chipset_tag_t pc = pa->pa_pc;
bus_space_tag_t memt = pa->pa_memt;
bus_addr_t membase;
bus_addr_t memsize;
int cachable;
#else
struct confargs *cf = (struct confargs *)aux;
#endif
/* Or we just return false in the match function */
if (ohci_dev_index >= MAX_OHCI_C) {
printf("Exceed max controller limits\n");
return;
}
#if defined(LOONGSON_2K)
ohci->pa = *pa;
#endif
usb_ohci_dev[ohci_dev_index++] = ohci;
#if defined(LOONGSON_2K)
if (pci_mem_find
(pc, pa->pa_tag, OHCI_PCI_MMBA, &membase, &memsize, &cachable)) {
printf("Can not find mem space for ohci\n");
return;
}
if (bus_space_map(memt, membase, memsize, 0, &ohci->sc_sh)) {
printf("Cant map mem space\n");
return;
}
#else
ohci_index++;
ohci->sc_sh = cf->ca_baseaddr;
#endif
#if defined(LOONGSON_2G1A) || defined(LOONGSON_2F1A)
/*set usb_rstn bit in LPC register0 before access usb regs */
@ -558,11 +529,6 @@ static void lohci_attach(struct device *parent, struct device *self, void *aux)
#endif
ohci->rdev = usb_alloc_new_device(ohci);
#if defined(LOONGSON_2K)
/*init sequence of EHCI*/
ohci->rdev = usb_alloc_new_device(ohci);
#endif
/*do the enumeration of the USB devices attached to the USB HUB(here root hub)
ports. */
usb_new_device(ohci->rdev);

2
sys/dev/usb/usb_storage.c

@ -1226,7 +1226,6 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
USB_STOR_PRINTF("usb_stor_get_info: skipping RESET..\n");
else
ss->transport_reset(ss);
#if defined(LOONGSON_2K)
{
#define US_BULK_GET_MAX_LUN 0xfe
char maxlun;
@ -1238,7 +1237,6 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
0, 0, &maxlun, 1, USB_CNTL_TIMEOUT);
printf("maxlun=%d\n", maxlun);
}
#endif
pccb->pdata = usb_stor_buf;

Loading…
Cancel
Save