Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/harbor/lib/harbor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export 'src/clock/clock_domain.dart';
export 'src/clock/clock_gate.dart';

// SoC
export 'src/soc/acpi.dart';
export 'src/soc/boot_sequencer.dart';
export 'src/soc/cpu.dart';
export 'src/soc/device_tree.dart';
export 'src/soc/graph.dart';
export 'src/soc/harbor_soc.dart';
Expand Down
16 changes: 15 additions & 1 deletion packages/harbor/lib/src/debug/debug_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:rohd_bridge/rohd_bridge.dart';

import '../bus/bus.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';

/// RISC-V Debug Module (DM) per the RISC-V Debug Specification 1.0.
Expand All @@ -22,7 +23,8 @@ import '../soc/device_tree.dart';
/// - 0x12: haltsum1 0x16: abstracts 0x17: command
/// - 0x18: abstractauto 0x20-0x2F: progbuf 0x38: sbcs
/// - 0x39: sbaddress0 0x3C: sbdata0
class HarborDebugModule extends BridgeModule with HarborDeviceTreeNodeProvider {
class HarborDebugModule extends BridgeModule
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
/// Base address for the debug module's memory-mapped registers.
final int baseAddress;

Expand Down Expand Up @@ -239,4 +241,16 @@ class HarborDebugModule extends BridgeModule with HarborDeviceTreeNodeProvider {
reg: BusAddressRange(baseAddress, 0x1000),
properties: {'num-harts': numHarts, 'progbuf-size': progBufSize},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, 0x1000)],
properties: {
'compatible': ['harbor,debug-module', 'riscv,debug-013'],
'num-harts': numHarts,
'progbuf-size': progBufSize,
},
);
}
15 changes: 14 additions & 1 deletion packages/harbor/lib/src/debug/trace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:rohd_bridge/rohd_bridge.dart';

import '../bus/bus.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';

/// Trace packet type.
Expand Down Expand Up @@ -45,7 +46,7 @@ enum HarborTracePacketType {
/// - 0x18: BUF_WR (current write pointer, read-only)
/// - 0x1C: SYNC_CNT (sync packet interval in branches)
class HarborTraceEncoder extends BridgeModule
with HarborDeviceTreeNodeProvider {
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
/// Base address for trace registers.
final int baseAddress;

Expand Down Expand Up @@ -245,4 +246,16 @@ class HarborTraceEncoder extends BridgeModule
reg: BusAddressRange(baseAddress, 0x1000),
properties: {'buffer-size': bufferSize, 'sync-interval': syncInterval},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, 0x1000)],
properties: {
'compatible': ['riscv,trace'],
'buffer-size': bufferSize,
'sync-interval': syncInterval,
},
);
}
23 changes: 22 additions & 1 deletion packages/harbor/lib/src/media/audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:rohd_bridge/rohd_bridge.dart';

import '../bus/bus.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';

/// Audio sample format.
Expand Down Expand Up @@ -109,7 +110,7 @@ enum HarborAudioCodecFormat {
/// - 0x84: CODEC_STATUS (codec busy/done/error)
/// - 0x88: CODEC_CAPS (supported codecs bitmask, read-only)
class HarborAudioController extends BridgeModule
with HarborDeviceTreeNodeProvider {
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
/// Base address in the SoC memory map.
final int baseAddress;

Expand Down Expand Up @@ -516,4 +517,24 @@ class HarborAudioController extends BridgeModule
'harbor,rx-fifo-depth': rxFifoDepth,
},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, 0x1000)],
properties: {
'compatible': ['harbor,audio'],
'#sound-dai-cells': 0,
'harbor,interfaces': audioInterfaces.map((i) => i.name).join(', '),
'harbor,max-channels': maxChannels,
'harbor,sample-rates': sampleRates.map((r) => '$r').join(', '),
'harbor,formats': formats.map((f) => f.name).join(', '),
if (hwCodecs.isNotEmpty)
'harbor,codecs': hwCodecs.map((c) => c.displayName).join(', '),
if (hasSrc) 'harbor,has-src': true,
'harbor,tx-fifo-depth': txFifoDepth,
'harbor,rx-fifo-depth': rxFifoDepth,
},
);
}
24 changes: 23 additions & 1 deletion packages/harbor/lib/src/media/media_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:rohd_bridge/rohd_bridge.dart';

