Skip to content

overlays: sdhost: Add gpios_22_27 and bus_width parameters#7467

Open
zjzhao-eda wants to merge 1 commit into
raspberrypi:rpi-6.18.yfrom
edatec:sdhost-gpios-buswidth
Open

overlays: sdhost: Add gpios_22_27 and bus_width parameters#7467
zjzhao-eda wants to merge 1 commit into
raspberrypi:rpi-6.18.yfrom
edatec:sdhost-gpios-buswidth

Conversation

@zjzhao-eda

Copy link
Copy Markdown
Contributor

Summary

Add gpios_22_27 and bus_width parameters to the sdhost overlay
to support CM4 custom carrier boards that route SD0 to GPIO 22-27.

Motivation

Some CM4 carrier boards (e.g. industrial IPC boards) wire a secondary
SD card slot to GPIO 22-27 rather than using eMMC. The stock sdhost
overlay provides no way to configure this pinmux, forcing users to
maintain separate out-of-tree overlays.

Changes

  • Add dormant fragment@3: configures GPIO 22-27 to ALT0 (SD0)
  • Add dormant fragment@4: binds sdhost to the above pinctrl
  • Add gpios_22_27 override: activates fragments 3 and 4
  • Add bus_width override: exposes bus-width configuration
  • Update README with parameter documentation

Testing

Verified on CM4 + EDATEC IPC2100 carrier board:

  • lsblk shows mmcblk2 correctly detected on GPIO 22-27
pi@pi:~ $ lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0          7:0    0    2G  0 loop
mmcblk0      179:0    0 29.1G  0 disk
├─mmcblk0p1  179:1    0  512M  0 part /boot/firmware
└─mmcblk0p2  179:2    0 28.6G  0 part /
mmcblk0boot0 179:32   0    4M  1 disk
mmcblk0boot1 179:64   0    4M  1 disk
mmcblk2      179:96   0 29.7G  0 disk
├─mmcblk2p1  179:97   0  512M  0 part /media/pi/system-boot
└─mmcblk2p2  179:98   0 29.2G  0 part
zram0        254:0    0    2G  0 disk [SWAP]
  • dmesg confirms sdhost-bcm2835 loaded with DMA
pi@pi:~ $ dmesg | grep -iE "sdhost|mmc0|emmc"
[    0.762195] mmc0: SDHCI controller on fe340000.mmc [fe340000.mmc] using ADMA
[    0.800705] sdhost-bcm2835 fe202000.mmc: loaded - DMA enabled (>1)
[    0.819078] mmc0: new high speed DDR MMC card at address 0001
[    0.819531] mmcblk0: mmc0:0001 BJTD4R 29.1 GiB
[    0.821222] mmcblk0: mmc0:0001 BJTD4R 29.1 GiB
[    0.821548] mmcblk0boot0: mmc0:0001 BJTD4R 4.00 MiB
[    0.823176] mmcblk0boot1: mmc0:0001 BJTD4R 4.00 MiB
[    0.824889] mmcblk0rpmb: mmc0:0001 BJTD4R 4.00 MiB, chardev (242:0)
  • vclog confirms overlay parameters applied correctly
004758.485: brfs: File read: /mfs/sd/overlays/sdhost.dtbo
004771.492: Loaded overlay 'sdhost'
004771.503: dtparam: gpios_22_27=on
004771.873: dtparam: bus_width=4
004772.148: dtparam: pio_limit=1
004811.120: brfs: File read: 1451 bytes

config.txt used for testing:
dtoverlay=sdhost,gpios_22_27=on,bus_width=4,pio_limit=1

Add two new optional parameters to the sdhost overlay:
- gpios_22_27: Routes the SD0 interface to GPIO 22-27 (CLK, CMD,
  DAT0-3) using ALT0 function, with appropriate pull configuration
  (CLK: no pull, CMD/DAT: pull-up). This allows custom CM4 carrier
  boards to use a secondary SD card slot wired to these pins.
- bus_width: Allows configuring the MMC bus width (defaults to 1).
Both parameters are implemented as dormant fragments and have no
effect unless explicitly activated, preserving full backward
compatibility with existing configurations.
Tested on CM4 carrier board (EDATEC IPC2100) with:
  dtoverlay=sdhost,gpios_22_27=on,bus_width=4,pio_limit=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant