summaryrefslogtreecommitdiff
path: root/drivers/misc/cardreader/rtsx_usb.c
diff options
context:
space:
mode:
authorRicky Wu <ricky_wu@realtek.com>2025-08-12 06:08:11 +0300
committerUlf Hansson <ulf.hansson@linaro.org>2025-08-19 15:34:15 +0300
commitd2e6fb2c31a07f34e5e7533df11431cb0d2ecf9f (patch)
tree13c965d7ec7d8c7efcd02b229d6e17569399a6e6 /drivers/misc/cardreader/rtsx_usb.c
parentb65e630a55a490a0269ab1e4a282af975848064c (diff)
downloadlinux-d2e6fb2c31a07f34e5e7533df11431cb0d2ecf9f.tar.xz
misc: rtsx: usb card reader: add OCP support
This patch adds support for Over Current Protection (OCP) to the Realtek USB card reader driver. The OCP mechanism protects the hardware by detecting and handling current overload conditions. This implementation includes: - Register configurations to enable OCP monitoring. - Handling of OCP interrupt events and associated error reporting. - Card power management changes in response to OCP triggers. This enhancement improves the robustness of the driver when operating in environments where electrical anomalies may occur, particularly with SD and MS card interfaces. Signed-off-by: Ricky Wu <ricky_wu@realtek.com> Link: https://lore.kernel.org/r/20250812030811.2426112-1-ricky_wu@realtek.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/misc/cardreader/rtsx_usb.c')
-rw-r--r--drivers/misc/cardreader/rtsx_usb.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/rtsx_usb.c
index d007a4455ce5..1830e9ed2521 100644
--- a/drivers/misc/cardreader/rtsx_usb.c
+++ b/drivers/misc/cardreader/rtsx_usb.c
@@ -552,6 +552,10 @@ static int rtsx_usb_reset_chip(struct rtsx_ucr *ucr)
ret = rtsx_usb_send_cmd(ucr, MODE_C, 100);
if (ret)
return ret;
+ /* config OCP */
+ rtsx_usb_write_register(ucr, OCPCTL, MS_OCP_DETECT_EN, MS_OCP_DETECT_EN);
+ rtsx_usb_write_register(ucr, OCPPARA1, 0xF0, 0x50);
+ rtsx_usb_write_register(ucr, OCPPARA2, 0x7, 0x3);
/* config non-crystal mode */
rtsx_usb_read_register(ucr, CFG_MODE, &val);
@@ -722,6 +726,9 @@ static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message)
if (val & (SD_CD | MS_CD)) {
device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child);
return -EAGAIN;
+ } else {
+ /* if the card does not exists, clear OCP status */
+ rtsx_usb_write_register(ucr, OCPCTL, MS_OCP_CLEAR, MS_OCP_CLEAR);
}
} else {
/* There is an ongoing operation*/