x86: tangier: Enable support for SD/SDIO family in the pinmux driver
PATCH v2 1/2 x86: tangier: Enable support for SD/SDIO family in the pinmux driver
We would need to quirk out the Card Detect case and for that we allow configuring the SD/SDIO family of pins.
---
v2: added tag, promised to deduplicate the code in the future (Bin)
arch/x86/cpu/tangier/pinmux.c | 39 ++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-)
arch/x86/cpu/tangier/pinmux.c +34 -5
@@ -37,8 +37,9 @@ struct mrfld_family { .npins = (e) - (s) + 1, \ } -/* Now we only support I2C family of pins */ +/* Now we only support SD/SDIO and I2C families of pins */ static struct mrfld_family mrfld_families[] = { +MRFLD_FAMILY (3 ,37 ,56 ),MRFLD_FAMILY (7 ,101 ,114 ), };
@@ -125,6 +126,34 @@ static int mrfld_pinconfig_protected(unsigned int pin, u32 mask, u32 bits)return ret; } +static int mrfld_pinconfig (unsigned int pin,u32 mask,u32 bits) +{ +struct mrfld_pinctrl *pinctrl; +struct udevice *dev; +void __iomem *bufcfg; +u32 v, value; +int ret; + + ret =syscon_get_by_driver_data (X86_SYSCON_PINCONF , &dev); +if (ret) +return ret; + + pinctrl =dev_get_priv (dev); + + bufcfg =mrfld_get_bufcfg (pinctrl, pin); +if (!bufcfg) +return -EINVAL ; + + value =readl (bufcfg); + v = (value & ~mask) | (bits & mask); +writel (v, bufcfg); + +debug ("v: 0x%x p: 0x%x bits: %d, mask: %d bufcfg: 0x%p\n" , + v, (u32 )bufcfg, bits, mask, bufcfg); + +return 0 ; +} +static int mrfld_pinctrl_cfg_pin (ofnode pin_node) {bool is_protected;
@@ -133,10 +162,7 @@ static int mrfld_pinctrl_cfg_pin(ofnode pin_node)u32 mask;int ret; -/* For now we only support just protected Family of pins */ is_protected =ofnode_read_bool (pin_node,"protected" ); -if (!is_protected) -return -ENOTSUPP ; pad_offset =ofnode_read_s32_default (pin_node,"pad-offset" ,-1 );if (pad_offset ==-1 )
@@ -152,7 +178,10 @@ static int mrfld_pinctrl_cfg_pin(ofnode pin_node)if (mode & ~mask)return -ENOTSUPP ; - ret =mrfld_pinconfig_protected (pad_offset, mask, mode); +if (is_protected) + ret =mrfld_pinconfig_protected (pad_offset, mask, mode); +else + ret =mrfld_pinconfig (pad_offset, mask, mode);return ret; }
Signature · 1 line
2.33.0
PATCH v2 2/2 x86: edison: Don't take SD card detect pin into consideration
There are two PCB designs in the wild which use the opposite signaling for SD card detection. This makes U-Boot working in one case and failing in the other. Quirk this out by disconnecting SD card detection pin from the PCB by switching it to mode 3. In the disconnected state the read value is always the same and inverted to what we are expecting in the code.
---
v2: added tag, updated commit message and comments in DTS (Bin)
arch/x86/dts/edison.dts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
arch/x86/dts/edison.dts +17 -0
@@ -94,6 +94,12 @@ sdcard: mmc@ff3fa000 { compatible = "intel,sdhci-tangier"; reg = <0xff3fa000 0x1000>; + /* + * In the disconnected state of the SD Card Detection pin + * the read value is always the same and inverted to what + * we are expecting in the code. + */ + cd-inverted; }; pmu: power@ff00b000 {
@@ -131,6 +137,17 @@ compatible = "intel,pinctrl-tangier"; reg = <0xff0c0000 0x8000>; + /* + * Disconnect SD card detection pin, so it won't affect + * the reality on two different PCB designs where it's + * using the opposite signaling: Edison/Arduino uses + * Active Low, while SparkFun went with Active High. + */ + sd_cd@0 { + pad-offset = <37>; + mode-func = <3>; + }; + /* * Initial configuration came from the firmware. * Which quite likely has been used in the phones, where I2C #8,
Signature · 1 line
2.33.0
Re: [PATCH v2 2/2] x86: edison: Don't take SD card detect pin into consideration
Quoted 8 lines · Andy Shevchenko
There are two PCB designs in the wild which use the opposite signaling for SD card detection. This makes U-Boot working in one case and failing in the other. Quirk this out by disconnecting SD card detection pin from the PCB by switching it to mode 3. In the disconnected state the read value is always the same and inverted to what we are expecting in the code.
Quoted 8 lines
Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Bin Meng <[email protected]>---
v2: added tag, updated commit message and comments in DTS (Bin)arch/x86/dts/edison.dts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
applied to u-boot-x86, thanks!
Quoted 11 lines · Andy Shevchenko
We would need to quirk out the Card Detect case and for that we allow configuring the SD/SDIO family of pins.
Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Bin Meng <[email protected]>---
v2: added tag, promised to deduplicate the code in the future (Bin)arch/x86/cpu/tangier/pinmux.c | 39 ++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-)
applied to u-boot-x86, thanks!