Ticket #2998: bfe440x.3.diff

File bfe440x.3.diff, 3.7 KB (added by Adek336, 15 years ago)
  • src/libs/compat/freebsd_network/bus.c

     
    108108    return 0;
    109109}
    110110
     111int
     112bus_alloc_mem_resource_adipe(device_t dev, struct resource *res, int regid)
     113{
     114    uint32 addr = pci_read_config(dev, regid, 4) & PCI_address_memory_32_mask;
     115    uint32 size = 4 * 1024; /* XXX */
     116    void *virtualAddr;
    111117
     118    dprintf("bfe: bus_alloc_mem_resource_adipe\n");
     119
     120    res->r_mapped_area = map_mem(&virtualAddr, (void *)addr, size, 0,
     121        "bus_alloc_resource(MEMORY)");
     122    if (res->r_mapped_area < B_OK)
     123        return -1;
     124
     125    res->r_bustag = I386_BUS_SPACE_MEM;
     126    res->r_bushandle = (bus_space_handle_t)virtualAddr;
     127    return 0;
     128}
     129
     130
    112131static int
    113132bus_alloc_ioport_resource(device_t dev, struct resource *res, int regid)
    114133{
  • 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);
    451468
    452     rid = PCIR_BAR(0);
    453     sc->bfe_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
    454             RF_ACTIVE);
     469    rid = PCIR_BAR (0);
     470    //sc->bfe_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
     471    //      RF_ACTIVE);
     472    {
     473        int result;
     474        static struct resource BLERES;
     475        sc->bfe_res = &BLERES;
     476        result = bus_alloc_mem_resource_adipe(dev, sc->bfe_res, rid);
     477        if (result < 0)
     478            panic("ble");
     479        sc->bfe_res->r_type = SYS_RES_MEMORY;
     480    }
    455481    if (sc->bfe_res == NULL) {
    456482        device_printf(dev, "couldn't map memory\n");
    457483        error = ENXIO;
    458484        goto fail;
    459485    }
    460486
     487    dprintf("bfe: rman_get_bushandle(sc->bfe_res) 0x%x\n", rman_get_bushandle(sc->bfe_res));
     488
    461489    /* Allocate interrupt */
    462490    rid = 0;
    463491
     
    498526    ifp->if_snd.ifq_drv_maxlen = BFE_TX_QLEN;
    499527    IFQ_SET_READY(&ifp->if_snd);
    500528
     529    {
     530        char buf[1024]; unsigned bp=0;
     531        int i=0;
     532        while ( i < 256 && bp < 1024 )
     533        {
     534            unsigned v= CSR_READ_4(sc, i);
     535            if ((i & 0xf) == 0)
     536                bp += snprintf(&buf[bp], 1024-bp, "(%02x)%08x/", i, v);
     537            else
     538                bp += snprintf(&buf[bp], 1024-bp, "%08x/", v);
     539            i += 4;
     540        }
     541
     542        dprintf("bfe: attach: %s\n", buf);
     543    }
     544
    501545    bfe_get_config(sc);
    502546
    503547    /* Reset the chip and turn on the PHY */
     
    854898    sc->bfe_enaddr[4] = eeprom[83];
    855899    sc->bfe_enaddr[5] = eeprom[82];
    856900
    857     sc->bfe_phyaddr = eeprom[90] & 0x1f;
     901    //sc->bfe_phyaddr = eeprom[90] & 0x1f;
     902    sc->bfe_phyaddr = 30;
    858903    sc->bfe_mdc_port = (eeprom[90] >> 14) & 0x1;
    859904
    860905    sc->bfe_core_unit = 0;
     
    11611206bfe_read_eeprom(struct bfe_softc *sc, u_int8_t *data)
    11621207{
    11631208    long i;
     1209    char buf[2048];
     1210    unsigned bp=0;
    11641211    u_int16_t *ptr = (u_int16_t *)data;
    11651212
    11661213    for(i = 0; i < 128; i += 2)
     1214    {
     1215        unsigned v;
    11671216        ptr[i/2] = CSR_READ_4(sc, 4096 + i);
     1217        v= ptr[i/2];
     1218        if (bp < 2048 && (i & 0xf) == 0)
     1219            bp += snprintf(&buf[bp], 2048-bp, "(%02x)", i);
     1220        if (bp < 2048)
     1221            bp += snprintf(&buf[bp], 2048-bp, "%08x/", v);
     1222    }
     1223    dprintf("bfe: bfe_read_eeprom: %s\n", buf);
    11681224}
    11691225
    11701226static int