#484 [X200*/T400/T500] SATA power in ultrabay is not handled

Open
opened 2 years ago by swiftgeek · 1 comments

TODO: MLB3I-* testpoints (VCC5MUBAY and BAY_MEDIA_EJECT)
X200* is fused and doesn't have battery option, but testpoints aren't available easily so not probed yet (Probe VCC5MUBAY_DRV, BAY_MEDIA_EJECT, BAY_ATTACH directly on dock connector)


BAY_ATTACH - pulled up with VCC3M so it's not depending VCC5MUBAY rail being turned on to detect SATA device being plugged in. Provides reliable indication of device presence - it's the last connection being made.
EC control path: ULTRA_ON -> VCC5MUBAY_DRV (rinkan) switches FET, shorting VCC5MUBAY to VCC5M (no fuse, 40W...)

DP – Device Present – Active low signal indicating device connect to the host. The device shall connect the DP pin to ground with a resistance of 1K ohms and a maximum tolerance of ± 10% ohms.


BAY_MEDIA_EJECT - Eject button triggered (from ODD), normally high (3v3), breaks SATA specification (Only available on ThinkPads)
TODO: Waveform capture

MD – Manufacturing Diagnostic – Signal pin used by device vendors during device testing. No host connection is allowed, device connection is optional.

SATA 3.1 introduced alt function on this pin - Device Attention - which matches scheme used by lenovo.


BAY_UNLOCK - UltraBay lever actuated, but not reliable for detecting device insertion! Use BAY_ATTACH signal for SATA power, so it won't lose power due to not latching in lever properly. Distance of error is last 3mm.

Provided by detector switch located on 44C4062 board in case of T400 and 42W7851 on T500
On X200 named BAY_EJECT


UltraBay battery would also need to be checked. Charging and discharging should be disabled on it when detaching (what signal) and on boot (when not attached). When detaching it should switch to main battery

S_TEMP could be used to detect battery existence (Pulled to VCC3M)


Bonus points for safe unmounting of device (UltraBay can contain HDD)


UltraBay battery should also react to interlock (lever)

TODO: MLB3I-* testpoints (`VCC5MUBAY` and `BAY_MEDIA_EJECT`) X200* is fused and doesn't have battery option, but testpoints aren't available easily so not probed yet (Probe `VCC5MUBAY_DRV`, `BAY_MEDIA_EJECT`, `BAY_ATTACH` directly on dock connector) --------- `BAY_ATTACH` - pulled up with `VCC3M` so it's not depending `VCC5MUBAY` rail being turned on to detect SATA device being plugged in. Provides reliable indication of device presence - it's the last connection being made. EC control path: `ULTRA_ON` -> `VCC5MUBAY_DRV` (rinkan) switches FET, shorting `VCC5MUBAY` to `VCC5M` (no fuse, 40W...) >DP – Device Present – Active low signal indicating device connect to the host. The device shall connect the DP pin to ground with a resistance of 1K ohms and a maximum tolerance of ± 10% ohms. -------- `BAY_MEDIA_EJECT` - Eject button triggered (from ODD), normally high (3v3), breaks SATA specification (Only available on ThinkPads) TODO: Waveform capture >MD – Manufacturing Diagnostic – Signal pin used by device vendors during device testing. **No host connection is allowed**, device connection is optional. SATA 3.1 introduced alt function on this pin - Device Attention - which matches scheme used by lenovo. -------- `BAY_UNLOCK` - UltraBay lever actuated, but **not reliable** for detecting device insertion! Use `BAY_ATTACH` signal for SATA power, so it won't lose power due to not latching in lever properly. Distance of error is last 3mm. Provided by detector switch located on *44C4062* board in case of T400 and *42W7851* on T500 On X200 named `BAY_EJECT` -------- UltraBay battery would also need to be checked. Charging and discharging should be disabled on it when detaching (what signal) and on boot (when not attached). When detaching it should switch to main battery `S_TEMP` could be used to detect battery existence (Pulled to `VCC3M`) -------- Bonus points for safe unmounting of device (UltraBay can contain HDD) -------- UltraBay battery should also react to interlock (lever)
Swift Geek commented 8 months ago
Collaborator

