Changeset 1587
- Timestamp:
- 06/26/09 06:32:57 (14 years ago)
- Files:
-
- trunk/libffado/src/rme/fireface_def.h (modified) (2 diffs)
- trunk/libffado/src/rme/fireface_flash.cpp (modified) (4 diffs)
- trunk/libffado/src/rme/fireface_hw.cpp (modified) (4 diffs)
- trunk/libffado/src/rme/rme_avdevice.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/rme/fireface_def.h
r1586 r1587 101 101 #define RME_FF800_FLASH_ERASE_CONFIG_REG 0x3fffffffcLL 102 102 103 /* Fla gs and special values*/103 /* Flash erase command values for the FF400 */ 104 104 #define RME_FF400_FLASH_CMD_WRITE 0x00000001 105 105 #define RME_FF400_FLASH_CMD_READ 0x00000002 … … 109 109 #define RME_FF400_FLASH_CMD_GET_REVISION 0x0000000f 110 110 111 /* Flags for use with erase_flash() */ 112 #define RME_FF_FLASH_ERASE_VOLUME 1 113 #define RME_FF_FLASH_ERASE_SETTINGS 2 114 #define RME_FF_FLASH_ERASE_CONFIG 3 111 115 112 116 /* Defines for components of the control registers */ trunk/libffado/src/rme/fireface_flash.cpp
r1543 r1587 82 82 // Read "n_quads" quadlets from the Fireface Flash starting at address 83 83 // addr. The result is written to "buf" which is assumed big enough to 84 // hold the result. Return 0 on success, -1 on error. 84 // hold the result. Return 0 on success, -1 on error. The caller must ensure 85 // that the flash source address makes sense for the device in use. 85 86 86 87 unsigned int xfer_size; … … 102 103 err |= writeRegister(RME_FF400_FLASH_CMD_REG, RME_FF400_FLASH_CMD_READ); 103 104 if (!err) 104 wait_while_busy(2);105 wait_while_busy(2); 105 106 // Read from bounce buffer into final destination 106 107 err |= readBlock(RME_FF400_FLASH_READ_BUFFER, buf, xfer_size); … … 114 115 } 115 116 117 signed int 118 Device::erase_flash(unsigned int flags) 119 { 120 // Erase the requested flash block. "flags" should be one of the 121 // RME_FF_FLASH_ERASE_* flags. Return 0 on success, -1 on error. 122 123 fb_nodeaddr_t addr; 124 quadlet_t data; 125 unsigned int err = 0; 126 127 if (m_rme_model == RME_MODEL_FIREFACE800) { 128 switch (flags) { 129 case RME_FF_FLASH_ERASE_VOLUME: 130 addr = RME_FF800_FLASH_ERASE_VOLUME_REG; break; 131 case RME_FF_FLASH_ERASE_SETTINGS: 132 addr = RME_FF800_FLASH_ERASE_SETTINGS_REG; break; 133 case RME_FF_FLASH_ERASE_CONFIG: 134 addr = RME_FF800_FLASH_ERASE_CONFIG_REG; break; 135 default: 136 debugOutput(DEBUG_LEVEL_WARNING, "unknown flag %d\n", flags); 137 return -1; 138 } 139 data = 0; 140 } else { 141 addr = RME_FF400_FLASH_CMD_REG; 142 switch (flags) { 143 case RME_FF_FLASH_ERASE_VOLUME: 144 data = RME_FF400_FLASH_CMD_ERASE_VOLUME; break; 145 case RME_FF_FLASH_ERASE_SETTINGS: 146 data = RME_FF400_FLASH_CMD_ERASE_SETTINGS; break; 147 case RME_FF_FLASH_ERASE_CONFIG: 148 data = RME_FF400_FLASH_CMD_ERASE_CONFIG; break; 149 default: 150 debugOutput(DEBUG_LEVEL_WARNING, "unknown flag %d\n", flags); 151 return -1; 152 } 153 } 154 155 err |= writeRegister(addr, data); 156 if (!err) { 157 wait_while_busy(500); 158 // After the device is ready, wait a further 20 milliseconds. The purpose 159 // of this is unclear. Drivers from other OSes do it, so we should too. 160 usleep(20000); 161 } 162 163 return err?-1:0; 164 } 165 166 signed int 167 Device::write_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads) 168 { 169 // Write "n_quads" quadlets to the Fireface Flash starting at address 170 // addr. Return 0 on success, -1 on error. The caller must ensure the 171 // supplied address is appropriate for the device in use. 172 173 unsigned int xfer_size; 174 unsigned int err = 0; 175 quadlet_t block_desc[2]; 176 quadlet_t ff400_addr = (addr & 0xffffffff); 177 178 if (m_rme_model == RME_MODEL_FIREFACE800) { 179 err |= readBlock(addr, buf, n_quads); 180 if (!err) 181 wait_while_busy(5); 182 } 183 // FF400 case follows 184 do { 185 xfer_size = (n_quads > 32)?32:n_quads; 186 // Send data to flash buffer 187 err |= writeBlock(RME_FF400_FLASH_WRITE_BUFFER, buf, xfer_size); 188 // Program the destination address and size 189 block_desc[0] = ff400_addr; 190 block_desc[1] = xfer_size * sizeof(quadlet_t); 191 err |= writeBlock(RME_FF400_FLASH_BLOCK_ADDR_REG, block_desc, 2); 192 // Execute the write and wait for its completion 193 err |= writeRegister(RME_FF400_FLASH_CMD_REG, RME_FF400_FLASH_CMD_WRITE); 194 if (!err) 195 wait_while_busy(2); 196 197 n_quads -= xfer_size; 198 ff400_addr += xfer_size*sizeof(quadlet_t); 199 buf += xfer_size; 200 } while (n_quads>0 && !err); 201 202 return err?-1:0; 203 } 204 205 116 206 signed int 117 207 Device::read_device_settings(void) 118 208 { 209 // Read the device's configuration flash RAM and use this to set up 210 // the object's "settings" data member field. 211 119 212 FF_device_flash_settings_t hw_settings; 120 213 signed int i; 121 214 unsigned int rev; 215 216 // FIXME: this is mostly for testing at present. Still need to interface from 217 // hw_settings to the object's "settings" field. 122 218 123 219 i = get_revision(&rev); … … 179 275 } 180 276 181 } 277 signed int 278 Device::write_device_settings(void) 279 { 280 // Write the current settings as held in the "settings" data member to 281 // the device configuration flash. 282 283 // FIXME: fairly obviously the detail needs to be filled in here. 284 return 0; 285 } 286 287 } trunk/libffado/src/rme/fireface_hw.cpp
r1586 r1587 202 202 } 203 203 204 signed int Device::read_tco(quadlet_t *tco_data, signed int size) 204 signed int 205 Device::read_tco(quadlet_t *tco_data, signed int size) 205 206 { 206 207 // Read the TCO registers and return the respective values in *tco_data. … … 236 237 } 237 238 238 signed int Device::write_tco(quadlet_t *tco_data, signed int size) 239 signed int 240 Device::write_tco(quadlet_t *tco_data, signed int size) 239 241 { 240 242 // Writes data to the TCO. No check is made as to whether a TCO is … … 258 260 } 259 261 260 signed int Device::read_tco_state(FF_TCO_state_t *tco_state) 262 signed int 263 Device::read_tco_state(FF_TCO_state_t *tco_state) 261 264 { 262 265 // Reads the current TCO state into the supplied state structure … … 318 321 } 319 322 320 signed int Device::write_tco_settings(FF_TCO_settings_t *tco_settings) 323 signed int 324 Device::write_tco_settings(FF_TCO_settings_t *tco_settings) 321 325 { 322 326 // Writes the supplied application-level settings to the device's TCO trunk/libffado/src/rme/rme_avdevice.h
r1586 r1587 110 110 signed int get_revision(unsigned int *revision); 111 111 signed int read_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads); 112 signed int erase_flash(unsigned int flags); 113 signed int write_flash(fb_nodeaddr_t addr, quadlet_t *buf, unsigned int n_quads); 112 114 113 115 /* Upper level flash memory functions */ 114 116 signed int read_device_settings(void); 117 signed int write_device_settings(void); 115 118 116 119 /* Hardware functions */