-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d28bf8a
commit 7e6a964
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
open HolKernel bossLib boolLib Parse; | ||
open wordsTheory wordsLib; | ||
open SPI_stateTheory write_SPIregsTheory read_SPIregsTheory board_memTheory; | ||
|
||
val _ = new_theory "driver_init"; | ||
|
||
(* SPI controller performs operation of reset. *) | ||
val init_reset_op_def = Define ` | ||
init_reset_op (spi:spi_state) = | ||
spi with regs := spi.regs with | ||
<| SYSCONFIG := spi.regs.SYSCONFIG with SOFTRESET := 0w; | ||
SYSSTATUS := 1w (* means reset is done *)|>` | ||
|
||
(* This function shows initialization operations of SPI driver considering SPI controller state *) | ||
val init_operations_def = Define ` | ||
init_operations (env:environment) (spi:spi_state) (driver:spi_driver) = | ||
let (read_spi,sysstatus) = (read_SPI_regs env SPI0_SYSSTATUS spi driver) in | ||
case driver.init.state of | ||
| init_start => (write_SPI_regs SPI0_SYSCONFIG (2w:word32) spi driver) | ||
| init_reset => if sysstatus = (1w:word32) then (read_spi,driver with init := driver.init with state := init_setregs) | ||
else (init_reset_op spi, driver) | ||
| init_setregs => if ~driver.init.sysconfig_mode_done then | ||
(write_SPI_regs SPI0_SYSCONFIG (0x11w:word32) spi driver) | ||
else if ~driver.init.modulctrl_bus_done then | ||
(write_SPI_regs SPI0_MODULCTRL (1w:word32) spi driver) | ||
else if ~driver.init.ch0conf_wordlen_done then | ||
(write_SPI_regs SPI0_CH0CONF (0x700w:word32) spi driver) | ||
else if ~driver.init.ch0conf_mode_done then | ||
(write_SPI_regs SPI0_CH0CONF (0x00010040w:word32) spi driver) | ||
else if ~driver.init.ch0conf_speed_done then | ||
(write_SPI_regs SPI0_CH0CONF (0x18w:word32) spi driver) | ||
else (spi, driver with init := driver.init with state := init_done) | ||
| init_done => (spi, driver)` | ||
|
||
val _ = export_theory(); |