Take the patches http://lists.infradead.org/pipermail/linux-mediatek/2017-October/010827.html and try to change the regulator in last line.
boot-4.4_sd_debug.log (82 KB) it looks like now there is no init with events:
[ 1.491596] mtk-msdc 11240000.mmc: Got CD GPIO
[ 1.496432] mtk-msdc 11240000.mmc: init hardware done!
[ 1.525380] mtk-msdc 11240000.mmc: Bus Width = 0
[ 1.529967] mtk-msdc 11240000.mmc: init hardware done!
[ 1.564729] mtk-msdc 11240000.mmc: Bus Width = 0
[ 1.574999] mtk-msdc 11240000.mmc: sclk: 399999, timing: 0
[ 1.635422] mtk-msdc 11240000.mmc: Bus Width = 0
[ 1.663539] mtk-msdc 11240000.mmc: set mclk to 0
also tried compatible-string with 2701 with same result
# cat /sys/devices/platform/11240000.mmc/of_node/status
okay#
# cat /sys/devices/platform/11240000.mmc/of_node/compatible
mediatek,mt2701-mmc#
# cat /sys/devices/platform/11240000.mmc/of_node/bus-width | hexdump
0000000 0000 0400
0000004
4.14-mmc2.patch (6,4 KB)
(patch for 4.14-final)
config used: mt7623n_evb_ryderlee_defconfig.txt (4,9 KB)
touched files: mt7623n-bananapi-bpi-r2.dts (9,2 KB) mt7623.dtsi (20,7 KB) mtk-sd.c (55,3 KB)
my build-script: build.sh (1,4 KB)
Could you provide 4.14 full debug log? Did you detect SD card with those change?
sd not working yet. How to make full debug-log?
CONFIG_DYNAMIC_DEBUG=y
To enable dev_dbg messages in a specific kernel file:
#define DEBUG
i have dynamic_debug enabled and #define DEBUG in mtk-sd.c…any other options (#define debug in another file)?
maybe debug-log is somewhere in Filesystem? i uploaded the bootlog from minicom…
try to add “ccflags-y :=-DDEBUG” in makefile or CONFIG_CMDLINE=“loglevel=8”
added the “ccflags-y :=-DDEBUG” to drivers/mmc/Makefile (main makefile is very big…where is the right section?) and the loglevel:
# cat /proc/cmdline
earlyprintk console=ttyS0,115200 vmalloc=496M debug=7 loglevel=8 no_console_suspend
but still no more messages for the SD-Card:
# grep '1124' /var/log/messages
Jan 1 00:00:01 goodman48 user.info kernel: [ 1.491610] mtk-msdc 11240000.mmc: Got CD GPIO
Jan 1 00:00:01 goodman48 user.debug kernel: [ 1.496447] mtk-msdc 11240000.mmc: init hardware done!
Jan 1 00:00:01 goodman48 user.debug kernel: [ 1.525378] mtk-msdc 11240000.mmc: Bus Width = 0
Jan 1 00:00:01 goodman48 user.debug kernel: [ 1.529964] mtk-msdc 11240000.mmc: init hardware done!
Jan 1 00:00:01 goodman48 user.debug kernel: [ 1.564732] mtk-msdc 11240000.mmc: Bus Width = 0
Jan 1 00:00:01 goodman48 user.debug kernel: [ 1.575001] mtk-msdc 11240000.mmc: sclk: 399999, timing: 0
Jan 1 00:00:01 goodman48 user.debug kernel: [ 1.635413] mtk-msdc 11240000.mmc: Bus Width = 0
Jan 1 00:00:01 goodman48 user.debug kernel: [ 1.663529] mtk-msdc 11240000.mmc: set mclk to 0
4.14_debug.log (42,6 KB)
full debug (added -DDEBUG to main makefile, login is hidden behind serial interrupt-messages): boot-4.14_sd_debug.log.zip (92,8 KB)
related messages from full debug log:
[ 23.567048] mtk-msdc 11240000.mmc: no init pinctrl state
[ 23.572318] mediatek-mt2701-pinctrl 1000b000.pinctrl: request pin 107 (MSDC1_DAT0) for 11240000.mmc
[ 23.581318] mediatek-mt2701-pinctrl 1000b000.pinctrl: request pin 108 (MSDC1_DAT1) for 11240000.mmc
[ 23.590318] mediatek-mt2701-pinctrl 1000b000.pinctrl: request pin 109 (MSDC1_DAT2) for 11240000.mmc
[ 23.599317] mediatek-mt2701-pinctrl 1000b000.pinctrl: request pin 110 (MSDC1_DAT3) for 11240000.mmc
[ 23.608314] mediatek-mt2701-pinctrl 1000b000.pinctrl: request pin 105 (MSDC1_CMD) for 11240000.mmc
[ 23.617226] mediatek-mt2701-pinctrl 1000b000.pinctrl: request pin 106 (MSDC1_CLK) for 11240000.mmc
[ 23.626135] mediatek-mt2701-pinctrl 1000b000.pinctrl: request pin 29 (EINT7) for 11240000.mmc
[ 23.634615] mediatek-mt2701-pinctrl 1000b000.pinctrl: request pin 261 (MSDC1_INS) for 11240000.mmc
[ 23.643524] mtk-msdc 11240000.mmc: no sleep pinctrl state
[ 23.648879] mtk-msdc 11240000.mmc: no idle pinctrl state
[ 23.654164] OF: no dma-ranges found for node(/mmc@11240000)
[ 23.659694] mtk-msdc 11240000.mmc: device is not dma coherent
[ 23.665409] mtk-msdc 11240000.mmc: device is not behind an iommu
[ 23.671380] devices_kset: Moving 11240000.mmc to end of list
[ 23.677038] mtk-msdc 11240000.mmc: GPIO lookup for consumer cd
[ 23.682839] mtk-msdc 11240000.mmc: using device tree for GPIO lookup
[ 23.689155] of_get_named_gpiod_flags: parsed 'cd-gpios' property of node '/mmc@11240000[0]' - status (0)
[ 23.698581] mediatek-mt2701-pinctrl 1000b000.pinctrl: request pin 261 (MSDC1_INS) for 1000b000.pinctrl:493
[ 23.708188] mtk-msdc 11240000.mmc: Got CD GPIO
[ 23.712597] mtk-msdc 11240000.mmc: GPIO lookup for consumer wp
[ 23.718402] mtk-msdc 11240000.mmc: using device tree for GPIO lookup
[ 23.724720] of_get_named_gpiod_flags: can't parse 'wp-gpios' property of node '/mmc@11240000[0]'
[ 23.733449] of_get_named_gpiod_flags: can't parse 'wp-gpio' property of node '/mmc@11240000[0]'
[ 23.742078] mtk-msdc 11240000.mmc: using lookup tables for GPIO lookup
[ 23.748565] mtk-msdc 11240000.mmc: lookup for GPIO wp failed
[ 23.754225] mtk-msdc 11240000.mmc: Looking up vmmc-supply from device tree
[ 23.761070] debugfs: creating file '11240000.mmc-vmmc'
[ 23.766191] debugfs: creating file 'uA_load'
[ 23.770427] debugfs: creating file 'min_uV'
[ 23.774592] debugfs: creating file 'max_uV'
[ 23.778743] debugfs: creating file 'constraint_flags'
[ 23.783780] mtk-msdc 11240000.mmc: Looking up vqmmc-supply from device tree
[ 23.790707] debugfs: creating file '11240000.mmc-vqmmc'
[ 23.795908] debugfs: creating file 'uA_load'
[ 23.800144] debugfs: creating file 'min_uV'
[ 23.804308] debugfs: creating file 'max_uV'
[ 23.808457] debugfs: creating file 'constraint_flags'
[ 23.813490] OF: comparing source with source
[ 23.817735] OF: comparing hclk with source
[ 23.821794] OF: comparing hclk with hclk
[ 23.825709] OF: of_irq_parse_one: dev=/mmc@11240000, index=0
[ 23.831335] OF: parent=/interrupt-controller@10200100, intsize=3
[ 23.837392] OF: intspec=0
[ 23.840073] of_irq_parse_raw: /interrupt-controller@10200100:00000000,00000028,00000008
[ 23.848122] OF: of_irq_parse_raw: ipar=/interrupt-controller@10200100, size=3
[ 23.855212] OF: -> addrsize=2
[ 23.858238] OF: -> got it !
[ 23.861098] mtk-msdc 11240000.mmc: obtain a copy of previously claimed pinctrl
[ 23.868283] cma: cma_alloc(cma c11be77c, count 1, align 0)
[ 23.873785] mmc0: mmc_rescan_try_freq: trying to init card at 400000 Hz
[ 23.873795] cma: cma_alloc(): returned e0768820
[ 23.873818] cma: cma_alloc(cma c11be77c, count 4, align 2)
[ 23.873840] cma: cma_alloc(): returned e0768900
[ 23.873920] mtk-msdc 11240000.mmc: init hardware done!
[ 23.873971] device: 'mmc1': device_add
[ 23.873980] kobject: 'mmc_host' (def87280): kobject_add_internal: parent: '11240000.mmc', set: '(null)'
[ 23.873994] kobject: 'mmc1' (defd8810): kobject_add_internal: parent: 'mmc_host', set: 'devices'
[ 23.874041] PM: Adding info for No Bus:mmc1
[ 23.874048] kobject: 'mmc1' (defd8810): kobject_uevent_env
[ 23.874058] kobject: 'mmc1' (defd8810): fill_kobj_path: path = '/devices/platform/11240000.mmc/mmc_host/mmc1'
[ 23.874073] debugfs: creating file 'mmc1'
[ 23.874086] debugfs: creating file 'ios'
[ 23.874093] debugfs: creating file 'clock'
[ 23.874108] mmc1: clock 0Hz busmode 2 powermode 1 cs 0 Vdd 21 width 1 timing 0
[ 23.874114] mtk-msdc 11240000.mmc: Bus Width = 0
[ 23.874127] mtk-msdc 11240000.mmc: init hardware done!
[ 23.874155] mtk-msdc 11240000.mmc: mmc_regulator_set_vqmmc: found vmmc voltage range of 3300000-3400000uV
lines 19029-19096 from above Logfile, after that here are dropped lines and much messages of creating files in debugfs with names clk_*, repeating from 19101-21093
maybe the “wp-gpio”-messages are the Problem?
below log is some successful log i have. but i also have found it can’t be detected at boot time. the log is shown when i replug for several times in the card after the boot.
[ 44.153800] mtk-msdc 11240000.mmc: msdc_irq: events=00002140
[ 44.159440] mtk-msdc 11240000.mmc: Bus Width = 2
[ 44.164035] mmc1: new high speed SDHC card at address aaaa
[ 44.170007] mmcblk1: mmc1:aaaa SC16G 14.8 GiB
[ 44.174986] mtk-msdc 11240000.mmc: msdc_irq: events=00002140
[ 44.180639] mtk-msdc 11240000.mmc: msdc_irq: events=00002140
[ 44.186264] mtk-msdc 11240000.mmc: DMA start
[ 44.190499] mtk-msdc 11240000.mmc: msdc_start_data: cmd=18 DMA data: 8 blocks; read=1
[ 44.198265] mtk-msdc 11240000.mmc: msdc_irq: events=00003040
[ 44.203877] mtk-msdc 11240000.mmc: DMA status: 0x 6
[ 44.209230] mtk-msdc 11240000.mmc: DMA stop
[ 44.213468] mmcblk1: p1
[ 44.216584] mtk-msdc 11240000.mmc: msdc_irq: events=00002140
[ 44.428169] mtk-msdc 11240000.mmc: msdc_irq: events=00002140
[ 44.638158] mtk-msdc 11240000.mmc: msdc_irq: events=00002140
i see that system recognize the removal of SD-Card, but not the re-inserting
14.4.-reenter.log (24,7 KB)
Hi, Frank
Good news, I should have solved the problems.
it is a polarity problem that pin for card detected should be used as LOW ACTIVE instead of HIGH ACTIVE. it worked for me. you can follow below steps to see whether it worked for you.
please apply all patches https://patchwork.ozlabs.org/cover/823758/ you should have done as your previous replied
in mt7623.dtsi
mmc0: mmc@11230000 {
compatible = "mediatek,mt7623-mmc",
"mediatek,mt2701-mmc"; ==> fall back to mt2701 instead mt8135
reg = <0 0x11230000 0 0x1000>;
interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_LOW>;
clocks = <&pericfg CLK_PERI_MSDC30_0>,
<&topckgen CLK_TOP_MSDC30_0_SEL>;
clock-names = "source", "hclk";
status = "disabled";
};
mmc1: mmc@11240000 {
compatible = "mediatek,mt7623-mmc",
"mediatek,mt2701-mmc";==> fall back to mt2701 instead mt8135
reg = <0 0x11240000 0 0x1000>;
interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_LOW>;
clocks = <&pericfg CLK_PERI_MSDC30_1>,
<&topckgen CLK_TOP_MSDC30_1_SEL>;
clock-names = "source", "hclk";
status = "disabled";
};
in mt7623n-bananapi-bpi-r2.dts
&mmc1 {
pinctrl-names = "default", "state_uhs";
pinctrl-0 = <&mmc1_pins_default>;
pinctrl-1 = <&mmc1_pins_uhs>;
status = "okay";
bus-width = <4>;
max-frequency = <50000000>;
cap-sd-highspeed;
cd-gpios = <&pio 261 1>; ==> used as GPIO_ACTIVE_LOW, which is very critical setup
vmmc-supply = <&mt6323_vmch_reg>;
vqmmc-supply = <&mt6323_vmc_reg>;
};
thank you for this, info, i’ll test it when i’m at home
strange…in 4.4.70 it is also 0 (should not work, but there it does)
&mmc1 {
pinctrl-names = "default", "state_uhs";
pinctrl-0 = <&mmc1_pins_default>;
pinctrl-1 = <&mmc1_pins_uhs>;
status = "okay";
bus-width = <4>;
max-frequency = <50000000>;
cap-sd-highspeed;
cd-gpios = <&pio 261 0>; <<<<<<<<
/*
wp-gpios = <&pio 29 0>;
*/
vmmc-supply = <&mt6323_vmch_reg>;
vqmmc-supply = <&mt6323_vmc_reg>;
};
After reviewing more on the 4.4 driver, i found the mtk-sd.c in 4.4 doesn’t have get_cd callback but it does in upstream kernel and thus 4.4 always bypasses the sanity check if card is present and upstream we MUST assign the exact what the core is expected to.
in drivers/mmc/core/core.c will check if get_cd is available.
if (mmc_card_is_removable(host) && host->ops->get_cd &&
host->ops->get_cd(host) == 0) {
mmc_power_off(host);
mmc_release_host(host);
goto out;
}
wow, MMC1 is detected on boot:
[ 2.584326] mmc0: new high speed MMC card at address 0001
[ 2.594712] mmc1: new high speed SDHC card at address 0001
[ 2.600445] mmcblk0: mmc0:0001 8WPD3R 7.28 GiB
[ 2.605110] mmcblk1: mmc1:0001 00000 7.61 GiB <<<<<<<<<<
[ 2.609766] mmcblk0boot0: mmc0:0001 8WPD3R partition 1 4.00 MiB
[ 2.616032] mmcblk0boot1: mmc0:0001 8WPD3R partition 2 4.00 MiB
[ 2.660531] mmcblk1: p1 p2 <<<<<<<<<<<<<<<
thank you very much, linkerosa
i have not patched any more files, only step 2&3 (have patched used my patch above: 4.14-mmc2.patch)
4.14-mmc2.patch (6,4 KB)
have you an idea, why gpio not available (file mt_gpio in 4.4.70)?
# ls /sys/devices/platform/1000b000.pinctrl/
driver/ gpiochip0/ of_node/ subsystem/
driver_override modalias power/ uevent
maybe it’s another filename…
source seems to be here (4.4.70): drivers/pinctrl/mediatek/pinctrl-mtk-common.c
maybe this is relevant:
and
added pinctrl-mtk-mt7623.h and pinctrl-mt7623.c to drivers/pinctrl/mediatek/, changed Makefile and Kconfig, build (was selected automaticly in menuconfig), but it’s not enough
Congratulations. as I knew the situation for mediatek gpio in upstream driver, the gpio is bound with the pinctrl and it has been exported into /sys/class/gpio/… through gpiolib and also you must enable CONFIG_GPIO_SYSFS in your config. file.
for example. to test gpio 206 through /sys interface
step1. To know what the base gpio expects to
# cat /sys/kernel/debug/pinctrl/1000b000.pinctrl/gpio-ranges
GPIO ranges handled:
0: 1000b000.pinctrl GPIOS [232 - 511] PINS [0 - 279]
okay. the base is 232.
step 2. rebase for gpio 206. followlingly we will operate on the result got from 206 + 232 the base we got in the previous step.
echo 438 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio438/direction
echo 1 > /sys/class/gpio/gpio438/value
echo 0 > /sys/class/gpio/gpio438/value
I don’t test every pin exported, but the pin 206 with previous steps seems working well through measuring the voltage on the pin
I try that,thank you again. How about “special gpios” which needs register-change in 4.4.70 https://github.com/BPI-SINOVOIP/BPI-R2-bsp/issues/11#issuecomment-326988062
Same in 4.14?
Then i only need the internal wlan-card,where driver is testing in 4.4…
@Ryder.Lee can you make a pull-request to mainline-repo for sd-patch?
I have a lot on my plate, could you help to send a pull-request?
Hi, Frank
the dedicated operation on special gpios should be not required based on below code snippet is ready, which would be done when pimux setup involved such gpio request from userspace or kernel space or driver initial pinctrl setup, but I don’t verify it on my board. You could have a try with upstream kernel.
drivers/pinctrl/mediatek/pinctrl-mt2701.c
static void mt2701_spec_pinmux_set(struct regmap *reg, unsigned int pin,
unsigned int mode)
{
unsigned int i, value, mask;
unsigned int info_num = ARRAY_SIZE(mt2701_spec_pinmux);
unsigned int spec_flag;
for (i = 0; i < info_num; i++) {
if (pin == mt2701_spec_pinmux[i].pin)
break;
}
if (i == info_num)
return;
spec_flag = (mode >> 3);
mask = BIT(mt2701_spec_pinmux[i].bit);
if (!spec_flag)
value = mask;
else
value = 0;
regmap_update_bits(reg, mt2701_spec_pinmux[i].offset, mask, value);
}
which would be called on mtk_pmx_set_mode()
seems that GPIO_SYSFS is not enough:
# cat /sys/kernel/debug/pinctrl/1000b000.pinctrl/gpio-ranges
cat: can't open '/sys/kernel/debug/pinctrl/1000b000.pinctrl/gpio-ranges': No such file or directory
# ls /sys/kernel/
config kexec_crash_loaded rcu_expedited uevent_seqnum
debug kexec_crash_size rcu_normal vmcoreinfo
fscaps kexec_loaded slab
iommu_groups mm tracing
irq notes uevent_helper
# ls /sys/kernel/debug/
#
frank@Frank-Laptop:/media/data_ext/kernel_4.14/linux$ grep 'GPIO\|PINCTRL' .config
CONFIG_ARCH_NR_GPIO=0
# CONFIG_MDIO_BUS_MUX_GPIO is not set
# CONFIG_KEYBOARD_GPIO is not set
# CONFIG_KEYBOARD_GPIO_POLLED is not set
# CONFIG_MOUSE_GPIO is not set
# CONFIG_SERIO_GPIO_PS2 is not set
# CONFIG_I2C_CBUS_GPIO is not set
# CONFIG_I2C_GPIO is not set
CONFIG_PINCTRL=y
# CONFIG_DEBUG_PINCTRL is not set
# CONFIG_PINCTRL_AMD is not set
# CONFIG_PINCTRL_MCP23S08 is not set
# CONFIG_PINCTRL_SINGLE is not set
# CONFIG_PINCTRL_SX150X is not set
CONFIG_PINCTRL_MTK=y
CONFIG_PINCTRL_MT2701=y
# CONFIG_PINCTRL_MT6397 is not set
CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
CONFIG_GPIOLIB=y
CONFIG_OF_GPIO=y
# CONFIG_DEBUG_GPIO is not set
CONFIG_GPIO_SYSFS=y
# Memory mapped GPIO drivers
# CONFIG_GPIO_74XX_MMIO is not set
# CONFIG_GPIO_ALTERA is not set
# CONFIG_GPIO_DWAPB is not set
# CONFIG_GPIO_EXAR is not set
# CONFIG_GPIO_FTGPIO010 is not set
# CONFIG_GPIO_GENERIC_PLATFORM is not set
# CONFIG_GPIO_GRGPIO is not set
# CONFIG_GPIO_MOCKUP is not set
# CONFIG_GPIO_MPC8XXX is not set
# CONFIG_GPIO_SYSCON is not set
# CONFIG_GPIO_XILINX is not set
# CONFIG_GPIO_ZEVIO is not set
# I2C GPIO expanders
# CONFIG_GPIO_ADP5588 is not set
# CONFIG_GPIO_ADNP is not set
# CONFIG_GPIO_MAX7300 is not set
# CONFIG_GPIO_MAX732X is not set
# CONFIG_GPIO_PCA953X is not set
# CONFIG_GPIO_PCF857X is not set
# CONFIG_GPIO_SX150X is not set
# CONFIG_GPIO_TPIC2810 is not set
# MFD GPIO expanders
# CONFIG_HTC_EGPIO is not set
# PCI GPIO expanders
# CONFIG_GPIO_BT8XX is not set
# CONFIG_GPIO_PCI_IDIO_16 is not set
# CONFIG_GPIO_RDC321X is not set
# USB GPIO expanders
# CONFIG_GPIO_WATCHDOG is not set
# CONFIG_REGULATOR_GPIO is not set
# CONFIG_IR_GPIO_CIR is not set
CONFIG_USB_GPIO_VBUS=y
CONFIG_LEDS_GPIO=y
# CONFIG_LEDS_TRIGGER_GPIO is not set
# CONFIG_EXTCON_GPIO is not set
# CONFIG_EXTCON_USB_GPIO is not set
CONFIG_TRACING_EVENTS_GPIO=y
as your path is /sys/kernel/debug, i assume that CONFIG_DEBUG_GPIO must be also enabled, right? => is also not enough
The entry should be added when CONFIG_DEBUG_FS is enabled