Skip to contentSkip to conversation

Can't access mmc #0 on mt7623 when booted from external SD

PATCH In review David Woodhouse 5 participants 16 messages Jun 16, 2020 – Jul 29, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

The Banana Pi R2 bootloader will load U-Boot from either the internal eMMC, or the external SD card if the latter is present.

If booted from the eMMC (and an SD card is subsequently inserted), both work from U-Boot. Both also work from Linux, whichever device is booted from.

If booted from SD, the internal eMMC cannot be accessed from U-Boot. This makes it slightly difficult for me to write a U-Boot script which installs OpenWRT from the SD card to the internal eMMC...

From SD:

U-Boot 2020.07-rc4-00057-gc622afb087 (Jun 16 2020 - 17:05:55 +0100)

CPU:   MediaTek MT7623 E3                                                       
DRAM:  2 GiB                                                                    
WDT:   Started with servicing (60s timeout)                                     
MMC:   mmc at 11230000: 0, mmc at 11240000: 1                                         

Loading Environment from FAT... ** No device specified ** ## Warning: Unknown environment variable type 'i' ## Warning: Unknown environment variable type 'i' ## Warning: Unknown environment variable type 'i'

In:    serial                                                                   
Out:   serial                                                                   
Err:   serial                                                                   
Hit any key to stop autoboot:  0                                                

U-Boot> mmc list
mmc at 11230000: 0
mmc at 11240000: 1
U-Boot> mmc dev 0
CMD_SEND:0

                ARG                      0x00000000                             
                MMC_RSP_NONE                                                    
CMD_SEND:8                                                                      
                ARG                      0x000001aa                             
                RET                      -110                                   
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                RET                      -110                                   
CMD_SEND:0                                                                      
                ARG                      0x00000000                             
                MMC_RSP_NONE                                                    
CMD_SEND:1                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R3,4             0xffffffff                             
CMD_SEND:2                                                                      
                ARG                      0x00000000                             
                RET                      -110                                   
U-Boot> mmc dev 1                                                               
CMD_SEND:0                                                                      
                ARG                      0x00000000                             
                MMC_RSP_NONE                                                    
CMD_SEND:8                                                                      
                ARG                      0x000001aa                             
                MMC_RSP_R1,5,6,7         0x000001aa                             
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000120                             
CMD_SEND:41                                                                     
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x00ff8000                             
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000120                             
CMD_SEND:41                                                                     
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x80ff8000                             
CMD_SEND:2                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R2               0x744a6055                             
                                         0x53442020                             
                                         0x104059f3                             
                                         0x34013be5                             
                                                                                
                                        DUMPING DATA                            
                                        000 - 74 4a 60 55                       
                                        004 - 53 44 20 20                       
                                        008 - 10 40 59 f3                       
                                        012 - 34 01 3b e5                       
CMD_SEND:3                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x59b40520                             
CMD_SEND:9                                                                      
                ARG                      0x59b40000                             
                MMC_RSP_R2               0x007f0032                             
                                         0x5b5a83bd                             
                                         0x6db7ff80                             
                                         0x0a80008d                             
                                                                                
                                        DUMPING DATA                            
                                        000 - 00 7f 00 32                       
                                        004 - 5b 5a 83 bd                       
                                        008 - 6d b7 ff 80                       
                                        012 - 0a 80 00 8d                       
CMD_SEND:7                                                                      
                ARG                      0x59b40000                             
                MMC_RSP_R1,5,6,7         0x00000700                             
CMD_SEND:55                                                                     
                ARG                      0x59b40000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:51                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:6                                                                      
                ARG                      0x00fffff1                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:55                                                                     
                ARG                      0x59b40000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:6                                                                      
                ARG                      0x00000002                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:6                                                                      
                ARG                      0x80fffff1                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:55                                                                     
                ARG                      0x59b40000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:13                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:16                                                                     
                ARG                      0x00000200                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:17                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000900                             

switch to partitions #0, OK
mmc1 is current device

From MMC:

U-Boot 2020.07-rc4-00057-gc622afb087 (Jun 16 2020 - 17:05:55 +0100)

CPU:   MediaTek MT7623 E3                                                       
DRAM:  2 GiB                                                                    
WDT:   Started with servicing (60s timeout)                                     
MMC:   mmc at 11230000: 0, mmc at 11240000: 1                                         

Loading Environment from FAT... ** No device specified ** ## Warning: Unknown environment variable type 'i' ## Warning: Unknown environment variable type 'i' ## Warning: Unknown environment variable type 'i'

In:    serial                                                                   
Out:   serial                                                                   
Err:   serial                                                                   
Hit any key to stop autoboot:  0                                                

U-Boot> mmc list
mmc at 11230000: 0
mmc at 11240000: 1
U-Boot> mmc dev 0
CMD_SEND:0

                ARG                      0x00000000                             
                MMC_RSP_NONE                                                    
CMD_SEND:8                                                                      
                ARG                      0x000001aa                             
                RET                      -110                                   
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                RET                      -110                                   
CMD_SEND:0                                                                      
                ARG                      0x00000000                             
                MMC_RSP_NONE                                                    
CMD_SEND:1                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R3,4             0x40ff8080                             
CMD_SEND:1                                                                      
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x40ff8080                             
CMD_SEND:0                                                                      
                ARG                      0x00000000                             
                MMC_RSP_NONE                                                    
CMD_SEND:1                                                                      
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x40ff8080                             
CMD_SEND:1                                                                      
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0xc0ff8080                             
CMD_SEND:2                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R2               0x15010038                             
                                         0x47544634                             
                                         0x5206071b                             
                                         0x48de461d                             
                                                                                
                                        DUMPING DATA                            
                                        000 - 15 01 00 38                       
                                        004 - 47 54 46 34                       
                                        008 - 52 06 07 1b                       
                                        012 - 48 de 46 1d                       
CMD_SEND:3                                                                      
                ARG                      0x00010000                             
                MMC_RSP_R1,5,6,7         0x00000500                             
CMD_SEND:9                                                                      
                ARG                      0x00010000                             
                MMC_RSP_R2               0xd0270132                             
                                         0x0f5903ff                             
                                         0xf6dbffef                             
                                         0x8e40400d                             
                                                                                
                                        DUMPING DATA                            
                                        000 - d0 27 01 32                       
                                        004 - 0f 59 03 ff                       
                                        008 - f6 db ff ef                       
                                        012 - 8e 40 40 0d                       
