Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Oct 2012 18:01:56 +0000 (UTC)
From:      Jim Harris <jimharris@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r241403 - head/sys/dev/isci
Message-ID:  <201210101801.q9AI1utf074723@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jimharris
Date: Wed Oct 10 18:01:56 2012
New Revision: 241403
URL: http://svn.freebsd.org/changeset/base/241403

Log:
  Add support for locate LED.
  
  While here, change ISCI_LED to ISCI_PHY since conceptually the hardware
  ties the LEDs to a phy and the LEDs for a given phy cannot be controlled
  independently.
  
  Submitted by: Paul Maulberger <Paul.Maulberger at gmx.de> (with modifications)

Modified:
  head/sys/dev/isci/isci.c
  head/sys/dev/isci/isci.h
  head/sys/dev/isci/isci_controller.c

Modified: head/sys/dev/isci/isci.c
==============================================================================
--- head/sys/dev/isci/isci.c	Wed Oct 10 17:51:23 2012	(r241402)
+++ head/sys/dev/isci/isci.c	Wed Oct 10 18:01:56 2012	(r241403)
@@ -223,9 +223,13 @@ isci_detach(device_t device)
 		if (controller->remote_device_memory != NULL)
 			free(controller->remote_device_memory, M_ISCI);
 
-		for (phy = 0; phy < SCI_MAX_PHYS; phy++)
-			if (controller->led[phy].cdev)
-				led_destroy(controller->led[phy].cdev);
+		for (phy = 0; phy < SCI_MAX_PHYS; phy++) {
+			if (controller->phys[phy].cdev_fault)
+				led_destroy(controller->phys[phy].cdev_fault);
+
+			if (controller->phys[phy].cdev_locate)
+				led_destroy(controller->phys[phy].cdev_locate);
+		}
 
 		while (1) {
 			sci_pool_get(controller->unmap_buffer_pool, unmap_buffer);

Modified: head/sys/dev/isci/isci.h
==============================================================================
--- head/sys/dev/isci/isci.h	Wed Oct 10 17:51:23 2012	(r241402)
+++ head/sys/dev/isci/isci.h	Wed Oct 10 18:01:56 2012	(r241403)
@@ -143,11 +143,14 @@ struct ISCI_INTERRUPT_INFO
 
 };
 
-struct ISCI_LED
+struct ISCI_PHY
 {
-	struct cdev		*cdev;
+	struct cdev		*cdev_fault;
+	struct cdev		*cdev_locate;
 	SCI_CONTROLLER_HANDLE_T	handle;
 	int			index;
+	int			led_fault;
+	int			led_locate;
 };
 
 struct ISCI_CONTROLLER
@@ -176,7 +179,7 @@ struct ISCI_CONTROLLER
 	uint32_t		queue_depth;
 	uint32_t		sim_queue_depth;
 	SCI_FAST_LIST_T		pending_device_reset_list;
-	struct ISCI_LED		led[SCI_MAX_PHYS];
+	struct ISCI_PHY		phys[SCI_MAX_PHYS];
 
 	SCI_MEMORY_DESCRIPTOR_LIST_HANDLE_T mdl;
 

Modified: head/sys/dev/isci/isci_controller.c
==============================================================================
--- head/sys/dev/isci/isci_controller.c	Wed Oct 10 17:51:23 2012	(r241402)
+++ head/sys/dev/isci/isci_controller.c	Wed Oct 10 18:01:56 2012	(r241403)
@@ -274,12 +274,24 @@ void isci_controller_construct(struct IS
 	sci_pool_initialize(controller->unmap_buffer_pool);
 }
 
-static void isci_led_func(void *priv, int onoff)
+static void isci_led_fault_func(void *priv, int onoff)
 {
-	struct ISCI_LED *led = priv;
+	struct ISCI_PHY *phy = priv;
+
+	/* map onoff to the fault LED */
+	phy->led_fault = onoff;
+	scic_sgpio_update_led_state(phy->handle, 1 << phy->index, 
+		phy->led_fault, phy->led_locate, 0);
+}
+
+static void isci_led_locate_func(void *priv, int onoff)
+{
+	struct ISCI_PHY *phy = priv;
 
 	/* map onoff to the locate LED */
-	scic_sgpio_update_led_state(led->handle, 1 << led->index, 0, onoff, 0);
+	phy->led_locate = onoff;
+	scic_sgpio_update_led_state(phy->handle, 1 << phy->index, 
+		phy->led_fault, phy->led_locate, 0);
 }
 
 SCI_STATUS isci_controller_initialize(struct ISCI_CONTROLLER *controller)
@@ -368,12 +380,20 @@ SCI_STATUS isci_controller_initialize(st
 	mtx_unlock(&controller->lock);
 
 	for (i = 0; i < SCI_MAX_PHYS; i++) {
-		controller->led[i].handle = scic_controller_handle;
-		controller->led[i].index = i;
-		sprintf(led_name, "isci.bus%d.port%d.locate",
-		    controller->index, i);
-		controller->led[i].cdev = led_create(isci_led_func,
-		    &controller->led[i], led_name);
+		controller->phys[i].handle = scic_controller_handle;
+		controller->phys[i].index = i;
+
+		/* fault */
+		controller->phys[i].led_fault = 0;
+		sprintf(led_name, "isci.bus%d.port%d.fault", controller->index, i);
+		controller->phys[i].cdev_fault = led_create(isci_led_fault_func,
+		    &controller->phys[i], led_name);
+			
+		/* locate */
+		controller->phys[i].led_locate = 0;
+		sprintf(led_name, "isci.bus%d.port%d.locate", controller->index, i);
+		controller->phys[i].cdev_locate = led_create(isci_led_locate_func,
+		    &controller->phys[i], led_name);
 	}
 
 	return (scif_controller_initialize(controller->scif_controller_handle));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210101801.q9AI1utf074723>