Letux Kernel

Issue 698: pyra-cpu: we need a driver for the TXS02612 SDIO switch

Reported by Nikolaus Schaller, Aug 20, 2015

the Pyra CPU has a digital switch to connect either the µSD or the 
eMMC to the eMMC interface of the OMAP5.
It can be either switched by a button (GPIO1_WK7 if GPIO3_82 is in 
High-Z mode, e.g. input) or by GPIO3_82 if in output mode.
The driver should add two new mmc interfaces and take care of 
switching between interfaces at the right moments (i.e. idle).
Optimally, this is fully transparent, i.e. we simply get two 
additional MMC interfaces for one and both can be used to mount SD 
cards/eMMC. Parallel access is possible and must be time-sliced.
Suboptimally we need to "eject" one and the other gets an 
"insert" event.
One thing to consider s that the µSD interface is 4 bit only while 
the eMMC is 8 bit (and the upper 4 bits are not multiplexed).

Comment 1 by Nikolaus Schaller, Sep 10, 2015

Basically we should design a DT node like

/ {
	mc-expander {
		compatible = “ti,txs02612”;
		mmc = <&mmc1>;
		select-gpio = <&gpio3 18 0>;	/* GPIO3_82 */
		ports {
			eMMC: port@0 {
				reg = <0>;
				bus-width: 8;
			};
			usd: port@1 {
				bus-width: 4;
				reg = <1>;
			};
	};
};

The driver should register itself as a client (like a wifi driver)
with mmc1 and register two new mmc interfaces.

Comment 2 by Nikolaus Schaller, Sep 10, 2015

Another note: we do not need to handle SDIO (interrupt) capabilities.

Comment 3 by Nikolaus Schaller, Mar 21, 2016

GPIOs have been reassigned because the original logic did not work 
as intended right after power-on.

We now have 3 GPIOs:

hardware-select to GND (auto-pull-up): gpio1_wk7
software-select: gpio2_32 (on V5 boards - gpio3_82 on V5.1)
control (0=hw 1=sw): gpio2_33 (on V5 boards - gpio3_76 on V5.1)

Please never switch gpio3_82 to output on V5.0 boards (will drive 
into selector chip).

This logic is available in current U-Boot but not yet in DT:

http://git.goldelico.com/?p=gta04-uboot.git;a=blobdiff;f=board/goldel
ico/letux-cortex15/lc15.c;h=faa1a09373708d2427dcb1fb33973a72f6f260f7;
hp=764979c740814821e9d47ab57252ecae9f460024;hb=0e8782de53dce2e18c0994
2bc7b2b3cba721a968;hpb=1b793b5449461d9fce930b3a089235eb1da6781e

Comment 4 by Nikolaus Schaller, Mar 22, 2016

Please note that we just have to control a single gpio (gpio2_33 or 
gpio3_82) by the Linux driver.

The other one (choosing between hardware and software selection) has 
already been handled by U-Boot!

This matches the fact that the txs only has one control input. The 
confusion is only specific to the Pyra board.

Comment 5 by Nikolaus Schaller, Mar 22, 2016

Test in U-Boot:

Preparation: boot and break into U-Boot

=> mmc dev 1
=> mmc rescan
=> mmcinfo
Device: OMAP SD/MMC
Manufacturer ID: 90
OEM: 14a
Name: H4G2a
Tran Speed: 52000000
Rd Block Len: 512
MMC version 4.5
High Capacity: Yes
Capacity: 3.6 GiB
Bus Width: 8-bit  <--- this is eMMC
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 3.6 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH
=> gpio set 32  
gpio: pin 32 (gpio 32) value is 1
=> mmc rescan
=> mmc info
Device: OMAP SD/MMC
Manufacturer ID: 1e
OEM: 4142
Name: USD
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 3.8 GiB
Bus Width: 4-bit  <--- this is the uSD
Erase Group Size: 512 Bytes
=>

Comment 6 by Nikolaus Schaller, Apr 14, 2017

A primitive driver with /sys interface is now available. It just 
allows to read the switch state or toggle the switch.

Note: this is not synchronized with MMC activities so it is like 
unplugging one card in the middle of a read/write operation and 
plugging in a different device. This may lead to data loss if there 
is no sync&umount done before.

Nevertheless, the kernel MMC stack detects this and umounts the 
device automatically. And since we have enabled the broken-CD 
property, the MMC driver polls for device changes , the new one is 
recognized automatically. Depending on installed user-space software 
the new device is mounted and shown on the desktop.
Status: Started

Comment 7 by James Stratton, Oct 17, 2019

This digital kind of newspaper “White Bear Press” is absolutely a 
definition of new World with an extent to opportunities and now I 
can easily visit https://edubirdie.org/ to complete the task. I 
really like this E-Edition and it is my best 2018’s experience to 
get this so thanks for it.

Created: 9 years 1 month ago by Nikolaus Schaller

Updated: 4 years 11 months ago

Status: Started

Followed by: 1 person

Labels:
Type:Defect
Priority:Critical
Device:Pyra