Skip to content

Commit

Permalink
litex_json2dts_zephyr.py: add custon handler for spiflash
Browse files Browse the repository at this point in the history
add custon handler for spiflash.

Signed-off-by: Fin Maaß <[email protected]>
  • Loading branch information
maass-hamburg committed Jun 11, 2024
1 parent 44b6fb5 commit bb155b5
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion litex/tools/litex_json2dts_zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,31 @@ def spimaster_handler(name, parm, csr):
return dtsi


def spiflash_handler(name, parm, csr):
registers = get_registers_of(name, csr)
if len(registers) == 0:
raise KeyError

# Add memory mapped region for spiflash, the linker script in zephyr expects this region to be
# the entry with the name flash_mmap in the reg property of the spi controller.
try:
registers.append({
'addr': csr['memories'][name]['base'],
'size': csr['memories'][name]['size'],
'name': 'flash_mmap',
})
except KeyError as e:
print('memory mapped', e, 'not found')

dtsi = dts_reg(registers)
dtsi += dts_reg_names(registers)

dtsi += indent("clock-frequency = <{}>;\n".format(
csr['constants'][name + '_phy_frequency']))

return dtsi


def peripheral_handler(name, parm, csr):
registers = get_registers_of(name, csr)
if len(registers) == 0:
Expand Down Expand Up @@ -244,7 +269,7 @@ def peripheral_handler(name, parm, csr):
'alias': 'spi0',
},
'spiflash': {
'handler': peripheral_handler,
'handler': spiflash_handler,
'alias': 'spi1',
},
'sdcard_block2mem': {
Expand Down

0 comments on commit bb155b5

Please sign in to comment.