diff --git a/sys/dev/isci/isci.c b/sys/dev/isci/isci.c index 4d2f4bd..0d4ae44 100644 --- a/sys/dev/isci/isci.c +++ b/sys/dev/isci/isci.c @@ -38,11 +38,14 @@ __FBSDID("$FreeBSD$"); #include +#include + #include #include #include #include +#include #include #include @@ -180,7 +183,7 @@ static int isci_detach(device_t device) { struct isci_softc *isci = DEVICE2SOFTC(device); - int i; + int i, phy; for (i = 0; i < isci->controller_count; i++) { struct ISCI_CONTROLLER *controller = &isci->controllers[i]; @@ -220,6 +223,10 @@ 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); + while (1) { sci_pool_get(controller->unmap_buffer_pool, unmap_buffer); if (unmap_buffer == NULL) diff --git a/sys/dev/isci/isci.h b/sys/dev/isci/isci.h index 48236b9..006d33a 100644 --- a/sys/dev/isci/isci.h +++ b/sys/dev/isci/isci.h @@ -143,6 +143,13 @@ struct ISCI_INTERRUPT_INFO }; +struct ISCI_LED +{ + struct cdev *cdev; + SCI_CONTROLLER_HANDLE_T handle; + int index; +}; + struct ISCI_CONTROLLER { struct isci_softc *isci; @@ -169,6 +176,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]; SCI_MEMORY_DESCRIPTOR_LIST_HANDLE_T mdl; diff --git a/sys/dev/isci/isci_controller.c b/sys/dev/isci/isci_controller.c index 1255201..8a03b60 100644 --- a/sys/dev/isci/isci_controller.c +++ b/sys/dev/isci/isci_controller.c @@ -49,6 +49,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include + +#include void isci_action(struct cam_sim *sim, union ccb *ccb); void isci_poll(struct cam_sim *sim); @@ -271,10 +274,19 @@ void isci_controller_construct(struct ISCI_CONTROLLER *controller, sci_pool_initialize(controller->unmap_buffer_pool); } +static void isci_led_func(void *priv, int onoff) +{ + struct ISCI_LED *led = priv; + + /* map onoff to the locate LED */ + scic_sgpio_update_led_state(led->handle, 1 << led->index, 0, onoff, 0); +} + SCI_STATUS isci_controller_initialize(struct ISCI_CONTROLLER *controller) { SCIC_USER_PARAMETERS_T scic_user_parameters; SCI_CONTROLLER_HANDLE_T scic_controller_handle; + char led_name[64]; unsigned long tunable; int i; @@ -355,6 +367,14 @@ SCI_STATUS isci_controller_initialize(struct ISCI_CONTROLLER *controller) xpt_freeze_simq(controller->sim, 1); 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", controller->index, i); + controller->led[i].cdev = led_create(isci_led_func, + &controller->led[i], led_name); + } + return (scif_controller_initialize(controller->scif_controller_handle)); }