8000 spidev: use constants for commands, add PRDRES to op.go · u-root/u-root@08ea1c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 08ea1c0

Browse files
committed
spidev: use constants for commands, add PRDRES to op.go
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
1 parent 9a9baa5 commit 08ea1c0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cmds/fwtools/spidev/spidev_linux.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
flag "github.com/spf13/pflag"
3434
"github.com/u-root/u-root/pkg/flash"
35+
"github.com/u-root/u-root/pkg/flash/op"
3536
"github.com/u-root/u-root/pkg/flash/sfdp"
3637
"github.com/u-root/u-root/pkg/spidev"
3738
)
@@ -84,12 +85,12 @@ func run(args []string, spiOpen spiOpenFunc, input io.Reader, output io.Writer)
8485
switch cmd {
8586
case "id":
8687
// Wake it up, then get the id.
87-
// 0xab is not universally handled on all devices, but that's ok.
88+
// PRDRES is not universally handled on all devices, but that's ok.
8889
// but CE MUST drop, so we structure this as two separate
8990
// transfers to ensure that happens.
9091
transfers := []spidev.Transfer{
9192
{
92-
Tx: []byte{0xab},
93+
Tx: []byte{op.PRDRES},
9394
Rx: make([]byte, 1),
9495
},
9596
}
@@ -101,7 +102,7 @@ func run(args []string, spiOpen spiOpenFunc, input io.Reader, output io.Writer)
101102
var id = []byte{0x9f, 0, 0, 0}
102103
transfers = []spidev.Transfer{
103104
{
104-
Tx: []byte{0x9f, 0, 0, 0},
105+
Tx: []byte{op.ReadJEDECID, 0, 0, 0},
105106
Rx: id,
106107
},
107108
}

pkg/flash/op/op.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const (
2323
ReadSFDP byte = 0x5a
2424
// ReadID reads the JEDEC ID.
2525
ReadJEDECID byte = 0x9f
26+
// PRD/RES
27+
PRDRES = 0xab
2628
// Enter4BA enters 4-byte addressing mode.
2729
Enter4BA byte = 0xb7
2830
// BlockErase erases a block to the value 0xff.

0 commit comments

Comments
 (0)
0