Skip to content

Commit

Permalink
EB
Browse files Browse the repository at this point in the history
  • Loading branch information
pamaury committed Sep 24, 2024
1 parent aedaf4c commit a76d5fe
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 55 deletions.
10 changes: 5 additions & 5 deletions sw/device/lib/testing/test_rom/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ cc_library(
"//hw/ip/entropy_src/data:entropy_src_c_regs",
"//hw/ip/otp_ctrl/data:otp_ctrl_c_regs",
"//hw/ip/sram_ctrl/data:sram_ctrl_c_regs",
"//hw/top_earlgrey/ip/ast/data:ast_c_regs",
"//hw/top_earlgrey/ip/sensor_ctrl/data:sensor_ctrl_c_regs",
"//hw/top_earlgrey/ip_autogen/clkmgr:clkmgr_c_regs",
"//hw/top_earlgrey/ip_autogen/flash_ctrl:flash_ctrl_c_regs",
"//hw/top_earlgrey/sw/autogen:top_earlgrey",
"//hw/top:ast_c_regs",
"//hw/top:sensor_ctrl_c_regs",
"//hw/top:clkmgr_c_regs",
"//hw/top:flash_ctrl_c_regs",
"//hw/top:top_lib",
"//sw/device/lib/arch:device",
"//sw/device/lib/base:abs_mmio",
"//sw/device/lib/base:bitfield",
Expand Down
4 changes: 3 additions & 1 deletion sw/device/silicon_creator/lib/drivers/flash_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ enum {
*/
#ifdef OT_IS_ENGLISH_BREAKFAST
kBase = TOP_ENGLISHBREAKFAST_FLASH_CTRL_CORE_BASE_ADDR,
kBaseMem = TOP_ENGLISHBREAKFAST_FLASH_CTRL_MEM_BASE_ADDR
#else
kBase = TOP_EARLGREY_FLASH_CTRL_CORE_BASE_ADDR,
kBaseMem = TOP_EARLGREY_FLASH_CTRL_MEM_BASE_ADDR
#endif
};

Expand Down Expand Up @@ -425,7 +427,7 @@ rom_error_t flash_ctrl_data_erase_verify(uint32_t addr,
for (; launder32(i) < byte_count && launder32(r) < byte_count;
i += sizeof(uint32_t), r -= sizeof(uint32_t)) {
uint32_t word =
abs_mmio_read32(TOP_EARLGREY_FLASH_CTRL_MEM_BASE_ADDR + addr + i);
abs_mmio_read32(kBaseMem + addr + i);
mask &= word;
error &= word;
}
Expand Down
4 changes: 2 additions & 2 deletions sw/device/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ opentitan_test(
{"//hw/top_earlgrey:silicon_creator": None},
),
deps = [
"//hw/top_earlgrey/sw/autogen:devicetables",
"//hw/top:devicetables",
"//sw/device/lib/base:math",
"//sw/device/lib/base:mmio",
"//sw/device/lib/dif:aon_timer",
Expand Down Expand Up @@ -5364,7 +5364,7 @@ opentitan_test(
test_harness = "//sw/host/tests/chip/sysrst_ctrl:sysrst_ctrl_outputs",
),
deps = [
"//hw/top_earlgrey/sw/autogen:devicetables",
"//hw/top:devicetables",
"//sw/device/lib/base:mmio",
"//sw/device/lib/dif:pinmux",
"//sw/device/lib/dif:sysrst_ctrl",
Expand Down
45 changes: 45 additions & 0 deletions util/dtgen/devicetables.c.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,48 @@ size_t dt_device_index(dt_device_id_t dev) {
}
return 0;
}

<%
# List all muxed pads directly from the top.
pads = {pad["name"]: pad for pad in top['pinout']['pads'] if pad['connection'] == 'muxed'}

# List direct pads from the pinmux to avoid pins which are not relevant.
for pad in top['pinmux']['ios']:
if pad['connection'] == 'muxed':
continue
name = pad['name']
if pad['width'] > 1:
name += str(pad['idx'])
pads[name] = pad
%>\
// Pad descriptions.
const dt_pad_t kDtPad[kDtPadCount] = {
% for (padname, pad) in pads.items():
<%
if pad["connection"] == "muxed":
pad_type = "Mio"
pad_mio_out_or_direct_pad = "kDtPadMioOutNone"
pad_insel = "kDtPadInselNone"
if pad["port_type"] in ["input", "inout"]:
pad_mio_out_or_direct_pad = snake_to_constant_name("top_{}_pinmux_mio_out_{}".format(top["name"], padname))
if pad["port_type"] in ["output", "inout"]:
pad_insel = snake_to_constant_name("top_{}_pinmux_insel_{}".format(top["name"], padname))
elif pad["connection"] == "direct":
pad_type = "Dio"
pad_mio_out_or_direct_pad = snake_to_constant_name("top_{}_direct_pads_{}".format(top["name"], padname))
pad_insel = "0"
else:
assert pad["connection"] == "manual", "unexpected connection type '{}'".format(pad["connection"])
pad_mio_out_or_direct_pad = "0"
pad_insel = "0"
pad_type = "Other"
%>\
[${snake_to_constant_name("dt_pad_" + padname)}] = {
.__internal = {
.type = kDtPinType${pad_type},
.mio_out_or_direct_pad = ${pad_mio_out_or_direct_pad},
.insel = ${pad_insel},
}
},
% endfor
};
33 changes: 33 additions & 0 deletions util/dtgen/devicetables.h.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,43 @@ include_guard = "OPENTITAN_TOP_{}_DEVICETABLES_H_".format(top["name"].capitalize
#include "${header}" // Generated.
% endfor

// Number of instances of each module.
enum {
% for module_name in module_types:
<%
modules = [m for m in top["module"] if m["type"] == module_name]
%>\
kDt${snake_to_constant_name(module_name)}Count = ${len(modules)},
% endfor
};

% for module_name in module_types:
// Device tables for ${module_name}
extern const dt_${module_name}_t kDt${snake_to_constant_name(module_name)}[kDt${snake_to_constant_name(module_name)}Count];
% endfor

<%
# List all muxed pads directly from the top.
pads = [pad["name"] for pad in top['pinout']['pads'] if pad['connection'] == 'muxed']

# List direct pads from the pinmux to avoid pins which are not relevant.
for pad in top['pinmux']['ios']:
if pad['connection'] == 'muxed':
continue
name = pad['name']
if pad['width'] > 1:
name += str(pad['idx'])
pads.append(name)
%>\
// List of pads.
typedef enum dt_pad_index_t {
% for pad in pads:
kDtPad${snake_to_constant_name(pad)},
% endfor
kDtPadCount,
} dt_pad_index_t;

// Pad descriptions (indexed by dt_pad_index_t)
extern const dt_pad_t kDtPad[kDtPadCount];

#endif // ${include_guard}
Loading

0 comments on commit a76d5fe

Please sign in to comment.