import '../bus/bus.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';
import 'codec.dart';

Expand Down Expand Up @@ -52,7 +53,8 @@ import 'codec.dart';
/// - +0x44: SESS_LEVEL (codec level)
/// - +0x48: SESS_BYTES_DONE (bytes processed, read-only)
/// - +0x4C: SESS_FRAMES_DONE (frames processed, read-only)
class HarborMediaEngine extends BridgeModule with HarborDeviceTreeNodeProvider {
class HarborMediaEngine extends BridgeModule
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
/// Base address in the SoC memory map.
final int baseAddress;

Expand Down Expand Up @@ -329,4 +331,24 @@ class HarborMediaEngine extends BridgeModule with HarborDeviceTreeNodeProvider {
),
},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, 0x1000)],
properties: {
'compatible': ['harbor,media-engine'],
'max-sessions': maxSessions,
'harbor,codecs': codecs.map((c) => c.format.displayName).join(', '),
'harbor,max-width': codecs.fold<int>(
0,
(max, c) => c.maxWidth > max ? c.maxWidth : max,
),
'harbor,max-height': codecs.fold<int>(
0,
(max, c) => c.maxHeight > max ? c.maxHeight : max,
),
},
);
}
17 changes: 16 additions & 1 deletion packages/harbor/lib/src/peripherals/aplic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:rohd_bridge/rohd_bridge.dart';

import '../bus/bus.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';

/// RISC-V Advanced Platform-Level Interrupt Controller (APLIC).
Expand All @@ -20,7 +21,8 @@ import '../soc/device_tree.dart';
/// - `target[i]`: 0x3004 + (i-1)*4
/// - IDC per hart: 0x4000 + hart*32
/// - `idelivery` +0x00, `iforce` +0x04, `ithreshold` +0x08, `claimi` +0x1C
class HarborAplic extends BridgeModule with HarborDeviceTreeNodeProvider {
class HarborAplic extends BridgeModule
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
final int sources;
final int harts;
final int priorityBits;
Expand Down Expand Up @@ -318,4 +320,17 @@ class HarborAplic extends BridgeModule with HarborDeviceTreeNodeProvider {
interruptCells: 2,
properties: {'riscv,num-sources': sources},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, 0x8000)],
properties: {
'compatible': ['riscv,aplic'],
'riscv,num-sources': sources,
'interrupt-controller': true,
'#interrupt-cells': 2,
},
);
}
15 changes: 14 additions & 1 deletion packages/harbor/lib/src/peripherals/clint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:rohd_bridge/rohd_bridge.dart';

import '../bus/bus.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';

/// RISC-V Core Local Interruptor (CLINT), SiFive-compatible.
Expand All @@ -16,7 +17,8 @@ import '../soc/device_tree.dart';
/// - `mtime`: 0xBFF8 (8 bytes, machine timer)
///
/// Address space: 64 KB (0x10000).
class HarborClint extends BridgeModule with HarborDeviceTreeNodeProvider {
class HarborClint extends BridgeModule
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
final int? busDataWidth;

/// Number of harts this CLINT serves.
Expand Down Expand Up @@ -168,4 +170,15 @@ class HarborClint extends BridgeModule with HarborDeviceTreeNodeProvider {
reg: BusAddressRange(baseAddress, 0x10000),
properties: {'reg-names': 'control'},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, 0x10000)],
properties: {
'compatible': ['riscv,clint0'],
'reg-names': 'control',
},
);
}
22 changes: 21 additions & 1 deletion packages/harbor/lib/src/peripherals/ddr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '../bus/bus.dart';
import 'ddr_phy_ecp5.dart';
import 'ddr_sequencer.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';
import '../util/pretty_string.dart';