CMD_SEND:7                                                                      
                ARG                      0x00010000                             
                MMC_RSP_R1,5,6,7         0x00000700                             
CMD_SEND:8                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:6                                                                      
                ARG                      0x03b70200                             
                MMC_RSP_R1b              0x00000900                             
CMD_SEND:13                                                                     
                ARG                      0x00010000                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CURR STATE:4                                                                    
CMD_SEND:6                                                                      
                ARG                      0x03b90100                             
                MMC_RSP_R1b              0x00000900                             
CMD_SEND:13                                                                     
                ARG                      0x00010000                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CURR STATE:4                                                                    
CMD_SEND:8                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:8                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:16                                                                     
                ARG                      0x00000200                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:17                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000900                             

switch to partitions #0, OK
mmc0(part 0) is current device
U-Boot> mmc dev 1
CMD_SEND:0

                ARG                      0x00000000                             
                MMC_RSP_NONE                                                    
CMD_SEND:8                                                                      
                ARG                      0x000001aa                             
                MMC_RSP_R1,5,6,7         0x000001aa                             
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000120                             
CMD_SEND:41                                                                     
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x00ff8000                             
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000120                             
CMD_SEND:41                                                                     
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x00ff8000                             
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000120                             
CMD_SEND:41                                                                     
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x00ff8000                             
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000120                             
CMD_SEND:41                                                                     
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x00ff8000                             
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000120                             
CMD_SEND:41                                                                     
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x00ff8000                             
CMD_SEND:55                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000120                             
CMD_SEND:41                                                                     
                ARG                      0x40300000                             
                MMC_RSP_R3,4             0x80ff8000                             
CMD_SEND:2                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R2               0x744a6055                             
                                         0x53442020                             
                                         0x104059f3                             
                                         0x34013be5                             
                                                                                
                                        DUMPING DATA                            
                                        000 - 74 4a 60 55                       
                                        004 - 53 44 20 20                       
                                        008 - 10 40 59 f3                       
                                        012 - 34 01 3b e5                       
CMD_SEND:3                                                                      
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x59b40520                             
CMD_SEND:9                                                                      
                ARG                      0x59b40000                             
                MMC_RSP_R2               0x007f0032                             
                                         0x5b5a83bd                             
                                         0x6db7ff80                             
                                         0x0a80008d                             
                                                                                
                                        DUMPING DATA                            
                                        000 - 00 7f 00 32                       
                                        004 - 5b 5a 83 bd                       
                                        008 - 6d b7 ff 80                       
                                        012 - 0a 80 00 8d                       
CMD_SEND:7                                                                      
                ARG                      0x59b40000                             
                MMC_RSP_R1,5,6,7         0x00000700                             
CMD_SEND:55                                                                     
                ARG                      0x59b40000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:51                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:6                                                                      
                ARG                      0x00fffff1                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:55                                                                     
                ARG                      0x59b40000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:6                                                                      
                ARG                      0x00000002                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:6                                                                      
                ARG                      0x80fffff1                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:55                                                                     
                ARG                      0x59b40000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:13                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000920                             
CMD_SEND:16                                                                     
                ARG                      0x00000200                             
                MMC_RSP_R1,5,6,7         0x00000900                             
CMD_SEND:17                                                                     
                ARG                      0x00000000                             
                MMC_RSP_R1,5,6,7         0x00000900                             

switch to partitions #0, OK
mmc1 is current device
U-Boot>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200616/4b911fb4/attachment.bin>

#1 lore raw

Hi David

Quoted 11 lines · David Woodhouse

The Banana Pi R2 bootloader will load U-Boot from either the internal eMMC, or the external SD card if the latter is present.

If booted from the eMMC (and an SD card is subsequently inserted), both work from U-Boot. Both also work from Linux, whichever device is booted from.

If booted from SD, the internal eMMC cannot be accessed from U-Boot. This makes it slightly difficult for me to write a U-Boot script which installs OpenWRT from the SD card to the internal eMMC...

I'm thinking that bootrom do the right job for you when both are working.

Michael

Quoted 338 lines

From SD:

U-Boot 2020.07-rc4-00057-gc622afb087 (Jun 16 2020 - 17:05:55 +0100)

CPU:   MediaTek MT7623 E3
DRAM:  2 GiB
WDT:   Started with servicing (60s timeout)
MMC:   mmc at 11230000: 0, mmc at 11240000: 1

Loading Environment from FAT... ** No device specified ** ## Warning: Unknown environment variable type 'i' ## Warning: Unknown environment variable type 'i' ## Warning: Unknown environment variable type 'i'

In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0

U-Boot> mmc list
mmc at 11230000: 0
mmc at 11240000: 1
U-Boot> mmc dev 0
CMD_SEND:0

                ARG                      0x00000000
                MMC_RSP_NONE
CMD_SEND:8
                ARG                      0x000001aa
                RET                      -110
CMD_SEND:55
                ARG                      0x00000000
                RET                      -110
CMD_SEND:0
                ARG                      0x00000000
                MMC_RSP_NONE
CMD_SEND:1
                ARG                      0x00000000
                MMC_RSP_R3,4             0xffffffff
CMD_SEND:2
                ARG                      0x00000000
                RET                      -110
U-Boot> mmc dev 1
CMD_SEND:0
                ARG                      0x00000000
                MMC_RSP_NONE
CMD_SEND:8
                ARG                      0x000001aa
                MMC_RSP_R1,5,6,7         0x000001aa
CMD_SEND:55
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000120
CMD_SEND:41
                ARG                      0x40300000
                MMC_RSP_R3,4             0x00ff8000
CMD_SEND:55
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000120
CMD_SEND:41
                ARG                      0x40300000
                MMC_RSP_R3,4             0x80ff8000
CMD_SEND:2
                ARG                      0x00000000
                MMC_RSP_R2               0x744a6055
                                         0x53442020
                                         0x104059f3
                                         0x34013be5

                                        DUMPING DATA
                                        000 - 74 4a 60 55
                                        004 - 53 44 20 20
                                        008 - 10 40 59 f3
                                        012 - 34 01 3b e5
CMD_SEND:3
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x59b40520
CMD_SEND:9
                ARG                      0x59b40000
                MMC_RSP_R2               0x007f0032
                                         0x5b5a83bd
                                         0x6db7ff80
                                         0x0a80008d

                                        DUMPING DATA
                                        000 - 00 7f 00 32
                                        004 - 5b 5a 83 bd
                                        008 - 6d b7 ff 80
                                        012 - 0a 80 00 8d
