Changeset 2068

Show
Ignore:
Timestamp:
03/06/12 03:27:42 (9 years ago)
Author:
adi
Message:

DICE: add DICE firmware utility

Peter Hinkel has contributed a DICE firmware utility.

I'll add it as is, any modifications will come later.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/dice/dice_avdevice.cpp

    r2060 r2068  
    16391639 
    16401640bool 
     1641Device::readRegFL (fb_nodeaddr_t offset, fb_quadlet_t *result) { 
     1642    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08"PRIX64"\n", offset); 
     1643 
     1644    if(offset >= DICE_INVALID_OFFSET) { 
     1645        debugError("invalid offset: 0x%016"PRIX64"\n", offset); 
     1646        return false; 
     1647    } 
     1648 
     1649    fb_nodeid_t nodeId = getNodeId() | 0xFFC0; 
     1650 
     1651    if(!get1394Service().read_quadlet(nodeId, offset, result)) { 
     1652        debugError("Could not read from node 0x%04X addr 0x%12"PRIX64"\n", nodeId, offset); 
     1653        return false; 
     1654    } 
     1655 
     1656    *result = CondSwapFromBus32(*result); 
     1657 
     1658    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08"PRIX32"\n", *result); 
     1659 
     1660    return true; 
     1661} 
     1662 
     1663bool 
    16411664Device::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 
    16421665    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08"PRIX64", data: 0x%08"PRIX32"\n", 
     
    16531676    if(!get1394Service().write_quadlet( nodeId, addr, CondSwapToBus32(data) ) ) { 
    16541677        debugError("Could not write to node 0x%04X addr 0x%12"PRIX64"\n", nodeId, addr); 
     1678        return false; 
     1679    } 
     1680    return true; 
     1681} 
     1682 
     1683bool 
     1684Device::writeRegFL(fb_nodeaddr_t offset, fb_quadlet_t data) { 
     1685    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08"PRIX64", data: 0x%08"PRIX32"\n", 
     1686        offset, data); 
     1687 
     1688    if(offset >= DICE_INVALID_OFFSET) { 
     1689        debugError("invalid offset: 0x%012"PRIX64"\n", offset); 
     1690        return false; 
     1691    } 
     1692 
     1693    fb_nodeid_t nodeId = getNodeId() | 0xFFC0; 
     1694 
     1695    if(!get1394Service().write_quadlet( nodeId, offset, CondSwapToBus32(data) ) ) { 
     1696        debugError("Could not write to node 0x%04X addr 0x%12"PRIX64"\n", nodeId, offset); 
    16551697        return false; 
    16561698    } 
     
    17031745 
    17041746bool 
     1747Device::readRegBlockFL(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     1748    debugOutput(DEBUG_LEVEL_VERBOSE, 
     1749                "Reading base register offset 0x%08"PRIX64", length %zd, to %p\n", 
     1750                offset, length, data); 
     1751    const int blocksize_quads = 512/4; 
     1752 
     1753    if(offset >= DICE_INVALID_OFFSET) { 
     1754        debugError("invalid offset: 0x%012"PRIX64"\n", offset); 
     1755        return false; 
     1756    } 
     1757 
     1758    fb_nodeid_t nodeId = getNodeId() | 0xFFC0; 
     1759    int quads_done = 0; 
     1760    int length_quads = (length+3)/4; // round to next full quadlet 
     1761    while(quads_done < length_quads) { 
     1762        fb_nodeaddr_t curr_addr = offset + quads_done*4; 
     1763        fb_quadlet_t *curr_data = data + quads_done; 
     1764        int quads_todo = length_quads - quads_done; 
     1765        debugOutput(DEBUG_LEVEL_VERBOSE, "reading addr: 0x%012"PRIX64", %d quads to %p\n", curr_addr, quads_todo, curr_data); 
     1766 
     1767        if (quads_todo > blocksize_quads) { 
     1768            debugOutput(DEBUG_LEVEL_VERBOSE, "Truncating read from %d to %d quadlets\n", quads_todo, blocksize_quads); 
     1769            quads_todo = blocksize_quads; 
     1770        } 
     1771        #ifdef DEBUG 
     1772        if (quads_todo < 0) { 
     1773            debugError("BUG: quads_todo < 0: %d\n", quads_todo); 
     1774        } 
     1775        #endif 
     1776 
     1777        if(!get1394Service().read( nodeId, curr_addr, quads_todo, curr_data ) ) { 
     1778            debugError("Could not read %d quadlets from node 0x%04X addr 0x%012"PRIX64"\n", quads_todo, nodeId, curr_addr); 
     1779            return false; 
     1780        } 
     1781        quads_done += quads_todo; 
     1782    } 
     1783 
     1784    byteSwapFromBus(data, length/4); 
     1785    return true; 
     1786} 
     1787 
     1788bool 
    17051789Device::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
    17061790    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08"PRIX64", length: %zd\n", 
     
    17461830 
    17471831bool 
     1832Device::writeRegBlockFL(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 
     1833    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08"PRIX64", length: %zd\n", 
     1834        offset, length); 
     1835    const int blocksize_quads = 512/4; 
     1836 
     1837    if(offset >= DICE_INVALID_OFFSET) { 
     1838        debugError("invalid offset: 0x%012"PRIX64"\n", offset); 
     1839        return false; 
     1840    } 
     1841 
     1842    fb_quadlet_t data_out[length/4]; 
     1843    memcpy(data_out, data, length); 
     1844    byteSwapToBus(data_out, length/4); 
     1845 
     1846    fb_nodeid_t nodeId = getNodeId() | 0xFFC0; 
     1847    int quads_done = 0; 
     1848    int length_quads = (length+3)/4; 
     1849    while(quads_done < length_quads) { 
     1850        fb_nodeaddr_t curr_addr = offset + quads_done*4; 
     1851        fb_quadlet_t *curr_data = data_out + quads_done; 
     1852        int quads_todo = length_quads - quads_done; 
     1853        if (quads_todo > blocksize_quads) { 
     1854            debugOutput(DEBUG_LEVEL_VERBOSE, "Truncating write from %d to %d quadlets\n", quads_todo, blocksize_quads); 
     1855            quads_todo = blocksize_quads; 
     1856        } 
     1857        #ifdef DEBUG 
     1858        if (quads_todo < 0) { 
     1859            debugError("BUG: quads_todo < 0: %d\n", quads_todo); 
     1860        } 
     1861        #endif 
     1862 
     1863        if(!get1394Service().write( nodeId, curr_addr, quads_todo, curr_data ) ) { 
     1864            debugError("Could not write %d quadlets to node 0x%04X addr 0x%012"PRIX64"\n", quads_todo, nodeId, curr_addr); 
     1865            return false; 
     1866        } 
     1867        quads_done += quads_todo; 
     1868    } 
     1869 
     1870    return true; 
     1871} 
     1872 
     1873bool 
    17481874Device::readGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 
    17491875    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading global register offset 0x%04"PRIX64"\n", offset); 
  • trunk/libffado/src/dice/dice_avdevice.h

    r2057 r2068  
    2424#ifndef DICEDEVICE_H 
    2525#define DICEDEVICE_H 
     26 
     27#include "dice_firmware_loader.h" 
    2628 
    2729#include "ffadotypes.h" 
     
    7880 
    7981    virtual void showDevice(); 
     82 
     83    virtual bool deleteImgFL(const char*, bool v = true); 
     84    virtual bool flashDiceFL(const char*, const char* image = "dice"); 
     85    virtual bool dumpFirmwareFL(const char*); 
     86    virtual bool showDiceInfoFL(); 
     87    virtual bool showImgInfoFL(); 
     88    virtual bool testDiceFL(int); 
     89    virtual DICE_FL_INFO_PARAM* showFlashInfoFL(bool v = true); 
     90    virtual bool showAppInfoFL(); 
    8091 
    8192    virtual bool setSamplingFrequency( int samplingFrequency ); 
     
    174185    bool prepareSP (unsigned int, const Streaming::Port::E_Direction direction_requested); 
    175186    void setRXTXfuncs (const Streaming::Port::E_Direction direction); 
     187 
    176188    // quadlet read/write routines 
    177189    bool readReg(fb_nodeaddr_t, fb_quadlet_t *); 
     
    179191    bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    180192    bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
     193 
     194    // quadlet read/write firmware loader routines 
     195    bool readRegFL(fb_nodeaddr_t, fb_quadlet_t *); 
     196    bool writeRegFL(fb_nodeaddr_t, fb_quadlet_t); 
     197    bool readRegBlockFL(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
     198    bool writeRegBlockFL(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    181199 
    182200    bool readGlobalReg(fb_nodeaddr_t, fb_quadlet_t *); 
     
    230248    #define DICE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL 
    231249    #define DICE_NOTIFIER_BLOCK_LENGTH 4 
     250 
    232251    class Notifier : public Ieee1394Service::ARMHandler 
    233252    { 
     
    248267 
    249268} 
    250 // vim: et 
     269 
    251270#endif 
  • trunk/libffado/src/SConscript

    r1996 r2068  
    161161dice_source = env.Split( '\ 
    162162        dice/dice_avdevice.cpp \ 
     163        dice/dice_firmware_loader.cpp \ 
    163164        dice/dice_eap.cpp \ 
    164165        dice/focusrite/focusrite_eap.cpp \ 
  • trunk/libffado/tests/SConscript

    r1989 r2068  
    7676if env['ENABLE_DICE']: 
    7777        apps.update( { "test-dice-eap" : "test-dice-eap.cpp" } ) 
     78        apps.update( { "dice-firmware-utility" : "dice-firmware-utility.cpp" } ) 
    7879 
    7980for app in apps.keys():