This comment pointed me in right direction

CONFIG_ACPI_DOCK (dock module)

sysfs interface

immediate_undock: 1 (default) will cause the driver to undock immediately when the undock button is pressed, 0 will cause the driver to wait for userspace to write the undock sysfs file before undocking

When module is compiled in, this can be passed as dock.immediate_undock=0 in kernel cmdline


On undock button event with udevadm monitor -pu we can see

UDEV  [95430.785730] change   /devices/platform/dock.0 (platform)
ACTION=change
DEVPATH=/devices/platform/dock.0
SUBSYSTEM=platform
EVENT=undock
MODALIAS=acpi:ACPI0003:LNXDOCK:
SEQNUM=7376
USEC_INITIALIZED=9249855
ID_PATH=platform-dock.0
ID_PATH_TAG=platform-dock_0

This has to be handled by userspace application somehow and notify user when it can't write to /sys/devices/platform/dock.0/undock automatically

This would need to be handled only by physically logged in user which means logind


[T/R/W]60/400/500, Z61* case:

  • Advanced Dock contains Ultrabay which means the dock contains a dock
  • Main body of notebook contains Ultrabay of its own (so a dock)
  • Advanced Mini Dock doesn't contain a dock of its own
  • Advanced (Mini) Dock cannot be powered from a battery (documentation is missing there, so maybe that's just vendor behavior)

X60/X200 case:

  • Ultrabase can be powered from battery on while AC adapter is disconnected. Loss of power is NOT a "surprise removal"
  • Ultrabase contains Ultrabay (so again a dock containing a dock)
  • Ultrabase is the only commercially available dock for device

NOTE: UltraBay, when capable of accepting ultrabay battery, counts as two docks: one for battery and one for *ATA device.


Fedora on vendor fw, Mocha-1 (plain x200)

Dummy? X60 leftover?

# cat /sys/devices/platform/dock.0/firmware_node/path
\_SB_.PCI0.LPC_.EC__.BAT1

Ultrabay:

# cat /sys/devices/platform/dock.1/firmware_node/path
\_SB_.PCI0.SATA.PRT1

Ultrabase:

# cat /sys/devices/platform/dock.2/firmware_node/path
\_SB_.GDCK

Undock event of ultrabase (side button):

UDEV  [3039.105421] change   /devices/platform/dock.2 (platform)
ACTION=change
DEVPATH=/devices/platform/dock.2
EVENT=undock
ID_VENDOR_FROM_DATABASE=IBM Brasil
MODALIAS=acpi:IBM0079:PNP0C15:LNXDOCK:
SEQNUM=3512
SUBSYSTEM=platform
USEC_INITIALIZED=14681694

Notes:

  • Ultrabay lever issues undock event. Ultrabase does not (bug).
  • Ultrabase issues undock on side button, which makes green arrow indicator blink, left of the undock button.
  • Fn+F9 doesn't cause anything (bug)
  • Docking of ultrabay of ultrabase seems to be broken on vendor+linux, it only works with entire ultrabase being docked (bug). Doesn't appear to be the issue on windows, but there the undocking of ultrabay does not work.
  • Undock event doesn't cause any blinking on ultrabay LED (inconsistency, lack of user notification, bug)
  • Removing power does NOT cause any undocking event!

/sys/devices/platform/dock.N/flags doesn't appear to be documented anywhere, so from dock.c code, u32 flags:

bit 0     - DOCK_DOCKING
bit 1     - DOCK_UNDOCKING
bit[3:2]  - reserved
bit 4     - DOCK_IS_DOCK
bit 5     - DOCK_IS_ATA
bit 6     - DOCK_IS_BAT
bit[31:7] - reserved

/sys/devices/platform/dock.N/flags value is decimal

Userspace should use /sys/devices/platform/dock.N/{flags,type,docked} to determine action to take (including notifying user)

[This comment pointed me in right direction](https://review.coreboot.org/c/coreboot/+/38681/3#message-1ebe809302111f4aa0862b3debcded7388e1de35) [CONFIG_ACPI_DOCK (dock module)](https://cateee.net/lkddb/web-lkddb/ACPI_DOCK.html) [sysfs interface](https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-devices-platform-dock) > immediate_undock: 1 (default) will cause the driver to undock immediately when the undock button is pressed, 0 will cause the driver to wait for userspace to write the undock sysfs file before undocking When module is compiled in, this can be passed as `dock.immediate_undock=0` in kernel cmdline ------- On undock button event with `udevadm monitor -pu` we can see UDEV [95430.785730] change /devices/platform/dock.0 (platform) ACTION=change DEVPATH=/devices/platform/dock.0 SUBSYSTEM=platform EVENT=undock MODALIAS=acpi:ACPI0003:LNXDOCK: SEQNUM=7376 USEC_INITIALIZED=9249855 ID_PATH=platform-dock.0 ID_PATH_TAG=platform-dock_0 This has to be handled by userspace application somehow and notify user when it can't write to `/sys/devices/platform/dock.0/undock` automatically This would need to be handled only by physically logged in user which means `logind` -------------- [T/R/W]60/400/500, Z61* case: * Advanced Dock contains Ultrabay which means the dock contains a dock * Main body of notebook contains Ultrabay of its own (so a dock) * Advanced Mini Dock doesn't contain a dock of its own * Advanced (Mini) Dock cannot be powered from a battery (documentation is missing there, so maybe that's just vendor behavior) X60/X200 case: * Ultrabase can be powered from battery on while AC adapter is disconnected. Loss of power is **NOT** a "surprise removal" * Ultrabase contains Ultrabay (so again a dock containing a dock) * Ultrabase is the only commercially available dock for device *NOTE: UltraBay, when capable of accepting ultrabay battery, counts as two docks: one for battery and one for \*ATA device.* -------- Fedora on vendor fw, Mocha-1 (plain x200) Dummy? X60 leftover? # cat /sys/devices/platform/dock.0/firmware_node/path \_SB_.PCI0.LPC_.EC__.BAT1 Ultrabay: # cat /sys/devices/platform/dock.1/firmware_node/path \_SB_.PCI0.SATA.PRT1 Ultrabase: # cat /sys/devices/platform/dock.2/firmware_node/path \_SB_.GDCK Undock event of ultrabase (side button): UDEV [3039.105421] change /devices/platform/dock.2 (platform) ACTION=change DEVPATH=/devices/platform/dock.2 EVENT=undock ID_VENDOR_FROM_DATABASE=IBM Brasil MODALIAS=acpi:IBM0079:PNP0C15:LNXDOCK: SEQNUM=3512 SUBSYSTEM=platform USEC_INITIALIZED=14681694 Notes: * Ultrabay lever issues undock event. Ultrabase does not (bug). * Ultrabase issues undock on side button, which makes green arrow indicator blink, left of the undock button. * Fn+F9 doesn't cause anything (bug) * Docking of ultrabay of ultrabase seems to be broken on vendor+linux, it only works with entire ultrabase being docked (bug). Doesn't appear to be the issue on windows, but there the undocking of ultrabay does not work. * Undock event doesn't cause any blinking on ultrabay LED (inconsistency, lack of user notification, bug) * Removing power does **NOT** cause any undocking event! --------- `/sys/devices/platform/dock.N/flags` doesn't appear to be documented anywhere, so from [dock.c code, u32 flags](https://github.com/torvalds/linux/blob/master/drivers/acpi/dock.c): ``` bit 0 - DOCK_DOCKING bit 1 - DOCK_UNDOCKING bit[3:2] - reserved bit 4 - DOCK_IS_DOCK bit 5 - DOCK_IS_ATA bit 6 - DOCK_IS_BAT bit[31:7] - reserved ``` `/sys/devices/platform/dock.N/flags` value is decimal Userspace should use /sys/devices/platform/dock.N/{flags,type,docked} to determine action to take (including notifying user)
Sign in to join this conversation.
Loading...
Cancel
Save
There is no content yet.