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.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
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.
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.
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.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
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
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.
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.
56 #ifndef _SCI_BASE_PHY_H_
57 #define _SCI_BASE_PHY_H_
60 * This file contains all of the structures, constants, and methods common to
61 * all phy object definitions.
66 #include "sci_base_state_machine.h"
69 * enum sci_base_phy_states - This enumeration depicts the standard states
70 * common to all phy state machine implementations.
74 enum sci_base_phy_states {
76 * Simply the initial state for the base domain state machine.
78 SCI_BASE_PHY_STATE_INITIAL,
81 * This state indicates that the phy has successfully been stopped.
82 * In this state no new IO operations are permitted on this phy.
83 * This state is entered from the INITIAL state.
84 * This state is entered from the STARTING state.
85 * This state is entered from the READY state.
86 * This state is entered from the RESETTING state.
88 SCI_BASE_PHY_STATE_STOPPED,
91 * This state indicates that the phy is in the process of becomming
92 * ready. In this state no new IO operations are permitted on this phy.
93 * This state is entered from the STOPPED state.
94 * This state is entered from the READY state.
95 * This state is entered from the RESETTING state.
97 SCI_BASE_PHY_STATE_STARTING,
100 * This state indicates the the phy is now ready. Thus, the user
101 * is able to perform IO operations utilizing this phy as long as it
102 * is currently part of a valid port.
103 * This state is entered from the STARTING state.
105 SCI_BASE_PHY_STATE_READY,
108 * This state indicates that the phy is in the process of being reset.
109 * In this state no new IO operations are permitted on this phy.
110 * This state is entered from the READY state.
112 SCI_BASE_PHY_STATE_RESETTING,
115 * Simply the final state for the base phy state machine.
117 SCI_BASE_PHY_STATE_FINAL,
119 SCI_BASE_PHY_MAX_STATES
124 * struct sci_base_phy - This structure defines all of the fields common to PHY
129 struct sci_base_phy {
131 * This field depicts the parent object (struct sci_base_object) for the phy.
133 struct sci_base_object parent;
136 * This field contains the information for the base phy state machine.
138 struct sci_base_state_machine state_machine;
141 typedef enum sci_status (*SCI_BASE_PHY_HANDLER_T)(
142 struct sci_base_phy *
146 * struct sci_base_phy_state_handler - This structure contains all of the state
147 * handler methods common to base phy state machines. Handler methods
148 * provide the ability to change the behavior for user requests or
149 * transitions depending on the state the machine is in.
153 struct sci_base_phy_state_handler {
155 * The start_handler specifies the method invoked when there is an
156 * attempt to start a phy.
158 SCI_BASE_PHY_HANDLER_T start_handler;
161 * The stop_handler specifies the method invoked when there is an
162 * attempt to stop a phy.
164 SCI_BASE_PHY_HANDLER_T stop_handler;
167 * The reset_handler specifies the method invoked when there is an
168 * attempt to reset a phy.
170 SCI_BASE_PHY_HANDLER_T reset_handler;
173 * The destruct_handler specifies the method invoked when attempting to
176 SCI_BASE_PHY_HANDLER_T destruct_handler;
181 * sci_base_phy_construct() - Construct the base phy
182 * @this_phy: This parameter specifies the base phy to be constructed.
183 * @state_table: This parameter specifies the table of state definitions to be
184 * utilized for the phy state machine.
187 static inline void sci_base_phy_construct(
188 struct sci_base_phy *base_phy,
189 const struct sci_base_state *state_table)
191 base_phy->parent.private = NULL;
192 sci_base_state_machine_construct(
193 &base_phy->state_machine,
196 SCI_BASE_PHY_STATE_INITIAL
199 sci_base_state_machine_start(
200 &base_phy->state_machine
205 #endif /* _SCI_BASE_PHY_H_ */