https://www.kernel.org/doc/Documentation/devicetree/bindings/mmc/sunxi-mmc.txt
* Allwinner sunxi MMC controller
The highspeed MMC host controller on Allwinner SoCs provides an interface
for MMC, SD and SDIO types of memory cards.
Supported maximum speeds are the ones of the eMMC standard 4.5 as well
as the speed of SD standard 3.0.
Absolute maximum transfer rate is 200MB/s
Required properties:
- compatible : should be one of:
* "allwinner,sun4i-a10-mmc"
* "allwinner,sun5i-a13-mmc"
* "allwinner,sun7i-a20-mmc"
* "allwinner,sun8i-a83t-emmc"
* "allwinner,sun9i-a80-mmc"
* "allwinner,sun50i-a64-emmc"
* "allwinner,sun50i-a64-mmc"
* "allwinner,sun50i-h6-emmc", "allwinner.sun50i-a64-emmc"
* "allwinner,sun50i-h6-mmc", "allwinner.sun50i-a64-mmc"
- reg : mmc controller base registers
- clocks : a list with 4 phandle + clock specifier pairs
- clock-names : must contain "ahb", "mmc", "output" and "sample"
- interrupts : mmc controller interrupt
Optional properties:
- resets : phandle + reset specifier pair
- reset-names : must contain "ahb"
- for cd, bus-width and additional generic mmc parameters
please refer to mmc.txt within this directory
Examples:
- Within .dtsi:
mmc0: mmc@1c0f000 {
compatible = "allwinner,sun5i-a13-mmc";
reg = <0x01c0f000 0x1000>;
clocks = <&ahb_gates 8>, <&mmc0_clk>, <&mmc0_output_clk>, <&mmc0_sample_clk>;
clock-names = "ahb", "mod", "output", "sample";
interrupts = <0 32 4>;
status = "disabled";
};
- Within dts:
mmc0: mmc@1c0f000 {
pinctrl-names = "default", "default";
pinctrl-0 = <&mmc0_pins_a>;
pinctrl-1 = <&mmc0_cd_pin_reference_design>;
bus-width = <4>;
cd-gpios = <&pio 7 1 0>; /* PH1 */
cd-inverted;
status = "okay";
};
离线
上面默认是 4bit 模式, 下面试一试把 S3/V3s 的 mmc2 改成 8bit 模式:
sun8i-dtsi 添加:
mmc2_pins: mmc1-pins {
pins = "PC0", "PC1", "PC2", "PC3",
"PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10";
function = "mmc2";
drive-strength = <30>;
bias-pull-up;
};
mmc2 改为:
mmc2: mmc@1c11000 {
compatible = "allwinner,sun7i-a20-mmc";
reg = <0x01c11000 0x1000>;
clocks = <&ccu CLK_BUS_MMC2>,
<&ccu CLK_MMC2>,
<&ccu CLK_MMC2_OUTPUT>,
<&ccu CLK_MMC2_SAMPLE>;
clock-names = "ahb",
"mmc",
"output",
"sample";
resets = <&ccu RST_BUS_MMC2>;
reset-names = "ahb";
interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
pinctrl-names = "default", "default";
pinctrl-0 = <&mmc2_pins>;
bus-width = <8>;
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
};
sun8i-v3s-licheepi-zero.dts 添加:
&mmc2 {
broken-cd;
bus-width = <4>;
vmmc-supply = <®_vcc3v3>;
status = "okay";
};
仅有 PC 这组 MMC 可以运行 8bit模式.
驱动程序: https://github.com/torvalds/linux/blob/master/drivers/mmc/host/sunxi-mmc.c
设备树:
https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/sun8i-v3s.dtsi
https://github.com/torvalds/linux/blob/master/arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dts
离线
感谢分享, 看来我应该使用 1bit 模式, 抠出 3个 IO口出来.
离线
牛啊。。。正在找这个,谢谢晕哥
离线
厉害了,感谢分享
离线
看起来很厉害,留名
离线
前面s3的mmc2 4bit sd nand上3.4上有识别到,4.13上好像没有识别到,
离线
没有测试, 因为我没有 8bit eMMC 的板子
没有测试, 因为我没有 8bit eMMC 的板子
没有测试, 因为我没有 8bit eMMC 的板子如果哪位测试 OK 了, 麻烦冒个泡泡.
等我先搞定qt的问题,然后测试,必须顶晕哥啊
离线
会不会是 IO,寄存器基地址和中断等资源配置不对呢?
我们看看是否可以解决这个问题吧
1. 上面有个地方bus_width应该是8的,没改
2. 修改pinctrl-sun8i-v3s.c
add
SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 4),
SUNXI_FUNCTION(0x0, "gpio_in"),
SUNXI_FUNCTION(0x1, "gpio_out"),
SUNXI_FUNCTION(0x2, "mmc2")), /* D1 */
SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 5),
SUNXI_FUNCTION(0x0, "gpio_in"),
SUNXI_FUNCTION(0x1, "gpio_out"),
SUNXI_FUNCTION(0x2, "mmc2")), /* D2 */
SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 6),
SUNXI_FUNCTION(0x0, "gpio_in"),
SUNXI_FUNCTION(0x1, "gpio_out"),
SUNXI_FUNCTION(0x2, "mmc2")), /* D3 */
SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 7),
SUNXI_FUNCTION(0x0, "gpio_in"),
SUNXI_FUNCTION(0x1, "gpio_out"),
SUNXI_FUNCTION(0x2, "mmc2")), /* D4 */
SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 8),
SUNXI_FUNCTION(0x0, "gpio_in"),
SUNXI_FUNCTION(0x1, "gpio_out"),
SUNXI_FUNCTION(0x2, "mmc2")), /* D5 */
SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 9),
SUNXI_FUNCTION(0x0, "gpio_in"),
SUNXI_FUNCTION(0x1, "gpio_out"),
SUNXI_FUNCTION(0x2, "mmc2")), /* D6 */
SUNXI_PIN(SUNXI_PINCTRL_PIN(C, 10),
SUNXI_FUNCTION(0x0, "gpio_in"),
SUNXI_FUNCTION(0x1, "gpio_out"),
SUNXI_FUNCTION(0x2, "mmc2")), /* D7 */
但是还不能用,说无法复位,发现在sunxi-mmc.c里面出错
[ 2.403310] sunxi-mmc 1c11000.mmc: fatal err reset timeout
[ 2.408816] sunxi_mmc_probe -5
[ 2.412372] sunxi-mmc: probe of 1c11000.mmc failed with error -5
因为 0x1c11000 读到的返回值是2,而不是0
但是测试过,所有的管脚配置都是对的,
0x1c20848, 0x1c2084c管脚设置都是2了
而且在用户态写复位也没问题
busybox devmem 0x1c11000 32 7
busybox devmem 0x1c11000 返回低三位0
最近编辑记录 powerpan (2019-06-29 14:41:34)
离线
那 4bit 可以用吗? 就是设备树什么都不用改,默认可以作为TF卡使用吗?
复位不成功,其他都是浮云。我测试了去掉了spi了,不是spi引起的冲突,但是肯定有啥冲突。。。否则不会到了用户态复位没问题,只要能正常加载,后面都好办
最近编辑记录 powerpan (2019-06-29 15:39:36)
离线
有没有上拉,和这个有没有关系?
离线
问题解决了,感谢 冰淇琳 icenowy 的 patch,
drivers/clk/sunxi-ng/ccu-sun8i-v3s.c
CLK_MMC1下面增加 CLK_MMC2的时钟3行
[CLK_MMC1] = &mmc1_clk.common.hw,
[CLK_MMC1_SAMPLE] = &mmc1_sample_clk.common.hw,
[CLK_MMC1_OUTPUT] = &mmc1_output_clk.common.hw,
[CLK_MMC2] = &mmc2_clk.common.hw,
[CLK_MMC2_SAMPLE] = &mmc2_sample_clk.common.hw,
[CLK_MMC2_OUTPUT] = &mmc2_output_clk.common.hw,
启动能看到
root@LicheePi:~# ls /dev/mmcblk*
/dev/mmcblk0 /dev/mmcblk0p2 /dev/mmcblk2boot0
/dev/mmcblk0p1 /dev/mmcblk2 /dev/mmcblk2boot1
离线
emmc uboot启动的问题,改动的是荔枝的 uboot代码, board.c
主要问题是pin config的问题,nnd这个uboot根本不会去读device tree。修改以下代码后就可以发现emmc了。
#elif defined(CONFIG_MACH_SUN8I) || defined(CONFIG_MACH_SUN50I)
#ifdef CONFIG_MACH_SUN8I_V3S
#define SUN8I_S3_GPC_SDC2 2
/* SDC2: PC0-PC10 by power*/
for (pin = SUNXI_GPC(0); pin <= SUNXI_GPC(10); pin++) {
//sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
sunxi_gpio_set_cfgpin(pin, SUN8I_S3_GPC_SDC2);
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
sunxi_gpio_set_drv(pin, 2);
}
#else
/* SDC2: PC5-PC6, PC8-PC16 */
for (pin = SUNXI_GPC(5); pin <= SUNXI_GPC(6); pin++) {
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
sunxi_gpio_set_drv(pin, 2);
}
for (pin = SUNXI_GPC(8); pin <= SUNXI_GPC(16); pin++) {
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
sunxi_gpio_set_drv(pin, 2);
}
#endif
#elif defined(CONFIG_MACH_SUN9I)
另外荔枝的 4.13的内核,emmc死活按照mmc2挂载,需要修改uboot的bootargs,否则没法挂文件系统。
uboot信息:
Hit any key to stop autoboot: 0
=> mmcinfo
Device: SUNXI SD/MMC
Manufacturer ID: 15
OEM: 100
Name: 4FTE4
Tran Speed: 52000000
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 3.6 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 3.6 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 512 KiB ENH
进入系统后信息:
ls /dev/mmc*
/dev/mmcblk2 /dev/mmcblk2boot1 /dev/mmcblk2p2
/dev/mmcblk2boot0 /dev/mmcblk2p1
最近编辑记录 powerpan (2019-12-31 12:55:50)
离线
感谢晕哥,icenowy的kernel代码和荔枝派提供的代码。
另外有人也说过什么spl部分不开源啊之类的,其实世上无难事,就看你是否用心了。9102年最后一天,留个记号。
另外谁知道uboot的 env保存在什么地方的?没看代码,如果知道的麻烦回下,感谢。
最近编辑记录 powerpan (2019-12-31 18:48:20)
离线
正在搞A33 eMMC,如此好帖怎么可以让他沉沦呢,我来托举一下吧。
离线
@powerpan
u-boot 的 pinctrl 没用起来, 所以得在 board.c 里面初始化管脚复用.
离线
@powerpan 大神 能修改改spi nand 吗
离线