CMD_SEND:7
                ARG                      0x59b40000
                MMC_RSP_R1,5,6,7         0x00000700
CMD_SEND:55
                ARG                      0x59b40000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:51
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:6
                ARG                      0x00fffff1
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:55
                ARG                      0x59b40000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:6
                ARG                      0x00000002
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:6
                ARG                      0x80fffff1
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:55
                ARG                      0x59b40000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:13
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:16
                ARG                      0x00000200
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:17
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000900

switch to partitions #0, OK
mmc1 is current device

From MMC:

U-Boot 2020.07-rc4-00057-gc622afb087 (Jun 16 2020 - 17:05:55 +0100)

CPU:   MediaTek MT7623 E3
DRAM:  2 GiB
WDT:   Started with servicing (60s timeout)
MMC:   mmc at 11230000: 0, mmc at 11240000: 1

Loading Environment from FAT... ** No device specified ** ## Warning: Unknown environment variable type 'i' ## Warning: Unknown environment variable type 'i' ## Warning: Unknown environment variable type 'i'

In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0

U-Boot> mmc list
mmc at 11230000: 0
mmc at 11240000: 1
U-Boot> mmc dev 0
CMD_SEND:0

                ARG                      0x00000000
                MMC_RSP_NONE
CMD_SEND:8
                ARG                      0x000001aa
                RET                      -110
CMD_SEND:55
                ARG                      0x00000000
                RET                      -110
CMD_SEND:0
                ARG                      0x00000000
                MMC_RSP_NONE
CMD_SEND:1
                ARG                      0x00000000
                MMC_RSP_R3,4             0x40ff8080
CMD_SEND:1
                ARG                      0x40300000
                MMC_RSP_R3,4             0x40ff8080
CMD_SEND:0
                ARG                      0x00000000
                MMC_RSP_NONE
CMD_SEND:1
                ARG                      0x40300000
                MMC_RSP_R3,4             0x40ff8080
CMD_SEND:1
                ARG                      0x40300000
                MMC_RSP_R3,4             0xc0ff8080
CMD_SEND:2
                ARG                      0x00000000
                MMC_RSP_R2               0x15010038
                                         0x47544634
                                         0x5206071b
                                         0x48de461d

                                        DUMPING DATA
                                        000 - 15 01 00 38
                                        004 - 47 54 46 34
                                        008 - 52 06 07 1b
                                        012 - 48 de 46 1d
CMD_SEND:3
                ARG                      0x00010000
                MMC_RSP_R1,5,6,7         0x00000500
CMD_SEND:9
                ARG                      0x00010000
                MMC_RSP_R2               0xd0270132
                                         0x0f5903ff
                                         0xf6dbffef
                                         0x8e40400d

                                        DUMPING DATA
                                        000 - d0 27 01 32
                                        004 - 0f 59 03 ff
                                        008 - f6 db ff ef
                                        012 - 8e 40 40 0d
CMD_SEND:7
                ARG                      0x00010000
                MMC_RSP_R1,5,6,7         0x00000700
CMD_SEND:8
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:6
                ARG                      0x03b70200
                MMC_RSP_R1b              0x00000900
CMD_SEND:13
                ARG                      0x00010000
                MMC_RSP_R1,5,6,7         0x00000900
CURR STATE:4
CMD_SEND:6
                ARG                      0x03b90100
                MMC_RSP_R1b              0x00000900
CMD_SEND:13
                ARG                      0x00010000
                MMC_RSP_R1,5,6,7         0x00000900
CURR STATE:4
CMD_SEND:8
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:8
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:16
                ARG                      0x00000200
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:17
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000900

switch to partitions #0, OK
mmc0(part 0) is current device
U-Boot> mmc dev 1
CMD_SEND:0

                ARG                      0x00000000
                MMC_RSP_NONE
CMD_SEND:8
                ARG                      0x000001aa
                MMC_RSP_R1,5,6,7         0x000001aa
CMD_SEND:55
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000120
CMD_SEND:41
                ARG                      0x40300000
                MMC_RSP_R3,4             0x00ff8000
CMD_SEND:55
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000120
CMD_SEND:41
                ARG                      0x40300000
                MMC_RSP_R3,4             0x00ff8000
CMD_SEND:55
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000120
CMD_SEND:41
                ARG                      0x40300000
                MMC_RSP_R3,4             0x00ff8000
CMD_SEND:55
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000120
CMD_SEND:41
                ARG                      0x40300000
                MMC_RSP_R3,4             0x00ff8000
CMD_SEND:55
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000120
CMD_SEND:41
                ARG                      0x40300000
                MMC_RSP_R3,4             0x00ff8000
CMD_SEND:55
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000120
CMD_SEND:41
                ARG                      0x40300000
                MMC_RSP_R3,4             0x80ff8000
CMD_SEND:2
                ARG                      0x00000000
                MMC_RSP_R2               0x744a6055
                                         0x53442020
                                         0x104059f3
                                         0x34013be5

                                        DUMPING DATA
                                        000 - 74 4a 60 55
                                        004 - 53 44 20 20
                                        008 - 10 40 59 f3
                                        012 - 34 01 3b e5
CMD_SEND:3
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x59b40520
CMD_SEND:9
                ARG                      0x59b40000
                MMC_RSP_R2               0x007f0032
                                         0x5b5a83bd
                                         0x6db7ff80
                                         0x0a80008d

                                        DUMPING DATA
                                        000 - 00 7f 00 32
                                        004 - 5b 5a 83 bd
                                        008 - 6d b7 ff 80
                                        012 - 0a 80 00 8d
CMD_SEND:7
                ARG                      0x59b40000
                MMC_RSP_R1,5,6,7         0x00000700
CMD_SEND:55
                ARG                      0x59b40000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:51
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:6
                ARG                      0x00fffff1
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:55
                ARG                      0x59b40000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:6
                ARG                      0x00000002
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:6
                ARG                      0x80fffff1
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:55
                ARG                      0x59b40000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:13
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000920
CMD_SEND:16
                ARG                      0x00000200
                MMC_RSP_R1,5,6,7         0x00000900
CMD_SEND:17
                ARG                      0x00000000
                MMC_RSP_R1,5,6,7         0x00000900

switch to partitions #0, OK
mmc1 is current device
U-Boot>

