// SPDX-License-Identifier: GPL-2.0-only /* * Linux LED driver for RTL8187 * * Copyright 2009 Larry Finger <Larry.Finger@lwfinger.net> * * Based on the LED handling in the r8187 driver, which is: * Copyright (c) Realtek Semiconductor Corp. All rights reserved. * * Thanks to Realtek for their support!
*/
staticvoid led_turn_on(struct work_struct *work)
{ /* As this routine does read/write operations on the hardware, it must * be run from a work queue.
*/
u8 reg; struct rtl8187_priv *priv = container_of(work, struct rtl8187_priv,
led_on.work); struct rtl8187_led *led = &priv->led_tx;
/* Don't change the LED, when the device is down. */ if (!priv->vif || priv->vif->type == NL80211_IFTYPE_UNSPECIFIED) return ;
/* Skip if the LED is not registered. */ if (!led->dev) return;
mutex_lock(&priv->conf_mutex); switch (led->ledpin) { case LED_PIN_GPIO0:
rtl818x_iowrite8(priv, &priv->map->GPIO0, 0x01);
rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x00); break; case LED_PIN_LED0:
reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) & ~(1 << 4);
rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); break; case LED_PIN_LED1:
reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) & ~(1 << 5);
rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); break; case LED_PIN_HW: default: break;
}
mutex_unlock(&priv->conf_mutex);
}
staticvoid led_turn_off(struct work_struct *work)
{ /* As this routine does read/write operations on the hardware, it must * be run from a work queue.
*/
u8 reg; struct rtl8187_priv *priv = container_of(work, struct rtl8187_priv,
led_off.work); struct rtl8187_led *led = &priv->led_tx;
/* Don't change the LED, when the device is down. */ if (!priv->vif || priv->vif->type == NL80211_IFTYPE_UNSPECIFIED) return ;
/* Skip if the LED is not registered. */ if (!led->dev) return;
mutex_lock(&priv->conf_mutex); switch (led->ledpin) { case LED_PIN_GPIO0:
rtl818x_iowrite8(priv, &priv->map->GPIO0, 0x01);
rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, 0x01); break; case LED_PIN_LED0:
reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) | (1 << 4);
rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); break; case LED_PIN_LED1:
reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) | (1 << 5);
rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg); break; case LED_PIN_HW: default: break;
}
mutex_unlock(&priv->conf_mutex);
}
/* According to the vendor driver, the LED operation depends on the * customer ID encoded in the EEPROM
*/
printk(KERN_INFO "rtl8187: Customer ID is 0x%02X\n", custid); switch (custid) { case EEPROM_CID_RSVD0: case EEPROM_CID_RSVD1: case EEPROM_CID_SERCOMM_PS: case EEPROM_CID_QMI: case EEPROM_CID_DELL: case EEPROM_CID_TOSHIBA:
ledpin = LED_PIN_GPIO0; break; case EEPROM_CID_ALPHA0:
ledpin = LED_PIN_LED0; break; case EEPROM_CID_HW:
ledpin = LED_PIN_HW; break; default:
ledpin = LED_PIN_GPIO0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.