Ticket #2998: bfe440x.4.diff

File bfe440x.4.diff, 2.9 KB (added by Adek336, 15 years ago)
  • src/add-ons/kernel/drivers/network/broadcom440x/dev/bfe/if_bfe.c

     
    430430    }
    431431}
    432432
     433
     434int bus_alloc_mem_resource_adipe(device_t dev, struct resource *res, int regid);
     435
    433436static int
    434437bfe_attach(device_t dev)
    435438{
     
    444447
    445448    sc->bfe_dev = dev;
    446449
     450    {
     451        int i=0;
     452        char buf[1024]; unsigned bp=0;
     453        while (bp < 1024 && i < 256)
     454        {
     455            if ((i & 0xf) == 0)
     456                bp += snprintf(&buf[bp], 1024-bp, "(%02x)%08x:", i, pci_read_config(dev, i, 4));
     457            else
     458                bp += snprintf(&buf[bp], 1024-bp, "%08x:", pci_read_config(dev, i, 4));
     459            i+=4;
     460        }
     461        dprintf("bfe: pci: %s\n", buf);
     462    }
     463
    447464    /*
    448465     * Map control/status registers.
    449466     */
    450467    pci_enable_busmaster(dev);
     468    //the following line means pci_set_command_bit(dev, PCI_command_memory);
     469    pci_write_config(dev, 4, pci_read_config(dev, 4, 2) | 2, 2);
    451470
    452     rid = PCIR_BAR(0);
    453     sc->bfe_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
    454             RF_ACTIVE);
     471
     472    rid = PCIR_BAR (0);
     473    //sc->bfe_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
     474    //      RF_ACTIVE);
     475    {
     476        int result;
     477        static struct resource BLERES;
     478        sc->bfe_res = &BLERES;
     479        result = bus_alloc_mem_resource_adipe(dev, sc->bfe_res, rid);
     480        if (result < 0)
     481            panic("ble");
     482        sc->bfe_res->r_type = SYS_RES_MEMORY;
     483    }
    455484    if (sc->bfe_res == NULL) {
    456485        device_printf(dev, "couldn't map memory\n");
    457486        error = ENXIO;
    458487        goto fail;
    459488    }
    460489
     490    dprintf("bfe: rman_get_bushandle(sc->bfe_res) 0x%x\n", rman_get_bushandle(sc->bfe_res));
     491
    461492    /* Allocate interrupt */
    462493    rid = 0;
    463494
     
    498529    ifp->if_snd.ifq_drv_maxlen = BFE_TX_QLEN;
    499530    IFQ_SET_READY(&ifp->if_snd);
    500531
     532    {
     533        char buf[1024]; unsigned bp=0;
     534        int i=0;
     535        while ( i < 256 && bp < 1024 )
     536        {
     537            unsigned v= CSR_READ_4(sc, i);
     538            if ((i & 0xf) == 0)
     539                bp += snprintf(&buf[bp], 1024-bp, "(%02x)%08x/", i, v);
     540            else
     541                bp += snprintf(&buf[bp], 1024-bp, "%08x/", v);
     542            i += 4;
     543        }
     544
     545        dprintf("bfe: attach: %s\n", buf);
     546    }
     547
    501548    bfe_get_config(sc);
    502549
    503550    /* Reset the chip and turn on the PHY */
     
    854901    sc->bfe_enaddr[4] = eeprom[83];
    855902    sc->bfe_enaddr[5] = eeprom[82];
    856903
    857     sc->bfe_phyaddr = eeprom[90] & 0x1f;
     904    //sc->bfe_phyaddr = eeprom[90] & 0x1f;
     905    sc->bfe_phyaddr = 30;
    858906    sc->bfe_mdc_port = (eeprom[90] >> 14) & 0x1;
    859907
    860908    sc->bfe_core_unit = 0;
     
    11611209bfe_read_eeprom(struct bfe_softc *sc, u_int8_t *data)
    11621210{
    11631211    long i;
     1212    char buf[2048];
     1213    unsigned bp=0;
    11641214    u_int16_t *ptr = (u_int16_t *)data;
    11651215
    11661216    for(i = 0; i < 128; i += 2)
     1217    {
     1218        unsigned v;
    11671219        ptr[i/2] = CSR_READ_4(sc, 4096 + i);
     1220        v= ptr[i/2];
     1221        if (bp < 2048 && (i & 0xf) == 0)
     1222            bp += snprintf(&buf[bp], 2048-bp, "(%02x)", i);
     1223        if (bp < 2048)
     1224            bp += snprintf(&buf[bp], 2048-bp, "%08x/", v);
     1225    }
     1226    dprintf("bfe: bfe_read_eeprom: %s\n", buf);
    11681227}
    11691228
    11701229static int