diff options
author | Michael Grzeschik <m.grzeschik@pengutronix.de> | 2014-09-18 00:12:50 +0200 |
---|---|---|
committer | Michael Grzeschik <m.grzeschik@pengutronix.de> | 2015-10-26 09:10:56 +0100 |
commit | 8890624a4e8c2c7046d63bfd15d7331af9f55f10 (patch) | |
tree | c99553d5963e353f9375206f1654fcc920d2da1b /drivers/net/arcnet/com20020-pci.c | |
parent | 5ef216c1f84825c6942fdd6c24d12a08ac2df135 (diff) | |
download | linux-stable-8890624a4e8c2c7046d63bfd15d7331af9f55f10.tar.gz linux-stable-8890624a4e8c2c7046d63bfd15d7331af9f55f10.tar.bz2 linux-stable-8890624a4e8c2c7046d63bfd15d7331af9f55f10.zip |
arcnet: com20020-pci: add led trigger support
The EAE PLX-PCI card has special leds on the the main io pci resource
bar. This patch adds support to trigger the conflict and data leds with
the packages.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Diffstat (limited to 'drivers/net/arcnet/com20020-pci.c')
-rw-r--r-- | drivers/net/arcnet/com20020-pci.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c index 637a6110cec6..239de38fbd6a 100644 --- a/drivers/net/arcnet/com20020-pci.c +++ b/drivers/net/arcnet/com20020-pci.c @@ -41,6 +41,7 @@ #include <linux/pci.h> #include <linux/list.h> #include <linux/io.h> +#include <linux/leds.h> #include "arcdevice.h" #include "com20020.h" @@ -62,6 +63,36 @@ module_param(clockp, int, 0); module_param(clockm, int, 0); MODULE_LICENSE("GPL"); +static void led_tx_set(struct led_classdev *led_cdev, + enum led_brightness value) +{ + struct com20020_dev *card; + struct com20020_priv *priv; + struct com20020_pci_card_info *ci; + + card = container_of(led_cdev, struct com20020_dev, tx_led); + + priv = card->pci_priv; + ci = priv->ci; + + outb(!!value, priv->misc + ci->leds[card->index].green); +} + +static void led_recon_set(struct led_classdev *led_cdev, + enum led_brightness value) +{ + struct com20020_dev *card; + struct com20020_priv *priv; + struct com20020_pci_card_info *ci; + + card = container_of(led_cdev, struct com20020_dev, recon_led); + + priv = card->pci_priv; + ci = priv->ci; + + outb(!!value, priv->misc + ci->leds[card->index].red); +} + static void com20020pci_remove(struct pci_dev *pdev); static int com20020pci_probe(struct pci_dev *pdev, @@ -170,14 +201,41 @@ static int com20020pci_probe(struct pci_dev *pdev, card->index = i; card->pci_priv = priv; + card->tx_led.brightness_set = led_tx_set; + card->tx_led.default_trigger = devm_kasprintf(&pdev->dev, + GFP_KERNEL, "arc%d-%d-tx", + dev->dev_id, i); + card->tx_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, + "pci:green:tx:%d-%d", + dev->dev_id, i); + + card->tx_led.dev = &dev->dev; + card->recon_led.brightness_set = led_recon_set; + card->recon_led.default_trigger = devm_kasprintf(&pdev->dev, + GFP_KERNEL, "arc%d-%d-recon", + dev->dev_id, i); + card->recon_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, + "pci:red:recon:%d-%d", + dev->dev_id, i); + card->recon_led.dev = &dev->dev; card->dev = dev; + ret = devm_led_classdev_register(&pdev->dev, &card->tx_led); + if (ret) + goto out_port; + + ret = devm_led_classdev_register(&pdev->dev, &card->recon_led); + if (ret) + goto out_port; + dev_set_drvdata(&dev->dev, card); ret = com20020_found(dev, IRQF_SHARED); if (ret) goto out_port; + devm_arcnet_led_init(dev, dev->dev_id, i); + list_add(&card->list, &priv->list_dev); } @@ -261,6 +319,12 @@ static struct com20020_pci_card_info card_info_eae_arc1 = { .offset = 0x10, .size = 0x04, }, + .leds = { + { + .green = 0x0, + .red = 0x1, + }, + }, .rotary = 0x0, .flags = ARC_CAN_10MBIT, }; @@ -284,6 +348,15 @@ static struct com20020_pci_card_info card_info_eae_ma1 = { .offset = 0x10, .size = 0x04, }, + .leds = { + { + .green = 0x0, + .red = 0x1, + }, { + .green = 0x2, + .red = 0x3, + }, + }, .rotary = 0x0, .flags = ARC_CAN_10MBIT, }; |