Signature · 4 lines
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |
#2 lore raw
Quoted 11 lines · Michael Nazzareno Trimarchi

Hi David

Quoted 8 lines · David Woodhouse

The Banana Pi R2 bootloader will load U-Boot from either the internal eMMC, or the external SD card if the latter is present.

If booted from the eMMC (and an SD card is subsequently inserted), both work from U-Boot. Both also work from Linux, whichever device is booted from.

Quoted 5 lines
Quoted 3 lines

If booted from SD, the internal eMMC cannot be accessed from U-Boot. This makes it slightly difficult for me to write a U-Boot script which installs OpenWRT from the SD card to the internal eMMC...

I'm thinking that bootrom do the right job for you when both are working.

Yes. It does seem likely that when loading U-Boot from the eMMC, the preloader is initialising it for us. But when the preloader loads U-Boot from the SD card, it possibly doesn't initialise the eMMC controller at all.

The Linux driver does cope with this, and drives the internal eMMC. Perhaps there's just some init code missing from the U-Boot mtk-sd driver?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200616/f9274c14/attachment.bin>

#3 lore raw
Quoted 19 lines · David Woodhouse
Quoted 11 lines · Michael Nazzareno Trimarchi

Hi David

Quoted 8 lines · David Woodhouse

The Banana Pi R2 bootloader will load U-Boot from either the internal eMMC, or the external SD card if the latter is present.

If booted from the eMMC (and an SD card is subsequently inserted), both work from U-Boot. Both also work from Linux, whichever device is booted from.

Quoted 5 lines
Quoted 3 lines

If booted from SD, the internal eMMC cannot be accessed from U-Boot. This makes it slightly difficult for me to write a U-Boot script which installs OpenWRT from the SD card to the internal eMMC...

I'm thinking that bootrom do the right job for you when both are working.

Quoted 8 lines

Yes. It does seem likely that when loading U-Boot from the eMMC, the preloader is initialising it for us. But when the preloader loads U-Boot from the SD card, it possibly doesn't initialise the eMMC controller at all.

The Linux driver does cope with this, and drives the internal eMMC. Perhaps there's just some init code missing from the U-Boot mtk-sd driver?

what dts are you using and config? I don't find Banana PI R2

Micheal

Quoted 3 lines
Signature · 4 lines
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |
#4 lore raw
Quoted 25 lines · Michael Nazzareno Trimarchi
Quoted 24 lines · David Woodhouse
Quoted 11 lines · Michael Nazzareno Trimarchi

Hi David

Quoted 8 lines · David Woodhouse

The Banana Pi R2 bootloader will load U-Boot from either the internal eMMC, or the external SD card if the latter is present.

If booted from the eMMC (and an SD card is subsequently inserted), both work from U-Boot. Both also work from Linux, whichever device is booted from.

Quoted 5 lines
Quoted 3 lines

If booted from SD, the internal eMMC cannot be accessed from U-Boot. This makes it slightly difficult for me to write a U-Boot script which installs OpenWRT from the SD card to the internal eMMC...

I'm thinking that bootrom do the right job for you when both are working.

Yes. It does seem likely that when loading U-Boot from the eMMC, the preloader is initialising it for us. But when the preloader loads U-Boot from the SD card, it possibly doesn't initialise the eMMC controller at all.

Quoted 5 lines
Quoted 3 lines

The Linux driver does cope with this, and drives the internal eMMC. Perhaps there's just some init code missing from the U-Boot mtk-sd driver?

what dts are you using and config? I don't find Banana PI R2

It's mt7623n_bpir2_defconfig
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200616/84e77464/attachment.bin>

#5 lore raw

Hi

Quoted 27 lines · David Woodhouse
Quoted 25 lines · Michael Nazzareno Trimarchi
Quoted 24 lines · David Woodhouse
Quoted 11 lines · Michael Nazzareno Trimarchi

Hi David

Quoted 8 lines · David Woodhouse

The Banana Pi R2 bootloader will load U-Boot from either the internal eMMC, or the external SD card if the latter is present.

If booted from the eMMC (and an SD card is subsequently inserted), both work from U-Boot. Both also work from Linux, whichever device is booted from.

Quoted 5 lines
Quoted 3 lines

If booted from SD, the internal eMMC cannot be accessed from U-Boot. This makes it slightly difficult for me to write a U-Boot script which installs OpenWRT from the SD card to the internal eMMC...

I'm thinking that bootrom do the right job for you when both are working.

Yes. It does seem likely that when loading U-Boot from the eMMC, the preloader is initialising it for us. But when the preloader loads U-Boot from the SD card, it possibly doesn't initialise the eMMC controller at all.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

The Linux driver does cope with this, and drives the internal eMMC. Perhaps there's just some init code missing from the U-Boot mtk-sd driver?

what dts are you using and config? I don't find Banana PI R2

It's mt7623n_bpir2_defconfig

Have you already tried to dump the pinmux using the cmd? in both situation?

Micahel

Signature · 4 lines
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |
#6 lore raw
Quoted 2 lines · Michael Nazzareno Trimarchi

Have you already tried to dump the pinmux using the cmd? in both situation?

U-Boot> pinmux status -a
--------------------------
pinctrl at 10005000:
Ops get_pin_muxing error (-38)
Can't display pin muxing for pinctrl at 10005000
exit not allowed from main input shell.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200616/b8ec98f5/attachment.bin>

#7 lore raw
Quoted 10 lines · David Woodhouse
Quoted 2 lines · Michael Nazzareno Trimarchi

Have you already tried to dump the pinmux using the cmd? in both situation?

U-Boot> pinmux status -a
--------------------------
pinctrl at 10005000:
Ops get_pin_muxing error (-38)
Can't display pin muxing for pinctrl at 10005000
exit not allowed from main input shell.

I found a datasheet...

Booted from SD, not working...

U-Boot> md 0x10005cc0 c

10005cc0: 00000111 00000111 00000111 00000111    ................               
10005cd0: 00000111 00000111 00000111 00000111    ................               
10005ce0: 00000011 00000011 00000011 00000011    ................               

Booted from eMMC, working...

U-Boot> md 0x10005cc0 c

10005cc0: 00000910 00000910 00000910 00000910    ................               
10005cd0: 00000c10 00000c10 00000c10 00000c10    ................               
10005ce0: 00000010 00000010 00000010 00000010    ................               

Now when I start U-Boot from the SD card I can make it work...

