xref: /openbmc/linux/drivers/scsi/isci/phy.h (revision 8be98d2f2a0a262f8bf8a0bc1fdf522b3c7aab17)
16f231ddaSDan Williams /*
26f231ddaSDan Williams  * This file is provided under a dual BSD/GPLv2 license.  When using or
36f231ddaSDan Williams  * redistributing this file, you may do so under either license.
46f231ddaSDan Williams  *
56f231ddaSDan Williams  * GPL LICENSE SUMMARY
66f231ddaSDan Williams  *
76f231ddaSDan Williams  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
86f231ddaSDan Williams  *
96f231ddaSDan Williams  * This program is free software; you can redistribute it and/or modify
106f231ddaSDan Williams  * it under the terms of version 2 of the GNU General Public License as
116f231ddaSDan Williams  * published by the Free Software Foundation.
126f231ddaSDan Williams  *
136f231ddaSDan Williams  * This program is distributed in the hope that it will be useful, but
146f231ddaSDan Williams  * WITHOUT ANY WARRANTY; without even the implied warranty of
156f231ddaSDan Williams  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
166f231ddaSDan Williams  * General Public License for more details.
176f231ddaSDan Williams  *
186f231ddaSDan Williams  * You should have received a copy of the GNU General Public License
196f231ddaSDan Williams  * along with this program; if not, write to the Free Software
206f231ddaSDan Williams  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
216f231ddaSDan Williams  * The full GNU General Public License is included in this distribution
226f231ddaSDan Williams  * in the file called LICENSE.GPL.
236f231ddaSDan Williams  *
246f231ddaSDan Williams  * BSD LICENSE
256f231ddaSDan Williams  *
266f231ddaSDan Williams  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
276f231ddaSDan Williams  * All rights reserved.
286f231ddaSDan Williams  *
296f231ddaSDan Williams  * Redistribution and use in source and binary forms, with or without
306f231ddaSDan Williams  * modification, are permitted provided that the following conditions
316f231ddaSDan Williams  * are met:
326f231ddaSDan Williams  *
336f231ddaSDan Williams  *   * Redistributions of source code must retain the above copyright
346f231ddaSDan Williams  *     notice, this list of conditions and the following disclaimer.
356f231ddaSDan Williams  *   * Redistributions in binary form must reproduce the above copyright
366f231ddaSDan Williams  *     notice, this list of conditions and the following disclaimer in
376f231ddaSDan Williams  *     the documentation and/or other materials provided with the
386f231ddaSDan Williams  *     distribution.
396f231ddaSDan Williams  *   * Neither the name of Intel Corporation nor the names of its
406f231ddaSDan Williams  *     contributors may be used to endorse or promote products derived
416f231ddaSDan Williams  *     from this software without specific prior written permission.
426f231ddaSDan Williams  *
436f231ddaSDan Williams  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
446f231ddaSDan Williams  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
456f231ddaSDan Williams  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
466f231ddaSDan Williams  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
476f231ddaSDan Williams  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
486f231ddaSDan Williams  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
496f231ddaSDan Williams  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
506f231ddaSDan Williams  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
516f231ddaSDan Williams  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
526f231ddaSDan Williams  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
536f231ddaSDan Williams  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
546f231ddaSDan Williams  */
554b33981aSDan Williams #ifndef _ISCI_PHY_H_
566f231ddaSDan Williams #define _ISCI_PHY_H_
576f231ddaSDan Williams 
58f2f30080SDave Jiang #include <scsi/sas.h>
596f231ddaSDan Williams #include <scsi/libsas.h>
6012ef6544SEdmund Nadolski #include "isci.h"
61e2f8db50SDan Williams #include "sas.h"
62d35bc1bdSDan Williams 
63d35bc1bdSDan Williams /* This is the timeout value for the SATA phy to wait for a SIGNATURE FIS
64d35bc1bdSDan Williams  * before restarting the starting state machine.  Technically, the old parallel
65d35bc1bdSDan Williams  * ATA specification required up to 30 seconds for a device to issue its
66d35bc1bdSDan Williams  * signature FIS as a result of a soft reset.  Now we see that devices respond
67d35bc1bdSDan Williams  * generally within 15 seconds, but we'll use 25 for now.
68d35bc1bdSDan Williams  */
69d35bc1bdSDan Williams #define SCIC_SDS_SIGNATURE_FIS_TIMEOUT    25000
70d35bc1bdSDan Williams 
71d35bc1bdSDan Williams /* This is the timeout for the SATA OOB/SN because the hardware does not
72d35bc1bdSDan Williams  * recognize a hot plug after OOB signal but before the SN signals.  We need to
73d35bc1bdSDan Williams  * make sure after a hotplug timeout if we have not received the speed event
74d35bc1bdSDan Williams  * notification from the hardware that we restart the hardware OOB state
75d35bc1bdSDan Williams  * machine.
76d35bc1bdSDan Williams  */
77d35bc1bdSDan Williams #define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT  250
78d35bc1bdSDan Williams 
79d35bc1bdSDan Williams /**
8085280955SDan Williams  * isci_phy - hba local phy infrastructure
8185280955SDan Williams  * @sm:
8285280955SDan Williams  * @protocol: attached device protocol
8385280955SDan Williams  * @phy_index: physical index relative to the controller (0-3)
8485280955SDan Williams  * @bcn_received_while_port_unassigned: bcn to report after port association
8585280955SDan Williams  * @sata_timer: timeout SATA signature FIS arrival
86d35bc1bdSDan Williams  */
876f231ddaSDan Williams struct isci_phy {
8885280955SDan Williams 	struct sci_base_state_machine sm;
89ffe191c9SDan Williams 	struct isci_port *owning_port;
9085280955SDan Williams 	enum sas_linkrate max_negotiated_speed;
91*c79dd80dSDan Williams 	enum sas_protocol protocol;
9285280955SDan Williams 	u8 phy_index;
9385280955SDan Williams 	bool bcn_received_while_port_unassigned;
9485280955SDan Williams 	bool is_in_link_training;
9585280955SDan Williams 	struct sci_timer sata_timer;
9685280955SDan Williams 	struct scu_transport_layer_registers __iomem *transport_layer_registers;
9785280955SDan Williams 	struct scu_link_layer_registers __iomem *link_layer_registers;
986f231ddaSDan Williams 	struct asd_sas_phy sas_phy;
996f231ddaSDan Williams 	u8 sas_addr[SAS_ADDR_SIZE];
1006f231ddaSDan Williams 	union {
1014b7ebd05SDave Jiang 		struct sas_identify_frame iaf;
102f2f30080SDave Jiang 		struct dev_to_host_fis fis;
1036f231ddaSDan Williams 	} frame_rcvd;
1046f231ddaSDan Williams };
1056f231ddaSDan Williams 
to_iphy(struct asd_sas_phy * sas_phy)10685280955SDan Williams static inline struct isci_phy *to_iphy(struct asd_sas_phy *sas_phy)
1074b33981aSDan Williams {
1084b33981aSDan Williams 	struct isci_phy *iphy = container_of(sas_phy, typeof(*iphy), sas_phy);
1096f231ddaSDan Williams 
1104b33981aSDan Williams 	return iphy;
1114b33981aSDan Williams }
1126f231ddaSDan Williams 
11389a7301fSDan Williams struct sci_phy_cap {
114d35bc1bdSDan Williams 	union {
115d35bc1bdSDan Williams 		struct {
116d35bc1bdSDan Williams 			/*
117d35bc1bdSDan Williams 			 * The SAS specification indicates the start bit shall
118d35bc1bdSDan Williams 			 * always be set to
119d35bc1bdSDan Williams 			 * 1.  This implementation will have the start bit set
120d35bc1bdSDan Williams 			 * to 0 if the PHY CAPABILITIES were either not
121d35bc1bdSDan Williams 			 * received or speed negotiation failed.
122d35bc1bdSDan Williams 			 */
123d35bc1bdSDan Williams 			u8 start:1;
124d35bc1bdSDan Williams 			u8 tx_ssc_type:1;
125d35bc1bdSDan Williams 			u8 res1:2;
126d35bc1bdSDan Williams 			u8 req_logical_linkrate:4;
127d35bc1bdSDan Williams 
128d35bc1bdSDan Williams 			u32 gen1_no_ssc:1;
129d35bc1bdSDan Williams 			u32 gen1_ssc:1;
130d35bc1bdSDan Williams 			u32 gen2_no_ssc:1;
131d35bc1bdSDan Williams 			u32 gen2_ssc:1;
132d35bc1bdSDan Williams 			u32 gen3_no_ssc:1;
133d35bc1bdSDan Williams 			u32 gen3_ssc:1;
134d35bc1bdSDan Williams 			u32 res2:17;
135d35bc1bdSDan Williams 			u32 parity:1;
136d35bc1bdSDan Williams 		};
137d35bc1bdSDan Williams 		u32 all;
138d35bc1bdSDan Williams 	};
139d35bc1bdSDan Williams }  __packed;
140d35bc1bdSDan Williams 
141d35bc1bdSDan Williams /* this data structure reflects the link layer transmit identification reg */
14289a7301fSDan Williams struct sci_phy_proto {
143d35bc1bdSDan Williams 	union {
144d35bc1bdSDan Williams 		struct {
145d35bc1bdSDan Williams 			u16 _r_a:1;
146d35bc1bdSDan Williams 			u16 smp_iport:1;
147d35bc1bdSDan Williams 			u16 stp_iport:1;
148d35bc1bdSDan Williams 			u16 ssp_iport:1;
149d35bc1bdSDan Williams 			u16 _r_b:4;
150d35bc1bdSDan Williams 			u16 _r_c:1;
151d35bc1bdSDan Williams 			u16 smp_tport:1;
152d35bc1bdSDan Williams 			u16 stp_tport:1;
153d35bc1bdSDan Williams 			u16 ssp_tport:1;
154d35bc1bdSDan Williams 			u16 _r_d:4;
155d35bc1bdSDan Williams 		};
156d35bc1bdSDan Williams 		u16 all;
157d35bc1bdSDan Williams 	};
158d35bc1bdSDan Williams } __packed;
159d35bc1bdSDan Williams 
160d35bc1bdSDan Williams 
161d35bc1bdSDan Williams /**
16289a7301fSDan Williams  * struct sci_phy_properties - This structure defines the properties common to
163d35bc1bdSDan Williams  *    all phys that can be retrieved.
164d35bc1bdSDan Williams  *
165d35bc1bdSDan Williams  *
166d35bc1bdSDan Williams  */
16789a7301fSDan Williams struct sci_phy_properties {
168d35bc1bdSDan Williams 	/**
169d35bc1bdSDan Williams 	 * This field specifies the port that currently contains the
170d35bc1bdSDan Williams 	 * supplied phy.  This field may be set to NULL
171d35bc1bdSDan Williams 	 * if the phy is not currently contained in a port.
172d35bc1bdSDan Williams 	 */
173ffe191c9SDan Williams 	struct isci_port *iport;
174d35bc1bdSDan Williams 
175d35bc1bdSDan Williams 	/**
176d35bc1bdSDan Williams 	 * This field specifies the link rate at which the phy is
177d35bc1bdSDan Williams 	 * currently operating.
178d35bc1bdSDan Williams 	 */
179d35bc1bdSDan Williams 	enum sas_linkrate negotiated_link_rate;
180d35bc1bdSDan Williams 
181d35bc1bdSDan Williams 	/**
182d35bc1bdSDan Williams 	 * This field specifies the index of the phy in relation to other
183d35bc1bdSDan Williams 	 * phys within the controller.  This index is zero relative.
184d35bc1bdSDan Williams 	 */
185d35bc1bdSDan Williams 	u8 index;
186d35bc1bdSDan Williams };
187d35bc1bdSDan Williams 
188d35bc1bdSDan Williams /**
18989a7301fSDan Williams  * struct sci_sas_phy_properties - This structure defines the properties,
190d35bc1bdSDan Williams  *    specific to a SAS phy, that can be retrieved.
191d35bc1bdSDan Williams  *
192d35bc1bdSDan Williams  *
193d35bc1bdSDan Williams  */
19489a7301fSDan Williams struct sci_sas_phy_properties {
195d35bc1bdSDan Williams 	/**
196d35bc1bdSDan Williams 	 * This field delineates the Identify Address Frame received
197d35bc1bdSDan Williams 	 * from the remote end point.
198d35bc1bdSDan Williams 	 */
199d35bc1bdSDan Williams 	struct sas_identify_frame rcvd_iaf;
200d35bc1bdSDan Williams 
201d35bc1bdSDan Williams 	/**
202d35bc1bdSDan Williams 	 * This field delineates the Phy capabilities structure received
203d35bc1bdSDan Williams 	 * from the remote end point.
204d35bc1bdSDan Williams 	 */
20589a7301fSDan Williams 	struct sci_phy_cap rcvd_cap;
206d35bc1bdSDan Williams 
207d35bc1bdSDan Williams };
208d35bc1bdSDan Williams 
209d35bc1bdSDan Williams /**
21089a7301fSDan Williams  * struct sci_sata_phy_properties - This structure defines the properties,
211d35bc1bdSDan Williams  *    specific to a SATA phy, that can be retrieved.
212d35bc1bdSDan Williams  *
213d35bc1bdSDan Williams  *
214d35bc1bdSDan Williams  */
21589a7301fSDan Williams struct sci_sata_phy_properties {
216d35bc1bdSDan Williams 	/**
217d35bc1bdSDan Williams 	 * This field delineates the signature FIS received from the
218d35bc1bdSDan Williams 	 * attached target.
219d35bc1bdSDan Williams 	 */
220d35bc1bdSDan Williams 	struct dev_to_host_fis signature_fis;
221d35bc1bdSDan Williams 
222d35bc1bdSDan Williams 	/**
223d35bc1bdSDan Williams 	 * This field specifies to the user if a port selector is connected
224d35bc1bdSDan Williams 	 * on the specified phy.
225d35bc1bdSDan Williams 	 */
226d35bc1bdSDan Williams 	bool is_port_selector_present;
227d35bc1bdSDan Williams 
228d35bc1bdSDan Williams };
229d35bc1bdSDan Williams 
230d35bc1bdSDan Williams /**
23189a7301fSDan Williams  * enum sci_phy_counter_id - This enumeration depicts the various pieces of
232d35bc1bdSDan Williams  *    optional information that can be retrieved for a specific phy.
233d35bc1bdSDan Williams  *
234d35bc1bdSDan Williams  *
235d35bc1bdSDan Williams  */
23689a7301fSDan Williams enum sci_phy_counter_id {
237d35bc1bdSDan Williams 	/**
238d35bc1bdSDan Williams 	 * This PHY information field tracks the number of frames received.
239d35bc1bdSDan Williams 	 */
240d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_FRAME,
241d35bc1bdSDan Williams 
242d35bc1bdSDan Williams 	/**
243d35bc1bdSDan Williams 	 * This PHY information field tracks the number of frames transmitted.
244d35bc1bdSDan Williams 	 */
245d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_TRANSMITTED_FRAME,
246d35bc1bdSDan Williams 
247d35bc1bdSDan Williams 	/**
248d35bc1bdSDan Williams 	 * This PHY information field tracks the number of DWORDs received.
249d35bc1bdSDan Williams 	 */
250d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_FRAME_WORD,
251d35bc1bdSDan Williams 
252d35bc1bdSDan Williams 	/**
253d35bc1bdSDan Williams 	 * This PHY information field tracks the number of DWORDs transmitted.
254d35bc1bdSDan Williams 	 */
255d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD,
256d35bc1bdSDan Williams 
257d35bc1bdSDan Williams 	/**
258d35bc1bdSDan Williams 	 * This PHY information field tracks the number of times DWORD
259d35bc1bdSDan Williams 	 * synchronization was lost.
260d35bc1bdSDan Williams 	 */
261d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR,
262d35bc1bdSDan Williams 
263d35bc1bdSDan Williams 	/**
264d35bc1bdSDan Williams 	 * This PHY information field tracks the number of received DWORDs with
265d35bc1bdSDan Williams 	 * running disparity errors.
266d35bc1bdSDan Williams 	 */
267d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR,
268d35bc1bdSDan Williams 
269d35bc1bdSDan Williams 	/**
270d35bc1bdSDan Williams 	 * This PHY information field tracks the number of received frames with a
271d35bc1bdSDan Williams 	 * CRC error (not including short or truncated frames).
272d35bc1bdSDan Williams 	 */
273d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR,
274d35bc1bdSDan Williams 
275d35bc1bdSDan Williams 	/**
276d35bc1bdSDan Williams 	 * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT)
277d35bc1bdSDan Williams 	 * primitives received.
278d35bc1bdSDan Williams 	 */
279d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT,
280d35bc1bdSDan Williams 
281d35bc1bdSDan Williams 	/**
282d35bc1bdSDan Williams 	 * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT)
283d35bc1bdSDan Williams 	 * primitives transmitted.
284d35bc1bdSDan Williams 	 */
285d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT,
286d35bc1bdSDan Williams 
287d35bc1bdSDan Williams 	/**
288d35bc1bdSDan Williams 	 * This PHY information field tracks the number of times the inactivity
289d35bc1bdSDan Williams 	 * timer for connections on the phy has been utilized.
290d35bc1bdSDan Williams 	 */
291d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED,
292d35bc1bdSDan Williams 
293d35bc1bdSDan Williams 	/**
294d35bc1bdSDan Williams 	 * This PHY information field tracks the number of DONE (CREDIT TIMEOUT)
295d35bc1bdSDan Williams 	 * primitives received.
296d35bc1bdSDan Williams 	 */
297d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT,
298d35bc1bdSDan Williams 
299d35bc1bdSDan Williams 	/**
300d35bc1bdSDan Williams 	 * This PHY information field tracks the number of DONE (CREDIT TIMEOUT)
301d35bc1bdSDan Williams 	 * primitives transmitted.
302d35bc1bdSDan Williams 	 */
303d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT,
304d35bc1bdSDan Williams 
305d35bc1bdSDan Williams 	/**
306d35bc1bdSDan Williams 	 * This PHY information field tracks the number of CREDIT BLOCKED
307d35bc1bdSDan Williams 	 * primitives received.
308d35bc1bdSDan Williams 	 * @note Depending on remote device implementation, credit blocks
309d35bc1bdSDan Williams 	 *       may occur regularly.
310d35bc1bdSDan Williams 	 */
311d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED,
312d35bc1bdSDan Williams 
313d35bc1bdSDan Williams 	/**
314d35bc1bdSDan Williams 	 * This PHY information field contains the number of short frames
315d35bc1bdSDan Williams 	 * received.  A short frame is simply a frame smaller then what is
316d35bc1bdSDan Williams 	 * allowed by either the SAS or SATA specification.
317d35bc1bdSDan Williams 	 */
318d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME,
319d35bc1bdSDan Williams 
320d35bc1bdSDan Williams 	/**
321d35bc1bdSDan Williams 	 * This PHY information field contains the number of frames received after
322d35bc1bdSDan Williams 	 * credit has been exhausted.
323d35bc1bdSDan Williams 	 */
324d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT,
325d35bc1bdSDan Williams 
326d35bc1bdSDan Williams 	/**
327d35bc1bdSDan Williams 	 * This PHY information field contains the number of frames received after
328d35bc1bdSDan Williams 	 * a DONE has been received.
329d35bc1bdSDan Williams 	 */
330d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE,
331d35bc1bdSDan Williams 
332d35bc1bdSDan Williams 	/**
333d35bc1bdSDan Williams 	 * This PHY information field contains the number of times the phy
334d35bc1bdSDan Williams 	 * failed to achieve DWORD synchronization during speed negotiation.
335d35bc1bdSDan Williams 	 */
336d35bc1bdSDan Williams 	SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR
337d35bc1bdSDan Williams };
338d35bc1bdSDan Williams 
339d35bc1bdSDan Williams /**
340d7a0ccddSDan Williams  * enum sci_phy_states - phy state machine states
341d7a0ccddSDan Williams  * @SCI_PHY_INITIAL: Simply the initial state for the base domain state
342d7a0ccddSDan Williams  *		     machine.
343d7a0ccddSDan Williams  * @SCI_PHY_STOPPED: phy has successfully been stopped.  In this state
344d7a0ccddSDan Williams  *		     no new IO operations are permitted on this phy.
345d7a0ccddSDan Williams  * @SCI_PHY_STARTING: the phy is in the process of becomming ready.  In
346d7a0ccddSDan Williams  *		      this state no new IO operations are permitted on
347d7a0ccddSDan Williams  *		      this phy.
348d7a0ccddSDan Williams  * @SCI_PHY_SUB_INITIAL: Initial state
349d7a0ccddSDan Williams  * @SCI_PHY_SUB_AWAIT_OSSP_EN: Wait state for the hardware OSSP event
350d7a0ccddSDan Williams  *			       type notification
351d7a0ccddSDan Williams  * @SCI_PHY_SUB_AWAIT_SAS_SPEED_EN: Wait state for the PHY speed
352d7a0ccddSDan Williams  *				    notification
353d7a0ccddSDan Williams  * @SCI_PHY_SUB_AWAIT_IAF_UF: Wait state for the IAF Unsolicited frame
354d7a0ccddSDan Williams  *			      notification
355d7a0ccddSDan Williams  * @SCI_PHY_SUB_AWAIT_SAS_POWER: Wait state for the request to consume
356d7a0ccddSDan Williams  *				 power
357d7a0ccddSDan Williams  * @SCI_PHY_SUB_AWAIT_SATA_POWER: Wait state for request to consume
358d7a0ccddSDan Williams  *				  power
359d7a0ccddSDan Williams  * @SCI_PHY_SUB_AWAIT_SATA_PHY_EN: Wait state for the SATA PHY
360d7a0ccddSDan Williams  *				   notification
361d7a0ccddSDan Williams  * @SCI_PHY_SUB_AWAIT_SATA_SPEED_EN: Wait for the SATA PHY speed
362d7a0ccddSDan Williams  *				     notification
363d7a0ccddSDan Williams  * @SCI_PHY_SUB_AWAIT_SIG_FIS_UF: Wait state for the SIGNATURE FIS
364d7a0ccddSDan Williams  *				  unsolicited frame notification
365d7a0ccddSDan Williams  * @SCI_PHY_SUB_FINAL: Exit state for this state machine
366d7a0ccddSDan Williams  * @SCI_PHY_READY: phy is now ready.  Thus, the user is able to perform
367d7a0ccddSDan Williams  *		   IO operations utilizing this phy as long as it is
368d7a0ccddSDan Williams  *		   currently part of a valid port.  This state is
369d7a0ccddSDan Williams  *		   entered from the STARTING state.
370d7a0ccddSDan Williams  * @SCI_PHY_RESETTING: phy is in the process of being reset.  In this
371d7a0ccddSDan Williams  *		       state no new IO operations are permitted on this
372d7a0ccddSDan Williams  *		       phy.  This state is entered from the READY state.
373d7a0ccddSDan Williams  * @SCI_PHY_FINAL: Simply the final state for the base phy state
374d7a0ccddSDan Williams  *		   machine.
375d35bc1bdSDan Williams  */
376d7a0ccddSDan Williams #define PHY_STATES {\
377d7a0ccddSDan Williams 	C(PHY_INITIAL),\
378d7a0ccddSDan Williams 	C(PHY_STOPPED),\
379d7a0ccddSDan Williams 	C(PHY_STARTING),\
380d7a0ccddSDan Williams 	C(PHY_SUB_INITIAL),\
381d7a0ccddSDan Williams 	C(PHY_SUB_AWAIT_OSSP_EN),\
382d7a0ccddSDan Williams 	C(PHY_SUB_AWAIT_SAS_SPEED_EN),\
383d7a0ccddSDan Williams 	C(PHY_SUB_AWAIT_IAF_UF),\
384d7a0ccddSDan Williams 	C(PHY_SUB_AWAIT_SAS_POWER),\
385d7a0ccddSDan Williams 	C(PHY_SUB_AWAIT_SATA_POWER),\
386d7a0ccddSDan Williams 	C(PHY_SUB_AWAIT_SATA_PHY_EN),\
387d7a0ccddSDan Williams 	C(PHY_SUB_AWAIT_SATA_SPEED_EN),\
388d7a0ccddSDan Williams 	C(PHY_SUB_AWAIT_SIG_FIS_UF),\
389d7a0ccddSDan Williams 	C(PHY_SUB_FINAL),\
390d7a0ccddSDan Williams 	C(PHY_READY),\
391d7a0ccddSDan Williams 	C(PHY_RESETTING),\
392d7a0ccddSDan Williams 	C(PHY_FINAL),\
393d7a0ccddSDan Williams 	}
394d7a0ccddSDan Williams #undef C
395d7a0ccddSDan Williams #define C(a) SCI_##a
396d7a0ccddSDan Williams enum sci_phy_states PHY_STATES;
397d7a0ccddSDan Williams #undef C
398d35bc1bdSDan Williams 
39989a7301fSDan Williams void sci_phy_construct(
40085280955SDan Williams 	struct isci_phy *iphy,
401ffe191c9SDan Williams 	struct isci_port *iport,
402d35bc1bdSDan Williams 	u8 phy_index);
403d35bc1bdSDan Williams 
404ffe191c9SDan Williams struct isci_port *phy_get_non_dummy_port(struct isci_phy *iphy);
405d35bc1bdSDan Williams 
40689a7301fSDan Williams void sci_phy_set_port(
40785280955SDan Williams 	struct isci_phy *iphy,
408ffe191c9SDan Williams 	struct isci_port *iport);
409d35bc1bdSDan Williams 
41089a7301fSDan Williams enum sci_status sci_phy_initialize(
41185280955SDan Williams 	struct isci_phy *iphy,
412d35bc1bdSDan Williams 	struct scu_transport_layer_registers __iomem *transport_layer_registers,
413d35bc1bdSDan Williams 	struct scu_link_layer_registers __iomem *link_layer_registers);
414d35bc1bdSDan Williams 
41589a7301fSDan Williams enum sci_status sci_phy_start(
41685280955SDan Williams 	struct isci_phy *iphy);
417d35bc1bdSDan Williams 
41889a7301fSDan Williams enum sci_status sci_phy_stop(
41985280955SDan Williams 	struct isci_phy *iphy);
420d35bc1bdSDan Williams 
42189a7301fSDan Williams enum sci_status sci_phy_reset(
42285280955SDan Williams 	struct isci_phy *iphy);
423d35bc1bdSDan Williams 
42489a7301fSDan Williams void sci_phy_resume(
42585280955SDan Williams 	struct isci_phy *iphy);
426d35bc1bdSDan Williams 
42789a7301fSDan Williams void sci_phy_setup_transport(
42885280955SDan Williams 	struct isci_phy *iphy,
429d35bc1bdSDan Williams 	u32 device_id);
430d35bc1bdSDan Williams 
43189a7301fSDan Williams enum sci_status sci_phy_event_handler(
43285280955SDan Williams 	struct isci_phy *iphy,
433d35bc1bdSDan Williams 	u32 event_code);
434d35bc1bdSDan Williams 
43589a7301fSDan Williams enum sci_status sci_phy_frame_handler(
43685280955SDan Williams 	struct isci_phy *iphy,
437d35bc1bdSDan Williams 	u32 frame_index);
438d35bc1bdSDan Williams 
43989a7301fSDan Williams enum sci_status sci_phy_consume_power_handler(
44085280955SDan Williams 	struct isci_phy *iphy);
441d35bc1bdSDan Williams 
44289a7301fSDan Williams void sci_phy_get_sas_address(
44385280955SDan Williams 	struct isci_phy *iphy,
444d35bc1bdSDan Williams 	struct sci_sas_address *sas_address);
445d35bc1bdSDan Williams 
44689a7301fSDan Williams void sci_phy_get_attached_sas_address(
44785280955SDan Williams 	struct isci_phy *iphy,
448d35bc1bdSDan Williams 	struct sci_sas_address *sas_address);
449d35bc1bdSDan Williams 
45089a7301fSDan Williams void sci_phy_get_protocols(
45185280955SDan Williams 	struct isci_phy *iphy,
45289a7301fSDan Williams 	struct sci_phy_proto *protocols);
45385280955SDan Williams enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy);
454d35bc1bdSDan Williams 
455ce2b3261SDan Williams struct isci_host;
4564b33981aSDan Williams void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index);
4574b33981aSDan Williams int isci_phy_control(struct asd_sas_phy *phy, enum phy_func func, void *buf);
4586f231ddaSDan Williams 
4596f231ddaSDan Williams #endif /* !defined(_ISCI_PHY_H_) */
460