2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23 * The full GNU General Public License is included in this distribution
24 * in the file called LICENSE.GPL.
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
35 * * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * * Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in
39 * the documentation and/or other materials provided with the
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 #ifndef _SCI_BASE_PHY_H_
57 #define _SCI_BASE_PHY_H_
62 * @brief This file contains all of the structures, constants, and methods
63 * common to all phy object definitions.
70 #include <dev/isci/scil/sci_base_logger.h>
71 #include <dev/isci/scil/sci_base_state_machine.h>
72 #include <dev/isci/scil/sci_base_state_machine_logger.h>
75 * @enum SCI_BASE_PHY_STATES
77 * @brief This enumeration depicts the standard states common to all phy
78 * state machine implementations.
80 typedef enum _SCI_BASE_PHY_STATES
83 * Simply the initial state for the base domain state machine.
85 SCI_BASE_PHY_STATE_INITIAL,
88 * This state indicates that the phy has successfully been stopped.
89 * In this state no new IO operations are permitted on this phy.
90 * This state is entered from the INITIAL state.
91 * This state is entered from the STARTING state.
92 * This state is entered from the READY state.
93 * This state is entered from the RESETTING state.
95 SCI_BASE_PHY_STATE_STOPPED,
98 * This state indicates that the phy is in the process of becoming
99 * ready. In this state no new IO operations are permitted on this phy.
100 * This state is entered from the STOPPED state.
101 * This state is entered from the READY state.
102 * This state is entered from the RESETTING state.
104 SCI_BASE_PHY_STATE_STARTING,
107 * This state indicates the phy is now ready. Thus, the user
108 * is able to perform IO operations utilizing this phy as long as it
109 * is currently part of a valid port.
110 * This state is entered from the STARTING state.
112 SCI_BASE_PHY_STATE_READY,
115 * This state indicates that the phy is in the process of being reset.
116 * In this state no new IO operations are permitted on this phy.
117 * This state is entered from the READY state.
119 SCI_BASE_PHY_STATE_RESETTING,
122 * Simply the final state for the base phy state machine.
124 SCI_BASE_PHY_STATE_FINAL,
126 SCI_BASE_PHY_MAX_STATES
128 } SCI_BASE_PHY_STATES;
131 * @struct SCI_BASE_PHY
133 * @brief This structure defines all of the fields common to PHY objects.
135 typedef struct SCI_BASE_PHY
138 * This field depicts the parent object (SCI_BASE_OBJECT) for the phy.
140 SCI_BASE_OBJECT_T parent;
143 * This field contains the information for the base phy state machine.
145 SCI_BASE_STATE_MACHINE_T state_machine;
148 SCI_BASE_STATE_MACHINE_LOGGER_T state_machine_logger;
149 #endif // SCI_LOGGING
153 typedef SCI_STATUS (*SCI_BASE_PHY_HANDLER_T)(
158 * @struct SCI_BASE_PHY_STATE_HANDLER
160 * @brief This structure contains all of the state handler methods common to
161 * base phy state machines. Handler methods provide the ability
162 * to change the behavior for user requests or transitions depending
163 * on the state the machine is in.
165 typedef struct SCI_BASE_PHY_STATE_HANDLER
168 * The start_handler specifies the method invoked when there is an
169 * attempt to start a phy.
171 SCI_BASE_PHY_HANDLER_T start_handler;
174 * The stop_handler specifies the method invoked when there is an
175 * attempt to stop a phy.
177 SCI_BASE_PHY_HANDLER_T stop_handler;
180 * The reset_handler specifies the method invoked when there is an
181 * attempt to reset a phy.
183 SCI_BASE_PHY_HANDLER_T reset_handler;
186 * The destruct_handler specifies the method invoked when attempting to
189 SCI_BASE_PHY_HANDLER_T destruct_handler;
191 } SCI_BASE_PHY_STATE_HANDLER_T;
194 * @brief Construct the base phy
196 * @param[in] this_phy This parameter specifies the base phy to be
198 * @param[in] logger This parameter specifies the logger associated with
199 * this base phy object.
200 * @param[in] state_table This parameter specifies the table of state
201 * definitions to be utilized for the phy state machine.
205 void sci_base_phy_construct(
206 SCI_BASE_PHY_T * this_phy,
207 SCI_BASE_LOGGER_T * logger,
208 SCI_BASE_STATE_T * state_table
213 #endif // __cplusplus
215 #endif // _SCI_BASE_PHY_H_