From patchwork Tue May 1 16:01:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10374141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9603D6053D for ; Tue, 1 May 2018 16:02:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84F5028426 for ; Tue, 1 May 2018 16:02:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7943B28988; Tue, 1 May 2018 16:02:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5EEA28426 for ; Tue, 1 May 2018 16:02:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755935AbeEAQCF (ORCPT ); Tue, 1 May 2018 12:02:05 -0400 Received: from mail-bn3nam01on0059.outbound.protection.outlook.com ([104.47.33.59]:62176 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755434AbeEAQCC (ORCPT ); Tue, 1 May 2018 12:02:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Tvd3orZYzpKIF4rBi8sDpN/jzW9ftyW/wP5BCX4hrQ0=; b=JQxTG2oFebg7TqT8y1fBKRVNRz1IBinCL7JYAlnmNtugcwMPKkE9QjER+/iaEEDcWlvl2/7BkUU56nz/405IizJFD/a3GXf2n1Ls6sRusW7ehXnojcAhbqOQ21tRtm7VtIvR851Qbf49B5xT10BHkrP+zTpa87zEj97gXcS2bQE= Received: from SN4PR0701CA0006.namprd07.prod.outlook.com (2603:10b6:803:28::16) by CY1PR07MB1512.namprd07.prod.outlook.com (2a01:111:e400:50ed::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Tue, 1 May 2018 16:01:57 +0000 Received: from BY2FFO11FD017.protection.gbl (2a01:111:f400:7c0c::156) by SN4PR0701CA0006.outlook.office365.com (2603:10b6:803:28::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.715.18 via Frontend Transport; Tue, 1 May 2018 16:01:57 +0000 Authentication-Results: spf=pass (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=cavium.com; Received-SPF: Pass (protection.outlook.com: domain of cavium.com designates 50.232.66.26 as permitted sender) receiver=protection.outlook.com; client-ip=50.232.66.26; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BY2FFO11FD017.mail.protection.outlook.com (10.1.14.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.696.11 via Frontend Transport; Tue, 1 May 2018 16:01:57 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Tue, 1 May 2018 09:01:59 -0700 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id w41G1tXv027954; Tue, 1 May 2018 09:01:55 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w41G1tpr027953; Tue, 1 May 2018 09:01:55 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 01/12] qla2xxx: Add Laser Control for ISP26XX/27XX Date: Tue, 1 May 2018 09:01:43 -0700 Message-ID: <20180501160154.27915-2-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180501160154.27915-1-himanshu.madhani@cavium.com> References: <20180501160154.27915-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(39860400002)(39380400002)(2980300002)(438002)(199004)(189003)(42186006)(16586007)(5660300001)(48376002)(478600001)(72206003)(87636003)(575784001)(50466002)(86362001)(305945005)(4326008)(186003)(356003)(47776003)(6666003)(336012)(2616005)(486006)(59450400001)(50226002)(44832011)(106002)(11346002)(476003)(36756003)(446003)(126002)(51416003)(76176011)(1076002)(8676002)(81166006)(106466001)(81156014)(80596001)(26005)(316002)(110136005)(54906003)(2906002)(69596002)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB1512; H:CAEXCH02.caveonetworks.com; FPR:; SPF:Pass; LANG:en; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD017; 1:yLl1nErWlqp+ZI/Ffvf7b27k7yO7g7ulqjfGJcD+2isF4rAJr37k2sGigc1NuVR/h1fdn5rt61fIBNBQYCNiwo073cJsoyoMlSTPqndUR+Wdx0IuKlrl/WyYyhT1okJF X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4608076)(2017052603328)(7153060); SRVR:CY1PR07MB1512; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1512; 3:DcVdXMg5OSAVTxghyDLZTvwRM4yl2SmjdK1YT7P7lxAjWZRALZ4+LuLhGAqE9FdXGLPhZ5wDx6rFw4ItsgTZJGOotFYnYT7338ogT3qz1qqzOX72G4BTtOine7BGxprxthLW1OneHouCF63uPYI/Q93ByY11I1TNbNYTmyS2c+QzCnOhu2+03KxkhPTEsGZssISCaPMUaj3W2pPtJfL5JhmwXVudOo76E4fwYautRjviHIVZ6celfJ2wDflII/CT2sZdXwLinLilOJrm/a0JhjZxZ5coDr3zgfY03i1JpeZGu/e4u9GpEsKY6TCDoVefavJgojr60KA0bVaK1TyrHg==; 25:D31bMWEEM6w/j8eFFIkqdMQ6gJIdcG6Uj+cPcIqOwO9mUZnnzcd9Kl1i/iM/C/WmLiVzkzVGfUhzFxb5Bkh75fKTpnCCQqLc6G6qRLCDwkp8XwPQZf3PQSakiSaDjTlEZUQH7+qQWHQLAzmuSBCb6PKiTCJnEU/sba8n0wiHauMZWmAPXZO4VGxjQ416TG/G4L7mBbug4pRrDAMR8Y3FGbVdCiKkWwCUdWQDW+4NgdynajxyfQBAO684QcvDjdPy1vrSWmp04nCFDQaqPQ5utFhXgPg2yqTgZXSoEtvUB0sTaXNktvvag1efk07WE0zZX1dIBV9FGQ2Un6/jwwzxkw==; 31:lFu4254C+B6wWjnkp43MD9s6Hc4tgNo1Sebqyxn8mgRq/bZLu5CgvZnAFG1k5tDs1JazUcpims52mTrM8DMRVRjX1JlhH282278HCIovf6r47Gmvl1jicbEiUcqUhC+cvj5kHht3ogcEoH29IoYAzAUCB05GgZf0TiUsxIQV7CJlpG/xrSHi6QdidaTtp5Z5ZpXFessCgbmn3IBuUqQLZCcZf8wpw1ZLREjENLjRkDg= X-MS-TrafficTypeDiagnostic: CY1PR07MB1512: X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1512; 20:KD/SNrWw6syyEZn8hjvWAM07yaaRr8JlFCoxE95x6HgVTqVM9BWmyOZi6Z8osMNKLDBc2s/cEevkArpnEdbVYC9rZ1oRb8j/Mn2DM3bifiPcM6JSwni7ubWNkbirJUCq3Y9h/yeV8p8sCi5dweLGjwcHGoxh69UNCUkwpiDjjcLQFoTQ6WXs1Mxetza+QihAKOtAJ0ZYYF8jLUnUPnEyLO5bb39C1P3t7hnAUS0tFUpi2cVtSadrJfqxVZVNPE2njjKIc00gGQvypfsa89EViYby6W11LBIZCIqt6A04bz9XuJnthtCHtGoumfazzIECgROjSWRwzgflGqdlMQJidlHBxWBNfp87SZ24gr4KrIZG2YtEq8yHBAyYhpiAD4KtOYOQbf6w8Zfg5jHUjM4qAkcFcCwqMQivVQkWGujKuShsYdBHyqaF7ucKhfJKHCfaHXTZ72hIEirAoTyQzuU4EvZgyboSgfhuExaAEerskn3QVDDhLjZe1HaNyb1UKsBF; 4:P+TktACJFsjJt27obH18qsJzh712Jxhc8VbeKPijn1xK9nKniFRk3N51Ws63huuaIMa2cboMXFtBfbInNXUms/WSclX2fOz+7R3ahS0oub+3myDRPgWIgSyY/jp8iltlW6DewvzZv6Pfo5hqeoezIo3AuvZeH3z5Ar18ZymWzKxAQmRfTA8j6USzzDgJN0DM8TRnNq7UXjWK2mP3tEvTZL40oiaafYc5xEGkzISO5Xb+vTZWy99lwY3H6ZFzhlhvmxxlkRJSRZBzlB9oMtrq/A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93004095)(10201501046)(3231254)(944501410)(52105095)(3002001)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:CY1PR07MB1512; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB1512; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB1512; 23:D9Li4G3kl2K1W2QKK+lvWM8olqJprrLw5aSxE8DQr?= =?us-ascii?Q?izFX4zYKtAzngqUI/6obZRSQztSQ4b4+h1upEkOG48v626MEcBwcXKTpbbzE?= =?us-ascii?Q?NwFlEyLyZKYRKf67DRTIxYN48qzZFuOQAAbzezcQOiWLQbfilbuiKTynkebi?= =?us-ascii?Q?Aun1MrzS6YfcCsVnGRdwTcXD5AYB5J8MKn1LCSgRcwPoQjyZRInEsHUT+fvl?= =?us-ascii?Q?38ngLrx0JPYN79/Yv/lem73NubjNLCqg7n0qSOo3HVrDs9QwNbpDaXgXOMaN?= =?us-ascii?Q?4NbvZMkT42cEcVdcCsFTRSnz7MZmujPUY9bMB6sMqWmzQrJOb5vFSRPUxTUn?= =?us-ascii?Q?AspnvsRZHIzzyvU81Q64PCXJxIMYeu1bbGwCSRXV6VdKRThg+SELdqdB856U?= =?us-ascii?Q?LnlJxL4zA7DLQztxEldnZs62e55BhwWqV4misd2Td7plhTOrpZ8GOU3dBixd?= =?us-ascii?Q?ukoIxIYWQ5pA+cuQKXh+53FO5tEu8o7fCs0RALhZ2T8TUI5xLfs3QS79h3jJ?= =?us-ascii?Q?PL/i99+wtKlQcUBETIWNAmgiW50pRXfdh1aGkkJ6vgkhUv2sDfHHK9wi2Q6s?= =?us-ascii?Q?7hN51MvmlDVX9lWpyrKQ3jwyjMZLJVAx4zy3SX0SjDffWlNR4Ah7NBNkG1Vu?= =?us-ascii?Q?kBgLTQ0KEbRmMsRbSlIIOWFJzZAax3Ze4Srx1iRjby7s34J82wTfLfGvLY//?= =?us-ascii?Q?1L0WtT9FHaGapAP1xtBXWhpclmuug/S3F/m4bYCgdbHmqygDebfUXj8Ey2j3?= =?us-ascii?Q?/tMhupxbQ1PiETtFVvF6sHcHTeq2tsqlM/r0/3JToSsQY9943fxam/0oc0XG?= =?us-ascii?Q?2h0O5dpnr948mR2NmMNwx6ccT7HvnlvHIOnJFfFdrTKXNcCTJQ6J9vkLAw0F?= =?us-ascii?Q?iH54lBrv7Bjxizlhl/jTi3kd3jB71uU9i55hzStzRwyc+YteMTdAuo4eR1HP?= =?us-ascii?Q?zoZJwJjptaLo79UWBWIYZsi/1MCXyUuQfJtgSua4APwb+MFX3NffBbHbtZX8?= =?us-ascii?Q?mCZPZzzWUTqu/g6Qo02/g0PGdvarTyGEGzhi/p/f8k+fqjLpn1Ys5xhFAIOK?= =?us-ascii?Q?BxDACbjrXaPyUkjiQzNdoJxvu0anE31BlDM9VHRD9BX8wJqAvVvgdZngK3y/?= =?us-ascii?Q?hbSXqAfAuvkVaAiE48rlHtMrPHJohCIAlTbZSz7rcdiMar1fj16T0r8cX87t?= =?us-ascii?Q?kbDxJ3IWDW67UE=3D?= X-Microsoft-Antispam-Message-Info: 1CJudByDrD3Y4GP+bxN/JbIwKdrc1F5hSINJFru/QItZHO0FEfquEyJqWofWftvNo3H4ogkaaS3shFuK+E8zEPRSBO8icERK41p1wipWVIAHBEt5F7K5lAYnQk/+UTWCzM1QpVNuANr627U446t/u4QJWYrSur6edLIFvjOiWZs6l4v+GoS0hoZWpY/sKZgj X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1512; 6:ca/IPoKSlHFAl+PmVre1usgXy7ajWXCaLlv1078gL4JEaTg6+ZEZaqyDylYDRFvhIOaTSP+jPC/gJxN7lWeku0DIlkfGu/xH3O9fFTOuaWmO+vKb2PcVoXe16XcLnKB7j9Dp1aq0B69Njf9I05NxEteez2w6frqCCgCxMgXVTIqqPQSPFe45teymd+NslXaBp+Iov8c3kL8RDVd2FPSSMAvPesq4oM6JQnO3o+UofBScfRv/247ALp2pt7LywLHgbrF3X0lvqBWTMebuoThi1iA/MO0w2+u8e9+hkF4YkfEB4ukRCFPi5Om1lAlB7q47Klo2YX3pKnZ5bNucRhaBWfWwzW0e/HLsbfBGFCWl5/dmxuGDPRGBIgdYF2LsXf62+DuYIa6obf/kQVyfjQh7t0wjQmqHYUcrAy6rpgNVbKPCMKHTeQ1Sfk6czkaNj9H08CxNbvKt/RNU8KcpDLSEOQ==; 5:cHIRV/xt6PpOVqnr0bL5tuWDTa3zMbwHdsZogHx2JyZT+m/M7Ugdj6AOKR1oqWEebmulfkKB/9WJ/eZbZcITFUjqj8MC4VTYS0Pq9I5gLA0TNUFAybRA0j59MeBfQNodUWS4YIDyTFU0sQGrHbQHHaJfIBQ8V+/klz9Xs1PQ5zo=; 24:Z8Q9s38Yj2kH/R0EjPnE2/Ijh3cwMUpbOlFpcMKydefJ/QhFP/mgp6lrpLYu7g45vhiGgYbcEn7wYXDE9ABHPX2nAbOpnGJ/alHdwiKVM7A= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1512; 7:N6tawSFjy4tHbUvTWyuseE7wWRPrk6u50GFf5zNQv+Axit/Q7t93Sm3Si/RuEkVxNLDwwHQsluvxTBhb2aMrreD41B/UZm2w46bqZgSjs2yBBwJJoDj7rqVNMis9FvJm9LZcioqdamynIKBg4mhuu11O8K1J65xZN5M8oG9qAaosYkuSsarFocBgHx3PI+ILvtflvc1kmYUz0JpPEcpgpDRBTHnyC4O/JyvbC+tt1OZDVxeKLsdxO0uVnQQL+4Ee X-MS-Office365-Filtering-Correlation-Id: 0594056c-8a42-4884-5abd-08d5af7cddb3 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2018 16:01:57.0933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0594056c-8a42-4884-5abd-08d5af7cddb3 X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB1512 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Himanshu Madhani This patch disables laser while unloading driver for 16/32G adapters. Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 7 ++++ drivers/scsi/qla2xxx/qla_fw.h | 2 ++ drivers/scsi/qla2xxx/qla_inline.h | 22 ++++++++++++ drivers/scsi/qla2xxx/qla_os.c | 72 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index eb2ec1fb07cb..c36e37fdc201 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -201,6 +201,10 @@ #define LASER_ON_2031 0x01800100 #define LASER_OFF_2031 0x01800180 +/* ISP27XX: Values for Laser ON/Off */ +#define LASER_ON_27XX 0x00400000 +#define LASER_OFF_27XX 0x00400040 + /* * The ISP2312 v2 chip cannot access the FLASH/GPIO registers via MMIO in an * 133Mhz slot. @@ -705,6 +709,8 @@ struct device_reg_2xxx { #define GPIO_LED_ALL_OFF 0x0000 #define GPIO_LED_RED_ON_OTHER_OFF 0x0001 /* isp2322 */ #define GPIO_LED_RGA_ON 0x00C1 /* isp2322: red green amber */ +#define GPIO_LASER_MASK BIT_6 +#define GPIO_LASER_DISABLE BIT_2 union { struct { @@ -3161,6 +3167,7 @@ struct isp_operations { int (*abort_isp) (struct scsi_qla_host *); int (*iospace_config)(struct qla_hw_data*); int (*initialize_adapter)(struct scsi_qla_host *); + void (*disable_laser)(struct scsi_qla_host *); }; /* MSI-X Support *************************************************************/ diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h index 5d8688e5bc7c..b11ae7d04c43 100644 --- a/drivers/scsi/qla2xxx/qla_fw.h +++ b/drivers/scsi/qla2xxx/qla_fw.h @@ -1096,6 +1096,8 @@ struct device_reg_24xx { #define GPDX_LED_AMBER_ON BIT_4 /* Data in/out. */ #define GPDX_DATA_INOUT (BIT_1|BIT_0) +#define GPDX_LASER_MASK BIT_22 +#define GPDX_LASER_DISABLE BIT_6 uint32_t gpioe; /* GPIO Enable register. */ /* Enable update mask. */ diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index 37ae0f6d8ae5..6ac96322fec1 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -367,3 +367,25 @@ qla_83xx_start_iocbs(struct qla_qpair *qpair) WRT_REG_DWORD(req->req_q_in, req->ring_index); } + +static inline void +qla24xx_drive_gpio(scsi_qla_host_t *vha) +{ + struct qla_hw_data *ha = vha->hw; + + /* Take control of GPIO register. */ + ha->fw_options[1] |= ADD_FO1_DISABLE_GPIO_LED_CTRL; + qla2x00_set_fw_options(vha, ha->fw_options); + qla2x00_get_fw_options(vha, ha->fw_options); +} + +static inline void +qla24xx_relinquish_gpio(scsi_qla_host_t *vha) +{ + struct qla_hw_data *ha = vha->hw; + + /* Restore control of GPIO register. */ + ha->fw_options[1] &= ~ADD_FO1_DISABLE_GPIO_LED_CTRL; + qla2x00_set_fw_options(vha, ha->fw_options); + qla2x00_get_fw_options(vha, ha->fw_options); +} diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 15eaa6dded04..bec8459523bd 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -302,6 +302,8 @@ static void qla2x00_clear_drv_active(struct qla_hw_data *); static void qla2x00_free_device(scsi_qla_host_t *); static int qla2xxx_map_queues(struct Scsi_Host *shost); static void qla2x00_destroy_deferred_work(struct qla_hw_data *); +static void qla83xx_disable_laser(scsi_qla_host_t *); +static void qla27xx_disable_laser(scsi_qla_host_t *); struct scsi_host_template qla2xxx_driver_template = { .module = THIS_MODULE, @@ -2156,6 +2158,7 @@ static struct isp_operations qla2100_isp_ops = { .abort_isp = qla2x00_abort_isp, .iospace_config = qla2x00_iospace_config, .initialize_adapter = qla2x00_initialize_adapter, + .disable_laser = NULL, }; static struct isp_operations qla2300_isp_ops = { @@ -2195,6 +2198,7 @@ static struct isp_operations qla2300_isp_ops = { .abort_isp = qla2x00_abort_isp, .iospace_config = qla2x00_iospace_config, .initialize_adapter = qla2x00_initialize_adapter, + .disable_laser = NULL, }; static struct isp_operations qla24xx_isp_ops = { @@ -2234,6 +2238,7 @@ static struct isp_operations qla24xx_isp_ops = { .abort_isp = qla2x00_abort_isp, .iospace_config = qla2x00_iospace_config, .initialize_adapter = qla2x00_initialize_adapter, + .disable_laser = NULL, }; static struct isp_operations qla25xx_isp_ops = { @@ -2273,6 +2278,7 @@ static struct isp_operations qla25xx_isp_ops = { .abort_isp = qla2x00_abort_isp, .iospace_config = qla2x00_iospace_config, .initialize_adapter = qla2x00_initialize_adapter, + .disable_laser = NULL, }; static struct isp_operations qla81xx_isp_ops = { @@ -2312,6 +2318,7 @@ static struct isp_operations qla81xx_isp_ops = { .abort_isp = qla2x00_abort_isp, .iospace_config = qla2x00_iospace_config, .initialize_adapter = qla2x00_initialize_adapter, + .disable_laser = NULL, }; static struct isp_operations qla82xx_isp_ops = { @@ -2351,6 +2358,7 @@ static struct isp_operations qla82xx_isp_ops = { .abort_isp = qla82xx_abort_isp, .iospace_config = qla82xx_iospace_config, .initialize_adapter = qla2x00_initialize_adapter, + .disable_laser = NULL, }; static struct isp_operations qla8044_isp_ops = { @@ -2390,6 +2398,7 @@ static struct isp_operations qla8044_isp_ops = { .abort_isp = qla8044_abort_isp, .iospace_config = qla82xx_iospace_config, .initialize_adapter = qla2x00_initialize_adapter, + .disable_laser = NULL, }; static struct isp_operations qla83xx_isp_ops = { @@ -2429,6 +2438,7 @@ static struct isp_operations qla83xx_isp_ops = { .abort_isp = qla2x00_abort_isp, .iospace_config = qla83xx_iospace_config, .initialize_adapter = qla2x00_initialize_adapter, + .disable_laser = qla83xx_disable_laser, }; static struct isp_operations qlafx00_isp_ops = { @@ -2468,6 +2478,7 @@ static struct isp_operations qlafx00_isp_ops = { .abort_isp = qlafx00_abort_isp, .iospace_config = qlafx00_iospace_config, .initialize_adapter = qlafx00_initialize_adapter, + .disable_laser = NULL, }; static struct isp_operations qla27xx_isp_ops = { @@ -2507,6 +2518,7 @@ static struct isp_operations qla27xx_isp_ops = { .abort_isp = qla2x00_abort_isp, .iospace_config = qla83xx_iospace_config, .initialize_adapter = qla2x00_initialize_adapter, + .disable_laser = qla27xx_disable_laser, }; static inline void @@ -3662,6 +3674,8 @@ qla2x00_remove_one(struct pci_dev *pdev) qla84xx_put_chip(base_vha); + ha->isp_ops->disable_laser(base_vha); + /* Disable timer */ if (base_vha->timer_active) qla2x00_stop_timer(base_vha); @@ -6822,6 +6836,64 @@ qla2xxx_pci_resume(struct pci_dev *pdev) ha->flags.eeh_busy = 0; } +static void +qla27xx_disable_laser(scsi_qla_host_t *vha) +{ + struct qla_hw_data *ha = vha->hw; + struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; + uint32_t gpio_data; + unsigned long flags; + + ql_dbg(ql_dbg_init, vha, 0x0190, + "Disabling Laser for hba: %p\n", vha); + + qla24xx_drive_gpio(vha); + + spin_lock_irqsave(&ha->hardware_lock, flags); + + /* Prepare GPIO enable mask. */ + gpio_data = RD_REG_DWORD(®->gpioe); + gpio_data |= GPDX_LASER_MASK | GPDX_LASER_DISABLE; + + WRT_REG_DWORD(®->gpioe, gpio_data); + RD_REG_DWORD(®->gpioe); + + /* Drive GPIO laser pin -- low. */ + gpio_data = RD_REG_DWORD(®->gpiod); + gpio_data |= GPDX_LASER_MASK | GPDX_LASER_DISABLE | LASER_OFF_27XX; + WRT_REG_DWORD(®->gpiod, gpio_data); + RD_REG_DWORD(®->gpiod); + spin_unlock_irqrestore(&ha->hardware_lock, flags); + + qla24xx_relinquish_gpio(vha); +} + +static void +qla83xx_disable_laser(scsi_qla_host_t *vha) +{ + uint32_t reg, data, fn; + struct qla_hw_data *ha = vha->hw; + struct device_reg_24xx __iomem *isp_reg = &ha->iobase->isp24; + + /* pci func #/port # */ + ql_dbg(ql_dbg_init, vha, 0x004b, + "Disabling Laser for hba: %p\n", vha); + + fn = (RD_REG_DWORD(&isp_reg->ctrl_status) & + (BIT_15|BIT_14|BIT_13|BIT_12)); + + fn = (fn >> 12); + + if (fn & 1) + reg = PORT_1_2031; + else + reg = PORT_0_2031; + + data = LASER_OFF_2031; + + qla83xx_wr_reg(vha, reg, data); +} + static int qla2xxx_map_queues(struct Scsi_Host *shost) { int rc;