Expand Down Expand Up @@ -164,7 +165,7 @@ class HarborDdrConfig with HarborPrettyString {
/// unimplemented shells until their PHYs exist; a Xilinx 7-series PHY for
/// the Arty S7 reuses the sequencer.
class HarborDdrController extends BridgeModule
with HarborDeviceTreeNodeProvider {
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
final int? busDataWidth;

/// Memory configuration.
Expand Down Expand Up @@ -391,4 +392,23 @@ class HarborDdrController extends BridgeModule
'clock-frequency': config.frequency,
},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, config.size)],
properties: {
'compatible': [
'harbor,sdram-controller',
if (config.isSdr) 'harbor,sdr-sdram',
if (config.type == HarborDdrType.ddr3 ||
config.type == HarborDdrType.ddr3l)
'harbor,ddr3-sdram',
],
'sdram-type': config.type.name,
'data-width': config.dataWidth,
'clock-frequency': config.frequency,
},
);
}
16 changes: 15 additions & 1 deletion packages/harbor/lib/src/peripherals/display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:rohd_bridge/rohd_bridge.dart';

import '../bus/bus.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';
import '../util/pretty_string.dart';

Expand Down Expand Up @@ -226,7 +227,7 @@ class HarborDisplayConfig with HarborPrettyString {
/// - 0x20: INT_STATUS (W1C: vblank, underrun)
/// - 0x24: INT_ENABLE
class HarborDisplayController extends BridgeModule
with HarborDeviceTreeNodeProvider {
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
/// Display configuration.
final HarborDisplayConfig config;

Expand Down Expand Up @@ -487,4 +488,17 @@ class HarborDisplayController extends BridgeModule
'max-height': config.maxHeight,
},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, 0x1000)],
properties: {
'compatible': ['harbor,display'],
'output-interface': config.interface_.name,
'max-width': config.maxWidth,
'max-height': config.maxHeight,
},
);
}
15 changes: 14 additions & 1 deletion packages/harbor/lib/src/peripherals/dma.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:rohd_bridge/rohd_bridge.dart';

import '../bus/bus.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';
import '../util/pretty_string.dart';

Expand Down Expand Up @@ -81,7 +82,7 @@ class HarborDmaChannelConfig with HarborPrettyString {
/// - 0x004: INT_STATUS (per-channel interrupt status, W1C)
/// - 0x008: INT_ENABLE (per-channel interrupt enable)
class HarborDmaController extends BridgeModule
with HarborDeviceTreeNodeProvider {
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
/// Number of DMA channels.
final int channels;

Expand Down Expand Up @@ -343,4 +344,16 @@ class HarborDmaController extends BridgeModule
reg: BusAddressRange(baseAddress, 0x1000),
properties: {'dma-channels': channels, '#dma-cells': 1},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, 0x1000)],
properties: {
'compatible': ['harbor,dma'],
'dma-channels': channels,
'#dma-cells': 1,
},
);
}
20 changes: 19 additions & 1 deletion packages/harbor/lib/src/peripherals/efuse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:rohd_bridge/rohd_bridge.dart';

import '../bus/bus.dart';
import '../bus/bus_slave_port.dart';
import '../soc/acpi.dart';
import '../soc/device_tree.dart';

/// eFuse bank configuration.
Expand Down Expand Up @@ -189,7 +190,8 @@ class HarborEfuseBlock extends BridgeModule {
/// - 0x14: LOCK (per-region lock bits, write-1-to-lock)
/// - 0x18: TIMING (program pulse width in clock cycles)
/// - 0x1C: KEY (write 0x4F545021 to unlock programming)
class HarborEfuseDevice extends BridgeModule with HarborDeviceTreeNodeProvider {
class HarborEfuseDevice extends BridgeModule
with HarborDeviceTreeNodeProvider, HarborAcpiDeviceProvider {
/// Base address in the SoC memory map.
final int baseAddress;

Expand Down Expand Up @@ -446,4 +448,20 @@ class HarborEfuseDevice extends BridgeModule with HarborDeviceTreeNodeProvider {
'#size-cells': 1,
},
);

@override
HarborAcpiDevice get acpiDevice => HarborAcpiDevice(
hid: 'PRP0001',
uid: 0,
memory: [BusAddressRange(baseAddress, 0x1000)],
properties: {
'compatible': ['harbor,efuse', 'harbor,otp'],
'harbor,total-bits': config.totalBits,
'harbor,bits-per-word': config.bitsPerWord,
'harbor,regions': config.regions,
'harbor,unlock-key': programUnlockKey,
'#address-cells': 1,
'#size-cells': 1,
},
);
}
Loading
Loading