1.1 --- a/pkg/devices/lib/msc/src/x1600.cc Fri Feb 16 23:11:25 2024 +0100
1.2 +++ b/pkg/devices/lib/msc/src/x1600.cc Sat Feb 17 23:04:12 2024 +0100
1.3 @@ -21,34 +21,43 @@
1.4
1.5 #include <l4/sys/err.h>
1.6
1.7 +#include "msc-defs.h"
1.8 #include "msc-x1600.h"
1.9
1.10
1.11
1.12 -// Register locations for each channel.
1.13 -
1.14 -enum Regs : unsigned
1.15 -{
1.16 - // Channel block size/offset.
1.17 -
1.18 - Msc_channel_offset = 0x10000,
1.19 -};
1.20 -
1.21 -
1.22 -
1.23 // Channel abstraction.
1.24
1.25 Msc_x1600_channel::Msc_x1600_channel(l4_addr_t msc_start, l4_addr_t addr,
1.26 - l4_cap_idx_t irq, Dma_x1600_channel *dma,
1.27 + l4_cap_idx_t irq,
1.28 + Cpm_chip *cpm, enum Clock_identifiers clock,
1.29 + Dma_x1600_channel *dma,
1.30 enum Dma_x1600_request_type request_type_in,
1.31 enum Dma_x1600_request_type request_type_out)
1.32 -: Msc_channel(msc_start, addr, irq),
1.33 +: Msc_channel(msc_start, addr, irq, cpm, clock),
1.34 _dma(dma),
1.35 _request_type_in(request_type_in),
1.36 _request_type_out(request_type_out)
1.37 {
1.38 }
1.39
1.40 +// Reset for X1600 and other recent SoCs only.
1.41 +
1.42 +void
1.43 +Msc_x1600_channel::reset()
1.44 +{
1.45 + _regs[Msc_control] = _regs[Msc_control] | Control_reset;
1.46 +
1.47 + // NOTE: On the X1600, Msc_control tends to read as zero, anyway, making this
1.48 + // NOTE: equivalent to clearing the register.
1.49 +
1.50 + _regs[Msc_control] = _regs[Msc_control] & ~Control_reset;
1.51 +
1.52 + // Sufficient for other SoCs...
1.53 +
1.54 + while (_regs[Msc_status] & Status_resetting);
1.55 +}
1.56 +
1.57 // Request the transfer of the indicated number of bytes between two physical
1.58 // addresses in the indicated direction, returning the number of bytes to be
1.59 // transferred.
1.60 @@ -77,25 +86,20 @@
1.61
1.62 // Peripheral abstraction.
1.63
1.64 -Msc_x1600_chip::Msc_x1600_chip(l4_addr_t msc_start, l4_addr_t start, l4_addr_t end)
1.65 -: Msc_chip(msc_start, start, end)
1.66 +Msc_x1600_chip::Msc_x1600_chip(l4_addr_t msc_start, l4_addr_t start,
1.67 + l4_addr_t end, Cpm_chip *cpm)
1.68 +: Msc_chip(msc_start, start, end, cpm)
1.69 {
1.70 }
1.71
1.72 Msc_channel *Msc_x1600_chip::get_channel(uint8_t channel, l4_cap_idx_t irq,
1.73 Dma_x1600_channel *dma)
1.74 {
1.75 - const enum Dma_x1600_request_type in_types[] =
1.76 - {Dma_request_msc0_in, Dma_request_msc1_in};
1.77 -
1.78 - const enum Dma_x1600_request_type out_types[] =
1.79 - {Dma_request_msc0_out, Dma_request_msc1_out};
1.80 -
1.81 if (channel < num_channels())
1.82 return new Msc_x1600_channel(_msc_start + channel * Msc_channel_offset,
1.83 _start + channel * Msc_channel_offset,
1.84 - irq, dma,
1.85 - in_types[channel], out_types[channel]);
1.86 + irq, _cpm, _clocks[channel], dma,
1.87 + _in_types[channel], _out_types[channel]);
1.88 else
1.89 throw -L4_EINVAL;
1.90 }
1.91 @@ -104,9 +108,11 @@
1.92
1.93 // C language interface functions.
1.94
1.95 -void *x1600_msc_init(l4_addr_t msc_start, l4_addr_t start, l4_addr_t end)
1.96 +void *x1600_msc_init(l4_addr_t msc_start, l4_addr_t start, l4_addr_t end,
1.97 + void *cpm)
1.98 {
1.99 - return (void *) new Msc_x1600_chip(msc_start, start, end);
1.100 + return (void *) new Msc_x1600_chip(msc_start, start, end,
1.101 + static_cast<Cpm_x1600_chip *>(cpm));
1.102 }
1.103
1.104 void *x1600_msc_get_channel(void *msc, uint8_t channel, l4_cap_idx_t irq,
1.105 @@ -132,9 +138,9 @@
1.106 }
1.107
1.108 uint32_t x1600_msc_read_blocks(void *msc_channel, uint8_t card,
1.109 - l4re_dma_space_dma_addr_t paddr,
1.110 + struct dma_region *region,
1.111 uint32_t block_address, uint32_t block_count)
1.112 {
1.113 - return static_cast<Msc_channel *>(msc_channel)->read_blocks(card, paddr,
1.114 + return static_cast<Msc_channel *>(msc_channel)->read_blocks(card, region,
1.115 block_address, block_count);
1.116 }