Skip to content

overlays: sdhost: Add gpios_22_27 and bus_width parameters#7467

Merged
pelwell merged 1 commit into
raspberrypi:rpi-6.18.yfrom
edatec:sdhost-gpios-buswidth
Jul 2, 2026
Merged

overlays: sdhost: Add gpios_22_27 and bus_width parameters#7467
pelwell merged 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

Comment thread arch/arm/boot/dts/overlays/README Outdated

debug Enable debug output (default off)

bus_width MMC bus width (default 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default bus-width is theoretically platform-dependent, but in practice it is always going to be 4.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the bus_width parameter per your feedback and kept only gpios_22_27 . The commit has been updated with a proper description and Signed-off-by. Ready for review.

@zjzhao-eda zjzhao-eda force-pushed the sdhost-gpios-buswidth branch from 2d8d014 to 71f517c Compare July 2, 2026 10:58
@pelwell

pelwell commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Delete the README entry for the bus_width parameter, then I'll merge it.

Add a new optional parameter 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.

The parameter is implemented as dormant fragments and has 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,pio_limit=1

Signed-off-by: zjzhao <zjzhao@edatec.cn>
@zjzhao-eda zjzhao-eda force-pushed the sdhost-gpios-buswidth branch from 71f517c to 872575c Compare July 2, 2026 11:04
@zjzhao-eda

Copy link
Copy Markdown
Contributor Author

Sorry, I forgot to update the README as well. I've now removed the bus_width parameter from both the DTS and the README.

@pelwell pelwell merged commit 63598c8 into raspberrypi:rpi-6.18.y Jul 2, 2026
12 checks passed
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.

2 participants