U-Boot> mmc list
mmc at 11230000: 0
mmc at 11240000: 1 (SD)
U-Boot> mmc dev 0
U-Boot> mw 0x10005cc0 0x910
U-Boot> mw 0x10005cd0 0xc10
U-Boot> mw 0x10005ce0 0x10
U-Boot> mmc dev 0
switch to partitions #0, OK
mmc0(part 0) is current device
U-Boot> mmc list
mmc at 11230000: 0 (eMMC)
mmc at 11240000: 1 (SD)
U-Boot>

So... whose bug is that? :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200618/0b56cab0/attachment.bin>

#8 lore raw
Quoted 1 line · David Woodhouse

So... whose bug is that? :)

Looks like the pinctrl driver. This *ought* to work (with the caveat that I really ought to make two pinctrl setups and change between them according to the voltage, like the Linux DT and mtk-sd driver do).

arch/arm/dts/mt7623n-bananapi-bpi-r2.dts +0 -0
@@ -133,12 +133,14 @@
                               "MSDC0_DAT2", "MSDC0_DAT3",

"MSDC0_DAT4",

                               "MSDC0_DAT5", "MSDC0_DAT6",
"MSDC0_DAT7";
                        input-enable;
-                       bias-pull-up;
+                       drive-strength = <2>;
+                       bias-pull-up = <3>;
                };
 
                conf-clk {
                        pins = "MSDC0_CLK";
-                       bias-pull-down;
+                       drive-strength = <2>;
+                       bias-pull-down = <3>;
                };
 
                conf-rst {

But it doesn't work. Partly because the U-Boot mtk pinctrl driver
doesn't support the R0 R1 bits encoded in that <3>, and partly because
it doesn't *even* get pullup/pulldown right at all; it sets the bit in
the GPIO_PULLSEL registers but *not* the PUPD bit in the correct
register for MSDC and other pins.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200618/5f1d8324/attachment.bin>

#9 lore raw

Hi David

Quoted 28 lines · David Woodhouse
Quoted 1 line · David Woodhouse

So... whose bug is that? :)

Looks like the pinctrl driver. This *ought* to work (with the caveat that I really ought to make two pinctrl setups and change between them according to the voltage, like the Linux DT and mtk-sd driver do).

arch/arm/dts/mt7623n-bananapi-bpi-r2.dts +4 -2
@@ -133,12 +133,14 @@
                               "MSDC0_DAT2", "MSDC0_DAT3",
 "MSDC0_DAT4",
                               "MSDC0_DAT5", "MSDC0_DAT6",
 "MSDC0_DAT7";
                        input-enable;
-                       bias-pull-up;
+                       drive-strength = <2>;
+                       bias-pull-up = <3>;
                };
 
                conf-clk {
                        pins = "MSDC0_CLK";
-                       bias-pull-down;
+                       drive-strength = <2>;
+                       bias-pull-down = <3>;
                };
Quoted 8 lines
                conf-rst {

But it doesn't work. Partly because the U-Boot mtk pinctrl driver doesn't support the R0 R1 bits encoded in that <3>, and partly because it doesn't *even* get pullup/pulldown right at all; it sets the bit in the GPIO_PULLSEL registers but *not* the PUPD bit in the correct register for MSDC and other pins.

So change them manually, make it work, You have the board. I don't have any MediaTek board at the moment. Can you implement the missed part?

Michael

Signature · 4 lines
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |
#10 lore raw
Quoted 25 lines · Michael Nazzareno Trimarchi
Quoted 25 lines

Looks like the pinctrl driver. This *ought* to work (with the caveat that I really ought to make two pinctrl setups and change between them according to the voltage, like the Linux DT and mtk-sd driver do).

arch/arm/dts/mt7623n-bananapi-bpi-r2.dts +4 -2
@@ -133,12 +133,14 @@
                                "MSDC0_DAT2", "MSDC0_DAT3", "MSDC0_DAT4",
                                "MSDC0_DAT5", "MSDC0_DAT6", "MSDC0_DAT7";
                         input-enable;
-                       bias-pull-up;
+                       drive-strength = <2>;
+                       bias-pull-up = <3>;
                 };
 
                 conf-clk {
                         pins = "MSDC0_CLK";
-                       bias-pull-down;
+                       drive-strength = <2>;
+                       bias-pull-down = <3>;
                 };
 
                 conf-rst {
Quoted 8 lines
Quoted 5 lines

But it doesn't work. Partly because the U-Boot mtk pinctrl driver doesn't support the R0 R1 bits encoded in that <3>, and partly because it doesn't *even* get pullup/pulldown right at all; it sets the bit in the GPIO_PULLSEL registers but *not* the PUPD bit in the correct register for MSDC and other pins.

So change them manually, make it work, You have the board. I don't have any MediaTek board at the moment. Can you implement the missed part?

I think I'd rather let the MediaTek folks handle it, as it affects other SoCs too.

It turns out Linux has a pinctrl-mt7623.c driver which looks a lot like the U-Boot one, but *isn't* actually the one being used, because in Linux it only matches "mediatek,mt7623-moore-pinctrl" which isn't in this board's DT.

Linux also has a pinctrl-mt2701.c driver that matches the "mediatek,mt7623-pinctrl" that *is* on this board, and which *does* work correctly.

So I don't know if we just have the wrong driver in U-Boot. Or if the mediatek,mt7623-moore-pinctrl compatible string is a temporary name for the *same* hardware, to invoke the new driver that isn't complete yet so it isn't being used in Linux... but is in U-Boot?

Sean?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200618/04c310d1/attachment.bin>

#11 lore raw

PATCH 1/1 pinctrl: mediatek: add PUPD/R0/R1 support for MT7623

The pins for the MMC controller weren't being set up correctly because the pinctrl driver only sets the GPIO pullup/pulldown config and doesn't handle the special cases with PUPD/R0/R1 control.

---
And now the eMMC on my Banana Pi R2 actually works, even when booted from SD and the preloader hasn't initialised the pins for the eMMC.

The really key thing is actually putting the clock pin in pull-down mode when we're asked to.

This is inspired by the Linux driver but I'm not sure the Linux driver is doing the right thing for GPIO pins, since AFAICT the mtk_pinconf_adv_pull_set() function will bail out completely without doing anything for pins without R0/R1 support. And won't set the PULLEN/PULLSEL GPIO config for pins which *do* have PUPD support, so doesn't that mean if you're using them in GPIO mode they don't work either? My code sets PULLEN/PULLSEL *and* sets PUPD/R0/R1 if those exist.

I note the Linux mtk-sd driver (and DT) has a separate pinctrl configuration for 1.8v mode. which explicitly sets the driver strength to 2mA and the R0/R1 enables. That would work now if we wanted to support that too, but doesn't seem to be necessary.

 drivers/pinctrl/mediatek/pinctrl-mt7623.c     | 129 ++++++++++++++++++
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c |  19 ++-
 drivers/pinctrl/mediatek/pinctrl-mtk-common.h |   3 +
 3 files changed, 146 insertions(+), 5 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mt7623.c +129 -0
index d58d840e08..0f5dcb2c63 100644
@@ -262,6 +262,132 @@ static const struct mtk_pin_field_calc mt7623_pin_drv_range[] = {
 	PIN_FIELD16(278, 278, 0xf70, 0x10, 8, 4),
 };
 
+static const struct mtk_pin_field_calc mt7623_pin_pupd_range[] = {
+	/* MSDC0 */
+	PIN_FIELD16(111, 111, 0xd00, 0x10, 12, 1),
+	PIN_FIELD16(112, 112, 0xd00, 0x10, 8, 1),
+	PIN_FIELD16(113, 113, 0xd00, 0x10, 4, 1),
+	PIN_FIELD16(114, 114, 0xd00, 0x10, 0, 1),
+	PIN_FIELD16(115, 115, 0xd10, 0x10, 0, 1),
+	PIN_FIELD16(116, 116, 0xcd0, 0x10, 8, 1),
+	PIN_FIELD16(117, 117, 0xcc0, 0x10, 8, 1),
+	PIN_FIELD16(118, 118, 0xcf0, 0x10, 12, 1),
+	PIN_FIELD16(119, 119, 0xcf0, 0x10, 8, 1),
+	PIN_FIELD16(120, 120, 0xcf0, 0x10, 4, 1),
+	PIN_FIELD16(121, 121, 0xcf0, 0x10, 0, 1),
+	/* MSDC1 */
+	PIN_FIELD16(105, 105, 0xd40, 0x10, 8, 1),
+	PIN_FIELD16(106, 106, 0xd30, 0x10, 8, 1),
+	PIN_FIELD16(107, 107, 0xd60, 0x10, 0, 1),
+	PIN_FIELD16(108, 108, 0xd60, 0x10, 10, 1),
+	PIN_FIELD16(109, 109, 0xd60, 0x10, 4, 1),
+	PIN_FIELD16(110, 110, 0xc60, 0x10, 12, 1),
+	/* MSDC1 */
+	PIN_FIELD16(85, 85, 0xda0, 0x10, 8, 1),
+	PIN_FIELD16(86, 86, 0xd90, 0x10, 8, 1),
+	PIN_FIELD16(87, 87, 0xdc0, 0x10, 0, 1),
+	PIN_FIELD16(88, 88, 0xdc0, 0x10, 10, 1),
+	PIN_FIELD16(89, 89, 0xdc0, 0x10, 4, 1),
+	PIN_FIELD16(90, 90, 0xdc0, 0x10, 12, 1),
+	/* MSDC0E */
+	PIN_FIELD16(249, 249, 0x140, 0x10, 0, 1),
+	PIN_FIELD16(250, 250, 0x130, 0x10, 12, 1),
+	PIN_FIELD16(251, 251, 0x130, 0x10, 8, 1),
+	PIN_FIELD16(252, 252, 0x130, 0x10, 4, 1),
+	PIN_FIELD16(253, 253, 0x130, 0x10, 0, 1),
+	PIN_FIELD16(254, 254, 0xf40, 0x10, 12, 1),
+	PIN_FIELD16(255, 255, 0xf40, 0x10, 8, 1),
+	PIN_FIELD16(256, 256, 0xf40, 0x10, 4, 1),
+	PIN_FIELD16(257, 257, 0xf40, 0x10, 0, 1),
+	PIN_FIELD16(258, 258, 0xcb0, 0x10, 8, 1),
+	PIN_FIELD16(259, 259, 0xc90, 0x10, 8, 1),
+	PIN_FIELD16(261, 261, 0x140, 0x10, 8, 1),
+};
+
+static const struct mtk_pin_field_calc mt7623_pin_r1_range[] = {
+	/* MSDC0 */
+	PIN_FIELD16(111, 111, 0xd00, 0x10, 13, 1),
+	PIN_FIELD16(112, 112, 0xd00, 0x10, 9, 1),
+	PIN_FIELD16(113, 113, 0xd00, 0x10, 5, 1),
+	PIN_FIELD16(114, 114, 0xd00, 0x10, 1, 1),
+	PIN_FIELD16(115, 115, 0xd10, 0x10, 1, 1),
+	PIN_FIELD16(116, 116, 0xcd0, 0x10, 9, 1),
+	PIN_FIELD16(117, 117, 0xcc0, 0x10, 9, 1),
+	PIN_FIELD16(118, 118, 0xcf0, 0x10, 13, 1),
+	PIN_FIELD16(119, 119, 0xcf0, 0x10, 9, 1),
+	PIN_FIELD16(120, 120, 0xcf0, 0x10, 5, 1),
+	PIN_FIELD16(121, 121, 0xcf0, 0x10, 1, 1),
+	/* MSDC1 */
+	PIN_FIELD16(105, 105, 0xd40, 0x10, 9, 1),
+	PIN_FIELD16(106, 106, 0xd30, 0x10, 9, 1),
+	PIN_FIELD16(107, 107, 0xd60, 0x10, 1, 1),
+	PIN_FIELD16(108, 108, 0xd60, 0x10, 9, 1),
+	PIN_FIELD16(109, 109, 0xd60, 0x10, 5, 1),
+	PIN_FIELD16(110, 110, 0xc60, 0x10, 13, 1),
+	/* MSDC2 */
+	PIN_FIELD16(85, 85, 0xda0, 0x10, 9, 1),
+	PIN_FIELD16(86, 86, 0xd90, 0x10, 9, 1),
+	PIN_FIELD16(87, 87, 0xdc0, 0x10, 1, 1),
+	PIN_FIELD16(88, 88, 0xdc0, 0x10, 9, 1),
+	PIN_FIELD16(89, 89, 0xdc0, 0x10, 5, 1),
+	PIN_FIELD16(90, 90, 0xdc0, 0x10, 13, 1),
+	/* MSDC0E */
+	PIN_FIELD16(249, 249, 0x140, 0x10, 1, 1),
+	PIN_FIELD16(250, 250, 0x130, 0x10, 13, 1),
+	PIN_FIELD16(251, 251, 0x130, 0x10, 9, 1),
+	PIN_FIELD16(252, 252, 0x130, 0x10, 5, 1),
+	PIN_FIELD16(253, 253, 0x130, 0x10, 1, 1),
+	PIN_FIELD16(254, 254, 0xf40, 0x10, 13, 1),
+	PIN_FIELD16(255, 255, 0xf40, 0x10, 9, 1),
+	PIN_FIELD16(256, 256, 0xf40, 0x10, 5, 1),
+	PIN_FIELD16(257, 257, 0xf40, 0x10, 1, 1),
+	PIN_FIELD16(258, 258, 0xcb0, 0x10, 9, 1),
+	PIN_FIELD16(259, 259, 0xc90, 0x10, 9, 1),
+	PIN_FIELD16(261, 261, 0x140, 0x10, 9, 1),
+};
+
+static const struct mtk_pin_field_calc mt7623_pin_r0_range[] = {
+	/* MSDC0 */
+	PIN_FIELD16(111, 111, 0xd00, 0x10, 14, 1),
+	PIN_FIELD16(112, 112, 0xd00, 0x10, 10, 1),
+	PIN_FIELD16(113, 113, 0xd00, 0x10, 6, 1),
+	PIN_FIELD16(114, 114, 0xd00, 0x10, 2, 1),
+	PIN_FIELD16(115, 115, 0xd10, 0x10, 2, 1),
+	PIN_FIELD16(116, 116, 0xcd0, 0x10, 10, 1),
+	PIN_FIELD16(117, 117, 0xcc0, 0x10, 10, 1),
+	PIN_FIELD16(118, 118, 0xcf0, 0x10, 14, 1),
+	PIN_FIELD16(119, 119, 0xcf0, 0x10, 10, 1),
+	PIN_FIELD16(120, 120, 0xcf0, 0x10, 6, 1),
+	PIN_FIELD16(121, 121, 0xcf0, 0x10, 2, 1),
+	/* MSDC1 */
+	PIN_FIELD16(105, 105, 0xd40, 0x10, 10, 1),
+	PIN_FIELD16(106, 106, 0xd30, 0x10, 10, 1),
+	PIN_FIELD16(107, 107, 0xd60, 0x10, 2, 1),
+	PIN_FIELD16(108, 108, 0xd60, 0x10, 8, 1),
+	PIN_FIELD16(109, 109, 0xd60, 0x10, 6, 1),
+	PIN_FIELD16(110, 110, 0xc60, 0x10, 14, 1),
+	/* MSDC2 */
+	PIN_FIELD16(85, 85, 0xda0, 0x10, 10, 1),
+	PIN_FIELD16(86, 86, 0xd90, 0x10, 10, 1),
+	PIN_FIELD16(87, 87, 0xdc0, 0x10, 2, 1),
+	PIN_FIELD16(88, 88, 0xdc0, 0x10, 8, 1),
+	PIN_FIELD16(89, 89, 0xdc0, 0x10, 6, 1),
+	PIN_FIELD16(90, 90, 0xdc0, 0x10, 14, 1),
+	/* MSDC0E */
+	PIN_FIELD16(249, 249, 0x140, 0x10, 2, 1),
+	PIN_FIELD16(250, 250, 0x130, 0x10, 14, 1),
+	PIN_FIELD16(251, 251, 0x130, 0x10, 10, 1),
+	PIN_FIELD16(252, 252, 0x130, 0x10, 6, 1),
+	PIN_FIELD16(253, 253, 0x130, 0x10, 2, 1),
+	PIN_FIELD16(254, 254, 0xf40, 0x10, 14, 1),
+	PIN_FIELD16(255, 255, 0xf40, 0x10, 10, 1),
+	PIN_FIELD16(256, 256, 0xf40, 0x10, 6, 1),
+	PIN_FIELD16(257, 257, 0xf40, 0x10, 5, 1),
+	PIN_FIELD16(258, 258, 0xcb0, 0x10, 10, 1),
+	PIN_FIELD16(259, 259, 0xc90, 0x10, 10, 1),
+	PIN_FIELD16(261, 261, 0x140, 0x10, 10, 1),
+};
+
 static const struct mtk_pin_reg_calc mt7623_reg_cals[] = {
 	[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7623_pin_mode_range),
 	[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7623_pin_dir_range),
@@ -272,6 +398,9 @@ static const struct mtk_pin_reg_calc mt7623_reg_cals[] = {
 	[PINCTRL_PIN_REG_PULLSEL] = MTK_RANGE(mt7623_pin_pullsel_range),
 	[PINCTRL_PIN_REG_PULLEN] = MTK_RANGE(mt7623_pin_pullen_range),
 	[PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7623_pin_drv_range),
+	[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt7623_pin_pupd_range),
+	[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt7623_pin_r0_range),
+	[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt7623_pin_r1_range),
 };
 
 static const struct mtk_pin_desc mt7623_pins[] = {
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +14 -5
index 5fdc150295..f5199fc574 100644
@@ -296,7 +296,7 @@ static const struct pinconf_param mtk_conf_params[] = {
 };
 
 
-int mtk_pinconf_bias_set_v0(struct udevice *dev, u32 pin, u32 arg)
+int mtk_pinconf_bias_set_v0(struct udevice *dev, u32 pin, u32 arg, u32 val)
 {
 	int err, disable, pullup;
 
@@ -323,12 +323,14 @@ int mtk_pinconf_bias_set_v0(struct udevice *dev, u32 pin, u32 arg)
 	return 0;
 }
 
-int mtk_pinconf_bias_set_v1(struct udevice *dev, u32 pin, u32 arg)
+int mtk_pinconf_bias_set_v1(struct udevice *dev, u32 pin, u32 arg, u32 val)
 {
-	int err, disable, pullup;
+	int err, disable, pullup, r0, r1;
 
 	disable = (arg == PIN_CONFIG_BIAS_DISABLE);
 	pullup = (arg == PIN_CONFIG_BIAS_PULL_UP);
+	r0 = !!(val & 1);
+	r1 = !!(val & 2);
 
 	if (disable) {
 		err = mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_PULLEN, 0);
@@ -344,6 +346,13 @@ int mtk_pinconf_bias_set_v1(struct udevice *dev, u32 pin, u32 arg)
 			return err;
 	}
 
+	/* Also set PUPD/R0/R1 if the pin has them */
+	err = mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_PUPD, !pullup);
+	if (err != -EINVAL) {
+		mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R0, r0);
+		mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R1, r1);
+	}
+
 	return 0;
 }
 
