47.6.4.1 Channel Initialization
The software flow required to initialize a channel must be performed in order to ensure proper operation.
For clarity, the software flow is grouped as follows:
- Configure the Hardware
- Program the Routing Fabric Block
- Program the AHB Block DMAs
- Synchronize and Unmute Synchronous Channel
Configure the Hardware
The MLB_MLBC0, HMCR0, HMCR1 and MLB_HCTL registers are accessible directly via APB reads and writes.
- Initialize CTR and registers
- Clear CAT, CDT, and ADT bits in CTR
- Clear all bits of all registers
- Configure the MediaLB interface
- Select MediaLB clock speed via MLB_MLBC0.MLBCLK
- Set MediaLB enable via MLB_MLBC0.MLBEN
- Configure the HBI interface
- Set HMCR0 and HMCR1 = FFFFFFFFh to activate all channels
- Set the HBI enable bit: MLB_HCTL.EN = 1
Program the Routing Fabric Block
The CAT and CDT reside in the external CTR and are programmed indirectly via APB or I/O reads and writes to the MIF block.
- Clear all bits of the CAT
- Select a logical channel: N = 0–63
- Program the CDT for channel N
- Set the 14-bit base address (BA)
- Set the 12-bit or 13-bit buffer depth (BD): BD = buffer depth
in bytes - 1
- For synchronous channels: (BD + 1) = 4 x frames per sub-buffer (m) x bytes- per-frame (bpf)
- For isochronous channels: (BD + 1) mod (BS + 1) = 0
- For asynchronous channels: (BD + 1) ≥ max packet length (1024 for a MOST Data Packet (MDP); 1536 for a MOST Ethernet Packet (MEP))
- For control channels: (BD + 1) ≥ max packet length (64)
- For isochronous channels, set the block size (BS): BS = block size in bytes - 1
- Clear all other bits of the CDT
- Program the CAT for the inbound DMA
- For Tx channels (to MediaLB) HBI is the inbound DMA
- For Rx channels (from MediaLB) MediaLB is the inbound DMA
- Set the channel direction: RNW = 0
- Set the channel type: CT[2:0] = 010 (asynchronous), 001 (control), 011 (isochronous), or 000 (synchronous)
- Set the connection label: CL[5:0] = N
- If CT[2:0] = 000 (synchronous), set the mute bit (MT = 1)
- Set the channel enable: CE = 1
- Set all other bits of the CAT to ‘0’
- Program the CAT for the outbound DMA
- For Tx channels (to MediaLB) MediaLB is the outbound DMA
- For Rx channels (from MediaLB) HBI is the outbound DMA
- Set the channel direction: RNW = 1
- Set the channel type: CT[2:0] = 010 (asynchronous), 001 (control), 011 (isochronous), or 000 (synchronous)
- Set the channel label: CL[5:0] = N
- If CT[2:0] = 000 (synchronous), set the mute bit (MT = 1)
- Set the channel enable: CE = 1
- Set all other bits of the CAT to ‘0’
- Repeat steps 2–5 to initialize all logical channels
Program the AHB Block DMAs
The ADT resides in the external CTR and is programmed indirectly via APB reads and writes to the MIF.
- Initialize all bits of the ADT to ‘0’
- Select a logical channel: N = 0–63
- Program the AHB block ping page for channel
N
- Set the 32-bit base address (BA1)
- Set the 11-bit buffer depth (BD1): BD1 = buffer depth in
bytes - 1
- For synchronous channels: (BD1 + 1) = n x frames per sub-buffer (m) x bytes-per-frame (bpf)
- For isochronous channels: (BD1 + 1) mod (BS + 1) = 0
- For asynchronous channels: 5 ≤ (BD1 + 1) ≤ 4096 (max packet length)
- For control channels: 5 ≤ (BD1 + 1) ≤ 4096 (max packet length)
- For asynchronous and control Tx channels set the packet start bit (PS1) iff the page contains the start of the packet
- Clear the page done bit (DNE1)
- Clear the error bit (ERR1)
- Set the page ready bit (RDY1)
- Program the AHB block pong page for channel N
- Set the 32-bit base address (BA2)
- Set the 11-bit buffer depth (BD2): BD2 = buffer depth in
bytes - 1
- For synchronous channels: (BD2 +1) = n x frames per sub-buffer (m) x bytes-per-frame (bpf)
- For isochronous channels: (BD2 + 1) mod (BS + 1) = 0
- For asynchronous channels: 5 ≤ (BD2 + 1) ≤ 4096 (max packet length)
- For control channels: 5 ≤ (BD2 + 1) ≤ 4096 (max packet length)
- For asynchronous and control Tx channels set the packet start bit (PS2) if the page contains the start of the packet
- Clear the page done bit (DNE2)
- Clear the error bit (ERR2)
- Set the page ready bit (RDY2)
- Select Big Endian (LE = 0) or Little Endian (LE = 1)
- Select the active page: PG = 0 (ping), PG = 1 (pong)
- Set the channel enable (CE) bit for all active logical channels
- Repeat steps 2–7 for all active logical channels
Synchronize and Unmute Synchronous Channel
The MLB_MLBC0 and MLB_MLBC1 registers are accessible directly via APB reads and writes.
- Check that MediaLB clock is running (MLB_MLBC1.CLKM = 0)
- If MLB_MLBC1.CLKM = 1, clear the register bit, wait one APB or I/O clock cycle and repeat step 1.
- Poll for MediaLB lock (MLB_MLBC0.MLBLK = 1)
- Wait four frames
- Unmute synchronous channel(s)