diff options
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_sup.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_sup.c | 294 |
1 files changed, 294 insertions, 0 deletions
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index f4d755a643e4..3105bb93cc19 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c | |||
@@ -695,3 +695,297 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, | |||
695 | 695 | ||
696 | return ret; | 696 | return ret; |
697 | } | 697 | } |
698 | |||
699 | |||
700 | static inline void | ||
701 | qla2x00_flip_colors(scsi_qla_host_t *ha, uint16_t *pflags) | ||
702 | { | ||
703 | if (IS_QLA2322(ha)) { | ||
704 | /* Flip all colors. */ | ||
705 | if (ha->beacon_color_state == QLA_LED_ALL_ON) { | ||
706 | /* Turn off. */ | ||
707 | ha->beacon_color_state = 0; | ||
708 | *pflags = GPIO_LED_ALL_OFF; | ||
709 | } else { | ||
710 | /* Turn on. */ | ||
711 | ha->beacon_color_state = QLA_LED_ALL_ON; | ||
712 | *pflags = GPIO_LED_RGA_ON; | ||
713 | } | ||
714 | } else { | ||
715 | /* Flip green led only. */ | ||
716 | if (ha->beacon_color_state == QLA_LED_GRN_ON) { | ||
717 | /* Turn off. */ | ||
718 | ha->beacon_color_state = 0; | ||
719 | *pflags = GPIO_LED_GREEN_OFF_AMBER_OFF; | ||
720 | } else { | ||
721 | /* Turn on. */ | ||
722 | ha->beacon_color_state = QLA_LED_GRN_ON; | ||
723 | *pflags = GPIO_LED_GREEN_ON_AMBER_OFF; | ||
724 | } | ||
725 | } | ||
726 | } | ||
727 | |||
728 | void | ||
729 | qla2x00_beacon_blink(struct scsi_qla_host *ha) | ||
730 | { | ||
731 | uint16_t gpio_enable; | ||
732 | uint16_t gpio_data; | ||
733 | uint16_t led_color = 0; | ||
734 | unsigned long flags; | ||
735 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | ||
736 | |||
737 | if (ha->pio_address) | ||
738 | reg = (struct device_reg_2xxx __iomem *)ha->pio_address; | ||
739 | |||
740 | spin_lock_irqsave(&ha->hardware_lock, flags); | ||
741 | |||
742 | /* Save the Original GPIOE. */ | ||
743 | if (ha->pio_address) { | ||
744 | gpio_enable = RD_REG_WORD_PIO(®->gpioe); | ||
745 | gpio_data = RD_REG_WORD_PIO(®->gpiod); | ||
746 | } else { | ||
747 | gpio_enable = RD_REG_WORD(®->gpioe); | ||
748 | gpio_data = RD_REG_WORD(®->gpiod); | ||
749 | } | ||
750 | |||
751 | /* Set the modified gpio_enable values */ | ||
752 | gpio_enable |= GPIO_LED_MASK; | ||
753 | |||
754 | if (ha->pio_address) { | ||
755 | WRT_REG_WORD_PIO(®->gpioe, gpio_enable); | ||
756 | } else { | ||
757 | WRT_REG_WORD(®->gpioe, gpio_enable); | ||
758 | RD_REG_WORD(®->gpioe); | ||
759 | } | ||
760 | |||
761 | qla2x00_flip_colors(ha, &led_color); | ||
762 | |||
763 | /* Clear out any previously set LED color. */ | ||
764 | gpio_data &= ~GPIO_LED_MASK; | ||
765 | |||
766 | /* Set the new input LED color to GPIOD. */ | ||
767 | gpio_data |= led_color; | ||
768 | |||
769 | /* Set the modified gpio_data values */ | ||
770 | if (ha->pio_address) { | ||
771 | WRT_REG_WORD_PIO(®->gpiod, gpio_data); | ||
772 | } else { | ||
773 | WRT_REG_WORD(®->gpiod, gpio_data); | ||
774 | RD_REG_WORD(®->gpiod); | ||
775 | } | ||
776 | |||
777 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | ||
778 | } | ||
779 | |||
780 | int | ||
781 | qla2x00_beacon_on(struct scsi_qla_host *ha) | ||
782 | { | ||
783 | uint16_t gpio_enable; | ||
784 | uint16_t gpio_data; | ||
785 | unsigned long flags; | ||
786 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | ||
787 | |||
788 | ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; | ||
789 | ha->fw_options[1] |= FO1_DISABLE_GPIO6_7; | ||
790 | |||
791 | if (qla2x00_set_fw_options(ha, ha->fw_options) != QLA_SUCCESS) { | ||
792 | qla_printk(KERN_WARNING, ha, | ||
793 | "Unable to update fw options (beacon on).\n"); | ||
794 | return QLA_FUNCTION_FAILED; | ||
795 | } | ||
796 | |||
797 | if (ha->pio_address) | ||
798 | reg = (struct device_reg_2xxx __iomem *)ha->pio_address; | ||
799 | |||
800 | /* Turn off LEDs. */ | ||
801 | spin_lock_irqsave(&ha->hardware_lock, flags); | ||
802 | if (ha->pio_address) { | ||
803 | gpio_enable = RD_REG_WORD_PIO(®->gpioe); | ||
804 | gpio_data = RD_REG_WORD_PIO(®->gpiod); | ||
805 | } else { | ||
806 | gpio_enable = RD_REG_WORD(®->gpioe); | ||
807 | gpio_data = RD_REG_WORD(®->gpiod); | ||
808 | } | ||
809 | gpio_enable |= GPIO_LED_MASK; | ||
810 | |||
811 | /* Set the modified gpio_enable values. */ | ||
812 | if (ha->pio_address) { | ||
813 | WRT_REG_WORD_PIO(®->gpioe, gpio_enable); | ||
814 | } else { | ||
815 | WRT_REG_WORD(®->gpioe, gpio_enable); | ||
816 | RD_REG_WORD(®->gpioe); | ||
817 | } | ||
818 | |||
819 | /* Clear out previously set LED colour. */ | ||
820 | gpio_data &= ~GPIO_LED_MASK; | ||
821 | if (ha->pio_address) { | ||
822 | WRT_REG_WORD_PIO(®->gpiod, gpio_data); | ||
823 | } else { | ||
824 | WRT_REG_WORD(®->gpiod, gpio_data); | ||
825 | RD_REG_WORD(®->gpiod); | ||
826 | } | ||
827 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | ||
828 | |||
829 | /* | ||
830 | * Let the per HBA timer kick off the blinking process based on | ||
831 | * the following flags. No need to do anything else now. | ||
832 | */ | ||
833 | ha->beacon_blink_led = 1; | ||
834 | ha->beacon_color_state = 0; | ||
835 | |||
836 | return QLA_SUCCESS; | ||
837 | } | ||
838 | |||
839 | int | ||
840 | qla2x00_beacon_off(struct scsi_qla_host *ha) | ||
841 | { | ||
842 | int rval = QLA_SUCCESS; | ||
843 | |||
844 | ha->beacon_blink_led = 0; | ||
845 | |||
846 | /* Set the on flag so when it gets flipped it will be off. */ | ||
847 | if (IS_QLA2322(ha)) | ||
848 | ha->beacon_color_state = QLA_LED_ALL_ON; | ||
849 | else | ||
850 | ha->beacon_color_state = QLA_LED_GRN_ON; | ||
851 | |||
852 | ha->isp_ops.beacon_blink(ha); /* This turns green LED off */ | ||
853 | |||
854 | ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; | ||
855 | ha->fw_options[1] &= ~FO1_DISABLE_GPIO6_7; | ||
856 | |||
857 | rval = qla2x00_set_fw_options(ha, ha->fw_options); | ||
858 | if (rval != QLA_SUCCESS) | ||
859 | qla_printk(KERN_WARNING, ha, | ||
860 | "Unable to update fw options (beacon off).\n"); | ||
861 | return rval; | ||
862 | } | ||
863 | |||
864 | |||
865 | static inline void | ||
866 | qla24xx_flip_colors(scsi_qla_host_t *ha, uint16_t *pflags) | ||
867 | { | ||
868 | /* Flip all colors. */ | ||
869 | if (ha->beacon_color_state == QLA_LED_ALL_ON) { | ||
870 | /* Turn off. */ | ||
871 | ha->beacon_color_state = 0; | ||
872 | *pflags = 0; | ||
873 | } else { | ||
874 | /* Turn on. */ | ||
875 | ha->beacon_color_state = QLA_LED_ALL_ON; | ||
876 | *pflags = GPDX_LED_YELLOW_ON | GPDX_LED_AMBER_ON; | ||
877 | } | ||
878 | } | ||
879 | |||
880 | void | ||
881 | qla24xx_beacon_blink(struct scsi_qla_host *ha) | ||
882 | { | ||
883 | uint16_t led_color = 0; | ||
884 | uint32_t gpio_data; | ||
885 | unsigned long flags; | ||
886 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | ||
887 | |||
888 | /* Save the Original GPIOD. */ | ||
889 | spin_lock_irqsave(&ha->hardware_lock, flags); | ||
890 | gpio_data = RD_REG_DWORD(®->gpiod); | ||
891 | |||
892 | /* Enable the gpio_data reg for update. */ | ||
893 | gpio_data |= GPDX_LED_UPDATE_MASK; | ||
894 | |||
895 | WRT_REG_DWORD(®->gpiod, gpio_data); | ||
896 | gpio_data = RD_REG_DWORD(®->gpiod); | ||
897 | |||
898 | /* Set the color bits. */ | ||
899 | qla24xx_flip_colors(ha, &led_color); | ||
900 | |||
901 | /* Clear out any previously set LED color. */ | ||
902 | gpio_data &= ~GPDX_LED_COLOR_MASK; | ||
903 | |||
904 | /* Set the new input LED color to GPIOD. */ | ||
905 | gpio_data |= led_color; | ||
906 | |||
907 | /* Set the modified gpio_data values. */ | ||
908 | WRT_REG_DWORD(®->gpiod, gpio_data); | ||
909 | gpio_data = RD_REG_DWORD(®->gpiod); | ||
910 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | ||
911 | } | ||
912 | |||
913 | int | ||
914 | qla24xx_beacon_on(struct scsi_qla_host *ha) | ||
915 | { | ||
916 | uint32_t gpio_data; | ||
917 | unsigned long flags; | ||
918 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | ||
919 | |||
920 | if (ha->beacon_blink_led == 0) { | ||
921 | /* Enable firmware for update */ | ||
922 | ha->fw_options[1] |= ADD_FO1_DISABLE_GPIO_LED_CTRL; | ||
923 | |||
924 | if (qla2x00_set_fw_options(ha, ha->fw_options) != QLA_SUCCESS) | ||
925 | return QLA_FUNCTION_FAILED; | ||
926 | |||
927 | if (qla2x00_get_fw_options(ha, ha->fw_options) != | ||
928 | QLA_SUCCESS) { | ||
929 | qla_printk(KERN_WARNING, ha, | ||
930 | "Unable to update fw options (beacon on).\n"); | ||
931 | return QLA_FUNCTION_FAILED; | ||
932 | } | ||
933 | |||
934 | spin_lock_irqsave(&ha->hardware_lock, flags); | ||
935 | gpio_data = RD_REG_DWORD(®->gpiod); | ||
936 | |||
937 | /* Enable the gpio_data reg for update. */ | ||
938 | gpio_data |= GPDX_LED_UPDATE_MASK; | ||
939 | WRT_REG_DWORD(®->gpiod, gpio_data); | ||
940 | RD_REG_DWORD(®->gpiod); | ||
941 | |||
942 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | ||
943 | } | ||
944 | |||
945 | /* So all colors blink together. */ | ||
946 | ha->beacon_color_state = 0; | ||
947 | |||
948 | /* Let the per HBA timer kick off the blinking process. */ | ||
949 | ha->beacon_blink_led = 1; | ||
950 | |||
951 | return QLA_SUCCESS; | ||
952 | } | ||
953 | |||
954 | int | ||
955 | qla24xx_beacon_off(struct scsi_qla_host *ha) | ||
956 | { | ||
957 | uint32_t gpio_data; | ||
958 | unsigned long flags; | ||
959 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | ||
960 | |||
961 | ha->beacon_blink_led = 0; | ||
962 | ha->beacon_color_state = QLA_LED_ALL_ON; | ||
963 | |||
964 | ha->isp_ops.beacon_blink(ha); /* Will flip to all off. */ | ||
965 | |||
966 | /* Give control back to firmware. */ | ||
967 | spin_lock_irqsave(&ha->hardware_lock, flags); | ||
968 | gpio_data = RD_REG_DWORD(®->gpiod); | ||
969 | |||
970 | /* Disable the gpio_data reg for update. */ | ||
971 | gpio_data &= ~GPDX_LED_UPDATE_MASK; | ||
972 | WRT_REG_DWORD(®->gpiod, gpio_data); | ||
973 | RD_REG_DWORD(®->gpiod); | ||
974 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | ||
975 | |||
976 | ha->fw_options[1] &= ~ADD_FO1_DISABLE_GPIO_LED_CTRL; | ||
977 | |||
978 | if (qla2x00_set_fw_options(ha, ha->fw_options) != QLA_SUCCESS) { | ||
979 | qla_printk(KERN_WARNING, ha, | ||
980 | "Unable to update fw options (beacon off).\n"); | ||
981 | return QLA_FUNCTION_FAILED; | ||
982 | } | ||
983 | |||
984 | if (qla2x00_get_fw_options(ha, ha->fw_options) != QLA_SUCCESS) { | ||
985 | qla_printk(KERN_WARNING, ha, | ||
986 | "Unable to get fw options (beacon off).\n"); | ||
987 | return QLA_FUNCTION_FAILED; | ||
988 | } | ||
989 | |||
990 | return QLA_SUCCESS; | ||
991 | } | ||