@@ -419,9 +428,9 @@ static int mtk_pinconf_set(struct udevice *dev, unsigned int pin,
 	case PIN_CONFIG_BIAS_PULL_UP:
 	case PIN_CONFIG_BIAS_PULL_DOWN:
 		if (rev == MTK_PINCTRL_V0)
-			err = mtk_pinconf_bias_set_v0(dev, pin, param);
+			err = mtk_pinconf_bias_set_v0(dev, pin, param, arg);
 		else
-			err = mtk_pinconf_bias_set_v1(dev, pin, param);
+			err = mtk_pinconf_bias_set_v1(dev, pin, param, arg);
 		if (err)
 			goto err;
 		break;
drivers/pinctrl/mediatek/pinctrl-mtk-common.h +3 -0
index e815761450..5e51a9a90c 100644
@@ -51,6 +51,9 @@ enum {
 	PINCTRL_PIN_REG_PULLEN,
 	PINCTRL_PIN_REG_PULLSEL,
 	PINCTRL_PIN_REG_DRV,
+	PINCTRL_PIN_REG_PUPD,
+	PINCTRL_PIN_REG_R0,
+	PINCTRL_PIN_REG_R1,
 	PINCTRL_PIN_REG_MAX,
 };
 
Signature · 9 lines
2.26.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200619/4b988004/attachment.bin>
Tested-by on v1 1/1
#12 lore raw

Aw: [PATCH] pinctrl: mediatek: add PUPD/R0/R1 support for MT7623

Hi,

Problem seems to be board-specific, on my bananapi-r2 v1.0 i had no problems with accessing emmc if booted from sdcard.

but with the Patch i can still access any mmc-device (tried booting from emmc and sd)

regards Frank

#13 lore raw

PATCH 1/1 pinctrl: mediatek: add PUPD/R0/R1 support for MT7623

In reply to David Woodhouse
Quoted 5 lines · David Woodhouse

The pins for the MMC controller weren't being set up correctly because the pinctrl driver only sets the GPIO pullup/pulldown config and doesn't handle the special cases with PUPD/R0/R1 control.

Ping?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5174 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200724/1f644255/attachment.bin>

#14 lore raw

PATCH 1/1 pinctrl: mediatek: add PUPD/R0/R1 support for MT7623

In reply to David Woodhouse
Quoted 6 lines · David Woodhouse

The pins for the MMC controller weren't being set up correctly because the pinctrl driver only sets the GPIO pullup/pulldown config and doesn't handle the special cases with PUPD/R0/R1 control.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200729/b99803db/attachment.sig>
#15 lore raw
In reply to David Woodhouse

Hi David,

1. mt7623-moore-pinctrl is written for introducing more supports for new mediatek soc like mt7622, mt7629, mt8183 and so on and even more easily maintained than before

2. mt7623-moore-pinctrl/mt2701-pinctrl drives the same hardware, but with different driver style, the latter one is already hard to extend to newer and variety mediatek SoC.

3. mt7623 pinctrl on uboot would prefer to apply mt7623-moore-pinctrl just since pinctrl on uboot is developed later than mt7623-moore-pinctrl. mt7623 pinctrl on linux still would prefer to apply mt2701-pinctrl since they have been supported for a while and be stable enough.

4. it's still welcome to submit patches to mt7623-moore-pinctrl from your experiences in mt7623 uboot to make it complete.

Thanks,
Sean

-----Original Message-----
From: David Woodhouse [mailto:dwmw2 at infradead.org]
Sent: Thursday, June 18, 2020 2:03 PM
To: Michael Nazzareno Trimarchi <[email protected]>
Cc: U-Boot-Denx <[email protected]>; Ryder Lee (???) <[email protected]>; Weijie Gao (???) <[email protected]>; frank wunderlich <[email protected]>; Sean Wang <[email protected]>
Subject: Re: Can't access mmc #0 on mt7623 when booted from external SD

Quoted 25 lines · Michael Nazzareno Trimarchi
Quoted 25 lines

Looks like the pinctrl driver. This *ought* to work (with the caveat that I really ought to make two pinctrl setups and change between them according to the voltage, like the Linux DT and mtk-sd driver do).

arch/arm/dts/mt7623n-bananapi-bpi-r2.dts +4 -2
@@ -133,12 +133,14 @@
                                "MSDC0_DAT2", "MSDC0_DAT3", "MSDC0_DAT4",
                                "MSDC0_DAT5", "MSDC0_DAT6", "MSDC0_DAT7";
                         input-enable;
-                       bias-pull-up;
+                       drive-strength = <2>;
+                       bias-pull-up = <3>;
                 };
 
                 conf-clk {
                         pins = "MSDC0_CLK";
-                       bias-pull-down;
+                       drive-strength = <2>;
+                       bias-pull-down = <3>;
                 };
 
                 conf-rst {
Quoted 8 lines
Quoted 5 lines

But it doesn't work. Partly because the U-Boot mtk pinctrl driver doesn't support the R0 R1 bits encoded in that <3>, and partly because it doesn't *even* get pullup/pulldown right at all; it sets the bit in the GPIO_PULLSEL registers but *not* the PUPD bit in the correct register for MSDC and other pins.

So change them manually, make it work, You have the board. I don't have any MediaTek board at the moment. Can you implement the missed part?

I think I'd rather let the MediaTek folks handle it, as it affects other SoCs too.

It turns out Linux has a pinctrl-mt7623.c driver which looks a lot like the U-Boot one, but *isn't* actually the one being used, because in Linux it only matches "mediatek,mt7623-moore-pinctrl" which isn't in this board's DT.

Linux also has a pinctrl-mt2701.c driver that matches the "mediatek,mt7623-pinctrl" that *is* on this board, and which *does* work correctly.

So I don't know if we just have the wrong driver in U-Boot. Or if the mediatek,mt7623-moore-pinctrl compatible string is a temporary name for the *same* hardware, to invoke the new driver that isn't complete yet so it isn't being used in Linux... but is in U-Boot?

Sean?