blob: fe18acfd6eb3ad9b62a775665a1dbedecb32e011 [file] [log] [blame]
Dan Williams6f231dd2011-07-02 22:56:22 -07001/*
2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
4 *
5 * GPL LICENSE SUMMARY
6 *
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * BSD LICENSE
25 *
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
38 * distribution.
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55
56#include "isci.h"
Dan Williamsce2b3262011-05-08 15:49:15 -070057#include "host.h"
Dan Williams6f231dd2011-07-02 22:56:22 -070058#include "phy.h"
Dan Williamsd35bc1b2011-05-10 02:28:45 -070059#include "scu_event_codes.h"
Dan Williamse2f8db52011-05-10 02:28:46 -070060#include "probe_roms.h"
Dan Williams6f231dd2011-07-02 22:56:22 -070061
Dan Williamsd35bc1b2011-05-10 02:28:45 -070062/* Maximum arbitration wait time in micro-seconds */
63#define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700)
64
Dan Williams85280952011-06-28 15:05:53 -070065enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -070066{
Dan Williams85280952011-06-28 15:05:53 -070067 return iphy->max_negotiated_speed;
Dan Williamsd35bc1b2011-05-10 02:28:45 -070068}
69
Dan Williams89a73012011-06-30 19:14:33 -070070static enum sci_status
71sci_phy_transport_layer_initialization(struct isci_phy *iphy,
72 struct scu_transport_layer_registers __iomem *reg)
Dan Williamsd35bc1b2011-05-10 02:28:45 -070073{
74 u32 tl_control;
75
Dan Williams89a73012011-06-30 19:14:33 -070076 iphy->transport_layer_registers = reg;
Dan Williamsd35bc1b2011-05-10 02:28:45 -070077
78 writel(SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX,
Dan Williams85280952011-06-28 15:05:53 -070079 &iphy->transport_layer_registers->stp_rni);
Dan Williamsd35bc1b2011-05-10 02:28:45 -070080
81 /*
82 * Hardware team recommends that we enable the STP prefetch for all
83 * transports
84 */
Dan Williams85280952011-06-28 15:05:53 -070085 tl_control = readl(&iphy->transport_layer_registers->control);
Dan Williamsd35bc1b2011-05-10 02:28:45 -070086 tl_control |= SCU_TLCR_GEN_BIT(STP_WRITE_DATA_PREFETCH);
Dan Williams85280952011-06-28 15:05:53 -070087 writel(tl_control, &iphy->transport_layer_registers->control);
Dan Williamsd35bc1b2011-05-10 02:28:45 -070088
89 return SCI_SUCCESS;
90}
91
Dan Williamsd35bc1b2011-05-10 02:28:45 -070092static enum sci_status
Dan Williams89a73012011-06-30 19:14:33 -070093sci_phy_link_layer_initialization(struct isci_phy *iphy,
Dan Williams2e5da882012-01-04 01:32:34 -080094 struct scu_link_layer_registers __iomem *llr)
Dan Williamsd35bc1b2011-05-10 02:28:45 -070095{
Dan Williams89a73012011-06-30 19:14:33 -070096 struct isci_host *ihost = iphy->owning_port->owning_controller;
Dan Williams2e5da882012-01-04 01:32:34 -080097 struct sci_phy_user_params *phy_user;
98 struct sci_phy_oem_params *phy_oem;
Dan Williams85280952011-06-28 15:05:53 -070099 int phy_idx = iphy->phy_index;
Dan Williams89a73012011-06-30 19:14:33 -0700100 struct sci_phy_cap phy_cap;
Dan Williams2e5da882012-01-04 01:32:34 -0800101 u32 phy_configuration;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700102 u32 parity_check = 0;
103 u32 parity_count = 0;
104 u32 llctl, link_rate;
105 u32 clksm_value = 0;
Marcin Tomczak985af6f2011-07-29 17:16:50 -0700106 u32 sp_timeouts = 0;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700107
Dan Williams2e5da882012-01-04 01:32:34 -0800108 phy_user = &ihost->user_parameters.phys[phy_idx];
109 phy_oem = &ihost->oem_parameters.phys[phy_idx];
110 iphy->link_layer_registers = llr;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700111
112 /* Set our IDENTIFY frame data */
113 #define SCI_END_DEVICE 0x01
114
115 writel(SCU_SAS_TIID_GEN_BIT(SMP_INITIATOR) |
116 SCU_SAS_TIID_GEN_BIT(SSP_INITIATOR) |
117 SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) |
118 SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) |
119 SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE),
Dan Williams2e5da882012-01-04 01:32:34 -0800120 &llr->transmit_identification);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700121
122 /* Write the device SAS Address */
Dan Williams2e5da882012-01-04 01:32:34 -0800123 writel(0xFEDCBA98, &llr->sas_device_name_high);
124 writel(phy_idx, &llr->sas_device_name_low);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700125
126 /* Write the source SAS Address */
Dan Williams2e5da882012-01-04 01:32:34 -0800127 writel(phy_oem->sas_address.high, &llr->source_sas_address_high);
128 writel(phy_oem->sas_address.low, &llr->source_sas_address_low);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700129
130 /* Clear and Set the PHY Identifier */
Dan Williams2e5da882012-01-04 01:32:34 -0800131 writel(0, &llr->identify_frame_phy_id);
132 writel(SCU_SAS_TIPID_GEN_VALUE(ID, phy_idx), &llr->identify_frame_phy_id);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700133
134 /* Change the initial state of the phy configuration register */
Dan Williams2e5da882012-01-04 01:32:34 -0800135 phy_configuration = readl(&llr->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700136
137 /* Hold OOB state machine in reset */
138 phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
Dan Williams2e5da882012-01-04 01:32:34 -0800139 writel(phy_configuration, &llr->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700140
141 /* Configure the SNW capabilities */
142 phy_cap.all = 0;
143 phy_cap.start = 1;
144 phy_cap.gen3_no_ssc = 1;
145 phy_cap.gen2_no_ssc = 1;
146 phy_cap.gen1_no_ssc = 1;
Dave Jiang594e5662012-01-04 01:32:44 -0800147 if (ihost->oem_parameters.controller.do_enable_ssc) {
148 struct scu_afe_registers __iomem *afe = &ihost->scu_registers->afe;
149 struct scu_afe_transceiver *xcvr = &afe->scu_afe_xcvr[phy_idx];
150 struct isci_pci_info *pci_info = to_pci_info(ihost->pdev);
151 bool en_sas = false;
152 bool en_sata = false;
153 u32 sas_type = 0;
154 u32 sata_spread = 0x2;
155 u32 sas_spread = 0x2;
156
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700157 phy_cap.gen3_ssc = 1;
158 phy_cap.gen2_ssc = 1;
159 phy_cap.gen1_ssc = 1;
Dave Jiang594e5662012-01-04 01:32:44 -0800160
161 if (pci_info->orom->hdr.version < ISCI_ROM_VER_1_1)
162 en_sas = en_sata = true;
163 else {
164 sata_spread = ihost->oem_parameters.controller.ssc_sata_tx_spread_level;
165 sas_spread = ihost->oem_parameters.controller.ssc_sas_tx_spread_level;
166
167 if (sata_spread)
168 en_sata = true;
169
170 if (sas_spread) {
171 en_sas = true;
172 sas_type = ihost->oem_parameters.controller.ssc_sas_tx_type;
173 }
174
175 }
176
177 if (en_sas) {
178 u32 reg;
179
180 reg = readl(&xcvr->afe_xcvr_control0);
181 reg |= (0x00100000 | (sas_type << 19));
182 writel(reg, &xcvr->afe_xcvr_control0);
183
184 reg = readl(&xcvr->afe_tx_ssc_control);
185 reg |= sas_spread << 8;
186 writel(reg, &xcvr->afe_tx_ssc_control);
187 }
188
189 if (en_sata) {
190 u32 reg;
191
192 reg = readl(&xcvr->afe_tx_ssc_control);
193 reg |= sata_spread;
194 writel(reg, &xcvr->afe_tx_ssc_control);
195
196 reg = readl(&llr->stp_control);
197 reg |= 1 << 12;
198 writel(reg, &llr->stp_control);
199 }
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700200 }
201
Dan Williams2e5da882012-01-04 01:32:34 -0800202 /* The SAS specification indicates that the phy_capabilities that
203 * are transmitted shall have an even parity. Calculate the parity.
204 */
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700205 parity_check = phy_cap.all;
206 while (parity_check != 0) {
207 if (parity_check & 0x1)
208 parity_count++;
209 parity_check >>= 1;
210 }
211
Dan Williams2e5da882012-01-04 01:32:34 -0800212 /* If parity indicates there are an odd number of bits set, then
213 * set the parity bit to 1 in the phy capabilities.
214 */
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700215 if ((parity_count % 2) != 0)
216 phy_cap.parity = 1;
217
Dan Williams2e5da882012-01-04 01:32:34 -0800218 writel(phy_cap.all, &llr->phy_capabilities);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700219
220 /* Set the enable spinup period but disable the ability to send
221 * notify enable spinup
222 */
223 writel(SCU_ENSPINUP_GEN_VAL(COUNT,
224 phy_user->notify_enable_spin_up_insertion_frequency),
Dan Williams2e5da882012-01-04 01:32:34 -0800225 &llr->notify_enable_spinup_control);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700226
227 /* Write the ALIGN Insertion Ferequency for connected phy and
228 * inpendent of connected state
229 */
230 clksm_value = SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(CONNECTED,
231 phy_user->in_connection_align_insertion_frequency);
232
233 clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL,
234 phy_user->align_insertion_frequency);
235
Dan Williams2e5da882012-01-04 01:32:34 -0800236 writel(clksm_value, &llr->clock_skew_management);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700237
Jeff Skirvinafd13a12012-01-04 01:32:39 -0800238 if (is_c0(ihost->pdev) || is_c1(ihost->pdev)) {
239 writel(0x04210400, &llr->afe_lookup_table_control);
240 writel(0x020A7C05, &llr->sas_primitive_timeout);
241 } else
242 writel(0x02108421, &llr->afe_lookup_table_control);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700243
244 llctl = SCU_SAS_LLCTL_GEN_VAL(NO_OUTBOUND_TASK_TIMEOUT,
Dan Williams89a73012011-06-30 19:14:33 -0700245 (u8)ihost->user_parameters.no_outbound_task_timeout);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700246
James Bottomleya5ec7f862011-07-03 14:14:45 -0500247 switch (phy_user->max_speed_generation) {
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700248 case SCIC_SDS_PARM_GEN3_SPEED:
249 link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3;
250 break;
251 case SCIC_SDS_PARM_GEN2_SPEED:
252 link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2;
253 break;
254 default:
255 link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1;
256 break;
257 }
258 llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate);
Dan Williams2e5da882012-01-04 01:32:34 -0800259 writel(llctl, &llr->link_layer_control);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700260
Dan Williams2e5da882012-01-04 01:32:34 -0800261 sp_timeouts = readl(&llr->sas_phy_timeouts);
Marcin Tomczak985af6f2011-07-29 17:16:50 -0700262
263 /* Clear the default 0x36 (54us) RATE_CHANGE timeout value. */
264 sp_timeouts &= ~SCU_SAS_PHYTOV_GEN_VAL(RATE_CHANGE, 0xFF);
265
266 /* Set RATE_CHANGE timeout value to 0x3B (59us). This ensures SCU can
267 * lock with 3Gb drive when SCU max rate is set to 1.5Gb.
268 */
269 sp_timeouts |= SCU_SAS_PHYTOV_GEN_VAL(RATE_CHANGE, 0x3B);
270
Dan Williams2e5da882012-01-04 01:32:34 -0800271 writel(sp_timeouts, &llr->sas_phy_timeouts);
Marcin Tomczak985af6f2011-07-29 17:16:50 -0700272
Dan Williamsdc00c8b2011-07-01 11:41:21 -0700273 if (is_a2(ihost->pdev)) {
Dan Williams2e5da882012-01-04 01:32:34 -0800274 /* Program the max ARB time for the PHY to 700us so we
275 * inter-operate with the PMC expander which shuts down
276 * PHYs if the expander PHY generates too many breaks.
277 * This time value will guarantee that the initiator PHY
278 * will generate the break.
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700279 */
280 writel(SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME,
Dan Williams2e5da882012-01-04 01:32:34 -0800281 &llr->maximum_arbitration_wait_timer_timeout);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700282 }
283
Dan Williams2e5da882012-01-04 01:32:34 -0800284 /* Disable link layer hang detection, rely on the OS timeout for
285 * I/O timeouts.
286 */
287 writel(0, &llr->link_layer_hang_detection_timeout);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700288
289 /* We can exit the initial state to the stopped state */
Dan Williams85280952011-06-28 15:05:53 -0700290 sci_change_state(&iphy->sm, SCI_PHY_STOPPED);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700291
292 return SCI_SUCCESS;
293}
294
Edmund Nadolskia628d472011-05-19 11:59:36 +0000295static void phy_sata_timeout(unsigned long data)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700296{
Edmund Nadolskia628d472011-05-19 11:59:36 +0000297 struct sci_timer *tmr = (struct sci_timer *)data;
Dan Williams85280952011-06-28 15:05:53 -0700298 struct isci_phy *iphy = container_of(tmr, typeof(*iphy), sata_timer);
Dan Williamsd9dcb4b2011-06-30 17:38:32 -0700299 struct isci_host *ihost = iphy->owning_port->owning_controller;
Edmund Nadolskia628d472011-05-19 11:59:36 +0000300 unsigned long flags;
301
302 spin_lock_irqsave(&ihost->scic_lock, flags);
303
304 if (tmr->cancel)
305 goto done;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700306
Dan Williams85280952011-06-28 15:05:53 -0700307 dev_dbg(sciphy_to_dev(iphy),
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700308 "%s: SCIC SDS Phy 0x%p did not receive signature fis before "
309 "timeout.\n",
310 __func__,
Dan Williams85280952011-06-28 15:05:53 -0700311 iphy);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700312
Dan Williams85280952011-06-28 15:05:53 -0700313 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Edmund Nadolskia628d472011-05-19 11:59:36 +0000314done:
315 spin_unlock_irqrestore(&ihost->scic_lock, flags);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700316}
317
318/**
319 * This method returns the port currently containing this phy. If the phy is
320 * currently contained by the dummy port, then the phy is considered to not
321 * be part of a port.
322 * @sci_phy: This parameter specifies the phy for which to retrieve the
323 * containing port.
324 *
325 * This method returns a handle to a port that contains the supplied phy.
326 * NULL This value is returned if the phy is not part of a real
327 * port (i.e. it's contained in the dummy port). !NULL All other
328 * values indicate a handle/pointer to the port containing the phy.
329 */
Dan Williams34a99152011-07-01 02:25:15 -0700330struct isci_port *phy_get_non_dummy_port(struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700331{
Dan Williams34a99152011-07-01 02:25:15 -0700332 struct isci_port *iport = iphy->owning_port;
333
334 if (iport->physical_port_index == SCIC_SDS_DUMMY_PORT)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700335 return NULL;
336
Dan Williams85280952011-06-28 15:05:53 -0700337 return iphy->owning_port;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700338}
339
340/**
341 * This method will assign a port to the phy object.
Dan Williams85280952011-06-28 15:05:53 -0700342 * @out]: iphy This parameter specifies the phy for which to assign a port
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700343 * object.
344 *
345 *
346 */
Dan Williams89a73012011-06-30 19:14:33 -0700347void sci_phy_set_port(
Dan Williams85280952011-06-28 15:05:53 -0700348 struct isci_phy *iphy,
Dan Williamsffe191c2011-06-29 13:09:25 -0700349 struct isci_port *iport)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700350{
Dan Williamsffe191c2011-06-29 13:09:25 -0700351 iphy->owning_port = iport;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700352
Dan Williams85280952011-06-28 15:05:53 -0700353 if (iphy->bcn_received_while_port_unassigned) {
354 iphy->bcn_received_while_port_unassigned = false;
Dan Williams89a73012011-06-30 19:14:33 -0700355 sci_port_broadcast_change_received(iphy->owning_port, iphy);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700356 }
357}
358
Dan Williams89a73012011-06-30 19:14:33 -0700359enum sci_status sci_phy_initialize(struct isci_phy *iphy,
360 struct scu_transport_layer_registers __iomem *tl,
361 struct scu_link_layer_registers __iomem *ll)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700362{
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700363 /* Perfrom the initialization of the TL hardware */
Dan Williams89a73012011-06-30 19:14:33 -0700364 sci_phy_transport_layer_initialization(iphy, tl);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700365
366 /* Perofrm the initialization of the PE hardware */
Dan Williams89a73012011-06-30 19:14:33 -0700367 sci_phy_link_layer_initialization(iphy, ll);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700368
Dan Williams89a73012011-06-30 19:14:33 -0700369 /* There is nothing that needs to be done in this state just
370 * transition to the stopped state
371 */
Dan Williams85280952011-06-28 15:05:53 -0700372 sci_change_state(&iphy->sm, SCI_PHY_STOPPED);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700373
374 return SCI_SUCCESS;
375}
376
377/**
378 * This method assigns the direct attached device ID for this phy.
379 *
Dan Williams85280952011-06-28 15:05:53 -0700380 * @iphy The phy for which the direct attached device id is to
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700381 * be assigned.
382 * @device_id The direct attached device ID to assign to the phy.
383 * This will either be the RNi for the device or an invalid RNi if there
384 * is no current device assigned to the phy.
385 */
Dan Williams89a73012011-06-30 19:14:33 -0700386void sci_phy_setup_transport(struct isci_phy *iphy, u32 device_id)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700387{
388 u32 tl_control;
389
Dan Williams85280952011-06-28 15:05:53 -0700390 writel(device_id, &iphy->transport_layer_registers->stp_rni);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700391
392 /*
393 * The read should guarantee that the first write gets posted
394 * before the next write
395 */
Dan Williams85280952011-06-28 15:05:53 -0700396 tl_control = readl(&iphy->transport_layer_registers->control);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700397 tl_control |= SCU_TLCR_GEN_BIT(CLEAR_TCI_NCQ_MAPPING_TABLE);
Dan Williams85280952011-06-28 15:05:53 -0700398 writel(tl_control, &iphy->transport_layer_registers->control);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700399}
400
Dan Williams89a73012011-06-30 19:14:33 -0700401static void sci_phy_suspend(struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700402{
403 u32 scu_sas_pcfg_value;
404
405 scu_sas_pcfg_value =
Dan Williams85280952011-06-28 15:05:53 -0700406 readl(&iphy->link_layer_registers->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700407 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
408 writel(scu_sas_pcfg_value,
Dan Williams85280952011-06-28 15:05:53 -0700409 &iphy->link_layer_registers->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700410
Dan Williams89a73012011-06-30 19:14:33 -0700411 sci_phy_setup_transport(iphy, SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700412}
413
Dan Williams89a73012011-06-30 19:14:33 -0700414void sci_phy_resume(struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700415{
416 u32 scu_sas_pcfg_value;
417
418 scu_sas_pcfg_value =
Dan Williams85280952011-06-28 15:05:53 -0700419 readl(&iphy->link_layer_registers->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700420 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
421 writel(scu_sas_pcfg_value,
Dan Williams85280952011-06-28 15:05:53 -0700422 &iphy->link_layer_registers->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700423}
424
Dan Williams89a73012011-06-30 19:14:33 -0700425void sci_phy_get_sas_address(struct isci_phy *iphy, struct sci_sas_address *sas)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700426{
Dan Williams89a73012011-06-30 19:14:33 -0700427 sas->high = readl(&iphy->link_layer_registers->source_sas_address_high);
428 sas->low = readl(&iphy->link_layer_registers->source_sas_address_low);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700429}
430
Dan Williams89a73012011-06-30 19:14:33 -0700431void sci_phy_get_attached_sas_address(struct isci_phy *iphy, struct sci_sas_address *sas)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700432{
433 struct sas_identify_frame *iaf;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700434
435 iaf = &iphy->frame_rcvd.iaf;
Dan Williams89a73012011-06-30 19:14:33 -0700436 memcpy(sas, iaf->sas_addr, SAS_ADDR_SIZE);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700437}
438
Dan Williams89a73012011-06-30 19:14:33 -0700439void sci_phy_get_protocols(struct isci_phy *iphy, struct sci_phy_proto *proto)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700440{
Dan Williams89a73012011-06-30 19:14:33 -0700441 proto->all = readl(&iphy->link_layer_registers->transmit_identification);
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700442}
443
Dan Williams89a73012011-06-30 19:14:33 -0700444enum sci_status sci_phy_start(struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700445{
Dan Williams89a73012011-06-30 19:14:33 -0700446 enum sci_phy_states state = iphy->sm.current_state_id;
Dan Williams966699b2011-05-12 03:44:24 -0700447
Edmund Nadolskie3013702011-06-02 00:10:43 +0000448 if (state != SCI_PHY_STOPPED) {
Dan Williams85280952011-06-28 15:05:53 -0700449 dev_dbg(sciphy_to_dev(iphy),
Dan Williams966699b2011-05-12 03:44:24 -0700450 "%s: in wrong state: %d\n", __func__, state);
451 return SCI_FAILURE_INVALID_STATE;
452 }
453
Dan Williams85280952011-06-28 15:05:53 -0700454 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams966699b2011-05-12 03:44:24 -0700455 return SCI_SUCCESS;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700456}
457
Dan Williams89a73012011-06-30 19:14:33 -0700458enum sci_status sci_phy_stop(struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700459{
Dan Williams89a73012011-06-30 19:14:33 -0700460 enum sci_phy_states state = iphy->sm.current_state_id;
Dan Williams93153232011-05-12 04:01:03 -0700461
462 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +0000463 case SCI_PHY_SUB_INITIAL:
464 case SCI_PHY_SUB_AWAIT_OSSP_EN:
465 case SCI_PHY_SUB_AWAIT_SAS_SPEED_EN:
466 case SCI_PHY_SUB_AWAIT_SAS_POWER:
467 case SCI_PHY_SUB_AWAIT_SATA_POWER:
468 case SCI_PHY_SUB_AWAIT_SATA_PHY_EN:
469 case SCI_PHY_SUB_AWAIT_SATA_SPEED_EN:
470 case SCI_PHY_SUB_AWAIT_SIG_FIS_UF:
471 case SCI_PHY_SUB_FINAL:
472 case SCI_PHY_READY:
Dan Williams93153232011-05-12 04:01:03 -0700473 break;
474 default:
Dan Williams85280952011-06-28 15:05:53 -0700475 dev_dbg(sciphy_to_dev(iphy),
Dan Williams93153232011-05-12 04:01:03 -0700476 "%s: in wrong state: %d\n", __func__, state);
477 return SCI_FAILURE_INVALID_STATE;
478 }
479
Dan Williams85280952011-06-28 15:05:53 -0700480 sci_change_state(&iphy->sm, SCI_PHY_STOPPED);
Dan Williams93153232011-05-12 04:01:03 -0700481 return SCI_SUCCESS;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700482}
483
Dan Williams89a73012011-06-30 19:14:33 -0700484enum sci_status sci_phy_reset(struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700485{
Dan Williams89a73012011-06-30 19:14:33 -0700486 enum sci_phy_states state = iphy->sm.current_state_id;
Dan Williams0cf36fa2011-05-12 04:02:07 -0700487
Edmund Nadolskie3013702011-06-02 00:10:43 +0000488 if (state != SCI_PHY_READY) {
Dan Williams85280952011-06-28 15:05:53 -0700489 dev_dbg(sciphy_to_dev(iphy),
Dan Williams0cf36fa2011-05-12 04:02:07 -0700490 "%s: in wrong state: %d\n", __func__, state);
491 return SCI_FAILURE_INVALID_STATE;
492 }
493
Dan Williams85280952011-06-28 15:05:53 -0700494 sci_change_state(&iphy->sm, SCI_PHY_RESETTING);
Dan Williams0cf36fa2011-05-12 04:02:07 -0700495 return SCI_SUCCESS;
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700496}
497
Dan Williams89a73012011-06-30 19:14:33 -0700498enum sci_status sci_phy_consume_power_handler(struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700499{
Dan Williams89a73012011-06-30 19:14:33 -0700500 enum sci_phy_states state = iphy->sm.current_state_id;
Dan Williams5b1d4af2011-05-12 04:51:41 -0700501
502 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +0000503 case SCI_PHY_SUB_AWAIT_SAS_POWER: {
Dan Williams5b1d4af2011-05-12 04:51:41 -0700504 u32 enable_spinup;
505
Dan Williams85280952011-06-28 15:05:53 -0700506 enable_spinup = readl(&iphy->link_layer_registers->notify_enable_spinup_control);
Dan Williams5b1d4af2011-05-12 04:51:41 -0700507 enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE);
Dan Williams85280952011-06-28 15:05:53 -0700508 writel(enable_spinup, &iphy->link_layer_registers->notify_enable_spinup_control);
Dan Williams5b1d4af2011-05-12 04:51:41 -0700509
510 /* Change state to the final state this substate machine has run to completion */
Dan Williams85280952011-06-28 15:05:53 -0700511 sci_change_state(&iphy->sm, SCI_PHY_SUB_FINAL);
Dan Williams5b1d4af2011-05-12 04:51:41 -0700512
513 return SCI_SUCCESS;
514 }
Edmund Nadolskie3013702011-06-02 00:10:43 +0000515 case SCI_PHY_SUB_AWAIT_SATA_POWER: {
Dan Williams5b1d4af2011-05-12 04:51:41 -0700516 u32 scu_sas_pcfg_value;
517
518 /* Release the spinup hold state and reset the OOB state machine */
519 scu_sas_pcfg_value =
Dan Williams85280952011-06-28 15:05:53 -0700520 readl(&iphy->link_layer_registers->phy_configuration);
Dan Williams5b1d4af2011-05-12 04:51:41 -0700521 scu_sas_pcfg_value &=
522 ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE));
523 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
524 writel(scu_sas_pcfg_value,
Dan Williams85280952011-06-28 15:05:53 -0700525 &iphy->link_layer_registers->phy_configuration);
Dan Williams5b1d4af2011-05-12 04:51:41 -0700526
527 /* Now restart the OOB operation */
528 scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
529 scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
530 writel(scu_sas_pcfg_value,
Dan Williams85280952011-06-28 15:05:53 -0700531 &iphy->link_layer_registers->phy_configuration);
Dan Williams5b1d4af2011-05-12 04:51:41 -0700532
533 /* Change state to the final state this substate machine has run to completion */
Dan Williams85280952011-06-28 15:05:53 -0700534 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_PHY_EN);
Dan Williams5b1d4af2011-05-12 04:51:41 -0700535
536 return SCI_SUCCESS;
537 }
538 default:
Dan Williams85280952011-06-28 15:05:53 -0700539 dev_dbg(sciphy_to_dev(iphy),
Dan Williams5b1d4af2011-05-12 04:51:41 -0700540 "%s: in wrong state: %d\n", __func__, state);
541 return SCI_FAILURE_INVALID_STATE;
542 }
Dan Williams23506a62011-05-12 04:27:29 -0700543}
544
Dan Williams89a73012011-06-30 19:14:33 -0700545static void sci_phy_start_sas_link_training(struct isci_phy *iphy)
Dan Williams23506a62011-05-12 04:27:29 -0700546{
Dan Williams89a73012011-06-30 19:14:33 -0700547 /* continue the link training for the phy as if it were a SAS PHY
548 * instead of a SATA PHY. This is done because the completion queue had a SAS
549 * PHY DETECTED event when the state machine was expecting a SATA PHY event.
550 */
Dan Williams23506a62011-05-12 04:27:29 -0700551 u32 phy_control;
552
Dan Williams89a73012011-06-30 19:14:33 -0700553 phy_control = readl(&iphy->link_layer_registers->phy_configuration);
Dan Williams23506a62011-05-12 04:27:29 -0700554 phy_control |= SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD);
555 writel(phy_control,
Dan Williams89a73012011-06-30 19:14:33 -0700556 &iphy->link_layer_registers->phy_configuration);
Dan Williams23506a62011-05-12 04:27:29 -0700557
Dan Williams85280952011-06-28 15:05:53 -0700558 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SAS_SPEED_EN);
Dan Williams23506a62011-05-12 04:27:29 -0700559
Dan Williams85280952011-06-28 15:05:53 -0700560 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS;
Dan Williams23506a62011-05-12 04:27:29 -0700561}
562
Dan Williams89a73012011-06-30 19:14:33 -0700563static void sci_phy_start_sata_link_training(struct isci_phy *iphy)
Dan Williams23506a62011-05-12 04:27:29 -0700564{
Dan Williams89a73012011-06-30 19:14:33 -0700565 /* This method continues the link training for the phy as if it were a SATA PHY
566 * instead of a SAS PHY. This is done because the completion queue had a SATA
567 * SPINUP HOLD event when the state machine was expecting a SAS PHY event. none
568 */
Dan Williams85280952011-06-28 15:05:53 -0700569 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_POWER);
Dan Williams23506a62011-05-12 04:27:29 -0700570
Dan Williams85280952011-06-28 15:05:53 -0700571 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
Dan Williams23506a62011-05-12 04:27:29 -0700572}
573
574/**
Dan Williams89a73012011-06-30 19:14:33 -0700575 * sci_phy_complete_link_training - perform processing common to
Dan Williams23506a62011-05-12 04:27:29 -0700576 * all protocols upon completion of link training.
577 * @sci_phy: This parameter specifies the phy object for which link training
578 * has completed.
579 * @max_link_rate: This parameter specifies the maximum link rate to be
580 * associated with this phy.
581 * @next_state: This parameter specifies the next state for the phy's starting
582 * sub-state machine.
583 *
584 */
Dan Williams89a73012011-06-30 19:14:33 -0700585static void sci_phy_complete_link_training(struct isci_phy *iphy,
586 enum sas_linkrate max_link_rate,
587 u32 next_state)
Dan Williams23506a62011-05-12 04:27:29 -0700588{
Dan Williams85280952011-06-28 15:05:53 -0700589 iphy->max_negotiated_speed = max_link_rate;
Dan Williams23506a62011-05-12 04:27:29 -0700590
Dan Williams85280952011-06-28 15:05:53 -0700591 sci_change_state(&iphy->sm, next_state);
Dan Williams23506a62011-05-12 04:27:29 -0700592}
593
Dan Williams89a73012011-06-30 19:14:33 -0700594enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
Dan Williams23506a62011-05-12 04:27:29 -0700595{
Dan Williams89a73012011-06-30 19:14:33 -0700596 enum sci_phy_states state = iphy->sm.current_state_id;
Dan Williams23506a62011-05-12 04:27:29 -0700597
598 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +0000599 case SCI_PHY_SUB_AWAIT_OSSP_EN:
Dan Williams23506a62011-05-12 04:27:29 -0700600 switch (scu_get_event_code(event_code)) {
601 case SCU_EVENT_SAS_PHY_DETECTED:
Dan Williams89a73012011-06-30 19:14:33 -0700602 sci_phy_start_sas_link_training(iphy);
Dan Williams85280952011-06-28 15:05:53 -0700603 iphy->is_in_link_training = true;
Dan Williams23506a62011-05-12 04:27:29 -0700604 break;
605 case SCU_EVENT_SATA_SPINUP_HOLD:
Dan Williams89a73012011-06-30 19:14:33 -0700606 sci_phy_start_sata_link_training(iphy);
Dan Williams85280952011-06-28 15:05:53 -0700607 iphy->is_in_link_training = true;
Dan Williams23506a62011-05-12 04:27:29 -0700608 break;
609 default:
Dan Williams85280952011-06-28 15:05:53 -0700610 dev_dbg(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700611 "%s: PHY starting substate machine received "
612 "unexpected event_code %x\n",
613 __func__,
614 event_code);
615 return SCI_FAILURE;
616 }
617 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000618 case SCI_PHY_SUB_AWAIT_SAS_SPEED_EN:
Dan Williams23506a62011-05-12 04:27:29 -0700619 switch (scu_get_event_code(event_code)) {
620 case SCU_EVENT_SAS_PHY_DETECTED:
621 /*
622 * Why is this being reported again by the controller?
623 * We would re-enter this state so just stay here */
624 break;
625 case SCU_EVENT_SAS_15:
626 case SCU_EVENT_SAS_15_SSC:
Dan Williams89a73012011-06-30 19:14:33 -0700627 sci_phy_complete_link_training(iphy, SAS_LINK_RATE_1_5_GBPS,
628 SCI_PHY_SUB_AWAIT_IAF_UF);
Dan Williams23506a62011-05-12 04:27:29 -0700629 break;
630 case SCU_EVENT_SAS_30:
631 case SCU_EVENT_SAS_30_SSC:
Dan Williams89a73012011-06-30 19:14:33 -0700632 sci_phy_complete_link_training(iphy, SAS_LINK_RATE_3_0_GBPS,
633 SCI_PHY_SUB_AWAIT_IAF_UF);
Dan Williams23506a62011-05-12 04:27:29 -0700634 break;
635 case SCU_EVENT_SAS_60:
636 case SCU_EVENT_SAS_60_SSC:
Dan Williams89a73012011-06-30 19:14:33 -0700637 sci_phy_complete_link_training(iphy, SAS_LINK_RATE_6_0_GBPS,
638 SCI_PHY_SUB_AWAIT_IAF_UF);
Dan Williams23506a62011-05-12 04:27:29 -0700639 break;
640 case SCU_EVENT_SATA_SPINUP_HOLD:
641 /*
642 * We were doing SAS PHY link training and received a SATA PHY event
643 * continue OOB/SN as if this were a SATA PHY */
Dan Williams89a73012011-06-30 19:14:33 -0700644 sci_phy_start_sata_link_training(iphy);
Dan Williams23506a62011-05-12 04:27:29 -0700645 break;
646 case SCU_EVENT_LINK_FAILURE:
647 /* Link failure change state back to the starting state */
Dan Williams85280952011-06-28 15:05:53 -0700648 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams23506a62011-05-12 04:27:29 -0700649 break;
650 default:
Dan Williams85280952011-06-28 15:05:53 -0700651 dev_warn(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700652 "%s: PHY starting substate machine received "
653 "unexpected event_code %x\n",
654 __func__, event_code);
655
656 return SCI_FAILURE;
657 break;
658 }
659 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000660 case SCI_PHY_SUB_AWAIT_IAF_UF:
Dan Williams23506a62011-05-12 04:27:29 -0700661 switch (scu_get_event_code(event_code)) {
662 case SCU_EVENT_SAS_PHY_DETECTED:
663 /* Backup the state machine */
Dan Williams89a73012011-06-30 19:14:33 -0700664 sci_phy_start_sas_link_training(iphy);
Dan Williams23506a62011-05-12 04:27:29 -0700665 break;
666 case SCU_EVENT_SATA_SPINUP_HOLD:
667 /* We were doing SAS PHY link training and received a
668 * SATA PHY event continue OOB/SN as if this were a
669 * SATA PHY
670 */
Dan Williams89a73012011-06-30 19:14:33 -0700671 sci_phy_start_sata_link_training(iphy);
Dan Williams23506a62011-05-12 04:27:29 -0700672 break;
673 case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT:
674 case SCU_EVENT_LINK_FAILURE:
675 case SCU_EVENT_HARD_RESET_RECEIVED:
676 /* Start the oob/sn state machine over again */
Dan Williams85280952011-06-28 15:05:53 -0700677 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams23506a62011-05-12 04:27:29 -0700678 break;
679 default:
Dan Williams85280952011-06-28 15:05:53 -0700680 dev_warn(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700681 "%s: PHY starting substate machine received "
682 "unexpected event_code %x\n",
683 __func__, event_code);
684 return SCI_FAILURE;
685 }
686 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000687 case SCI_PHY_SUB_AWAIT_SAS_POWER:
Dan Williams23506a62011-05-12 04:27:29 -0700688 switch (scu_get_event_code(event_code)) {
689 case SCU_EVENT_LINK_FAILURE:
690 /* Link failure change state back to the starting state */
Dan Williams85280952011-06-28 15:05:53 -0700691 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams23506a62011-05-12 04:27:29 -0700692 break;
693 default:
Dan Williams85280952011-06-28 15:05:53 -0700694 dev_warn(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700695 "%s: PHY starting substate machine received unexpected "
696 "event_code %x\n",
697 __func__,
698 event_code);
699 return SCI_FAILURE;
700 }
701 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000702 case SCI_PHY_SUB_AWAIT_SATA_POWER:
Dan Williams23506a62011-05-12 04:27:29 -0700703 switch (scu_get_event_code(event_code)) {
704 case SCU_EVENT_LINK_FAILURE:
705 /* Link failure change state back to the starting state */
Dan Williams85280952011-06-28 15:05:53 -0700706 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams23506a62011-05-12 04:27:29 -0700707 break;
708 case SCU_EVENT_SATA_SPINUP_HOLD:
709 /* These events are received every 10ms and are
710 * expected while in this state
711 */
712 break;
713
714 case SCU_EVENT_SAS_PHY_DETECTED:
715 /* There has been a change in the phy type before OOB/SN for the
716 * SATA finished start down the SAS link traning path.
717 */
Dan Williams89a73012011-06-30 19:14:33 -0700718 sci_phy_start_sas_link_training(iphy);
Dan Williams23506a62011-05-12 04:27:29 -0700719 break;
720
721 default:
Dan Williams85280952011-06-28 15:05:53 -0700722 dev_warn(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700723 "%s: PHY starting substate machine received "
724 "unexpected event_code %x\n",
725 __func__, event_code);
726
727 return SCI_FAILURE;
728 }
729 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000730 case SCI_PHY_SUB_AWAIT_SATA_PHY_EN:
Dan Williams23506a62011-05-12 04:27:29 -0700731 switch (scu_get_event_code(event_code)) {
732 case SCU_EVENT_LINK_FAILURE:
733 /* Link failure change state back to the starting state */
Dan Williams85280952011-06-28 15:05:53 -0700734 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams23506a62011-05-12 04:27:29 -0700735 break;
736 case SCU_EVENT_SATA_SPINUP_HOLD:
737 /* These events might be received since we dont know how many may be in
738 * the completion queue while waiting for power
739 */
740 break;
741 case SCU_EVENT_SATA_PHY_DETECTED:
Dan Williams85280952011-06-28 15:05:53 -0700742 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
Dan Williams23506a62011-05-12 04:27:29 -0700743
744 /* We have received the SATA PHY notification change state */
Dan Williams85280952011-06-28 15:05:53 -0700745 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN);
Dan Williams23506a62011-05-12 04:27:29 -0700746 break;
747 case SCU_EVENT_SAS_PHY_DETECTED:
748 /* There has been a change in the phy type before OOB/SN for the
749 * SATA finished start down the SAS link traning path.
750 */
Dan Williams89a73012011-06-30 19:14:33 -0700751 sci_phy_start_sas_link_training(iphy);
Dan Williams23506a62011-05-12 04:27:29 -0700752 break;
753 default:
Dan Williams85280952011-06-28 15:05:53 -0700754 dev_warn(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700755 "%s: PHY starting substate machine received "
756 "unexpected event_code %x\n",
757 __func__,
758 event_code);
759
Justin P. Mattock69932482011-07-26 23:06:29 -0700760 return SCI_FAILURE;
Dan Williams23506a62011-05-12 04:27:29 -0700761 }
762 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000763 case SCI_PHY_SUB_AWAIT_SATA_SPEED_EN:
Dan Williams23506a62011-05-12 04:27:29 -0700764 switch (scu_get_event_code(event_code)) {
765 case SCU_EVENT_SATA_PHY_DETECTED:
766 /*
767 * The hardware reports multiple SATA PHY detected events
768 * ignore the extras */
769 break;
770 case SCU_EVENT_SATA_15:
771 case SCU_EVENT_SATA_15_SSC:
Dan Williams89a73012011-06-30 19:14:33 -0700772 sci_phy_complete_link_training(iphy, SAS_LINK_RATE_1_5_GBPS,
773 SCI_PHY_SUB_AWAIT_SIG_FIS_UF);
Dan Williams23506a62011-05-12 04:27:29 -0700774 break;
775 case SCU_EVENT_SATA_30:
776 case SCU_EVENT_SATA_30_SSC:
Dan Williams89a73012011-06-30 19:14:33 -0700777 sci_phy_complete_link_training(iphy, SAS_LINK_RATE_3_0_GBPS,
778 SCI_PHY_SUB_AWAIT_SIG_FIS_UF);
Dan Williams23506a62011-05-12 04:27:29 -0700779 break;
780 case SCU_EVENT_SATA_60:
781 case SCU_EVENT_SATA_60_SSC:
Dan Williams89a73012011-06-30 19:14:33 -0700782 sci_phy_complete_link_training(iphy, SAS_LINK_RATE_6_0_GBPS,
783 SCI_PHY_SUB_AWAIT_SIG_FIS_UF);
Dan Williams23506a62011-05-12 04:27:29 -0700784 break;
785 case SCU_EVENT_LINK_FAILURE:
786 /* Link failure change state back to the starting state */
Dan Williams85280952011-06-28 15:05:53 -0700787 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams23506a62011-05-12 04:27:29 -0700788 break;
789 case SCU_EVENT_SAS_PHY_DETECTED:
790 /*
791 * There has been a change in the phy type before OOB/SN for the
792 * SATA finished start down the SAS link traning path. */
Dan Williams89a73012011-06-30 19:14:33 -0700793 sci_phy_start_sas_link_training(iphy);
Dan Williams23506a62011-05-12 04:27:29 -0700794 break;
795 default:
Dan Williams85280952011-06-28 15:05:53 -0700796 dev_warn(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700797 "%s: PHY starting substate machine received "
798 "unexpected event_code %x\n",
799 __func__, event_code);
800
801 return SCI_FAILURE;
802 }
803
804 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000805 case SCI_PHY_SUB_AWAIT_SIG_FIS_UF:
Dan Williams23506a62011-05-12 04:27:29 -0700806 switch (scu_get_event_code(event_code)) {
807 case SCU_EVENT_SATA_PHY_DETECTED:
808 /* Backup the state machine */
Dan Williams85280952011-06-28 15:05:53 -0700809 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_SATA_SPEED_EN);
Dan Williams23506a62011-05-12 04:27:29 -0700810 break;
811
812 case SCU_EVENT_LINK_FAILURE:
813 /* Link failure change state back to the starting state */
Dan Williams85280952011-06-28 15:05:53 -0700814 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams23506a62011-05-12 04:27:29 -0700815 break;
816
817 default:
Dan Williams85280952011-06-28 15:05:53 -0700818 dev_warn(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700819 "%s: PHY starting substate machine received "
820 "unexpected event_code %x\n",
821 __func__,
822 event_code);
823
824 return SCI_FAILURE;
825 }
826 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000827 case SCI_PHY_READY:
Dan Williams23506a62011-05-12 04:27:29 -0700828 switch (scu_get_event_code(event_code)) {
829 case SCU_EVENT_LINK_FAILURE:
830 /* Link failure change state back to the starting state */
Dan Williams85280952011-06-28 15:05:53 -0700831 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams23506a62011-05-12 04:27:29 -0700832 break;
833 case SCU_EVENT_BROADCAST_CHANGE:
834 /* Broadcast change received. Notify the port. */
Dan Williams85280952011-06-28 15:05:53 -0700835 if (phy_get_non_dummy_port(iphy) != NULL)
Dan Williams89a73012011-06-30 19:14:33 -0700836 sci_port_broadcast_change_received(iphy->owning_port, iphy);
Dan Williams23506a62011-05-12 04:27:29 -0700837 else
Dan Williams85280952011-06-28 15:05:53 -0700838 iphy->bcn_received_while_port_unassigned = true;
Dan Williams23506a62011-05-12 04:27:29 -0700839 break;
840 default:
Dan Williams85280952011-06-28 15:05:53 -0700841 dev_warn(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700842 "%sP SCIC PHY 0x%p ready state machine received "
843 "unexpected event_code %x\n",
Dan Williams85280952011-06-28 15:05:53 -0700844 __func__, iphy, event_code);
Dan Williams23506a62011-05-12 04:27:29 -0700845 return SCI_FAILURE_INVALID_STATE;
846 }
847 return SCI_SUCCESS;
Edmund Nadolskie3013702011-06-02 00:10:43 +0000848 case SCI_PHY_RESETTING:
Dan Williams23506a62011-05-12 04:27:29 -0700849 switch (scu_get_event_code(event_code)) {
850 case SCU_EVENT_HARD_RESET_TRANSMITTED:
851 /* Link failure change state back to the starting state */
Dan Williams85280952011-06-28 15:05:53 -0700852 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williams23506a62011-05-12 04:27:29 -0700853 break;
854 default:
Dan Williams85280952011-06-28 15:05:53 -0700855 dev_warn(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700856 "%s: SCIC PHY 0x%p resetting state machine received "
857 "unexpected event_code %x\n",
Dan Williams85280952011-06-28 15:05:53 -0700858 __func__, iphy, event_code);
Dan Williams23506a62011-05-12 04:27:29 -0700859
860 return SCI_FAILURE_INVALID_STATE;
861 break;
862 }
863 return SCI_SUCCESS;
864 default:
Dan Williams85280952011-06-28 15:05:53 -0700865 dev_dbg(sciphy_to_dev(iphy),
Dan Williams23506a62011-05-12 04:27:29 -0700866 "%s: in wrong state: %d\n", __func__, state);
867 return SCI_FAILURE_INVALID_STATE;
868 }
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700869}
870
Dan Williams89a73012011-06-30 19:14:33 -0700871enum sci_status sci_phy_frame_handler(struct isci_phy *iphy, u32 frame_index)
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700872{
Dan Williams89a73012011-06-30 19:14:33 -0700873 enum sci_phy_states state = iphy->sm.current_state_id;
Dan Williamsd9dcb4b2011-06-30 17:38:32 -0700874 struct isci_host *ihost = iphy->owning_port->owning_controller;
Dan Williamsc4441ab2011-05-12 04:17:51 -0700875 enum sci_status result;
Dan Williams4cffe132011-06-23 23:44:52 -0700876 unsigned long flags;
Dan Williamsc4441ab2011-05-12 04:17:51 -0700877
878 switch (state) {
Edmund Nadolskie3013702011-06-02 00:10:43 +0000879 case SCI_PHY_SUB_AWAIT_IAF_UF: {
Dan Williamsc4441ab2011-05-12 04:17:51 -0700880 u32 *frame_words;
881 struct sas_identify_frame iaf;
Dan Williamsc4441ab2011-05-12 04:17:51 -0700882
Dan Williams89a73012011-06-30 19:14:33 -0700883 result = sci_unsolicited_frame_control_get_header(&ihost->uf_control,
884 frame_index,
885 (void **)&frame_words);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700886
887 if (result != SCI_SUCCESS)
888 return result;
889
890 sci_swab32_cpy(&iaf, frame_words, sizeof(iaf) / sizeof(u32));
891 if (iaf.frame_type == 0) {
892 u32 state;
893
Dan Williams4cffe132011-06-23 23:44:52 -0700894 spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700895 memcpy(&iphy->frame_rcvd.iaf, &iaf, sizeof(iaf));
Dan Williams4cffe132011-06-23 23:44:52 -0700896 spin_unlock_irqrestore(&iphy->sas_phy.frame_rcvd_lock, flags);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700897 if (iaf.smp_tport) {
898 /* We got the IAF for an expander PHY go to the final
899 * state since there are no power requirements for
900 * expander phys.
901 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000902 state = SCI_PHY_SUB_FINAL;
Dan Williamsc4441ab2011-05-12 04:17:51 -0700903 } else {
904 /* We got the IAF we can now go to the await spinup
905 * semaphore state
906 */
Edmund Nadolskie3013702011-06-02 00:10:43 +0000907 state = SCI_PHY_SUB_AWAIT_SAS_POWER;
Dan Williamsc4441ab2011-05-12 04:17:51 -0700908 }
Dan Williams85280952011-06-28 15:05:53 -0700909 sci_change_state(&iphy->sm, state);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700910 result = SCI_SUCCESS;
911 } else
Dan Williams85280952011-06-28 15:05:53 -0700912 dev_warn(sciphy_to_dev(iphy),
Dan Williamsc4441ab2011-05-12 04:17:51 -0700913 "%s: PHY starting substate machine received "
914 "unexpected frame id %x\n",
915 __func__, frame_index);
916
Dan Williams89a73012011-06-30 19:14:33 -0700917 sci_controller_release_frame(ihost, frame_index);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700918 return result;
919 }
Edmund Nadolskie3013702011-06-02 00:10:43 +0000920 case SCI_PHY_SUB_AWAIT_SIG_FIS_UF: {
Dan Williamsc4441ab2011-05-12 04:17:51 -0700921 struct dev_to_host_fis *frame_header;
922 u32 *fis_frame_data;
Dan Williamsc4441ab2011-05-12 04:17:51 -0700923
Dan Williams34a99152011-07-01 02:25:15 -0700924 result = sci_unsolicited_frame_control_get_header(&ihost->uf_control,
925 frame_index,
926 (void **)&frame_header);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700927
928 if (result != SCI_SUCCESS)
929 return result;
930
931 if ((frame_header->fis_type == FIS_REGD2H) &&
932 !(frame_header->status & ATA_BUSY)) {
Dan Williams89a73012011-06-30 19:14:33 -0700933 sci_unsolicited_frame_control_get_buffer(&ihost->uf_control,
934 frame_index,
935 (void **)&fis_frame_data);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700936
Dan Williams4cffe132011-06-23 23:44:52 -0700937 spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags);
Dan Williams89a73012011-06-30 19:14:33 -0700938 sci_controller_copy_sata_response(&iphy->frame_rcvd.fis,
939 frame_header,
940 fis_frame_data);
Dan Williams4cffe132011-06-23 23:44:52 -0700941 spin_unlock_irqrestore(&iphy->sas_phy.frame_rcvd_lock, flags);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700942
943 /* got IAF we can now go to the await spinup semaphore state */
Dan Williams85280952011-06-28 15:05:53 -0700944 sci_change_state(&iphy->sm, SCI_PHY_SUB_FINAL);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700945
946 result = SCI_SUCCESS;
947 } else
Dan Williams85280952011-06-28 15:05:53 -0700948 dev_warn(sciphy_to_dev(iphy),
Dan Williamsc4441ab2011-05-12 04:17:51 -0700949 "%s: PHY starting substate machine received "
950 "unexpected frame id %x\n",
951 __func__, frame_index);
952
953 /* Regardless of the result we are done with this frame with it */
Dan Williams89a73012011-06-30 19:14:33 -0700954 sci_controller_release_frame(ihost, frame_index);
Dan Williamsc4441ab2011-05-12 04:17:51 -0700955
956 return result;
957 }
958 default:
Dan Williams85280952011-06-28 15:05:53 -0700959 dev_dbg(sciphy_to_dev(iphy),
Dan Williamsc4441ab2011-05-12 04:17:51 -0700960 "%s: in wrong state: %d\n", __func__, state);
961 return SCI_FAILURE_INVALID_STATE;
962 }
Dan Williams5076a1a2011-06-27 14:57:03 -0700963
Dan Williamsd35bc1b2011-05-10 02:28:45 -0700964}
965
Dan Williams89a73012011-06-30 19:14:33 -0700966static void sci_phy_starting_initial_substate_enter(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +0000967{
Dan Williams85280952011-06-28 15:05:53 -0700968 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Adam Gruchala4a33c522011-05-10 23:54:23 +0000969
Adam Gruchala4a33c522011-05-10 23:54:23 +0000970 /* This is just an temporary state go off to the starting state */
Dan Williams85280952011-06-28 15:05:53 -0700971 sci_change_state(&iphy->sm, SCI_PHY_SUB_AWAIT_OSSP_EN);
Adam Gruchala4a33c522011-05-10 23:54:23 +0000972}
973
Dan Williams89a73012011-06-30 19:14:33 -0700974static void sci_phy_starting_await_sas_power_substate_enter(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +0000975{
Dan Williams85280952011-06-28 15:05:53 -0700976 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Dan Williamsd9dcb4b2011-06-30 17:38:32 -0700977 struct isci_host *ihost = iphy->owning_port->owning_controller;
Adam Gruchala4a33c522011-05-10 23:54:23 +0000978
Dan Williams89a73012011-06-30 19:14:33 -0700979 sci_controller_power_control_queue_insert(ihost, iphy);
Adam Gruchala4a33c522011-05-10 23:54:23 +0000980}
981
Dan Williams89a73012011-06-30 19:14:33 -0700982static void sci_phy_starting_await_sas_power_substate_exit(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +0000983{
Dan Williams85280952011-06-28 15:05:53 -0700984 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Dan Williamsd9dcb4b2011-06-30 17:38:32 -0700985 struct isci_host *ihost = iphy->owning_port->owning_controller;
Adam Gruchala4a33c522011-05-10 23:54:23 +0000986
Dan Williams89a73012011-06-30 19:14:33 -0700987 sci_controller_power_control_queue_remove(ihost, iphy);
Adam Gruchala4a33c522011-05-10 23:54:23 +0000988}
989
Dan Williams89a73012011-06-30 19:14:33 -0700990static void sci_phy_starting_await_sata_power_substate_enter(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +0000991{
Dan Williams85280952011-06-28 15:05:53 -0700992 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Dan Williamsd9dcb4b2011-06-30 17:38:32 -0700993 struct isci_host *ihost = iphy->owning_port->owning_controller;
Adam Gruchala4a33c522011-05-10 23:54:23 +0000994
Dan Williams89a73012011-06-30 19:14:33 -0700995 sci_controller_power_control_queue_insert(ihost, iphy);
Adam Gruchala4a33c522011-05-10 23:54:23 +0000996}
997
Dan Williams89a73012011-06-30 19:14:33 -0700998static void sci_phy_starting_await_sata_power_substate_exit(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +0000999{
Dan Williams85280952011-06-28 15:05:53 -07001000 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Dan Williamsd9dcb4b2011-06-30 17:38:32 -07001001 struct isci_host *ihost = iphy->owning_port->owning_controller;
Adam Gruchala4a33c522011-05-10 23:54:23 +00001002
Dan Williams89a73012011-06-30 19:14:33 -07001003 sci_controller_power_control_queue_remove(ihost, iphy);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001004}
1005
Dan Williams89a73012011-06-30 19:14:33 -07001006static void sci_phy_starting_await_sata_phy_substate_enter(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +00001007{
Dan Williams85280952011-06-28 15:05:53 -07001008 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001009
Dan Williams85280952011-06-28 15:05:53 -07001010 sci_mod_timer(&iphy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001011}
1012
Dan Williams89a73012011-06-30 19:14:33 -07001013static void sci_phy_starting_await_sata_phy_substate_exit(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +00001014{
Dan Williams85280952011-06-28 15:05:53 -07001015 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001016
Dan Williams85280952011-06-28 15:05:53 -07001017 sci_del_timer(&iphy->sata_timer);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001018}
1019
Dan Williams89a73012011-06-30 19:14:33 -07001020static void sci_phy_starting_await_sata_speed_substate_enter(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +00001021{
Dan Williams85280952011-06-28 15:05:53 -07001022 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001023
Dan Williams85280952011-06-28 15:05:53 -07001024 sci_mod_timer(&iphy->sata_timer, SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001025}
1026
Dan Williams89a73012011-06-30 19:14:33 -07001027static void sci_phy_starting_await_sata_speed_substate_exit(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +00001028{
Dan Williams85280952011-06-28 15:05:53 -07001029 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001030
Dan Williams85280952011-06-28 15:05:53 -07001031 sci_del_timer(&iphy->sata_timer);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001032}
1033
Dan Williams89a73012011-06-30 19:14:33 -07001034static void sci_phy_starting_await_sig_fis_uf_substate_enter(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +00001035{
Dan Williams85280952011-06-28 15:05:53 -07001036 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001037
Dan Williams89a73012011-06-30 19:14:33 -07001038 if (sci_port_link_detected(iphy->owning_port, iphy)) {
Adam Gruchala4a33c522011-05-10 23:54:23 +00001039
Adam Gruchala4a33c522011-05-10 23:54:23 +00001040 /*
1041 * Clear the PE suspend condition so we can actually
1042 * receive SIG FIS
1043 * The hardware will not respond to the XRDY until the PE
1044 * suspend condition is cleared.
1045 */
Dan Williams89a73012011-06-30 19:14:33 -07001046 sci_phy_resume(iphy);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001047
Dan Williams85280952011-06-28 15:05:53 -07001048 sci_mod_timer(&iphy->sata_timer,
Edmund Nadolskia628d472011-05-19 11:59:36 +00001049 SCIC_SDS_SIGNATURE_FIS_TIMEOUT);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001050 } else
Dan Williams85280952011-06-28 15:05:53 -07001051 iphy->is_in_link_training = false;
Adam Gruchala4a33c522011-05-10 23:54:23 +00001052}
1053
Dan Williams89a73012011-06-30 19:14:33 -07001054static void sci_phy_starting_await_sig_fis_uf_substate_exit(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +00001055{
Dan Williams85280952011-06-28 15:05:53 -07001056 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001057
Dan Williams85280952011-06-28 15:05:53 -07001058 sci_del_timer(&iphy->sata_timer);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001059}
1060
Dan Williams89a73012011-06-30 19:14:33 -07001061static void sci_phy_starting_final_substate_enter(struct sci_base_state_machine *sm)
Adam Gruchala4a33c522011-05-10 23:54:23 +00001062{
Dan Williams85280952011-06-28 15:05:53 -07001063 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001064
Adam Gruchala4a33c522011-05-10 23:54:23 +00001065 /* State machine has run to completion so exit out and change
1066 * the base state machine to the ready state
1067 */
Dan Williams85280952011-06-28 15:05:53 -07001068 sci_change_state(&iphy->sm, SCI_PHY_READY);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001069}
1070
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001071/**
1072 *
Dan Williams85280952011-06-28 15:05:53 -07001073 * @sci_phy: This is the struct isci_phy object to stop.
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001074 *
Dan Williams85280952011-06-28 15:05:53 -07001075 * This method will stop the struct isci_phy object. This does not reset the
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001076 * protocol engine it just suspends it and places it in a state where it will
1077 * not cause the end device to power up. none
1078 */
1079static void scu_link_layer_stop_protocol_engine(
Dan Williams85280952011-06-28 15:05:53 -07001080 struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001081{
1082 u32 scu_sas_pcfg_value;
1083 u32 enable_spinup_value;
1084
1085 /* Suspend the protocol engine and place it in a sata spinup hold state */
1086 scu_sas_pcfg_value =
Dan Williams85280952011-06-28 15:05:53 -07001087 readl(&iphy->link_layer_registers->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001088 scu_sas_pcfg_value |=
1089 (SCU_SAS_PCFG_GEN_BIT(OOB_RESET) |
1090 SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE) |
1091 SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD));
1092 writel(scu_sas_pcfg_value,
Dan Williams85280952011-06-28 15:05:53 -07001093 &iphy->link_layer_registers->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001094
1095 /* Disable the notify enable spinup primitives */
Dan Williams85280952011-06-28 15:05:53 -07001096 enable_spinup_value = readl(&iphy->link_layer_registers->notify_enable_spinup_control);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001097 enable_spinup_value &= ~SCU_ENSPINUP_GEN_BIT(ENABLE);
Dan Williams85280952011-06-28 15:05:53 -07001098 writel(enable_spinup_value, &iphy->link_layer_registers->notify_enable_spinup_control);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001099}
1100
Marcin Tomczak0953dbe2012-01-04 01:33:36 -08001101static void scu_link_layer_start_oob(struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001102{
Marcin Tomczak0953dbe2012-01-04 01:33:36 -08001103 struct scu_link_layer_registers __iomem *ll = iphy->link_layer_registers;
1104 u32 val;
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001105
Marcin Tomczak0953dbe2012-01-04 01:33:36 -08001106 /** Reset OOB sequence - start */
1107 val = readl(&ll->phy_configuration);
1108 val &= ~(SCU_SAS_PCFG_GEN_BIT(OOB_RESET) |
1109 SCU_SAS_PCFG_GEN_BIT(HARD_RESET));
1110 writel(val, &ll->phy_configuration);
1111 readl(&ll->phy_configuration); /* flush */
1112 /** Reset OOB sequence - end */
1113
1114 /** Start OOB sequence - start */
1115 val = readl(&ll->phy_configuration);
1116 val |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
1117 writel(val, &ll->phy_configuration);
1118 readl(&ll->phy_configuration); /* flush */
1119 /** Start OOB sequence - end */
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001120}
1121
1122/**
1123 *
1124 *
1125 * This method will transmit a hard reset request on the specified phy. The SCU
1126 * hardware requires that we reset the OOB state machine and set the hard reset
1127 * bit in the phy configuration register. We then must start OOB over with the
1128 * hard reset bit set.
1129 */
1130static void scu_link_layer_tx_hard_reset(
Dan Williams85280952011-06-28 15:05:53 -07001131 struct isci_phy *iphy)
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001132{
1133 u32 phy_configuration_value;
1134
1135 /*
1136 * SAS Phys must wait for the HARD_RESET_TX event notification to transition
1137 * to the starting state. */
1138 phy_configuration_value =
Dan Williams85280952011-06-28 15:05:53 -07001139 readl(&iphy->link_layer_registers->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001140 phy_configuration_value |=
1141 (SCU_SAS_PCFG_GEN_BIT(HARD_RESET) |
1142 SCU_SAS_PCFG_GEN_BIT(OOB_RESET));
1143 writel(phy_configuration_value,
Dan Williams85280952011-06-28 15:05:53 -07001144 &iphy->link_layer_registers->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001145
1146 /* Now take the OOB state machine out of reset */
1147 phy_configuration_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
1148 phy_configuration_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
1149 writel(phy_configuration_value,
Dan Williams85280952011-06-28 15:05:53 -07001150 &iphy->link_layer_registers->phy_configuration);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001151}
1152
Dan Williams89a73012011-06-30 19:14:33 -07001153static void sci_phy_stopped_state_enter(struct sci_base_state_machine *sm)
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001154{
Dan Williams85280952011-06-28 15:05:53 -07001155 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Dan Williams34a99152011-07-01 02:25:15 -07001156 struct isci_port *iport = iphy->owning_port;
1157 struct isci_host *ihost = iport->owning_controller;
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001158
1159 /*
1160 * @todo We need to get to the controller to place this PE in a
1161 * reset state
1162 */
Dan Williams85280952011-06-28 15:05:53 -07001163 sci_del_timer(&iphy->sata_timer);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001164
Dan Williams85280952011-06-28 15:05:53 -07001165 scu_link_layer_stop_protocol_engine(iphy);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001166
Dan Williams85280952011-06-28 15:05:53 -07001167 if (iphy->sm.previous_state_id != SCI_PHY_INITIAL)
Dan Williams34a99152011-07-01 02:25:15 -07001168 sci_controller_link_down(ihost, phy_get_non_dummy_port(iphy), iphy);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001169}
1170
Dan Williams89a73012011-06-30 19:14:33 -07001171static void sci_phy_starting_state_enter(struct sci_base_state_machine *sm)
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001172{
Dan Williams85280952011-06-28 15:05:53 -07001173 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Dan Williams34a99152011-07-01 02:25:15 -07001174 struct isci_port *iport = iphy->owning_port;
1175 struct isci_host *ihost = iport->owning_controller;
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001176
Dan Williams85280952011-06-28 15:05:53 -07001177 scu_link_layer_stop_protocol_engine(iphy);
1178 scu_link_layer_start_oob(iphy);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001179
1180 /* We don't know what kind of phy we are going to be just yet */
Dan Williams85280952011-06-28 15:05:53 -07001181 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
1182 iphy->bcn_received_while_port_unassigned = false;
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001183
Dan Williams85280952011-06-28 15:05:53 -07001184 if (iphy->sm.previous_state_id == SCI_PHY_READY)
Dan Williams34a99152011-07-01 02:25:15 -07001185 sci_controller_link_down(ihost, phy_get_non_dummy_port(iphy), iphy);
Adam Gruchala4a33c522011-05-10 23:54:23 +00001186
Dan Williams85280952011-06-28 15:05:53 -07001187 sci_change_state(&iphy->sm, SCI_PHY_SUB_INITIAL);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001188}
1189
Dan Williams89a73012011-06-30 19:14:33 -07001190static void sci_phy_ready_state_enter(struct sci_base_state_machine *sm)
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001191{
Dan Williams85280952011-06-28 15:05:53 -07001192 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Dan Williams34a99152011-07-01 02:25:15 -07001193 struct isci_port *iport = iphy->owning_port;
1194 struct isci_host *ihost = iport->owning_controller;
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001195
Dan Williams34a99152011-07-01 02:25:15 -07001196 sci_controller_link_up(ihost, phy_get_non_dummy_port(iphy), iphy);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001197}
1198
Dan Williams89a73012011-06-30 19:14:33 -07001199static void sci_phy_ready_state_exit(struct sci_base_state_machine *sm)
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001200{
Dan Williams85280952011-06-28 15:05:53 -07001201 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001202
Dan Williams89a73012011-06-30 19:14:33 -07001203 sci_phy_suspend(iphy);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001204}
1205
Dan Williams89a73012011-06-30 19:14:33 -07001206static void sci_phy_resetting_state_enter(struct sci_base_state_machine *sm)
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001207{
Dan Williams85280952011-06-28 15:05:53 -07001208 struct isci_phy *iphy = container_of(sm, typeof(*iphy), sm);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001209
Dan Williams5b1d4af2011-05-12 04:51:41 -07001210 /* The phy is being reset, therefore deactivate it from the port. In
1211 * the resetting state we don't notify the user regarding link up and
1212 * link down notifications
1213 */
Dan Williams89a73012011-06-30 19:14:33 -07001214 sci_port_deactivate_phy(iphy->owning_port, iphy, false);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001215
Dan Williams85280952011-06-28 15:05:53 -07001216 if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) {
1217 scu_link_layer_tx_hard_reset(iphy);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001218 } else {
Dan Williams5b1d4af2011-05-12 04:51:41 -07001219 /* The SCU does not need to have a discrete reset state so
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001220 * just go back to the starting state.
1221 */
Dan Williams85280952011-06-28 15:05:53 -07001222 sci_change_state(&iphy->sm, SCI_PHY_STARTING);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001223 }
1224}
1225
Dan Williams89a73012011-06-30 19:14:33 -07001226static const struct sci_base_state sci_phy_state_table[] = {
Edmund Nadolskie3013702011-06-02 00:10:43 +00001227 [SCI_PHY_INITIAL] = { },
1228 [SCI_PHY_STOPPED] = {
Dan Williams89a73012011-06-30 19:14:33 -07001229 .enter_state = sci_phy_stopped_state_enter,
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001230 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001231 [SCI_PHY_STARTING] = {
Dan Williams89a73012011-06-30 19:14:33 -07001232 .enter_state = sci_phy_starting_state_enter,
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001233 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001234 [SCI_PHY_SUB_INITIAL] = {
Dan Williams89a73012011-06-30 19:14:33 -07001235 .enter_state = sci_phy_starting_initial_substate_enter,
Adam Gruchala4a33c522011-05-10 23:54:23 +00001236 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001237 [SCI_PHY_SUB_AWAIT_OSSP_EN] = { },
1238 [SCI_PHY_SUB_AWAIT_SAS_SPEED_EN] = { },
1239 [SCI_PHY_SUB_AWAIT_IAF_UF] = { },
1240 [SCI_PHY_SUB_AWAIT_SAS_POWER] = {
Dan Williams89a73012011-06-30 19:14:33 -07001241 .enter_state = sci_phy_starting_await_sas_power_substate_enter,
1242 .exit_state = sci_phy_starting_await_sas_power_substate_exit,
Adam Gruchala4a33c522011-05-10 23:54:23 +00001243 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001244 [SCI_PHY_SUB_AWAIT_SATA_POWER] = {
Dan Williams89a73012011-06-30 19:14:33 -07001245 .enter_state = sci_phy_starting_await_sata_power_substate_enter,
1246 .exit_state = sci_phy_starting_await_sata_power_substate_exit
Adam Gruchala4a33c522011-05-10 23:54:23 +00001247 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001248 [SCI_PHY_SUB_AWAIT_SATA_PHY_EN] = {
Dan Williams89a73012011-06-30 19:14:33 -07001249 .enter_state = sci_phy_starting_await_sata_phy_substate_enter,
1250 .exit_state = sci_phy_starting_await_sata_phy_substate_exit
Adam Gruchala4a33c522011-05-10 23:54:23 +00001251 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001252 [SCI_PHY_SUB_AWAIT_SATA_SPEED_EN] = {
Dan Williams89a73012011-06-30 19:14:33 -07001253 .enter_state = sci_phy_starting_await_sata_speed_substate_enter,
1254 .exit_state = sci_phy_starting_await_sata_speed_substate_exit
Adam Gruchala4a33c522011-05-10 23:54:23 +00001255 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001256 [SCI_PHY_SUB_AWAIT_SIG_FIS_UF] = {
Dan Williams89a73012011-06-30 19:14:33 -07001257 .enter_state = sci_phy_starting_await_sig_fis_uf_substate_enter,
1258 .exit_state = sci_phy_starting_await_sig_fis_uf_substate_exit
Adam Gruchala4a33c522011-05-10 23:54:23 +00001259 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001260 [SCI_PHY_SUB_FINAL] = {
Dan Williams89a73012011-06-30 19:14:33 -07001261 .enter_state = sci_phy_starting_final_substate_enter,
Adam Gruchala4a33c522011-05-10 23:54:23 +00001262 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001263 [SCI_PHY_READY] = {
Dan Williams89a73012011-06-30 19:14:33 -07001264 .enter_state = sci_phy_ready_state_enter,
1265 .exit_state = sci_phy_ready_state_exit,
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001266 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001267 [SCI_PHY_RESETTING] = {
Dan Williams89a73012011-06-30 19:14:33 -07001268 .enter_state = sci_phy_resetting_state_enter,
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001269 },
Edmund Nadolskie3013702011-06-02 00:10:43 +00001270 [SCI_PHY_FINAL] = { },
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001271};
1272
Dan Williams89a73012011-06-30 19:14:33 -07001273void sci_phy_construct(struct isci_phy *iphy,
Dan Williamsffe191c2011-06-29 13:09:25 -07001274 struct isci_port *iport, u8 phy_index)
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001275{
Dan Williams89a73012011-06-30 19:14:33 -07001276 sci_init_sm(&iphy->sm, sci_phy_state_table, SCI_PHY_INITIAL);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001277
1278 /* Copy the rest of the input data to our locals */
Dan Williamsffe191c2011-06-29 13:09:25 -07001279 iphy->owning_port = iport;
Dan Williams85280952011-06-28 15:05:53 -07001280 iphy->phy_index = phy_index;
1281 iphy->bcn_received_while_port_unassigned = false;
1282 iphy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
1283 iphy->link_layer_registers = NULL;
1284 iphy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN;
Edmund Nadolskia628d472011-05-19 11:59:36 +00001285
1286 /* Create the SIGNATURE FIS Timeout timer for this phy */
Dan Williams85280952011-06-28 15:05:53 -07001287 sci_init_timer(&iphy->sata_timer, phy_sata_timeout);
Dan Williamsd35bc1b2011-05-10 02:28:45 -07001288}
Dan Williams6f231dd2011-07-02 22:56:22 -07001289
Dan Williams4b339812011-05-06 17:36:38 -07001290void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index)
Dan Williams6f231dd2011-07-02 22:56:22 -07001291{
Dan Williams89a73012011-06-30 19:14:33 -07001292 struct sci_oem_params *oem = &ihost->oem_parameters;
Dan Williams4b339812011-05-06 17:36:38 -07001293 u64 sci_sas_addr;
1294 __be64 sas_addr;
Dan Williams6f231dd2011-07-02 22:56:22 -07001295
Dan Williams89a73012011-06-30 19:14:33 -07001296 sci_sas_addr = oem->phys[index].sas_address.high;
Dan Williams4b339812011-05-06 17:36:38 -07001297 sci_sas_addr <<= 32;
Dan Williams89a73012011-06-30 19:14:33 -07001298 sci_sas_addr |= oem->phys[index].sas_address.low;
Dan Williams4b339812011-05-06 17:36:38 -07001299 sas_addr = cpu_to_be64(sci_sas_addr);
1300 memcpy(iphy->sas_addr, &sas_addr, sizeof(sas_addr));
Dan Williams6f231dd2011-07-02 22:56:22 -07001301
Dan Williams4b339812011-05-06 17:36:38 -07001302 iphy->isci_port = NULL;
1303 iphy->sas_phy.enabled = 0;
1304 iphy->sas_phy.id = index;
1305 iphy->sas_phy.sas_addr = &iphy->sas_addr[0];
1306 iphy->sas_phy.frame_rcvd = (u8 *)&iphy->frame_rcvd;
1307 iphy->sas_phy.ha = &ihost->sas_ha;
1308 iphy->sas_phy.lldd_phy = iphy;
1309 iphy->sas_phy.enabled = 1;
1310 iphy->sas_phy.class = SAS;
1311 iphy->sas_phy.iproto = SAS_PROTOCOL_ALL;
1312 iphy->sas_phy.tproto = 0;
1313 iphy->sas_phy.type = PHY_TYPE_PHYSICAL;
1314 iphy->sas_phy.role = PHY_ROLE_INITIATOR;
1315 iphy->sas_phy.oob_mode = OOB_NOT_CONNECTED;
1316 iphy->sas_phy.linkrate = SAS_LINK_RATE_UNKNOWN;
1317 memset(&iphy->frame_rcvd, 0, sizeof(iphy->frame_rcvd));
Dan Williams6f231dd2011-07-02 22:56:22 -07001318}
1319
1320
1321/**
1322 * isci_phy_control() - This function is one of the SAS Domain Template
1323 * functions. This is a phy management function.
1324 * @phy: This parameter specifies the sphy being controlled.
1325 * @func: This parameter specifies the phy control function being invoked.
1326 * @buf: This parameter is specific to the phy function being invoked.
1327 *
1328 * status, zero indicates success.
1329 */
Dave Jiang4d07f7f2011-03-02 12:31:24 -08001330int isci_phy_control(struct asd_sas_phy *sas_phy,
1331 enum phy_func func,
1332 void *buf)
Dan Williams6f231dd2011-07-02 22:56:22 -07001333{
Dave Jiang4d07f7f2011-03-02 12:31:24 -08001334 int ret = 0;
1335 struct isci_phy *iphy = sas_phy->lldd_phy;
1336 struct isci_port *iport = iphy->isci_port;
1337 struct isci_host *ihost = sas_phy->ha->lldd_ha;
1338 unsigned long flags;
Dan Williams6f231dd2011-07-02 22:56:22 -07001339
Dave Jiang4d07f7f2011-03-02 12:31:24 -08001340 dev_dbg(&ihost->pdev->dev,
1341 "%s: phy %p; func %d; buf %p; isci phy %p, port %p\n",
1342 __func__, sas_phy, func, buf, iphy, iport);
Dan Williams6f231dd2011-07-02 22:56:22 -07001343
1344 switch (func) {
Dave Jiang4d07f7f2011-03-02 12:31:24 -08001345 case PHY_FUNC_DISABLE:
1346 spin_lock_irqsave(&ihost->scic_lock, flags);
Dan Williams89a73012011-06-30 19:14:33 -07001347 sci_phy_stop(iphy);
Dave Jiang4d07f7f2011-03-02 12:31:24 -08001348 spin_unlock_irqrestore(&ihost->scic_lock, flags);
1349 break;
1350
Dan Williams6f231dd2011-07-02 22:56:22 -07001351 case PHY_FUNC_LINK_RESET:
Dave Jiang4d07f7f2011-03-02 12:31:24 -08001352 spin_lock_irqsave(&ihost->scic_lock, flags);
Dan Williams89a73012011-06-30 19:14:33 -07001353 sci_phy_stop(iphy);
1354 sci_phy_start(iphy);
Dave Jiang4d07f7f2011-03-02 12:31:24 -08001355 spin_unlock_irqrestore(&ihost->scic_lock, flags);
1356 break;
1357
1358 case PHY_FUNC_HARD_RESET:
1359 if (!iport)
1360 return -ENODEV;
Dan Williams6f231dd2011-07-02 22:56:22 -07001361
1362 /* Perform the port reset. */
Dan Williams4393aa42011-03-31 13:10:44 -07001363 ret = isci_port_perform_hard_reset(ihost, iport, iphy);
Dan Williams6f231dd2011-07-02 22:56:22 -07001364
1365 break;
Dan Williamsac013ed2011-09-28 18:48:02 -07001366 case PHY_FUNC_GET_EVENTS: {
1367 struct scu_link_layer_registers __iomem *r;
1368 struct sas_phy *phy = sas_phy->phy;
1369
1370 r = iphy->link_layer_registers;
1371 phy->running_disparity_error_count = readl(&r->running_disparity_error_count);
1372 phy->loss_of_dword_sync_count = readl(&r->loss_of_sync_error_count);
1373 phy->phy_reset_problem_count = readl(&r->phy_reset_problem_count);
1374 phy->invalid_dword_count = readl(&r->invalid_dword_counter);
1375 break;
1376 }
Dan Williams6f231dd2011-07-02 22:56:22 -07001377
Dan Williams6f231dd2011-07-02 22:56:22 -07001378 default:
Dave Jiang4d07f7f2011-03-02 12:31:24 -08001379 dev_dbg(&ihost->pdev->dev,
1380 "%s: phy %p; func %d NOT IMPLEMENTED!\n",
1381 __func__, sas_phy, func);
1382 ret = -ENOSYS;
Dan Williams6f231dd2011-07-02 22:56:22 -07001383 break;
1384 }
1385 return ret;
1386}